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