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"
56Algorithm(name, pSvcLocator) {
58 declareProperty(
"debug", m_debug =
false );
59 declareProperty(
"ReadBeamEFromDB", m_ReadBeamEFromDB =
false );
60 declareProperty(
"UseCalibBeamE", m_usecalibBeamE =
false );
61 declareProperty(
"BeamE", m_beamE = 1.8865 );
62 declareProperty(
"D0List", m_decaylist =
"test.txt" );
67 MsgStream log(
msgSvc(), name());
68 log << MSG::INFO <<
"in initialize()" <<endreq;
77 return StatusCode::SUCCESS;
82 MsgStream log(
msgSvc(), name());
83 log << MSG::INFO <<
"in finalize()" << endreq;
87 return StatusCode::SUCCESS;
90StatusCode NeutralDReconstruction::registerEvtRecDTagCol(
92 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
94 if (sc != StatusCode::SUCCESS) {
95 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
102 MsgStream log(
msgSvc(), name());
103 log << MSG::INFO <<
"in execute()" << endreq;
110 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
111 int event= eventHeader->eventNumber();
117 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
118 <<
" " << eventHeader->eventNumber() << endreq;
119 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
120 << recEvent->totalCharged() <<
" , "
121 << recEvent->totalNeutral() <<
" , "
122 << recEvent->totalTracks() <<endreq;
131 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
133 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
134 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 in TDS" << endreq;
156 return StatusCode::FAILURE;
180 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
183 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
186 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
195 int run = eventHeader->runNumber();
196 m_ievt = eventHeader->eventNumber();
197 m_nChrg = recEvent->totalCharged();
198 m_nNeu = recEvent->totalNeutral();
199 m_nPion = pionList.
size();
200 m_nKaon = kaonList.
size();
201 m_nPi0 = pi0List.size();
202 m_nKs = ksList.size();
208 if(m_ReadBeamEFromDB && m_irun!=run){
212 m_beamE=m_readDb.
getbeamE(m_irun, m_beamE);
218 double ebeam=m_beamE;
226 for(
int list=0;list<chanlist.size();list++){
228 string channel=chanlist[list];
234 bool isFlavorMode=
false;
241 if(channel==
"D0toKPi") {
243 numchan.push_back(1);
244 numchan.push_back(2);
245 decaylist=kaonList.
minus() * pionList.
plus();
248 else if(channel==
"D0toKPiPi0"){
250 numchan.push_back(1);
251 numchan.push_back(2);
252 numchan.push_back(3);
253 decaylist=kaonList.
minus() * pionList.
plus() * pi0List;
256 else if(channel==
"D0toKPiPi0Pi0"){
258 numchan.push_back(1);
259 numchan.push_back(2);
260 numchan.push_back(3);
261 numchan.push_back(3);
262 decaylist=kaonList.
minus() * pionList.
plus() * pi0List * pi0List;
265 else if(channel==
"D0toKPiPiPi"){
267 numchan.push_back(1);
268 numchan.push_back(2);
269 numchan.push_back(2);
270 numchan.push_back(2);
274 else if(channel==
"D0toKPiPiPiPi0"){
276 numchan.push_back(1);
277 numchan.push_back(2);
278 numchan.push_back(2);
279 numchan.push_back(2);
280 numchan.push_back(3);
281 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
284 else if(channel==
"D0toKPiEta"){
286 numchan.push_back(1);
287 numchan.push_back(2);
288 numchan.push_back(4);
289 decaylist=kaonList.
minus() * pionList.
plus() * etaList;
292 else if(channel==
"D0toKsKPi"){
294 numchan.push_back(5);
295 numchan.push_back(1);
296 numchan.push_back(2);
297 decaylist=ksList* kaonList.
minus()* pionList.
plus();
299 else if(channel==
"D0toKsKPiPi0"){
301 numchan.push_back(5);
302 numchan.push_back(1);
303 numchan.push_back(2);
304 numchan.push_back(3);
305 decaylist=ksList* kaonList.
minus() * pionList.
plus()* pi0List;
307 else if(channel==
"D0toKsPiPi"){
309 numchan.push_back(5);
310 numchan.push_back(2);
311 numchan.push_back(2);
312 decaylist=ksList* pionList.
plus()* pionList.
minus();
314 else if(channel==
"D0toKsPiPiPi0"){
316 numchan.push_back(5);
317 numchan.push_back(2);
318 numchan.push_back(2);
319 numchan.push_back(3);
320 decaylist=ksList* pionList.
plus()* pionList.
minus()* pi0List;
322 else if(channel==
"D0toKsPi0"){
324 numchan.push_back(5);
325 numchan.push_back(3);
326 decaylist=ksList* pi0List;
328 else if(channel==
"D0toPiPiPi0"){
330 numchan.push_back(2);
331 numchan.push_back(2);
332 numchan.push_back(3);
333 decaylist=pionList.
plus()* pionList.
minus()* pi0List;
335 else if(channel==
"D0toPiPi"){
337 numchan.push_back(2);
338 numchan.push_back(2);
339 decaylist=pionList.
plus()* pionList.
minus();
341 else if(channel==
"D0toKK"){
343 numchan.push_back(1);
344 numchan.push_back(1);
345 decaylist=kaonList.
minus()* kaonList.
plus();
347 else if(channel==
"D0toKKPi0"){
349 numchan.push_back(1);
350 numchan.push_back(1);
351 numchan.push_back(3);
352 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List;
354 else if(channel==
"D0toPi0Pi0"){
356 numchan.push_back(3);
357 numchan.push_back(3);
358 decaylist=pi0List* pi0List;
360 else if(channel==
"D0toKsKs"){
362 numchan.push_back(5);
363 numchan.push_back(5);
364 decaylist=ksList* ksList;
366 else if(channel==
"D0toKsKsPi0"){
368 numchan.push_back(5);
369 numchan.push_back(5);
370 numchan.push_back(3);
371 decaylist=ksList* ksList* pi0List;
373 else if(channel==
"D0toKsPi0Pi0"){
375 numchan.push_back(5);
376 numchan.push_back(3);
377 numchan.push_back(3);
378 decaylist=ksList* pi0List* pi0List;
380 else if(channel==
"D0toKsKK"){
382 numchan.push_back(5);
383 numchan.push_back(1);
384 numchan.push_back(1);
385 decaylist=ksList* kaonList.
minus()* kaonList.
plus();
387 else if(channel==
"D0toKsEta"){
389 numchan.push_back(5);
390 numchan.push_back(4);
391 decaylist=ksList* etaList;
393 else if(channel==
"D0toPi0Pi0Pi0"){
395 numchan.push_back(3);
396 numchan.push_back(3);
397 numchan.push_back(3);
398 decaylist=pi0List* pi0List* pi0List;
400 else if(channel==
"D0toKsKsKs"){
402 numchan.push_back(5);
403 numchan.push_back(5);
404 numchan.push_back(5);
405 decaylist=ksList* ksList* ksList;
407 else if(channel==
"D0toPiPiPiPi"){
409 numchan.push_back(2);
410 numchan.push_back(2);
411 numchan.push_back(2);
412 numchan.push_back(2);
415 else if(channel==
"D0toPiPiPi0Pi0"){
417 numchan.push_back(2);
418 numchan.push_back(2);
419 numchan.push_back(3);
420 numchan.push_back(3);
421 decaylist=pionList.
plus()* pionList.
minus()* pi0List* pi0List;
423 else if(channel==
"D0toKKPiPi"){
425 numchan.push_back(1);
426 numchan.push_back(1);
427 numchan.push_back(2);
428 numchan.push_back(2);
431 else if(channel==
"D0toKKPi0Pi0"){
433 numchan.push_back(1);
434 numchan.push_back(1);
435 numchan.push_back(3);
436 numchan.push_back(3);
437 decaylist=kaonList.
minus()* kaonList.
plus()* pi0List* pi0List;
439 else if(channel==
"D0toKsKsPiPi"){
441 numchan.push_back(5);
442 numchan.push_back(5);
443 numchan.push_back(2);
444 numchan.push_back(2);
445 decaylist=ksList* ksList* pionList.
plus()* pionList.
minus();
447 else if(channel==
"D0toPiPiPiPiPi0"){
449 numchan.push_back(2);
450 numchan.push_back(2);
451 numchan.push_back(2);
452 numchan.push_back(2);
453 numchan.push_back(3);
454 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus()* pi0List;
456 else if(channel==
"D0toKsPiPiPiPi"){
458 numchan.push_back(5);
459 numchan.push_back(2);
460 numchan.push_back(2);
461 numchan.push_back(2);
462 numchan.push_back(2);
463 decaylist=ksList* pionList.
plus()* pionList.
plus()* pionList.
minus()* pionList.
minus();
465 else if(channel==
"D0toKKPiPiPi0"){
467 numchan.push_back(1);
468 numchan.push_back(1);
469 numchan.push_back(2);
470 numchan.push_back(2);
471 numchan.push_back(3);
472 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
474 else if(channel==
"D0toKsPi0Eta"){
476 numchan.push_back(5);
477 numchan.push_back(3);
478 numchan.push_back(4);
479 decaylist=ksList* pi0List* etaList;
481 else if(channel==
"D0toKsEPPiPiEta"){
483 numchan.push_back(5);
484 numchan.push_back(6);
486 epList=pionList.
plus()* pionList.
minus()* etaList;
487 decaylist= ksList* epList;
489 else if(channel==
"D0toKsEPRhoGam"){
491 numchan.push_back(5);
492 numchan.push_back(7);
494 rhoList=pionList.
plus()* pionList.
minus();
496 epList=rhoList* photonList;
497 decaylist= ksList* epList;
510 vector<int> trackid, showerid;
511 vector<int> kaonid, pionid;
513 int numofchildren=numchan.size()-1;
515 for(
int i=0; i< numofchildren;i++){
517 const CDCandidate& daughter=(*it).particle().child(i);
518 if(isFlavorMode && i==0)
523 trackid.push_back(track->
trackId());
524 kaonid.push_back(track->
trackId());
526 else if(numchan[i+1]==2){
528 trackid.push_back(track->
trackId());
529 pionid.push_back(track->
trackId());
531 else if ( numchan[i+1]==3){
534 showerid.push_back(hiEnGamma->
trackId());
535 showerid.push_back(loEnGamma->
trackId());
537 else if ( numchan[i+1]==4){
540 showerid.push_back(hiEnGamma->
trackId());
541 showerid.push_back(loEnGamma->
trackId());
543 else if ( numchan[i+1]==5){
547 trackid.push_back(pion1Trk->
trackId());
548 trackid.push_back(pion2Trk->
trackId());
550 else if (numchan[i+1]==6){
559 trackid.push_back(apiontrk->
trackId());
560 trackid.push_back(spiontrk->
trackId());
561 showerid.push_back(hiEnGamma->
trackId());
562 showerid.push_back(loEnGamma->
trackId());
565 else if (numchan[i+1]==7){
577 trackid.push_back(apiontrk->
trackId());
578 trackid.push_back(spiontrk->
trackId());
579 showerid.push_back(gammatrk->
trackId());
587 saveD0Info(it, ebeam, charm, numofchildren, recDTag);
588 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
589 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
599 recDTagCol->push_back(recDTag);
608 return StatusCode::SUCCESS;
613 double mass = (*it).particle().mass();
614 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
618 double mbc2_CMS = ebeam*ebeam - p4.v().mag2();
619 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
620 double deltaE_CMS = p4.t() - ebeam;
622 int tag=(*it).particle().userTag();
640 vector<EvtRecTrackIterator> trktemp;
641 vector<EvtRecTrackIterator> shrtemp;
646 bool isothertrack=
true;
647 for(
int i=0; i<trackid.size(); i++){
648 if( (*trk)->trackId()==trackid[i] ){
649 trktemp.push_back(trk);
657 for(
int i=0; i<trackid.size();i++){
658 for(
int j=0; j<trktemp.size(); j++){
660 if( (*trk)->trackId()==trackid[i])
668 bool isothershower=
true;
669 for(
int i=0; i<showerid.size(); i++){
670 if( (*shr)->trackId()==showerid[i] ){
671 shrtemp.push_back(shr);
680 for(
int i=0; i<showerid.size();i++){
681 for(
int j=0; j<shrtemp.size(); j++){
683 if( (*shr)->trackId()==showerid[i])
694 bool iskaon=
false,ispion=
false;
700 recDTag->
addKaonId( (*kit).particle().track() );
704 recDTag->
addPionId( (*pit).particle().track() );
755 inFile.open(filename.c_str());
757 cout <<
"Unable to open decay list file";
761 while (inFile >> channel) {
762 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)
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)
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()
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecDTagCol
_EXTERN_ std::string EvtRecTrackCol