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