]>
Commit | Line | Data |
---|---|---|
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;} | |
6ad386ea | 56 | Double_t GetNSteps() const {return fNSteps;} |
a5fe2c41 | 57 | TH2F *GetHistogram() const {return fTimeRZ;} |
faf00b0d | 58 | AliPMonData *GetPMonData(Int_t itype) const {return &(fPData[itype]);} |
53cc3264 | 59 | void Merge(AliTransportMonitorVol* volM); |
a5fe2c41 | 60 | private: |
61 | AliPMonData &GetPMonData(Int_t pdg); | |
faf00b0d | 62 | AliTransportMonitorVol(const AliTransportMonitorVol& other) : TNamed(other), fNtypes(0), fTotalTime(0), fNSteps(0), fPData(0), fTimeRZ(0), fParticles() {} |
a5fe2c41 | 63 | AliTransportMonitorVol &operator=(const AliTransportMonitorVol&) {return *this;} |
64 | private: | |
65 | Int_t fNtypes; // Number of different particle types | |
66 | Double_t fTotalTime; // Total time spent in this volume | |
6ad386ea | 67 | Double_t fNSteps; // Total number of steps |
a5fe2c41 | 68 | AliPMonData *fPData; //[fNtypes] Array of particle data |
69 | TH2F *fTimeRZ; // Timing R-Z histogram per volume | |
70 | typedef std::map<Int_t, Int_t> ParticleMap_t; | |
71 | typedef ParticleMap_t::iterator ParticleMapIt_t; | |
72 | ParticleMap_t fParticles; //! Map of stored particla data | |
73 | ||
6ad386ea | 74 | ClassDef(AliTransportMonitorVol,2) // Helper to hold particle info per volume |
a5fe2c41 | 75 | }; |
76 | //________________________________________________________________ | |
77 | private: | |
78 | AliTransportMonitor(const AliTransportMonitor&other) : TObject(other), fTotalTime(0), fTimer(), fVolumeMon(0) {} | |
79 | AliTransportMonitor &operator=(const AliTransportMonitor&) {return *this;} | |
80 | public: | |
81 | AliTransportMonitor(); | |
82 | AliTransportMonitor(Int_t nvolumes); | |
83 | virtual ~AliTransportMonitor(); | |
84 | ||
85 | void StepInfo(Int_t volId, | |
86 | Int_t pdg, | |
87 | Double_t energy, | |
88 | Double_t x, Double_t y, Double_t z); | |
89 | void Print(Option_t *volName="") const; | |
90 | void DummyStep(); | |
91 | void Start(); | |
92 | void Stop(); | |
93 | void Export(const char *fname); | |
53cc3264 | 94 | TObjArray* GetVolumes() const {return fVolumeMon;} |
95 | void Merge(AliTransportMonitor* mergeMon); | |
a5fe2c41 | 96 | static AliTransportMonitor *Import(const char *fname); |
97 | private: | |
98 | Double_t fTotalTime; // Total simulation time | |
99 | TStopwatch fTimer; //! Global timer | |
100 | TObjArray *fVolumeMon; // Array of monitoring objects per volume | |
101 | ||
102 | ClassDef(AliTransportMonitor,1) // Class to monitor timing per volume | |
103 | }; | |
104 | //______________________________________________________________________________ | |
105 | ||
106 | ||
107 | #endif //ALI_TRANSPORTMONITOR__H |