1 #ifndef ALIEMCALGETTER_H
2 #define ALIEMCALGETTER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6 //________________________________________________________________________
7 // A singleton that returns various objects
8 // Should be used on the analysis stage to avoid confusing between different
9 // branches of reconstruction tree: e.g. reading RecPoints and TS made from
10 // another set of RecPoints.
12 // The objects are retrived from folders.
13 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
17 // August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
18 // of new IO (à la PHOS)
20 // --- ROOT system ---
21 #include "TClonesArray.h"
29 // --- Standard library ---
32 // --- AliRoot header files ---
35 #include "AliEMCALHit.h"
36 #include "AliEMCALDigit.h"
37 #include "AliEMCALTowerRecPoint.h"
38 class AliEMCALGeometry ;
39 #include "AliEMCALDigitizer.h"
40 #include "AliEMCALSDigitizer.h"
41 class AliEMCALClusterizer ;
43 class AliEMCALGetter : public TObject {
47 AliEMCALGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
48 Fatal("ctor", "singleton: default ctor not callable") ;
50 AliEMCALGetter(const AliEMCALGetter & obj) {
51 // cpy ctor requested by Coding Convention
53 Fatal("cpy ctor", "not implemented") ;
56 AliEMCALGetter & operator = (const AliEMCALGetter & ) {
57 // assignement operator requested by coding convention, but not needed
58 Fatal("operator =", "not implemented") ;
61 virtual ~AliEMCALGetter() ;
63 //=========== Instantiators ================
64 static AliEMCALGetter * GetInstance(const char* headerFile,
65 const char* branchTitle = "Default",
66 const Bool_t toSplit = kFALSE ) ;
67 static AliEMCALGetter * GetInstance() ;
69 //=========== General information about run ==============
70 const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
71 const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
72 const Bool_t BranchExists(const TString recName) const ;
74 //========== EMCALGeometry and EMCAL =============
75 const AliEMCAL * EMCAL() ;
76 AliEMCALGeometry * EMCALGeometry() ;
78 //========== Methods to read somethig from file ==========
79 void Event(const Int_t event, const char * opt = "HSDRP") ;
80 void Track(const Int_t itrack) ;
81 void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
82 //digitizing is under the conytrol of AliRunDigitizer,
83 //which opens all files etc.
84 //-----------------now getter's data--------------------------------------
86 //=========== Primaries ============
87 TTree * TreeK(TString filename="") ;
88 TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
89 const TParticle * Primary(Int_t index) const;
90 const Int_t NPrimaries()const { return fNPrimaries; }
91 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
93 //=========== Hits =================
94 TTree * TreeH(TString filename="") ;
95 const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
96 const AliEMCALHit * Hit(Int_t index) { return dynamic_cast<const AliEMCALHit*>(Hits()->At(index) );}
98 //=========== SDigits ==============
99 TTree * TreeS(TString filename="") ;
100 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
101 return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
102 const AliEMCALDigit * SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
103 const AliEMCALSDigitizer * SDigitizer(const char * name =0) const {
104 return (const AliEMCALSDigitizer*)(ReturnT("SDigitizer", name)) ; // here static or dynamic cast does not work ! why ?
107 //========== Digits ================
108 TTree * TreeD(TString filename="") ;
109 TClonesArray * Digits(const char * name = 0)const {
110 return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
111 const AliEMCALDigit * Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
112 const AliEMCALDigitizer * Digitizer(const char * name =0) const {
113 return (const AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
115 //========== RecPoints =============
116 TObjArray * TowerRecPoints(const char * name = 0) const {
117 return (dynamic_cast<TObjArray*>(ReturnO("TowerRecPoints", name))) ; }
118 const AliEMCALTowerRecPoint * TowerRecPoint(Int_t index) { return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
119 TObjArray * PreShowerRecPoints(const char * name = 0) const {
120 return (dynamic_cast<TObjArray*>(ReturnO("PreShowerRecPoints", name))) ; }
121 const AliEMCALRecPoint * PreShowerRecPoint(Int_t index) { return static_cast<const AliEMCALRecPoint *>(PreShowerRecPoints()->At(index)) ;}
122 const AliEMCALClusterizer * Clusterizer (const char * name =0) const {
123 return (const AliEMCALClusterizer*)(ReturnT("Clusterizer", name)) ;// here static or dynamic cast does not work ! why ?
126 //-----------------Auxiliary methods: cleaners-----------------
127 void RemoveTask(TString opt, TString name) const ;
128 void RemoveObjects(TString opt, TString name) const ;
129 void RemoveSDigits() const ;
131 //-----------------Auxiliary methods: miscellana-----------------
133 const TFolder * Folder(const TString what) const ;
134 const Bool_t HasFailed(void) const {return fFailed ;}
135 void ListBranches(Int_t event=0) const ;
136 void NewBranch(TString name, Int_t event = 0) ;
137 Bool_t NewFile(TString name) ;
138 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
139 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
140 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
142 //------------Auxiliary methods: Posters--------------------
143 const Bool_t PostPrimaries(void ) const ;
144 const Bool_t PostHits(void ) const ;
145 const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
146 const Bool_t PostDigits( const char * name ) const ;
147 const Bool_t PostRecPoints( const char * name ) const ;
148 const Bool_t PostClusterizer( const char * name) const ;
149 const Bool_t PostClusterizer(AliEMCALClusterizer * clu) const ;
150 const Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;
151 const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
152 const Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;
153 const Bool_t PostDigitizer ( const char * name) const ;
157 AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
158 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
159 const TTask * ReturnT(TString what,TString name=0) const ;
160 void DefineBranchTitles(char* branch, char* branchTitle) ;
161 Int_t ReadTreeD(const Int_t event) ;
162 Int_t ReadTreeH(void) ;
163 Int_t ReadTreeR(const Int_t event) ;
164 Int_t ReadTreeS(const Int_t event) ;
165 void ReadTreeQA(void) ;
166 void ReadPrimaries(void) ;
167 void CleanWhiteBoard(void) ;
168 void CloseSplitFiles(void) ;
169 void SetTitle(const char * title) ;
171 TObject ** PrimariesRef(void) const ;
172 TObject ** HitsRef(void) const ;
173 TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
174 TObject ** DigitsRef (const char * name) const ;
175 TObject ** TowerRecPointsRef (const char * name) const ;
176 TObject ** PreShowerRecPointsRef (const char * name) const ;
177 TObject ** SDigitizerRef (const char * name) const ;
178 TObject ** DigitizerRef (const char * name) const ;
179 TObject ** ClusterizerRef(const char * name) const ;
183 static TFile * fFile ; //!
184 Bool_t fToSplit ; //! Do we work in the split mode
185 TString fHeaderFile ; //! File in which gAlice lives
186 TString fBranchTitle ; //!
187 TString fTrackSegmentsTitle ;//!
188 TString fTrackSegmentsFileName ;//!
189 TString fRecPointsTitle ; //!
190 TString fRecPointsFileName ; //!
191 TString fRecParticlesTitle ; //!
192 TString fRecParticlesFileName ; //!
193 TString fDigitsTitle ; //!TDirectory tempo(gDirectory)
194 TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
195 TString fSDigitsTitle ; //!
196 TString fSDigitsFileName ; //!
197 Bool_t fFailed ; //! true if file is not opened and/or galice not found
198 Int_t fDebug ; // Debug level
199 AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
200 Int_t fNPrimaries ; //! # of primaries
201 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
202 TFolder * fModuleFolder ; //!Folder that contains the modules
203 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
204 TFolder * fHitsFolder ; //!Folder that contains the Hits
205 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
206 TFolder * fDigitsFolder ; //!Folder that contains the Digits
207 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
208 TFolder * fQAFolder ; //!Folder that contains the QA objects
209 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
211 static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
213 ClassDef(AliEMCALGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
217 #endif // AliEMCALGETTER_H