]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSLoader.h
Inserting TMath.h where required by the new version of ROOT
[u/mrichter/AliRoot.git] / PHOS / AliPHOSLoader.h
1 #ifndef ALIPHOSLOADER_H
2 #define ALIPHOSLOADER_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 /* History of cvs commits:
9  *
10  * $Log$
11  * Revision 1.11  2006/08/01 12:15:03  cvetan
12  * Adding a constructor from TFolder. Needed by AliReconstruction plugin scheme
13  *
14  * Revision 1.10  2005/05/28 14:19:04  schutz
15  * Compilation warnings fixed by T.P.
16  *
17  */
18
19 //_________________________________________________________________________
20 //  A singleton that returns various objects 
21 //  Should be used on the analysis stage to avoid confusing between different
22 //  branches of reconstruction tree: e.g. reading RecPoints and TS made from 
23 //  another set of RecPoints.
24 // 
25 //  The objects are retrived from folders.  
26 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
27 //    
28
29
30 // --- ROOT system ---
31 #include "TClonesArray.h"
32 class TString ;
33 class TParticle ;
34 class TTask ;
35
36 // --- Standard library ---
37
38 // --- AliRoot header files ---
39
40 #include "AliRun.h"
41 #include "AliLoader.h"
42 #include "AliRunLoader.h"
43 #include "AliPHOSClusterizer.h"
44 #include "AliPHOSTrackSegmentMaker.h"
45 #include "AliPHOSPID.h"
46 class AliPHOS ; 
47 class AliPHOSGeometry ;
48 class AliPHOSHit ; 
49 class AliPHOSDigit ; 
50 class AliPHOSEmcRecPoint ; 
51 class AliPHOSCpvRecPoint ; 
52 class AliPHOSTrackSegment ;
53 class AliPHOSRecParticle ;  
54 class AliPHOSCalibrationDB ;
55 class AliPHOSSDigitizer ; 
56 class AliPHOSDigitizer ;
57   
58
59
60 //
61
62 class AliPHOSLoader : public AliLoader {
63   
64 public:
65
66   AliPHOSLoader();
67   AliPHOSLoader(const AliPHOSLoader & obj);
68   AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername); 
69   AliPHOSLoader(const Char_t *detname,TFolder *topfolder);
70   
71   virtual ~AliPHOSLoader() ; 
72
73   // assignement operator requested by coding convention, but not needed
74   AliPHOSLoader & operator = (const AliPHOSLoader & ) {return *this;}
75
76   Int_t   GetEvent();//extends the method on PHOS RecPart posting
77   Int_t   SetEvent();//extends the method on PHOS RecPart posting
78   
79   Bool_t  BranchExists(const TString& recName);
80   Int_t   LoadHits(Option_t* opt=""); //reads  from disk and sends them to folder; array as well as tree
81   Int_t   LoadSDigits(Option_t* opt="");
82   Int_t   LoadDigits(Option_t* opt=""); //reads Digits from disk and sends them to folder; array as well as tree
83   Int_t   LoadRecPoints(Option_t* opt=""); //reads RecPoints from disk and sends them to folder; array as well as tree
84   Int_t   LoadTracks(Option_t* opt="");  //reads Tracks from disk and sends them to folder; array as well as tree
85   Int_t   LoadRecParticles(Option_t* opt="");
86    
87   Int_t   PostHits()const;  //Posts the 
88   Int_t   PostSDigits()const;
89   Int_t   PostDigits()const;
90   Int_t   PostRecPoints()const;
91   Int_t   PostTracks()const;
92   Int_t   PostRecParticles()const;
93   
94   void    CleanFolders();//cleans all the stuff loaded by this detector + calls AliLoader::Clean
95
96   void    CleanHits()const;
97   void    CleanSDigits()const;
98   void    CleanDigits()const;
99   void    CleanRecPoints()const;
100   void    CleanTracks()const;
101   void    CleanRecParticles();
102
103 //up to now it is only here -> no definition about global/incremental tracking/PID
104  
105 //   Int_t   WriteRecParticles(Option_t* opt="");//writes the reconstructed particles
106 //   Int_t   WritePID(Option_t* opt="");//writes the task for PID to file
107 //   Bool_t  PostPID  (AliPHOSPID * pid) const {return kTRUE;}
108   
109 /*******************************************************************/
110 /*******************************************************************/
111 /*******************************************************************/
112
113   TObject** HitsRef(){return GetDetectorDataRef(Hits());}
114   TObject** SDigitsRef(){return GetDetectorDataRef(SDigits());}
115   TObject** DigitsRef(){return GetDetectorDataRef(Digits());}
116   TObject** EmcRecPointsRef(){return GetDetectorDataRef(EmcRecPoints());}
117   TObject** CpvRecPointsRef(){return GetDetectorDataRef(CpvRecPoints());}
118   TObject** TracksRef(){return GetDetectorDataRef(TrackSegments());}
119   TObject** RecParticlesRef(){return GetDetectorDataRef(RecParticles());}
120   TObject** AlarmsRef(){return GetDetectorDataRef(Alarms());}
121   void   Track(Int_t itrack) ;
122
123   static AliPHOSGeometry* GetPHOSGeometry();
124   static AliPHOSLoader* GetPHOSLoader(const  char* eventfoldername);
125
126   //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
127   Int_t  EventNumber()       { return (Int_t) GetRunLoader()->GetEventNumber();}
128   Int_t  MaxEvent()          { return (Int_t) GetRunLoader()->TreeE()->GetEntries();}
129
130   const AliPHOS *         PHOS();
131   const AliPHOSGeometry  *PHOSGeometry() ; 
132   // Alarms
133   // TFolder * Alarms() const { return (TFolder*)(ReturnO("Alarms", 0)); }
134   TObjArray *  Alarms() {return 0x0;}  
135
136   /*********************************************/
137   /************    TClonesArrays     ***********/
138   /*********************************************/
139   /****   H i t s  ****/
140   TClonesArray*  Hits(void);
141   const AliPHOSHit*    Hit(Int_t index);
142   void MakeHitsArray();
143   /****   S D i g i t s  ****/ 
144   TClonesArray*  SDigits();
145   const AliPHOSDigit*  SDigit(Int_t index);
146   void MakeSDigitsArray();
147   /****  D i g i t s  ****/
148   TClonesArray*   Digits();
149   const AliPHOSDigit *  Digit(Int_t index);
150   void MakeDigitsArray();
151   /****  R e c P o i n t s  ****/
152   TObjArray * EmcRecPoints();
153   TObjArray * CpvRecPoints();
154   const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) ;
155   const AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) ;
156   void MakeRecPointsArray();
157   /****   T r a c k S e g m e n t s ****/
158   TClonesArray * TrackSegments();
159   const AliPHOSTrackSegment * TrackSegment(Int_t index);
160   void MakeTrackSegmentsArray();
161   /****  R e c P a r t ic l e s   ****/
162   TClonesArray * RecParticles() ;
163   const AliPHOSRecParticle * RecParticle(Int_t index);
164   void MakeRecParticlesArray();
165
166   /*********************************************/
167   /************    T A S K S      **************/
168   /*********************************************/
169   // 
170   //  AliPHOSSDigitizer*  PHOSSDigitizer(TString name = AliConfig::GetDefaultEventFolderName());
171   //AliPHOSDigitizer*   PHOSDigitizer()  { return  dynamic_cast<AliPHOSDigitizer*>(Digitizer()) ;}
172
173   AliPHOSClusterizer* Clusterizer () const {return dynamic_cast<AliPHOSClusterizer*>(Reconstructioner()) ;}
174   Int_t PostClusterizer(TTask* clust) const {return PostReconstructioner(clust);}
175   Int_t LoadClusterizer(Option_t * opt="") const {return LoadReconstructioner(opt);}
176   Int_t WriteClusterizer(Option_t * opt="") const {return WriteReconstructioner(opt);}
177
178   AliPHOSPID * PID () const {return dynamic_cast<AliPHOSPID*>(PIDTask()) ;}
179   Int_t PostPID(TTask* pid) const {return PostPIDTask(pid);}
180   Int_t LoadPID(Option_t * opt="") const {return LoadPIDTask(opt);}
181   Int_t WritePID(Option_t * opt="") const {return WritePIDTask(opt);}
182
183
184   AliPHOSTrackSegmentMaker * TrackSegmentMaker () const { return dynamic_cast<AliPHOSTrackSegmentMaker *>(Tracker()) ;}
185   Int_t PostTrackSegmentMaker(TTask* segmaker) const {return PostTracker(segmaker);}
186   Int_t LoadTrackSegmentMaker(Option_t * opt="") const {return LoadTracker(opt);}
187   Int_t WriteTrackSegmentMaker(Option_t * opt="") const {return WriteTracker(opt);}
188
189   
190   void   SetDebug(Int_t level) {fDebug = level;} // Set debug level
191   void   SetBranchTitle(const TString& btitle);
192
193   Int_t   GetDebug()                     const {return fDebug;      }
194   TString GetBranchTitle()               const {return fBranchTitle;}
195   AliPHOSCalibrationDB * CalibrationDB() const {return fcdb;        }
196   void ReadCalibrationDB(const char * name, const char * filename);
197   
198 protected:
199   TString fBranchTitle;            //Title of the branch
200   AliPHOSCalibrationDB * fcdb ;       //!
201
202 private:
203
204   Int_t ReadHits();
205   Int_t ReadDigits();
206   Int_t ReadSDigits();
207   Int_t ReadRecPoints();
208   Int_t ReadTracks();
209   Int_t ReadRecParticles();
210   
211   Int_t  fDebug ;             // Debug level
212
213   static const TString fgkHitsName;//Name for TClonesArray with hits from one event
214   static const TString fgkSDigitsName;//Name for TClonesArray 
215   static const TString fgkDigitsName;//Name for TClonesArray 
216   static const TString fgkEmcRecPointsName;//Name for TClonesArray 
217   static const TString fgkCpvRecPointsName;//Name for TClonesArray 
218   static const TString fgkTracksName;//Name for TClonesArray 
219   static const TString fgkRecParticlesName;//Name for TClonesArray
220
221   static const TString fgkEmcRecPointsBranchName;//Name for branch
222   static const TString fgkCpvRecPointsBranchName;//Name for branch
223   static const TString fgkTrackSegmentsBranchName;//Name for branch
224   static const TString fgkRecParticlesBranchName;//Name for branch
225   
226  
227   ClassDef(AliPHOSLoader,3)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
228
229 };
230
231 /******************************************************************************/
232 /****************    I N L I N E S     ****************************************/
233 /******************************************************************************/
234
235 inline TClonesArray* AliPHOSLoader::Hits()  
236 {
237  return (TClonesArray*)GetDetectorData(fgkHitsName);
238 }
239 /******************************************************************************/
240
241 inline const AliPHOSHit* AliPHOSLoader::Hit(Int_t index)  
242 {
243   const TClonesArray* tcarr = Hits();
244   if (tcarr)
245     return (const AliPHOSHit*) tcarr->At(index);
246   return 0x0; 
247 }
248 /******************************************************************************/
249
250 inline TClonesArray* AliPHOSLoader::SDigits()
251 {
252    return dynamic_cast<TClonesArray*>(GetDetectorData(fgkSDigitsName));
253 }
254 /******************************************************************************/
255
256 inline const AliPHOSDigit*  AliPHOSLoader::SDigit(Int_t index)
257 {
258   const TClonesArray* tcarr = SDigits();
259   if (tcarr)
260     return (const AliPHOSDigit*) tcarr->At(index);
261   return 0x0; 
262 }
263 /******************************************************************************/
264
265 inline TClonesArray* AliPHOSLoader::Digits()
266 {
267  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkDigitsName));
268 }
269 /******************************************************************************/
270
271 inline const AliPHOSDigit*  AliPHOSLoader::Digit(Int_t index)
272 {
273   const TClonesArray* tcarr = Digits();
274   if (tcarr)
275     return (const AliPHOSDigit*) tcarr->At(index);
276   return 0x0; 
277 }
278 /******************************************************************************/
279
280 inline TObjArray * AliPHOSLoader::EmcRecPoints()
281 {
282  return dynamic_cast<TObjArray*>(GetDetectorData(fgkEmcRecPointsName));
283 }
284 /******************************************************************************/
285
286 inline const AliPHOSEmcRecPoint * AliPHOSLoader::EmcRecPoint(Int_t index)
287 {
288   TObjArray* tcarr = EmcRecPoints();
289   if (tcarr)
290     return (const AliPHOSEmcRecPoint*) tcarr->At(index);
291   return 0x0; 
292 }
293 /******************************************************************************/
294
295 inline TObjArray * AliPHOSLoader::CpvRecPoints()
296 {
297  return dynamic_cast<TObjArray*>(GetDetectorData(fgkCpvRecPointsName));
298 }
299 /******************************************************************************/
300
301 inline const AliPHOSCpvRecPoint * AliPHOSLoader::CpvRecPoint(Int_t index)
302 {
303   TObjArray* tcarr = CpvRecPoints();
304   if (tcarr)
305     return (const AliPHOSCpvRecPoint*) tcarr->At(index);
306   return 0x0; 
307 }
308 /******************************************************************************/
309
310 inline TClonesArray * AliPHOSLoader::TrackSegments()
311 {
312  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkTracksName));
313 }
314 /******************************************************************************/
315
316 inline const AliPHOSTrackSegment * AliPHOSLoader::TrackSegment(Int_t index)
317 {
318   const TClonesArray* tcarr = TrackSegments();
319   if (tcarr)
320     return (const AliPHOSTrackSegment*) tcarr->At(index);
321   return 0x0; 
322 }
323 /******************************************************************************/
324
325 inline TClonesArray * AliPHOSLoader::RecParticles() 
326 {
327  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkRecParticlesName)); 
328 }
329 /******************************************************************************/
330
331 inline const AliPHOSRecParticle* AliPHOSLoader::RecParticle(Int_t index)
332 {
333   TClonesArray* tcarr = RecParticles();
334   if (tcarr)
335     return (const AliPHOSRecParticle*) tcarr->At(index);
336   return 0x0;  
337 }
338
339 #endif // AliPHOSLOADER_H