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"
56Algorithm(name, pSvcLocator) {
58 declareProperty(
"debug", m_debug =
false );
59 declareProperty(
"ReadBeamEFromDB", m_ReadBeamEFromDB =
false );
60 declareProperty(
"UseCalibBeamE", m_usecalibBeamE =
false );
61 declareProperty(
"UseVertexfit", m_usevertexfit =
false );
62 declareProperty(
"BeamE", m_beamE = 1.8865 );
63 declareProperty(
"DpList", m_decaylist =
"test.txt" );
68 MsgStream log(
msgSvc(), name());
69 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 ChargedDReconstruction::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;
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;
161 Hep3Vector xorigin(0,0,0);
164 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
169 xorigin.setX(vertex[0]);
170 xorigin.setY(vertex[1]);
171 xorigin.setZ(vertex[2]);
197 dc_fill(ksList, recVeeVertexCol->begin(), recVeeVertexCol->end());
200 map<EvtRecVeeVertex*, vector< double > > fitinfo;
201 for(
CDKsList::iterator ksit = ksList.particle_begin(); ksit != ksList.particle_end(); ++ksit ){
207 dc_fill(pi0List, recPi0Col->begin(), recPi0Col->end());
210 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();
235 if(m_ReadBeamEFromDB && m_irun!=run){
239 m_beamE=m_readDb.
getbeamE(m_irun,m_beamE);
244 double ebeam=m_beamE;
252 for(
int list=0;list<chanlist.size();list++){
254 string channel=chanlist[list];
264 if(channel==
"DptoKPiPi") {
266 numchan.push_back(1);
267 numchan.push_back(2);
268 numchan.push_back(2);
269 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus();
271 else if(channel==
"DptoKPiPiPi0") {
273 numchan.push_back(1);
274 numchan.push_back(2);
275 numchan.push_back(2);
276 numchan.push_back(3);
277 decaylist=kaonList.
minus()* pionList.
plus()* pionList.
plus()* pi0List;
279 else if(channel==
"DptoKsPi") {
281 numchan.push_back(5);
282 numchan.push_back(2);
283 decaylist=ksList* pionList.
plus();
285 else if(channel==
"DptoKsPiPi0") {
287 numchan.push_back(5);
288 numchan.push_back(2);
289 numchan.push_back(3);
290 decaylist=ksList* pionList.
plus()* pi0List;
292 else if(channel==
"DptoKsPiPiPi") {
294 numchan.push_back(5);
295 numchan.push_back(2);
296 numchan.push_back(2);
297 numchan.push_back(2);
298 decaylist=ksList* pionList.
plus()* pionList.
plus()* pionList.
minus();
300 else if(channel==
"DptoKKPi") {
302 numchan.push_back(1);
303 numchan.push_back(1);
304 numchan.push_back(2);
305 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus();
307 else if(channel==
"DptoPiPi0") {
309 numchan.push_back(2);
310 numchan.push_back(3);
311 decaylist=pionList.
plus()* pi0List;
313 else if(channel==
"DptoKPi0") {
315 numchan.push_back(1);
316 numchan.push_back(3);
317 decaylist=kaonList.
plus()* pi0List;
319 else if(channel==
"DptoKsK") {
321 numchan.push_back(5);
322 numchan.push_back(1);
323 decaylist=ksList* kaonList.
plus();
325 else if(channel==
"DptoPiPiPi") {
327 numchan.push_back(2);
328 numchan.push_back(2);
329 numchan.push_back(2);
330 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus() ;
332 else if(channel==
"DptoPiPi0Pi0") {
334 numchan.push_back(2);
335 numchan.push_back(3);
336 numchan.push_back(3);
337 decaylist=pionList.
plus()* pi0List* pi0List;
339 else if(channel==
"DptoKsKsPi") {
341 numchan.push_back(5);
342 numchan.push_back(5);
343 numchan.push_back(2);
344 decaylist=ksList* ksList* pionList.
plus();
346 else if(channel==
"DptoKsKPi0") {
348 numchan.push_back(5);
349 numchan.push_back(1);
350 numchan.push_back(3);
351 decaylist=ksList* kaonList.
plus()* pi0List;
353 else if(channel==
"DptoKsKsK") {
355 numchan.push_back(5);
356 numchan.push_back(5);
357 numchan.push_back(1);
358 decaylist=ksList* ksList* kaonList.
plus();
360 else if(channel==
"DptoPiPiPiPi0") {
362 numchan.push_back(2);
363 numchan.push_back(2);
364 numchan.push_back(2);
365 numchan.push_back(3);
366 decaylist=pionList.
plus()* pionList.
plus()* pionList.
minus()* pi0List;
368 else if(channel==
"DptoKsPiPi0Pi0") {
370 numchan.push_back(5);
371 numchan.push_back(2);
372 numchan.push_back(3);
373 numchan.push_back(3);
374 decaylist=ksList* pionList.
plus()* pi0List* pi0List;
376 else if(channel==
"DptoKsKplusPiPi") {
378 numchan.push_back(5);
379 numchan.push_back(1);
380 numchan.push_back(2);
381 numchan.push_back(2);
382 decaylist=ksList* kaonList.
plus()* pionList.
plus()* pionList.
minus();
384 else if(channel==
"DptoKsKminusPiPi") {
386 numchan.push_back(5);
387 numchan.push_back(1);
388 numchan.push_back(2);
389 numchan.push_back(2);
390 decaylist=ksList* kaonList.
minus()* pionList.
plus()* pionList.
plus();
392 else if(channel==
"DptoKKPiPi0") {
394 numchan.push_back(1);
395 numchan.push_back(1);
396 numchan.push_back(2);
397 numchan.push_back(3);
398 decaylist=kaonList.
minus()* kaonList.
plus()* pionList.
plus()* pi0List;
400 else if(channel==
"DptoPiPiPiPiPi") {
402 numchan.push_back(2);
403 numchan.push_back(2);
404 numchan.push_back(2);
405 numchan.push_back(2);
406 numchan.push_back(2);
409 else if(channel==
"DptoKPiPiPiPi") {
411 numchan.push_back(1);
412 numchan.push_back(2);
413 numchan.push_back(2);
414 numchan.push_back(2);
415 numchan.push_back(2);
418 else if(channel==
"DptoPiEta") {
420 numchan.push_back(2);
421 numchan.push_back(4);
422 decaylist=pionList.
plus()* etaList;
424 else if(channel==
"DptoKsPiEta") {
426 numchan.push_back(5);
427 numchan.push_back(2);
428 numchan.push_back(4);
429 decaylist=ksList* pionList.
plus()* etaList;
440 vector<int> trackid, showerid;
441 vector<int> kaonid, pionid;
442 int numofchildren=numchan.size()-1;
444 for(
int i=0; i< numofchildren;i++){
446 const CDCandidate& daughter=(*it).particle().child(i);
450 trackid.push_back(track->
trackId());
451 kaonid.push_back(track->
trackId());
453 else if(numchan[i+1]==2){
455 trackid.push_back(track->
trackId());
456 pionid.push_back(track->
trackId());
458 else if ( numchan[i+1]==3){
461 showerid.push_back(hiEnGamma->
trackId());
462 showerid.push_back(loEnGamma->
trackId());
464 else if ( numchan[i+1]==4){
467 showerid.push_back(hiEnGamma->
trackId());
468 showerid.push_back(loEnGamma->
trackId());
470 else if ( numchan[i+1]==5){
473 recDTag->
addToFitInfo(aKsCand->
mass(),fitinfo[aKsCand][0],fitinfo[aKsCand][1],fitinfo[aKsCand][2]);
477 trackid.push_back(pion1Trk->
trackId());
478 trackid.push_back(pion2Trk->
trackId());
485 savetrack(trackid,showerid,charged_begin,charged_end,neutral_begin,neutral_end,recDTag);
486 pidtag(kaonid,pionid,kaonList_tight, pionList_tight,recDTag);
489 HepLorentzVector p4change_vfit=util.
vfit(channel, kaonid, pionid, xorigin, charged_begin);
490 recDTag->
setp4(recDTag->
p4()+p4change_vfit);
500 recDTagCol->push_back(recDTag);
508 return StatusCode::SUCCESS;
514 double mass = (*it).particle().mass();
515 int charge= (*it).particle().charge();
516 HepLorentzVector p4((*it).particle().momentum(), (*it).particle().energy());
520 double mbc2_CMS =
ebeam*
ebeam - p4.v().mag2();
521 double mbc_CMS = mbc2_CMS > 0 ? sqrt( mbc2_CMS ) : -10;
522 double deltaE_CMS = p4.t() -
ebeam;
524 if((*it).particle().userTag()==1)
541 vector<EvtRecTrackIterator> trktemp;
542 vector<EvtRecTrackIterator> shrtemp;
547 bool isothertrack=
true;
548 for(
int i=0; i<trackid.size(); i++){
549 if( (*trk)->trackId()==trackid[i] ){
550 trktemp.push_back(trk);
558 for(
int i=0; i<trackid.size();i++){
559 for(
int j=0; j<trktemp.size(); j++){
561 if( (*trk)->trackId()==trackid[i])
569 bool isothershower=
true;
570 for(
int i=0; i<showerid.size(); i++){
571 if( (*shr)->trackId()==showerid[i] ){
572 shrtemp.push_back(shr);
581 for(
int i=0; i<showerid.size();i++){
582 for(
int j=0; j<shrtemp.size(); j++){
584 if( (*shr)->trackId()==showerid[i])
594 bool iskaon=
false,ispion=
false;
600 recDTag->
addKaonId( (*kit).particle().track() );
604 recDTag->
addPionId( (*pit).particle().track() );
655 inFile.open(filename.c_str());
657 cout <<
"Unable to open decay list file";
661 while (inFile >> channel) {
662 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 *)
ChargedDReconstruction(const std::string &name, ISvcLocator *pSvcLocator)
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 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