Class to perform calibration with beam test
[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 ---
20#include "TClonesArray.h"
7a9d98f9 21#include "TFolder.h"
22#include "TTree.h"
68853e3a 23#include "TFile.h"
4ae78bb1 24class TString ;
25class TParticle ;
26class TTask ;
27
28// --- Standard library ---
f404725b 29#include <stdlib.h>
4ae78bb1 30
31// --- AliRoot header files ---
32
7a9d98f9 33#include "AliRun.h"
34#include "AliPHOS.h"
cb34a1fa 35#include "AliPHOSHit.h"
36#include "AliPHOSDigit.h"
37#include "AliPHOSEmcRecPoint.h"
38#include "AliPHOSCpvRecPoint.h"
39#include "AliPHOSTrackSegment.h"
40#include "AliPHOSRecParticle.h"
4ae78bb1 41class AliPHOSGeometry ;
4ae78bb1 42class AliPHOSDigitizer ;
43class AliPHOSSDigitizer ;
4ae78bb1 44class AliPHOSClusterizer ;
4ae78bb1 45class AliPHOSTrackSegmentMaker ;
4ae78bb1 46class AliPHOSPID ;
c2cd5471 47class AliPHOSCalibrationDB ;
4ae78bb1 48
49class AliPHOSGetter : public TObject {
50
51 public:
52
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 }
56 AliPHOSGetter(const AliPHOSGetter & obj) {
57 // cpy ctor requested by Coding Convention
58 // but not yet needed
f1611b7c 59 Fatal("cpy ctor", "not implemented") ;
4ae78bb1 60 }
61
fbf811ec 62 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
63 // assignement operator requested by coding convention, but not needed
f1611b7c 64 Fatal("operator =", "not implemented") ;
fbf811ec 65 return *this ;
66 }
d071065d 67 virtual ~AliPHOSGetter() ;
548f0134 68
fbf811ec 69 //=========== Instantiators ================
70 static AliPHOSGetter * GetInstance(const char* headerFile,
71 const char* branchTitle = "Default",
72 const Bool_t toSplit = kFALSE ) ;
73 static AliPHOSGetter * GetInstance() ;
548f0134 74
fbf811ec 75 //=========== General information about run ==============
76 const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
77 const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
78 const Bool_t BranchExists(const TString tree) const ;
b0bba0af 79
fbf811ec 80 //========== PHOSGeometry and PHOS =============
81 const AliPHOS * PHOS() ;
82 const AliPHOSGeometry * PHOSGeometry() ;
548f0134 83
fbf811ec 84 //========== Methods to read something from file ==========
85 void Event(const Int_t event, const char * opt = "HSDRP") ;
86 void Track(const Int_t itrack) ;
87 void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
c2cd5471 88 //digitizing is under the control ofAliRunDigizer,
fbf811ec 89 //which opens all files etc.
90 //========== Alarms ======================
91 TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
92 const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
93 const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
548f0134 94
fbf811ec 95 //-----------------now getter's data--------------------------------------
548f0134 96
fbf811ec 97 //=========== Primaries ============
98 TTree * TreeK(TString filename="") ;
99 TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
100 const TParticle * Primary(Int_t index) const ;
101 const Int_t NPrimaries()const { return fNPrimaries; }
102 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
548f0134 103
fbf811ec 104 //=========== Hits =================
9bd3caba 105 TTree * TreeH(TString filename="") ;
fbf811ec 106 const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
107 const AliPHOSHit * Hit(Int_t index) { return dynamic_cast<const AliPHOSHit*>(Hits()->At(index) );}
cb34a1fa 108
fbf811ec 109 //=========== SDigits ==============
110 TTree * TreeS(TString filename="") ;
111 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
112 return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
113 //const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit *>(SDigits()->At(index)) ;} !!! why no such method ?
114 const AliPHOSSDigitizer * SDigitizer(const char * name =0) const {
115 return (const AliPHOSSDigitizer *) ReturnT("SDigitizer", name) ; // here static or dynamic cast does not work ! why ?
cb34a1fa 116 }
548f0134 117
fbf811ec 118 //========== Digits ================
119 TTree * TreeD(TString filename="") ;
120 TClonesArray * Digits(const char * name = 0)const {
121 return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
548f0134 122 //const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
c2cd5471 123 const TTask * Digitizer(const char * name = 0) const {
124 return ReturnT("Digitizer", name) ; }
125 AliPHOSCalibrationDB * CalibrationDB(){return fcdb; }
126 void ReadCalibrationDB(const char * name, const char * filename) ;
cb34a1fa 127
fbf811ec 128 //========== RecPoints =============
fbf811ec 129 TObjArray * EmcRecPoints(const char * name = 0) {
130 return dynamic_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ; }
548f0134 131 //const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) { return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;} !!! why no such method ?
fbf811ec 132 TObjArray * CpvRecPoints(const char * name = 0) {
133 return dynamic_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ; }
fbf811ec 134 const AliPHOSClusterizer * Clusterizer (const char * name =0) const {
135 return (const AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; // here static or dynamic cast does not work ! why ?
548f0134 136 }
cb34a1fa 137
fbf811ec 138 //========== TrackSegments ==========
cb34a1fa 139 TClonesArray * TrackSegments(const char * name = 0) {
fbf811ec 140 return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ; }
141 const AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
142 return (const AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; }
cb34a1fa 143
fbf811ec 144 //========== RecParticles ===========
cb34a1fa 145 TClonesArray * RecParticles(const char * name = 0) {
fbf811ec 146 return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ; }
147 const AliPHOSPID * PID(const char * name =0) const {
548f0134 148 return (const AliPHOSPID*)(ReturnT("PID", name)) ; } // here static or dynamic cast does not work ! why ?
149
fbf811ec 150 //-----------------Auxiliary methods: cleaners-----------------
65549808 151 void RemoveTask(TString opt, TString name) const ;
152 void RemoveObjects(TString opt, TString name) const ;
fbf811ec 153 void RemoveSDigits() const ;
5bf7ace9 154
fbf811ec 155 //----------------Auxiliary methods: miscellana----------------
156 void CloseFile() ;
157 const TFolder * Folder(const TString what) const ;
158 const Bool_t HasFailed() const { return fFailed ; }
159 void ListBranches(Int_t event=0) const ;
160 void NewBranch(TString name, Int_t event = 0) ;
161 Bool_t NewFile(TString name) ;
162 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
163 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
5bf7ace9 164 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
cb34a1fa 165
fbf811ec 166 //------------Auxiliary methods: Posters--------------------
167 const Bool_t PostPrimaries(void ) const ;
168 const Bool_t PostHits(void ) const ;
169 const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
170 const Bool_t PostDigits( const char * name ) const ;
171 const Bool_t PostRecPoints( const char * name ) const ;
172 const Bool_t PostTrackSegments(const char * name) const ;
173 const Bool_t PostRecParticles( const char * name) const ;
174 const Bool_t PostClusterizer( const char * name) const ;
175 const Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
176 const Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
177 const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
178 const Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
179 const Bool_t PostDigitizer ( const char * name) const ;
180 const Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
181 const Bool_t PostTrackSegmentMaker(const char * name ) const ;
182 const Bool_t PostPID (AliPHOSPID * pid) const ;
183 const Bool_t PostPID (const char * name ) const ;
184 const Bool_t PostQA (void) const ;
185
cb34a1fa 186private:
187
fbf811ec 188 AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
cb34a1fa 189 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
4ae78bb1 190 const TTask * ReturnT(TString what,TString name=0) const ;
191 void DefineBranchTitles(char* branch, char* branchTitle) ;
fbf811ec 192 Int_t ReadTreeD(const Int_t event) ;
193 Int_t ReadTreeH(void) ;
194 Int_t ReadTreeR(const Int_t event) ;
195 Int_t ReadTreeS(const Int_t event) ;
196 void ReadTreeQA(void) ;
197 void ReadPrimaries(void) ;
198 void CleanWhiteBoard(void) ;
199 void CloseSplitFiles(void) ;
200 void SetTitle(const char * title) ;
4ae78bb1 201
65c0665e 202 TObject** PrimariesRef(void) const ;
203 TObject** HitsRef(void) const ;
204 TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
205 TObject** DigitsRef (const char * name) const ;
206 TObject** EmcRecPointsRef (const char * name) const ;
207 TObject** CpvRecPointsRef (const char * name) const ;
208 TObject** TrackSegmentsRef(const char * name) const ;
209 TObject** RecParticlesRef (const char * name) const ;
210 TObject** AlarmsRef (void) const ;
211
212 TObject** SDigitizerRef (const char * name) const ;
213 TObject** DigitizerRef (const char * name) const ;
214 TObject** ClusterizerRef(const char * name) const ;
215 TObject** TSMakerRef (const char * name) const ;
216 TObject** PIDRef (const char * name) const ;
b0bba0af 217
4ae78bb1 218 private:
219
fbf811ec 220 static TFile * fFile; //!
221 Bool_t fToSplit ; //! Do we work in the split mode
222 TString fHeaderFile ; //! File in which gAlice lives
223 TString fBranchTitle ; //!
224 TString fTrackSegmentsTitle ; //!
225 TString fTrackSegmentsFileName ;//!
226 TString fRecPointsTitle ; //!
227 TString fRecPointsFileName ; //!
228 TString fRecParticlesTitle ; //!
229 TString fRecParticlesFileName ; //!
230 TString fDigitsTitle ; //! TDirectory tempo(gDirectory)
231 TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
232 TString fSDigitsTitle ; //!
233 TString fSDigitsFileName ; //!
dca3a7c4 234 Bool_t fFailed ; //! set if file not opend or galice not found
fbf811ec 235 Int_t fDebug ; //! Debug level
c2cd5471 236 AliRun * fAlice ; //! needed to read TreeK if in an other file than fHeaderFile
fbf811ec 237 Int_t fNPrimaries ; //! # of primaries
b0bba0af 238 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
7a9d98f9 239 TFolder * fModuleFolder ; //!Folder that contains the modules
cb34a1fa 240 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
7a9d98f9 241 TFolder * fHitsFolder ; //!Folder that contains the Hits
242 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
243 TFolder * fDigitsFolder ; //!Folder that contains the Digits
244 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
245 TFolder * fQAFolder ; //!Folder that contains the QA objects
246 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
c2cd5471 247
248 AliPHOSCalibrationDB * fcdb ; //!
9bd3caba 249
b0bba0af 250 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
4ae78bb1 251
252 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
253
254};
255
256#endif // AliPHOSGETTER_H