New detector numbering scheme (common for DAQ/HLT/Offline). All the subdetectors...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGetter.h
CommitLineData
4ae78bb1 1#ifndef ALIPHOSGETTER_H
2#define ALIPHOSGETTER_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 ---
88cb7938 20#include "TObject.h"
e957fea8 21class TParticle ;
22class TTree ;
45c1ce6f 23class TGraph ;
24class TF1 ;
4ae78bb1 25
26// --- Standard library ---
27
28// --- AliRoot header files ---
88cb7938 29#include "AliConfig.h"
e957fea8 30#include "AliPHOSLoader.h"
31#include "AliPHOSHit.h"
32#include "AliPHOSDigit.h"
33#include "AliPHOSEmcRecPoint.h"
34#include "AliPHOSCpvRecPoint.h"
35#include "AliPHOSTrackSegment.h"
36#include "AliPHOSRecParticle.h"
88cb7938 37#include "AliPHOSDigitizer.h"
e957fea8 38#include "AliPHOSSDigitizer.h"
7ca0684e 39#include "AliPHOSCalibData.h"
40
e957fea8 41class AliPHOS ;
42class AliPHOSGeometry ;
43class AliPHOSClusterizer ;
44class AliPHOSTrackSegmentMaker ;
45class AliPHOSPID ;
7bb289a7 46class AliPHOSBeamTestEvent ;
95635748 47class AliESD ;
3cf4f75f 48class AliRawReader ;
4ae78bb1 49
50class AliPHOSGetter : public TObject {
51
95635748 52public:
cb34a1fa 53 AliPHOSGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
f1611b7c 54 Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ;
4ae78bb1 55 }
66f895c8 56
57public:
a8c47ab6 58 AliPHOSGetter(const AliPHOSGetter & obj) : TObject(obj) {
4ae78bb1 59 // cpy ctor requested by Coding Convention
f1611b7c 60 Fatal("cpy ctor", "not implemented") ;
4ae78bb1 61 }
62
fbf811ec 63 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
64 // assignement operator requested by coding convention, but not needed
f1611b7c 65 Fatal("operator =", "not implemented") ;
fbf811ec 66 return *this ;
67 }
d071065d 68 virtual ~AliPHOSGetter() ;
548f0134 69
fbf811ec 70 //=========== Instantiators ================
88cb7938 71 static AliPHOSGetter * Instance(const char* headerFile,
e191bb57 72 const char* version = AliConfig::GetDefaultEventFolderName(),
88cb7938 73 Option_t * openingOption = "READ" ) ;
74 static AliPHOSGetter * Instance() ;
95635748 75
702ab87e 76 void Print(const Option_t *)const{}
88cb7938 77 static void Print() ;
548f0134 78
95635748 79 //=========== General information about run ==============
66f895c8 80 virtual Bool_t IsLoaded(TString tree) const { return fLoadingStatus.Contains(tree) ; }
81 virtual void SetLoaded(TString tree) { fLoadingStatus += tree ; }
95635748 82
66f895c8 83 virtual Int_t MaxEvent() const ;
84 virtual Int_t EventNumber() const ;
85 virtual Bool_t VersionExists(TString & opt) const ;
86 virtual UShort_t EventPattern(void) const ;
87 virtual Float_t BeamEnergy(void) const ;
b0bba0af 88
95635748 89 //========== PHOSGeometry and PHOS =============
66f895c8 90 virtual AliPHOS * PHOS() const ;
91 virtual AliPHOSGeometry * PHOSGeometry() const ;
548f0134 92
95635748 93 //========== Methods to read something from file ==========
66f895c8 94 virtual void Event(Int_t event, const char * opt = "HSDRTP") ;
3cf4f75f 95 void Event(AliRawReader *rawReader, const char * opt = "W") ;
66f895c8 96 virtual void Track(Int_t itrack) ;
97
548f0134 98
95635748 99 //-----------------now getter's data--------------------------------------
3b844b86 100 AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
101 void ReadCalibrationDB(const char * /*name*/, const char * /*filename*/){ ;}
102 void SetCalibrationDB(AliPHOSCalibrationDB * cdb) {fcdb = cdb ;}
95635748 103
a0c6611f 104 void SetCalibData(AliPHOSCalibData* calibda) { fgCalibData = calibda; }
7ca0684e 105 AliPHOSCalibData * CalibData();
106
fbf811ec 107 //=========== Primaries ============
66f895c8 108 virtual TClonesArray * Primaries(void) ;
109 virtual TParticle * Primary(Int_t index) const ;
110 virtual Int_t NPrimaries()const { return fNPrimaries; }
111 virtual TParticle * Secondary(const TParticle * p, Int_t index=1) const ;
88cb7938 112
95635748 113 //=========== Hits =================
a0c6611f 114 virtual TClonesArray * Hits(void) const ;
fd31ff92 115 virtual AliPHOSHit * Hit(Int_t index) const { return dynamic_cast<AliPHOSHit*>(Hits()->At(index) );}
66f895c8 116 virtual TTree * TreeH() const ;
cb34a1fa 117
fbf811ec 118 //=========== SDigits ==============
a0c6611f 119 virtual TClonesArray * SDigits() const ;
fd31ff92 120 virtual AliPHOSDigit * SDigit(Int_t index) const { return static_cast<AliPHOSDigit *>(SDigits()->At(index)) ;}
66f895c8 121 virtual TTree * TreeS() const ;
122 virtual AliPHOSSDigitizer * SDigitizer() ;
123
124 virtual TString GetSDigitsFileName() const { return PhosLoader()->GetSDigitsFileName() ; }
125 virtual Int_t LoadSDigits(Option_t* opt="") const { return PhosLoader()->LoadSDigits(opt) ; }
126 virtual Int_t LoadSDigitizer(Option_t* opt="") const { return PhosLoader()->LoadSDigitizer(opt) ; }
127 virtual Int_t WriteSDigits(Option_t* opt="") const { return PhosLoader()->WriteSDigits(opt) ; }
128 virtual Int_t WriteSDigitizer(Option_t* opt="") const {
88cb7938 129 return PhosLoader()->WriteSDigitizer(opt) ; }
548f0134 130
fbf811ec 131 //========== Digits ================
a0c6611f 132 virtual TClonesArray * Digits() const ;
fd31ff92 133 virtual AliPHOSDigit * Digit(Int_t index) const { return static_cast<AliPHOSDigit *>(Digits()->At(index)) ;}
66f895c8 134 virtual TTree * TreeD() const ;
135 virtual AliPHOSDigitizer * Digitizer() ;
136 virtual TString GetDigitsFileName() const { return PhosLoader()->GetDigitsFileName() ; }
137 virtual Int_t LoadDigits(Option_t* opt="") const { return PhosLoader()->LoadDigits(opt) ; }
138 virtual Int_t LoadDigitizer(Option_t* opt="") const {
88cb7938 139 return PhosLoader()->LoadDigitizer(opt) ; }
66f895c8 140 virtual Int_t WriteDigits(Option_t* opt="") const { return PhosLoader()->WriteDigits(opt) ; }
141 virtual Int_t WriteDigitizer(Option_t* opt="") const {
88cb7938 142 return PhosLoader()->WriteDigitizer(opt) ; }
66f895c8 143
144 //Methods to distinguish raw and simulated digits
145 virtual Bool_t IsRawDigits(void) const {return fRawDigits;}
146 virtual void SetRawDigits(Bool_t isRaw = kTRUE){fRawDigits = isRaw;}
cb34a1fa 147
fbf811ec 148 //========== RecPoints =============
a0c6611f 149 virtual TObjArray * EmcRecPoints() const;
fd31ff92 150 virtual AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) const { return static_cast<AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;}
a0c6611f 151 virtual TObjArray * CpvRecPoints() const ;
fd31ff92 152 virtual AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) const { return static_cast<AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;}
66f895c8 153 virtual TTree * TreeR() const ;
154 virtual AliPHOSClusterizer * Clusterizer() ;
155 virtual TString GetRecPointsFileName() const { return PhosLoader()->GetRecPointsFileName() ; }
156 virtual Int_t LoadRecPoints(Option_t* opt="") const { return PhosLoader()->LoadRecPoints(opt) ; }
157 virtual Int_t LoadClusterizer(Option_t* opt="") const {
88cb7938 158 return PhosLoader()->LoadClusterizer(opt) ; }
66f895c8 159 virtual Int_t WriteRecPoints(Option_t* opt="") const { return PhosLoader()->WriteRecPoints(opt) ; }
160 virtual Int_t WriteClusterizer(Option_t* opt="") const {
88cb7938 161 return PhosLoader()->WriteClusterizer(opt) ; }
95635748 162
88cb7938 163 //========== TrackSegments TClonesArray * TrackSegments(const char * name = 0) {
a0c6611f 164 virtual TClonesArray * TrackSegments() const;
fd31ff92 165 virtual AliPHOSTrackSegment * TrackSegment(Int_t index) const { return static_cast<AliPHOSTrackSegment *>(TrackSegments()->At(index)) ;}
66f895c8 166 virtual TTree * TreeT() const ;
167 virtual AliPHOSTrackSegmentMaker * TrackSegmentMaker() ;
168 virtual TString GetTracksFileName() const { return PhosLoader()->GetTracksFileName() ; }
169 virtual Int_t LoadTracks(Option_t* opt="") const { return PhosLoader()->LoadTracks(opt) ; }
170 virtual Int_t LoadTrackSegementMaker(Option_t* opt="") const {
88cb7938 171 return PhosLoader()->LoadTrackSegmentMaker(opt) ; }
66f895c8 172 virtual Int_t WriteTracks(Option_t* opt="") const { return PhosLoader()->WriteTracks(opt) ; }
173 virtual Int_t WriteTrackSegmentMaker(Option_t* opt="") const {
88cb7938 174 return PhosLoader()->WriteTracker(opt) ; }
95635748 175
fbf811ec 176 //========== RecParticles ===========
a0c6611f 177 virtual TClonesArray * RecParticles() const;
fd31ff92 178 virtual AliPHOSRecParticle * RecParticle(Int_t index) const { return static_cast<AliPHOSRecParticle *>(RecParticles()->At(index)) ;}
66f895c8 179 virtual TTree * TreeP() const ;
180 virtual AliPHOSPID * PID() ;
181 virtual TString GetRecParticlesFileName() const { return PhosLoader()->GetRecParticlesFileName() ; }
182 virtual Int_t LoadRecParticles(Option_t* opt="") const { return PhosLoader()->LoadRecParticles(opt) ; }
183 virtual Int_t LoadPID(Option_t* opt="") const {
88cb7938 184 return PhosLoader()->LoadPID(opt) ; }
66f895c8 185 virtual Int_t WriteRecParticles(Option_t* opt="") const { return PhosLoader()->WriteRecParticles(opt) ; }
186 virtual Int_t WritePID(Option_t* opt="") const {
88cb7938 187 return PhosLoader()->WritePID(opt) ; }
a43c51c3 188
189 //========== Raw ===========
3cf4f75f 190 virtual Int_t ReadRaw(AliRawReader *rawReader) ;
a43c51c3 191
3b844b86 192 void SetDebug(Int_t level) {fgDebug = level;} // Set debug level
66f895c8 193 virtual void PostClusterizer(AliPHOSClusterizer * clu)
88cb7938 194 const{PhosLoader()->PostClusterizer(clu) ; }
66f895c8 195 virtual void PostPID(AliPHOSPID * pid)
88cb7938 196 const{PhosLoader()->PostPID(pid) ; }
66f895c8 197 virtual void PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tr)
88cb7938 198 const{PhosLoader()->PostTrackSegmentMaker(tr) ; }
66f895c8 199 virtual void PostSDigitizer (AliPHOSSDigitizer * sdigitizer)
88cb7938 200 const {PhosLoader()->PostSDigitizer(sdigitizer);}
66f895c8 201 virtual void PostDigitizer (AliPHOSDigitizer * digitizer)
bf6adc12 202 const {PhosLoader()->PostDigitizer(digitizer);}
95635748 203
66f895c8 204 virtual TString Version() const { return PhosLoader()->GetTitle() ; }
205 virtual AliPHOSLoader * PhosLoader() const { return fgPhosLoader ; }
206 virtual void Reset() ;
88cb7938 207
66f895c8 208 virtual AliESD * ESD() const { return fESD ; }
95635748 209
a0c6611f 210protected :
211 AliPHOSGetter(Int_t /*i*/){ // special constructor for onflight
212
213 }
214protected:
215 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
216
217private:
218 AliPHOSGetter(const char* headerFile,
219 const char* version = AliConfig::GetDefaultEventFolderName(),
220 Option_t * openingOption = "READ") ;
cb34a1fa 221private:
222
fd31ff92 223 Int_t ReadTreeD(void) const ;
224 Int_t ReadTreeH(void) const ;
225 Int_t ReadTreeR(void) const ;
226 Int_t ReadTreeT(void) const ;
227 Int_t ReadTreeS(void) const ;
228 Int_t ReadTreeP(void) const ;
677c8a30 229
230 Int_t ReadTreeE(Int_t event) ;
231 Bool_t OpenESDFile() ;
fbf811ec 232 void ReadPrimaries(void) ;
e4d04cf1 233
a0c6611f 234 void FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const;
44ae287e 235
236 Int_t CalibrateRaw (Double_t energy, Int_t *relId);
e4d04cf1 237
88cb7938 238private:
95635748 239
7bb289a7 240 AliPHOSBeamTestEvent * fBTE ; //! Header if BeamTest Event
88cb7938 241 static Int_t fgDebug ; //! Debug level
95635748 242
88cb7938 243 TString fLoadingStatus ; //! tells which trees are loaded
244 Int_t fNPrimaries ; //! # of primaries
245 TClonesArray * fPrimaries ; //! list of lists of primaries
95635748 246 TFile * fESDFile ; //! ESD file
247 TString fESDFileName ; //! ESD File Name
677c8a30 248 AliESD * fESD ; //! ESD object
249 TTree * fESDTree ; //! ESD Tree
66f895c8 250
44ae287e 251 Bool_t fRawDigits ; //! true is raw data
677c8a30 252
fd31ff92 253 AliPHOSCalibrationDB * fcdb ; //! Calibration DB for beam test run 2004
254 static AliPHOSCalibData * fgCalibData; //! instance of AliPHOSCalibData
7ca0684e 255
e957fea8 256 static AliPHOSLoader * fgPhosLoader ; // the loader for the NewIO
88cb7938 257
258 enum EDataTypes{kHits,kSDigits,kDigits,kRecPoints,kTracks,kNDataTypes};
66f895c8 259
95635748 260
a0c6611f 261 ClassDef(AliPHOSGetter,2) // Algorithm class that provides methods to retrieve objects from a list knowing the index
95635748 262
263 };
4ae78bb1 264
265#endif // AliPHOSGETTER_H