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