]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGetter.h
Obsolete class AliPHOSCPVBaseGeometry removed
[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 "TClonesArray.h"
21 #include "TFolder.h"  
22 #include "TTree.h"
23 #include "TFile.h"
24 class TString ;
25 class TParticle ;
26 class TTask ;
27
28 // --- Standard library ---
29 #include <stdlib.h>
30
31 // --- AliRoot header files ---
32
33 #include "AliRun.h"
34 #include "AliPHOS.h" 
35 #include "AliPHOSHit.h" 
36 #include "AliPHOSDigit.h"
37 #include "AliPHOSEmcRecPoint.h"
38 #include "AliPHOSCpvRecPoint.h"
39 #include "AliPHOSTrackSegment.h"
40 #include "AliPHOSRecParticle.h"
41 class AliPHOSGeometry ;
42 class AliPHOSDigitizer ;
43 class AliPHOSSDigitizer ;
44 class AliPHOSClusterizer ;
45 class AliPHOSTrackSegmentMaker ;
46 class AliPHOSPID ;
47 //class AliPHOSCalibrationDB ;
48 class AliPHOSConTableDB ;
49 class AliPHOSBeamTestEvent ;
50
51 class AliPHOSGetter : public TObject {
52   
53  public:
54   
55   AliPHOSGetter(){    // ctor: this is a singleton, the ctor should never be called but cint needs it as public
56     Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
57   } 
58   AliPHOSGetter(const AliPHOSGetter & obj) {
59     // cpy ctor requested by Coding Convention 
60     // but not yet needed
61     Fatal("cpy ctor", "not implemented") ;
62   } 
63   
64   AliPHOSGetter & operator = (const AliPHOSGetter & ) {
65     // assignement operator requested by coding convention, but not needed
66     Fatal("operator =", "not implemented") ;
67     return *this ; 
68   }
69   virtual ~AliPHOSGetter() ; 
70   
71   //=========== Instantiators ================
72   static AliPHOSGetter * GetInstance(const char* headerFile,
73                                      const char* branchTitle = "Default",
74                                      const Bool_t toSplit = kFALSE ) ; 
75   static AliPHOSGetter * GetInstance() ; 
76   
77   //=========== General information about run ==============
78   const Int_t  MaxEvent() const    { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
79   const Int_t  EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
80   const Bool_t BranchExists(const TString tree) const ; 
81   const UShort_t EventPattern(void) ;
82   const Float_t BeamEnergy(void) ;
83   
84   //========== PHOSGeometry and PHOS ============= 
85   const AliPHOS *         PHOS() ;  
86   const AliPHOSGeometry * PHOSGeometry() ; 
87   
88   //========== Methods to read something from file ==========
89   void   Event(const Int_t event, const char * opt = "HSDRP") ;    
90   void   Track(const Int_t itrack) ;
91   void   ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when 
92                                                 //digitizing is under the control ofAliRunDigizer, 
93                                                 //which opens all files etc.
94   //========== Alarms ======================
95   TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
96   const TObjArray *  Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
97   const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
98   
99   //-----------------now getter's data--------------------------------------
100 //  AliPHOSCalibrationDB * CalibrationDB(){return  fcdb; }
101 //  void ReadCalibrationDB(const char * name, const char * filename) ;
102
103   //=========== Primaries ============
104   TTree *           TreeK(TString filename="") ; 
105   TClonesArray *    Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
106   const TParticle * Primary(Int_t index) const ;
107   const Int_t       NPrimaries()const { return fNPrimaries; }
108   const TParticle * Secondary(TParticle * p, Int_t index=1) const ;  
109   
110   //=========== Hits =================
111   TTree *               TreeH(TString filename="") ; 
112   const TClonesArray *  Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
113   const AliPHOSHit *    Hit(Int_t index)  { return dynamic_cast<const AliPHOSHit*>(Hits()->At(index) );}
114   
115   //=========== SDigits ==============
116   TTree *                    TreeS(TString filename="") ; 
117   TClonesArray *             SDigits(const char * name = 0, const char * file=0) const { 
118     return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ;   }
119   //const AliPHOSDigit *  SDigit(Int_t index) { return static_cast<const AliPHOSDigit *>(SDigits()->At(index)) ;} !!! why no such method ?
120   const AliPHOSSDigitizer *  SDigitizer(const char * name =0) const { 
121     return (const AliPHOSSDigitizer *) ReturnT("SDigitizer", name) ;   // here static or dynamic cast does not work ! why ?
122   }
123   
124   //========== Digits ================
125   TTree *                   TreeD(TString filename="") ; 
126   TClonesArray *            Digits(const char * name = 0)const  { 
127     return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ;   }
128   //const AliPHOSDigit *  Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
129   const TTask *           Digitizer(const char * name = 0) const { 
130     return ReturnT("Digitizer", name) ;   }
131   
132   //========== RecPoints =============
133   TObjArray *                EmcRecPoints(const char * name = 0) {
134     return dynamic_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ;   }
135   //const AliPHOSEmcRecPoint *  EmcRecPoint(Int_t index) { return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;} !!! why no such method ?
136   TObjArray *                CpvRecPoints(const char * name = 0) { 
137     return dynamic_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ;   }    
138   const AliPHOSClusterizer * Clusterizer (const char * name =0) const { 
139     return (const AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ;   // here static or dynamic cast does not work ! why ?
140   }
141   
142   //========== TrackSegments ==========
143   TClonesArray * TrackSegments(const char * name = 0) { 
144     return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ;   }
145   const AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const { 
146     return (const AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;   }
147   
148   //========== RecParticles ===========
149   TClonesArray * RecParticles(const char * name = 0) { 
150     return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ;   }
151   const AliPHOSPID * PID(const char * name =0) const { 
152     return (const AliPHOSPID*)(ReturnT("PID", name)) ; } // here static or dynamic cast does not work ! why ? 
153     
154   //-----------------Auxiliary methods: cleaners-----------------
155   void  RemoveTask(TString opt, TString name) const ;
156   void  RemoveObjects(TString opt, TString name) const ;
157   void  RemoveSDigits() const ;  
158
159   //----------------Auxiliary methods: miscellana----------------
160   void CloseFile() ;  
161   const TFolder * Folder(const TString what) const ;
162   const Bool_t HasFailed() const { return fFailed ; }
163   void ListBranches(Int_t event=0) const ;
164   void NewBranch(TString name, Int_t event = 0) ; 
165   Bool_t NewFile(TString name) ;
166   TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }  
167   void SetDebug(Int_t level) {fDebug = level;} // Set debug level
168   void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
169   
170   //------------Auxiliary methods: Posters--------------------
171   const Bool_t PostPrimaries(void ) const ;  
172   const Bool_t PostHits(void ) const ;  
173   const Bool_t PostSDigits(      const char * name,  const char * file = 0) const ;  
174   const Bool_t PostDigits(       const char * name ) const ;  
175   const Bool_t PostRecPoints(    const char * name ) const ;  
176   const Bool_t PostTrackSegments(const char * name) const ;  
177   const Bool_t PostRecParticles( const char * name) const ;  
178   const Bool_t PostClusterizer( const char * name) const ;  
179   const Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;  
180   const Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;  
181   const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;  
182   const Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;  
183   const Bool_t PostDigitizer  ( const char * name) const ;  
184   const Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;  
185   const Bool_t PostTrackSegmentMaker(const char * name ) const ;  
186   const Bool_t PostPID  (AliPHOSPID * pid) const ;  
187   const Bool_t PostPID  (const char * name ) const ;  
188   const Bool_t PostQA   (void) const ;
189
190 private:
191   
192   AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ; 
193   TObject * ReturnO(TString what, TString name=0, TString file=0) const ; 
194   const TTask * ReturnT(TString what,TString name=0) const ; 
195   void DefineBranchTitles(char* branch, char* branchTitle) ;
196   Int_t ReadTreeD(const Int_t event) ;
197   Int_t ReadTreeH(void) ;
198   Int_t ReadTreeR(const Int_t event) ;
199   Int_t ReadTreeS(const Int_t event) ;
200   void ReadTreeQA(void) ;
201   void ReadPrimaries(void) ;
202   void CleanWhiteBoard(void) ;
203   void CloseSplitFiles(void) ;
204   void SetTitle(const char * title) ;
205
206   TObject** PrimariesRef(void) const ;
207   TObject** HitsRef(void) const ;
208   TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
209   TObject** DigitsRef (const char * name)   const ;
210   TObject** EmcRecPointsRef (const char * name) const ;
211   TObject** CpvRecPointsRef (const char * name) const ;
212   TObject** TrackSegmentsRef(const char * name)   const ;
213   TObject** RecParticlesRef (const char * name)   const ;
214   TObject** AlarmsRef (void)   const ;
215
216   TObject** SDigitizerRef (const char * name) const ; 
217   TObject** DigitizerRef  (const char * name) const ; 
218   TObject** ClusterizerRef(const char * name) const ; 
219   TObject** TSMakerRef    (const char * name) const ; 
220   TObject** PIDRef        (const char * name) const ; 
221
222  private:
223
224   static TFile * fgFile;           //! 
225   Bool_t         fToSplit ;              //! Do we work in the split mode
226   AliPHOSBeamTestEvent * fBTE ;           //! Header if BeamTest Event
227   TString        fHeaderFile ;           //! File in which gAlice lives
228   TString        fBranchTitle ;          //!
229   TString        fTrackSegmentsTitle ;   //! 
230   TString        fTrackSegmentsFileName ;//! 
231   TString        fRecPointsTitle ;       //!
232   TString        fRecPointsFileName ;    //!
233   TString        fRecParticlesTitle ;    //!
234   TString        fRecParticlesFileName ; //!
235   TString        fDigitsTitle ;          //! TDirectory tempo(gDirectory) 
236   TString        fDigitsFileName ;       //! TDirectory tempo(gDirectory) 
237   TString        fSDigitsTitle ;         //!
238   TString        fSDigitsFileName ;      //!
239   Bool_t         fFailed ;            //! set if file not opend or galice not found
240   Int_t          fDebug ;             //! Debug level
241   AliRun *       fAlice ;             //! needed to read TreeK if in an other file than fHeaderFile
242   Int_t          fNPrimaries ;        //! # of primaries  
243   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
244   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
245   TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
246   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
247   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
248   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
249   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
250   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
251   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
252
253 //  AliPHOSCalibrationDB * fcdb ;       //!
254    
255   static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton 
256
257   ClassDef(AliPHOSGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
258
259 };
260
261 #endif // AliPHOSGETTER_H