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 */
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 ---
21 #include "TClonesArray.h"
25 // --- Standard library ---
27 // --- AliRoot header files ---
28 #include "AliConfig.h"
30 // #include "AliRun.h"
31 #include "AliEMCALHit.h"
32 #include "AliEMCALRecParticle.h"
33 #include "AliEMCALDigitizer.h"
34 #include "AliEMCALSDigitizer.h"
35 #include "AliEMCALLoader.h"
37 class AliEMCALGeometry ;
38 class AliEMCALClusterizer ;
39 class AliEMCALRecPoint ;
40 class AliEMCALTowerRecPoint ;
41 class AliEMCALTrackSegmentMaker ;
42 class AliEMCALTrackSegment ;
44 class AliEMCALBeamTestEvent ;
47 class AliEMCALGetter : public TObject {
50 AliEMCALGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
51 Fatal("ctor", "AliEMCALGetter is a singleton default ctor not callable") ;
53 AliEMCALGetter(const AliEMCALGetter & obj):TObject(obj) {
54 // cpy ctor requested by Coding Convention
55 Fatal("cpy ctor", "not implemented") ;
58 AliEMCALGetter & operator = (const AliEMCALGetter & ) {
59 // assignement operator requested by coding convention, but not needed
60 Fatal("operator =", "not implemented") ;
63 virtual ~AliEMCALGetter() ;
65 //=========== Instantiators ================
66 static AliEMCALGetter * Instance(const char* headerFile,
67 const char* version = AliConfig::fgkDefaultEventFolderName,
68 Option_t * openingOption = "READ" ) ;
69 static AliEMCALGetter * Instance() ;
73 // //=========== General information about run ==============
74 Bool_t IsLoaded(TString tree) const { return fLoadingStatus.Contains(tree) ; }
75 void SetLoaded(TString tree) { fLoadingStatus += tree ; }
77 Int_t MaxEvent() const ;
78 Int_t EventNumber() const ;
79 Bool_t VersionExists(TString & opt) const ;
80 UShort_t EventPattern(void) const ;
81 Float_t BeamEnergy(void) const ;
83 // //========== EMCALGeometry and EMCAL =============
84 AliEMCAL * EMCAL() const ;
85 AliEMCALGeometry * EMCALGeometry() const ;
87 // //========== Methods to read something from file ==========
88 void Event(Int_t event, const char * opt = "HSDRP") ;
89 void Track(Int_t itrack) ;
91 // //-----------------now getter's data--------------------------------------
92 // // AliEMCALCalibrationDB * CalibrationDB(){return fcdb; }
93 // // void ReadCalibrationDB(const char * name, const char * filename) ;
95 //=========== Primaries ============
96 // TTree * TreeK(TString filename="") ;
97 TClonesArray * Primaries(void) ;
98 TParticle * Primary(Int_t index) const ;
99 Int_t NPrimaries()const { return fNPrimaries; }
100 TParticle * Secondary(const TParticle * p, Int_t index=1) const ;
102 // //=========== Hits =================
103 // TTree * TreeH(TString filename="") ;
104 TClonesArray * Hits(void) const ;
105 AliEMCALHit * Hit(Int_t index) const { return dynamic_cast<AliEMCALHit*>(Hits()->At(index) );}
106 TTree * TreeH() const ;
108 //=========== SDigits ==============
109 TClonesArray * SDigits() const ;
110 AliEMCALDigit * SDigit(Int_t index) const { return static_cast<AliEMCALDigit *>(SDigits()->At(index)) ;}
111 TTree * TreeS() const ;
112 AliEMCALSDigitizer * SDigitizer() ;
114 TString GetSDigitsFileName() const { return EmcalLoader()->GetSDigitsFileName() ; }
115 Int_t LoadSDigits(Option_t* opt="") const { return EmcalLoader()->LoadSDigits(opt) ; }
116 Int_t LoadSDigitizer(Option_t* opt="") const { return EmcalLoader()->LoadSDigitizer(opt) ; }
117 Int_t WriteSDigits(Option_t* opt="") const { return EmcalLoader()->WriteSDigits(opt) ; }
118 Int_t WriteSDigitizer(Option_t* opt="") const {
119 return EmcalLoader()->WriteSDigitizer(opt) ; }
121 //========== Digits ================
122 TClonesArray * Digits() const ;
123 AliEMCALDigit * Digit(Int_t index) const { return static_cast<AliEMCALDigit *>(Digits()->At(index)) ;}
124 TTree * TreeD() const ;
125 AliEMCALDigitizer * Digitizer() ;
126 TString GetDigitsFileName() const { return EmcalLoader()->GetDigitsFileName() ; }
127 Int_t LoadDigits(Option_t* opt="") const { return EmcalLoader()->LoadDigits(opt) ; }
128 Int_t LoadDigitizer(Option_t* opt="") const {
129 return EmcalLoader()->LoadDigitizer(opt) ; }
130 Int_t WriteDigits(Option_t* opt="") const { return EmcalLoader()->WriteDigits(opt) ; }
131 Int_t WriteDigitizer(Option_t* opt="") const {
132 return EmcalLoader()->WriteDigitizer(opt) ; }
134 //========== RecPoints =============
135 TObjArray * ECARecPoints() const;
136 AliEMCALTowerRecPoint * ECARecPoint(Int_t index) const{ return static_cast<AliEMCALTowerRecPoint *>(ECARecPoints()->At(index)) ;}
137 TTree * TreeR() const ;
138 AliEMCALClusterizer * Clusterizer() ;
139 TString GetRecPointsFileName() const { return EmcalLoader()->GetRecPointsFileName() ; }
140 Int_t LoadRecPoints(Option_t* opt="") const { return EmcalLoader()->LoadRecPoints(opt) ; }
141 Int_t LoadClusterizer(Option_t* opt="") const {
142 return EmcalLoader()->LoadClusterizer(opt) ; }
143 Int_t WriteRecPoints(Option_t* opt="") const { return EmcalLoader()->WriteRecPoints(opt) ; }
144 Int_t WriteClusterizer(Option_t* opt="") const {
145 return EmcalLoader()->WriteClusterizer(opt) ; }
147 //========== TrackSegments TClonesArray * TrackSegments(const char * name = 0) {
148 TClonesArray * TrackSegments() const ;
149 AliEMCALTrackSegment * TrackSegments(Int_t index) const { return static_cast<AliEMCALTrackSegment *>(TrackSegments()->At(index)) ;}
150 TTree * TreeT() const ;
151 AliEMCALTrackSegmentMaker * TrackSegmentMaker() ;
152 TString GetTracksFileName() const { return EmcalLoader()->GetTracksFileName() ; }
153 Int_t LoadTracks(Option_t* opt="") const { return EmcalLoader()->LoadTracks(opt) ; }
154 Int_t LoadTrackSegementMaker(Option_t* opt="") const {
155 return EmcalLoader()->LoadTrackSegmentMaker(opt) ; }
156 Int_t WriteTracks(Option_t* opt="") const { return EmcalLoader()->WriteTracks(opt) ; }
157 Int_t WriteTrackSegmentMaker(Option_t* opt="") const {
158 return EmcalLoader()->WriteTracker(opt) ; }
159 //========== RecParticles ===========
161 TClonesArray * RecParticles() const ;
162 AliEMCALRecParticle * RecPaticles(Int_t index) const { return static_cast<AliEMCALRecParticle *>(RecParticles()->At(index)) ;}
163 TTree * TreeP() const ;
164 AliEMCALPID * PID() ;
165 TString GetRecParticlesFileName() const { return EmcalLoader()->GetRecParticlesFileName() ; }
166 Int_t LoadRecParticles(Option_t* opt="") const { return EmcalLoader()->LoadRecParticles(opt) ; }
167 Int_t LoadPID(Option_t* opt="") const {
168 return EmcalLoader()->LoadPID(opt) ; }
169 Int_t WriteRecParticles(Option_t* opt="") const { return EmcalLoader()->WriteRecParticles(opt) ; }
170 Int_t WritePID(Option_t* opt="") const {
171 return EmcalLoader()->WritePID(opt) ; }
174 void SetDebug(Int_t level) {fgDebug = level;} // Set debug level
175 void PostClusterizer(AliEMCALClusterizer * clu)
176 const{EmcalLoader()->PostClusterizer(clu) ; }
177 void PostPID(AliEMCALPID * pid)
178 const{EmcalLoader()->PostPID(pid) ; }
179 void PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tr)
180 const{EmcalLoader()->PostTrackSegmentMaker(tr) ; }
181 void PostSDigitizer (AliEMCALSDigitizer * sdigitizer)
182 const {EmcalLoader()->PostSDigitizer(sdigitizer);}
183 void PostDigitizer (AliEMCALDigitizer * digitizer)
184 const {EmcalLoader()->PostDigitizer(dynamic_cast<AliDigitizer *>(digitizer));}
186 TString Version() const { return EmcalLoader()->GetTitle() ; }
187 AliEMCALLoader * EmcalLoader() const { return fgEmcalLoader ; }
188 void Reset() {fgEmcalLoader = 0; fgObjGetter = 0; }
192 AliEMCALGetter(const char* headerFile,
193 const char* version = AliConfig::fgkDefaultEventFolderName,
194 Option_t * openingOption = "READ") ;
196 Int_t ReadTreeD(void) ;
197 Int_t ReadTreeH(void) ;
198 Int_t ReadTreeR(void) ;
199 Int_t ReadTreeT(void) ;
200 Int_t ReadTreeS(void) ;
201 Int_t ReadTreeP(void) ;
204 void ReadPrimaries(void) ;
208 // static TFile * fgFile; //!
210 // AliEMCALBeamTestEvent * fBTE ; //! Header if BeamTest Event
212 static Int_t fgDebug ; //! Debug level
214 TString fLoadingStatus ; //! tells which trees are loaded
215 Int_t fNPrimaries ; //! # of primaries
216 TClonesArray * fPrimaries ; //! list of lists of primaries
218 // AliEMCALCalibrationDB * fcdb ; //!
220 static AliEMCALLoader * fgEmcalLoader ; // pointer to EMCAL Loader
221 static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
223 enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
226 ClassDef(AliEMCALGetter,2) // Algorithm class that provides methods to retrieve objects from a list knowing the index
230 #endif // AliEMCALGETTER_H