]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.h
Adding event generator for e+e- pair production
[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 /* $Id$ */
6 //________________________________________________________________________
7 //  A singleton that returns various objects 
8 //  Should be used on the analysis stage to avoid confusing between different
9 //  branches of reconstruction tree: e.g. reading RecPoints and TS made from 
10 //  another set of RecPoints.
11 // 
12 //  The objects are retrived from folders.  
13 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
14 //    
15
16 // Modif: 
17 //  August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
18 //                           of new  IO (à la PHOS)
19  
20 // --- ROOT system ---
21 #include "TClonesArray.h"
22 #include "TFolder.h"  
23 #include "TTree.h"
24 #include "TFile.h"
25 class TString ;
26 class TParticle ;
27 class TTask ;
28
29 // --- Standard library ---
30 #include <stdlib.h>
31
32 // --- AliRoot header files ---
33 #include "AliRun.h"
34 #include "AliEMCAL.h" 
35 #include "AliEMCALHit.h" 
36 #include "AliEMCALDigit.h" 
37 #include "AliEMCALTowerRecPoint.h"
38 class AliEMCALGeometry ;
39 #include "AliEMCALDigitizer.h" 
40 #include "AliEMCALSDigitizer.h"
41 class AliEMCALClusterizer ;
42
43 class AliEMCALGetter : public TObject {
44   
45  public:
46   
47   AliEMCALGetter(){  // ctor: this is a singleton, the ctor should never be called but cint needs it as public
48     Fatal("ctor", "singleton: default ctor not callable") ;
49   } 
50   AliEMCALGetter(const AliEMCALGetter & obj) {
51     // cpy ctor requested by Coding Convention 
52     // but not yet needed
53     Fatal("cpy ctor", "not implemented") ;  
54   } 
55   
56   AliEMCALGetter & operator = (const AliEMCALGetter & ) {
57     // assignement operator requested by coding convention, but not needed
58     Fatal("operator =", "not implemented") ;  
59     return *this ; 
60   }
61   virtual ~AliEMCALGetter() ; 
62   
63   //=========== Instantiators ================  
64   static AliEMCALGetter * GetInstance(const char* headerFile,
65                                       const char* branchTitle = "Default", 
66                                       const Bool_t toSplit = kFALSE ) ; 
67   static AliEMCALGetter * GetInstance() ; 
68  
69   //=========== General information about run ============== 
70   const Int_t  MaxEvent() const    { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
71   const Int_t  EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
72   const Bool_t BranchExists(const TString recName) const ;
73
74   //========== EMCALGeometry and EMCAL ============= 
75   const AliEMCAL *   EMCAL() ;  
76   AliEMCALGeometry * EMCALGeometry() ; 
77
78   //========== Methods to read somethig from file ==========
79   void   Event(const Int_t event, const char * opt = "HSDRP") ;    
80   void   Track(const Int_t itrack) ;
81   void   ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when 
82                                                 //digitizing is under the conytrol of AliRunDigitizer, 
83                                                 //which opens all files etc.
84   //-----------------now getter's data--------------------------------------
85
86   //=========== Primaries ============
87   TTree *           TreeK(TString filename="") ; 
88   TClonesArray *    Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
89   const TParticle * Primary(Int_t index) const;
90   const Int_t       NPrimaries()const { return fNPrimaries; }
91   const TParticle * Secondary(TParticle * p, Int_t index=1) const ;  
92
93   //=========== Hits =================
94   TTree *               TreeH(TString filename="") ; 
95   const TClonesArray *  Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
96   const AliEMCALHit *   Hit(Int_t index) { return dynamic_cast<const AliEMCALHit*>(Hits()->At(index) );}
97
98   //=========== SDigits ==============
99   TTree *         TreeS(TString filename="") ; 
100   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
101     return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
102   const AliEMCALDigit *  SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
103   const AliEMCALSDigitizer *  SDigitizer(const char * name =0) const { 
104     return (const AliEMCALSDigitizer*)(ReturnT("SDigitizer", name)) ; // here static or dynamic cast does not work ! why ?
105   }
106
107   //========== Digits ================
108   TTree *         TreeD(TString filename="") ; 
109   TClonesArray *  Digits(const char * name = 0)const  { 
110     return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
111   const AliEMCALDigit *  Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
112   const AliEMCALDigitizer *  Digitizer(const char * name =0) const { 
113     return (const AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
114       
115   //========== RecPoints =============
116   TObjArray * TowerRecPoints(const char * name = 0) const { 
117     return (dynamic_cast<TObjArray*>(ReturnO("TowerRecPoints", name))) ; }
118   const AliEMCALTowerRecPoint *  TowerRecPoint(Int_t index) { return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
119   TObjArray * PreShowerRecPoints(const char * name = 0) const { 
120     return (dynamic_cast<TObjArray*>(ReturnO("PreShowerRecPoints", name))) ; }
121   const AliEMCALClusterizer * Clusterizer (const char * name =0) const { 
122     return (const AliEMCALClusterizer*)(ReturnT("Clusterizer", name)) ;// here static or dynamic cast does not work ! why ?
123   }
124
125   //-----------------Auxiliary methods: cleaners-----------------
126   void RemoveTask(TString opt, TString name) const ;
127   void RemoveObjects(TString opt, TString name) const ; 
128   void RemoveSDigits() const ; 
129
130  //-----------------Auxiliary methods: miscellana-----------------
131   void CloseFile() ;  
132   const TFolder * Folder(const TString what) const ;
133   const Bool_t HasFailed(void) const {return fFailed ;} 
134   void ListBranches(Int_t event=0) const ;
135   void NewBranch(TString name, Int_t event = 0) ; 
136   Bool_t NewFile(TString name) ;
137   TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
138   void SetDebug(Int_t level) {fDebug = level;} // Set debug level
139   void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
140
141   //------------Auxiliary methods: Posters--------------------
142   const Bool_t PostPrimaries(void ) const ;  
143   const Bool_t PostHits(void ) const ;  
144   const Bool_t PostSDigits(      const char * name,  const char * file = 0) const ;  
145   const Bool_t PostDigits(       const char * name ) const ;  
146   const Bool_t PostRecPoints(    const char * name ) const ;  
147   const Bool_t PostClusterizer( const char * name) const ;  
148   const Bool_t PostClusterizer(AliEMCALClusterizer * clu) const ;  
149   const Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;  
150   const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;  
151   const Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;  
152   const Bool_t PostDigitizer  ( const char * name) const ;  
153
154 private:
155
156   AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ; 
157   TObject * ReturnO(TString what, TString name=0, TString file=0) const ; 
158   const TTask * ReturnT(TString what,TString name=0) const ; 
159   void DefineBranchTitles(char* branch, char* branchTitle) ;
160   Int_t ReadTreeD(const Int_t event) ;
161   Int_t ReadTreeH(void) ;
162   Int_t ReadTreeR(const Int_t event) ;
163   Int_t ReadTreeS(const Int_t event) ;
164   void ReadTreeQA(void) ;
165   void ReadPrimaries(void) ;
166   void CleanWhiteBoard(void) ;
167   void CloseSplitFiles(void) ;
168   void SetTitle(const char * title) ;
169
170   TObject ** PrimariesRef(void) const ;
171   TObject ** HitsRef(void) const ;
172   TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
173   TObject ** DigitsRef (const char * name)   const ;
174   TObject ** TowerRecPointsRef (const char * name) const ;
175   TObject ** PreShowerRecPointsRef (const char * name) const ;
176   TObject ** SDigitizerRef (const char * name) const ; 
177   TObject ** DigitizerRef  (const char * name) const ; 
178   TObject ** ClusterizerRef(const char * name) const ; 
179
180  private:
181
182   static TFile * fFile ;              //!
183   Bool_t         fToSplit ;           //! Do we work in the split mode
184   TString        fHeaderFile ;        //! File in which gAlice lives
185   TString        fBranchTitle ;       //!
186   TString        fTrackSegmentsTitle ;//! 
187   TString        fTrackSegmentsFileName ;//! 
188   TString        fRecPointsTitle ;    //!
189   TString        fRecPointsFileName ;    //!
190   TString        fRecParticlesTitle ; //!
191   TString        fRecParticlesFileName ; //!
192   TString        fDigitsTitle ;       //!TDirectory tempo(gDirectory) 
193   TString        fDigitsFileName ;    //! TDirectory tempo(gDirectory)  
194   TString        fSDigitsTitle ;      //!
195   TString        fSDigitsFileName ;      //!
196   Bool_t         fFailed ;            //! true if file is not opened and/or galice not found
197   Int_t          fDebug ;             // Debug level
198   Int_t          fNPrimaries ;        //! # of primaries 
199   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
200   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
201   TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
202   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
203   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
204   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
205   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
206   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
207   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
208  
209   static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton 
210
211   ClassDef(AliEMCALGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
212
213 };
214
215 #endif // AliEMCALGETTER_H
216