a5fe2c41 |
1 | #ifndef ALI_TRANSPORTMONITOR__H |
2 | #define ALI_TRANSPORTMONITOR__H |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ |
5 | |
6 | #ifndef ROOT_TNamed |
7 | #include "TNamed.h" |
8 | #endif |
9 | |
10 | #include <map> |
11 | |
12 | #ifndef ROOT_TStopwatch |
13 | #include "TStopwatch.h" |
14 | #endif |
15 | |
53cc3264 |
16 | #ifndef ROOT_TH2F |
17 | #include "TH2F.h" |
18 | #endif |
19 | |
a5fe2c41 |
20 | // Class that can be plugged in the simulation to monitor transport timing per |
21 | // particle for each geometry volume. |
22 | // |
23 | // andrei.gheata@cern.ch |
24 | |
a5fe2c41 |
25 | |
26 | |
27 | //______________________________________________________________________________ |
28 | class AliTransportMonitor : public TObject { |
29 | public: |
30 | //________________________________________________________________ |
31 | class AliTransportMonitorVol : public TNamed { |
32 | public: |
33 | //___________________________________________________ |
34 | class AliPMonData { |
35 | public: |
36 | Int_t fPDG; // particle PDG |
37 | Double_t fEdt; // Energy * dt integral |
38 | Double_t fTime; // Total transport time for the particle in this volume |
39 | AliPMonData() : fPDG(0), fEdt(0), fTime(0) {} |
40 | virtual ~AliPMonData() {} |
41 | ClassDef(AliPMonData, 1) // Basic monitoring info structure |
42 | }; |
43 | //___________________________________________________ |
44 | AliTransportMonitorVol(); |
45 | virtual ~AliTransportMonitorVol(); |
46 | |
47 | Int_t GetNtypes() const {return fNtypes;} |
48 | void StepInfo(Int_t pdg, |
49 | Double_t energy, |
50 | Double_t dt, |
51 | Double_t x, Double_t y, Double_t z); |
52 | Double_t GetTotalTime() const {return fTotalTime;} |
53 | Double_t GetTime(Int_t itype) const {return fPData[itype].fTime;} |
54 | Double_t GetEmed(Int_t itype) const {return (fTotalTime>0)?fPData[itype].fEdt/fTotalTime : 0.;} |
55 | Int_t GetPDG(Int_t itype) const {return fPData[itype].fPDG;} |
56 | TH2F *GetHistogram() const {return fTimeRZ;} |
53cc3264 |
57 | AliPMonData *GetPMonData(Int_t itype) const {AliPMonData obj = fPData[itype]; return &obj;} |
58 | void Merge(AliTransportMonitorVol* volM); |
a5fe2c41 |
59 | private: |
60 | AliPMonData &GetPMonData(Int_t pdg); |
61 | AliTransportMonitorVol(const AliTransportMonitorVol& other) : TNamed(other), fNtypes(0), fTotalTime(0), fPData(0), fTimeRZ(0), fParticles() {} |
62 | AliTransportMonitorVol &operator=(const AliTransportMonitorVol&) {return *this;} |
63 | private: |
64 | Int_t fNtypes; // Number of different particle types |
65 | Double_t fTotalTime; // Total time spent in this volume |
66 | AliPMonData *fPData; //[fNtypes] Array of particle data |
67 | TH2F *fTimeRZ; // Timing R-Z histogram per volume |
68 | typedef std::map<Int_t, Int_t> ParticleMap_t; |
69 | typedef ParticleMap_t::iterator ParticleMapIt_t; |
70 | ParticleMap_t fParticles; //! Map of stored particla data |
71 | |
72 | ClassDef(AliTransportMonitorVol,1) // Helper to hold particle info per volume |
73 | }; |
74 | //________________________________________________________________ |
75 | private: |
76 | AliTransportMonitor(const AliTransportMonitor&other) : TObject(other), fTotalTime(0), fTimer(), fVolumeMon(0) {} |
77 | AliTransportMonitor &operator=(const AliTransportMonitor&) {return *this;} |
78 | public: |
79 | AliTransportMonitor(); |
80 | AliTransportMonitor(Int_t nvolumes); |
81 | virtual ~AliTransportMonitor(); |
82 | |
83 | void StepInfo(Int_t volId, |
84 | Int_t pdg, |
85 | Double_t energy, |
86 | Double_t x, Double_t y, Double_t z); |
87 | void Print(Option_t *volName="") const; |
88 | void DummyStep(); |
89 | void Start(); |
90 | void Stop(); |
91 | void Export(const char *fname); |
53cc3264 |
92 | TObjArray* GetVolumes() const {return fVolumeMon;} |
93 | void Merge(AliTransportMonitor* mergeMon); |
a5fe2c41 |
94 | static AliTransportMonitor *Import(const char *fname); |
95 | private: |
96 | Double_t fTotalTime; // Total simulation time |
97 | TStopwatch fTimer; //! Global timer |
98 | TObjArray *fVolumeMon; // Array of monitoring objects per volume |
99 | |
100 | ClassDef(AliTransportMonitor,1) // Class to monitor timing per volume |
101 | }; |
102 | //______________________________________________________________________________ |
103 | |
104 | |
105 | #endif //ALI_TRANSPORTMONITOR__H |