]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.h
Introducing Riostream.h
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.h
1 #ifndef ALIEMCALGETTER_H
2
3 #define ALIEMCALGETTER_H
4
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6
7  * See cxx source for full Copyright notice                               */
8
9
10
11 /* $Id$ */
12
13
14
15 //_________________________________________________________________________
16
17 //  A singleton that returns various objects 
18
19 //  Should be used on the analysis stage to avoid confusing between different
20
21 //  branches of reconstruction tree: e.g. reading RecPoints and TS made from 
22
23 //  another set of RecPoints.
24
25 // 
26
27 //  The objects are retrived from folders.  
28
29 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
30
31 //    
32
33
34
35 // Modif: 
36
37 //  August 2002 Yves Schutz: clone PHOS as closely as possible and intoduction
38
39 //                           of new  IO (à la PHOS)
40
41  
42
43 // --- ROOT system ---
44
45 #include "TClonesArray.h"
46
47 #include "TFolder.h"  
48
49 #include "TTree.h"
50
51 #include "TFile.h"
52
53 class TString ;
54
55 class TParticle ;
56
57 class TTask ;
58
59
60
61 // --- Standard library ---
62
63 #include <stdlib.h>
64
65 #include <Riostream.h>
66
67
68
69 // --- AliRoot header files ---
70
71
72
73 #include "AliRun.h"
74
75 #include "AliEMCAL.h" 
76
77 #include "AliEMCALHit.h" 
78
79 #include "AliEMCALDigit.h" 
80
81 #include "AliEMCALTowerRecPoint.h"
82
83 //class AliEMCALTrackSegment ;
84
85 //class AliEMCALRecParticle ;
86
87 class AliEMCALGeometry ;
88
89 #include "AliEMCALDigitizer.h" 
90
91 #include "AliEMCALSDigitizer.h"
92
93 class AliEMCALClusterizer ;
94
95 //class AliEMCALTrackSegmentMaker ;
96
97 //class AliEMCALPID ;
98
99
100
101 class AliEMCALGetter : public TObject {
102
103   
104
105  public:
106
107   
108
109   AliEMCALGetter(){  // ctor: this is a singleton, the ctor should never be called but cint needs it as public
110
111     cerr << "ERROR: AliEMCALGetter is a singleton default ctor not callable" << endl ;
112
113     abort() ; 
114
115   } 
116
117   AliEMCALGetter(const AliEMCALGetter & obj) {
118
119     // cpy ctor requested by Coding Convention 
120
121     // but not yet needed
122
123     abort() ; 
124
125   } 
126
127   
128
129   AliEMCALGetter & operator = (const AliEMCALGetter & ) {
130
131     // assignement operator requested by coding convention, but not needed
132
133     abort() ;
134
135     return *this ; 
136
137   }
138
139   virtual ~AliEMCALGetter() ; 
140
141   
142
143   //=========== Instantiators ================  
144
145   static AliEMCALGetter * GetInstance(const char* headerFile,
146
147                                       const char* branchTitle = "Default", 
148
149                                       const Bool_t toSplit = kFALSE ) ; 
150
151   static AliEMCALGetter * GetInstance() ; 
152
153  
154
155   //=========== General information about run ============== 
156
157   const Int_t  MaxEvent() const    { return static_cast<Int_t>(gAlice->TreeE()->GetEntries()) ; }
158
159   const Int_t  EventNumber() const { return static_cast<Int_t>(gAlice->GetEvNumber()) ; }
160
161   const Bool_t BranchExists(const TString recName) const ;
162
163
164
165   //========== EMCALGeometry and EMCAL ============= 
166
167   const AliEMCAL *   EMCAL() ;  
168
169   AliEMCALGeometry * EMCALGeometry() ; 
170
171
172
173   //========== Methods to read something from file ==========
174
175   void   Event(const Int_t event, const char * opt = "HSDRP") ;    
176
177   void   Track(const Int_t itrack) ;
178
179   void   ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when 
180
181                                                 //digitizing is under the conytrol of AliRunDigitizer, 
182
183                                                 //which opens all files etc.
184
185   //========== Alarms ======================
186
187   //TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
188
189   //const TObjArray *  Alarms(const char * name ) const { return dynamic_cast<const TObjArray*>(ReturnO("Alarms", name)) ; }
190
191   //const TTask * QATasks(const char * name = 0) const { return ReturnT("QATasks", name) ; }
192
193
194
195   //-----------------now getter's data--------------------------------------
196
197
198
199   //=========== Primaries ============
200
201   TTree *           TreeK(TString filename="") ; 
202
203   TClonesArray *    Primaries(void) const { return dynamic_cast<TClonesArray*>(ReturnO("Primaries")) ; }
204
205   const TParticle * Primary(Int_t index) const;
206
207   const Int_t       NPrimaries()const { return fNPrimaries; }
208
209   const TParticle * Secondary(TParticle * p, Int_t index=1) const ;  
210
211  
212
213   //=========== Hits =================
214
215   TTree *               TreeH(TString filename="") ; 
216
217   const TClonesArray *  Hits(void) { return dynamic_cast<const TClonesArray*>(ReturnO("Hits")) ; }
218
219   const AliEMCALHit *   Hit(Int_t index) { return dynamic_cast<const AliEMCALHit*>(Hits()->At(index) );}
220
221
222
223   //=========== SDigits ==============
224
225   TTree *         TreeS(TString filename="") ; 
226
227   TClonesArray *  SDigits(const char * name = 0, const char * file=0) { 
228
229     return dynamic_cast<TClonesArray*>(ReturnO("SDigits", name, file)) ; }
230
231   const AliEMCALDigit *  SDigit(Int_t index) { return static_cast<const AliEMCALDigit*>(SDigits()->At(index)) ;}
232
233   const AliEMCALSDigitizer *  SDigitizer(const char * name =0) const { 
234
235     return (const AliEMCALSDigitizer*)(ReturnT("SDigitizer", name)) ; // here static or dynamic cast does not work ! why ?
236
237   }
238
239
240
241   //========== Digits ================
242
243   TTree *         TreeD(TString filename="") ; 
244
245   TClonesArray *  Digits(const char * name = 0)const  { 
246
247     return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ; }
248
249   const AliEMCALDigit *  Digit(Int_t index) { return static_cast<const AliEMCALDigit *>(Digits()->At(index)) ;}
250
251   const AliEMCALDigitizer *  Digitizer(const char * name =0) const { 
252
253     return (const AliEMCALDigitizer*)(ReturnT("Digitizer", name)) ; }
254
255       
256
257   //========== RecPoints =============
258
259   TObjArray * TowerRecPoints(const char * name = 0) const { 
260
261     return (dynamic_cast<TObjArray*>(ReturnO("TowerRecPoints", name))) ; }
262
263   const AliEMCALTowerRecPoint *  TowerRecPoint(Int_t index) { return static_cast<const AliEMCALTowerRecPoint *>(TowerRecPoints()->At(index)) ;}
264
265   TObjArray * PreShowerRecPoints(const char * name = 0) const { 
266
267     return (dynamic_cast<TObjArray*>(ReturnO("PreShowerRecPoints", name))) ; }
268
269   const AliEMCALClusterizer * Clusterizer (const char * name =0) const { 
270
271     return (const AliEMCALClusterizer*)(ReturnT("Clusterizer", name)) ;// here static or dynamic cast does not work ! why ?
272
273   }
274
275
276
277   //========== TrackSegments ==========
278
279   //TClonesArray * TrackSegments(const char * name = 0) const { 
280
281   // return (dynamic_cast<TClonesArray*>(ReturnO("TrackSegments", name))) ; }
282
283   //const AliEMCALTrackSegmentMaker * TrackSegmentMaker (const char * name =0) const {
284
285   // return (const AliEMCALTrackSegmentMaker*)(ReturnT("TrackSegmentMaker", name)) ;// here static or dynamic cast does not work ! why }
286
287
288
289   //========== RecParticles ===========
290
291   //TClonesArray * RecParticles(const char * name = 0) const { 
292
293   // return (dynamic_cast<TClonesArray*>(ReturnO("RecParticles", name))) ; }
294
295   //const AliEMCALPID * PID(const char * name =0) const {
296
297   // return (const AliEMCALPID*)(ReturnT("PID", name)) ;// here static or dynamic cast does not work ! why }
298
299
300
301   //-----------------Auxiliary methods: cleaners-----------------
302
303   void RemoveTask(TString opt, TString name) const ;
304
305   void RemoveObjects(TString opt, TString name) const ; 
306
307   void RemoveSDigits() const ; 
308
309
310
311  //-----------------Auxiliary methods: miscellana-----------------
312
313   void CloseFile() ;  
314
315   const TFolder * Folder(const TString what) const ;
316
317   const Bool_t HasFailed(void) const {return fFailed ;} 
318
319   void ListBranches(Int_t event=0) const ;
320
321   void NewBranch(TString name, Int_t event = 0) ; 
322
323   Bool_t NewFile(TString name) ;
324
325   TFolder * SDigitsFolder() { return dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ; }
326
327   void SetDebug(Int_t level) {fDebug = level;} // Set debug level
328
329   void SetRecParticlesTitle(const TString title) { fRecParticlesTitle = title ; }
330
331
332
333   //------------Auxiliary methods: Posters--------------------
334
335   const Bool_t PostPrimaries(void ) const ;  
336
337   const Bool_t PostHits(void ) const ;  
338
339   const Bool_t PostSDigits(      const char * name,  const char * file = 0) const ;  
340
341   const Bool_t PostDigits(       const char * name ) const ;  
342
343   const Bool_t PostRecPoints(    const char * name ) const ;  
344
345   //const Bool_t PostTrackSegments(const char * name) const ;  
346
347   //const Bool_t PostRecParticles( const char * name) const ;  
348
349   const Bool_t PostClusterizer( const char * name) const ;  
350
351   const Bool_t PostClusterizer(AliEMCALClusterizer * clu) const ;  
352
353   const Bool_t PostSDigitizer (AliEMCALSDigitizer * sdigitizer) const ;  
354
355   const Bool_t PostSDigitizer ( const char * name, const char * file ) const ;  
356
357   const Bool_t PostDigitizer (AliEMCALDigitizer * digitizer) const ;  
358
359   const Bool_t PostDigitizer  ( const char * name) const ;  
360
361   //const Bool_t PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsm) const ;  
362
363   //const Bool_t PostTrackSegmentMaker(const char * name ) const ;  
364
365   //const Bool_t PostPID  (AliEMCALPID * pid) const ;  
366
367   //const Bool_t PostPID  (const char * name ) const ;  
368
369   //const Bool_t PostQA   (void) const ;
370
371   
372
373  private:
374
375
376
377   AliEMCALGetter(const char* headerFile, const char* branchTitle ="Default", const Bool_t toSplit = kFALSE) ; 
378
379   TObject * ReturnO(TString what, TString name=0, TString file=0) const ; 
380
381   const TTask * ReturnT(TString what,TString name=0) const ; 
382
383   void DefineBranchTitles(char* branch, char* branchTitle) ;
384
385   Int_t ReadTreeD(const Int_t event) ;
386
387   Int_t ReadTreeH(void) ;
388
389   Int_t ReadTreeR(const Int_t event) ;
390
391   Int_t ReadTreeS(const Int_t event) ;
392
393   void ReadTreeQA(void) ;
394
395   void ReadPrimaries(void) ;
396
397   void CleanWhiteBoard(void) ;
398
399   void CloseSplitFiles(void) ;
400
401   void SetTitle(const char * title) ;
402
403
404
405   TObject ** PrimariesRef(void) const ;
406
407   TObject ** HitsRef(void) const ;
408
409   TObject ** SDigitsRef(const char * name, const char * file = 0 ) const;
410
411   TObject ** DigitsRef (const char * name)   const ;
412
413   TObject ** TowerRecPointsRef (const char * name) const ;
414
415   TObject ** PreShowerRecPointsRef (const char * name) const ;
416
417   //TObject ** TrackSegmentsRef(const char * name)   const ;
418
419   //TObject ** RecParticlesRef (const char * name)   const ;
420
421   //TObject ** AlarmsRef (void)   const ;
422
423
424
425   TObject ** SDigitizerRef (const char * name) const ; 
426
427   TObject ** DigitizerRef  (const char * name) const ; 
428
429   TObject ** ClusterizerRef(const char * name) const ; 
430
431   //TObject ** TSMakerRef    (const char * name) const ; 
432
433   //TObject ** PIDRef        (const char * name) const ; 
434
435
436
437  private:
438
439
440
441   static TFile * fFile ;              //!
442
443   Bool_t         fToSplit ;           //! Do we work in the split mode
444
445   TString        fHeaderFile ;        //! File in which gAlice lives
446
447   TString        fBranchTitle ;       //!
448
449   TString        fTrackSegmentsTitle ;//! 
450
451   TString        fTrackSegmentsFileName ;//! 
452
453   TString        fRecPointsTitle ;    //!
454
455   TString        fRecPointsFileName ;    //!
456
457   TString        fRecParticlesTitle ; //!
458
459   TString        fRecParticlesFileName ; //!
460
461   TString        fDigitsTitle ;       //!TDirectory tempo(gDirectory) 
462
463   TString        fDigitsFileName ;    //! TDirectory tempo(gDirectory)  
464
465   TString        fSDigitsTitle ;      //!
466
467   TString        fSDigitsFileName ;      //!
468
469   Bool_t         fFailed ;            //! true if file is not opened and/or galice not found
470
471   Int_t          fDebug ;             // Debug level
472
473   Int_t          fNPrimaries ;        //! # of primaries 
474
475   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
476
477   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
478
479   TFolder *      fPrimariesFolder ;   //!Folder that contains the Primary Particles 
480
481   TFolder *      fHitsFolder ;        //!Folder that contains the Hits 
482
483   TFolder *      fSDigitsFolder ;     //!Folder that contains the SDigits 
484
485   TFolder *      fDigitsFolder ;      //!Folder that contains the Digits 
486
487   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
488
489   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
490
491   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
492
493  
494
495   static AliEMCALGetter * fgObjGetter; // pointer to the unique instance of the singleton 
496
497
498
499   ClassDef(AliEMCALGetter,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
500
501
502
503 };
504
505
506
507 #endif // AliEMCALGETTER_H
508