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