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