1 #ifndef ALIEMCALGETTER_H
3 #define ALIEMCALGETTER_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
15 //_________________________________________________________________________
17 // A singleton that returns various objects
19 // Should be used on the analysis stage to avoid confusing between different
21 // branches of reconstruction tree: e.g. reading RecPoints and TS made from
23 // another set of RecPoints.
27 // The objects are retrived from folders.
29 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
37 // August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
39 // of new IO (à la PHOS)
43 // --- ROOT system ---
45 #include "TClonesArray.h"
61 // --- Standard library ---
65 #include <Riostream.h>
69 // --- AliRoot header files ---
77 #include "AliEMCALHit.h"
79 #include "AliEMCALDigit.h"
81 #include "AliEMCALTowerRecPoint.h"
83 //class AliEMCALTrackSegment ;
85 //class AliEMCALRecParticle ;
87 class AliEMCALGeometry ;
89 #include "AliEMCALDigitizer.h"
91 #include "AliEMCALSDigitizer.h"
93 class AliEMCALClusterizer ;
95 //class AliEMCALTrackSegmentMaker ;
101 class AliEMCALGetter : public TObject {
109 AliEMCALGetter(){ // ctor: this is a singleton, the ctor should never be called but cint needs it as public
111 cerr << "ERROR: AliEMCALGetter is a singleton default ctor not callable" << endl ;
117 AliEMCALGetter(const AliEMCALGetter & obj) {
119 // cpy ctor requested by Coding Convention
121 // but not yet needed
129 AliEMCALGetter & operator = (const AliEMCALGetter & ) {
131 // assignement operator requested by coding convention, but not needed
139 virtual ~AliEMCALGetter() ;
143 //=========== Instantiators ================
145 static AliEMCALGetter * GetInstance(const char* headerFile,
147 const char* branchTitle = "Default",
149 const Bool_t toSplit = kFALSE ) ;
151 static AliEMCALGetter * GetInstance() ;
155 //=========== General information about run ==============
157 const Int_t MaxEvent() const { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
159 const Int_t EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
161 const Bool_t BranchExists(const TString recName) const ;
165 //========== EMCALGeometry and EMCAL =============
167 const AliEMCAL * EMCAL() ;
169 AliEMCALGeometry * EMCALGeometry() ;
173 //========== Methods to read something from file ==========
175 void Event(const Int_t event, const char * opt = "HSDRP") ;
177 void Track(const Int_t itrack) ;
179 void ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when
181 //digitizing is under the conytrol of AliRunDigitizer,
183 //which opens all files etc.
185 //========== Alarms ======================
187 //TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
189 //const TObjArray * Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
191 //const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
195 //-----------------now getter's data--------------------------------------
199 //=========== Primaries ============
201 TTree * TreeK(TString filename="") ;
203 TClonesArray * Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
205 const TParticle * Primary(Int_t index) const;
207 const Int_t NPrimaries()const { return fNPrimaries; }
209 const TParticle * Secondary(TParticle * p, Int_t index=1) const ;
213 //=========== Hits =================
215 TTree * TreeH(TString filename="") ;
217 const TClonesArray * Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
219 const AliEMCALHit * Hit(Int_t index) { return dynamic_cast<const AliEMCALHit*>(Hits()->At(index) );}
223 //=========== SDigits ==============
225 TTree * TreeS(TString filename="") ;
227 TClonesArray * SDigits(const char * name = 0, const char * file=0) {
229 return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
231 const AliEMCALDigit * SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
233 const AliEMCALSDigitizer * SDigitizer(const char * name =0) const {
235 return (const AliEMCALSDigitizer*)(ReturnT("SDigitizer", name)) ; // here static or dynamic cast does not work ! why ?
241 //========== Digits ================
243 TTree * TreeD(TString filename="") ;
245 TClonesArray * Digits(const char * name = 0)const {
247 return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
249 const AliEMCALDigit * Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
251 const AliEMCALDigitizer * Digitizer(const char * name =0) const {
253 return (const AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
257 //========== RecPoints =============
259 TObjArray * TowerRecPoints(const char * name = 0) const {
261 return (dynamic_cast<TObjArray*>(ReturnO("TowerRecPoints", name))) ; }
263 const AliEMCALTowerRecPoint * TowerRecPoint(Int_t index) { return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
265 TObjArray * PreShowerRecPoints(const char * name = 0) const {
267 return (dynamic_cast<TObjArray*>(ReturnO("PreShowerRecPoints", name))) ; }
269 const AliEMCALClusterizer * Clusterizer (const char * name =0) const {
271 return (const AliEMCALClusterizer*)(ReturnT("Clusterizer", name)) ;// here static or dynamic cast does not work ! why ?
277 //========== TrackSegments ==========
279 //TClonesArray * TrackSegments(const char * name = 0) const {
281 // return (dynamic_cast<TClonesArray*>(ReturnO("TrackSegments", name))) ; }
283 //const AliEMCALTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
285 // return (const AliEMCALTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;// here static or dynamic cast does not work ! why }
289 //========== RecParticles ===========
291 //TClonesArray * RecParticles(const char * name = 0) const {
293 // return (dynamic_cast<TClonesArray*>(ReturnO("RecParticles", name))) ; }
295 //const AliEMCALPID * PID(const char * name =0) const {
297 // return (const AliEMCALPID*)(ReturnT("PID", name)) ;// here static or dynamic cast does not work ! why }
301 //-----------------Auxiliary methods: cleaners-----------------
303 void RemoveTask(TString opt, TString name) const ;
305 void RemoveObjects(TString opt, TString name) const ;
307 void RemoveSDigits() const ;
311 //-----------------Auxiliary methods: miscellana-----------------
315 const TFolder * Folder(const TString what) const ;
317 const Bool_t HasFailed(void) const {return fFailed ;}
319 void ListBranches(Int_t event=0) const ;
321 void NewBranch(TString name, Int_t event = 0) ;
323 Bool_t NewFile(TString name) ;
325 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
327 void SetDebug(Int_t level) {fDebug = level;} // Set debug level
329 void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
333 //------------Auxiliary methods: Posters--------------------
335 const Bool_t PostPrimaries(void ) const ;
337 const Bool_t PostHits(void ) const ;
339 const Bool_t PostSDigits( const char * name, const char * file = 0) const ;
341 const Bool_t PostDigits( const char * name ) const ;
343 const Bool_t PostRecPoints( const char * name ) const ;
345 //const Bool_t PostTrackSegments(const char * name) const ;
347 //const Bool_t PostRecParticles( const char * name) const ;
349 const Bool_t PostClusterizer( const char * name) const ;
351 const Bool_t PostClusterizer(AliEMCALClusterizer * clu) const ;
353 const Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;
355 const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
357 const Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;
359 const Bool_t PostDigitizer ( const char * name) const ;
361 //const Bool_t PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsm) const ;
363 //const Bool_t PostTrackSegmentMaker(const char * name ) const ;
365 //const Bool_t PostPID (AliEMCALPID * pid) const ;
367 //const Bool_t PostPID (const char * name ) const ;
369 //const Bool_t PostQA (void) const ;
377 AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ;
379 TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
381 const TTask * ReturnT(TString what,TString name=0) const ;
383 void DefineBranchTitles(char* branch, char* branchTitle) ;
385 Int_t ReadTreeD(const Int_t event) ;
387 Int_t ReadTreeH(void) ;
389 Int_t ReadTreeR(const Int_t event) ;
391 Int_t ReadTreeS(const Int_t event) ;
393 void ReadTreeQA(void) ;
395 void ReadPrimaries(void) ;
397 void CleanWhiteBoard(void) ;
399 void CloseSplitFiles(void) ;
401 void SetTitle(const char * title) ;
405 TObject ** PrimariesRef(void) const ;
407 TObject ** HitsRef(void) const ;
409 TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
411 TObject ** DigitsRef (const char * name) const ;
413 TObject ** TowerRecPointsRef (const char * name) const ;
415 TObject ** PreShowerRecPointsRef (const char * name) const ;
417 //TObject ** TrackSegmentsRef(const char * name) const ;
419 //TObject ** RecParticlesRef (const char * name) const ;
421 //TObject ** AlarmsRef (void) const ;
425 TObject ** SDigitizerRef (const char * name) const ;
427 TObject ** DigitizerRef (const char * name) const ;
429 TObject ** ClusterizerRef(const char * name) const ;
431 //TObject ** TSMakerRef (const char * name) const ;
433 //TObject ** PIDRef (const char * name) const ;
441 static TFile * fFile ; //!
443 Bool_t fToSplit ; //! Do we work in the split mode
445 TString fHeaderFile ; //! File in which gAlice lives
447 TString fBranchTitle ; //!
449 TString fTrackSegmentsTitle ;//!
451 TString fTrackSegmentsFileName ;//!
453 TString fRecPointsTitle ; //!
455 TString fRecPointsFileName ; //!
457 TString fRecParticlesTitle ; //!
459 TString fRecParticlesFileName ; //!
461 TString fDigitsTitle ; //!TDirectory tempo(gDirectory)
463 TString fDigitsFileName ; //! TDirectory tempo(gDirectory)
465 TString fSDigitsTitle ; //!
467 TString fSDigitsFileName ; //!
469 Bool_t fFailed ; //! true if file is not opened and/or galice not found
471 Int_t fDebug ; // Debug level
473 Int_t fNPrimaries ; //! # of primaries
475 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
477 TFolder * fModuleFolder ; //!Folder that contains the modules
479 TFolder * fPrimariesFolder ; //!Folder that contains the Primary Particles
481 TFolder * fHitsFolder ; //!Folder that contains the Hits
483 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
485 TFolder * fDigitsFolder ; //!Folder that contains the Digits
487 TFolder * fRecoFolder ; //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles)
489 TFolder * fQAFolder ; //!Folder that contains the QA objects
491 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
495 static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
499 ClassDef(AliEMCALGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
507 #endif // AliEMCALGETTER_H