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