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