]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGetter.h
Introduce new default paramenters (previous version did not do it properly)
[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 class TString ;
24 class TParticle ;
25 class TTask ;
26
27 // --- Standard library ---
28 #include <stdlib.h>
29 #include <iostream.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
48 class AliPHOSGetter : public TObject {
49   
50  public:
51   
52   AliPHOSGetter(){    // ctor: this is a singleton, the ctor should never be called but cint needs it as public
53     cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
54     abort() ; 
55   } 
56   AliPHOSGetter(const AliPHOSGetter & obj) {
57     // cpy ctor requested by Coding Convention 
58     // but not yet needed
59     abort() ; 
60   } 
61   
62   virtual ~AliPHOSGetter() ; 
63   
64   void ListBranches(Int_t event=0) const ;
65   void NewBranch(TString name, Int_t event = 0) ; 
66   Bool_t AliPHOSGetter::NewFile(TString name) ;
67   const Bool_t HasFailed() 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(AliPHOSClusterizer * clu) const ;  
78   Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;  
79   Bool_t PostSDigitizer ( const char * name, const char * file ) const ;  
80   Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;  
81   Bool_t PostDigitizer  ( const char * name) const ;  
82   Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;  
83   Bool_t PostTrackSegmentMaker(const char * name ) const ;  
84   Bool_t PostPID  (AliPHOSPID * 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 = "HSDRP") ;    
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 AliPHOSGetter * GetInstance(const char* headerFile,
98                                      const char* branchTitle = "Default" ) ; 
99   static AliPHOSGetter *   GetInstance() ; 
100
101   const AliPHOS *         PHOS()  ;  
102   const  AliPHOSGeometry * PHOSGeometry() ; 
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   // Hits
113   const TClonesArray *  Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
114   const AliPHOSHit * Hit(Int_t index)  { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
115   
116   // SDigits
117   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
118     return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; 
119   }
120   const AliPHOSDigit *  SDigit(Int_t index) { return static_cast<const AliPHOSDigit*>(SDigits()->At(index)) ;}
121   
122   AliPHOSSDigitizer *  SDigitizer(const char * name =0) const { 
123     return ((AliPHOSSDigitizer*)(ReturnT("SDigitizer", name))) ; 
124   }
125   
126   // Digits
127   TClonesArray *  Digits(const char * name = 0)const  { 
128     return static_cast<TClonesArray*>(ReturnO("Digits", name)) ; 
129   }
130   const AliPHOSDigit *  Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;}
131   AliPHOSDigitizer *  Digitizer(const char * name =0) const { 
132     return (AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ; 
133   }
134   
135   // RecPoints
136   TObjArray * EmcRecPoints(const char * name = 0) {
137     return static_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ; 
138   }
139   TObjArray * CpvRecPoints(const char * name = 0) { 
140     return static_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ; 
141   }
142   const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { 
143     return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;
144   }
145   const AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) { 
146     return static_cast<const AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;  
147   }
148     
149   AliPHOSClusterizer * Clusterizer (const char * name =0) const { 
150     return (AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; 
151   }
152   
153   // TrackSegments
154   TClonesArray * TrackSegments(const char * name = 0) { 
155     return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ; 
156   }
157   const AliPHOSTrackSegment * TrackSegment(Int_t index) { 
158     return static_cast<const AliPHOSTrackSegment*>(TrackSegments()->At(index)) ; 
159   }
160   AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const { 
161     return (AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; 
162   }
163   
164   // RecParticles
165   TClonesArray * RecParticles(const char * name = 0) { 
166     return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ; 
167   }
168   const AliPHOSRecParticle * RecParticle(Int_t index) { 
169     return static_cast<const AliPHOSRecParticle*>(RecParticles()->At(index)) ; 
170   }
171   AliPHOSPID * PID(const char * name =0) const { 
172     return (AliPHOSPID*)(ReturnT("PID", name)) ; 
173   }
174   
175   // Primaries
176   const TParticle *           Primary(Int_t index) const ;
177   const Int_t                 NPrimaries()const { return fNPrimaries; }
178   const TParticle *           Secondary(TParticle * p, Int_t index=1) const ;
179   
180   void  SetDebug(Int_t level) {fDebug = level;} // Set debug level
181   
182   AliPHOSGetter & operator = (const AliPHOSGetter & ) {
183     // assignement operator requested by coding convention, but not needed
184     abort() ;
185     return *this ; 
186   }
187   
188   TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
189
190   void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
191   
192 private:
193   
194   AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default") ; 
195   TObject * ReturnO(TString what, TString name=0, TString file=0) const ; 
196   const TTask * ReturnT(TString what,TString name=0) const ; 
197   void DefineBranchTitles(char* branch, char* branchTitle) ;
198   Int_t ReadTreeD() ;
199   Int_t ReadTreeH() ;
200   Int_t ReadTreeR(Bool_t any=kFALSE) ;
201   Int_t ReadTreeS(Int_t event) ;
202   void ReadTreeQA() ;
203   void ReadPrimaries() ;
204
205   TObject** PrimariesRef(void) const ;
206   TObject** HitsRef(void) const ;
207   TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
208   TObject** DigitsRef (const char * name)   const ;
209   TObject** EmcRecPointsRef (const char * name) const ;
210   TObject** CpvRecPointsRef (const char * name) const ;
211   TObject** TrackSegmentsRef(const char * name)   const ;
212   TObject** RecParticlesRef (const char * name)   const ;
213   TObject** AlarmsRef (void)   const ;
214
215   TObject** SDigitizerRef (const char * name) const ; 
216   TObject** DigitizerRef  (const char * name) const ; 
217   TObject** ClusterizerRef(const char * name) const ; 
218   TObject** TSMakerRef    (const char * name) const ; 
219   TObject** PIDRef        (const char * name) const ; 
220
221  private:
222
223   static TFile *        fFile;               //! 
224   TString        fHeaderFile ;        //! File in which gAlice lives
225   TString        fBranchTitle ;       //!
226   TString        fTrackSegmentsTitle ;//! 
227   TString        fRecPointsTitle ;    //!
228   TString        fRecParticlesTitle ; //!
229   TString        fDigitsTitle ;       //! TDirectory tempo(gDirectory) ; 
230
231   TString        fSDigitsTitle ;      //!
232
233   Bool_t         fFailed ;            //! set if file not opend or galice not found
234   Int_t          fDebug ;             // Debug level
235
236   Int_t          fNPrimaries ;        //! # of primaries
237   
238   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
239
240   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
241   TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
242   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
243   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
244   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
245   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
246   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
247   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
248  
249   static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton 
250
251   ClassDef(AliPHOSGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
252
253 };
254
255 #endif // AliPHOSGETTER_H