231 #ifndef ST_NO_NAMESPACES
235 #include "StMcTrack.hh"
237 #include "StMcContainers.hh"
238 #include "StParticleTable.hh"
239 #include "StParticleDefinition.hh"
241 #include "tables/St_g2t_track_Table.h"
242 #include "tables/St_particle_Table.h"
244 static const char rcsid[] =
"$Id: StMcTrack.cc,v 2.38 2016/05/16 23:47:09 perev Exp $";
248 StMcTrack::StMcTrack()
255 StMcTrack::StMcTrack(g2t_track_st* trk) {
257 mFourMomentum.setPx(trk->p[0]);
258 mFourMomentum.setPy(trk->p[1]);
259 mFourMomentum.setPz(trk->p[2]);
260 mFourMomentum.setE(trk->e);
261 mIsShower = trk->is_shower;
262 mGeantId = trk->ge_pid;
263 assert(mGeantId>=0 && mGeantId<=0xFFFF);
264 mPdgId = trk->eg_pid;
266 mParticleDefinition = StParticleTable::instance()->findParticleByGeantId(trk->ge_pid);
267 mEventGenLabel = trk->eg_label;
276 StMcTrack::StMcTrack(particle_st* trk) {
278 mFourMomentum.setPx(trk->phep[0]);
279 mFourMomentum.setPy(trk->phep[1]);
280 mFourMomentum.setPz(trk->phep[2]);
281 mFourMomentum.setE(trk->phep[3]);
282 mParticleDefinition = StParticleTable::instance()->findParticle(trk->idhep);
291 StMcTrack::~StMcTrack() {
293 mIntermediateVertices.clear();
316 void StMcTrack::initToZero()
321 mParticleDefinition = 0;
331 int StMcTrack::operator==(
const StMcTrack& t)
const
333 return (t.mFourMomentum == mFourMomentum &&
334 t.mStartVertex == mStartVertex &&
335 t.mStopVertex == mStopVertex );
338 int StMcTrack::operator!=(
const StMcTrack& t)
const
340 return !(t == *
this);
343 ostream& operator<<(ostream& os,
const StMcTrack& t)
345 if (t.particleDefinition())
346 os <<
"Particle : " << t.particleDefinition()->name().c_str() << endl;
347 os <<
"Four Momentum : " << t.fourMomentum() << endl;
348 os <<
"Pt : " << t.pt() << endl;
349 os <<
"Rapidity : " << t.rapidity() << endl;
350 os <<
"PseudoRapidity: " << t.pseudoRapidity() << endl;
351 os <<
"No. Tpc Hits: " << t.tpcHits().size() << endl;
352 os <<
"No. Svt Hits: " << t.svtHits().size() << endl;
353 os <<
"No. Ssd Hits: " << t.ssdHits().size() << endl;
354 os <<
"No. Ftpc Hits: " << t.ftpcHits().size() << endl;
355 os <<
"No. Rich Hits: " << t.richHits().size() << endl;
356 os <<
"No. Ctb Hits: " << t.ctbHits().size() << endl;
357 os <<
"No. Bemc Hits: " << t.bemcHits().size() << endl;
358 os <<
"No. Bprs Hits: " << t.bprsHits().size() << endl;
359 os <<
"No. Bsmde Hits: " << t.bsmdeHits().size() << endl;
360 os <<
"No. Bsmdp Hits: " << t.bsmdpHits().size() << endl;
361 os <<
"No. Tof Hits: " << t.tofHits().size() << endl;
362 os <<
"No. Mtd Hits: " << t.mtdHits().size() << endl;
363 os <<
"No. Eemc Hits: " << t.eemcHits().size() << endl;
364 os <<
"No. Eprs Hits: " << t.eprsHits().size() << endl;
365 os <<
"No. Esmdu Hits: " << t.esmduHits().size() << endl;
366 os <<
"No. Esmdv Hits: " << t.esmdvHits().size() << endl;
367 os <<
"No. Pxl Hits : " << t.pxlHits().size() << endl;
368 os <<
"No. Ist Hits : " << t.istHits().size() << endl;
369 os <<
"No. Fgt Hits : " << t.fgtHits().size() << endl;
370 os <<
"No. Fsc Hits : " << t.fscHits().size() << endl;
371 os <<
"No. Etr Hits : " << t.etrHits().size() << endl;
372 os <<
"Is Shower : " << t.isShower() << endl;
373 os <<
"Geant Id : " << t.geantId() << endl;
374 os <<
"Pdg Code : " << t.pdgId() << endl;
375 os <<
"Event Gen. Lab: " << t.eventGenLabel() << endl;
376 os <<
"Key from g2t : " << t.key() << endl;
380 void StMcTrack::Print(Option_t *option)
const {
382 if (opt ==
"") {cout << *
this << endl;
return;}
383 if (opt.Contains(
"desc",TString::kIgnoreCase)) {
420 if (particleDefinition()) Name = particleDefinition()->name().c_str();
421 Double_t eta = pseudoRapidity();
422 if (TMath::Abs(eta) > 999.999) eta = TMath::Sign(999.999, eta);
423 Double_t y = rapidity();
424 if (TMath::Abs(y) > 999.999) y = TMath::Sign(999.999, y);
426 Form(
"%8s%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%8.3f%3li%6li%3li%3li%6li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li%3li",
428 fourMomentum().x(), fourMomentum().y(), fourMomentum().z(), fourMomentum().t(),
432 (
long int)(geantId()),
434 (
long int)(eventGenLabel()),
436 (
long int)(tpcHits().size()),
437 (
long int)(svtHits().size()),
438 (
long int)(ssdHits().size()),
439 (
long int)(ftpcHits().size()),
440 (
long int)(richHits().size()),
441 (
long int)(ctbHits().size()),
442 (
long int)(bemcHits().size()),
443 (
long int)(bprsHits().size()),
444 (
long int)(bsmdeHits().size()),
445 (
long int)(bsmdpHits().size()),
446 (
long int)(tofHits().size()),
447 (
long int)(mtdHits().size()),
448 (
long int)(eemcHits().size()),
449 (
long int)(eprsHits().size()),
450 (
long int)(esmduHits().size()),
451 (
long int)(esmdvHits().size()),
452 (
long int)(pxlHits().size()),
453 (
long int)(istHits().size()),
454 (
long int)(fgtHits().size()),
455 (
long int)(etrHits().size()),
456 (
long int)(isShower()))
459 void StMcTrack::setFourMomentum(
const StLorentzVectorF& val) { mFourMomentum = val; }
461 void StMcTrack::setStartVertex(
StMcVertex* val) { mStartVertex = val; }
463 void StMcTrack::setStopVertex(
StMcVertex* val) { mStopVertex = val; }
465 void StMcTrack::setIntermediateVertices(StPtrVecMcVertex& val) { mIntermediateVertices = val; }
467 void StMcTrack::setTpcHits(StPtrVecMcTpcHit& val) { mTpcHits = val; }
469 void StMcTrack::setSvtHits(StPtrVecMcSvtHit& val) { mSvtHits = val; }
471 void StMcTrack::setSsdHits(StPtrVecMcSsdHit& val) { mSsdHits = val; }
473 void StMcTrack::setFtpcHits(StPtrVecMcFtpcHit& val) { mFtpcHits = val; }
475 void StMcTrack::setRichHits(StPtrVecMcRichHit& val) { mRichHits = val; }
477 void StMcTrack::setCtbHits(StPtrVecMcCtbHit& val) { mCtbHits = val; }
479 void StMcTrack::setBemcHits(StPtrVecMcCalorimeterHit& val) { mBemcHits = val; }
481 void StMcTrack::setBprsHits(StPtrVecMcCalorimeterHit& val) { mBprsHits = val; }
483 void StMcTrack::setBsmdeHits(StPtrVecMcCalorimeterHit& val) { mBsmdeHits = val; }
485 void StMcTrack::setBsmdpHits(StPtrVecMcCalorimeterHit& val) { mBsmdpHits = val; }
487 void StMcTrack::setTofHits(StPtrVecMcTofHit& val) { mTofHits = val; }
489 void StMcTrack::setMtdHits(StPtrVecMcMtdHit& val) { mMtdHits = val; }
491 void StMcTrack::setEemcHits(StPtrVecMcCalorimeterHit& val) { mEemcHits = val; }
493 void StMcTrack::setEprsHits(StPtrVecMcCalorimeterHit& val) { mEprsHits = val; }
495 void StMcTrack::setEsmduHits(StPtrVecMcCalorimeterHit& val) { mEsmduHits = val; }
497 void StMcTrack::setEsmdvHits(StPtrVecMcCalorimeterHit& val) { mEsmdvHits = val; }
499 void StMcTrack::setFscHits(StPtrVecMcCalorimeterHit& val) { mFscHits = val; }
501 void StMcTrack::setPxlHits(StPtrVecMcPxlHit& val) { mPxlHits = val; }
503 void StMcTrack::setIstHits(StPtrVecMcIstHit& val) { mIstHits = val; }
505 void StMcTrack::setFgtHits(StPtrVecMcFgtHit& val) { mFgtHits = val; }
507 void StMcTrack::setEtrHits(StPtrVecMcEtrHit& val) { mEtrHits = val; }
509 void StMcTrack::setShower(
char val) { mIsShower = val; }
511 void StMcTrack::setGeantId(
long val) { mGeantId = val; assert(mGeantId>=0 && mGeantId<=0xFFFF); }
513 void StMcTrack::setPdgId(
long val) { mPdgId = val; }
515 void StMcTrack::setKey(
long val) { mKey = val; }
517 void StMcTrack::setEventGenLabel(
long val) { mEventGenLabel = val; }
519 void StMcTrack::setParent(
StMcTrack* val) { mParent = val; }
523 mTpcHits.push_back(hit);
528 mFtpcHits.push_back(hit);
533 mSvtHits.push_back(hit);
538 mSsdHits.push_back(hit);
543 mRichHits.push_back(hit);
548 mCtbHits.push_back(hit);
553 mBemcHits.push_back(hit);
558 mBprsHits.push_back(hit);
563 mBsmdeHits.push_back(hit);
568 mBsmdpHits.push_back(hit);
573 mTofHits.push_back(hit);
578 mMtdHits.push_back(hit);
583 mEemcHits.push_back(hit);
588 mEprsHits.push_back(hit);
593 mEsmduHits.push_back(hit);
598 mEsmdvHits.push_back(hit);
603 mFpdHits.push_back(hit);
608 mFscHits.push_back(hit);
613 mPxlHits.push_back(hit);
618 mIstHits.push_back(hit);
623 mFgtHits.push_back(hit);
628 mEtrHits.push_back(hit);
636 StMcTpcHitIterator iter = find (mTpcHits.begin(), mTpcHits.end(), hit);
637 if (iter != mTpcHits.end()) {
638 mTpcHits.erase(iter);
644 StMcFtpcHitIterator iter = find (mFtpcHits.begin(), mFtpcHits.end(),hit);
645 if (iter != mFtpcHits.end()) {
646 mFtpcHits.erase(iter);
652 StMcSvtHitIterator iter = find(mSvtHits.begin(), mSvtHits.end(), hit);
653 if (iter != mSvtHits.end()) {
654 mSvtHits.erase(iter);
660 StMcSsdHitIterator iter = find(mSsdHits.begin(), mSsdHits.end(), hit);
661 if (iter != mSsdHits.end()) {
662 mSsdHits.erase(iter);
668 StMcRichHitIterator iter = find(mRichHits.begin(), mRichHits.end(), hit);
669 if (iter != mRichHits.end()){
670 mRichHits.erase(iter);
676 StMcCtbHitIterator iter = find(mCtbHits.begin(), mCtbHits.end(), hit);
677 if (iter != mCtbHits.end()){
678 mCtbHits.erase(iter);
682 void StMcTrack::removeCalorimeterHit(StPtrVecMcCalorimeterHit& vch,
StMcCalorimeterHit* hit)
684 StMcCalorimeterHitIterator iter = find(vch.begin(), vch.end(), hit);
685 if (iter != vch.end()) {
692 removeCalorimeterHit(mBemcHits, hit);
696 removeCalorimeterHit(mBprsHits, hit);
700 removeCalorimeterHit(mBsmdeHits, hit);
704 removeCalorimeterHit(mBsmdpHits, hit);
709 StMcTofHitIterator iter = find(mTofHits.begin(), mTofHits.end(), hit);
710 if (iter != mTofHits.end()){
711 mTofHits.erase(iter);
717 StMcMtdHitIterator iter = find(mMtdHits.begin(), mMtdHits.end(), hit);
718 if (iter != mMtdHits.end()){
719 mMtdHits.erase(iter);
725 removeCalorimeterHit(mEemcHits, hit);
730 removeCalorimeterHit(mEprsHits, hit);
735 removeCalorimeterHit(mEsmduHits, hit);
740 removeCalorimeterHit(mEsmdvHits, hit);
745 StMcPxlHitIterator iter = find (mPxlHits.begin(), mPxlHits.end(),hit);
746 if (iter != mPxlHits.end()) {
747 mPxlHits.erase(iter);
753 StMcIstHitIterator iter = find (mIstHits.begin(), mIstHits.end(),hit);
754 if (iter != mIstHits.end()) {
755 mIstHits.erase(iter);
762 StMcFgtHitIterator iter = find (mFgtHits.begin(), mFgtHits.end(),hit);
763 if (iter != mFgtHits.end()) {
764 mFgtHits.erase(iter);
770 StMcEtrHitIterator iter = find (mEtrHits.begin(), mEtrHits.end(),hit);
771 if (iter != mEtrHits.end()) {
772 mEtrHits.erase(iter);
778 if (mParticleDefinition)
return mParticleDefinition;
779 if (mGeantId > 0) mParticleDefinition = StParticleTable::instance()->findParticleByGeantId(mGeantId);
780 if (mParticleDefinition)
return mParticleDefinition;
781 if (mPdgId) mParticleDefinition = StParticleTable::instance()->findParticle(mPdgId);
782 return mParticleDefinition;
785 const StPtrVecMcHit *StMcTrack::Hits(StDetectorId Id)
const {
786 StPtrVecMcHit *coll = 0;
788 case kTpcId: coll = (StPtrVecMcHit *) &mTpcHits;
break;
789 case kSvtId: coll = (StPtrVecMcHit *) &mSvtHits;
break;
790 case kRichId: coll = (StPtrVecMcHit *) &mRichHits;
break;
792 case kFtpcEastId: coll = (StPtrVecMcHit *) &mFtpcHits;
break;
793 case kTofId: coll = (StPtrVecMcHit *) &mTofHits;
break;
794 case kMtdId: coll = (StPtrVecMcHit *) &mMtdHits;
break;
795 case kCtbId: coll = (StPtrVecMcHit *) &mCtbHits;
break;
796 case kSsdId: coll = (StPtrVecMcHit *) &mSsdHits;
break;
797 case kBarrelEmcTowerId:
break;
798 case kBarrelEmcPreShowerId:
break;
799 case kBarrelSmdEtaStripId:
break;
800 case kBarrelSmdPhiStripId:
break;
801 case kEndcapEmcTowerId:
break;
802 case kEndcapEmcPreShowerId:
break;
803 case kEndcapSmdUStripId:
break;
804 case kEndcapSmdVStripId:
break;
806 case kZdcEastId:
break;
808 case kMwpcEastId:
break;
809 case kPhmdCpvId:
break;
811 case kPxlId: coll = (StPtrVecMcHit *) &mPxlHits;
break;
812 case kIstId: coll = (StPtrVecMcHit *) &mIstHits;
break;
813 case kFgtId: coll = (StPtrVecMcHit *) &mFgtHits;
break;
814 case kEtrId: coll = (StPtrVecMcHit *) &mEtrHits;
break;
820 const StPtrVecMcCalorimeterHit *StMcTrack::CalorimeterHits(StDetectorId Id)
const {
821 StPtrVecMcCalorimeterHit *coll = 0;
827 case kFtpcEastId:
break;
832 case kBarrelEmcTowerId: coll = (StPtrVecMcCalorimeterHit *) &mBemcHits;
break;
833 case kBarrelEmcPreShowerId: coll = (StPtrVecMcCalorimeterHit *) &mBprsHits;
break;
834 case kBarrelSmdEtaStripId: coll = (StPtrVecMcCalorimeterHit *) &mBsmdeHits;
break;
835 case kBarrelSmdPhiStripId: coll = (StPtrVecMcCalorimeterHit *) &mBsmdpHits;
break;
836 case kEndcapEmcTowerId: coll = (StPtrVecMcCalorimeterHit *) &mEemcHits;
break;
837 case kEndcapEmcPreShowerId: coll = (StPtrVecMcCalorimeterHit *) &mEprsHits;
break;
838 case kEndcapSmdUStripId: coll = (StPtrVecMcCalorimeterHit *) &mEsmduHits;
break;
839 case kEndcapSmdVStripId: coll = (StPtrVecMcCalorimeterHit *) &mEsmdvHits;
break;
841 case kZdcEastId:
break;
843 case kMwpcEastId:
break;
844 case kPhmdCpvId:
break;
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...