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