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 */
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.
14 // The objects are retrived from folders.
15 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
19 // --- ROOT system ---
20 #include "TClonesArray.h"
28 // --- Standard library ---
31 // --- AliRoot header files ---
35 #include "AliPHOSHit.h"
36 #include "AliPHOSDigit.h"
37 #include "AliPHOSEmcRecPoint.h"
38 #include "AliPHOSCpvRecPoint.h"
39 #include "AliPHOSTrackSegment.h"
40 #include "AliPHOSRecParticle.h"
41 class AliPHOSGeometry ;
42 class AliPHOSDigitizer ;
43 class AliPHOSSDigitizer ;
44 class AliPHOSClusterizer ;
45 class AliPHOSTrackSegmentMaker ;
47 class AliPHOSCalibrationDB ;
49 class AliPHOSGetter : public TObject {
53 AliPHOSGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
54 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
56 AliPHOSGetter(const AliPHOSGetter & obj) {
57 // cpy ctor requested by Coding Convention
59 Fatal("cpy ctor", "not implemented") ;
62 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
63 // assignement operator requested by coding convention, but not needed
64 Fatal("operator =", "not implemented") ;
67 virtual ~AliPHOSGetter() ;
69 //=========== Instantiators ================
70 static AliPHOSGetter * GetInstance(const char* headerFile,
71 const char* branchTitle = "Default",
72 const Bool_t toSplit = kFALSE ) ;
73 static AliPHOSGetter * GetInstance() ;
75 //=========== General information about run ==============
76 const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
77 const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
78 const Bool_t BranchExists(const TString tree) const ;
80 //========== PHOSGeometry and PHOS =============
81 const AliPHOS * PHOS() ;
82 const AliPHOSGeometry * PHOSGeometry() ;
84 //========== Methods to read something from file ==========
85 void Event(const Int_t event, const char * opt = "HSDRP") ;
86 void Track(const Int_t itrack) ;
87 void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
88 //digitizing is under the control ofAliRunDigizer,
89 //which opens all files etc.
90 //========== Alarms ======================
91 TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
92 const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
93 const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
95 //-----------------now getter's data--------------------------------------
97 //=========== Primaries ============
98 TTree * TreeK(TString filename="") ;
99 TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
100 const TParticle * Primary(Int_t index) const ;
101 const Int_t NPrimaries()const { return fNPrimaries; }
102 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
104 //=========== Hits =================
105 TTree * TreeH(TString filename="") ;
106 const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
107 const AliPHOSHit * Hit(Int_t index) { return dynamic_cast<const AliPHOSHit*>(Hits()->At(index) );}
109 //=========== SDigits ==============
110 TTree * TreeS(TString filename="") ;
111 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
112 return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
113 //const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit *>(SDigits()->At(index)) ;} !!! why no such method ?
114 const AliPHOSSDigitizer * SDigitizer(const char * name =0) const {
115 return (const AliPHOSSDigitizer *) ReturnT("SDigitizer", name) ; // here static or dynamic cast does not work ! why ?
118 //========== Digits ================
119 TTree * TreeD(TString filename="") ;
120 TClonesArray * Digits(const char * name = 0)const {
121 return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
122 //const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
123 const TTask * Digitizer(const char * name = 0) const {
124 return ReturnT("Digitizer", name) ; }
125 AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
126 void ReadCalibrationDB(const char * name, const char * filename) ;
128 //========== RecPoints =============
129 TObjArray * EmcRecPoints(const char * name = 0) {
130 return dynamic_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ; }
131 //const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;} !!! why no such method ?
132 TObjArray * CpvRecPoints(const char * name = 0) {
133 return dynamic_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ; }
134 const AliPHOSClusterizer * Clusterizer (const char * name =0) const {
135 return (const AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; // here static or dynamic cast does not work ! why ?
138 //========== TrackSegments ==========
139 TClonesArray * TrackSegments(const char * name = 0) {
140 return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ; }
141 const AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
142 return (const AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; }
144 //========== RecParticles ===========
145 TClonesArray * RecParticles(const char * name = 0) {
146 return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ; }
147 const AliPHOSPID * PID(const char * name =0) const {
148 return (const AliPHOSPID*)(ReturnT("PID", name)) ; } // here static or dynamic cast does not work ! why ?
150 //-----------------Auxiliary methods: cleaners-----------------
151 void RemoveTask(TString opt, TString name) const ;
152 void RemoveObjects(TString opt, TString name) const ;
153 void RemoveSDigits() const ;
155 //----------------Auxiliary methods: miscellana----------------
157 const TFolder * Folder(const TString what) const ;
158 const Bool_t HasFailed() const { return fFailed ; }
159 void ListBranches(Int_t event=0) const ;
160 void NewBranch(TString name, Int_t event = 0) ;
161 Bool_t NewFile(TString name) ;
162 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
163 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
164 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
166 //------------Auxiliary methods: Posters--------------------
167 const Bool_t PostPrimaries(void ) const ;
168 const Bool_t PostHits(void ) const ;
169 const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
170 const Bool_t PostDigits( const char * name ) const ;
171 const Bool_t PostRecPoints( const char * name ) const ;
172 const Bool_t PostTrackSegments(const char * name) const ;
173 const Bool_t PostRecParticles( const char * name) const ;
174 const Bool_t PostClusterizer( const char * name) const ;
175 const Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
176 const Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
177 const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
178 const Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
179 const Bool_t PostDigitizer ( const char * name) const ;
180 const Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
181 const Bool_t PostTrackSegmentMaker(const char * name ) const ;
182 const Bool_t PostPID (AliPHOSPID * pid) const ;
183 const Bool_t PostPID (const char * name ) const ;
184 const Bool_t PostQA (void) const ;
188 AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
189 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
190 const TTask * ReturnT(TString what,TString name=0) const ;
191 void DefineBranchTitles(char* branch, char* branchTitle) ;
192 Int_t ReadTreeD(const Int_t event) ;
193 Int_t ReadTreeH(void) ;
194 Int_t ReadTreeR(const Int_t event) ;
195 Int_t ReadTreeS(const Int_t event) ;
196 void ReadTreeQA(void) ;
197 void ReadPrimaries(void) ;
198 void CleanWhiteBoard(void) ;
199 void CloseSplitFiles(void) ;
200 void SetTitle(const char * title) ;
202 TObject** PrimariesRef(void) const ;
203 TObject** HitsRef(void) const ;
204 TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
205 TObject** DigitsRef (const char * name) const ;
206 TObject** EmcRecPointsRef (const char * name) const ;
207 TObject** CpvRecPointsRef (const char * name) const ;
208 TObject** TrackSegmentsRef(const char * name) const ;
209 TObject** RecParticlesRef (const char * name) const ;
210 TObject** AlarmsRef (void) const ;
212 TObject** SDigitizerRef (const char * name) const ;
213 TObject** DigitizerRef (const char * name) const ;
214 TObject** ClusterizerRef(const char * name) const ;
215 TObject** TSMakerRef (const char * name) const ;
216 TObject** PIDRef (const char * name) const ;
220 static TFile * fFile; //!
221 Bool_t fToSplit ; //! Do we work in the split mode
222 TString fHeaderFile ; //! File in which gAlice lives
223 TString fBranchTitle ; //!
224 TString fTrackSegmentsTitle ; //!
225 TString fTrackSegmentsFileName ;//!
226 TString fRecPointsTitle ; //!
227 TString fRecPointsFileName ; //!
228 TString fRecParticlesTitle ; //!
229 TString fRecParticlesFileName ; //!
230 TString fDigitsTitle ; //! TDirectory tempo(gDirectory)
231 TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
232 TString fSDigitsTitle ; //!
233 TString fSDigitsFileName ; //!
234 Bool_t fFailed ; //! set if file not opend or galice not found
235 Int_t fDebug ; //! Debug level
236 AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
237 Int_t fNPrimaries ; //! # of primaries
238 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
239 TFolder * fModuleFolder ; //!Folder that contains the modules
240 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
241 TFolder * fHitsFolder ; //!Folder that contains the Hits
242 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
243 TFolder * fDigitsFolder ; //!Folder that contains the Digits
244 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
245 TFolder * fQAFolder ; //!Folder that contains the QA objects
246 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
248 AliPHOSCalibrationDB * fcdb ; //!
250 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
252 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
256 #endif // AliPHOSGETTER_H