coding convention
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.h
CommitLineData
ffa6d63b 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 */
88cb7938 5
ffa6d63b 6/* $Id$ */
88cb7938 7
8//_________________________________________________________________________
ffa6d63b 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.
d75bea67 13//
ffa6d63b 14// The objects are retrived from folders.
d75bea67 15//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
16//
ffa6d63b 17
88cb7938 18
ffa6d63b 19// --- ROOT system ---
88cb7938 20#include "TObject.h"
1ce25ac8 21#include "TClonesArray.h"
22class TParticle ;
23class TTree ;
ffa6d63b 24
25// --- Standard library ---
173558f2 26
ffa6d63b 27// --- AliRoot header files ---
88cb7938 28#include "AliConfig.h"
29
30// #include "AliRun.h"
88cb7938 31#include "AliEMCALHit.h"
d64c959b 32#include "AliEMCALRecParticle.h"
88cb7938 33#include "AliEMCALDigitizer.h"
34#include "AliEMCALSDigitizer.h"
1ce25ac8 35#include "AliEMCALLoader.h"
36class AliEMCAL ;
37class AliEMCALGeometry ;
38class AliEMCALClusterizer ;
39class AliEMCALRecPoint ;
40class AliEMCALTowerRecPoint ;
41class AliEMCALTrackSegmentMaker ;
42class AliEMCALTrackSegment ;
43class AliEMCALPID ;
88cb7938 44class AliEMCALBeamTestEvent ;
45
173558f2 46
ffa6d63b 47class AliEMCALGetter : public TObject {
48
88cb7938 49 public:
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") ;
ffa6d63b 52 }
39200c71 53 AliEMCALGetter(const AliEMCALGetter & obj):TObject(obj) {
ffa6d63b 54 // cpy ctor requested by Coding Convention
88cb7938 55 Fatal("cpy ctor", "not implemented") ;
ffa6d63b 56 }
57
05a92d59 58 AliEMCALGetter & operator = (const AliEMCALGetter & ) {
59 // assignement operator requested by coding convention, but not needed
88cb7938 60 Fatal("operator =", "not implemented") ;
05a92d59 61 return *this ;
62 }
ffa6d63b 63 virtual ~AliEMCALGetter() ;
64
88cb7938 65 //=========== Instantiators ================
66 static AliEMCALGetter * Instance(const char* headerFile,
67 const char* version = AliConfig::fgkDefaultEventFolderName,
68 Option_t * openingOption = "READ" ) ;
69 static AliEMCALGetter * Instance() ;
70
71 static void Print() ;
72
73// //=========== General information about run ==============
74 Bool_t IsLoaded(const TString tree) const { return fLoadingStatus.Contains(tree) ; }
75 void SetLoaded(const TString tree) { fLoadingStatus += tree ; }
76
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 ;
82
83// //========== EMCALGeometry and EMCAL =============
84 AliEMCAL * EMCAL() const ;
85 AliEMCALGeometry * EMCALGeometry() const ;
86
87// //========== Methods to read something from file ==========
05a92d59 88 void Event(const Int_t event, const char * opt = "HSDRP") ;
89 void Track(const Int_t itrack) ;
88cb7938 90
91// //-----------------now getter's data--------------------------------------
92// // AliEMCALCalibrationDB * CalibrationDB(){return fcdb; }
93// // void ReadCalibrationDB(const char * name, const char * filename) ;
05a92d59 94
95 //=========== Primaries ============
88cb7938 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, const Int_t index=1) const ;
101
102// //=========== Hits =================
103// TTree * TreeH(TString filename="") ;
1ce25ac8 104 TClonesArray * Hits(void) const ;
105 AliEMCALHit * Hit(const Int_t index) const { return dynamic_cast<AliEMCALHit*>(Hits()->At(index) );}
88cb7938 106 TTree * TreeH() const ;
107
05a92d59 108 //=========== SDigits ==============
1ce25ac8 109 TClonesArray * SDigits() const ;
110 AliEMCALDigit * SDigit(const Int_t index) const { return static_cast<AliEMCALDigit *>(SDigits()->At(index)) ;}
88cb7938 111 TTree * TreeS() const ;
112 AliEMCALSDigitizer * SDigitizer() ;
113
1ce25ac8 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 {
88cb7938 119 return EmcalLoader()->WriteSDigitizer(opt) ; }
120
05a92d59 121 //========== Digits ================
1ce25ac8 122 TClonesArray * Digits() const ;
123 AliEMCALDigit * Digit(const Int_t index) const { return static_cast<AliEMCALDigit *>(Digits()->At(index)) ;}
88cb7938 124 TTree * TreeD() const ;
125 AliEMCALDigitizer * Digitizer() ;
1ce25ac8 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 {
88cb7938 129 return EmcalLoader()->LoadDigitizer(opt) ; }
1ce25ac8 130 Int_t WriteDigits(Option_t* opt="") const { return EmcalLoader()->WriteDigits(opt) ; }
131 Int_t WriteDigitizer(Option_t* opt="") const {
88cb7938 132 return EmcalLoader()->WriteDigitizer(opt) ; }
133
05a92d59 134 //========== RecPoints =============
1ce25ac8 135 TObjArray * PRERecPoints() const ;
136 AliEMCALRecPoint * PRERecPoint(const Int_t index) const { return static_cast<AliEMCALRecPoint *>(PRERecPoints()->At(index)) ;}
137 TObjArray * ECARecPoints() const ;
138 AliEMCALTowerRecPoint * ECARecPoint(const Int_t index) const { return static_cast<AliEMCALTowerRecPoint *>(ECARecPoints()->At(index)) ;}
139 TObjArray * HCARecPoints() const ;
140 AliEMCALTowerRecPoint * HCARecPoint(const Int_t index) const { return static_cast<AliEMCALTowerRecPoint *>(HCARecPoints()->At(index)) ;}
88cb7938 141 TTree * TreeR() const ;
142 AliEMCALClusterizer * Clusterizer() ;
1ce25ac8 143 TString GetRecPointsFileName() const { return EmcalLoader()->GetRecPointsFileName() ; }
144 Int_t LoadRecPoints(Option_t* opt="") const { return EmcalLoader()->LoadRecPoints(opt) ; }
145 Int_t LoadClusterizer(Option_t* opt="") const {
88cb7938 146 return EmcalLoader()->LoadClusterizer(opt) ; }
1ce25ac8 147 Int_t WriteRecPoints(Option_t* opt="") const { return EmcalLoader()->WriteRecPoints(opt) ; }
148 Int_t WriteClusterizer(Option_t* opt="") const {
88cb7938 149 return EmcalLoader()->WriteClusterizer(opt) ; }
150
151 //========== TrackSegments TClonesArray * TrackSegments(const char * name = 0) {
1ce25ac8 152 TClonesArray * TrackSegments() const ;
153 AliEMCALTrackSegment * TrackSegments(const Int_t index) const { return static_cast<AliEMCALTrackSegment *>(TrackSegments()->At(index)) ;}
88cb7938 154 TTree * TreeT() const ;
155 AliEMCALTrackSegmentMaker * TrackSegmentMaker() ;
1ce25ac8 156 TString GetTracksFileName() const { return EmcalLoader()->GetTracksFileName() ; }
157 Int_t LoadTracks(Option_t* opt="") const { return EmcalLoader()->LoadTracks(opt) ; }
158 Int_t LoadTrackSegementMaker(Option_t* opt="") const {
88cb7938 159 return EmcalLoader()->LoadTrackSegmentMaker(opt) ; }
1ce25ac8 160 Int_t WriteTracks(Option_t* opt="") const { return EmcalLoader()->WriteTracks(opt) ; }
161 Int_t WriteTrackSegmentMaker(Option_t* opt="") const {
88cb7938 162 return EmcalLoader()->WriteTracker(opt) ; }
516fff8e 163 //========== RecParticles ===========
173558f2 164
1ce25ac8 165 TClonesArray * RecParticles() const ;
166 AliEMCALRecParticle * RecPaticles(const Int_t index) const { return static_cast<AliEMCALRecParticle *>(RecParticles()->At(index)) ;}
88cb7938 167 TTree * TreeP() const ;
168 AliEMCALPID * PID() ;
1ce25ac8 169 TString GetRecParticlesFileName() const { return EmcalLoader()->GetRecParticlesFileName() ; }
170 Int_t LoadRecParticles(Option_t* opt="") const { return EmcalLoader()->LoadRecParticles(opt) ; }
171 Int_t LoadPID(Option_t* opt="") const {
88cb7938 172 return EmcalLoader()->LoadPID(opt) ; }
1ce25ac8 173 Int_t WriteRecParticles(Option_t* opt="") const { return EmcalLoader()->WriteRecParticles(opt) ; }
174 Int_t WritePID(Option_t* opt="") const {
88cb7938 175 return EmcalLoader()->WritePID(opt) ; }
176
177
178 void SetDebug(Int_t level) {fgDebug = level;} // Set debug level
1ce25ac8 179 void PostClusterizer(AliEMCALClusterizer * clu)
88cb7938 180 const{EmcalLoader()->PostClusterizer(clu) ; }
181 void PostPID(AliEMCALPID * pid)
182 const{EmcalLoader()->PostPID(pid) ; }
183 void PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tr)
184 const{EmcalLoader()->PostTrackSegmentMaker(tr) ; }
185 void PostSDigitizer (AliEMCALSDigitizer * sdigitizer)
186 const {EmcalLoader()->PostSDigitizer(sdigitizer);}
187 void PostDigitizer (AliEMCALDigitizer * digitizer)
188 const {EmcalLoader()->PostDigitizer(dynamic_cast<AliDigitizer *>(digitizer));}
189
190 TString Version() const { return EmcalLoader()->GetTitle() ; }
191 AliEMCALLoader * EmcalLoader() const { return fgEmcalLoader ; }
192
9859bfc0 193private:
88cb7938 194
195 AliEMCALGetter(const char* headerFile,
196 const char* version = AliConfig::fgkDefaultEventFolderName,
197 Option_t * openingOption = "READ") ;
173558f2 198
88cb7938 199 Int_t ReadTreeD(void) ;
05a92d59 200 Int_t ReadTreeH(void) ;
88cb7938 201 Int_t ReadTreeR(void) ;
202 Int_t ReadTreeT(void) ;
203 Int_t ReadTreeS(void) ;
204 Int_t ReadTreeP(void) ;
205
206
05a92d59 207 void ReadPrimaries(void) ;
88cb7938 208
209private:
210
211// static TFile * fgFile; //!
212
213// AliEMCALBeamTestEvent * fBTE ; //! Header if BeamTest Event
214
215 static Int_t fgDebug ; //! Debug level
216
217 TString fLoadingStatus ; //! tells which trees are loaded
218 Int_t fNPrimaries ; //! # of primaries
219 TClonesArray * fPrimaries ; //! list of lists of primaries
220
221// AliEMCALCalibrationDB * fcdb ; //!
222
1ce25ac8 223 static AliEMCALLoader * fgEmcalLoader ; // pointer to EMCAL Loader
ffa6d63b 224 static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
88cb7938 225
226 enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
227
ffa6d63b 228
39200c71 229 ClassDef(AliEMCALGetter,2) // Algorithm class that provides methods to retrieve objects from a list knowing the index
ffa6d63b 230
231};
232
233#endif // AliEMCALGETTER_H