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 ---
24 // --- Standard library ---
26 // --- AliRoot header files ---
27 #include "AliConfig.h"
28 #include "AliPHOSLoader.h"
29 #include "AliPHOSHit.h"
30 #include "AliPHOSDigit.h"
31 #include "AliPHOSEmcRecPoint.h"
32 #include "AliPHOSCpvRecPoint.h"
33 #include "AliPHOSTrackSegment.h"
34 #include "AliPHOSRecParticle.h"
35 #include "AliPHOSDigitizer.h"
36 #include "AliPHOSSDigitizer.h"
38 class AliPHOSGeometry ;
39 class AliPHOSClusterizer ;
40 class AliPHOSTrackSegmentMaker ;
42 class AliPHOSBeamTestEvent ;
45 class AliPHOSGetter : public TObject {
48 AliPHOSGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
49 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
52 AliPHOSGetter(Int_t /*i*/){ // special constructor for onflight
56 AliPHOSGetter(const char* headerFile,
57 const char* version = AliConfig::GetDefaultEventFolderName(),
58 Option_t * openingOption = "READ") ;
61 AliPHOSGetter(const AliPHOSGetter & obj) : TObject(obj) {
62 // cpy ctor requested by Coding Convention
63 Fatal("cpy ctor", "not implemented") ;
66 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
67 // assignement operator requested by coding convention, but not needed
68 Fatal("operator =", "not implemented") ;
71 virtual ~AliPHOSGetter() ;
73 //=========== Instantiators ================
74 static AliPHOSGetter * Instance(const char* headerFile,
75 const char* version = AliConfig::GetDefaultEventFolderName(),
76 Option_t * openingOption = "READ" ) ;
77 static AliPHOSGetter * Instance() ;
81 //=========== General information about run ==============
82 virtual Bool_t IsLoaded(TString tree) const { return fLoadingStatus.Contains(tree) ; }
83 virtual void SetLoaded(TString tree) { fLoadingStatus += tree ; }
85 virtual Int_t MaxEvent() const ;
86 virtual Int_t EventNumber() const ;
87 virtual Bool_t VersionExists(TString & opt) const ;
88 virtual UShort_t EventPattern(void) const ;
89 virtual Float_t BeamEnergy(void) const ;
91 //========== PHOSGeometry and PHOS =============
92 virtual AliPHOS * PHOS() const ;
93 virtual AliPHOSGeometry * PHOSGeometry() const ;
95 //========== Methods to read something from file ==========
96 virtual void Event(Int_t event, const char * opt = "HSDRTP") ;
97 virtual void Track(Int_t itrack) ;
100 //-----------------now getter's data--------------------------------------
101 virtual AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
102 virtual void ReadCalibrationDB(const char * /*name*/, const char * /*filename*/){ ;}
104 //=========== Primaries ============
105 virtual TClonesArray * Primaries(void) ;
106 virtual TParticle * Primary(Int_t index) const ;
107 virtual Int_t NPrimaries()const { return fNPrimaries; }
108 virtual TParticle * Secondary(const TParticle * p, Int_t index=1) const ;
110 //=========== Hits =================
111 virtual TClonesArray * Hits(void) ;
112 virtual AliPHOSHit * Hit(Int_t index) { return dynamic_cast<AliPHOSHit*>(Hits()->At(index) );}
113 virtual TTree * TreeH() const ;
115 //=========== SDigits ==============
116 virtual TClonesArray * SDigits() ;
117 virtual AliPHOSDigit * SDigit(Int_t index) { return static_cast<AliPHOSDigit *>(SDigits()->At(index)) ;}
118 virtual TTree * TreeS() const ;
119 virtual AliPHOSSDigitizer * SDigitizer() ;
121 virtual TString GetSDigitsFileName() const { return PhosLoader()->GetSDigitsFileName() ; }
122 virtual Int_t LoadSDigits(Option_t* opt="") const { return PhosLoader()->LoadSDigits(opt) ; }
123 virtual Int_t LoadSDigitizer(Option_t* opt="") const { return PhosLoader()->LoadSDigitizer(opt) ; }
124 virtual Int_t WriteSDigits(Option_t* opt="") const { return PhosLoader()->WriteSDigits(opt) ; }
125 virtual Int_t WriteSDigitizer(Option_t* opt="") const {
126 return PhosLoader()->WriteSDigitizer(opt) ; }
128 //========== Digits ================
129 virtual TClonesArray * Digits() ;
130 virtual AliPHOSDigit * Digit(Int_t index) { return static_cast<AliPHOSDigit *>(Digits()->At(index)) ;}
131 virtual TTree * TreeD() const ;
132 virtual AliPHOSDigitizer * Digitizer() ;
133 virtual TString GetDigitsFileName() const { return PhosLoader()->GetDigitsFileName() ; }
134 virtual Int_t LoadDigits(Option_t* opt="") const { return PhosLoader()->LoadDigits(opt) ; }
135 virtual Int_t LoadDigitizer(Option_t* opt="") const {
136 return PhosLoader()->LoadDigitizer(opt) ; }
137 virtual Int_t WriteDigits(Option_t* opt="") const { return PhosLoader()->WriteDigits(opt) ; }
138 virtual Int_t WriteDigitizer(Option_t* opt="") const {
139 return PhosLoader()->WriteDigitizer(opt) ; }
141 //Methods to distinguish raw and simulated digits
142 virtual Bool_t IsRawDigits(void) const {return fRawDigits;}
143 virtual void SetRawDigits(Bool_t isRaw = kTRUE){fRawDigits = isRaw;}
145 //========== RecPoints =============
146 virtual TObjArray * EmcRecPoints() ;
147 virtual AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { return static_cast<AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;}
148 virtual TObjArray * CpvRecPoints() ;
149 virtual AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) { return static_cast<AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;}
150 virtual TTree * TreeR() const ;
151 virtual AliPHOSClusterizer * Clusterizer() ;
152 virtual TString GetRecPointsFileName() const { return PhosLoader()->GetRecPointsFileName() ; }
153 virtual Int_t LoadRecPoints(Option_t* opt="") const { return PhosLoader()->LoadRecPoints(opt) ; }
154 virtual Int_t LoadClusterizer(Option_t* opt="") const {
155 return PhosLoader()->LoadClusterizer(opt) ; }
156 virtual Int_t WriteRecPoints(Option_t* opt="") const { return PhosLoader()->WriteRecPoints(opt) ; }
157 virtual Int_t WriteClusterizer(Option_t* opt="") const {
158 return PhosLoader()->WriteClusterizer(opt) ; }
160 //========== TrackSegments TClonesArray * TrackSegments(const char * name = 0) {
161 virtual TClonesArray * TrackSegments() ;
162 virtual AliPHOSTrackSegment * TrackSegment(Int_t index) { return static_cast<AliPHOSTrackSegment *>(TrackSegments()->At(index)) ;}
163 virtual TTree * TreeT() const ;
164 virtual AliPHOSTrackSegmentMaker * TrackSegmentMaker() ;
165 virtual TString GetTracksFileName() const { return PhosLoader()->GetTracksFileName() ; }
166 virtual Int_t LoadTracks(Option_t* opt="") const { return PhosLoader()->LoadTracks(opt) ; }
167 virtual Int_t LoadTrackSegementMaker(Option_t* opt="") const {
168 return PhosLoader()->LoadTrackSegmentMaker(opt) ; }
169 virtual Int_t WriteTracks(Option_t* opt="") const { return PhosLoader()->WriteTracks(opt) ; }
170 virtual Int_t WriteTrackSegmentMaker(Option_t* opt="") const {
171 return PhosLoader()->WriteTracker(opt) ; }
173 //========== RecParticles ===========
174 virtual TClonesArray * RecParticles() ;
175 virtual AliPHOSRecParticle * RecParticle(Int_t index) { return static_cast<AliPHOSRecParticle *>(RecParticles()->At(index)) ;}
176 virtual TTree * TreeP() const ;
177 virtual AliPHOSPID * PID() ;
178 virtual TString GetRecParticlesFileName() const { return PhosLoader()->GetRecParticlesFileName() ; }
179 virtual Int_t LoadRecParticles(Option_t* opt="") const { return PhosLoader()->LoadRecParticles(opt) ; }
180 virtual Int_t LoadPID(Option_t* opt="") const {
181 return PhosLoader()->LoadPID(opt) ; }
182 virtual Int_t WriteRecParticles(Option_t* opt="") const { return PhosLoader()->WriteRecParticles(opt) ; }
183 virtual Int_t WritePID(Option_t* opt="") const {
184 return PhosLoader()->WritePID(opt) ; }
186 //========== Raw ===========
187 virtual Int_t ReadRaw(Int_t event) ;
189 virtual void SetDebug(Int_t level) {fgDebug = level;} // Set debug level
190 virtual void PostClusterizer(AliPHOSClusterizer * clu)
191 const{PhosLoader()->PostClusterizer(clu) ; }
192 virtual void PostPID(AliPHOSPID * pid)
193 const{PhosLoader()->PostPID(pid) ; }
194 virtual void PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tr)
195 const{PhosLoader()->PostTrackSegmentMaker(tr) ; }
196 virtual void PostSDigitizer (AliPHOSSDigitizer * sdigitizer)
197 const {PhosLoader()->PostSDigitizer(sdigitizer);}
198 virtual void PostDigitizer (AliPHOSDigitizer * digitizer)
199 const {PhosLoader()->PostDigitizer(dynamic_cast<AliDigitizer *>(digitizer));}
201 virtual TString Version() const { return PhosLoader()->GetTitle() ; }
202 virtual AliPHOSLoader * PhosLoader() const { return fgPhosLoader ; }
203 virtual void Reset() ;
205 virtual AliESD * ESD() const { return fESD ; }
209 Int_t ReadTreeD(void) ;
210 Int_t ReadTreeH(void) ;
211 Int_t ReadTreeR(void) ;
212 Int_t ReadTreeT(void) ;
213 Int_t ReadTreeS(void) ;
214 Int_t ReadTreeP(void) ;
216 Int_t ReadTreeE(Int_t event) ;
217 Bool_t OpenESDFile() ;
218 void ReadPrimaries(void) ;
223 AliPHOSBeamTestEvent * fBTE ; //! Header if BeamTest Event
224 static Int_t fgDebug ; //! Debug level
226 TString fLoadingStatus ; //! tells which trees are loaded
227 Int_t fNPrimaries ; //! # of primaries
228 TClonesArray * fPrimaries ; //! list of lists of primaries
229 TFile * fESDFile ; //! ESD file
230 TString fESDFileName ; //! ESD File Name
231 AliESD * fESD ; //! ESD object
232 TTree * fESDTree ; //! ESD Tree
234 Bool_t fRawDigits ; //!
236 AliPHOSCalibrationDB * fcdb ; //!
238 static AliPHOSLoader * fgPhosLoader ; // the loader for the NewIO
240 enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
243 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
246 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
250 #endif // AliPHOSGETTER_H