]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/PHOSbase/AliPHOSLoader.h
Integrate CPV to AliReconstruction
[u/mrichter/AliRoot.git] / PHOS / PHOSbase / 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 class TString ;
35 class TParticle ;
36 #include <TClonesArray.h>
37 #include <TTree.h>
38
39 // --- Standard library ---
40
41 // --- AliRoot header files ---
42 #include "AliRun.h"
43 #include "AliLoader.h"
44 #include "AliRunLoader.h"
45 #include "AliPHOSClusterizer.h"
46 #include "AliPHOSTrackSegmentMaker.h"
47 #include "AliPHOSPID.h"
48 class AliPHOS ; 
49 class AliPHOSHit ; 
50 class AliPHOSDigit ; 
51 class AliPHOSEmcRecPoint ; 
52 class AliPHOSCpvRecPoint ; 
53 class AliPHOSTrackSegment ;
54 class AliPHOSRecParticle ;  
55 class AliPHOSSDigitizer ; 
56 class AliPHOSDigitizer ;
57   
58 class AliPHOSLoader : public AliLoader {
59   
60 public:
61
62   AliPHOSLoader();
63   AliPHOSLoader(const Char_t *detname,const Char_t *eventfoldername); 
64   AliPHOSLoader(const Char_t *detname,TFolder *topfolder);
65   
66   virtual ~AliPHOSLoader() ; 
67
68   Int_t   GetEvent();//extends the method on PHOS RecPart posting
69   Int_t   SetEvent();//extends the method on PHOS RecPart posting
70   
71   Bool_t  BranchExists(const TString& recName);
72   Int_t   LoadHits(Option_t* opt=""); //reads  from disk and sends them to folder; array as well as tree
73   Int_t   LoadSDigits(Option_t* opt="");
74   Int_t   LoadDigits(Option_t* opt=""); //reads Digits from disk and sends them to folder; array as well as tree
75   Int_t   LoadRecPoints(Option_t* opt=""); //reads RecPoints from disk and sends them to folder; array as well as tree
76   Int_t   LoadTracks(Option_t* opt="");  //reads Tracks from disk and sends them to folder; array as well as tree
77   Int_t   LoadRecParticles(Option_t* opt="");
78    
79   Int_t   PostHits()const;  //Posts the 
80   Int_t   PostSDigits()const;
81   Int_t   PostDigits()const;
82   Int_t   PostRecPoints()const;
83   Int_t   PostTracks()const;
84   Int_t   PostRecParticles()const;
85   
86   void    CleanFolders();//cleans all the stuff loaded by this detector + calls AliLoader::Clean
87
88   void    CleanHits()const;
89   void    CleanSDigits()const;
90   void    CleanDigits()const;
91   void    CleanRecPoints()const;
92   void    CleanTracks()const;
93   void    CleanRecParticles();
94
95   
96 /*******************************************************************/
97 /*******************************************************************/
98 /*******************************************************************/
99
100   TObject** HitsRef(){return GetDetectorDataRef(Hits());}
101   TObject** SDigitsRef(){return GetDetectorDataRef(SDigits());}
102   TObject** DigitsRef(){return GetDetectorDataRef(Digits());}
103   TObject** EmcRecPointsRef(){return GetDetectorDataRef(EmcRecPoints());}
104   TObject** CpvRecPointsRef(){return GetDetectorDataRef(CpvRecPoints());}
105   TObject** TracksRef(){return GetDetectorDataRef(TrackSegments());}
106   TObject** RecParticlesRef(){return GetDetectorDataRef(RecParticles());}
107   TObject** AlarmsRef(){return GetDetectorDataRef(Alarms());}
108   void   Track(Int_t itrack) ;
109
110   static AliPHOSLoader* GetPHOSLoader(const  char* eventfoldername);
111
112   //Method to be used when digitizing under AliDigitizationInput, who opens all files etc.
113   Int_t  EventNumber()       { return (Int_t) GetRunLoader()->GetEventNumber();}
114   Int_t  MaxEvent()          { return (Int_t) GetRunLoader()->TreeE()->GetEntries();}
115
116 /*   const AliPHOS *         PHOS(); */
117   // Alarms
118   // TFolder * Alarms() const { return (TFolder*)(ReturnO("Alarms", 0)); }
119   TObjArray *  Alarms() {return 0x0;}  
120
121   /*********************************************/
122   /************    TClonesArrays     ***********/
123   /*********************************************/
124   /****   H i t s  ****/
125   TClonesArray*  Hits(void);
126   const AliPHOSHit*    Hit(Int_t index);
127   void MakeHitsArray();
128   /****   S D i g i t s  ****/ 
129   TClonesArray*  SDigits();
130   const AliPHOSDigit*  SDigit(Int_t index);
131   void MakeSDigitsArray();
132   /****  D i g i t s  ****/
133   TClonesArray*   Digits();
134   const AliPHOSDigit *  Digit(Int_t index);
135   void MakeDigitsArray();
136   /****  R e c P o i n t s  ****/
137   TObjArray * EmcRecPoints();
138   TObjArray * CpvRecPoints();
139   const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) ;
140   const AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) ;
141   void MakeRecPointsArray();
142   /****   T r a c k S e g m e n t s ****/
143   TClonesArray * TrackSegments();
144   const AliPHOSTrackSegment * TrackSegment(Int_t index);
145   void MakeTrackSegmentsArray();
146   /****  R e c P a r t ic l e s   ****/
147   TClonesArray * RecParticles() ;
148   const AliPHOSRecParticle * RecParticle(Int_t index);
149   void MakeRecParticlesArray();
150   
151   void   SetDebug(Int_t level) {fDebug = level;} // Set debug level
152   void   SetBranchTitle(const TString& btitle);
153
154   Int_t   GetDebug()                     const {return fDebug;      }
155   TString GetBranchTitle()               const {return fBranchTitle;}
156   
157 protected:
158   TString fBranchTitle;            //Title of the branch
159
160 private:
161
162   // assignement operator requested by coding convention, but not needed
163   AliPHOSLoader(const AliPHOSLoader &);                //Not implemented
164   AliPHOSLoader & operator = (const AliPHOSLoader & ); //Not implemented
165
166   Int_t ReadHits();
167   Int_t ReadDigits();
168   Int_t ReadSDigits();
169   Int_t ReadRecPoints();
170   Int_t ReadTracks();
171   Int_t ReadRecParticles();
172   
173   Int_t  fDebug ;             // Debug level
174   TClonesArray *fTmpHits;     //! Temporary array of hits per track
175
176   static const TString fgkHitsName;//Name for TClonesArray with hits from one event
177   static const TString fgkSDigitsName;//Name for TClonesArray 
178   static const TString fgkDigitsName;//Name for TClonesArray 
179   static const TString fgkEmcRecPointsName;//Name for TClonesArray 
180   static const TString fgkCpvRecPointsName;//Name for TClonesArray 
181   static const TString fgkTracksName;//Name for TClonesArray 
182   static const TString fgkRecParticlesName;//Name for TClonesArray
183
184   static const TString fgkEmcRecPointsBranchName;//Name for branch
185   static const TString fgkCpvRecPointsBranchName;//Name for branch
186   static const TString fgkTrackSegmentsBranchName;//Name for branch
187   static const TString fgkRecParticlesBranchName;//Name for branch
188   
189  
190   ClassDef(AliPHOSLoader,4)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
191
192 };
193
194 /******************************************************************************/
195 /****************    I N L I N E S     ****************************************/
196 /******************************************************************************/
197
198 inline TClonesArray* AliPHOSLoader::Hits()  
199 {
200  return (TClonesArray*)GetDetectorData(fgkHitsName);
201 }
202 /******************************************************************************/
203
204 inline const AliPHOSHit* AliPHOSLoader::Hit(Int_t index)  
205 {
206   const TClonesArray* tcarr = Hits();
207   if (tcarr)
208     return (const AliPHOSHit*) tcarr->At(index);
209   return 0x0; 
210 }
211 /******************************************************************************/
212
213 inline TClonesArray* AliPHOSLoader::SDigits()
214 {
215    return dynamic_cast<TClonesArray*>(GetDetectorData(fgkSDigitsName));
216 }
217 /******************************************************************************/
218
219 inline const AliPHOSDigit*  AliPHOSLoader::SDigit(Int_t index)
220 {
221   const TClonesArray* tcarr = SDigits();
222   if (tcarr)
223     return (const AliPHOSDigit*) tcarr->At(index);
224   return 0x0; 
225 }
226 /******************************************************************************/
227
228 inline TClonesArray* AliPHOSLoader::Digits()
229 {
230  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkDigitsName));
231 }
232 /******************************************************************************/
233
234 inline const AliPHOSDigit*  AliPHOSLoader::Digit(Int_t index)
235 {
236   const TClonesArray* tcarr = Digits();
237   if (tcarr)
238     return (const AliPHOSDigit*) tcarr->At(index);
239   return 0x0; 
240 }
241 /******************************************************************************/
242
243 inline TObjArray * AliPHOSLoader::EmcRecPoints()
244 {
245  return dynamic_cast<TObjArray*>(GetDetectorData(fgkEmcRecPointsName));
246 }
247 /******************************************************************************/
248
249 inline const AliPHOSEmcRecPoint * AliPHOSLoader::EmcRecPoint(Int_t index)
250 {
251   TObjArray* tcarr = EmcRecPoints();
252   if (tcarr)
253     return (const AliPHOSEmcRecPoint*) tcarr->At(index);
254   return 0x0; 
255 }
256 /******************************************************************************/
257
258 inline TObjArray * AliPHOSLoader::CpvRecPoints()
259 {
260  return dynamic_cast<TObjArray*>(GetDetectorData(fgkCpvRecPointsName));
261 }
262 /******************************************************************************/
263
264 inline const AliPHOSCpvRecPoint * AliPHOSLoader::CpvRecPoint(Int_t index)
265 {
266   TObjArray* tcarr = CpvRecPoints();
267   if (tcarr)
268     return (const AliPHOSCpvRecPoint*) tcarr->At(index);
269   return 0x0; 
270 }
271 /******************************************************************************/
272
273 inline TClonesArray * AliPHOSLoader::TrackSegments()
274 {
275  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkTracksName));
276 }
277 /******************************************************************************/
278
279 inline const AliPHOSTrackSegment * AliPHOSLoader::TrackSegment(Int_t index)
280 {
281   const TClonesArray* tcarr = TrackSegments();
282   if (tcarr)
283     return (const AliPHOSTrackSegment*) tcarr->At(index);
284   return 0x0; 
285 }
286 /******************************************************************************/
287
288 inline TClonesArray * AliPHOSLoader::RecParticles() 
289 {
290  return dynamic_cast<TClonesArray*>(GetDetectorData(fgkRecParticlesName)); 
291 }
292 /******************************************************************************/
293
294 inline const AliPHOSRecParticle* AliPHOSLoader::RecParticle(Int_t index)
295 {
296   TClonesArray* tcarr = RecParticles();
297   if (tcarr)
298     return (const AliPHOSRecParticle*) tcarr->At(index);
299   return 0x0;  
300 }
301
302 #endif // AliPHOSLOADER_H