]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.h
Logarithmic dependence of energy loss added as option.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.h
1 #ifndef ALIEMCALGETTER_H
2 #define ALIEMCALGETTER_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 #include <iostream.h>
31
32 // --- AliRoot header files ---
33
34 #include "AliRun.h"
35 #include "AliEMCALv1.h" 
36 #include "AliEMCALHit.h" 
37 #include "AliEMCALDigit.h" 
38 #include "AliEMCALDigitizer.h" 
39 #include "AliEMCALSDigitizer.h"
40 #include "AliEMCALTowerRecPoint.h"
41 class AliEMCALGeometry ;
42 class AliEMCALClusterizerv1 ;
43 //class AliEMCALTrackSegment ;
44 //class AliEMCALTrackSegmentMaker ;
45 //class AliEMCALRecParticle ;
46 //class AliEMCALPID ;
47
48 class AliEMCALGetter : public TObject {
49   
50  public:
51   
52   AliEMCALGetter(){ 
53     // ctor: this is a singleton, the ctor should never be called but cint needs it as public
54     cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
55     abort() ; 
56   } 
57   AliEMCALGetter(const AliEMCALGetter & obj) {
58     // cpy ctor requested by Coding Convention 
59     // but not yet needed
60     abort() ; 
61   } 
62   
63   virtual ~AliEMCALGetter() ; 
64   
65   void CloseFile() ;  
66   const TFolder * Folder(const TString what) const ;
67   const Bool_t HasFailed(void) const {return fFailed ;} 
68   Bool_t PostPrimaries(void ) const ;  
69   Bool_t PostHits(void ) const ;  
70   Bool_t PostSDigits(      const char * name,  const char * file = 0) const ;  
71   Bool_t PostDigits(       const char * name ) const ;  
72   Bool_t PostRecPoints(    const char * name ) const ;  
73   //Bool_t PostTrackSegments(const char * name) const ;  
74   //Bool_t PostRecParticles( const char * name) const ;  
75
76   Bool_t PostClusterizer( const char * name) const ;  
77   Bool_t PostClusterizer(AliEMCALClusterizerv1 * clu) const ;  
78   Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;  
79   Bool_t PostSDigitizer ( const char * name, const char * file ) const ;  
80   Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;  
81   Bool_t PostDigitizer  ( const char * name) const ;  
82   //Bool_t PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsm) const ;  
83   //Bool_t PostTrackSegmentMaker(const char * name ) const ;  
84   //Bool_t PostPID  (AliEMCALPID * pid) const ;  
85   //Bool_t PostPID  (const char * name ) const ;  
86   //Bool_t PostQA   (void) const ;
87   
88
89   void   Event(const Int_t event, const char * opt = "HSDR") ;    
90   void   Track(Int_t itrack) ;
91
92   //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
93   void   ReadTreeS(TTree * treeS,Int_t input) ;
94   
95   Int_t  EventNumber()       { return (Int_t) gAlice->GetEvNumber() ; }
96   Int_t  MaxEvent()          { return (Int_t) gAlice->TreeE()->GetEntries() ; }
97   static AliEMCALGetter * GetInstance(const char* headerFile,
98                                      const char* branchTitle = "Default", const Option_t * rw="" ) ; 
99   static AliEMCALGetter *   GetInstance() ; 
100
101   const AliEMCALv1 *         EMCAL()  ;  
102   AliEMCALGeometry * EMCALGeometry() ; 
103    // Alarms
104   //TFolder * Alarms() const { return (TFolder*)(ReturnO("Alarms", 0)) ; }
105   //TObjArray *  Alarms(const char * name ) const { return (TObjArray*)(ReturnO("Alarms", name)) ; }
106
107   // QA Tasks
108   //TTask * QATasks(const char * name = 0) const { return (TTask*)(ReturnT("QATasks", name)) ; }
109
110   // Primaries
111   TClonesArray *  Primaries(void) const { return (TClonesArray*)(ReturnO("Primaries")) ; }
112   
113   
114   // Hits
115   TTree *               TreeH(TString filename="") ; 
116   const TClonesArray *  Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
117   const AliEMCALHit *   Hit(Int_t index)  { return static_cast<const AliEMCALHit*>(Hits()->At(index) );}
118   
119   // SDigits
120   TTree *         TreeS(TString filename="") ; 
121   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
122     return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; 
123   }
124   const AliEMCALDigit *  SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
125   
126   AliEMCALSDigitizer *  SDigitizer(const char * name =0) const { 
127     return ((AliEMCALSDigitizer*)(ReturnT("SDigitizer", name))) ; 
128   }
129  
130   // Digits
131   TTree *         TreeD(TString filename="") ; 
132   TClonesArray *  Digits(const char * name = 0)const  { 
133     return static_cast<TClonesArray*>(ReturnO("Digits", name)) ; 
134   }
135   const AliEMCALDigit *  Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
136   AliEMCALDigitizer *  Digitizer(const char * name =0) const { 
137     return (AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; 
138   }
139
140   //  RecPoints
141   TObjArray * TowerRecPoints(const char * name = 0) const { 
142     return (TObjArray*)(ReturnO("TowerRecPoints", name)) ; }
143   TObjArray * PreShowerRecPoints(const char * name = 0) const { 
144     return (TObjArray*)(ReturnO("PreShoRecPoints", name)) ; }
145   const AliEMCALTowerRecPoint *  TowerRecPoint(Int_t index) { 
146     return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
147   const AliEMCALTowerRecPoint *  PreShowerRecPoint(Int_t index) { 
148     return static_cast<const AliEMCALTowerRecPoint *>(PreShowerRecPoints()->At(index)) ;}
149
150     AliEMCALClusterizerv1 * Clusterizer (const char * name =0) const { 
151     return (AliEMCALClusterizerv1*)(ReturnT("Clusterizer", name)) ; }
152
153   // TrackSegments
154   //TClonesArray * TrackSegments(const char * name = 0) const 
155    //                { return (TClonesArray*)(ReturnO("TrackSegments", name)) ; }
156   //AliEMCALTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const 
157     //               { return (AliEMCALTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; }
158
159   // RecParticles
160   //TClonesArray * RecParticles(const char * name = 0) const  
161     //               { return (TClonesArray*)(ReturnO("RecParticles", name)) ; }
162     //AliEMCALPID * PID(const char * name =0) const 
163       //             { return (AliEMCALPID*)(ReturnT("PID", name)) ; }
164
165   // Primaries
166   TTree *                     TreeK(TString filename="") ; 
167   const TParticle *           Primary(Int_t index) const ;
168   const Int_t                 NPrimaries()const { return fNPrimaries; }
169
170   void RemoveTask(TString opt, TString name) const ;
171   void RemoveObjects(TString opt, TString name) const ; 
172   void RemoveSDigits() const ; 
173   void SetDebug(Int_t level) {fDebug = level;} // Set debug level
174
175   AliEMCALGetter & operator = (const AliEMCALGetter & ) {
176     // assignement operator requested by coding convention, but not needed
177     abort() ;
178     return *this ; 
179   }
180   
181   TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
182
183  private:
184
185   AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Option_t * rw ="") ; 
186   void CreateWhiteBoard() const ; 
187   TObject * ReturnO(TString what, TString name=0, TString file=0) const ; 
188   const TTask * ReturnT(TString what,TString name=0) const ; 
189   void DefineBranchTitles(char* branch, char* branchTitle) ;
190   void ReadTreeD() ;
191   void ReadTreeH() ;
192   void ReadTreeR() ;
193   void ReadTreeS(Int_t event) ;
194   //void ReadTreeQA() ;
195   void ReadPrimaries() ;
196
197   TObject ** PrimariesRef(void) const ;
198   TObject ** HitsRef(void) const ;
199   TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
200   TObject ** DigitsRef (const char * name)   const ;
201   TObject ** TowerRecPointsRef (const char * name) const ;
202   TObject ** PreShoRecPointsRef (const char * name) const ;
203   //TObject ** TrackSegmentsRef(const char * name)   const ;
204   //TObject ** RecParticlesRef (const char * name)   const ;
205   //TObject ** AlarmsRef (void)   const ;
206
207   TObject ** SDigitizerRef (const char * name) const ; 
208   TObject ** DigitizerRef  (const char * name) const ; 
209   TObject ** ClusterizerRef(const char * name) const ; 
210   //TObject ** TSMakerRef    (const char * name) const ; 
211   //TObject ** PIDRef        (const char * name) const ; 
212
213  private:
214
215   static TFile *        fFile ;              //!
216   TString        fHeaderFile ;        //! File in which gAlice lives
217   TString        fBranchTitle ;       //!
218   //TString        fTrackSegmentsTitle ;//! 
219   TString        fRecPointsTitle ;    //!
220   //TString        fRecParticlesTitle ; //!
221   TString        fDigitsTitle ;       //!
222   TString        fSDigitsTitle ;      //!
223
224   Bool_t         fFailed ;            //! true if file is not opened and/or galice not found
225   Int_t          fDebug ;             // Debug level
226
227   AliRun *       fAlice ;             //! needed to read TreeK if in an other file than fHeaderFile
228   Int_t          fNPrimaries ;        //! # of primaries
229   
230   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
231
232   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
233   TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
234   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
235   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
236   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
237   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
238   //TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
239   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
240  
241   static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton 
242
243   ClassDef(AliEMCALGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
244
245 };
246
247 #endif // AliEMCALGETTER_H