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"
55Algorithm(name, pSvcLocator) {
57 declareProperty(
"debug", m_debug =
false );
58 declareProperty(
"ReadBeamEFromDB", m_ReadBeamEFromDB =
false );
59 declareProperty(
"UseCalibBeamE", m_usecalibBeamE =
false );
60 declareProperty(
"BeamE", m_beamE=2.015 );
61 declareProperty(
"DsList", m_decaylist =
"test.txt" );
66 MsgStream log(
msgSvc(), name());
67 log << MSG::INFO <<
"in initialize()" <<endreq;
75 return StatusCode::SUCCESS;
80 MsgStream log(
msgSvc(), name());
81 log << MSG::INFO <<
"in finalize()" << endreq;
85 return StatusCode::SUCCESS;
88StatusCode DsReconstruction::registerEvtRecDTagCol(
90 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
92 if (sc != StatusCode::SUCCESS) {
93 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
100 MsgStream log(
msgSvc(), name());
101 log << MSG::INFO <<
"in execute()" << endreq;
108 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
109 int event= eventHeader->eventNumber();
115 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
116 <<
" " << eventHeader->eventNumber() << endreq;
117 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
118 << recEvent->totalCharged() <<
" , "
119 << recEvent->totalNeutral() <<
" , "
120 << recEvent->totalTracks() <<endreq;
129 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
131 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
132 return StatusCode::FAILURE;
135 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
136 if ( ! recEtaToGGCol ) {
137 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
138 return StatusCode::FAILURE;
142 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
143 if ( ! recVeeVertexCol ) {
144 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
145 return StatusCode::FAILURE;
151 log << MSG::FATAL <<
"EvtRecDTagCol is not registered yet" << endreq;
152 return StatusCode::FAILURE;
176 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
179 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
182 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
191 int run = eventHeader->runNumber();
192 m_ievt = eventHeader->eventNumber();
193 m_nChrg = recEvent->totalCharged();
194 m_nNeu = recEvent->totalNeutral();
195 m_nPion = pionList.
size();
196 m_nKaon = kaonList.
size();
197 m_nPi0 = pi0List.size();
198 m_nKs = ksList.size();
205 if(m_ReadBeamEFromDB && m_irun!=run){
209 m_beamE=m_readDb.
getbeamE(m_irun,m_beamE);
214 double ebeam=m_beamE;
221 for(
int list=0;list<chanlist.size();list++){
223 string channel=chanlist[list];
233 if(channel==
"DstoKsK") {
235 numchan.push_back(5);
236 numchan.push_back(1);
237 decaylist=ksList* kaonList.
plus();
239 else if(channel==
"DstoKKPi") {
241 numchan.push_back(1);
242 numchan.push_back(1);
243 numchan.push_back(2);
244 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus();
246 else if(channel==
"DstoKsKPi0") {
248 numchan.push_back(5);
249 numchan.push_back(1);
250 numchan.push_back(3);
251 decaylist=ksList* kaonList.
plus()* pi0List;
253 else if(channel==
"DstoKsKsPi") {
255 numchan.push_back(5);
256 numchan.push_back(5);
257 numchan.push_back(2);
258 decaylist=ksList* ksList* pionList.
plus();
260 else if(channel==
"DstoKKPiPi0") {
262 numchan.push_back(1);
263 numchan.push_back(1);
264 numchan.push_back(2);
265 numchan.push_back(3);
266 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pi0List;
268 else if(channel==
"DstoKsKplusPiPi") {
270 numchan.push_back(5);
271 numchan.push_back(1);
272 numchan.push_back(2);
273 numchan.push_back(2);
274 decaylist=ksList* kaonList.
plus()* pionList.
plus()* pionList.
minus();
276 else if(channel==
"DstoKsKminusPiPi") {
278 numchan.push_back(5);
279 numchan.push_back(1);
280 numchan.push_back(2);
281 numchan.push_back(2);
282 decaylist=ksList* kaonList.
minus()* pionList.
plus()* pionList.
plus();
284 else if(channel==
"DstoKKPiPiPi") {
286 numchan.push_back(1);
287 numchan.push_back(1);
288 numchan.push_back(2);
289 numchan.push_back(2);
290 numchan.push_back(2);
293 else if(channel==
"DstoPiPi0") {
295 numchan.push_back(2);
296 numchan.push_back(3);
297 decaylist=pionList.
plus()* pi0List;
299 else if(channel==
"DstoPiPiPi") {
301 numchan.push_back(2);
302 numchan.push_back(2);
303 numchan.push_back(2);
304 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus();
306 else if(channel==
"DstoPiPiPiPi0") {
308 numchan.push_back(2);
309 numchan.push_back(2);
310 numchan.push_back(2);
311 numchan.push_back(3);
312 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
314 else if(channel==
"DstoPiPiPiPiPi") {
316 numchan.push_back(2);
317 numchan.push_back(2);
318 numchan.push_back(2);
319 numchan.push_back(2);
320 numchan.push_back(2);
323 else if(channel==
"DstoPiPiPiPiPiPi0") {
325 numchan.push_back(2);
326 numchan.push_back(2);
327 numchan.push_back(2);
328 numchan.push_back(2);
329 numchan.push_back(2);
330 numchan.push_back(3);
333 else if(channel==
"DstoPiEta") {
335 numchan.push_back(2);
336 numchan.push_back(4);
337 decaylist=pionList.
plus()* etaList;
339 else if(channel==
"DstoPiPi0Eta") {
341 numchan.push_back(2);
342 numchan.push_back(3);
343 numchan.push_back(4);
344 decaylist=pionList.
plus()* pi0List* etaList;
346 else if(channel==
"DstoPiPiPiEta") {
348 numchan.push_back(2);
349 numchan.push_back(2);
350 numchan.push_back(2);
351 numchan.push_back(4);
352 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* etaList;
354 else if(channel==
"DstoPiEPPiPiEta") {
356 numchan.push_back(2);
357 numchan.push_back(6);
359 epList=pionList.
plus()* pionList.
minus()* etaList;
360 decaylist=pionList.
plus()* epList;
362 else if(channel==
"DstoPiPi0EPPiPiEta") {
364 numchan.push_back(2);
365 numchan.push_back(3);
366 numchan.push_back(6);
368 epList=pionList.
plus()* pionList.
minus()* etaList;
369 decaylist=pionList.
plus()* pi0List* epList;
371 else if(channel==
"DstoPiEPRhoGam") {
373 numchan.push_back(2);
374 numchan.push_back(7);
376 rhoList=pionList.
plus()* pionList.
minus();
378 epList=rhoList* photonList;
379 decaylist=pionList.
plus()* epList;
381 else if(channel==
"DstoPiPi0EPRhoGam") {
383 numchan.push_back(2);
384 numchan.push_back(3);
385 numchan.push_back(7);
387 rhoList=pionList.
plus()* pionList.
minus();
389 epList=rhoList* photonList;
390 decaylist=pionList.
plus()* pi0List* epList;
392 else if(channel==
"DstoKsPi") {
394 numchan.push_back(5);
395 numchan.push_back(2);
396 decaylist=ksList* pionList.
plus();
398 else if(channel==
"DstoKsPiPi0") {
400 numchan.push_back(5);
401 numchan.push_back(2);
402 numchan.push_back(3);
403 decaylist=ksList* pionList.
plus()* pi0List;
405 else if(channel==
"DstoKPiPi") {
407 numchan.push_back(1);
408 numchan.push_back(2);
409 numchan.push_back(2);
410 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus();
412 else if(channel==
"DstoKPiPiPi0") {
414 numchan.push_back(1);
415 numchan.push_back(2);
416 numchan.push_back(2);
417 numchan.push_back(3);
418 decaylist=kaonList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
420 else if(channel==
"DstoKKK") {
422 numchan.push_back(1);
423 numchan.push_back(1);
424 numchan.push_back(1);
425 decaylist=kaonList.
minus()* kaonList.
plus()* kaonList.
plus();
436 vector<int> trackid, showerid;
437 vector<int> kaonid, pionid;
438 int numofchildren=numchan.size()-1;
440 for(
int i=0; i< numofchildren;i++){
442 const CDCandidate& daughter=(*it).particle().child(i);
446 trackid.push_back(track->
trackId());
447 kaonid.push_back(track->
trackId());
449 else if(numchan[i+1]==2){
451 trackid.push_back(track->
trackId());
452 pionid.push_back(track->
trackId());
454 else if ( numchan[i+1]==3){
457 showerid.push_back(hiEnGamma->
trackId());
458 showerid.push_back(loEnGamma->
trackId());
460 else if ( numchan[i+1]==4){
463 showerid.push_back(hiEnGamma->
trackId());
464 showerid.push_back(loEnGamma->
trackId());
466 else if ( numchan[i+1]==5){
470 trackid.push_back(pion1Trk->
trackId());
471 trackid.push_back(pion2Trk->
trackId());
473 else if (numchan[i+1]==6){
482 trackid.push_back(apiontrk->
trackId());
483 trackid.push_back(spiontrk->
trackId());
484 showerid.push_back(hiEnGamma->
trackId());
485 showerid.push_back(loEnGamma->
trackId());
488 else if (numchan[i+1]==7){
499 trackid.push_back(apiontrk->
trackId());
500 trackid.push_back(spiontrk->
trackId());
501 showerid.push_back(gammatrk->
trackId());
509 saveDsInfo(it, ebeam, numofchildren, recDTag);
510 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
511 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
521 recDTagCol->push_back(recDTag);
531 return StatusCode::SUCCESS;
537 double mass = (*it).particle().mass();
538 int charge= (*it).particle().charge();
539 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
543 double mbc2_CMS = ebeam*ebeam - p4.v().mag2();
544 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
545 double deltaE_CMS = p4.t() - ebeam;
547 if((*it).particle().userTag()==1)
564 vector<EvtRecTrackIterator> trktemp;
565 vector<EvtRecTrackIterator> shrtemp;
570 bool isothertrack=
true;
571 for(
int i=0; i<trackid.size(); i++){
572 if( (*trk)->trackId()==trackid[i] ){
573 trktemp.push_back(trk);
581 for(
int i=0; i<trackid.size();i++){
582 for(
int j=0; j<trktemp.size(); j++){
584 if( (*trk)->trackId()==trackid[i])
592 bool isothershower=
true;
593 for(
int i=0; i<showerid.size(); i++){
594 if( (*shr)->trackId()==showerid[i] ){
595 shrtemp.push_back(shr);
604 for(
int i=0; i<showerid.size();i++){
605 for(
int j=0; j<shrtemp.size(); j++){
607 if( (*shr)->trackId()==showerid[i])
617 bool iskaon=
false,ispion=
false;
623 recDTag->
addKaonId( (*kit).particle().track() );
627 recDTag->
addPionId( (*pit).particle().track() );
677 inFile.open(filename.c_str());
679 cout <<
"Unable to open decay list file";
683 while (inFile >> channel) {
684 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
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)
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)
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