00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 #include <typeinfo>
00176 #include <algorithm>
00177 #include "TClass.h"
00178 #include "TDataSetIter.h"
00179 #include "TObjectSet.h"
00180 #include "TBrowser.h"
00181 #include "StCalibrationVertex.h"
00182 #include "StDetectorState.h"
00183 #include "StEvent.h"
00184 #include "StEventClusteringHints.h"
00185 #include "StEventInfo.h"
00186 #include "StEventSummary.h"
00187 #include "StTpcHitCollection.h"
00188 #include "StRnDHitCollection.h"
00189 #include "StEtrHitCollection.h"
00190 #include "StSvtHitCollection.h"
00191 #include "StSsdHitCollection.h"
00192 #include "StFtpcHitCollection.h"
00193 #include "StEmcCollection.h"
00194 #include "StFmsCollection.h"
00195 #include "StRichCollection.h"
00196 #include "StRpsCollection.h"
00197 #include "StRunInfo.h"
00198 #include "StTofCollection.h"
00199 #include "StBTofCollection.h"
00200 #include "StMtdCollection.h"
00201 #include "StFpdCollection.h"
00202 #include "StPhmdCollection.h"
00203 #include "StTrackDetectorInfo.h"
00204 #include "StTriggerData.h"
00205 #include "StTriggerDetectorCollection.h"
00206 #include "StTriggerIdCollection.h"
00207 #include "StPrimaryVertex.h"
00208 #include "StL0Trigger.h"
00209 #include "StL1Trigger.h"
00210 #include "StL3Trigger.h"
00211 #include "StPsd.h"
00212 #include "event_header.h"
00213 #include "StAutoBrowse.h"
00214 #include "StEventBranch.h"
00215 #include "StHltEvent.h"
00216 #include "StFgtCollection.h"
00217
00218 #include "StTrackNode.h"
00219 #include "StTrack.h"
00220
00221 #ifndef ST_NO_NAMESPACES
00222 using std::swap;
00223 #endif
00224
00225 TString StEvent::mCvsTag = "$Id: StEvent.cxx,v 2.51 2012/04/16 20:22:16 ullrich Exp $";
00226 static const char rcsid[] = "$Id: StEvent.cxx,v 2.51 2012/04/16 20:22:16 ullrich Exp $";
00227
00228 ClassImp(StEvent)
00229
00230
00231 template<class T> void _lookup(T*& val, StSPtrVecObject &vec)
00232 {
00233 val = 0;
00234 for (unsigned int i=0; i<vec.size(); i++)
00235 if (vec[i] && typeid(*vec[i]) == typeid(T)) {
00236 val = static_cast<T*>(vec[i]);
00237 break;
00238 }
00239 }
00240
00241
00242 template<class T> void _lookupOrCreate(T*& val, StSPtrVecObject &vec)
00243 {
00244 T* t = 0;
00245 _lookup(t, vec);
00246 if (!t) {
00247 t = new T;
00248 vec.push_back(t);
00249 }
00250 val = t;
00251 }
00252
00253
00254 template<class T> void _lookupAndSet(T* val, StSPtrVecObject &vec)
00255 {
00256 for (unsigned int i=0; i<vec.size(); i++)
00257 if (vec[i] && typeid(*vec[i]) == typeid(T)) {
00258 delete vec[i];
00259 vec[i] = val;
00260 return;
00261 }
00262 if (!val) return;
00263 vec.push_back(val);
00264 }
00265
00266
00267 template<class T> void _lookupDynamic(T*& val, StSPtrVecObject &vec)
00268 {
00269 val = 0;
00270 for (unsigned int i=0; i<vec.size(); i++)
00271 if (vec[i]) {
00272 val = dynamic_cast<T*>(vec[i]);
00273 if (val) break;
00274 }
00275 }
00276
00277
00278 template<class T> void _lookupDynamicAndSet(T* val, StSPtrVecObject &vec)
00279 {
00280 T *test;
00281 for (unsigned int i=0; i<vec.size(); i++) {
00282 if (vec[i]) {
00283 test = dynamic_cast<T*>(vec[i]);
00284 if (test) {
00285 delete vec[i];
00286 vec[i] = val;
00287 return;
00288 }
00289 }
00290 }
00291 if (!val) return;
00292 vec.push_back(val);
00293 }
00294
00295
00296 void StEvent::initToZero() { }
00297
00298
00299 StEvent::StEvent() : StXRefMain("StEvent")
00300 {
00301 GenUUId();
00302 initToZero();
00303 }
00304
00305
00306 StEvent::~StEvent()
00307 { }
00308
00309 TString
00310 StEvent::type() const
00311 {
00312 StEventInfo* info = 0;
00313 _lookup(info, mContent);
00314 return info ? info->type() : TString();
00315 }
00316
00317 int
00318 StEvent::id() const
00319 {
00320 StEventInfo* info = 0;
00321 _lookup(info, mContent);
00322 return info ? info->id() : 0;
00323 }
00324
00325 int
00326 StEvent::runId() const
00327 {
00328 StEventInfo* info = 0;
00329 _lookup(info, mContent);
00330 return info ? info->runId() : 0;
00331 }
00332
00333 int
00334 StEvent::time() const
00335 {
00336 StEventInfo* info = 0;
00337 _lookup(info, mContent);
00338 return info ? info->time() : 0;
00339 }
00340
00341 unsigned int
00342 StEvent::triggerMask() const
00343 {
00344 StEventInfo* info = 0;
00345 _lookup(info, mContent);
00346 return info ? info->triggerMask() : 0;
00347 }
00348
00349 unsigned int
00350 StEvent::bunchCrossingNumber(unsigned int i) const
00351 {
00352 StEventInfo* info = 0;
00353 _lookup(info, mContent);
00354 return info ? info->bunchCrossingNumber(i) : 0;
00355 }
00356
00357 StEventInfo*
00358 StEvent::info()
00359 {
00360 StEventInfo* info = 0;
00361 _lookup(info, mContent);
00362 return info;
00363 }
00364
00365 const StEventInfo*
00366 StEvent::info() const
00367 {
00368 StEventInfo* info = 0;
00369 _lookup(info, mContent);
00370 return info;
00371 }
00372
00373 StRunInfo*
00374 StEvent::runInfo()
00375 {
00376 StRunInfo* info = 0;
00377 _lookup(info, mContent);
00378 return info;
00379 }
00380
00381 const StRunInfo*
00382 StEvent::runInfo() const
00383 {
00384 StRunInfo* info = 0;
00385 _lookup(info, mContent);
00386 return info;
00387 }
00388
00389 StEventSummary*
00390 StEvent::summary()
00391 {
00392 StEventSummary* summary = 0;
00393 _lookup(summary, mContent);
00394 return summary;
00395 }
00396
00397 const StEventSummary*
00398 StEvent::summary() const
00399 {
00400 StEventSummary* summary = 0;
00401 _lookup(summary, mContent);
00402 return summary;
00403 }
00404
00405 const TString&
00406 StEvent::cvsTag() { return mCvsTag; }
00407
00408
00409 StTpcHitCollection* StEvent::tpcHitCollection()
00410 {
00411 StTpcHitCollection *hits = 0;
00412 _lookup(hits, mContent);
00413 return hits;
00414 }
00415
00416
00417 const StTpcHitCollection*
00418 StEvent::tpcHitCollection() const
00419 {
00420 StTpcHitCollection *hits = 0;
00421 _lookup(hits, mContent);
00422 return hits;
00423 }
00424
00425
00426 StRnDHitCollection* StEvent::rndHitCollection()
00427 {
00428 StRnDHitCollection *hits = 0;
00429 _lookup(hits, mContent);
00430 return hits;
00431 }
00432
00433
00434 const StRnDHitCollection* StEvent::rndHitCollection() const
00435 {
00436 StRnDHitCollection *hits = 0;
00437 _lookup(hits, mContent);
00438 return hits;
00439 }
00440
00441
00442 const StEtrHitCollection* StEvent::etrHitCollection() const
00443 {
00444 StEtrHitCollection *hits = 0;
00445 _lookup(hits, mContent);
00446 return hits;
00447 }
00448
00449
00450 StEtrHitCollection* StEvent::etrHitCollection()
00451 {
00452 StEtrHitCollection *hits = 0;
00453 _lookup(hits, mContent);
00454 return hits;
00455 }
00456
00457 StFtpcHitCollection* StEvent::ftpcHitCollection()
00458 {
00459 StFtpcHitCollection *hits = 0;
00460 _lookup(hits, mContent);
00461 return hits;
00462 }
00463
00464 const StFtpcHitCollection*
00465 StEvent::ftpcHitCollection() const
00466 {
00467 StFtpcHitCollection *hits = 0;
00468 _lookup(hits, mContent);
00469 return hits;
00470 }
00471
00472 StSvtHitCollection*
00473 StEvent::svtHitCollection()
00474 {
00475 StSvtHitCollection *hits = 0;
00476 _lookup(hits, mContent);
00477 return hits;
00478 }
00479
00480 const StSvtHitCollection*
00481 StEvent::svtHitCollection() const
00482 {
00483 StSvtHitCollection *hits = 0;
00484 _lookup(hits, mContent);
00485 return hits;
00486 }
00487
00488 StSsdHitCollection*
00489 StEvent::ssdHitCollection()
00490 {
00491 StSsdHitCollection *hits = 0;
00492 _lookup(hits, mContent);
00493 return hits;
00494 }
00495
00496 const StSsdHitCollection*
00497 StEvent::ssdHitCollection() const
00498 {
00499 StSsdHitCollection *hits = 0;
00500 _lookup(hits, mContent);
00501 return hits;
00502 }
00503
00504 StEmcCollection*
00505 StEvent::emcCollection()
00506 {
00507 StEmcCollection *emc = 0;
00508 _lookup(emc, mContent);
00509 return emc;
00510 }
00511
00512 const StEmcCollection*
00513 StEvent::emcCollection() const
00514 {
00515 StEmcCollection *emc = 0;
00516 _lookup(emc, mContent);
00517 return emc;
00518 }
00519
00520 StFmsCollection*
00521 StEvent::fmsCollection()
00522 {
00523 StFmsCollection *fms = 0;
00524 _lookup(fms, mContent);
00525 return fms;
00526 }
00527
00528 const StFmsCollection*
00529 StEvent::fmsCollection() const
00530 {
00531 StFmsCollection *fms = 0;
00532 _lookup(fms, mContent);
00533 return fms;
00534 }
00535
00536 StRichCollection*
00537 StEvent::richCollection()
00538 {
00539 StRichCollection *rich = 0;
00540 _lookup(rich, mContent);
00541 return rich;
00542 }
00543
00544 const StRichCollection*
00545 StEvent::richCollection() const
00546 {
00547 StRichCollection *rich = 0;
00548 _lookup(rich, mContent);
00549 return rich;
00550 }
00551
00552 StRpsCollection*
00553 StEvent::rpsCollection()
00554 {
00555 StRpsCollection *rps = 0;
00556 _lookup(rps, mContent);
00557 return rps;
00558 }
00559
00560 const StRpsCollection*
00561 StEvent::rpsCollection() const
00562 {
00563 StRpsCollection *rps = 0;
00564 _lookup(rps, mContent);
00565 return rps;
00566 }
00567
00568 StTofCollection*
00569 StEvent::tofCollection()
00570 {
00571 StTofCollection *tof = 0;
00572 _lookup(tof, mContent);
00573 return tof;
00574 }
00575
00576 const StTofCollection*
00577 StEvent::tofCollection() const
00578 {
00579 StTofCollection *tof = 0;
00580 _lookup(tof, mContent);
00581 return tof;
00582 }
00583
00584 StBTofCollection*
00585 StEvent::btofCollection()
00586 {
00587 StBTofCollection *btof = 0;
00588 _lookup(btof, mContent);
00589 return btof;
00590 }
00591
00592 const StBTofCollection*
00593 StEvent::btofCollection() const
00594 {
00595 StBTofCollection *btof = 0;
00596 _lookup(btof, mContent);
00597 return btof;
00598 }
00599
00600 StMtdCollection*
00601 StEvent::mtdCollection()
00602 {
00603 StMtdCollection *mtd = 0;
00604 _lookup(mtd, mContent);
00605 return mtd;
00606 }
00607
00608 const StMtdCollection*
00609 StEvent::mtdCollection() const
00610 {
00611 StMtdCollection *mtd = 0;
00612 _lookup(mtd, mContent);
00613 return mtd;
00614 }
00615
00616 StFpdCollection*
00617 StEvent::fpdCollection()
00618 {
00619 StFpdCollection *fpd = 0;
00620 _lookup(fpd, mContent);
00621 return fpd;
00622 }
00623
00624 const StFpdCollection*
00625 StEvent::fpdCollection() const
00626 {
00627 StFpdCollection *fpd = 0;
00628 _lookup(fpd, mContent);
00629 return fpd;
00630 }
00631
00632 StPhmdCollection*
00633 StEvent::phmdCollection()
00634 {
00635 StPhmdCollection *phmd = 0;
00636 _lookup(phmd, mContent);
00637 return phmd;
00638 }
00639
00640 const StPhmdCollection*
00641 StEvent::phmdCollection() const
00642 {
00643 StPhmdCollection *phmd = 0;
00644 _lookup(phmd, mContent);
00645 return phmd;
00646 }
00647
00648 StTriggerDetectorCollection*
00649 StEvent::triggerDetectorCollection()
00650 {
00651 StTriggerDetectorCollection *trg = 0;
00652 _lookup(trg, mContent);
00653 return trg;
00654 }
00655
00656 const StTriggerDetectorCollection*
00657 StEvent::triggerDetectorCollection() const
00658 {
00659 StTriggerDetectorCollection *trg = 0;
00660 _lookup(trg, mContent);
00661 return trg;
00662 }
00663
00664 StTriggerIdCollection*
00665 StEvent::triggerIdCollection()
00666 {
00667 StTriggerIdCollection *trg = 0;
00668 _lookup(trg, mContent);
00669 return trg;
00670 }
00671
00672 const StTriggerIdCollection*
00673 StEvent::triggerIdCollection() const
00674 {
00675 StTriggerIdCollection *trg = 0;
00676 _lookup(trg, mContent);
00677 return trg;
00678 }
00679
00680 StTriggerData*
00681 StEvent::triggerData()
00682 {
00683 StTriggerData *trg = 0;
00684 _lookupDynamic(trg, mContent);
00685 return trg;
00686 }
00687
00688 const StTriggerData*
00689 StEvent::triggerData() const
00690 {
00691 StTriggerData *trg = 0;
00692 _lookupDynamic(trg, mContent);
00693 return trg;
00694 }
00695
00696 StL0Trigger*
00697 StEvent::l0Trigger()
00698 {
00699 StL0Trigger *trg = 0;
00700 _lookup(trg, mContent);
00701 return trg;
00702 }
00703
00704 const StL0Trigger*
00705 StEvent::l0Trigger() const
00706 {
00707 StL0Trigger *trg = 0;
00708 _lookup(trg, mContent);
00709 return trg;
00710 }
00711
00712 StL1Trigger*
00713 StEvent::l1Trigger()
00714 {
00715 StL1Trigger *trg = 0;
00716 _lookup(trg, mContent);
00717 return trg;
00718 }
00719
00720 const StL1Trigger*
00721 StEvent::l1Trigger() const
00722 {
00723 StL1Trigger *trg = 0;
00724 _lookup(trg, mContent);
00725 return trg;
00726 }
00727
00728 StL3Trigger*
00729 StEvent::l3Trigger()
00730 {
00731 StL3Trigger *trg = 0;
00732 _lookup(trg, mContent);
00733 return trg;
00734 }
00735
00736 const StL3Trigger*
00737 StEvent::l3Trigger() const
00738 {
00739 StL3Trigger *trg = 0;
00740 _lookup(trg, mContent);
00741 return trg;
00742 }
00743
00744 StHltEvent*
00745 StEvent::hltEvent()
00746 {
00747 StHltEvent *hlt = 0;
00748 _lookup(hlt, mContent);
00749 return hlt;
00750 }
00751
00752 const StHltEvent*
00753 StEvent::hltEvent() const
00754 {
00755 StHltEvent *hlt = 0;
00756 _lookup(hlt, mContent);
00757 return hlt;
00758 }
00759
00760 StFgtCollection*
00761 StEvent::fgtCollection()
00762 {
00763 StFgtCollection *fgtCollection = 0;
00764 _lookup(fgtCollection, mContent);
00765 return fgtCollection;
00766 }
00767
00768 const StFgtCollection*
00769 StEvent::fgtCollection() const
00770 {
00771 StFgtCollection *fgtCollection = 0;
00772 _lookup(fgtCollection, mContent);
00773 return fgtCollection;
00774 }
00775
00776 StSPtrVecTrackDetectorInfo&
00777 StEvent::trackDetectorInfo()
00778 {
00779 StSPtrVecTrackDetectorInfo *info = 0;
00780 _lookupOrCreate(info, mContent);
00781 return *info;
00782 }
00783
00784 const StSPtrVecTrackDetectorInfo&
00785 StEvent::trackDetectorInfo() const
00786 {
00787 StSPtrVecTrackDetectorInfo *info = 0;
00788 _lookupOrCreate(info, mContent);
00789 return *info;
00790 }
00791
00792 StSPtrVecTrackNode&
00793 StEvent::trackNodes()
00794 {
00795 StSPtrVecTrackNode *nodes = 0;
00796 _lookupOrCreate(nodes, mContent);
00797 return *nodes;
00798 }
00799
00800 const StSPtrVecTrackNode&
00801 StEvent::trackNodes() const
00802 {
00803 StSPtrVecTrackNode *nodes = 0;
00804 _lookupOrCreate(nodes, mContent);
00805 return *nodes;
00806 }
00807
00808 unsigned int
00809 StEvent::numberOfPrimaryVertices() const
00810 {
00811 StSPtrVecPrimaryVertex *vertices = 0;
00812 _lookupOrCreate(vertices, mContent);
00813 return vertices ? vertices->size() : 0;
00814 }
00815
00816 StPrimaryVertex*
00817 StEvent::primaryVertex(unsigned int i)
00818 {
00819 StSPtrVecPrimaryVertex *vertices = 0;
00820 _lookup(vertices, mContent);
00821 if (vertices && i < vertices->size())
00822 return (*vertices)[i];
00823 else
00824 return 0;
00825 }
00826
00827 const StPrimaryVertex*
00828 StEvent::primaryVertex(unsigned int i) const
00829 {
00830 StSPtrVecPrimaryVertex *vertices = 0;
00831 _lookup(vertices, mContent);
00832 if (vertices && i < vertices->size())
00833 return (*vertices)[i];
00834 else
00835 return 0;
00836 }
00837
00838 unsigned int
00839 StEvent::numberOfCalibrationVertices() const
00840 {
00841 StSPtrVecCalibrationVertex *vertices = 0;
00842 _lookupOrCreate(vertices, mContent);
00843 return vertices ? vertices->size() : 0;
00844 }
00845
00846 StCalibrationVertex*
00847 StEvent::calibrationVertex(unsigned int i)
00848 {
00849 StSPtrVecCalibrationVertex *vertices = 0;
00850 _lookup(vertices, mContent);
00851 if (vertices && i < vertices->size())
00852 return (*vertices)[i];
00853 else
00854 return 0;
00855 }
00856
00857 const StCalibrationVertex*
00858 StEvent::calibrationVertex(unsigned int i) const
00859 {
00860 StSPtrVecCalibrationVertex *vertices = 0;
00861 _lookup(vertices, mContent);
00862 if (vertices && i < vertices->size())
00863 return (*vertices)[i];
00864 else
00865 return 0;
00866 }
00867
00868 StSPtrVecV0Vertex&
00869 StEvent::v0Vertices()
00870 {
00871 StSPtrVecV0Vertex *vertices = 0;
00872 _lookupOrCreate(vertices, mContent);
00873 return *vertices;
00874 }
00875
00876 const StSPtrVecV0Vertex&
00877 StEvent::v0Vertices() const
00878 {
00879 StSPtrVecV0Vertex *vertices = 0;
00880 _lookupOrCreate(vertices, mContent);
00881 return *vertices;
00882 }
00883
00884 StSPtrVecXiVertex&
00885 StEvent::xiVertices()
00886 {
00887 StSPtrVecXiVertex *vertices = 0;
00888 _lookupOrCreate(vertices, mContent);
00889 return *vertices;
00890 }
00891
00892 const StSPtrVecXiVertex&
00893 StEvent::xiVertices() const
00894 {
00895 StSPtrVecXiVertex *vertices = 0;
00896 _lookupOrCreate(vertices, mContent);
00897 return *vertices;
00898 }
00899
00900 StSPtrVecKinkVertex&
00901 StEvent::kinkVertices()
00902 {
00903 StSPtrVecKinkVertex *vertices = 0;
00904 _lookupOrCreate(vertices, mContent);
00905 return *vertices;
00906 }
00907
00908 const StSPtrVecKinkVertex&
00909 StEvent::kinkVertices() const
00910 {
00911 StSPtrVecKinkVertex *vertices = 0;
00912 _lookupOrCreate(vertices, mContent);
00913 return *vertices;
00914 }
00915
00916 StDetectorState*
00917 StEvent::detectorState(StDetectorId det)
00918 {
00919 StSPtrVecDetectorState *states = 0;
00920 _lookup(states, mContent);
00921 if (states)
00922 for (unsigned int i=0; i<states->size(); i++)
00923 if ((*states)[i]->detector() == det) return (*states)[i];
00924 return 0;
00925 }
00926
00927 const StDetectorState*
00928 StEvent::detectorState(StDetectorId det) const
00929 {
00930 StSPtrVecDetectorState *states = 0;
00931 _lookup(states, mContent);
00932 if (states)
00933 for (unsigned int i=0; i<states->size(); i++)
00934 if ((*states)[i]->detector() == det) return (*states)[i];
00935 return 0;
00936 }
00937
00938 StPsd*
00939 StEvent::psd(StPwg p, int i)
00940 {
00941 StPsd *thePsd = 0;
00942 for (unsigned int k=0; k<mContent.size(); k++) {
00943 thePsd = dynamic_cast<StPsd*>(mContent[k]);
00944 if (thePsd && thePsd->pwg() == p && thePsd->id() == i)
00945 return thePsd;
00946 }
00947 return 0;
00948 }
00949
00950 const StPsd*
00951 StEvent::psd(StPwg p, int i) const
00952 {
00953 const StPsd *thePsd = 0;
00954 for (unsigned int k=0; k<mContent.size(); k++) {
00955 thePsd = dynamic_cast<StPsd*>(mContent[k]);
00956 if (thePsd && thePsd->pwg() == p && thePsd->id() == i)
00957 return thePsd;
00958 }
00959 return 0;
00960 }
00961
00962 unsigned int
00963 StEvent::numberOfPsds() const
00964 {
00965 int nPsds = 0;
00966 for (unsigned int i=0; i<mContent.size(); i++)
00967 if (dynamic_cast<StPsd*>(mContent[i])) nPsds++;
00968 return nPsds;
00969 }
00970
00971 unsigned int
00972 StEvent::numberOfPsds(StPwg p) const
00973 {
00974 StPsd* thePsd;
00975 int nPsds = 0;
00976 for (unsigned int i=0; i<mContent.size(); i++) {
00977 thePsd = dynamic_cast<StPsd*>(mContent[i]);
00978 if (thePsd && thePsd->pwg() == p) nPsds++;
00979 }
00980 return nPsds;
00981 }
00982
00983 StSPtrVecObject&
00984 StEvent::content() { return mContent; }
00985
00986 const StEventClusteringHints*
00987 StEvent::clusteringHints() const
00988 {
00989 StEventClusteringHints *hints = 0;
00990 _lookupOrCreate(hints, mContent);
00991 return hints;
00992 }
00993
00994 StEventClusteringHints*
00995 StEvent::clusteringHints()
00996 {
00997 StEventClusteringHints *hints = 0;
00998 _lookupOrCreate(hints, mContent);
00999 hints->SetParent(this);
01000 return hints;
01001 }
01002
01003 void
01004 StEvent::setType(const char* val)
01005 {
01006 StEventInfo* info = 0;
01007 _lookupOrCreate(info, mContent);
01008 info->setType(val);
01009 }
01010
01011 void
01012 StEvent::setRunId(int val)
01013 {
01014 StEventInfo* info = 0;
01015 _lookupOrCreate(info, mContent);
01016 info->setRunId(val);
01017 }
01018
01019 void
01020 StEvent::setId(int val)
01021 {
01022 StEventInfo* info = 0;
01023 _lookupOrCreate(info, mContent);
01024 info->setId(val);
01025 }
01026
01027 void
01028 StEvent::setTime(int val)
01029 {
01030 StEventInfo* info = 0;
01031 _lookupOrCreate(info, mContent);
01032 info->setTime(val);
01033 }
01034
01035 void
01036 StEvent::setTriggerMask(unsigned int val)
01037 {
01038 StEventInfo* info = 0;
01039 _lookupOrCreate(info, mContent);
01040 info->setTriggerMask(val);
01041 }
01042
01043 void
01044 StEvent::setBunchCrossingNumber(unsigned int val, unsigned int i)
01045 {
01046 StEventInfo* info = 0;
01047 _lookupOrCreate(info, mContent);
01048 info->setBunchCrossingNumber(val, i);
01049 }
01050
01051 void
01052 StEvent::setInfo(StEventInfo* val)
01053 {
01054 _lookupAndSet(val, mContent);
01055 }
01056
01057 void
01058 StEvent::setRunInfo(StRunInfo* val)
01059 {
01060 _lookupAndSet(val, mContent);
01061 }
01062
01063 void
01064 StEvent::setSummary(StEventSummary* val)
01065 {
01066 _lookupAndSet(val, mContent);
01067 }
01068
01069 void
01070 StEvent::setTpcHitCollection(StTpcHitCollection* val)
01071 {
01072 _lookupAndSet(val, mContent);
01073 }
01074
01075 void
01076 StEvent::setRnDHitCollection(StRnDHitCollection* val)
01077 {
01078 _lookupAndSet(val, mContent);
01079 }
01080
01081 void
01082 StEvent::setFtpcHitCollection(StFtpcHitCollection* val)
01083 {
01084 _lookupAndSet(val, mContent);
01085 }
01086
01087 void
01088 StEvent::setSvtHitCollection(StSvtHitCollection* val)
01089 {
01090 _lookupAndSet(val, mContent);
01091 }
01092
01093 void
01094 StEvent::setSsdHitCollection(StSsdHitCollection* val)
01095 {
01096 _lookupAndSet(val, mContent);
01097 }
01098
01099
01100 void
01101 StEvent::setEmcCollection(StEmcCollection* val)
01102 {
01103 _lookupAndSet(val, mContent);
01104 }
01105
01106 void
01107 StEvent::setFmsCollection(StFmsCollection* val)
01108 {
01109 _lookupAndSet(val, mContent);
01110 }
01111
01112 void
01113 StEvent::setRichCollection(StRichCollection* val)
01114 {
01115 _lookupAndSet(val, mContent);
01116 }
01117
01118 void
01119 StEvent::setRpsCollection(StRpsCollection* val)
01120 {
01121 _lookupAndSet(val, mContent);
01122 }
01123
01124 void
01125 StEvent::setTofCollection(StTofCollection* val)
01126 {
01127 _lookupAndSet(val, mContent);
01128 }
01129
01130 void
01131 StEvent::setBTofCollection(StBTofCollection* val)
01132 {
01133 _lookupAndSet(val, mContent);
01134 }
01135
01136 void
01137 StEvent::setMtdCollection(StMtdCollection* val)
01138 {
01139 _lookupAndSet(val, mContent);
01140 }
01141
01142 void
01143 StEvent::setFpdCollection(StFpdCollection* val)
01144 {
01145 _lookupAndSet(val, mContent);
01146 }
01147
01148 void
01149 StEvent::setPhmdCollection(StPhmdCollection* val)
01150 {
01151 _lookupAndSet(val, mContent);
01152 }
01153
01154 void
01155 StEvent::setTriggerDetectorCollection(StTriggerDetectorCollection* val)
01156 {
01157 _lookupAndSet(val, mContent);
01158 }
01159
01160 void
01161 StEvent::setTriggerIdCollection(StTriggerIdCollection* val)
01162 {
01163 _lookupAndSet(val, mContent);
01164 }
01165
01166 void
01167 StEvent::setTriggerData(StTriggerData* val)
01168 {
01169 _lookupDynamicAndSet(val, mContent);
01170 }
01171
01172 void
01173 StEvent::setL0Trigger(StL0Trigger* val)
01174 {
01175 _lookupAndSet(val, mContent);
01176 }
01177
01178 void
01179 StEvent::setL1Trigger(StL1Trigger* val)
01180 {
01181 _lookupAndSet(val, mContent);
01182 }
01183
01184 void
01185 StEvent::setL3Trigger(StL3Trigger* val)
01186 {
01187 _lookupAndSet(val, mContent);
01188 }
01189
01190 void
01191 StEvent::setEtrHitCollection(StEtrHitCollection* val)
01192 {
01193 _lookupAndSet(val, mContent);
01194 }
01195
01196 void
01197 StEvent::setHltEvent(StHltEvent* val)
01198 {
01199 _lookupAndSet(val, mContent);
01200 }
01201
01202 void
01203 StEvent::setFgtCollection(StFgtCollection* val)
01204 {
01205 _lookupAndSet(val, mContent);
01206 }
01207
01208 void
01209 StEvent::addPrimaryVertex(StPrimaryVertex* vertex, StPrimaryVertexOrder order)
01210 {
01211 if (!vertex) return;
01212
01213
01214
01215
01216 StSPtrVecPrimaryVertex* vertexVector = 0;
01217 _lookupOrCreate(vertexVector, mContent);
01218 vertexVector->push_back(vertex);
01219
01220
01221
01222
01223
01224
01225
01226
01227 int i;
01228 switch (order) {
01229 case(orderByNumberOfDaughters):
01230 for (i=vertexVector->size()-1; i>0; i--) {
01231 if ((*vertexVector)[i]->numberOfDaughters() > (*vertexVector)[i-1]->numberOfDaughters())
01232 swap((*vertexVector)[i], (*vertexVector)[i-1]);
01233 else
01234 break;
01235 }
01236 break;
01237
01238 case(orderByRanking):
01239 default:
01240 for (i=vertexVector->size()-1; i>0; i--) {
01241 if ((*vertexVector)[i]->ranking() > (*vertexVector)[i-1]->ranking())
01242 swap((*vertexVector)[i], (*vertexVector)[i-1]);
01243 else
01244 break;
01245 }
01246 break;
01247 }
01248 }
01249
01250 void
01251 StEvent::addCalibrationVertex(StCalibrationVertex* vertex)
01252 {
01253 if (vertex) {
01254 StSPtrVecCalibrationVertex* vertexVector = 0;
01255 _lookupOrCreate(vertexVector, mContent);
01256 vertexVector->push_back(vertex);
01257 }
01258 }
01259
01260 void
01261 StEvent::addDetectorState(StDetectorState *state)
01262 {
01263 if (state) {
01264 StSPtrVecDetectorState* stateVector = 0;
01265 _lookupOrCreate(stateVector, mContent);
01266 stateVector->push_back(state);
01267 }
01268 }
01269
01270 void
01271 StEvent::addPsd(StPsd* p)
01272 {
01273 if (p) {
01274 if (psd(p->pwg(), p->id()))
01275 cerr << "StEvent::addPsd(): Error, PSD with same identifiers already exist. Nothing added." << endl;
01276 else
01277 mContent.push_back(p);
01278 }
01279 }
01280
01281 void StEvent::removePsd(StPsd* p)
01282 {
01283 StSPtrVecObjectIterator iter;
01284 if (p) {
01285 for (iter = mContent.begin(); iter != mContent.end(); iter++)
01286 if (*iter == p)
01287 mContent.erase(iter);
01288 }
01289 }
01290
01291 void StEvent::Browse(TBrowser* b)
01292 {
01293 if (!b) b = new TBrowser("StEvent",(TObject*)0);
01294 StAutoBrowse::Browse(this,b);
01295 TDataSet::Browse(b);
01296 }
01297
01298 void StEvent::statistics()
01299 {
01300 cout << "Statistics and information for event " << id() << endl;
01301 cout << "\tthis: " << static_cast<void*>(this) << endl;
01302
01303 cout << "\ttype: " << type() << endl;
01304 cout << "\tid: " << id() << endl;
01305 cout << "\trunId: " << runId() << endl;
01306 cout << "\ttime: " << time() << endl;
01307 cout << "\ttriggerMask: " << triggerMask() << endl;
01308 cout << "\tbunchCrossingNumber(0): " << bunchCrossingNumber(0) << endl;
01309 cout << "\tbunchCrossingNumber(1): " << bunchCrossingNumber(1) << endl;
01310 cout << "\tStEventSummary: " << static_cast<void*>(summary());
01311 cout << "\tStTpcHitCollection: " << static_cast<void*>(tpcHitCollection());
01312 cout << "\tStRnDHitCollection: " << static_cast<void*>(rndHitCollection());
01313 cout << "\tStFtpcHitCollection: " << static_cast<void*>(ftpcHitCollection());
01314 cout << "\tStSvtHitCollection: " << static_cast<void*>(svtHitCollection());
01315 cout << "\tStSsdHitCollection: " << static_cast<void*>(ssdHitCollection());
01316 cout << "\tStEmcCollection: " << static_cast<void*>(emcCollection());
01317 cout << "\tStFmsCollection: " << static_cast<void*>(fmsCollection());
01318 cout << "\tStRichCollection: " << static_cast<void*>(richCollection());
01319 cout << "\tStRpsCollection: " << static_cast<void*>(rpsCollection());
01320 cout << "\tStTofCollection: " << static_cast<void*>(tofCollection());
01321 cout << "\tStBTofCollection: " << static_cast<void*>(btofCollection());
01322 cout << "\tStMtdCollection: " << static_cast<void*>(mtdCollection());
01323 cout << "\tStFpdCollection: " << static_cast<void*>(fpdCollection());
01324 cout << "\tStPhmdCollection: " << static_cast<void*>(phmdCollection());
01325 cout << "\tStL0Trigger: " << static_cast<void*>(l0Trigger());
01326 cout << "\tStL1Trigger: " << static_cast<void*>(l0Trigger());
01327 cout << "\tStL3Trigger: " << static_cast<void*>(l3Trigger());
01328 cout << "\tStHltEvent: " << static_cast<void*>(hltEvent());
01329 cout << "\tStTriggerDetectorCollection: " << static_cast<void*>(triggerDetectorCollection());
01330 cout << "\tStTriggerIdCollection: " << static_cast<void*>(triggerIdCollection());
01331 cout << "\tStTriggerData: " << static_cast<void*>(triggerData());
01332 cout << "\tStPrimaryVertex: " << static_cast<void*>(primaryVertex(0));
01333 cout << "\tnumberOfPrimaryVertices: " << numberOfPrimaryVertices() << endl;
01334 cout << "\tStCalibrationVertex: " << static_cast<void*>(calibrationVertex(0));
01335 cout << "\tnumberOfCalibrationVertices: " << numberOfCalibrationVertices() << endl;
01336 cout << "\t# of TPC hits: " << (tpcHitCollection() ? tpcHitCollection()->numberOfHits() : 0) << endl;
01337 cout << "\t# of FTPC hits: " << (ftpcHitCollection() ? ftpcHitCollection()->numberOfHits() : 0) << endl;
01338 cout << "\t# of SVT hits: " << (svtHitCollection() ? svtHitCollection()->numberOfHits() : 0) << endl;
01339 cout << "\t# of SSD hits: " << (ssdHitCollection() ? ssdHitCollection()->numberOfHits() : 0) << endl;
01340 cout << "\t# of track nodes: " << trackNodes().size() << endl;
01341 cout << "\t# of primary tracks: " << (primaryVertex(0) ? primaryVertex(0)->numberOfDaughters() : 0) << endl;
01342 cout << "\t# of V0s: " << v0Vertices().size() << endl;
01343 cout << "\t# of Xis: " << xiVertices().size() << endl;
01344 cout << "\t# of Kinks: " << kinkVertices().size() << endl;
01345 cout << "\t# of hits in EMC: " << (emcCollection() ? emcCollection()->barrelPoints().size() : 0) << endl;
01346 cout << "\t# of hits in EEMC: " << (emcCollection() ? emcCollection()->endcapPoints().size() : 0) << endl;
01347 cout << "\t# of hits in FGT: " << (fgtCollection() ? fgtCollection()->getNumHits() : 0) << endl;
01348 cout << "\t# of hits in RICH: " << (richCollection() ? richCollection()->getRichHits().size() : 0) << endl;
01349 cout << "\t# of PSDs: " << numberOfPsds() << endl;
01350 }
01351
01352 void StEvent::Split()
01353 {
01354 StEventClusteringHints *clu = clusteringHints();
01355 assert(clu);
01356 TDataSetIter next(this);
01357 TDataSet *ds;
01358
01359 while ((ds=next())) {
01360 if (ds->IsA()!=StEventBranch::Class()) continue;
01361 Remove(ds); delete ds;
01362 }
01363
01364 vector<string> brs = clu->listOfBranches();
01365 int nbrs = brs.size();
01366 for (int ibr =0; ibr < nbrs; ibr++) {
01367 string sbr = brs[ibr];
01368 if(sbr.size()==0) continue;
01369 const char *brName = sbr.c_str();
01370 assert(strncmp(brName,"evt_",4)==0 || strcmp(brName,"event")==0);
01371
01372 UInt_t tally = ((clu->branchId(brName)) << 22) | 1 ;
01373
01374 StEventBranch *obr = new StEventBranch(brName,this,tally);
01375 vector<string> cls = clu->listOfClasses(sbr.c_str());
01376 int ncls = cls.size();
01377 for (int icl =0; icl < ncls; icl++) {
01378 string scl = cls[icl];
01379 if(scl.size()==0) continue;
01380 obr->AddKlass(scl.c_str());
01381 }
01382 }
01383 }
01384
01385 Bool_t StEvent::Notify() {Split();return 0;}
01386
01387 void StEvent::Streamer(TBuffer &R__b)
01388 {
01389
01390
01391 UInt_t R__s, R__c;
01392 if (R__b.IsReading()) {
01393
01394 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
01395 if (R__v == 1) {
01396 TDataSet::Streamer(R__b);
01397 mContent.Streamer(R__b);
01398 R__b.CheckByteCount(R__s, R__c, Class());
01399 Split();
01400 return;
01401 } else {
01402 StXRefMain::Streamer(R__b);
01403 R__b.CheckByteCount(R__s, R__c, Class());
01404 }
01405
01406 } else {
01407
01408 TDataSetIter next(this);
01409 TDataSet *ds;
01410 while ((ds=next())) {
01411 if (ds->IsA()==StEventBranch::Class()) break;
01412 }
01413 if (!ds) {
01414 Split();}
01415
01416 R__c = R__b.WriteVersion(Class(), kTRUE);
01417 StXRefMain::Streamer(R__b);
01418 R__b.SetByteCount(R__c, kTRUE);
01419 }
01420 }
01421
01422 StSPtrVecHit* StEvent::hitCollection(const Char_t *name) {
01423 StSPtrVecHit *theHitCollection = 0;
01424 TObjectSet *set = (TObjectSet *) FindByName(name);
01425 if (set) theHitCollection = (StSPtrVecHit *) set->GetObject();
01426 return theHitCollection;
01427 }
01428
01429 void StEvent::addHitCollection(StSPtrVecHit* p, const Char_t *name) {
01430 if (p) {
01431 TObjectSet *set = (TObjectSet *) FindByName(name);
01432 if (set)
01433 cerr << "StEvent::addHitCollection(): Error, HitCollection with "
01434 << name << " already exist. Nothing added." << endl;
01435 else {
01436 set = new TObjectSet(name,p,kTRUE);
01437 Add(set);
01438 }
01439 }
01440 }
01441
01442 void StEvent::removeHitCollection(const Char_t *name) {
01443 TObjectSet *set = (TObjectSet *) FindByName(name);
01444 if (set) set->Delete();
01445 }
01446
01447 void StEvent::setIdTruth() {
01448 StSPtrVecTrackNode& trackNode = trackNodes();
01449 UInt_t nTracks = trackNode.size();
01450 StTrackNode *node=0;
01451 for (UInt_t i = 0; i < nTracks; i++) {
01452 node = trackNode[i];
01453 if (!node) continue;
01454 UInt_t notr = node->entries();
01455 for (UInt_t t = 0; t < notr; t++) {
01456 StTrack *track = node->track(t);
01457 track->setIdTruth();
01458 }
01459 }
01460
01461 Int_t noOfPrimaryVertices = numberOfPrimaryVertices();
01462 for (Int_t i = 0; i < noOfPrimaryVertices; i++) primaryVertex(i)->setIdTruth();
01463 Int_t noOfCalibrationVertices = numberOfCalibrationVertices();
01464 for (Int_t i = 0; i < noOfCalibrationVertices; i++) calibrationVertex(i)->setIdTruth();
01465 Int_t noOfv0Vertices = v0Vertices().size();
01466 for (Int_t i = 0; i < noOfv0Vertices; i++) ((StVertex *) v0Vertices()[i])->setIdTruth();
01467 Int_t noOfxiVertices = xiVertices().size();
01468 for (Int_t i = 0; i < noOfxiVertices; i++) ((StVertex *) xiVertices()[i])->setIdTruth();
01469 Int_t noOfkinkVertices = kinkVertices().size();
01470 for (Int_t i = 0; i < noOfkinkVertices; i++) ((StVertex *) kinkVertices()[i])->setIdTruth();
01471 }