150 #include "StThreeVectorF.hh"
152 #include "StMcEvent.hh"
153 #include "StMcTpcHitCollection.hh"
154 #include "StMcFtpcHitCollection.hh"
155 #include "StMcRichHitCollection.hh"
156 #include "StMcCtbHitCollection.hh"
157 #include "StMcSvtHitCollection.hh"
158 #include "StMcSsdHitCollection.hh"
159 #include "StMcEmcHitCollection.hh"
160 #include "StMcTofHitCollection.hh"
161 #include "StMcBTofHitCollection.hh"
162 #include "StMcMtdHitCollection.hh"
163 #include "StMcPxlHitCollection.hh"
164 #include "StMcIstHitCollection.hh"
165 #include "StMcFgtHitCollection.hh"
166 #include "StMcEtrHitCollection.hh"
167 #include "StMcContainers.hh"
168 #include "StMcVertex.hh"
169 #include "StMcTrack.hh"
170 #include "StMcTpcHit.hh"
171 #include "StMcFtpcHit.hh"
172 #include "StMcRichHit.hh"
173 #include "StMcSvtHit.hh"
174 #include "StMcSsdHit.hh"
175 #include "StMcCalorimeterHit.hh"
176 #include "StMcTofHit.hh"
177 #include "StMcBTofHit.hh"
178 #include "StMcMtdHit.hh"
179 #include "StMcPxlHit.hh"
180 #include "StMcIstHit.hh"
181 #include "StMcFgtHit.hh"
182 #include "StMcEtrHit.hh"
183 #include "tables/St_g2t_event_Table.h"
184 #include "TDataSetIter.h"
187 TString StMcEvent::mCvsTag =
"$Id: StMcEvent.cc,v 2.40 2016/05/17 19:41:50 perev Exp $";
188 static const char rcsid[] =
"$Id: StMcEvent.cc,v 2.40 2016/05/17 19:41:50 perev Exp $";
191 void StMcEvent::initToZero()
193 memset(mBeg,0,mEnd-mBeg+1);
196 void StMcEvent::makeColls()
216 StMcEvent::StMcEvent() :
TDataSet(
"StMcEvent")
222 StMcEvent::StMcEvent(g2t_event_st* evTable)
226 mEventGeneratorEventLabel = evTable->eg_label;
227 mEventNumber = evTable->n_event;
228 mRunNumber = evTable->n_run;
229 mType = evTable->event_type;
230 mZWest = evTable->n_part_prot_west;
231 mNWest = evTable->n_part_neut_west;
232 mZEast = evTable->n_part_prot_east;
233 mNEast = evTable->n_part_neut_east;
234 mEvGenFSTracks = evTable->n_track_eg_fs;
235 mPrimaryTracks = evTable->n_track_prim;
236 mSubProcessId = evTable->subprocess_id;
237 mImpactParameter = evTable->b_impact;
238 mPhiReactionPlane = evTable->phi_impact;
239 mTriggerTimeOffset = evTable->time_offset;
240 mNBinary = evTable->n_binary;
241 mNWoundedEast = evTable->n_wounded_east;
242 mNWoundedWest = evTable->n_wounded_west;
243 mNJets = evTable->njets;
249 StMcEvent::StMcEvent(
const StMcEvent&) { }
255 StMcEvent::~StMcEvent()
257 for (
auto jk=mBegColl; jk<mEndColl;jk++) {
260 for(
auto jk=0;jk<(int)mTracks.size() ;jk++) {
delete mTracks[jk] ;}
263 for(
int jk=0;jk<(int)mVertices.size();jk++) {
delete mVertices[jk];}
268 int StMcEvent::operator==(
const StMcEvent& e)
const
270 return (e.mEventNumber == mEventNumber &&
271 e.mRunNumber == mRunNumber &&
277 int StMcEvent::operator!=(
const StMcEvent& e)
const
279 return !(e == *
this);
283 ostream& operator<<(ostream& os,
const StMcEvent& e)
285 os <<
"Label: " << e.eventGeneratorEventLabel()
286 <<
"\tRun: " << e.runNumber()
287 <<
"\tId: " << e.eventNumber()
288 <<
"\tType: " << e.type() << endl;
289 os <<
"Participant Protons East: " << e.zEast() <<
"\tWest: " << e.zWest() << endl;
290 os <<
"Participant Neutrons East: " << e.nEast() <<
"\tWest: " << e.nWest() << endl;
291 os <<
"# Ev. Gen. Fin. St. Track: " << e.eventGeneratorFinalStateTracks()
292 <<
"\tNumber of Primary Tracks : " << e.numberOfPrimaryTracks() << endl;
293 os <<
"Subprocess Id : " << e.subProcessId() << endl;
294 os <<
"Impact Parameter : " << e.impactParameter() << endl;
295 os <<
"Phi Reaction Pl. : " << e.phiReactionPlane() << endl;
296 os <<
"Trig. Time Offset: " << e.triggerTimeOffset() << endl;
297 os <<
"N Binary Coll. : " << e.nBinary() << endl;
298 os <<
"N Wounded East : " << e.nWoundedEast() << endl;
299 os <<
"N Wounded West : " << e.nWoundedWest() << endl;
300 os <<
"N Jets : " << e.nJets() << endl;
306 void StMcEvent::setEventGeneratorEventLabel(
unsigned long val) { mEventGeneratorEventLabel = val; }
309 void StMcEvent::setEventNumber(
unsigned long val) { mEventNumber = val; }
312 void StMcEvent::setRunNumber(
unsigned long val) { mRunNumber = val; }
315 void StMcEvent::setType(
unsigned long val) { mType = val; }
318 void StMcEvent::setZWest(
unsigned long val) { mZWest = val; }
321 void StMcEvent::setNWest(
unsigned long val) { mNWest = val; }
324 void StMcEvent::setZEast(
unsigned long val) { mZEast = val; }
327 void StMcEvent::setNEast(
unsigned long val) { mNEast = val; }
330 void StMcEvent::setEventGeneratorFinalStateTracks(
unsigned long val){ mEvGenFSTracks = val; }
333 void StMcEvent::setNumberOfPrimaryTracks(
unsigned long val){ mPrimaryTracks = val; }
336 void StMcEvent::setImpactParameter(
float val) { mImpactParameter = val; }
339 void StMcEvent::setPhiReactionPlane(
float val) { mPhiReactionPlane = val; }
342 void StMcEvent::setTriggerTimeOffset(
float val) { mTriggerTimeOffset = val; }
345 void StMcEvent::setNBinary(
unsigned long val) { mNBinary = val; }
348 void StMcEvent::setNWoundedEast(
unsigned long val) { mNWoundedEast = val; }
351 void StMcEvent::setNWoundedWest(
unsigned long val) { mNWoundedWest = val; }
354 void StMcEvent::setNJets(
unsigned long val) { mNJets = val; }
357 void StMcEvent::setPrimaryVertex(
StMcVertex* val) { mPrimaryVertex = val; }
362 if (mTpcHits!= val)
delete mTpcHits;
369 if (mSvtHits!= val)
delete mSvtHits;
376 if (mSsdHits!= val)
delete mSsdHits;
383 if (mFtpcHits!= val)
delete mFtpcHits;
390 if (mRichHits!= val)
delete mRichHits;
396 if (mTofHits!= val)
delete mTofHits;
402 if (mBTofHits!= val)
delete mBTofHits;
408 if (mMtdHits!= val)
delete mMtdHits;
414 if (mPxlHits!= val)
delete mPxlHits;
421 if (mIstHits!= val)
delete mIstHits;
429 if (mFgtHits!= val)
delete mFgtHits;
434 #define PrintHeader(Name,name) \
435 const StMc ## Name ## HitCollection *name ## Coll = name ## HitCollection();\
436 cout << "---------------------------------------------------------" << endl;\
438 cout << "StMc"#Name"HitCollection at " << (void*) name ## Coll << endl; \
439 cout << "Dumping collection size"; \
440 cout << " and one hit only."; \
443 cout << "---------------------------------------------------------" << endl;\
444 nhits = name ## Coll->numberOfHits();\
445 cout << "# of hits in StMc"#Name"HitCollection = " << nhits << endl;
446 #define PrintHitCollection(Name,name) \
447 PrintHeader(Name,name) \
448 if ( name ## Coll && nhits) { \
449 nh = name ## Coll->hits().size(); \
451 if (! all) {nh = 1; gotOneHit = kTRUE;} \
452 for (i = 0; i < nh; i++) { \
453 if (! all) cout << *(name ## Coll->hits()[i]); \
454 else (name ## Coll->hits()[i])->Print(); \
457 cout << "Parent Track of this hit" << endl; \
458 cout << *(name ## Coll->hits()[i]->parentTrack()) << endl; \
463 #define PrintHitCollectionL(Name,name,layer,Layers) \
464 PrintHeader(Name,name) \
465 if ( name ## Coll && nhits) { \
466 gotOneHit = kFALSE; \
467 for (k=0; !gotOneHit && k<name ## Coll->numberOf ## Layers(); k++) \
468 if (name ## Coll->layer(k)) \
470 { nh = name ## Coll->layer(k)->hits().size(); \
472 if (! all) {nh = 1; gotOneHit = kTRUE;} \
473 for (i = 0; i < nh; i++) { \
474 if (! all) cout << *(name ## Coll->layer(k)->hits()[i]); \
475 else (name ## Coll->layer(k)->hits()[i])->Print(); \
478 cout << "Parent Track of this hit" << endl; \
479 cout << *(name ## Coll->layer(k)->hits()[i]->parentTrack()) << endl; \
486 #define PrintHitCollectionW(Name,name,ladder,Ladders,wafer,Wafers) \
487 PrintHeader(Name,name); \
488 if ( name ## Coll && nhits) { \
489 gotOneHit = kFALSE; \
490 for (k=0; !gotOneHit && k<name ## Coll->numberOf ## Ladders(); k++) \
491 if (name ## Coll->ladder(k)) \
493 for (l = 0; gotOneHit && k<name ## Coll->ladder(k)->numberOf ## Wafers(); l++) \
494 { nh = name ## Coll->ladder(k)->wafer(l)->hits().size(); \
496 if (! all) {nh = 1; gotOneHit = kTRUE;} \
497 for (i = 0; i < nh; i++) { \
498 if (! all) cout << *(name ## Coll->ladder(k)->wafer(l)->hits()[i]); \
499 else (name ## Coll->ladder(k)->wafer(l)->hits()[i])->Print(); \
502 cout << "Parent Track of this hit" << endl; \
503 cout << *(name ## Coll->ladder(k)->wafer(l)->hits()[i]->parentTrack()) << endl; \
512 void StMcEvent::Print(Option_t *option)
const {
515 if (Opt.Contains(
"all",TString::kIgnoreCase)) all = 1;
522 cout <<
"---------------------------------------------------------" << endl;
523 cout <<
"StSPtrVecMcTrack" << endl;
525 cout <<
"Dumping first element in collection only (if available). " << endl;
526 cout <<
"---------------------------------------------------------" << endl;
527 Int_t Ntracks = tracks().size();
528 cout <<
"collection size = " << Ntracks << endl;
531 cout <<
"---------------------------------------------------------" << endl;
532 cout <<
"StMcTrack at " << tracks()[0] << endl;
533 cout <<
"---------------------------------------------------------" << endl;
534 cout << *(tracks()[0]) << endl;
537 tracks()[0]->Print(
"desc");
538 for (
int i = 0; i < Ntracks; i++) {
539 (tracks()[i])->particleDefinition();
540 (tracks()[i])->Print(
"all");
544 cout <<
"---------------------------------------------------------" << endl;
546 cout <<
"StMcVertex" << endl;
547 cout <<
"Dumping vertex info and first daughter track. " << endl;
548 cout <<
"---------------------------------------------------------" << endl;
549 if (primaryVertex()) {
550 cout <<
"Primary Vertex at " << primaryVertex() << endl;
551 cout <<
"---------------------------------------------------------" << endl;
552 cout << *primaryVertex() << endl;
553 cout <<
"---------------------------------------------------------" << endl;
554 cout <<
"First Daughter of Primary Vertex" << endl;
555 cout << *(primaryVertex()->daughter(0)) << endl;
556 cout <<
"---------------------------------------------------------" << endl;
558 else cout <<
"No Primary Vertex " << endl;
561 Int_t nVertices = vertices().size();
562 cout <<
"StSPtrVecMcVertex" << endl;
563 cout <<
"# of Vertices : " << nVertices << endl;
564 cout <<
"---------------------------------------------------------" << endl;
567 cout <<
"Daughters of second Vertex : " << vertices()[1]->numberOfDaughters() << endl;
568 if (vertices()[1]->numberOfDaughters()) {
569 cout <<
"First Daughter of this Vertex" << endl;
570 cout << *(vertices()[1]->daughter(0)) << endl;
574 cout <<
"---------------------------------------------------------" << endl;
575 cout <<
"Dumping vertices" << endl;
577 for (
int i = i1; i < nVertices; i++) {
579 cout <<
"---------------------------------------------------------" << endl;
580 cout <<
"StMcVertex " << i+1 <<
" at " << vertices()[i] << endl;
581 cout <<
"---------------------------------------------------------" << endl;
582 cout << *(vertices()[i]) << endl;
583 cout <<
"---------------------------------------------------------" << endl;
586 cout <<
"StMcVertex " << i+1 <<
" at ";
587 (vertices()[i])->Print();
591 UInt_t i, j, k, l, ii, nhits, nh;
594 if (tpcColl && nhits) {
596 for (k=0; !gotOneHit && k<tpcColl->numberOfSectors(); k++) {
597 for (j=0; !gotOneHit && j<tpcColl->sector(k)->numberOfPadrows(); j++) {
598 const StSPtrVecMcTpcHit &hits = tpcColl->sector(k)->padrow(j)->hits();
602 cout << *hits[0] << endl;
603 cout <<
"Parent Track of this hit" << endl;
604 cout << *(hits[0]->parentTrack()) << endl;
606 cout <<
"Dumping all the z coordinates and track key in this padrow" << endl;
607 cout <<
"Should be sorted according to z: " << endl;
608 cout <<
"---------------------------------------------------------" << endl;
609 for (i = 0; i < nh; i++)
610 cout <<
"\t" << hits[i]->position().z() <<
":" << hits[i]->parentTrack()->key();
613 else for (i = 0; i < nh; i++) {
614 hits[i]->Print(); cout << endl;
622 PrintHitCollectionL(Ftpc,ftpc,plane,Planes);
623 PrintHitCollection(Rich,rich);
625 PrintHeader(Svt,svt);
626 nhits = svtColl->numberOfHits();
627 if (svtColl && nhits) {
630 for (k=0; !gotOneHit && k<svtColl->numberOfBarrels(); k++)
631 for (j=0; !gotOneHit && j<svtColl->barrel(k)->numberOfLadders(); j++)
632 for (i=0; !gotOneHit && i<svtColl->barrel(k)->ladder(j)->numberOfWafers(); i++) {
633 nh = svtColl->barrel(k)->ladder(j)->wafer(i)->hits().size();
636 if (! all) {nh = 1; gotOneHit = kTRUE;}
637 for (ii = 0; ii < nh; ii++) {
639 cout << *(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii]) << endl;
640 cout <<
"Parent track of this Hit" << endl;
641 cout << *(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii]->parentTrack()) << endl;
642 }
else {(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii])->Print(); cout << endl;}
647 PrintHitCollectionW(Ssd,ssd,ladder,Ladders,wafer,Wafers);
648 PrintHitCollection(Tof,
tof);
649 PrintHitCollection(BTof,btof);
650 PrintHitCollection(Mtd,mtd);
652 PrintHitCollectionL(Ist,ist,layer,Layers);
653 PrintHitCollectionL(Fgt,fgt,layer,Layers);
654 PrintHitCollection(Etr,etr);
659 while( (ds = next())) {
661 if (emcColl) emcColl->Print(option);
668 for (
auto jk=mBegColl; jk<mEndColl;jk++) {
669 TObject *obj = *jk;
if (!obj)
continue;
670 b->Add(obj,obj->GetName());
675 #undef PrintHitCollection
676 #undef PrintHitCollectionL
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...