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"
57Algorithm(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 = 1.8865 );
64 declareProperty(
"DpList", m_decaylist =
"test.txt" );
65 declareProperty(
"UseVFRefine", m_useVFrefine =
true);
70 MsgStream log(
msgSvc(), name());
71 log << MSG::INFO <<
"in initialize()" <<endreq;
79 return StatusCode::SUCCESS;
84 MsgStream log(
msgSvc(), name());
85 log << MSG::INFO <<
"in finalize()" << endreq;
89 return StatusCode::SUCCESS;
92StatusCode ChargedDReconstruction::registerEvtRecDTagCol(
94 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
96 if (sc != StatusCode::SUCCESS) {
97 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
104 MsgStream log(
msgSvc(), name());
105 log << MSG::INFO <<
"in execute()" << endreq;
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
113 int event= eventHeader->eventNumber();
119 log << MSG::DEBUG <<
"run and event = " << eventHeader->runNumber()
120 <<
" " << eventHeader->eventNumber() << endreq;
121 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
122 << recEvent->totalCharged() <<
" , "
123 << recEvent->totalNeutral() <<
" , "
124 << recEvent->totalTracks() <<endreq;
133 SmartDataPtr<EvtRecPi0Col> recPi0Col(eventSvc(),
"/Event/EvtRec/EvtRecPi0Col");
135 log << MSG::FATAL <<
"Could not find EvtRecPi0Col" << endreq;
136 return StatusCode::FAILURE;
140 SmartDataPtr<EvtRecEtaToGGCol> recEtaToGGCol(eventSvc(),
"/Event/EvtRec/EvtRecEtaToGGCol");
141 if ( ! recEtaToGGCol ) {
142 log << MSG::FATAL <<
"Could not find EvtRecEtaToGGCol" << endreq;
143 return StatusCode::FAILURE;
147 SmartDataPtr<EvtRecVeeVertexCol> recVeeVertexCol(eventSvc(),
"/Event/EvtRec/EvtRecVeeVertexCol");
148 if ( ! recVeeVertexCol ) {
149 log << MSG::FATAL <<
"Could not find EvtRecVeeVertexCol" << endreq;
150 return StatusCode::FAILURE;
156 log << MSG::FATAL <<
"EvtRecDTagCol is not registered yet" << endreq;
157 return StatusCode::FAILURE;
163 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]);
199 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
202 map<EvtRecVeeVertex*, vector< double > > fitinfo;
203 for(
CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
215 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
218 dc_fill(etaList, recEtaToGGCol->begin(), recEtaToGGCol->end());
228 int run = eventHeader->runNumber();
229 m_ievt = eventHeader->eventNumber();
230 m_nChrg = recEvent->totalCharged();
231 m_nNeu = recEvent->totalNeutral();
232 m_nPion = pionList.
size();
233 m_nKaon = kaonList.
size();
234 m_nPi0 = pi0List.size();
235 m_nKs = ksList.size();
243 if(m_ReadBeamEFromDB && m_irun!=run){
247 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];
272 if(channel==
"DptoKPiPi") {
274 numchan.push_back(1);
275 numchan.push_back(2);
276 numchan.push_back(2);
277 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus();
279 else if(channel==
"DptoKPiPiPi0") {
281 numchan.push_back(1);
282 numchan.push_back(2);
283 numchan.push_back(2);
284 numchan.push_back(3);
285 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus()* pi0List;
287 else if(channel==
"DptoKsPi") {
289 numchan.push_back(5);
290 numchan.push_back(2);
291 decaylist=ksList* pionList.
plus();
293 else if(channel==
"DptoKsPiPi0") {
295 numchan.push_back(5);
296 numchan.push_back(2);
297 numchan.push_back(3);
298 decaylist=ksList* pionList.
plus()* pi0List;
300 else if(channel==
"DptoKsPiPiPi") {
302 numchan.push_back(5);
303 numchan.push_back(2);
304 numchan.push_back(2);
305 numchan.push_back(2);
306 decaylist=ksList* pionList.
plus()* pionList.
plus()* pionList.
minus();
308 else if(channel==
"DptoKKPi") {
310 numchan.push_back(1);
311 numchan.push_back(1);
312 numchan.push_back(2);
313 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus();
315 else if(channel==
"DptoPiPi0") {
317 numchan.push_back(2);
318 numchan.push_back(3);
319 decaylist=pionList.
plus()* pi0List;
321 else if(channel==
"DptoKPi0") {
323 numchan.push_back(1);
324 numchan.push_back(3);
325 decaylist=kaonList.
plus()* pi0List;
327 else if(channel==
"DptoKsK") {
329 numchan.push_back(5);
330 numchan.push_back(1);
331 decaylist=ksList* kaonList.
plus();
333 else if(channel==
"DptoPiPiPi") {
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==
"DptoPiPi0Pi0") {
342 numchan.push_back(2);
343 numchan.push_back(3);
344 numchan.push_back(3);
345 decaylist=pionList.
plus()* pi0List* pi0List;
347 else if(channel==
"DptoKsKsPi") {
349 numchan.push_back(5);
350 numchan.push_back(5);
351 numchan.push_back(2);
352 decaylist=ksList* ksList* pionList.
plus();
354 else if(channel==
"DptoKsKPi0") {
356 numchan.push_back(5);
357 numchan.push_back(1);
358 numchan.push_back(3);
359 decaylist=ksList* kaonList.
plus()* pi0List;
361 else if(channel==
"DptoKsKsK") {
363 numchan.push_back(5);
364 numchan.push_back(5);
365 numchan.push_back(1);
366 decaylist=ksList* ksList* kaonList.
plus();
368 else if(channel==
"DptoPiPiPiPi0") {
370 numchan.push_back(2);
371 numchan.push_back(2);
372 numchan.push_back(2);
373 numchan.push_back(3);
374 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
376 else if(channel==
"DptoKsPiPi0Pi0") {
378 numchan.push_back(5);
379 numchan.push_back(2);
380 numchan.push_back(3);
381 numchan.push_back(3);
382 decaylist=ksList* pionList.
plus()* pi0List* pi0List;
384 else if(channel==
"DptoKsKplusPiPi") {
386 numchan.push_back(5);
387 numchan.push_back(1);
388 numchan.push_back(2);
389 numchan.push_back(2);
390 decaylist=ksList* kaonList.
plus()* pionList.
plus()* pionList.
minus();
392 else if(channel==
"DptoKsKminusPiPi") {
394 numchan.push_back(5);
395 numchan.push_back(1);
396 numchan.push_back(2);
397 numchan.push_back(2);
398 decaylist=ksList* kaonList.
minus()* pionList.
plus()* pionList.
plus();
400 else if(channel==
"DptoKKPiPi0") {
402 numchan.push_back(1);
403 numchan.push_back(1);
404 numchan.push_back(2);
405 numchan.push_back(3);
406 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pi0List;
408 else if(channel==
"DptoPiPiPiPiPi") {
410 numchan.push_back(2);
411 numchan.push_back(2);
412 numchan.push_back(2);
413 numchan.push_back(2);
414 numchan.push_back(2);
417 else if(channel==
"DptoKPiPiPiPi") {
419 numchan.push_back(1);
420 numchan.push_back(2);
421 numchan.push_back(2);
422 numchan.push_back(2);
423 numchan.push_back(2);
426 else if(channel==
"DptoPiEta") {
428 numchan.push_back(2);
429 numchan.push_back(4);
430 decaylist=pionList.
plus()* etaList;
432 else if(channel==
"DptoKsPiEta") {
434 numchan.push_back(5);
435 numchan.push_back(2);
436 numchan.push_back(4);
437 decaylist=ksList* pionList.
plus()* etaList;
448 vector<int> trackid, showerid;
449 vector<int> kaonid, pionid;
450 int numofchildren=numchan.size()-1;
452 for(
int i=0; i< numofchildren;i++){
454 const CDCandidate& daughter=(*it).particle().child(i);
458 trackid.push_back(track->
trackId());
459 kaonid.push_back(track->
trackId());
461 else if(numchan[i+1]==2){
463 trackid.push_back(track->
trackId());
464 pionid.push_back(track->
trackId());
466 else if ( numchan[i+1]==3){
469 showerid.push_back(hiEnGamma->
trackId());
470 showerid.push_back(loEnGamma->
trackId());
472 else if ( numchan[i+1]==4){
475 showerid.push_back(hiEnGamma->
trackId());
476 showerid.push_back(loEnGamma->
trackId());
478 else if ( numchan[i+1]==5){
481 recDTag->
addToFitInfo(aKsCand->
mass(),fitinfo[aKsCand][0],fitinfo[aKsCand][1],fitinfo[aKsCand][2]);
485 trackid.push_back(pion1Trk->
trackId());
486 trackid.push_back(pion2Trk->
trackId());
493 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
494 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
497 if(m_debug) cout<<
"beforevfit:"<<endl;
499 HepLorentzVector p4change_vfit;
502 p4change_vfit=util.
vfitref(channel, kaonid, pionid, xorigin, charged_begin);
504 p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
507 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
518 recDTagCol->push_back(recDTag);
526 return StatusCode::SUCCESS;
532 double mass = (*it).particle().mass();
533 int charge= (*it).particle().charge();
534 HepLorentzVector
p4((*it).particle().momentum(), (*it).particle().energy());
539 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
540 double deltaE_CMS =
p4.t() -
ebeam;
542 if((*it).particle().userTag()==1)
559 vector<EvtRecTrackIterator> trktemp;
560 vector<EvtRecTrackIterator> shrtemp;
565 bool isothertrack=
true;
566 for(
int i=0; i<trackid.size(); i++){
567 if( (*trk)->trackId()==trackid[i] ){
568 trktemp.push_back(trk);
576 for(
int i=0; i<trackid.size();i++){
577 for(
int j=0; j<trktemp.size(); j++){
579 if( (*trk)->trackId()==trackid[i])
587 bool isothershower=
true;
588 for(
int i=0; i<showerid.size(); i++){
589 if( (*shr)->trackId()==showerid[i] ){
590 shrtemp.push_back(shr);
599 for(
int i=0; i<showerid.size();i++){
600 for(
int j=0; j<shrtemp.size(); j++){
602 if( (*shr)->trackId()==showerid[i])
612 bool iskaon=
false,ispion=
false;
618 recDTag->
addKaonId( (*kit).particle().track() );
622 recDTag->
addPionId( (*pit).particle().track() );
673 inFile.open(filename.c_str());
675 cout <<
"Unable to open decay list file";
679 while (inFile >> channel) {
680 temp.push_back(channel);
ChargedDSelector chargedDSelector
void dc_fill(DCFillableChargedList< Charged > &aFillableList, WitnessIterator first, WitnessIterator last)
ObjectVector< EvtRecDTag > EvtRecDTagCol
EvtRecTrackCol::iterator EvtRecTrackIterator
LocalEtatoGGSelector etatoGGSelector
LocalKaonSelector kaonSelector
LocalKsSelector ksSelector
LocalPi0Selector pi0Selector
LocalPionSelector pionSelector
virtual const EvtRecTrack * track() const
virtual const EvtRecVeeVertex * navKshort() const
virtual const EvtRecPi0 * navPi0() const
virtual const EvtRecEtaToGG * navEta() const
void saveDpInfo(CDDecayList::iterator, double, int, EvtRecDTag *)
vector< string > getlist(string &filename)
void pidtag(vector< int >, vector< int >, CDChargedKaonList &, CDChargedPionList &, EvtRecDTag *)
void savetrack(vector< int >, vector< int >, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecTrackIterator, EvtRecDTag *)
void setbeta(Hep3Vector beta)
void setebeam(double ebeam)
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 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