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 ---
32 // --- AliRoot header files ---
36 #include "AliPHOSHit.h"
37 #include "AliPHOSDigit.h"
38 #include "AliPHOSEmcRecPoint.h"
39 #include "AliPHOSCpvRecPoint.h"
40 #include "AliPHOSTrackSegment.h"
41 #include "AliPHOSRecParticle.h"
42 class AliPHOSGeometry ;
43 class AliPHOSDigitizer ;
44 class AliPHOSSDigitizer ;
45 class AliPHOSClusterizer ;
46 class AliPHOSTrackSegmentMaker ;
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 cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
57 AliPHOSGetter(const AliPHOSGetter & obj) {
58 // cpy ctor requested by Coding Convention
63 virtual ~AliPHOSGetter() ;
66 const TFolder * Folder(const TString what) const ;
67 void ListBranches(Int_t event=0) const ;
68 void NewBranch(TString name, Int_t event = 0) ;
69 Bool_t NewFile(TString name) ;
70 const Bool_t HasFailed() const { return fFailed ; }
71 Bool_t PostPrimaries(void ) const ;
72 Bool_t PostHits(void ) const ;
73 Bool_t PostSDigits( const char * name, const char * file = 0) const ;
74 Bool_t PostDigits( const char * name ) const ;
75 Bool_t PostRecPoints( const char * name ) const ;
76 Bool_t PostTrackSegments(const char * name) const ;
77 Bool_t PostRecParticles( const char * name) const ;
79 Bool_t PostClusterizer( const char * name) const ;
80 Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
81 Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
82 Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
83 Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
84 Bool_t PostDigitizer ( const char * name) const ;
85 Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
86 Bool_t PostTrackSegmentMaker(const char * name ) const ;
87 Bool_t PostPID (AliPHOSPID * pid) const ;
88 Bool_t PostPID (const char * name ) const ;
89 Bool_t PostQA (void) const ;
92 void Event(const Int_t event, const char * opt = "HSDRP") ;
93 void Track(Int_t itrack) ;
95 //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
96 void ReadTreeS(TTree * treeS,Int_t input) ;
98 Int_t EventNumber() { return (Int_t) gAlice->GetEvNumber() ; }
99 Int_t MaxEvent() { return (Int_t) gAlice->TreeE()->GetEntries() ; }
100 static AliPHOSGetter * GetInstance(const char* headerFile,
101 const char* branchTitle = "Default" ) ;
102 static AliPHOSGetter * GetInstance() ;
104 const AliPHOS * PHOS() ;
105 const AliPHOSGeometry * PHOSGeometry() ;
107 TFolder * Alarms() const { return (TFolder*)(ReturnO("Alarms", 0)) ; }
108 TObjArray * Alarms(const char * name ) const { return (TObjArray*)(ReturnO("Alarms", name)) ; }
111 TTask * QATasks(const char * name = 0) const { return (TTask*)(ReturnT("QATasks", name)) ; }
114 TClonesArray * Primaries(void) const { return (TClonesArray*)(ReturnO("Primaries")) ; }
116 const TClonesArray * Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
117 const AliPHOSHit * Hit(Int_t index) { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
120 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
121 return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ;
123 const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit*>(SDigits()->At(index)) ;}
125 AliPHOSSDigitizer * SDigitizer(const char * name =0) const {
126 return ((AliPHOSSDigitizer*)(ReturnT("SDigitizer", name))) ;
130 TClonesArray * Digits(const char * name = 0)const {
131 return static_cast<TClonesArray*>(ReturnO("Digits", name)) ;
133 const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;}
134 AliPHOSDigitizer * Digitizer(const char * name =0) const {
135 return (AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ;
139 TObjArray * EmcRecPoints(const char * name = 0) {
140 return static_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ;
142 TObjArray * CpvRecPoints(const char * name = 0) {
143 return static_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ;
145 const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) {
146 return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;
148 const AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) {
149 return static_cast<const AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;
152 AliPHOSClusterizer * Clusterizer (const char * name =0) const {
153 return (AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ;
157 TClonesArray * TrackSegments(const char * name = 0) {
158 return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ;
160 const AliPHOSTrackSegment * TrackSegment(Int_t index) {
161 return static_cast<const AliPHOSTrackSegment*>(TrackSegments()->At(index)) ;
163 AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
164 return (AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;
168 TClonesArray * RecParticles(const char * name = 0) {
169 return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ;
171 const AliPHOSRecParticle * RecParticle(Int_t index) {
172 return static_cast<const AliPHOSRecParticle*>(RecParticles()->At(index)) ;
174 AliPHOSPID * PID(const char * name =0) const {
175 return (AliPHOSPID*)(ReturnT("PID", name)) ;
179 const TParticle * Primary(Int_t index) const ;
180 const Int_t NPrimaries()const { return fNPrimaries; }
181 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
183 void RemoveTask(TString opt, TString name) const ;
184 void RemoveObjects(TString opt, TString name) const ;
185 void RemoveSDigits() const ;
186 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
188 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
189 // assignement operator requested by coding convention, but not needed
194 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
196 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
200 AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default") ;
201 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
202 const TTask * ReturnT(TString what,TString name=0) const ;
203 void DefineBranchTitles(char* branch, char* branchTitle) ;
206 Int_t ReadTreeR(Bool_t any=kFALSE) ;
207 Int_t ReadTreeS(Int_t event) ;
209 void ReadPrimaries() ;
211 TObject** PrimariesRef(void) const ;
212 TObject** HitsRef(void) const ;
213 TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
214 TObject** DigitsRef (const char * name) const ;
215 TObject** EmcRecPointsRef (const char * name) const ;
216 TObject** CpvRecPointsRef (const char * name) const ;
217 TObject** TrackSegmentsRef(const char * name) const ;
218 TObject** RecParticlesRef (const char * name) const ;
219 TObject** AlarmsRef (void) const ;
221 TObject** SDigitizerRef (const char * name) const ;
222 TObject** DigitizerRef (const char * name) const ;
223 TObject** ClusterizerRef(const char * name) const ;
224 TObject** TSMakerRef (const char * name) const ;
225 TObject** PIDRef (const char * name) const ;
229 static TFile * fFile; //!
230 TString fHeaderFile ; //! File in which gAlice lives
231 TString fBranchTitle ; //!
232 TString fTrackSegmentsTitle ;//!
233 TString fRecPointsTitle ; //!
234 TString fRecParticlesTitle ; //!
235 TString fDigitsTitle ; //! TDirectory tempo(gDirectory) ;
237 TString fSDigitsTitle ; //!
239 Bool_t fFailed ; //! set if file not opend or galice not found
240 Int_t fDebug ; // Debug level
242 Int_t fNPrimaries ; //! # of primaries
244 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
246 TFolder * fModuleFolder ; //!Folder that contains the modules
247 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
248 TFolder * fHitsFolder ; //!Folder that contains the Hits
249 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
250 TFolder * fDigitsFolder ; //!Folder that contains the Digits
251 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
252 TFolder * fQAFolder ; //!Folder that contains the QA objects
253 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
255 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
257 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
261 #endif // AliPHOSGETTER_H