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" );
70 MsgStream log(
msgSvc(), name());
71 log << MSG::INFO <<
"in initialize()" <<endreq;
80 return StatusCode::SUCCESS;
85 MsgStream log(
msgSvc(), name());
86 log << MSG::INFO <<
"in finalize()" << endreq;
90 return StatusCode::SUCCESS;
93StatusCode NeutralDReconstruction::registerEvtRecDTagCol(
95 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
97 if (sc != StatusCode::SUCCESS) {
98 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
105 MsgStream log(
msgSvc(), name());
106 log << MSG::INFO <<
"in execute()" << endreq;
113 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
114 int event= eventHeader->eventNumber();
120 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
121 <<
" " << eventHeader->eventNumber() << endreq;
122 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
123 << recEvent->totalCharged() <<
" , "
124 << recEvent->totalNeutral() <<
" , "
125 << recEvent->totalTracks() <<endreq;
134 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
136 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
137 return StatusCode::FAILURE;
142 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
143 if ( ! recEtaToGGCol ) {
144 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
145 return StatusCode::FAILURE;
149 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
150 if ( ! recVeeVertexCol ) {
151 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
152 return StatusCode::FAILURE;
158 log << MSG::FATAL <<
"EvtRecDTagCol is not registered in TDS" << endreq;
159 return StatusCode::FAILURE;
163 Hep3Vector xorigin(0,0,0);
165 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
170 xorigin.setX(vertex[0]);
171 xorigin.setY(vertex[1]);
172 xorigin.setZ(vertex[2]);
199 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
202 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
205 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
214 int run = eventHeader->runNumber();
215 m_ievt = eventHeader->eventNumber();
216 m_nChrg = recEvent->totalCharged();
217 m_nNeu = recEvent->totalNeutral();
218 m_nPion = pionList.
size();
219 m_nKaon = kaonList.
size();
220 m_nPi0 = pi0List.size();
221 m_nKs = ksList.size();
227 if(m_ReadBeamEFromDB && m_irun!=run){
231 m_beamE=m_readDb.
getbeamE(m_irun, m_beamE);
237 double ebeam=m_beamE;
245 for(
int list=0;list<chanlist.size();list++){
247 string channel=chanlist[list];
253 bool isFlavorMode=
false;
260 if(channel==
"D0toKPi") {
262 numchan.push_back(1);
263 numchan.push_back(2);
264 decaylist=kaonList.
minus() * pionList.
plus();
267 else if(channel==
"D0toKPiPi0"){
269 numchan.push_back(1);
270 numchan.push_back(2);
271 numchan.push_back(3);
272 decaylist=kaonList.
minus() * pionList.
plus() * pi0List;
275 else if(channel==
"D0toKPiPi0Pi0"){
277 numchan.push_back(1);
278 numchan.push_back(2);
279 numchan.push_back(3);
280 numchan.push_back(3);
281 decaylist=kaonList.
minus() * pionList.
plus() * pi0List * pi0List;
284 else if(channel==
"D0toKPiPiPi"){
286 numchan.push_back(1);
287 numchan.push_back(2);
288 numchan.push_back(2);
289 numchan.push_back(2);
293 else if(channel==
"D0toKPiPiPiPi0"){
295 numchan.push_back(1);
296 numchan.push_back(2);
297 numchan.push_back(2);
298 numchan.push_back(2);
299 numchan.push_back(3);
300 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
303 else if(channel==
"D0toKPiEta"){
305 numchan.push_back(1);
306 numchan.push_back(2);
307 numchan.push_back(4);
308 decaylist=kaonList.
minus() * pionList.
plus() * etaList;
311 else if(channel==
"D0toKsKPi"){
313 numchan.push_back(5);
314 numchan.push_back(1);
315 numchan.push_back(2);
316 decaylist=ksList* kaonList.
minus()* pionList.
plus();
318 else if(channel==
"D0toKsKPiPi0"){
320 numchan.push_back(5);
321 numchan.push_back(1);
322 numchan.push_back(2);
323 numchan.push_back(3);
324 decaylist=ksList* kaonList.
minus() * pionList.
plus()* pi0List;
326 else if(channel==
"D0toKsPiPi"){
328 numchan.push_back(5);
329 numchan.push_back(2);
330 numchan.push_back(2);
331 decaylist=ksList* pionList.
plus()* pionList.
minus();
333 else if(channel==
"D0toKsPiPiPi0"){
335 numchan.push_back(5);
336 numchan.push_back(2);
337 numchan.push_back(2);
338 numchan.push_back(3);
339 decaylist=ksList* pionList.
plus()* pionList.
minus()* pi0List;
341 else if(channel==
"D0toKsPi0"){
343 numchan.push_back(5);
344 numchan.push_back(3);
345 decaylist=ksList* pi0List;
347 else if(channel==
"D0toPiPiPi0"){
349 numchan.push_back(2);
350 numchan.push_back(2);
351 numchan.push_back(3);
352 decaylist=pionList.
plus()* pionList.
minus()* pi0List;
354 else if(channel==
"D0toPiPi"){
356 numchan.push_back(2);
357 numchan.push_back(2);
358 decaylist=pionList.
plus()* pionList.
minus();
360 else if(channel==
"D0toKK"){
362 numchan.push_back(1);
363 numchan.push_back(1);
364 decaylist=kaonList.
minus()* kaonList.
plus();
366 else if(channel==
"D0toKKPi0"){
368 numchan.push_back(1);
369 numchan.push_back(1);
370 numchan.push_back(3);
371 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List;
373 else if(channel==
"D0toPi0Pi0"){
375 numchan.push_back(3);
376 numchan.push_back(3);
377 decaylist=pi0List* pi0List;
379 else if(channel==
"D0toKsKs"){
381 numchan.push_back(5);
382 numchan.push_back(5);
383 decaylist=ksList* ksList;
385 else if(channel==
"D0toKsKsPi0"){
387 numchan.push_back(5);
388 numchan.push_back(5);
389 numchan.push_back(3);
390 decaylist=ksList* ksList* pi0List;
392 else if(channel==
"D0toKsPi0Pi0"){
394 numchan.push_back(5);
395 numchan.push_back(3);
396 numchan.push_back(3);
397 decaylist=ksList* pi0List* pi0List;
399 else if(channel==
"D0toKsKK"){
401 numchan.push_back(5);
402 numchan.push_back(1);
403 numchan.push_back(1);
404 decaylist=ksList* kaonList.
minus()* kaonList.
plus();
406 else if(channel==
"D0toKsEta"){
408 numchan.push_back(5);
409 numchan.push_back(4);
410 decaylist=ksList* etaList;
412 else if(channel==
"D0toPi0Pi0Pi0"){
414 numchan.push_back(3);
415 numchan.push_back(3);
416 numchan.push_back(3);
417 decaylist=pi0List* pi0List* pi0List;
419 else if(channel==
"D0toKsKsKs"){
421 numchan.push_back(5);
422 numchan.push_back(5);
423 numchan.push_back(5);
424 decaylist=ksList* ksList* ksList;
426 else if(channel==
"D0toPiPiPiPi"){
428 numchan.push_back(2);
429 numchan.push_back(2);
430 numchan.push_back(2);
431 numchan.push_back(2);
434 else if(channel==
"D0toPiPiPi0Pi0"){
436 numchan.push_back(2);
437 numchan.push_back(2);
438 numchan.push_back(3);
439 numchan.push_back(3);
440 decaylist=pionList.
plus()* pionList.
minus()* pi0List* pi0List;
442 else if(channel==
"D0toKKPiPi"){
444 numchan.push_back(1);
445 numchan.push_back(1);
446 numchan.push_back(2);
447 numchan.push_back(2);
450 else if(channel==
"D0toKKPi0Pi0"){
452 numchan.push_back(1);
453 numchan.push_back(1);
454 numchan.push_back(3);
455 numchan.push_back(3);
456 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List* pi0List;
458 else if(channel==
"D0toKsKsPiPi"){
460 numchan.push_back(5);
461 numchan.push_back(5);
462 numchan.push_back(2);
463 numchan.push_back(2);
464 decaylist=ksList* ksList* pionList.
plus()* pionList.
minus();
466 else if(channel==
"D0toPiPiPiPiPi0"){
468 numchan.push_back(2);
469 numchan.push_back(2);
470 numchan.push_back(2);
471 numchan.push_back(2);
472 numchan.push_back(3);
473 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus()* pi0List;
475 else if(channel==
"D0toKsPiPiPiPi"){
477 numchan.push_back(5);
478 numchan.push_back(2);
479 numchan.push_back(2);
480 numchan.push_back(2);
481 numchan.push_back(2);
482 decaylist=ksList* pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus();
484 else if(channel==
"D0toKKPiPiPi0"){
486 numchan.push_back(1);
487 numchan.push_back(1);
488 numchan.push_back(2);
489 numchan.push_back(2);
490 numchan.push_back(3);
491 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
493 else if(channel==
"D0toKsPi0Eta"){
495 numchan.push_back(5);
496 numchan.push_back(3);
497 numchan.push_back(4);
498 decaylist=ksList* pi0List* etaList;
500 else if(channel==
"D0toKsEPPiPiEta"){
502 numchan.push_back(5);
503 numchan.push_back(6);
505 epList=pionList.
plus()* pionList.
minus()* etaList;
506 decaylist= ksList* epList;
508 else if(channel==
"D0toKsEPRhoGam"){
510 numchan.push_back(5);
511 numchan.push_back(7);
513 rhoList=pionList.
plus()* pionList.
minus();
515 epList=rhoList* photonList;
516 decaylist= ksList* epList;
518 else if(channel==
"D0toKsPi0Pi0Pi0"){
520 numchan.push_back(5);
521 numchan.push_back(3);
522 numchan.push_back(3);
523 numchan.push_back(3);
524 decaylist=ksList* pi0List* pi0List* pi0List;
537 vector<int> trackid, showerid;
538 vector<int> kaonid, pionid;
540 int numofchildren=numchan.size()-1;
542 for(
int i=0; i< numofchildren;i++){
544 const CDCandidate& daughter=(*it).particle().child(i);
545 if(isFlavorMode && i==0)
550 trackid.push_back(track->
trackId());
551 kaonid.push_back(track->
trackId());
553 else if(numchan[i+1]==2){
555 trackid.push_back(track->
trackId());
556 pionid.push_back(track->
trackId());
558 else if ( numchan[i+1]==3){
561 showerid.push_back(hiEnGamma->
trackId());
562 showerid.push_back(loEnGamma->
trackId());
564 else if ( numchan[i+1]==4){
567 showerid.push_back(hiEnGamma->
trackId());
568 showerid.push_back(loEnGamma->
trackId());
570 else if ( numchan[i+1]==5){
574 trackid.push_back(pion1Trk->
trackId());
575 trackid.push_back(pion2Trk->
trackId());
577 else if (numchan[i+1]==6){
586 trackid.push_back(apiontrk->
trackId());
587 trackid.push_back(spiontrk->
trackId());
588 showerid.push_back(hiEnGamma->
trackId());
589 showerid.push_back(loEnGamma->
trackId());
592 else if (numchan[i+1]==7){
604 trackid.push_back(apiontrk->
trackId());
605 trackid.push_back(spiontrk->
trackId());
606 showerid.push_back(gammatrk->
trackId());
614 saveD0Info(it, ebeam, charm, numofchildren, recDTag);
615 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
616 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
619 HepLorentzVector p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
620 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
631 recDTagCol->push_back(recDTag);
640 return StatusCode::SUCCESS;
645 double mass = (*it).particle().mass();
646 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
650 double mbc2_CMS = ebeam*ebeam - p4.v().mag2();
651 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
652 double deltaE_CMS = p4.t() - ebeam;
654 int tag=(*it).particle().userTag();
672 vector<EvtRecTrackIterator> trktemp;
673 vector<EvtRecTrackIterator> shrtemp;
678 bool isothertrack=
true;
679 for(
int i=0; i<trackid.size(); i++){
680 if( (*trk)->trackId()==trackid[i] ){
681 trktemp.push_back(trk);
689 for(
int i=0; i<trackid.size();i++){
690 for(
int j=0; j<trktemp.size(); j++){
692 if( (*trk)->trackId()==trackid[i])
700 bool isothershower=
true;
701 for(
int i=0; i<showerid.size(); i++){
702 if( (*shr)->trackId()==showerid[i] ){
703 shrtemp.push_back(shr);
712 for(
int i=0; i<showerid.size();i++){
713 for(
int j=0; j<shrtemp.size(); j++){
715 if( (*shr)->trackId()==showerid[i])
726 bool iskaon=
false,ispion=
false;
732 recDTag->
addKaonId( (*kit).particle().track() );
736 recDTag->
addPionId( (*pit).particle().track() );
788 inFile.open(filename.c_str());
790 cout <<
"Unable to open decay list file";
794 while (inFile >> channel) {
795 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 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)
NeutralDReconstruction(const std::string &name, ISvcLocator *pSvcLocator)
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 vfit(string channel, vector< int > kaonid, vector< int > pionid, HepPoint3D vx, EvtRecTrackIterator charged_begin)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecDTagCol
_EXTERN_ std::string EvtRecTrackCol