This update is a step in the continuous development of EMCAL.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.h
CommitLineData
ffa6d63b 1#ifndef ALIEMCALGETTER_H
2#define ALIEMCALGETTER_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// At this stage the Getter class handles only Hits, Digits, and SDigits.
14// The objects are retrived from folders.
15//*-- Author: Sahal Yacoob (LBL)
16// based on : AliPHOSGetter
17
18
19// --- ROOT system ---
20#include "TClonesArray.h"
21#include "TFolder.h"
22#include "TTree.h"
23class TString ;
24class TParticle ;
25class TTask ;
26
27// --- Standard library ---
28#include <stdlib.h>
29#include <iostream.h>
30
31// --- AliRoot header files ---
32
33#include "AliRun.h"
34#include "AliEMCALv1.h"
35class AliEMCALGeometry ;
36class AliEMCALHit ;
37class AliEMCALDigit ;
38class AliEMCALDigitizer ;
39class AliEMCALSDigitizer ;
40
41class AliEMCALGetter : public TObject {
42
43 public:
44
45 AliEMCALGetter(){
46 // ctor: this is a singleton, the ctor should never be called but cint needs it as public
47 cerr << "ERROR: AliPHOGetter is a singleton default ctor not callable" << endl ;
48 abort() ;
49 }
50 AliEMCALGetter(const AliEMCALGetter & obj) {
51 // cpy ctor requested by Coding Convention
52 // but not yet needed
53 abort() ;
54 }
55
56 virtual ~AliEMCALGetter() ;
57
58 Bool_t PostHits(void ) const ;
59 Bool_t PostSDigits( const char * name, const char * file = 0) const ;
60 Bool_t PostDigits( const char * name ) const ;
61
62 Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;
63 Bool_t PostSDigitizer ( const char * name, const char * file ) const ;
64 Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;
65 Bool_t PostDigitizer ( const char * name) const ;
66
67
68 void Event(const Int_t event, const char * opt = "HSD") ;
69 void Track(Int_t itrack) ;
70
71 //Method to be used when digitizing under AliRunDigitizer, who opens all files etc.
72 void ReadTreeS(TTree * treeS,Int_t input) ;
73
74 Int_t EventNumber() { return (Int_t) gAlice->GetEvNumber() ; }
75 Int_t MaxEvent() { return (Int_t) gAlice->TreeE()->GetEntries() ; }
76 static AliEMCALGetter * GetInstance(const char* headerFile,
77 const char* branchTitle = "Default" ) ;
78 static AliEMCALGetter * GetInstance() ;
79
80 const AliEMCALv0 * EMCAL() ;
81 const AliEMCALGeometry * EMCALGeometry() ;
82
83 // Hits
84 TClonesArray * Hits(void) const { return (TClonesArray*)(ReturnO("Hits")) ; }
85
86 // SDigits
87 TClonesArray * SDigits(const char * name = 0, const char * file=0) const
88 { return (TClonesArray*)(ReturnO("SDigits", name, file)) ; }
89
90 AliEMCALSDigitizer * SDigitizer(const char * name =0) const
91 { return ((AliEMCALSDigitizer*)(ReturnT("SDigitizer", name))) ; }
92
93 // Digits
94 TClonesArray * Digits(const char * name = 0) const
95 { return (TClonesArray*)(ReturnO("Digits", name)) ; }
96 AliEMCALDigitizer * Digitizer(const char * name =0) const
97 { return (AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
98
99 // Primaries
100 const TParticle * Primary(Int_t index) const ;
101 const Int_t NPrimaries()const { return fNPrimaries; }
102
103
104 AliEMCALGetter & operator = (const AliEMCALGetter & ) {
105 // assignement operator requested by coding convention, but not needed
106 abort() ;
107 return *this ;
108 }
109
110 TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
111
112 private:
113
114 AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default") ;
115 void CreateWhiteBoard() const ;
116 const TObject * ReturnO(TString what, TString name=0, TString file=0) const ;
117 const TTask * ReturnT(TString what,TString name=0) const ;
118 void DefineBranchTitles(char* branch, char* branchTitle) ;
119 void ReadTreeD() ;
120 void ReadTreeH() ;
121 void ReadTreeS(Int_t event) ;
122 void ReadPrimaries() ;
123
124 void * HitsRef(void) const ;
125 void * SDigitsRef(const char * name, const char * file = 0 ) const;
126 void * DigitsRef (const char * name) const ;
127
128 void * SDigitizerRef (const char * name) const ;
129 void * DigitizerRef (const char * name) const ;
130
131 private:
132
133 TString fHeaderFile ; //! File in which gAlice lives
134 TString fBranchTitle ; //!
135 TString fDigitsTitle ; //!
136 TString fSDigitsTitle ; //!
137
138 Int_t fDebug ; // Debug level
139
140 Int_t fNPrimaries ; //! # of primaries
141
142 TObjArray * fPrimaries ; //! list of lists of primaries-for the case of mixing
143
144 TFolder * fHitsFolder ; //!Folder that contains the Hits
145 TFolder * fSDigitsFolder ; //!Folder that contains the SDigits
146 TFolder * fDigitsFolder ; //!Folder that contains the Digits
147 TFolder * fTasksFolder ; //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
148 TFolder * fModuleFolder ; //!
149 static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton
150
151 ClassDef(AliEMCALGetter,1) // Algorithm class that provides methods to retrieve objects from a list knowing the index
152
153};
154
155#endif // AliEMCALGETTER_H