StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcEvent.cc
1 
150 #include "StThreeVectorF.hh"
151 
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"
185 
186 
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 $";
189 ClassImp(StMcEvent);
190 //______________________________________________________________________________
191 void StMcEvent::initToZero()
192 {
193  memset(mBeg,0,mEnd-mBeg+1);
194 }
195 //______________________________________________________________________________
196 void StMcEvent::makeColls()
197 {
198  // Create the collections
199 
200  mTpcHits = new StMcTpcHitCollection();
201  mSvtHits = new StMcSvtHitCollection();
202  mSsdHits = new StMcSsdHitCollection();
203  mFtpcHits = new StMcFtpcHitCollection();
204  mRichHits = new StMcRichHitCollection();
205  mCtbHits = new StMcCtbHitCollection();
206  mTofHits = new StMcTofHitCollection();
207  mBTofHits = new StMcBTofHitCollection();
208  mMtdHits = new StMcMtdHitCollection();
209  mPxlHits = new StMcPxlHitCollection();
210  mIstHits = new StMcIstHitCollection();
211  mFgtHits = new StMcFgtHitCollection();
212  mEtrHits = new StMcEtrHitCollection();
213 }
214 
215 //______________________________________________________________________________
216 StMcEvent::StMcEvent() :TDataSet("StMcEvent")
217 {
218  initToZero();
219 }
220 
221 //______________________________________________________________________________
222 StMcEvent::StMcEvent(g2t_event_st* evTable)
223  :TDataSet("StMcEvent")
224 {
225  initToZero();
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;
244  makeColls();
245 }
246 
247 
248 //______________________________________________________________________________
249 StMcEvent::StMcEvent(const StMcEvent&) { /* noop */} // private
250 
251 //______________________________________________________________________________
252 const StMcEvent& StMcEvent::operator=(const StMcEvent&) { return *this;} // private
253 
254 //______________________________________________________________________________
255 StMcEvent::~StMcEvent()
256 {
257  for (auto jk=mBegColl; jk<mEndColl;jk++) {
258  delete *jk; *jk=0;
259  }
260  for(auto jk=0;jk<(int)mTracks.size() ;jk++) {delete mTracks[jk] ;}
261  mTracks.clear();
262 
263  for(int jk=0;jk<(int)mVertices.size();jk++) {delete mVertices[jk];}
264  mVertices.clear();
265 }
266 
267 //______________________________________________________________________________
268 int StMcEvent::operator==(const StMcEvent& e) const
269 {
270  return (e.mEventNumber == mEventNumber &&
271  e.mRunNumber == mRunNumber &&
272  e.mType == mType
273  );
274 }
275 
276 //______________________________________________________________________________
277 int StMcEvent::operator!=(const StMcEvent& e) const
278 {
279  return !(e == *this); // invoke operator==()
280 }
281 
282 //______________________________________________________________________________
283 ostream& operator<<(ostream& os, const StMcEvent& e)
284 {
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;
301  return os;
302 }
303 
304 
305 //______________________________________________________________________________
306 void StMcEvent::setEventGeneratorEventLabel(unsigned long val) { mEventGeneratorEventLabel = val; }
307 
308 //______________________________________________________________________________
309 void StMcEvent::setEventNumber(unsigned long val) { mEventNumber = val; }
310 
311 //______________________________________________________________________________
312 void StMcEvent::setRunNumber(unsigned long val) { mRunNumber = val; }
313 
314 //______________________________________________________________________________
315 void StMcEvent::setType(unsigned long val) { mType = val; }
316 
317 //______________________________________________________________________________
318 void StMcEvent::setZWest(unsigned long val) { mZWest = val; }
319 //______________________________________________________________________________
320 
321 void StMcEvent::setNWest(unsigned long val) { mNWest = val; }
322 
323 //______________________________________________________________________________
324 void StMcEvent::setZEast(unsigned long val) { mZEast = val; }
325 
326 //______________________________________________________________________________
327 void StMcEvent::setNEast(unsigned long val) { mNEast = val; }
328 
329 //______________________________________________________________________________
330 void StMcEvent::setEventGeneratorFinalStateTracks(unsigned long val){ mEvGenFSTracks = val; }
331 
332 //______________________________________________________________________________
333 void StMcEvent::setNumberOfPrimaryTracks(unsigned long val){ mPrimaryTracks = val; }
334 
335 //______________________________________________________________________________
336 void StMcEvent::setImpactParameter(float val) { mImpactParameter = val; }
337 
338 //______________________________________________________________________________
339 void StMcEvent::setPhiReactionPlane(float val) { mPhiReactionPlane = val; }
340 
341 //______________________________________________________________________________
342 void StMcEvent::setTriggerTimeOffset(float val) { mTriggerTimeOffset = val; }
343 
344 //______________________________________________________________________________
345 void StMcEvent::setNBinary(unsigned long val) { mNBinary = val; }
346 
347 //______________________________________________________________________________
348 void StMcEvent::setNWoundedEast(unsigned long val) { mNWoundedEast = val; }
349 
350 //______________________________________________________________________________
351 void StMcEvent::setNWoundedWest(unsigned long val) { mNWoundedWest = val; }
352 
353 //______________________________________________________________________________
354 void StMcEvent::setNJets(unsigned long val) { mNJets = val; }
355 
356 //______________________________________________________________________________
357 void StMcEvent::setPrimaryVertex(StMcVertex* val) { mPrimaryVertex = val; }
358 
359 //______________________________________________________________________________
360 void StMcEvent::setTpcHitCollection(StMcTpcHitCollection* val)
361 {
362  if (mTpcHits!= val) delete mTpcHits;
363  mTpcHits = val;
364 }
365 
366 //______________________________________________________________________________
367 void StMcEvent::setSvtHitCollection(StMcSvtHitCollection* val)
368 {
369  if (mSvtHits!= val) delete mSvtHits;
370  mSvtHits = val;
371 }
372 
373 //______________________________________________________________________________
374 void StMcEvent::setSsdHitCollection(StMcSsdHitCollection* val)
375 {
376  if (mSsdHits!= val) delete mSsdHits;
377  mSsdHits = val;
378 }
379 
380 //______________________________________________________________________________
381 void StMcEvent::setFtpcHitCollection(StMcFtpcHitCollection* val)
382 {
383  if (mFtpcHits!= val) delete mFtpcHits;
384  mFtpcHits = val;
385 }
386 
387 //______________________________________________________________________________
388 void StMcEvent::setRichHitCollection(StMcRichHitCollection* val)
389 {
390  if (mRichHits!= val) delete mRichHits;
391  mRichHits = val;
392 }
393 //______________________________________________________________________________
394 void StMcEvent::setTofHitCollection(StMcTofHitCollection* val)
395 {
396  if (mTofHits!= val) delete mTofHits;
397  mTofHits = val;
398 }
399 //______________________________________________________________________________
400 void StMcEvent::setBTofHitCollection(StMcBTofHitCollection* val)
401 {
402  if (mBTofHits!= val) delete mBTofHits;
403  mBTofHits = val;
404 }
405 //______________________________________________________________________________
406 void StMcEvent::setMtdHitCollection(StMcMtdHitCollection* val)
407 {
408  if (mMtdHits!= val) delete mMtdHits;
409  mMtdHits = val;
410 }
411 //______________________________________________________________________________
412 void StMcEvent::setPxlHitCollection(StMcPxlHitCollection* val)
413 {
414  if (mPxlHits!= val) delete mPxlHits;
415  mPxlHits = val;
416 }
417 
418 //______________________________________________________________________________
419 void StMcEvent::setIstHitCollection(StMcIstHitCollection* val)
420 {
421  if (mIstHits!= val) delete mIstHits;
422  mIstHits = val;
423 }
424 
425 
426 //______________________________________________________________________________
427 void StMcEvent::setFgtHitCollection(StMcFgtHitCollection* val)
428 {
429  if (mFgtHits!= val) delete mFgtHits;
430  mFgtHits = val;
431 }
432 //______________________________________________________________________________
433 //______________________________________________________________________________
434 #define PrintHeader(Name,name) \
435  const StMc ## Name ## HitCollection *name ## Coll = name ## HitCollection();\
436  cout << "---------------------------------------------------------" << endl;\
437  if (! all) {\
438  cout << "StMc"#Name"HitCollection at " << (void*) name ## Coll << endl; \
439  cout << "Dumping collection size"; \
440  cout << " and one hit only."; \
441  cout << endl; \
442  } \
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(); \
450  if (nh) { \
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(); \
455  cout << endl; \
456  if (! all) { \
457  cout << "Parent Track of this hit" << endl; \
458  cout << *(name ## Coll->hits()[i]->parentTrack()) << endl; \
459  } \
460  } \
461  } \
462  }
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)) \
469  { \
470  { nh = name ## Coll->layer(k)->hits().size(); \
471  if (nh) { \
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(); \
476  cout << endl; \
477  if (! all) { \
478  cout << "Parent Track of this hit" << endl; \
479  cout << *(name ## Coll->layer(k)->hits()[i]->parentTrack()) << endl; \
480  } \
481  } \
482  } \
483  } \
484  } \
485  }
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)) \
492  { \
493  for (l = 0; gotOneHit && k<name ## Coll->ladder(k)->numberOf ## Wafers(); l++) \
494  { nh = name ## Coll->ladder(k)->wafer(l)->hits().size(); \
495  if (nh) { \
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(); \
500  cout << endl; \
501  if (! all) { \
502  cout << "Parent Track of this hit" << endl; \
503  cout << *(name ## Coll->ladder(k)->wafer(l)->hits()[i]->parentTrack()) << endl; \
504  } \
505  } \
506  } \
507  } \
508  } \
509  }
510 
511 //________________________________________________________________________________
512 void StMcEvent::Print(Option_t *option) const {
513  TString Opt(option);
514  Int_t all = 0;
515  if (Opt.Contains("all",TString::kIgnoreCase)) all = 1;
516  //
517  // Printing all the information of the components of StMcEvent.
518  // For printing the simple data members of StMcEvent, use operator<<
519  //
520  //
521 
522  cout << "---------------------------------------------------------" << endl;
523  cout << "StSPtrVecMcTrack" << endl;
524  if (! all)
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;
529  if (Ntracks) {
530  if (! all) { // Option for printing only the first track.
531  cout << "---------------------------------------------------------" << endl;
532  cout << "StMcTrack at " << tracks()[0] << endl;
533  cout << "---------------------------------------------------------" << endl;
534  cout << *(tracks()[0]) << endl;
535  }
536  else { // Option for printing "all" tracks.
537  tracks()[0]->Print("desc");
538  for (int i = 0; i < Ntracks; i++) {
539  (tracks()[i])->particleDefinition();
540  (tracks()[i])->Print("all");
541  }
542  }
543  }
544  cout << "---------------------------------------------------------" << endl;
545  if (! all) {
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;
557  }
558  else cout << "No Primary Vertex " << endl;
559  }
560  Int_t i1 = 0;
561  Int_t nVertices = vertices().size();
562  cout << "StSPtrVecMcVertex" << endl;
563  cout << "# of Vertices : " << nVertices << endl;
564  cout << "---------------------------------------------------------" << endl;
565  if (nVertices > 1) {
566  if (! all) {
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;
571  }
572  i1 = 1;
573  nVertices = 2;
574  cout << "---------------------------------------------------------" << endl;
575  cout << "Dumping vertices" << endl;
576  }
577  for (int i = i1; i < nVertices; i++) {
578  if (! all) {
579  cout << "---------------------------------------------------------" << endl;
580  cout << "StMcVertex " << i+1 << " at " << vertices()[i] << endl;
581  cout << "---------------------------------------------------------" << endl;
582  cout << *(vertices()[i]) << endl;
583  cout << "---------------------------------------------------------" << endl;
584  }
585  else {
586  cout << "StMcVertex " << i+1 << " at ";
587  (vertices()[i])->Print();
588  }
589  }
590  }
591  UInt_t i, j, k, l, ii, nhits, nh;
592  Bool_t gotOneHit;
593  PrintHeader(Tpc,tpc)
594  if (tpcColl && nhits) {
595  gotOneHit = kFALSE;
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();
599  nh = hits.size();
600  if (nh) {
601  if (! all ) {
602  cout << *hits[0] << endl;
603  cout << "Parent Track of this hit" << endl;
604  cout << *(hits[0]->parentTrack()) << endl;
605  gotOneHit = kTRUE;
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();
611  cout << endl;
612  }
613  else for (i = 0; i < nh; i++) {
614  hits[i]->Print(); cout << endl;
615  }
616  } // check for nh
617 
618  } // padrow loop
619  }// sector loop
620  }
621 
622  PrintHitCollectionL(Ftpc,ftpc,plane,Planes);
623  PrintHitCollection(Rich,rich);
624 
625  PrintHeader(Svt,svt);
626  nhits = svtColl->numberOfHits();
627  if (svtColl && nhits) {
628 
629  gotOneHit = kFALSE;
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();
634 
635  if (nh) {
636  if (! all) {nh = 1; gotOneHit = kTRUE;}
637  for (ii = 0; ii < nh; ii++) {
638  if (! all) {
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;}
643  }
644  }
645  }
646  }
647  PrintHitCollectionW(Ssd,ssd,ladder,Ladders,wafer,Wafers);
648  PrintHitCollection(Tof,tof);
649  PrintHitCollection(BTof,btof);
650  PrintHitCollection(Mtd,mtd);
651  //PrintHitCollectionL(Pxl,pxl,sector,Sectors);
652  PrintHitCollectionL(Ist,ist,layer,Layers);
653  PrintHitCollectionL(Fgt,fgt,layer,Layers);
654  PrintHitCollection(Etr,etr);
655 
656  TDataSet *mcEvent = (TDataSet *) this;
657  TDataSetIter next(mcEvent);
658  TDataSet *ds = 0;
659  while( (ds = next())) {
660  StMcEmcHitCollection *emcColl = dynamic_cast<StMcEmcHitCollection *>(ds);
661  if (emcColl) emcColl->Print(option);
662  }
663 }
664 //______________________________________________________________________________
665 void StMcEvent::Browse(TBrowser *b)
666 {
667  // Browse this event (called by TBrowser).
668  for (auto jk=mBegColl; jk<mEndColl;jk++) {
669  TObject *obj = *jk; if (!obj) continue;
670  b->Add(obj,obj->GetName());
671  }
672  TDataSet::Browse(b);
673 }
674 //______________________________________________________________________________
675 #undef PrintHitCollection
676 #undef PrintHitCollectionL
677 #undef PrintHeader
678 
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: StMcEvent.cc:665
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TDataSet.cxx:297
Definition: tof.h:15
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
Definition: StMcEvent.hh:169