Option to open the stream in READ or UPDATE mode
[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"
21#include <stdlib.h>
22#include <iostream.h>
23
518b8b75 24#include <TTree.h>
4ae78bb1 25class TString ;
26class TParticle ;
27class TTask ;
ef5b46d2 28class TFolder ;
4ae78bb1 29
30// --- Standard library ---
31
32// --- AliRoot header files ---
33
518b8b75 34#include <AliRun.h>
4ae78bb1 35class AliPHOS ;
36class AliPHOSGeometry ;
37class AliPHOSHit ;
38class AliPHOSDigit ;
39class AliPHOSDigitizer ;
40class AliPHOSSDigitizer ;
41class AliPHOSEmcRecPoint ;
b0bba0af 42class AliPHOSCpvRecPoint ;
4ae78bb1 43class AliPHOSClusterizer ;
44class AliPHOSTrackSegment ;
45class AliPHOSTrackSegmentMaker ;
46class AliPHOSRecParticle ;
47class AliPHOSPID ;
48
49class AliPHOSGetter : public TObject {
50
51 public:
52
53 AliPHOSGetter(){
54 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
55 cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
56 abort() ;
57 }
58 AliPHOSGetter(const AliPHOSGetter & obj) {
59 // cpy ctor requested by Coding Convention
60 // but not yet needed
61 abort() ;
62 }
63
d071065d 64 virtual ~AliPHOSGetter() ;
4ae78bb1 65
b0bba0af 66 Bool_t PostGeometry( void ) const ;
67 Bool_t PostHits(void ) const ;
68 Bool_t PostSDigits( const char * name, const char * file = 0) const ;
69 Bool_t PostDigits( const char * name ) const ;
70 Bool_t PostRecPoints( const char * name ) const ;
71 Bool_t PostTrackSegments(const char * name) const ;
72 Bool_t PostRecParticles( const char * name) const ;
73
74 Bool_t PostClusterizer( const char * name) const ;
75 Bool_t PostClusterizer(AliPHOSClusterizer * clu) const ;
76 Bool_t PostSDigitizer (AliPHOSSDigitizer * sdigitizer) const ;
77 Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
78 Bool_t PostDigitizer (AliPHOSDigitizer * digitizer) const ;
79 Bool_t PostDigitizer ( const char * name) const ;
80 Bool_t PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsm) const ;
81 Bool_t PostTrackSegmentMaker(const char * name ) const ;
82 Bool_t PostPID (AliPHOSPID * pid) const ;
83 Bool_t PostPID ( const char * name ) const ;
84 Bool_t PostQA ( const char * headerFile ) const ;
85
86
87 void Event(const Int_t event, const char * opt = "HSDRQ") ;
88 void Track(Int_t itrack) ;
89
90 //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
91 void ReadTreeS(TTree * treeS,Int_t input) ;
92
93 Int_t EventNumber() { return (Int_t) gAlice->GetEvNumber() ; }
94 Int_t MaxEvent() { return (Int_t) gAlice->TreeE()->GetEntries() ; }
4ae78bb1 95 static AliPHOSGetter * GetInstance(const char* headerFile,
b0bba0af 96 const char* branchTitle = "Default" ) ;
97 static AliPHOSGetter * GetInstance() ;
98
99 const AliPHOS * PHOS() const ;
100 const AliPHOSGeometry * PHOSGeometry() const ;
101 // Alarms
4ae78bb1 102 TFolder * Alarms(const char * name = 0) const { return (TFolder*)(ReturnO("Alarms", name)) ; }
103
eb9763ac 104 // QA Tasks
105 TTask * QATasks(const char * name = 0) const { return (TTask*)(ReturnT("QATasks", name)) ; }
106
4ae78bb1 107 // Hits
b0bba0af 108 TClonesArray * Hits(void) const { return (TClonesArray*)(ReturnO("Hits")) ; }
109
4ae78bb1 110 // SDigits
b0bba0af 111 TClonesArray * SDigits(const char * name = 0, const char * file=0) const
112 { return (TClonesArray*)(ReturnO("SDigits", name, file)) ; }
113
114 AliPHOSSDigitizer * SDigitizer(const char * name =0) const
115 { return ((AliPHOSSDigitizer*)(ReturnT("SDigitizer", name))) ; }
116
4ae78bb1 117 // Digits
b0bba0af 118 TClonesArray * Digits(const char * name = 0) const
119 { return (TClonesArray*)(ReturnO("Digits", name)) ; }
120 AliPHOSDigitizer * Digitizer(const char * name =0) const
121 { return (AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ; }
122
4ae78bb1 123 // RecPoints
b0bba0af 124 TObjArray * EmcRecPoints(const char * name = 0) const {
125 return (TObjArray*)(ReturnO("EmcRecPoints", name)) ; }
126 TObjArray * CpvRecPoints(const char * name = 0) const {
127 return (TObjArray*)(ReturnO("CpvRecPoints", name)) ; }
128
4ae78bb1 129 AliPHOSClusterizer * Clusterizer (const char * name =0) const
b0bba0af 130 { return (AliPHOSClusterizer*)(ReturnT("Clusterizer", name)) ; }
131
4ae78bb1 132 // TrackSegments
b0bba0af 133 TClonesArray * TrackSegments(const char * name = 0) const
134 { return (TClonesArray*)(ReturnO("TrackSegments", name)) ; }
4ae78bb1 135 AliPHOSTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const
b0bba0af 136 { return (AliPHOSTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ; }
137
4ae78bb1 138 // RecParticles
b0bba0af 139 TClonesArray * RecParticles(const char * name = 0) const
140 { return (TClonesArray*)(ReturnO("RecParticles", name)) ; }
141 AliPHOSPID * PID(const char * name =0) const
142 { return (AliPHOSPID*)(ReturnT("PID", name)) ; }
143
4ae78bb1 144 // Primaries
145 const TParticle * Primary(Int_t index) const ;
146 const Int_t NPrimaries()const { return fNPrimaries; }
147
b0bba0af 148 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
4ae78bb1 149
150 AliPHOSGetter & operator = (const AliPHOSGetter & ) {
b0bba0af 151 // assignement operator requested by coding convention, but not needed
4ae78bb1 152 abort() ;
153 return *this ;
154 }
155
156 private:
157
b0bba0af 158 AliPHOSGetter(const char* headerFile, const char* branchTitle ="Default") ;
4ae78bb1 159 void CreateWhiteBoard() const ;
160 const TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
161 const TTask * ReturnT(TString what,TString name=0) const ;
162 void DefineBranchTitles(char* branch, char* branchTitle) ;
163 void ReadTreeD() ;
164 void ReadTreeH() ;
4ae78bb1 165 void ReadTreeR() ;
b0bba0af 166 void ReadTreeS(Int_t event) ;
167 void ReadTreeQA() ;
4ae78bb1 168 void ReadPrimaries() ;
169
b0bba0af 170 TClonesArray ** HitsRef(void) const ;
171 TClonesArray ** SDigitsRef(const char * name, const char * file = 0 ) const;
172 TClonesArray ** DigitsRef (const char * name) const ;
173 TObjArray ** EmcRecPointsRef (const char * name) const ;
174 TObjArray ** CpvRecPointsRef (const char * name) const ;
175 TClonesArray ** TrackSegmentsRef(const char * name) const ;
176 TClonesArray ** RecParticlesRef (const char * name) const ;
177
178 AliPHOSSDigitizer ** SDigitizerRef (const char * name) const ;
179 AliPHOSDigitizer ** DigitizerRef (const char * name) const ;
180 AliPHOSClusterizer ** ClusterizerRef(const char * name) const ;
181 AliPHOSTrackSegmentMaker ** TSMakerRef (const char * name) const ;
182 AliPHOSPID ** PIDRef (const char * name) const ;
183
4ae78bb1 184 private:
185
b0bba0af 186 TString fHeaderFile ; //! File in which gAlice lives
187 TString fBranchTitle ; //!
188 TString fTrackSegmentsTitle ;//!
189 TString fRecPointsTitle ; //!
190 TString fRecParticlesTitle ; //!
191 TString fDigitsTitle ; //!
192 TString fSDigitsTitle ; //!
4ae78bb1 193
b0bba0af 194 Int_t fDebug ; // Debug level
518b8b75 195
b0bba0af 196 Int_t fNPrimaries ; //! # of primaries
4ae78bb1 197
b0bba0af 198 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
4ae78bb1 199
b0bba0af 200 static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton
4ae78bb1 201
202 ClassDef(AliPHOSGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
203
204};
205
206#endif // AliPHOSGETTER_H