Use log(E) dependence for energy loss if IHPR2(50) == 1.
[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 ;
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
4ae78bb1 54 cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
55 abort() ;
56 }
57 AliPHOSGetter(const AliPHOSGetter & obj) {
58 // cpy ctor requested by Coding Convention
59 // but not yet needed
60 abort() ;
61 }
62
d071065d 63 virtual ~AliPHOSGetter() ;
4ae78bb1 64
65549808 65 void CloseFile() ;
0c87da39 66 const TFolder * Folder(const TString what) const ;
6ad0e528 67 void ListBranches(Int_t event=0) const ;
68 void NewBranch(TString name, Int_t event = 0) ;
c6987a88 69 Bool_t NewFile(TString name) ;
dca3a7c4 70 const Bool_t HasFailed() const { return fFailed ; }
cb34a1fa 71 Bool_t PostPrimaries(void ) const ;
b0bba0af 72 Bool_t PostHits(void ) const ;
73 Bool_t PostSDigits( const char * name, const char * file = 0) const ;
74 Bool_t PostDigits( const char * name ) const ;
75 Bool_t PostRecPoints( const char * name ) const ;
76 Bool_t PostTrackSegments(const char * name) const ;
77 Bool_t PostRecParticles( const char * name) const ;
78
79 Bool_t PostClusterizer( const char * name) const ;
80 Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
81 Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
82 Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
83 Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
84 Bool_t PostDigitizer ( const char * name) const ;
85 Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
86 Bool_t PostTrackSegmentMaker(const char * name ) const ;
87 Bool_t PostPID (AliPHOSPID * pid) const ;
7a9d98f9 88 Bool_t PostPID (const char * name ) const ;
89 Bool_t PostQA (void) const ;
b0bba0af 90
91
9fbf3755 92 void Event(const Int_t event, const char * opt = "HSDRP") ;
b0bba0af 93 void Track(Int_t itrack) ;
94
95 //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
96 void ReadTreeS(TTree * treeS,Int_t input) ;
97
98 Int_t EventNumber() { return (Int_t) gAlice->GetEvNumber() ; }
99 Int_t MaxEvent() { return (Int_t) gAlice->TreeE()->GetEntries() ; }
4ae78bb1 100 static AliPHOSGetter * GetInstance(const char* headerFile,
b0bba0af 101 const char* branchTitle = "Default" ) ;
102 static AliPHOSGetter * GetInstance() ;
103
7a9d98f9 104 const AliPHOS * PHOS() ;
105 const AliPHOSGeometry * PHOSGeometry() ;
b0bba0af 106 // Alarms
7a9d98f9 107 TFolder * Alarms() const { return (TFolder*)(ReturnO("Alarms", 0)) ; }
108 TObjArray * Alarms(const char * name ) const { return (TObjArray*)(ReturnO("Alarms", name)) ; }
4ae78bb1 109
eb9763ac 110 // QA Tasks
111 TTask * QATasks(const char * name = 0) const { return (TTask*)(ReturnT("QATasks", name)) ; }
112
cb34a1fa 113 // Primaries
114 TClonesArray * Primaries(void) const { return (TClonesArray*)(ReturnO("Primaries")) ; }
4ae78bb1 115 // Hits
cb34a1fa 116 const TClonesArray * Hits(void) { return static_cast<const TClonesArray*>(ReturnO("Hits")) ; }
117 const AliPHOSHit * Hit(Int_t index) { return static_cast<const AliPHOSHit*>(Hits()->At(index) );}
118
4ae78bb1 119 // SDigits
cb34a1fa 120 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
121 return static_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ;
122 }
123 const AliPHOSDigit * SDigit(Int_t index) { return static_cast<const AliPHOSDigit*>(SDigits()->At(index)) ;}
124
125 AliPHOSSDigitizer * SDigitizer(const char * name =0) const {
126 return ((AliPHOSSDigitizer*)(ReturnT("SDigitizer", name))) ;
127 }
128
4ae78bb1 129 // Digits
cb34a1fa 130 TClonesArray * Digits(const char * name = 0)const {
131 return static_cast<TClonesArray*>(ReturnO("Digits", name)) ;
132 }
133 const AliPHOSDigit * Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;}
134 AliPHOSDigitizer * Digitizer(const char * name =0) const {
135 return (AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ;
136 }
137
4ae78bb1 138 // RecPoints
65c0665e 139 TObjArray * EmcRecPoints(const char * name = 0) {
cb34a1fa 140 return static_cast<TObjArray*>(ReturnO("EmcRecPoints", name)) ;
141 }
142 TObjArray * CpvRecPoints(const char * name = 0) {
143 return static_cast<TObjArray*>(ReturnO("CpvRecPoints", name)) ;
144 }
145 const AliPHOSEmcRecPoint * EmcRecPoint(Int_t index) {
146 return static_cast<const AliPHOSEmcRecPoint *>(EmcRecPoints()->At(index)) ;
147 }
148 const AliPHOSCpvRecPoint * CpvRecPoint(Int_t index) {
149 return static_cast<const AliPHOSCpvRecPoint *>(CpvRecPoints()->At(index)) ;
150 }
151
152 AliPHOSClusterizer * Clusterizer (const char * name =0) const {
153 return (AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ;
154 }
155
4ae78bb1 156 // TrackSegments
cb34a1fa 157 TClonesArray * TrackSegments(const char * name = 0) {
158 return static_cast<TClonesArray*>(ReturnO("TrackSegments", name)) ;
159 }
160 const AliPHOSTrackSegment * TrackSegment(Int_t index) {
161 return static_cast<const AliPHOSTrackSegment*>(TrackSegments()->At(index)) ;
162 }
163 AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
164 return (AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;
165 }
166
4ae78bb1 167 // RecParticles
cb34a1fa 168 TClonesArray * RecParticles(const char * name = 0) {
169 return static_cast<TClonesArray*>(ReturnO("RecParticles", name)) ;
170 }
171 const AliPHOSRecParticle * RecParticle(Int_t index) {
172 return static_cast<const AliPHOSRecParticle*>(RecParticles()->At(index)) ;
173 }
174 AliPHOSPID * PID(const char * name =0) const {
175 return (AliPHOSPID*)(ReturnT("PID", name)) ;
176 }
177
4ae78bb1 178 // Primaries
179 const TParticle * Primary(Int_t index) const ;
180 const Int_t NPrimaries()const { return fNPrimaries; }
cb34a1fa 181 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
182
65549808 183 void RemoveTask(TString opt, TString name) const ;
184 void RemoveObjects(TString opt, TString name) const ;
185 void RemoveSDigits() const ;
b0bba0af 186 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
cb34a1fa 187
4ae78bb1 188 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
b0bba0af 189 // assignement operator requested by coding convention, but not needed
4ae78bb1 190 abort() ;
191 return *this ;
192 }
193
7a9d98f9 194 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ; }
5bf7ace9 195
196 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
cb34a1fa 197
198private:
199
b0bba0af 200 AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default") ;
cb34a1fa 201 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
4ae78bb1 202 const TTask * ReturnT(TString what,TString name=0) const ;
203 void DefineBranchTitles(char* branch, char* branchTitle) ;
ab3ecbea 204 Int_t ReadTreeD() ;
205 Int_t ReadTreeH() ;
5bf7ace9 206 Int_t ReadTreeR(Bool_t any=kFALSE) ;
ab3ecbea 207 Int_t ReadTreeS(Int_t event) ;
b0bba0af 208 void ReadTreeQA() ;
4ae78bb1 209 void ReadPrimaries() ;
210
65c0665e 211 TObject** PrimariesRef(void) const ;
212 TObject** HitsRef(void) const ;
213 TObject** SDigitsRef(const char * name, const char * file = 0 ) const;
214 TObject** DigitsRef (const char * name) const ;
215 TObject** EmcRecPointsRef (const char * name) const ;
216 TObject** CpvRecPointsRef (const char * name) const ;
217 TObject** TrackSegmentsRef(const char * name) const ;
218 TObject** RecParticlesRef (const char * name) const ;
219 TObject** AlarmsRef (void) const ;
220
221 TObject** SDigitizerRef (const char * name) const ;
222 TObject** DigitizerRef (const char * name) const ;
223 TObject** ClusterizerRef(const char * name) const ;
224 TObject** TSMakerRef (const char * name) const ;
225 TObject** PIDRef (const char * name) const ;
b0bba0af 226
4ae78bb1 227 private:
228
59b46416 229 static TFile * fFile; //!
b0bba0af 230 TString fHeaderFile ; //! File in which gAlice lives
231 TString fBranchTitle ; //!
232 TString fTrackSegmentsTitle ;//!
233 TString fRecPointsTitle ; //!
234 TString fRecParticlesTitle ; //!
59b46416 235 TString fDigitsTitle ; //! TDirectory tempo(gDirectory) ;
236
b0bba0af 237 TString fSDigitsTitle ; //!
4ae78bb1 238
dca3a7c4 239 Bool_t fFailed ; //! set if file not opend or galice not found
b0bba0af 240 Int_t fDebug ; // Debug level
518b8b75 241
b0bba0af 242 Int_t fNPrimaries ; //! # of primaries
4ae78bb1 243
b0bba0af 244 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
4ae78bb1 245
7a9d98f9 246 TFolder * fModuleFolder ; //!Folder that contains the modules
cb34a1fa 247 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
7a9d98f9 248 TFolder * fHitsFolder ; //!Folder that contains the Hits
249 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
250 TFolder * fDigitsFolder ; //!Folder that contains the Digits
251 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
252 TFolder * fQAFolder ; //!Folder that contains the QA objects
253 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
254
b0bba0af 255 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
4ae78bb1 256
257 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
258
259};
260
261#endif // AliPHOSGETTER_H