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