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" );
69 MsgStream log(
msgSvc(), name());
70 log << MSG::INFO <<
"in initialize()" <<endreq;
78 return StatusCode::SUCCESS;
83 MsgStream log(
msgSvc(), name());
84 log << MSG::INFO <<
"in finalize()" << endreq;
88 return StatusCode::SUCCESS;
91StatusCode DsReconstruction::registerEvtRecDTagCol(
93 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
95 if (sc != StatusCode::SUCCESS) {
96 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
103 MsgStream log(
msgSvc(), name());
104 log << MSG::INFO <<
"in execute()" << endreq;
111 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
112 int event= eventHeader->eventNumber();
118 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
119 <<
" " << eventHeader->eventNumber() << endreq;
120 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
121 << recEvent->totalCharged() <<
" , "
122 << recEvent->totalNeutral() <<
" , "
123 << recEvent->totalTracks() <<endreq;
132 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
134 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
135 return StatusCode::FAILURE;
138 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
139 if ( ! recEtaToGGCol ) {
140 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
141 return StatusCode::FAILURE;
145 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
146 if ( ! recVeeVertexCol ) {
147 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
148 return StatusCode::FAILURE;
154 log << MSG::FATAL <<
"EvtRecDTagCol is not registered yet" << endreq;
155 return StatusCode::FAILURE;
160 Hep3Vector xorigin(0,0,0);
162 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
167 xorigin.setX(vertex[0]);
168 xorigin.setY(vertex[1]);
169 xorigin.setZ(vertex[2]);
197 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
201 map<EvtRecVeeVertex*, vector< double > > fitinfo;
202 for(
CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
208 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
211 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
220 int run = eventHeader->runNumber();
221 m_ievt = eventHeader->eventNumber();
222 m_nChrg = recEvent->totalCharged();
223 m_nNeu = recEvent->totalNeutral();
224 m_nPion = pionList.
size();
225 m_nKaon = kaonList.
size();
226 m_nPi0 = pi0List.size();
227 m_nKs = ksList.size();
234 if(m_ReadBeamEFromDB && m_irun!=run){
238 m_beamE=m_readDb.
getbeamE(m_irun,m_beamE);
243 double ebeam=m_beamE;
250 for(
int list=0;list<chanlist.size();list++){
252 string channel=chanlist[list];
267 if(channel==
"DstoKsK") {
269 numchan.push_back(5);
270 numchan.push_back(1);
271 decaylist=ksList* kaonList.
plus();
273 else if(channel==
"DstoKKPi") {
275 numchan.push_back(1);
276 numchan.push_back(1);
277 numchan.push_back(2);
278 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus();
280 else if(channel==
"DstoKsKPi0") {
282 numchan.push_back(5);
283 numchan.push_back(1);
284 numchan.push_back(3);
285 decaylist=ksList* kaonList.
plus()* pi0List;
287 else if(channel==
"DstoKsKsPi") {
289 numchan.push_back(5);
290 numchan.push_back(5);
291 numchan.push_back(2);
292 decaylist=ksList* ksList* pionList.
plus();
294 else if(channel==
"DstoKKPiPi0") {
296 numchan.push_back(1);
297 numchan.push_back(1);
298 numchan.push_back(2);
299 numchan.push_back(3);
300 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pi0List;
302 else if(channel==
"DstoKsKplusPiPi") {
304 numchan.push_back(5);
305 numchan.push_back(1);
306 numchan.push_back(2);
307 numchan.push_back(2);
308 decaylist=ksList* kaonList.
plus()* pionList.
plus()* pionList.
minus();
310 else if(channel==
"DstoKsKminusPiPi") {
312 numchan.push_back(5);
313 numchan.push_back(1);
314 numchan.push_back(2);
315 numchan.push_back(2);
316 decaylist=ksList* kaonList.
minus()* pionList.
plus()* pionList.
plus();
318 else if(channel==
"DstoKKPiPiPi") {
320 numchan.push_back(1);
321 numchan.push_back(1);
322 numchan.push_back(2);
323 numchan.push_back(2);
324 numchan.push_back(2);
327 else if(channel==
"DstoPiPi0") {
329 numchan.push_back(2);
330 numchan.push_back(3);
331 decaylist=pionList.
plus()* pi0List;
333 else if(channel==
"DstoPiPiPi") {
335 numchan.push_back(2);
336 numchan.push_back(2);
337 numchan.push_back(2);
338 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus();
340 else if(channel==
"DstoPiPiPiPi0") {
342 numchan.push_back(2);
343 numchan.push_back(2);
344 numchan.push_back(2);
345 numchan.push_back(3);
346 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
348 else if(channel==
"DstoPiPiPiPiPi") {
350 numchan.push_back(2);
351 numchan.push_back(2);
352 numchan.push_back(2);
353 numchan.push_back(2);
354 numchan.push_back(2);
357 else if(channel==
"DstoPiPiPiPiPiPi0") {
359 numchan.push_back(2);
360 numchan.push_back(2);
361 numchan.push_back(2);
362 numchan.push_back(2);
363 numchan.push_back(2);
364 numchan.push_back(3);
367 else if(channel==
"DstoPiPiPiPi0Pi0") {
369 numchan.push_back(2);
370 numchan.push_back(2);
371 numchan.push_back(2);
372 numchan.push_back(3);
373 numchan.push_back(3);
374 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List* pi0List;
376 else if(channel==
"DstoPiEta") {
378 numchan.push_back(2);
379 numchan.push_back(4);
380 decaylist=pionList.
plus()* etaList;
382 else if(channel==
"DstoPiEtaPiPiPi0") {
384 numchan.push_back(2);
385 numchan.push_back(9);
387 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
388 decaylist=pionList.
plus()* EtaList;
390 else if(channel==
"DstoPiPi0Eta") {
392 numchan.push_back(2);
393 numchan.push_back(3);
394 numchan.push_back(4);
395 decaylist=pionList.
plus()* pi0List* etaList;
397 else if(channel==
"DstoPiPi0EtaPiPiPi0") {
399 numchan.push_back(2);
400 numchan.push_back(3);
401 numchan.push_back(9);
403 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
404 decaylist=pionList.
plus()* pi0List* EtaList;
406 else if(channel==
"DstoPiPiPiEta") {
408 numchan.push_back(2);
409 numchan.push_back(2);
410 numchan.push_back(2);
411 numchan.push_back(4);
412 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* etaList;
414 else if(channel==
"DstoPiPiPiEtaPiPiPi0") {
416 numchan.push_back(2);
417 numchan.push_back(2);
418 numchan.push_back(2);
419 numchan.push_back(9);
421 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
422 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* EtaList;
424 else if(channel==
"DstoPiEPPiPiEta") {
426 numchan.push_back(2);
427 numchan.push_back(6);
429 epList=pionList.
plus()* pionList.
minus()* etaList;
430 decaylist=pionList.
plus()* epList;
432 else if(channel==
"DstoPiPi0EPPiPiEta") {
434 numchan.push_back(2);
435 numchan.push_back(3);
436 numchan.push_back(6);
438 epList=pionList.
plus()* pionList.
minus()* etaList;
439 decaylist=pionList.
plus()* pi0List* epList;
441 else if(channel==
"DstoPiEPPiPiEtaPiPiPi0") {
443 numchan.push_back(2);
444 numchan.push_back(8);
446 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
448 EtapList=pionList.
plus()* pionList.
minus()* EtaList;
449 decaylist=pionList.
plus()* EtapList;
451 else if(channel==
"DstoPiPi0EPPiPiEtaPiPiPi0") {
453 numchan.push_back(2);
454 numchan.push_back(3);
455 numchan.push_back(8);
457 EtaList=pionList.
plus()* pionList.
minus()* pi0List;
459 EtapList=pionList.
plus()* pionList.
minus()* EtaList;
460 decaylist=pionList.
plus()* pi0List* EtapList;
463 else if(channel==
"DstoPiEPRhoGam") {
465 numchan.push_back(2);
466 numchan.push_back(7);
468 rhoList=pionList.
plus()* pionList.
minus();
470 epList=rhoList* photonList;
471 decaylist=pionList.
plus()* epList;
473 else if(channel==
"DstoPiPi0EPRhoGam") {
475 numchan.push_back(2);
476 numchan.push_back(3);
477 numchan.push_back(7);
479 rhoList=pionList.
plus()* pionList.
minus();
481 epList=rhoList* photonList;
482 decaylist=pionList.
plus()* pi0List* epList;
484 else if(channel==
"DstoKsPi") {
486 numchan.push_back(5);
487 numchan.push_back(2);
488 decaylist=ksList* pionList.
plus();
490 else if(channel==
"DstoKsPiPi0") {
492 numchan.push_back(5);
493 numchan.push_back(2);
494 numchan.push_back(3);
495 decaylist=ksList* pionList.
plus()* pi0List;
497 else if(channel==
"DstoKPiPi") {
499 numchan.push_back(1);
500 numchan.push_back(2);
501 numchan.push_back(2);
502 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus();
504 else if(channel==
"DstoKPiPiPi0") {
506 numchan.push_back(1);
507 numchan.push_back(2);
508 numchan.push_back(2);
509 numchan.push_back(3);
510 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
512 else if(channel==
"DstoKKK") {
514 numchan.push_back(1);
515 numchan.push_back(1);
516 numchan.push_back(1);
517 decaylist=kaonList.
minus()* kaonList.
plus()* kaonList.
plus();
528 vector<int> trackid, showerid;
529 vector<int> kaonid, pionid;
530 int numofchildren=numchan.size()-1;
532 for(
int i=0; i< numofchildren;i++){
534 const CDCandidate& daughter=(*it).particle().child(i);
538 trackid.push_back(track->
trackId());
539 kaonid.push_back(track->
trackId());
541 else if(numchan[i+1]==2){
543 trackid.push_back(track->
trackId());
544 pionid.push_back(track->
trackId());
546 else if ( numchan[i+1]==3){
549 showerid.push_back(hiEnGamma->
trackId());
550 showerid.push_back(loEnGamma->
trackId());
552 else if ( numchan[i+1]==4){
555 showerid.push_back(hiEnGamma->
trackId());
556 showerid.push_back(loEnGamma->
trackId());
558 else if ( numchan[i+1]==5){
562 recDTag->
addToFitInfo(aKsCand->
mass(),fitinfo[aKsCand][0],fitinfo[aKsCand][1],fitinfo[aKsCand][2]);
566 trackid.push_back(pion1Trk->
trackId());
567 trackid.push_back(pion2Trk->
trackId());
569 else if (numchan[i+1]==6){
578 trackid.push_back(apiontrk->
trackId());
579 trackid.push_back(spiontrk->
trackId());
580 showerid.push_back(hiEnGamma->
trackId());
581 showerid.push_back(loEnGamma->
trackId());
584 else if (numchan[i+1]==7){
595 trackid.push_back(apiontrk->
trackId());
596 trackid.push_back(spiontrk->
trackId());
597 showerid.push_back(gammatrk->
trackId());
600 else if (numchan[i+1]==8){
616 trackid.push_back(apiontrk->
trackId());
617 trackid.push_back(spiontrk->
trackId());
618 trackid.push_back(e0piontrk->
trackId());
619 trackid.push_back(e1piontrk->
trackId());
620 showerid.push_back(hiEnGamma->
trackId());
621 showerid.push_back(loEnGamma->
trackId());
624 else if (numchan[i+1]==9){
633 trackid.push_back(apiontrk->
trackId());
634 trackid.push_back(spiontrk->
trackId());
635 showerid.push_back(hiEnGamma->
trackId());
636 showerid.push_back(loEnGamma->
trackId());
645 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
646 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
650 HepLorentzVector p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
651 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
663 recDTagCol->push_back(recDTag);
673 return StatusCode::SUCCESS;
679 double mass = (*it).particle().mass();
680 int charge= (*it).particle().charge();
681 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
685 double mbc2_CMS =
ebeam*
ebeam - p4.v().mag2();
686 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
687 double deltaE_CMS = p4.t() -
ebeam;
689 if((*it).particle().userTag()==1)
706 vector<EvtRecTrackIterator> trktemp;
707 vector<EvtRecTrackIterator> shrtemp;
712 bool isothertrack=
true;
713 for(
int i=0; i<trackid.size(); i++){
714 if( (*trk)->trackId()==trackid[i] ){
715 trktemp.push_back(trk);
723 for(
int i=0; i<trackid.size();i++){
724 for(
int j=0; j<trktemp.size(); j++){
726 if( (*trk)->trackId()==trackid[i])
734 bool isothershower=
true;
735 for(
int i=0; i<showerid.size(); i++){
736 if( (*shr)->trackId()==showerid[i] ){
737 shrtemp.push_back(shr);
746 for(
int i=0; i<showerid.size();i++){
747 for(
int j=0; j<shrtemp.size(); j++){
749 if( (*shr)->trackId()==showerid[i])
759 bool iskaon=
false,ispion=
false;
765 recDTag->
addKaonId( (*kit).particle().track() );
769 recDTag->
addPionId( (*pit).particle().track() );
819 inFile.open(filename.c_str());
821 cout <<
"Unable to open decay list file";
825 while (inFile >> channel) {
826 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 *)
DsReconstruction(const std::string &name, ISvcLocator *pSvcLocator)
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 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