]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.h
Preparing to make a better virtual volume for the FMD3 sub-detector -
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.h
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                               */
5
6 /* $Id$ */
7
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.
13 // 
14 //  The objects are retrived from folders.  
15 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
16 //    
17
18
19 // --- ROOT system ---
20 #include "TObject.h"  
21 #include "TClonesArray.h"
22 class TParticle ;
23 class TTree ; 
24 class TGraph ;
25 class TF1 ;
26
27 // --- Standard library ---
28
29 // --- AliRoot header files ---
30 #include "AliConfig.h" 
31
32 // #include "AliRun.h"
33 #include "AliEMCALHit.h"   
34 #include "AliEMCALRecParticle.h"
35 #include "AliEMCALDigitizer.h"
36 #include "AliEMCALSDigitizer.h" 
37 #include "AliEMCALLoader.h" 
38 class AliEMCAL ; 
39 class AliEMCALGeometry ; 
40 class AliEMCALClusterizer ; 
41 class AliEMCALRecPoint ; 
42 class AliEMCALTrackSegmentMaker ;
43 class AliEMCALTrackSegment ; 
44 class AliEMCALPID ; 
45 class AliEMCALBeamTestEvent ;
46
47
48 class AliEMCALGetter : public TObject {
49   
50  public:  
51   AliEMCALGetter() {    
52     // ctor: this is a singleton, the ctor should never be called but cint needs it as public
53     Fatal("ctor", "AliEMCALGetter is a singleton default ctor not callable") ;
54   } 
55   AliEMCALGetter(const AliEMCALGetter & obj):TObject(obj) {
56     // cpy ctor requested by Coding Convention 
57     Fatal("cpy ctor", "not implemented") ;
58   } 
59   
60   AliEMCALGetter & operator = (const AliEMCALGetter & ) {
61     // assignement operator requested by coding convention, but not needed
62     Fatal("operator =", "not implemented") ;
63     return *this ; 
64   }
65   virtual ~AliEMCALGetter() ; 
66   
67   //=========== Instantiators ================
68   static AliEMCALGetter * Instance(const char* headerFile,
69                                   const char* version = AliConfig::GetDefaultEventFolderName(),
70                                   Option_t * openingOption = "READ" ) ; 
71   static AliEMCALGetter * Instance() ; 
72   void   OpenFile(const char* headerFile,
73                   const char* version = AliConfig::GetDefaultEventFolderName(),
74                   Option_t * openingOption = "READ" );
75
76   static void Print() ; 
77   
78 //   //=========== General information about run ==============
79   Bool_t IsLoaded(TString tree) const { return fLoadingStatus.Contains(tree) ; } 
80   void   SetLoaded(TString tree) { fLoadingStatus += tree ; } 
81
82   Int_t  MaxEvent() const ; 
83   Int_t  EventNumber() const ; 
84   Bool_t VersionExists(TString & opt) const ; 
85   UShort_t EventPattern(void) const ; 
86   Float_t  BeamEnergy(void) const ;
87   
88 //   //========== EMCALGeometry and EMCAL ============= 
89   AliEMCAL *         EMCAL() const  ;  
90   AliEMCALGeometry * EMCALGeometry() const ; 
91   
92 //   //========== Methods to read something from file ==========
93   void   Event(Int_t event, const char * opt = "HSDRP") ;    
94   void   Track(Int_t itrack) ;
95   
96 //   //-----------------now getter's data--------------------------------------
97 // //  AliEMCALCalibrationDB * CalibrationDB(){return  fcdb; }
98 // //  void ReadCalibrationDB(const char * name, const char * filename) ;
99
100   //=========== Primaries ============
101 //   TTree *           TreeK(TString filename="") ; 
102   TParticle * Primary(Int_t index) const ;
103   Int_t       NPrimaries() const;
104   TParticle * Secondary(const TParticle * p, Int_t index=1) const ;  
105   
106 //   //=========== Hits =================
107 //   TTree *               TreeH(TString filename="") ; 
108   TClonesArray *  Hits(void) const  ; 
109   AliEMCALHit *    Hit(Int_t index) const { return dynamic_cast<AliEMCALHit*>(Hits()->At(index) );}
110   TTree *         TreeH() const ; 
111   
112   //=========== SDigits ==============
113   TClonesArray *      SDigits() const ;  
114   AliEMCALDigit *      SDigit(Int_t index) const { return static_cast<AliEMCALDigit *>(SDigits()->At(index)) ;} 
115   TTree *             TreeS() const ; 
116   AliEMCALSDigitizer * SDigitizer() ;  
117
118   TString             GetSDigitsFileName() const { return EmcalLoader()->GetSDigitsFileName() ; }  
119   Int_t               LoadSDigits(Option_t* opt="") const { return EmcalLoader()->LoadSDigits(opt) ; }
120   Int_t               LoadSDigitizer(Option_t* opt="") const { return  EmcalLoader()->LoadSDigitizer(opt) ; }
121   Int_t               WriteSDigits(Option_t* opt="") const { return EmcalLoader()->WriteSDigits(opt) ; }
122   Int_t               WriteSDigitizer(Option_t* opt="") const {
123     return  EmcalLoader()->WriteSDigitizer(opt) ; }
124   
125   //========== Digits ================
126   TClonesArray * Digits() const ;
127   AliEMCALDigit * Digit(Int_t index) const { return static_cast<AliEMCALDigit *>(Digits()->At(index)) ;} 
128   TTree *        TreeD() const ; 
129   AliEMCALDigitizer * Digitizer() ;
130   TString             GetDigitsFileName() const { return EmcalLoader()->GetDigitsFileName() ; }  
131   Int_t               LoadDigits(Option_t* opt="") const { return EmcalLoader()->LoadDigits(opt) ; }
132   Int_t               LoadDigitizer(Option_t* opt="") const {
133     return  EmcalLoader()->LoadDigitizer(opt) ; }
134   Int_t               WriteDigits(Option_t* opt="") const { return EmcalLoader()->WriteDigits(opt) ; }
135   Int_t               WriteDigitizer(Option_t* opt="") const {
136     return  EmcalLoader()->WriteDigitizer(opt) ; }
137   
138   //========== RecPoints =============
139   TObjArray *             ECARecPoints() const;
140   AliEMCALRecPoint * ECARecPoint(Int_t index) const{ return static_cast<AliEMCALRecPoint *>(ECARecPoints()->At(index)) ;}    
141   TTree *                 TreeR() const ;
142   AliEMCALClusterizer *   Clusterizer()  ;
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 {
146     return  EmcalLoader()->LoadClusterizer(opt) ; }
147   Int_t                   WriteRecPoints(Option_t* opt="") const { return EmcalLoader()->WriteRecPoints(opt) ; }
148   Int_t                   WriteClusterizer(Option_t* opt="") const {
149     return  EmcalLoader()->WriteClusterizer(opt) ; }
150
151   //========== TrackSegments   TClonesArray * TrackSegments(const char * name = 0) { 
152   TClonesArray *           TrackSegments() const ;
153   AliEMCALTrackSegment *  TrackSegments(Int_t index) const { return static_cast<AliEMCALTrackSegment *>(TrackSegments()->At(index)) ;} 
154   TTree *               TreeT() const ;
155   AliEMCALTrackSegmentMaker * TrackSegmentMaker() ;
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 {
159     return  EmcalLoader()->LoadTrackSegmentMaker(opt) ; }
160   Int_t                 WriteTracks(Option_t* opt="") const { return EmcalLoader()->WriteTracks(opt) ; }
161   Int_t                 WriteTrackSegmentMaker(Option_t* opt="") const {
162     return  EmcalLoader()->WriteTracker(opt) ; }
163   //========== RecParticles ===========
164
165   TClonesArray *         RecParticles() const ;
166   AliEMCALRecParticle *  RecParticle(Int_t index) const { return static_cast<AliEMCALRecParticle *>(RecParticles()->At(index)) ;} 
167   TTree *               TreeP() const ;
168   AliEMCALPID * PID() ;
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 {
172     return  EmcalLoader()->LoadPID(opt) ; }
173   Int_t                 WriteRecParticles(Option_t* opt="") const { return EmcalLoader()->WriteRecParticles(opt) ; }
174   Int_t                 WritePID(Option_t* opt="") const {
175     return  EmcalLoader()->WritePID(opt) ; }
176
177   //========== Raw ===========
178   Int_t ReadRaw(Int_t event) ; 
179
180   void SetDebug(Int_t level) {fgDebug = level;} // Set debug level 
181     void PostClusterizer(AliEMCALClusterizer * clu) 
182     const{EmcalLoader()->PostClusterizer(clu) ; }
183   void PostPID(AliEMCALPID * pid) 
184     const{EmcalLoader()->PostPID(pid) ; }
185   void PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tr) 
186     const{EmcalLoader()->PostTrackSegmentMaker(tr) ; }
187   void PostSDigitizer (AliEMCALSDigitizer * sdigitizer) 
188     const {EmcalLoader()->PostSDigitizer(sdigitizer);}    
189   void PostDigitizer (AliEMCALDigitizer * digitizer)    
190     const {EmcalLoader()->PostDigitizer(dynamic_cast<AliDigitizer *>(digitizer));}
191
192   TString Version() const  { return EmcalLoader()->GetTitle() ; } 
193   AliEMCALLoader * EmcalLoader() const { return fgEmcalLoader; }
194   void Reset() ;  
195
196 private:
197   
198   AliEMCALGetter(const char* headerFile,
199                  const char* version = AliConfig::GetDefaultEventFolderName(),
200                  Option_t * openingOption = "READ") ;
201
202
203   Int_t ReadTreeD(void) ;
204   Int_t ReadTreeH(void) ;
205   Int_t ReadTreeR(void) ;
206   Int_t ReadTreeT(void) ;
207   Int_t ReadTreeS(void) ;
208   Int_t ReadTreeP(void) ;
209
210
211   void ReadPrimaries(void) ;
212  
213   void FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Int_t & amp, Double_t & time) ; 
214
215 private:
216
217 //   static TFile * fgFile;           //! 
218
219 //  AliEMCALBeamTestEvent * fBTE ;           //! Header if BeamTest Event
220
221   static Int_t          fgDebug ;             //! Debug level
222
223   TString           fLoadingStatus ;     //! tells which trees are loaded
224   static TString           fVersion;            //! stores the current folder name
225
226 //  AliEMCALCalibrationDB * fcdb ;       //!
227    
228   static AliEMCALLoader * fgEmcalLoader ; // pointer to EMCAL Loader
229   static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton 
230   
231   enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
232
233
234   ClassDef(AliEMCALGetter,5)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
235
236 };
237
238 #endif // AliEMCALGETTER_H