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"
58Algorithm(name, pSvcLocator) {
60 declareProperty(
"debug",
m_debug =
false );
61 declareProperty(
"ReadBeamEFromDB", m_ReadBeamEFromDB =
false );
62 declareProperty(
"UseCalibBeamE", m_usecalibBeamE =
false );
63 declareProperty(
"UseVertexfit", m_usevertexfit =
false );
64 declareProperty(
"BeamE", m_beamE = 1.8865 );
65 declareProperty(
"D0List", m_decaylist =
"test.txt" );
66 declareProperty(
"UseVFRefine", m_useVFrefine =
true);
71 MsgStream log(
msgSvc(), name());
72 log << MSG::INFO <<
"in initialize()" <<endreq;
81 return StatusCode::SUCCESS;
86 MsgStream log(
msgSvc(), name());
87 log << MSG::INFO <<
"in finalize()" << endreq;
91 return StatusCode::SUCCESS;
94StatusCode NeutralDReconstruction::registerEvtRecDTagCol(
96 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
98 if (sc != StatusCode::SUCCESS) {
99 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
106 MsgStream log(
msgSvc(), name());
107 log << MSG::INFO <<
"in execute()" << endreq;
114 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
115 int event= eventHeader->eventNumber();
121 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
122 <<
" " << eventHeader->eventNumber() << endreq;
123 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
124 << recEvent->totalCharged() <<
" , "
125 << recEvent->totalNeutral() <<
" , "
126 << recEvent->totalTracks() <<endreq;
135 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
137 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
138 return StatusCode::FAILURE;
143 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
144 if ( ! recEtaToGGCol ) {
145 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
146 return StatusCode::FAILURE;
150 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
151 if ( ! recVeeVertexCol ) {
152 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
153 return StatusCode::FAILURE;
159 log << MSG::FATAL <<
"EvtRecDTagCol is not registered in TDS" << endreq;
160 return StatusCode::FAILURE;
164 Hep3Vector xorigin(0,0,0);
166 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
171 xorigin.setX(vertex[0]);
172 xorigin.setY(vertex[1]);
173 xorigin.setZ(vertex[2]);
201 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
204 map<EvtRecVeeVertex*, vector< double > > fitinfo;
205 for(
CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
217 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
220 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
229 int run = eventHeader->runNumber();
230 m_ievt = eventHeader->eventNumber();
231 m_nChrg = recEvent->totalCharged();
232 m_nNeu = recEvent->totalNeutral();
233 m_nPion = pionList.
size();
234 m_nKaon = kaonList.
size();
235 m_nPi0 = pi0List.size();
236 m_nKs = ksList.size();
242 if(m_ReadBeamEFromDB && m_irun!=run){
246 m_beamE=m_readDb.
getbeamE(m_irun, m_beamE);
252 double ebeam=m_beamE;
260 for(
int list=0;list<chanlist.size();list++){
262 string channel=chanlist[list];
268 bool isFlavorMode=
false;
275 if(channel==
"D0toKPi") {
277 numchan.push_back(1);
278 numchan.push_back(2);
279 decaylist=kaonList.
minus() * pionList.
plus();
282 else if(channel==
"D0toKPiPi0"){
284 numchan.push_back(1);
285 numchan.push_back(2);
286 numchan.push_back(3);
287 decaylist=kaonList.
minus() * pionList.
plus() * pi0List;
290 else if(channel==
"D0toKPiPi0Pi0"){
292 numchan.push_back(1);
293 numchan.push_back(2);
294 numchan.push_back(3);
295 numchan.push_back(3);
296 decaylist=kaonList.
minus() * pionList.
plus() * pi0List * pi0List;
299 else if(channel==
"D0toKPiPiPi"){
301 numchan.push_back(1);
302 numchan.push_back(2);
303 numchan.push_back(2);
304 numchan.push_back(2);
308 else if(channel==
"D0toKPiPiPiPi0"){
310 numchan.push_back(1);
311 numchan.push_back(2);
312 numchan.push_back(2);
313 numchan.push_back(2);
314 numchan.push_back(3);
315 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
318 else if(channel==
"D0toKPiEta"){
320 numchan.push_back(1);
321 numchan.push_back(2);
322 numchan.push_back(4);
323 decaylist=kaonList.
minus() * pionList.
plus() * etaList;
326 else if(channel==
"D0toKsKPi"){
328 numchan.push_back(5);
329 numchan.push_back(1);
330 numchan.push_back(2);
331 decaylist=ksList* kaonList.
minus()* pionList.
plus();
333 else if(channel==
"D0toKsKPiPi0"){
335 numchan.push_back(5);
336 numchan.push_back(1);
337 numchan.push_back(2);
338 numchan.push_back(3);
339 decaylist=ksList* kaonList.
minus() * pionList.
plus()* pi0List;
341 else if(channel==
"D0toKsPiPi"){
343 numchan.push_back(5);
344 numchan.push_back(2);
345 numchan.push_back(2);
346 decaylist=ksList* pionList.
plus()* pionList.
minus();
348 else if(channel==
"D0toKsPiPiPi0"){
350 numchan.push_back(5);
351 numchan.push_back(2);
352 numchan.push_back(2);
353 numchan.push_back(3);
354 decaylist=ksList* pionList.
plus()* pionList.
minus()* pi0List;
356 else if(channel==
"D0toKsPi0"){
358 numchan.push_back(5);
359 numchan.push_back(3);
360 decaylist=ksList* pi0List;
362 else if(channel==
"D0toPiPiPi0"){
364 numchan.push_back(2);
365 numchan.push_back(2);
366 numchan.push_back(3);
367 decaylist=pionList.
plus()* pionList.
minus()* pi0List;
369 else if(channel==
"D0toPiPi"){
371 numchan.push_back(2);
372 numchan.push_back(2);
373 decaylist=pionList.
plus()* pionList.
minus();
375 else if(channel==
"D0toKK"){
377 numchan.push_back(1);
378 numchan.push_back(1);
379 decaylist=kaonList.
minus()* kaonList.
plus();
381 else if(channel==
"D0toKKPi0"){
383 numchan.push_back(1);
384 numchan.push_back(1);
385 numchan.push_back(3);
386 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List;
388 else if(channel==
"D0toPi0Pi0"){
390 numchan.push_back(3);
391 numchan.push_back(3);
392 decaylist=pi0List* pi0List;
394 else if(channel==
"D0toKsKs"){
396 numchan.push_back(5);
397 numchan.push_back(5);
398 decaylist=ksList* ksList;
400 else if(channel==
"D0toKsKsPi0"){
402 numchan.push_back(5);
403 numchan.push_back(5);
404 numchan.push_back(3);
405 decaylist=ksList* ksList* pi0List;
407 else if(channel==
"D0toKsPi0Pi0"){
409 numchan.push_back(5);
410 numchan.push_back(3);
411 numchan.push_back(3);
412 decaylist=ksList* pi0List* pi0List;
414 else if(channel==
"D0toKsKK"){
416 numchan.push_back(5);
417 numchan.push_back(1);
418 numchan.push_back(1);
419 decaylist=ksList* kaonList.
minus()* kaonList.
plus();
421 else if(channel==
"D0toKsEta"){
423 numchan.push_back(5);
424 numchan.push_back(4);
425 decaylist=ksList* etaList;
427 else if(channel==
"D0toPi0Pi0Pi0"){
429 numchan.push_back(3);
430 numchan.push_back(3);
431 numchan.push_back(3);
432 decaylist=pi0List* pi0List* pi0List;
434 else if(channel==
"D0toKsKsKs"){
436 numchan.push_back(5);
437 numchan.push_back(5);
438 numchan.push_back(5);
439 decaylist=ksList* ksList* ksList;
441 else if(channel==
"D0toPiPiPiPi"){
443 numchan.push_back(2);
444 numchan.push_back(2);
445 numchan.push_back(2);
446 numchan.push_back(2);
449 else if(channel==
"D0toPiPiPi0Pi0"){
451 numchan.push_back(2);
452 numchan.push_back(2);
453 numchan.push_back(3);
454 numchan.push_back(3);
455 decaylist=pionList.
plus()* pionList.
minus()* pi0List* pi0List;
457 else if(channel==
"D0toKKPiPi"){
459 numchan.push_back(1);
460 numchan.push_back(1);
461 numchan.push_back(2);
462 numchan.push_back(2);
465 else if(channel==
"D0toKKPi0Pi0"){
467 numchan.push_back(1);
468 numchan.push_back(1);
469 numchan.push_back(3);
470 numchan.push_back(3);
471 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List* pi0List;
473 else if(channel==
"D0toKsKsPiPi"){
475 numchan.push_back(5);
476 numchan.push_back(5);
477 numchan.push_back(2);
478 numchan.push_back(2);
479 decaylist=ksList* ksList* pionList.
plus()* pionList.
minus();
481 else if(channel==
"D0toPiPiPiPiPi0"){
483 numchan.push_back(2);
484 numchan.push_back(2);
485 numchan.push_back(2);
486 numchan.push_back(2);
487 numchan.push_back(3);
488 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus()* pi0List;
490 else if(channel==
"D0toKsPiPiPiPi"){
492 numchan.push_back(5);
493 numchan.push_back(2);
494 numchan.push_back(2);
495 numchan.push_back(2);
496 numchan.push_back(2);
497 decaylist=ksList* pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus();
499 else if(channel==
"D0toKKPiPiPi0"){
501 numchan.push_back(1);
502 numchan.push_back(1);
503 numchan.push_back(2);
504 numchan.push_back(2);
505 numchan.push_back(3);
506 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
508 else if(channel==
"D0toKsPi0Eta"){
510 numchan.push_back(5);
511 numchan.push_back(3);
512 numchan.push_back(4);
513 decaylist=ksList* pi0List* etaList;
515 else if(channel==
"D0toKsEPPiPiEta"){
517 numchan.push_back(5);
518 numchan.push_back(6);
520 epList=pionList.
plus()* pionList.
minus()* etaList;
521 decaylist= ksList* epList;
523 else if(channel==
"D0toKsEPRhoGam"){
525 numchan.push_back(5);
526 numchan.push_back(7);
528 rhoList=pionList.
plus()* pionList.
minus();
530 epList=rhoList* photonList;
531 decaylist= ksList* epList;
533 else if(channel==
"D0toKsPi0Pi0Pi0"){
535 numchan.push_back(5);
536 numchan.push_back(3);
537 numchan.push_back(3);
538 numchan.push_back(3);
539 decaylist=ksList* pi0List* pi0List* pi0List;
552 vector<int> trackid, showerid;
553 vector<int> kaonid, pionid;
555 int numofchildren=numchan.size()-1;
557 for(
int i=0; i< numofchildren;i++){
559 const CDCandidate& daughter=(*it).particle().child(i);
560 if(isFlavorMode && i==0)
565 trackid.push_back(track->
trackId());
566 kaonid.push_back(track->
trackId());
568 else if(numchan[i+1]==2){
570 trackid.push_back(track->
trackId());
571 pionid.push_back(track->
trackId());
573 else if ( numchan[i+1]==3){
576 showerid.push_back(hiEnGamma->
trackId());
577 showerid.push_back(loEnGamma->
trackId());
579 else if ( numchan[i+1]==4){
582 showerid.push_back(hiEnGamma->
trackId());
583 showerid.push_back(loEnGamma->
trackId());
585 else if ( numchan[i+1]==5){
588 recDTag->
addToFitInfo(aKsCand->
mass(),fitinfo[aKsCand][0],fitinfo[aKsCand][1],fitinfo[aKsCand][2]);
592 trackid.push_back(pion1Trk->
trackId());
593 trackid.push_back(pion2Trk->
trackId());
595 else if (numchan[i+1]==6){
604 trackid.push_back(apiontrk->
trackId());
605 trackid.push_back(spiontrk->
trackId());
606 showerid.push_back(hiEnGamma->
trackId());
607 showerid.push_back(loEnGamma->
trackId());
610 else if (numchan[i+1]==7){
622 trackid.push_back(apiontrk->
trackId());
623 trackid.push_back(spiontrk->
trackId());
624 showerid.push_back(gammatrk->
trackId());
633 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
634 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
637 if(m_debug) cout<<
"beforevfit:"<<endl;
639 HepLorentzVector p4change_vfit;
642 p4change_vfit=util.
vfitref(channel, kaonid, pionid, xorigin, charged_begin);
644 p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
647 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
658 recDTagCol->push_back(recDTag);
667 return StatusCode::SUCCESS;
672 double mass = (*it).particle().mass();
673 HepLorentzVector
p4((*it).particle().momentum(), (*it).particle().energy());
678 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
679 double deltaE_CMS =
p4.t() -
ebeam;
681 int tag=(*it).particle().userTag();
699 vector<EvtRecTrackIterator> trktemp;
700 vector<EvtRecTrackIterator> shrtemp;
705 bool isothertrack=
true;
706 for(
int i=0; i<trackid.size(); i++){
707 if( (*trk)->trackId()==trackid[i] ){
708 trktemp.push_back(trk);
716 for(
int i=0; i<trackid.size();i++){
717 for(
int j=0; j<trktemp.size(); j++){
719 if( (*trk)->trackId()==trackid[i])
727 bool isothershower=
true;
728 for(
int i=0; i<showerid.size(); i++){
729 if( (*shr)->trackId()==showerid[i] ){
730 shrtemp.push_back(shr);
739 for(
int i=0; i<showerid.size();i++){
740 for(
int j=0; j<shrtemp.size(); j++){
742 if( (*shr)->trackId()==showerid[i])
753 bool iskaon=
false,ispion=
false;
759 recDTag->
addKaonId( (*kit).particle().track() );
763 recDTag->
addPionId( (*pit).particle().track() );
815 inFile.open(filename.c_str());
817 cout <<
"Unable to open decay list file";
821 while (inFile >> channel) {
822 temp.push_back(channel);
void dc_fill(DCFillableChargedList< Charged > &aFillableList, WitnessIterator first, WitnessIterator last)
ObjectVector< EvtRecDTag > EvtRecDTagCol
EvtRecTrackCol::iterator EvtRecTrackIterator
LocalEptoPiPiEtaSelector eptoPiPiEtaSelector
LocalEptoRhoGamSelector eptoRhoGamSelector
LocalEtatoGGSelector etatoGGSelector
LocalKaonSelector kaonSelector
LocalKsSelector ksSelector
LocalPhotonSelector photonSelector
LocalPi0Selector pi0Selector
LocalPionSelector pionSelector
LocalRhotoPiPiSelector rhotoPiPiSelector
NeutralDSelector neutralDSelector
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
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)
void savetrack(vector< int >, vector< int >, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecDTag *)
vector< string > getlist(string &filename)
void pidtag(vector< int >, vector< int >, CDChargedKaonList &, CDChargedPionList &, EvtRecDTag *)
void saveD0Info(CDDecayList::iterator, double, int, int, EvtRecDTag *)
void setbeta(Hep3Vector beta)
void setebeam(double ebeam)
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