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