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