00001
00138 #include "StThreeVectorF.hh"
00139
00140 #include "StMcEvent.hh"
00141 #include "StMcTpcHitCollection.hh"
00142 #include "StMcFtpcHitCollection.hh"
00143 #include "StMcRichHitCollection.hh"
00144 #include "StMcCtbHitCollection.hh"
00145 #include "StMcSvtHitCollection.hh"
00146 #include "StMcSsdHitCollection.hh"
00147 #include "StMcEmcHitCollection.hh"
00148 #include "StMcTofHitCollection.hh"
00149 #include "StMcBTofHitCollection.hh"
00150 #include "StMcMtdHitCollection.hh"
00151 #include "StMcPixelHitCollection.hh"
00152 #include "StMcIstHitCollection.hh"
00153 #include "StMcFgtHitCollection.hh"
00154 #include "StMcEtrHitCollection.hh"
00155 #include "StMcContainers.hh"
00156 #include "StMcVertex.hh"
00157 #include "StMcTrack.hh"
00158 #include "StMcTpcHit.hh"
00159 #include "StMcFtpcHit.hh"
00160 #include "StMcRichHit.hh"
00161 #include "StMcSvtHit.hh"
00162 #include "StMcSsdHit.hh"
00163 #include "StMcCalorimeterHit.hh"
00164 #include "StMcTofHit.hh"
00165 #include "StMcBTofHit.hh"
00166 #include "StMcMtdHit.hh"
00167 #include "StMcPixelHit.hh"
00168 #include "StMcIstHit.hh"
00169 #include "StMcFgtHit.hh"
00170 #include "StMcEtrHit.hh"
00171 #include "tables/St_g2t_event_Table.h"
00172 #include "TDataSetIter.h"
00173
00174
00175 TString StMcEvent::mCvsTag = "$Id: StMcEvent.cc,v 2.35 2012/04/19 16:22:51 perev Exp $";
00176 static const char rcsid[] = "$Id: StMcEvent.cc,v 2.35 2012/04/19 16:22:51 perev Exp $";
00177 ClassImp(StMcEvent);
00178
00179 void StMcEvent::initToZero()
00180 {
00181 memset(mBeg,0,mEnd-mBeg+1);
00182 }
00183
00184 void StMcEvent::makeColls()
00185 {
00186
00187
00188 mTpcHits = new StMcTpcHitCollection();
00189 mSvtHits = new StMcSvtHitCollection();
00190 mSsdHits = new StMcSsdHitCollection();
00191 mFtpcHits = new StMcFtpcHitCollection();
00192 mRichHits = new StMcRichHitCollection();
00193 mCtbHits = new StMcCtbHitCollection();
00194 mTofHits = new StMcTofHitCollection();
00195 mBTofHits = new StMcBTofHitCollection();
00196 mMtdHits = new StMcMtdHitCollection();
00197 mPixelHits = new StMcPixelHitCollection();
00198 mIstHits = new StMcIstHitCollection();
00199 mFgtHits = new StMcFgtHitCollection();
00200 mEtrHits = new StMcEtrHitCollection();
00201 }
00202
00203
00204 StMcEvent::StMcEvent() :TDataSet("StMcEvent")
00205 {
00206 initToZero();
00207 }
00208
00209
00210 StMcEvent::StMcEvent(g2t_event_st* evTable)
00211 :TDataSet("StMcEvent"),
00212 mEventGeneratorEventLabel(evTable->eg_label),
00213 mEventNumber(evTable->n_event),
00214 mRunNumber(evTable->n_run),
00215 mType (evTable->event_type),
00216 mZWest(evTable->n_part_prot_west),
00217 mNWest(evTable->n_part_neut_west),
00218 mZEast(evTable->n_part_prot_east),
00219 mNEast(evTable->n_part_neut_east),
00220 mEvGenFSTracks(evTable->n_track_eg_fs),
00221 mPrimaryTracks(evTable->n_track_prim),
00222 mSubProcessId(evTable->subprocess_id),
00223 mImpactParameter(evTable->b_impact),
00224 mPhiReactionPlane(evTable->phi_impact),
00225 mTriggerTimeOffset(evTable->time_offset),
00226 mNBinary(evTable->n_binary),
00227 mNWoundedEast(evTable->n_wounded_east),
00228 mNWoundedWest(evTable->n_wounded_west),
00229 mNJets(evTable->njets)
00230 {
00231 makeColls();
00232 }
00233
00234
00235
00236 StMcEvent::StMcEvent(const StMcEvent&) { }
00237
00238
00239 const StMcEvent& StMcEvent::operator=(const StMcEvent&) { return *this;}
00240
00241
00242 StMcEvent::~StMcEvent()
00243 {
00244 for (int jk=1; mBegColl+jk<mEndColl;jk++) {
00245 delete mBegColl[jk]; mBegColl[jk]=0;
00246 }
00247 for(int jk=0;jk<(int)mTracks.size() ;jk++) {delete mTracks[jk] ;}
00248 mTracks.clear();
00249
00250 for(int jk=0;jk<(int)mVertices.size();jk++) {delete mVertices[jk];}
00251 mVertices.clear();
00252 }
00253
00254
00255 int StMcEvent::operator==(const StMcEvent& e) const
00256 {
00257 return (e.mEventNumber == mEventNumber &&
00258 e.mRunNumber == mRunNumber &&
00259 e.mType == mType
00260 );
00261 }
00262
00263
00264 int StMcEvent::operator!=(const StMcEvent& e) const
00265 {
00266 return !(e == *this);
00267 }
00268
00269
00270 ostream& operator<<(ostream& os, const StMcEvent& e)
00271 {
00272 os << "Label: " << e.eventGeneratorEventLabel()
00273 << "\tRun: " << e.runNumber()
00274 << "\tId: " << e.eventNumber()
00275 << "\tType: " << e.type() << endl;
00276 os << "Participant Protons East: " << e.zEast() << "\tWest: " << e.zWest() << endl;
00277 os << "Participant Neutrons East: " << e.nEast() << "\tWest: " << e.nWest() << endl;
00278 os << "# Ev. Gen. Fin. St. Track: " << e.eventGeneratorFinalStateTracks()
00279 << "\tNumber of Primary Tracks : " << e.numberOfPrimaryTracks() << endl;
00280 os << "Subprocess Id : " << e.subProcessId() << endl;
00281 os << "Impact Parameter : " << e.impactParameter() << endl;
00282 os << "Phi Reaction Pl. : " << e.phiReactionPlane() << endl;
00283 os << "Trig. Time Offset: " << e.triggerTimeOffset() << endl;
00284 os << "N Binary Coll. : " << e.nBinary() << endl;
00285 os << "N Wounded East : " << e.nWoundedEast() << endl;
00286 os << "N Wounded West : " << e.nWoundedWest() << endl;
00287 os << "N Jets : " << e.nJets() << endl;
00288 return os;
00289 }
00290
00291
00292
00293 void StMcEvent::setEventGeneratorEventLabel(unsigned long val) { mEventGeneratorEventLabel = val; }
00294
00295
00296 void StMcEvent::setEventNumber(unsigned long val) { mEventNumber = val; }
00297
00298
00299 void StMcEvent::setRunNumber(unsigned long val) { mRunNumber = val; }
00300
00301
00302 void StMcEvent::setType(unsigned long val) { mType = val; }
00303
00304
00305 void StMcEvent::setZWest(unsigned long val) { mZWest = val; }
00306
00307
00308 void StMcEvent::setNWest(unsigned long val) { mNWest = val; }
00309
00310
00311 void StMcEvent::setZEast(unsigned long val) { mZEast = val; }
00312
00313
00314 void StMcEvent::setNEast(unsigned long val) { mNEast = val; }
00315
00316
00317 void StMcEvent::setEventGeneratorFinalStateTracks(unsigned long val){ mEvGenFSTracks = val; }
00318
00319
00320 void StMcEvent::setNumberOfPrimaryTracks(unsigned long val){ mPrimaryTracks = val; }
00321
00322
00323 void StMcEvent::setImpactParameter(float val) { mImpactParameter = val; }
00324
00325
00326 void StMcEvent::setPhiReactionPlane(float val) { mPhiReactionPlane = val; }
00327
00328
00329 void StMcEvent::setTriggerTimeOffset(float val) { mTriggerTimeOffset = val; }
00330
00331
00332 void StMcEvent::setNBinary(unsigned long val) { mNBinary = val; }
00333
00334
00335 void StMcEvent::setNWoundedEast(unsigned long val) { mNWoundedEast = val; }
00336
00337
00338 void StMcEvent::setNWoundedWest(unsigned long val) { mNWoundedWest = val; }
00339
00340
00341 void StMcEvent::setNJets(unsigned long val) { mNJets = val; }
00342
00343
00344 void StMcEvent::setPrimaryVertex(StMcVertex* val) { mPrimaryVertex = val; }
00345
00346
00347 void StMcEvent::setTpcHitCollection(StMcTpcHitCollection* val)
00348 {
00349 if (mTpcHits && mTpcHits!= val) delete mTpcHits;
00350 mTpcHits = val;
00351 }
00352
00353
00354 void StMcEvent::setSvtHitCollection(StMcSvtHitCollection* val)
00355 {
00356 if (mSvtHits && mSvtHits!= val) delete mSvtHits;
00357 mSvtHits = val;
00358 }
00359
00360
00361 void StMcEvent::setSsdHitCollection(StMcSsdHitCollection* val)
00362 {
00363 if (mSsdHits && mSsdHits!= val) delete mSsdHits;
00364 mSsdHits = val;
00365 }
00366
00367
00368 void StMcEvent::setFtpcHitCollection(StMcFtpcHitCollection* val)
00369 {
00370 if (mFtpcHits && mFtpcHits!= val) delete mFtpcHits;
00371 mFtpcHits = val;
00372 }
00373
00374
00375 void StMcEvent::setRichHitCollection(StMcRichHitCollection* val)
00376 {
00377 if (mRichHits && mRichHits!= val) delete mRichHits;
00378 mRichHits = val;
00379 }
00380 #if 0
00381
00382 void StMcEvent::setBemcHitCollection(StMcEmcHitCollection* val)
00383 {
00384 if (mBemcHits && mBemcHits!= val) delete mBemcHits;
00385 mBemcHits = val;
00386 }
00387
00388
00389 void StMcEvent::setBprsHitCollection(StMcEmcHitCollection* val)
00390 {
00391 if (mBprsHits && mBprsHits!= val) delete mBprsHits;
00392 mBprsHits = val;
00393 }
00394
00395
00396 void StMcEvent::setBsmdeHitCollection(StMcEmcHitCollection* val)
00397 {
00398 if (mBsmdeHits && mBsmdeHits!= val) delete mBsmdeHits;
00399 mBsmdeHits = val;
00400 }
00401
00402
00403 void StMcEvent::setBsmdpHitCollection(StMcEmcHitCollection* val)
00404 {
00405 if (mBsmdpHits && mBsmdpHits!= val) delete mBsmdpHits;
00406 mBsmdpHits = val;
00407 }
00408 #endif
00409
00410 void StMcEvent::setTofHitCollection(StMcTofHitCollection* val)
00411 {
00412 if (mTofHits && mTofHits!= val) delete mTofHits;
00413 mTofHits = val;
00414 }
00415
00416 void StMcEvent::setBTofHitCollection(StMcBTofHitCollection* val)
00417 {
00418 if (mBTofHits && mBTofHits!= val) delete mBTofHits;
00419 mBTofHits = val;
00420 }
00421
00422 void StMcEvent::setMtdHitCollection(StMcMtdHitCollection* val)
00423 {
00424 if (mMtdHits && mMtdHits!= val) delete mMtdHits;
00425 mMtdHits = val;
00426 }
00427 #if 0
00428
00429 void StMcEvent::setEemcHitCollection(StMcEmcHitCollection* val)
00430 {
00431 if (mEemcHits && mEemcHits!= val) delete mEemcHits;
00432 mEemcHits = val;
00433 }
00434
00435
00436 void StMcEvent::setEprsHitCollection(StMcEmcHitCollection* val)
00437 {
00438 if (mEprsHits && mEprsHits!= val) delete mEprsHits;
00439 mEprsHits = val;
00440 }
00441
00442
00443 void StMcEvent::setEsmduHitCollection(StMcEmcHitCollection* val)
00444 {
00445 if (mEsmduHits && mEsmduHits!= val) delete mEsmduHits;
00446 mEsmduHits = val;
00447 }
00448
00449
00450 void StMcEvent::setEsmdvHitCollection(StMcEmcHitCollection* val)
00451 {
00452 if (mEsmdvHits && mEsmdvHits!= val) delete mEsmdvHits;
00453 mEsmdvHits = val;
00454 }
00455 #endif
00456
00457 void StMcEvent::setPixelHitCollection(StMcPixelHitCollection* val)
00458 {
00459 if (mPixelHits && mPixelHits!= val) delete mPixelHits;
00460 mPixelHits = val;
00461 }
00462
00463
00464 void StMcEvent::setIstHitCollection(StMcIstHitCollection* val)
00465 {
00466 if (mIstHits && mIstHits!= val) delete mIstHits;
00467 mIstHits = val;
00468 }
00469
00470
00471
00472 void StMcEvent::setFgtHitCollection(StMcFgtHitCollection* val)
00473 {
00474 if (mFgtHits && mFgtHits!= val) delete mFgtHits;
00475 mFgtHits = val;
00476 }
00477
00478
00479 #define PrintHeader(Name,name) \
00480 const StMc ## Name ## HitCollection *name ## Coll = name ## HitCollection();\
00481 cout << "---------------------------------------------------------" << endl;\
00482 if (! all) {\
00483 cout << "StMc"#Name"HitCollection at " << (void*) name ## Coll << endl; \
00484 cout << "Dumping collection size"; \
00485 cout << " and one hit only."; \
00486 cout << endl; \
00487 } \
00488 cout << "---------------------------------------------------------" << endl;\
00489 nhits = name ## Coll->numberOfHits();\
00490 cout << "# of hits in StMc"#Name"HitCollection = " << nhits << endl;
00491 #define PrintHitCollection(Name,name) \
00492 PrintHeader(Name,name) \
00493 if ( name ## Coll && nhits) { \
00494 nh = name ## Coll->hits().size(); \
00495 if (nh) { \
00496 if (! all) {nh = 1; gotOneHit = kTRUE;} \
00497 for (i = 0; i < nh; i++) { \
00498 if (! all) cout << *(name ## Coll->hits()[i]); \
00499 else (name ## Coll->hits()[i])->Print(); \
00500 cout << endl; \
00501 if (! all) { \
00502 cout << "Parent Track of this hit" << endl; \
00503 cout << *(name ## Coll->hits()[i]->parentTrack()) << endl; \
00504 } \
00505 } \
00506 } \
00507 }
00508 #define PrintHitCollectionL(Name,name,layer,Layers) \
00509 PrintHeader(Name,name) \
00510 if ( name ## Coll && nhits) { \
00511 gotOneHit = kFALSE; \
00512 for (k=0; !gotOneHit && k<name ## Coll->numberOf ## Layers(); k++) \
00513 if (name ## Coll->layer(k)) \
00514 { \
00515 { nh = name ## Coll->layer(k)->hits().size(); \
00516 if (nh) { \
00517 if (! all) {nh = 1; gotOneHit = kTRUE;} \
00518 for (i = 0; i < nh; i++) { \
00519 if (! all) cout << *(name ## Coll->layer(k)->hits()[i]); \
00520 else (name ## Coll->layer(k)->hits()[i])->Print(); \
00521 cout << endl; \
00522 if (! all) { \
00523 cout << "Parent Track of this hit" << endl; \
00524 cout << *(name ## Coll->layer(k)->hits()[i]->parentTrack()) << endl; \
00525 } \
00526 } \
00527 } \
00528 } \
00529 } \
00530 }
00531 #define PrintHitCollectionW(Name,name,ladder,Ladders,wafer,Wafers) \
00532 PrintHeader(Name,name); \
00533 if ( name ## Coll && nhits) { \
00534 gotOneHit = kFALSE; \
00535 for (k=0; !gotOneHit && k<name ## Coll->numberOf ## Ladders(); k++) \
00536 if (name ## Coll->ladder(k)) \
00537 { \
00538 for (l = 0; gotOneHit && k<name ## Coll->ladder(k)->numberOf ## Wafers(); l++) \
00539 { nh = name ## Coll->ladder(k)->wafer(l)->hits().size(); \
00540 if (nh) { \
00541 if (! all) {nh = 1; gotOneHit = kTRUE;} \
00542 for (i = 0; i < nh; i++) { \
00543 if (! all) cout << *(name ## Coll->ladder(k)->wafer(l)->hits()[i]); \
00544 else (name ## Coll->ladder(k)->wafer(l)->hits()[i])->Print(); \
00545 cout << endl; \
00546 if (! all) { \
00547 cout << "Parent Track of this hit" << endl; \
00548 cout << *(name ## Coll->ladder(k)->wafer(l)->hits()[i]->parentTrack()) << endl; \
00549 } \
00550 } \
00551 } \
00552 } \
00553 } \
00554 }
00555
00556
00557 void StMcEvent::Print(Option_t *option) const {
00558 TString Opt(option);
00559 Int_t all = 0;
00560 if (Opt.Contains("all",TString::kIgnoreCase)) all = 1;
00561
00562
00563
00564
00565
00566
00567 cout << "---------------------------------------------------------" << endl;
00568 cout << "StSPtrVecMcTrack" << endl;
00569 if (! all)
00570 cout << "Dumping first element in collection only (if available). " << endl;
00571 cout << "---------------------------------------------------------" << endl;
00572 Int_t Ntracks = tracks().size();
00573 cout << "collection size = " << Ntracks << endl;
00574 if (Ntracks) {
00575 if (! all) {
00576 cout << "---------------------------------------------------------" << endl;
00577 cout << "StMcTrack at " << tracks()[0] << endl;
00578 cout << "---------------------------------------------------------" << endl;
00579 cout << *(tracks()[0]) << endl;
00580 }
00581 else {
00582 tracks()[0]->Print("desc");
00583 for (int i = 0; i < Ntracks; i++) {
00584 (tracks()[i])->particleDefinition();
00585 (tracks()[i])->Print("all");
00586 }
00587 }
00588 }
00589 cout << "---------------------------------------------------------" << endl;
00590 if (! all) {
00591 cout << "StMcVertex" << endl;
00592 cout << "Dumping vertex info and first daughter track. " << endl;
00593 cout << "---------------------------------------------------------" << endl;
00594 if (primaryVertex()) {
00595 cout << "Primary Vertex at " << primaryVertex() << endl;
00596 cout << "---------------------------------------------------------" << endl;
00597 cout << *primaryVertex() << endl;
00598 cout << "---------------------------------------------------------" << endl;
00599 cout << "First Daughter of Primary Vertex" << endl;
00600 cout << *(primaryVertex()->daughter(0)) << endl;
00601 cout << "---------------------------------------------------------" << endl;
00602 }
00603 else cout << "No Primary Vertex " << endl;
00604 }
00605 Int_t i1 = 0;
00606 Int_t nVertices = vertices().size();
00607 cout << "StSPtrVecMcVertex" << endl;
00608 cout << "# of Vertices : " << nVertices << endl;
00609 cout << "---------------------------------------------------------" << endl;
00610 if (nVertices > 1) {
00611 if (! all) {
00612 cout << "Daughters of second Vertex : " << vertices()[1]->numberOfDaughters() << endl;
00613 if (vertices()[1]->numberOfDaughters()) {
00614 cout << "First Daughter of this Vertex" << endl;
00615 cout << *(vertices()[1]->daughter(0)) << endl;
00616 }
00617 i1 = 1;
00618 nVertices = 2;
00619 cout << "---------------------------------------------------------" << endl;
00620 cout << "Dumping vertices" << endl;
00621 }
00622 for (int i = i1; i < nVertices; i++) {
00623 if (! all) {
00624 cout << "---------------------------------------------------------" << endl;
00625 cout << "StMcVertex " << i+1 << " at " << vertices()[i] << endl;
00626 cout << "---------------------------------------------------------" << endl;
00627 cout << *(vertices()[i]) << endl;
00628 cout << "---------------------------------------------------------" << endl;
00629 }
00630 else {
00631 cout << "StMcVertex " << i+1 << " at ";
00632 (vertices()[i])->Print();
00633 }
00634 }
00635 }
00636 UInt_t i, j, k, l, ii, nhits, nh;
00637 Bool_t gotOneHit;
00638 PrintHeader(Tpc,tpc)
00639 if (tpcColl && nhits) {
00640 gotOneHit = kFALSE;
00641 for (k=0; !gotOneHit && k<tpcColl->numberOfSectors(); k++) {
00642 for (j=0; !gotOneHit && j<tpcColl->sector(k)->numberOfPadrows(); j++) {
00643 const StSPtrVecMcTpcHit &hits = tpcColl->sector(k)->padrow(j)->hits();
00644 nh = hits.size();
00645 if (nh) {
00646 if (! all ) {
00647 cout << *hits[0] << endl;
00648 cout << "Parent Track of this hit" << endl;
00649 cout << *(hits[0]->parentTrack()) << endl;
00650 gotOneHit = kTRUE;
00651 cout << "Dumping all the z coordinates and track key in this padrow" << endl;
00652 cout << "Should be sorted according to z: " << endl;
00653 cout << "---------------------------------------------------------" << endl;
00654 for (i = 0; i < nh; i++)
00655 cout << "\t" << hits[i]->position().z() << ":" << hits[i]->parentTrack()->key();
00656 cout << endl;
00657 }
00658 else for (i = 0; i < nh; i++) {
00659 hits[i]->Print(); cout << endl;
00660 }
00661 }
00662
00663 }
00664 }
00665 }
00666
00667 PrintHitCollectionL(Ftpc,ftpc,plane,Planes);
00668 PrintHitCollection(Rich,rich);
00669
00670 PrintHeader(Svt,svt);
00671 nhits = svtColl->numberOfHits();
00672 if (svtColl && nhits) {
00673
00674 gotOneHit = kFALSE;
00675 for (k=0; !gotOneHit && k<svtColl->numberOfBarrels(); k++)
00676 for (j=0; !gotOneHit && j<svtColl->barrel(k)->numberOfLadders(); j++)
00677 for (i=0; !gotOneHit && i<svtColl->barrel(k)->ladder(j)->numberOfWafers(); i++) {
00678 nh = svtColl->barrel(k)->ladder(j)->wafer(i)->hits().size();
00679
00680 if (nh) {
00681 if (! all) {nh = 1; gotOneHit = kTRUE;}
00682 for (ii = 0; ii < nh; ii++) {
00683 if (! all) {
00684 cout << *(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii]) << endl;
00685 cout << "Parent track of this Hit" << endl;
00686 cout << *(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii]->parentTrack()) << endl;
00687 } else {(svtColl->barrel(k)->ladder(j)->wafer(i)->hits()[ii])->Print(); cout << endl;}
00688 }
00689 }
00690 }
00691 }
00692 PrintHitCollectionW(Ssd,ssd,ladder,Ladders,wafer,Wafers);
00693 PrintHitCollection(Tof,tof);
00694 PrintHitCollection(BTof,btof);
00695 PrintHitCollection(Mtd,mtd);
00696 PrintHitCollectionL(Pixel,pixel,layer,Layers);
00697 PrintHitCollectionL(Ist,ist,layer,Layers);
00698 PrintHitCollectionL(Fgt,fgt,layer,Layers);
00699 PrintHitCollection(Etr,etr);
00700
00701 TDataSet *mcEvent = (TDataSet *) this;
00702 TDataSetIter next(mcEvent);
00703 TDataSet *ds = 0;
00704 while( (ds = next())) {
00705 StMcEmcHitCollection *emcColl = dynamic_cast<StMcEmcHitCollection *>(ds);
00706 if (emcColl) emcColl->Print(option);
00707 }
00708 }
00709
00710 void StMcEvent::Browse(TBrowser *b)
00711 {
00712
00713 for (int jk=1; mBegColl+jk<mEndColl;jk++) {
00714 TObject *obj = mBegColl[jk]; if (!obj) continue;
00715 b->Add(obj,obj->GetName());
00716 }
00717 TDataSet::Browse(b);
00718 }
00719
00720 #undef PrintHitCollection
00721 #undef PrintHitCollectionL
00722 #undef PrintHeader
00723