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