5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/AlgFactory.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/SmartDataPtr.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/PropertyMgr.h"
57 Algorithm(name, pSvcLocator) {
59 declareProperty(
"debug",
m_debug =
false );
60 declareProperty(
"ReadBeamEFromDB", m_ReadBeamEFromDB =
false );
61 declareProperty(
"UseCalibBeamE", m_usecalibBeamE =
false );
62 declareProperty(
"UseVertexfit", m_usevertexfit =
false );
63 declareProperty(
"BeamE", m_beamE=2.015 );
64 declareProperty(
"DsList", m_decaylist =
"test.txt" );
65 declareProperty(
"UseVFRefine", m_useVFrefine =
true);
70 MsgStream log(
msgSvc(), name());
71 log << MSG::INFO <<
"in initialize()" <<endreq;
79 return StatusCode::SUCCESS;
84 MsgStream log(
msgSvc(), name());
85 log << MSG::INFO <<
"in finalize()" << endreq;
89 return StatusCode::SUCCESS;
92StatusCode DsReconstruction::registerEvtRecDTagCol(
94 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
96 if (sc != StatusCode::SUCCESS) {
97 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
104 MsgStream log(
msgSvc(), name());
105 log << MSG::INFO <<
"in execute()" << endreq;
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
113 int event= eventHeader->eventNumber();
119 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
120 <<
" " << eventHeader->eventNumber() << endreq;
121 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
122 << recEvent->totalCharged() <<
" , "
123 << recEvent->totalNeutral() <<
" , "
124 << recEvent->totalTracks() <<endreq;
133 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
135 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
136 return StatusCode::FAILURE;
139 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
140 if ( ! recEtaToGGCol ) {
141 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
142 return StatusCode::FAILURE;
146 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
147 if ( ! recVeeVertexCol ) {
148 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
149 return StatusCode::FAILURE;
155 log << MSG::FATAL <<
"EvtRecDTagCol is not registered yet" << endreq;
156 return StatusCode::FAILURE;
161 Hep3Vector xorigin(0,0,0);
163 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
168 xorigin.setX(vertex[0]);
169 xorigin.setY(vertex[1]);
170 xorigin.setZ(vertex[2]);
198 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
202 map<EvtRecVeeVertex*, vector< double > > fitinfo;
203 for(
CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
215 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
218 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
227 int run = eventHeader->runNumber();
228 m_ievt = eventHeader->eventNumber();
229 m_nChrg = recEvent->totalCharged();
230 m_nNeu = recEvent->totalNeutral();
231 m_nPion = pionList.
size();
232 m_nKaon = kaonList.
size();
233 m_nPi0 = pi0List.size();
234 m_nKs = ksList.size();
241 if(m_ReadBeamEFromDB && m_irun!=run){
245 m_beamE=m_readDb.
getbeamE(m_irun,m_beamE);
250 double ebeam=m_beamE;
257 for(
int list=0;list<chanlist.size();list++){
259 string channel=chanlist[list];
274 if(channel==
"DstoKsK") {
276 numchan.push_back(5);
277 numchan.push_back(1);
278 decaylist=ksList* kaonList.
plus();
280 else if(channel==
"DstoKKPi") {
282 numchan.push_back(1);
283 numchan.push_back(1);
284 numchan.push_back(2);
285 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus();
287 else if(channel==
"DstoKsKPi0") {
289 numchan.push_back(5);
290 numchan.push_back(1);
291 numchan.push_back(3);
292 decaylist=ksList* kaonList.
plus()* pi0List;
294 else if(channel==
"DstoKsKsPi") {
296 numchan.push_back(5);
297 numchan.push_back(5);
298 numchan.push_back(2);
299 decaylist=ksList* ksList* pionList.
plus();
301 else if(channel==
"DstoKKPiPi0") {
303 numchan.push_back(1);
304 numchan.push_back(1);
305 numchan.push_back(2);
306 numchan.push_back(3);
307 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pi0List;
309 else if(channel==
"DstoKsKplusPiPi") {
311 numchan.push_back(5);
312 numchan.push_back(1);
313 numchan.push_back(2);
314 numchan.push_back(2);
315 decaylist=ksList* kaonList.
plus()* pionList.
plus()* pionList.
minus();
317 else if(channel==
"DstoKsKminusPiPi") {
319 numchan.push_back(5);
320 numchan.push_back(1);
321 numchan.push_back(2);
322 numchan.push_back(2);
323 decaylist=ksList* kaonList.
minus()* pionList.
plus()* pionList.
plus();
325 else if(channel==
"DstoKKPiPiPi") {
327 numchan.push_back(1);
328 numchan.push_back(1);
329 numchan.push_back(2);
330 numchan.push_back(2);
331 numchan.push_back(2);
334 else if(channel==
"DstoPiPi0") {
336 numchan.push_back(2);
337 numchan.push_back(3);
338 decaylist=pionList.
plus()* pi0List;
340 else if(channel==
"DstoPiPiPi") {
342 numchan.push_back(2);
343 numchan.push_back(2);
344 numchan.push_back(2);
345 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus();
347 else if(channel==
"DstoPiPiPiPi0") {
349 numchan.push_back(2);
350 numchan.push_back(2);
351 numchan.push_back(2);
352 numchan.push_back(3);
353 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
355 else if(channel==
"DstoPiPiPiPiPi") {
357 numchan.push_back(2);
358 numchan.push_back(2);
359 numchan.push_back(2);
360 numchan.push_back(2);
361 numchan.push_back(2);
364 else if(channel==
"DstoPiPiPiPiPiPi0") {
366 numchan.push_back(2);
367 numchan.push_back(2);
368 numchan.push_back(2);
369 numchan.push_back(2);
370 numchan.push_back(2);
371 numchan.push_back(3);
374 else if(channel==
"DstoPiPiPiPi0Pi0") {
376 numchan.push_back(2);
377 numchan.push_back(2);
378 numchan.push_back(2);
379 numchan.push_back(3);
380 numchan.push_back(3);
381 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List* pi0List;
383 else if(channel==
"DstoPiEta") {
385 numchan.push_back(2);
386 numchan.push_back(4);
387 decaylist=pionList.
plus()* etaList;
389 else if(channel==
"DstoPiEtaPiPiPi0") {
391 numchan.push_back(2);
392 numchan.push_back(9);
394 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
395 decaylist=pionList.
plus()* EtaList;
397 else if(channel==
"DstoPiPi0Eta") {
399 numchan.push_back(2);
400 numchan.push_back(3);
401 numchan.push_back(4);
402 decaylist=pionList.
plus()* pi0List* etaList;
404 else if(channel==
"DstoPiPi0EtaPiPiPi0") {
406 numchan.push_back(2);
407 numchan.push_back(3);
408 numchan.push_back(9);
410 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
411 decaylist=pionList.
plus()* pi0List* EtaList;
413 else if(channel==
"DstoPiPiPiEta") {
415 numchan.push_back(2);
416 numchan.push_back(2);
417 numchan.push_back(2);
418 numchan.push_back(4);
419 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* etaList;
421 else if(channel==
"DstoPiPiPiEtaPiPiPi0") {
423 numchan.push_back(2);
424 numchan.push_back(2);
425 numchan.push_back(2);
426 numchan.push_back(9);
428 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
429 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* EtaList;
431 else if(channel==
"DstoPiEPPiPiEta") {
433 numchan.push_back(2);
434 numchan.push_back(6);
436 epList=pionList.
plus()* pionList.
minus()* etaList;
437 decaylist=pionList.
plus()* epList;
439 else if(channel==
"DstoPiPi0EPPiPiEta") {
441 numchan.push_back(2);
442 numchan.push_back(3);
443 numchan.push_back(6);
445 epList=pionList.
plus()* pionList.
minus()* etaList;
446 decaylist=pionList.
plus()* pi0List* epList;
448 else if(channel==
"DstoPiEPPiPiEtaPiPiPi0") {
450 numchan.push_back(2);
451 numchan.push_back(8);
453 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
455 EtapList=pionList.
plus()* pionList.
minus()* EtaList;
456 decaylist=pionList.
plus()* EtapList;
458 else if(channel==
"DstoPiPi0EPPiPiEtaPiPiPi0") {
460 numchan.push_back(2);
461 numchan.push_back(3);
462 numchan.push_back(8);
464 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
466 EtapList=pionList.
plus()* pionList.
minus()* EtaList;
467 decaylist=pionList.
plus()* pi0List* EtapList;
470 else if(channel==
"DstoPiEPRhoGam") {
472 numchan.push_back(2);
473 numchan.push_back(7);
475 rhoList=pionList.
plus()* pionList.
minus();
477 epList=rhoList* photonList;
478 decaylist=pionList.
plus()* epList;
480 else if(channel==
"DstoPiPi0EPRhoGam") {
482 numchan.push_back(2);
483 numchan.push_back(3);
484 numchan.push_back(7);
486 rhoList=pionList.
plus()* pionList.
minus();
488 epList=rhoList* photonList;
489 decaylist=pionList.
plus()* pi0List* epList;
491 else if(channel==
"DstoKsPi") {
493 numchan.push_back(5);
494 numchan.push_back(2);
495 decaylist=ksList* pionList.
plus();
497 else if(channel==
"DstoKsPiPi0") {
499 numchan.push_back(5);
500 numchan.push_back(2);
501 numchan.push_back(3);
502 decaylist=ksList* pionList.
plus()* pi0List;
504 else if(channel==
"DstoKPiPi") {
506 numchan.push_back(1);
507 numchan.push_back(2);
508 numchan.push_back(2);
509 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus();
511 else if(channel==
"DstoKPiPiPi0") {
513 numchan.push_back(1);
514 numchan.push_back(2);
515 numchan.push_back(2);
516 numchan.push_back(3);
517 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
519 else if(channel==
"DstoKKK") {
521 numchan.push_back(1);
522 numchan.push_back(1);
523 numchan.push_back(1);
524 decaylist=kaonList.
minus()* kaonList.
plus()* kaonList.
plus();
535 vector<int> trackid, showerid;
536 vector<int> kaonid, pionid;
537 int numofchildren=numchan.size()-1;
539 for(
int i=0; i< numofchildren;i++){
541 const CDCandidate& daughter=(*it).particle().child(i);
545 trackid.push_back(track->
trackId());
546 kaonid.push_back(track->
trackId());
548 else if(numchan[i+1]==2){
550 trackid.push_back(track->
trackId());
551 pionid.push_back(track->
trackId());
553 else if ( numchan[i+1]==3){
556 showerid.push_back(hiEnGamma->
trackId());
557 showerid.push_back(loEnGamma->
trackId());
559 else if ( numchan[i+1]==4){
562 showerid.push_back(hiEnGamma->
trackId());
563 showerid.push_back(loEnGamma->
trackId());
565 else if ( numchan[i+1]==5){
569 recDTag->
addToFitInfo(aKsCand->
mass(),fitinfo[aKsCand][0],fitinfo[aKsCand][1],fitinfo[aKsCand][2]);
573 trackid.push_back(pion1Trk->
trackId());
574 trackid.push_back(pion2Trk->
trackId());
576 else if (numchan[i+1]==6){
585 trackid.push_back(apiontrk->
trackId());
586 trackid.push_back(spiontrk->
trackId());
587 showerid.push_back(hiEnGamma->
trackId());
588 showerid.push_back(loEnGamma->
trackId());
591 else if (numchan[i+1]==7){
602 trackid.push_back(apiontrk->
trackId());
603 trackid.push_back(spiontrk->
trackId());
604 showerid.push_back(gammatrk->
trackId());
607 else if (numchan[i+1]==8){
623 trackid.push_back(apiontrk->
trackId());
624 trackid.push_back(spiontrk->
trackId());
625 trackid.push_back(e0piontrk->
trackId());
626 trackid.push_back(e1piontrk->
trackId());
627 showerid.push_back(hiEnGamma->
trackId());
628 showerid.push_back(loEnGamma->
trackId());
631 else if (numchan[i+1]==9){
640 trackid.push_back(apiontrk->
trackId());
641 trackid.push_back(spiontrk->
trackId());
642 showerid.push_back(hiEnGamma->
trackId());
643 showerid.push_back(loEnGamma->
trackId());
652 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
653 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
657 if(m_debug) cout<<
"beforevfit:"<<endl;
659 HepLorentzVector p4change_vfit;
662 p4change_vfit=util.
vfitref(channel, kaonid, pionid, xorigin, charged_begin);
664 p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
667 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
679 recDTagCol->push_back(recDTag);
689 return StatusCode::SUCCESS;
695 double mass = (*it).particle().mass();
696 int charge= (*it).particle().charge();
697 HepLorentzVector
p4((*it).particle().momentum(), (*it).particle().energy());
702 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
703 double deltaE_CMS =
p4.t() -
ebeam;
705 if((*it).particle().userTag()==1)
722 vector<EvtRecTrackIterator> trktemp;
723 vector<EvtRecTrackIterator> shrtemp;
728 bool isothertrack=
true;
729 for(
int i=0; i<trackid.size(); i++){
730 if( (*trk)->trackId()==trackid[i] ){
731 trktemp.push_back(trk);
739 for(
int i=0; i<trackid.size();i++){
740 for(
int j=0; j<trktemp.size(); j++){
742 if( (*trk)->trackId()==trackid[i])
750 bool isothershower=
true;
751 for(
int i=0; i<showerid.size(); i++){
752 if( (*shr)->trackId()==showerid[i] ){
753 shrtemp.push_back(shr);
762 for(
int i=0; i<showerid.size();i++){
763 for(
int j=0; j<shrtemp.size(); j++){
765 if( (*shr)->trackId()==showerid[i])
775 bool iskaon=
false,ispion=
false;
781 recDTag->
addKaonId( (*kit).particle().track() );
785 recDTag->
addPionId( (*pit).particle().track() );
835 inFile.open(filename.c_str());
837 cout <<
"Unable to open decay list file";
841 while (inFile >> channel) {
842 temp.push_back(channel);
void dc_fill(DCFillableChargedList< Charged > &aFillableList, WitnessIterator first, WitnessIterator last)
ObjectVector< EvtRecDTag > EvtRecDTagCol
EvtRecTrackCol::iterator EvtRecTrackIterator
LocalEptoPiPiEta3PiSelector eptoPiPiEta3PiSelector
LocalEptoPiPiEtaSelector eptoPiPiEtaSelector
LocalEptoRhoGamSelector eptoRhoGamSelector
LocalEtatoGGSelector etatoGGSelector
LocalEtatoPiPiPi0Selector etatoPiPiPi0Selector
LocalKaonSelector kaonSelector
LocalKsSelector ksSelector
LocalPhotonSelector photonSelector
LocalPi0Selector pi0Selector
LocalPionSelector pionSelector
LocalRhotoPiPiSelector rhotoPiPiSelector
virtual const DecayEvidence & decay() const
virtual const EvtRecTrack * photon() const
virtual const EvtRecTrack * track() const
virtual const EvtRecVeeVertex * navKshort() const
virtual const EvtRecPi0 * navPi0() const
virtual const EvtRecEtaToGG * navEta() const
const CDCandidate & child(unsigned int aPosition) const
vector< string > getlist(string &filename)
void savetrack(vector< int >, vector< int >, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecDTag *)
void pidtag(vector< int >, vector< int >, CDChargedKaonList &, CDChargedPionList &, EvtRecDTag *)
void saveDsInfo(CDDecayList::iterator, double, int, EvtRecDTag *)
void setbeta(Hep3Vector beta)
void setebeam(double ebeam)
@ kDstoPiEPPiPiEtaPiPiPi0
@ kDstoPiPi0EPPiPiEtaPiPiPi0
void addOtherTrack(const SmartRef< EvtRecTrack > track)
void settype(SelType type)
void setdecayMode(DecayMode decayMode)
HepLorentzVector p4() const
void setp4(HepLorentzVector p4)
void setmass(double mass)
void addToFitInfo(double ksmass, double chi2, double length, double error)
void addOtherShower(const SmartRef< EvtRecTrack > shower)
void addKaonId(const SmartRef< EvtRecTrack > kaonId)
void setdeltaE(double deltaE)
void setcharge(int charge)
void addPionId(const SmartRef< EvtRecTrack > pionId)
void setbeamE(double beamE)
void addShower(const SmartRef< EvtRecTrack > shower)
void setnumOfChildren(int numOfChildren)
void addTrack(const SmartRef< EvtRecTrack > track)
const EvtRecTrack * hiEnGamma() const
const EvtRecTrack * loEnGamma() const
const EvtRecTrack * loEnGamma() const
const EvtRecTrack * hiEnGamma() const
SmartRef< EvtRecTrack > & daughter(int i)
virtual bool isVertexValid()=0
virtual double * PrimaryVertex()=0
void setpidtype(int type)
void setpidtype(int type)
bool setcalib(bool calib)
CLHEP::Hep3Vector getbeta()
ChosenChargeList< Charged, CandidateClass > & plus() const
ChosenChargeList< Charged, CandidateClass > & minus() const
iterator particle_begin()
virtual iterator particle_begin()
virtual iterator particle_end()
HepLorentzVector vfitref(string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
vector< double > SecondaryVFitref(EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
HepLorentzVector vfit(string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
vector< double > SecondaryVFit(EvtRecVeeVertex *ks, IVertexDbSvc *vtxsvc)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecDTagCol
_EXTERN_ std::string EvtRecTrackCol
double double double * p4