]>
Commit | Line | Data |
---|---|---|
4ae78bb1 | 1 | #ifndef ALIPHOSGETTER_H |
2 | #define ALIPHOSGETTER_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
8 | //_________________________________________________________________________ | |
9 | // A singleton that returns various objects | |
10 | // Should be used on the analysis stage to avoid confusing between different | |
11 | // branches of reconstruction tree: e.g. reading RecPoints and TS made from | |
12 | // another set of RecPoints. | |
13 | // | |
14 | // The objects are retrived from folders. | |
15 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) | |
16 | // | |
17 | ||
18 | ||
19 | // --- ROOT system --- | |
20 | #include "TClonesArray.h" | |
7a9d98f9 | 21 | #include "TFolder.h" |
22 | #include "TTree.h" | |
68853e3a | 23 | #include "TFile.h" |
4ae78bb1 | 24 | class TString ; |
25 | class TParticle ; | |
26 | class TTask ; | |
27 | ||
28 | // --- Standard library --- | |
f404725b | 29 | #include <stdlib.h> |
931e9fdb | 30 | #include <iostream.h> |
4ae78bb1 | 31 | |
32 | // --- AliRoot header files --- | |
33 | ||
7a9d98f9 | 34 | #include "AliRun.h" |
35 | #include "AliPHOS.h" | |
cb34a1fa | 36 | #include "AliPHOSHit.h" |
37 | #include "AliPHOSDigit.h" | |
38 | #include "AliPHOSEmcRecPoint.h" | |
39 | #include "AliPHOSCpvRecPoint.h" | |
40 | #include "AliPHOSTrackSegment.h" | |
41 | #include "AliPHOSRecParticle.h" | |
4ae78bb1 | 42 | class AliPHOSGeometry ; |
4ae78bb1 | 43 | class AliPHOSDigitizer ; |
44 | class AliPHOSSDigitizer ; | |
4ae78bb1 | 45 | class AliPHOSClusterizer ; |
4ae78bb1 | 46 | class AliPHOSTrackSegmentMaker ; |
4ae78bb1 | 47 | class AliPHOSPID ; |
48 | ||
49 | class AliPHOSGetter : public TObject { | |
50 | ||
51 | public: | |
52 | ||
cb34a1fa | 53 | AliPHOSGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public |
fbf811ec | 54 | cerr << "ERROR: AliPHOSGetter is a singleton default ctor not callable" << endl ; |
4ae78bb1 | 55 | abort() ; |
56 | } | |
57 | AliPHOSGetter(const AliPHOSGetter & obj) { | |
58 | // cpy ctor requested by Coding Convention | |
59 | // but not yet needed | |
60 | abort() ; | |
61 | } | |
62 | ||
fbf811ec | 63 | AliPHOSGetter & operator = (const AliPHOSGetter & ) { |
64 | // assignement operator requested by coding convention, but not needed | |
65 | abort() ; | |
66 | return *this ; | |
67 | } | |
d071065d | 68 | virtual ~AliPHOSGetter() ; |
548f0134 | 69 | |
fbf811ec | 70 | //=========== Instantiators ================ |
71 | static AliPHOSGetter * GetInstance(const char* headerFile, | |
72 | const char* branchTitle = "Default", | |
73 | const Bool_t toSplit = kFALSE ) ; | |
74 | static AliPHOSGetter * GetInstance() ; | |
548f0134 | 75 | |
fbf811ec | 76 | //=========== General information about run ============== |
77 | const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; } | |
78 | const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; } | |
79 | const Bool_t BranchExists(const TString tree) const ; | |
b0bba0af | 80 | |
fbf811ec | 81 | //========== PHOSGeometry and PHOS ============= |
82 | const AliPHOS * PHOS() ; | |
83 | const AliPHOSGeometry * PHOSGeometry() ; | |
548f0134 | 84 | |
fbf811ec | 85 | //========== Methods to read something from file ========== |
86 | void Event(const Int_t event, const char * opt = "HSDRP") ; | |
87 | void Track(const Int_t itrack) ; | |
88 | void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when | |
89 | //digitizing is under the control ofAliRunDigitizer, | |
90 | //which opens all files etc. | |
91 | //========== Alarms ====================== | |
92 | TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; } | |
93 | const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; } | |
94 | const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; } | |
548f0134 | 95 | |
fbf811ec | 96 | //-----------------now getter's data-------------------------------------- |
548f0134 | 97 | |
fbf811ec | 98 | //=========== Primaries ============ |
99 | TTree * TreeK(TString filename="") ; | |
100 | TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; } | |
101 | const TParticle * Primary(Int_t index) const ; | |
102 | const Int_t NPrimaries()const { return fNPrimaries; } | |
103 | const TParticle * Secondary(TParticle * p, Int_t index=1) const ; | |
548f0134 | 104 | |
fbf811ec | 105 | //=========== Hits ================= |
9bd3caba | 106 | TTree * TreeH(TString filename="") ; |
fbf811ec | 107 | const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; } |
108 | const AliPHOSHit * Hit(Int_t index) { return dynamic_cast<const AliPHOSHit*>(Hits()->At(index) );} | |
cb34a1fa | 109 | |
fbf811ec | 110 | //=========== SDigits ============== |
111 | TTree * TreeS(TString filename="") ; | |
112 | TClonesArray * SDigits(const char * name = 0, const char * file=0) { | |
113 | return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; } | |
114 | //const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit *>(SDigits()->At(index)) ;} !!! why no such method ? | |
115 | const AliPHOSSDigitizer * SDigitizer(const char * name =0) const { | |
116 | return (const AliPHOSSDigitizer *) ReturnT("SDigitizer", name) ; // here static or dynamic cast does not work ! why ? | |
cb34a1fa | 117 | } |
548f0134 | 118 | |
fbf811ec | 119 | //========== Digits ================ |
120 | TTree * TreeD(TString filename="") ; | |
121 | TClonesArray * Digits(const char * name = 0)const { | |
122 | return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; } | |
548f0134 | 123 | //const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ? |
fbf811ec | 124 | const AliPHOSDigitizer * Digitizer(const char * name = 0) const { |
125 | return (const AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ; } | |
cb34a1fa | 126 | |
fbf811ec | 127 | //========== RecPoints ============= |
fbf811ec | 128 | TObjArray * EmcRecPoints(const char * name = 0) { |
129 | return dynamic_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ; } | |
548f0134 | 130 | //const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;} !!! why no such method ? |
fbf811ec | 131 | TObjArray * CpvRecPoints(const char * name = 0) { |
132 | return dynamic_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ; } | |
fbf811ec | 133 | const AliPHOSClusterizer * Clusterizer (const char * name =0) const { |
134 | return (const AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; // here static or dynamic cast does not work ! why ? | |
548f0134 | 135 | } |
cb34a1fa | 136 | |
fbf811ec | 137 | //========== TrackSegments ========== |
cb34a1fa | 138 | TClonesArray * TrackSegments(const char * name = 0) { |
fbf811ec | 139 | return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ; } |
140 | const AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const { | |
141 | return (const AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; } | |
cb34a1fa | 142 | |
fbf811ec | 143 | //========== RecParticles =========== |
cb34a1fa | 144 | TClonesArray * RecParticles(const char * name = 0) { |
fbf811ec | 145 | return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ; } |
146 | const AliPHOSPID * PID(const char * name =0) const { | |
548f0134 | 147 | return (const AliPHOSPID*)(ReturnT("PID", name)) ; } // here static or dynamic cast does not work ! why ? |
148 | ||
fbf811ec | 149 | //-----------------Auxiliary methods: cleaners----------------- |
65549808 | 150 | void RemoveTask(TString opt, TString name) const ; |
151 | void RemoveObjects(TString opt, TString name) const ; | |
fbf811ec | 152 | void RemoveSDigits() const ; |
5bf7ace9 | 153 | |
fbf811ec | 154 | //----------------Auxiliary methods: miscellana---------------- |
155 | void CloseFile() ; | |
156 | const TFolder * Folder(const TString what) const ; | |
157 | const Bool_t HasFailed() const { return fFailed ; } | |
158 | void ListBranches(Int_t event=0) const ; | |
159 | void NewBranch(TString name, Int_t event = 0) ; | |
160 | Bool_t NewFile(TString name) ; | |
161 | TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; } | |
162 | void SetDebug(Int_t level) {fDebug = level;} // Set debug level | |
5bf7ace9 | 163 | void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; } |
cb34a1fa | 164 | |
fbf811ec | 165 | //------------Auxiliary methods: Posters-------------------- |
166 | const Bool_t PostPrimaries(void ) const ; | |
167 | const Bool_t PostHits(void ) const ; | |
168 | const Bool_t PostSDigits( const char * name, const char * file = 0) const ; | |
169 | const Bool_t PostDigits( const char * name ) const ; | |
170 | const Bool_t PostRecPoints( const char * name ) const ; | |
171 | const Bool_t PostTrackSegments(const char * name) const ; | |
172 | const Bool_t PostRecParticles( const char * name) const ; | |
173 | const Bool_t PostClusterizer( const char * name) const ; | |
174 | const Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ; | |
175 | const Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ; | |
176 | const Bool_t PostSDigitizer ( const char * name, const char * file ) const ; | |
177 | const Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ; | |
178 | const Bool_t PostDigitizer ( const char * name) const ; | |
179 | const Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ; | |
180 | const Bool_t PostTrackSegmentMaker(const char * name ) const ; | |
181 | const Bool_t PostPID (AliPHOSPID * pid) const ; | |
182 | const Bool_t PostPID (const char * name ) const ; | |
183 | const Bool_t PostQA (void) const ; | |
184 | ||
cb34a1fa | 185 | private: |
186 | ||
fbf811ec | 187 | AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ; |
cb34a1fa | 188 | TObject * ReturnO(TString what, TString name=0, TString file=0) const ; |
4ae78bb1 | 189 | const TTask * ReturnT(TString what,TString name=0) const ; |
190 | void DefineBranchTitles(char* branch, char* branchTitle) ; | |
fbf811ec | 191 | Int_t ReadTreeD(const Int_t event) ; |
192 | Int_t ReadTreeH(void) ; | |
193 | Int_t ReadTreeR(const Int_t event) ; | |
194 | Int_t ReadTreeS(const Int_t event) ; | |
195 | void ReadTreeQA(void) ; | |
196 | void ReadPrimaries(void) ; | |
197 | void CleanWhiteBoard(void) ; | |
198 | void CloseSplitFiles(void) ; | |
199 | void SetTitle(const char * title) ; | |
4ae78bb1 | 200 | |
65c0665e | 201 | TObject** PrimariesRef(void) const ; |
202 | TObject** HitsRef(void) const ; | |
203 | TObject** SDigitsRef(const char * name, const char * file = 0 ) const; | |
204 | TObject** DigitsRef (const char * name) const ; | |
205 | TObject** EmcRecPointsRef (const char * name) const ; | |
206 | TObject** CpvRecPointsRef (const char * name) const ; | |
207 | TObject** TrackSegmentsRef(const char * name) const ; | |
208 | TObject** RecParticlesRef (const char * name) const ; | |
209 | TObject** AlarmsRef (void) const ; | |
210 | ||
211 | TObject** SDigitizerRef (const char * name) const ; | |
212 | TObject** DigitizerRef (const char * name) const ; | |
213 | TObject** ClusterizerRef(const char * name) const ; | |
214 | TObject** TSMakerRef (const char * name) const ; | |
215 | TObject** PIDRef (const char * name) const ; | |
b0bba0af | 216 | |
4ae78bb1 | 217 | private: |
218 | ||
fbf811ec | 219 | static TFile * fFile; //! |
220 | Bool_t fToSplit ; //! Do we work in the split mode | |
221 | TString fHeaderFile ; //! File in which gAlice lives | |
222 | TString fBranchTitle ; //! | |
223 | TString fTrackSegmentsTitle ; //! | |
224 | TString fTrackSegmentsFileName ;//! | |
225 | TString fRecPointsTitle ; //! | |
226 | TString fRecPointsFileName ; //! | |
227 | TString fRecParticlesTitle ; //! | |
228 | TString fRecParticlesFileName ; //! | |
229 | TString fDigitsTitle ; //! TDirectory tempo(gDirectory) | |
230 | TString fDigitsFileName ; //! TDirectory tempo(gDirectory) | |
231 | TString fSDigitsTitle ; //! | |
232 | TString fSDigitsFileName ; //! | |
dca3a7c4 | 233 | Bool_t fFailed ; //! set if file not opend or galice not found |
fbf811ec | 234 | Int_t fDebug ; //! Debug level |
fbf811ec | 235 | Int_t fNPrimaries ; //! # of primaries |
b0bba0af | 236 | TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing |
7a9d98f9 | 237 | TFolder * fModuleFolder ; //!Folder that contains the modules |
cb34a1fa | 238 | TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles |
7a9d98f9 | 239 | TFolder * fHitsFolder ; //!Folder that contains the Hits |
240 | TFolder * fSDigitsFolder ; //!Folder that contains the SDigits | |
241 | TFolder * fDigitsFolder ; //!Folder that contains the Digits | |
242 | TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) | |
243 | TFolder * fQAFolder ; //!Folder that contains the QA objects | |
244 | TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner) | |
9bd3caba | 245 | |
b0bba0af | 246 | static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton |
4ae78bb1 | 247 | |
248 | ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index | |
249 | ||
250 | }; | |
251 | ||
252 | #endif // AliPHOSGETTER_H |