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