]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGetter.cxx
Fixing memory leaks (T.Kuhr)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGetter.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 //  A singleton. This class should be used in the analysis stage to get 
20 //  reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 //  instead of directly reading them from galice.root file. This container 
22 //  ensures, that one reads Digits, made of these particular digits, RecPoints, 
23 //  made of these particular RecPoints, TrackSegments and RecParticles. 
24 //  This becomes non trivial if there are several identical branches, produced with
25 //  different set of parameters. 
26 //
27 //  An example of how to use (see also class AliEMCALAnalyser):
28 //  AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
29 //  for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
30 //     AliEMCALRecParticle * part = gime->RecParticle(1) ;
31 //     ................
32 //  gime->Event(event) ;    // reads new event from galice.root
33 //                  
34 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
35 //*--         Completely redesigned by Dmitri Peressounko March 2001  
36 //
37 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
38 //*--         systematic usage of TFolders without changing the interface        
39 //////////////////////////////////////////////////////////////////////////////
40
41 // --- ROOT system ---
42
43 #include "TSystem.h"
44 #include "TROOT.h"
45
46
47 // --- Standard library ---
48
49 // --- AliRoot header files ---
50
51 #include "AliEMCALGetter.h"
52 #include "AliEMCAL.h"
53 #include "AliRunLoader.h"
54 #include "AliStack.h"  
55 #include "AliHeader.h"  
56 #include "AliEMCALLoader.h"
57 #include "AliMC.h"
58
59 ClassImp(AliEMCALGetter)
60   
61 AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ; 
62 AliEMCALLoader * AliEMCALGetter::fgEmcalLoader = 0;
63 Int_t AliEMCALGetter::fgDebug = 0;
64
65 //  TFile * AliEMCALGetter::fgFile = 0 ; 
66
67 //____________________________________________________________________________ 
68 AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* version, Option_t * openingOption)
69 {
70   // ctor only called by Instance()
71
72   AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ; 
73   if (!rl) {
74     rl = AliRunLoader::Open(headerFile, version, openingOption);
75     if (!rl) {
76       Fatal("AliEMCALGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ; 
77       return ;
78     } 
79     if (rl->GetAliRun() == 0x0) {
80       rl->LoadgAlice();
81       gAlice = rl->GetAliRun(); // should be removed
82     }
83   }
84   fgEmcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetLoader("EMCALLoader"));
85   if ( !fgEmcalLoader ) 
86     Error("AliEMCALGetter", "Could not find EMCALLoader") ; 
87   else 
88     fgEmcalLoader->SetTitle(version);
89   
90   
91   // initialize data members
92   SetDebug(0) ; 
93   //fBTE = 0 ; 
94   fPrimaries = 0 ; 
95   fLoadingStatus = "" ; 
96 }
97
98 //____________________________________________________________________________ 
99 AliEMCALGetter::~AliEMCALGetter()
100 {
101   // dtor
102   delete fgEmcalLoader ;
103   fgEmcalLoader = 0 ;
104   //delete fBTE ; 
105   // fBTE = 0 ; 
106   fPrimaries->Delete() ; 
107   delete fPrimaries ; 
108   fgObjGetter = 0; 
109 }
110
111 //____________________________________________________________________________ 
112 void AliEMCALGetter::Reset()
113 {
114   // resets things in case the getter is called consecutively with different files
115   // the EMCAL Loader is already deleted by the Run Loader
116
117   if (fPrimaries) { 
118     fPrimaries->Delete() ; 
119     delete fPrimaries ;
120   } 
121   fgEmcalLoader = 0; 
122   fgObjGetter = 0; 
123 }
124
125 //____________________________________________________________________________ 
126 AliEMCALClusterizer * AliEMCALGetter::Clusterizer()
127
128   // return pointer to Clusterizer Tree
129   AliEMCALClusterizer * rv ; 
130   rv =  dynamic_cast<AliEMCALClusterizer *>(EmcalLoader()->Reconstructioner()) ;
131   if (!rv) {
132     Event(0, "R") ; 
133     rv =  dynamic_cast<AliEMCALClusterizer*>(EmcalLoader()->Reconstructioner()) ;
134   }
135   return rv ; 
136 }
137
138
139 //____________________________________________________________________________ 
140 TClonesArray * AliEMCALGetter::Digits() const  
141 {
142   // asks the Loader to return the Digits container 
143
144   TClonesArray * rv = 0 ; 
145   rv = EmcalLoader()->Digits() ; 
146
147   if( !rv ) {
148     EmcalLoader()->MakeDigitsArray() ; 
149     rv = EmcalLoader()->Digits() ;
150   }
151   return rv ; 
152 }
153
154 //____________________________________________________________________________ 
155 AliEMCALDigitizer * AliEMCALGetter::Digitizer() 
156
157   // return pointer to Digitizer Tree
158   AliEMCALDigitizer * rv ; 
159   rv =  dynamic_cast<AliEMCALDigitizer *>(EmcalLoader()->Digitizer()) ;
160   if (!rv) {
161     Event(0, "D") ; 
162     rv =  dynamic_cast<AliEMCALDigitizer *>(EmcalLoader()->Digitizer()) ;
163   }
164   return rv ; 
165 }
166
167 //____________________________________________________________________________ 
168 TObjArray * AliEMCALGetter::ECARecPoints() const 
169 {
170   // asks the Loader to return the EMC RecPoints container 
171
172   TObjArray * rv = 0 ; 
173   
174   rv = EmcalLoader()->ECARecPoints() ; 
175   if (!rv) {
176     EmcalLoader()->MakeRecPointsArray() ;
177     rv = EmcalLoader()->ECARecPoints() ; 
178   }
179   return rv ; 
180 }
181
182 //____________________________________________________________________________ 
183 TClonesArray * AliEMCALGetter::TrackSegments() const 
184 {
185   // asks the Loader to return the TrackSegments container 
186
187   TClonesArray * rv = 0 ; 
188   
189   rv = EmcalLoader()->TrackSegments() ; 
190   if (!rv) {
191     EmcalLoader()->MakeTrackSegmentsArray() ;
192     rv = EmcalLoader()->TrackSegments() ; 
193   }
194   return rv ; 
195 }
196
197 //____________________________________________________________________________ 
198 AliEMCALTrackSegmentMaker * AliEMCALGetter::TrackSegmentMaker() 
199
200   // return pointer to TrackSegmentMaker Tree
201   AliEMCALTrackSegmentMaker * rv ; 
202   rv =  dynamic_cast<AliEMCALTrackSegmentMaker *>(EmcalLoader()->TrackSegmentMaker()) ;
203   if (!rv) {
204     Event(0, "T") ; 
205     rv =  dynamic_cast<AliEMCALTrackSegmentMaker *>(EmcalLoader()->TrackSegmentMaker()) ;
206   }
207   return rv ; 
208 }
209
210 //____________________________________________________________________________ 
211 TClonesArray * AliEMCALGetter::RecParticles() const  
212 {
213   // asks the Loader to return the TrackSegments container 
214
215   TClonesArray * rv = 0 ; 
216   
217   rv = EmcalLoader()->RecParticles() ; 
218   if (!rv) {
219     EmcalLoader()->MakeRecParticlesArray() ;
220     rv = EmcalLoader()->RecParticles() ; 
221   }
222   return rv ; 
223 }
224 //____________________________________________________________________________ 
225 void AliEMCALGetter::Event(Int_t event, const char* opt) 
226 {
227   // Reads the content of all Tree's S, D and R
228
229   if ( event >= MaxEvent() ) {
230     Error("Event", "%d not found in TreeE !", event) ; 
231     return ; 
232   }
233
234   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
235   // checks if we are dealing with test-beam data
236 //   TBranch * btb = rl->TreeE()->GetBranch("AliEMCALBeamTestEvent") ;
237 //   if(btb){
238 //     if(!fBTE)
239 //       fBTE = new AliEMCALBeamTestEvent() ;
240 //     btb->SetAddress(&fBTE) ;
241 //     btb->GetEntry(event) ;
242 //   }
243 //   else{
244 //     if(fBTE){
245 //       delete fBTE ;
246 //       fBTE = 0 ;
247 //     }
248 //   }
249
250   // Loads the type of object(s) requested
251   
252   rl->GetEvent(event) ;
253
254   if( strstr(opt,"X") || (strcmp(opt,"")==0) )
255     ReadPrimaries() ;
256
257   if(strstr(opt,"H") )
258     ReadTreeH();
259
260   if(strstr(opt,"S") )
261     ReadTreeS() ;
262
263   if( strstr(opt,"D") )
264     ReadTreeD() ;
265
266   if( strstr(opt,"R") )
267     ReadTreeR() ;
268
269   if( strstr(opt,"T") )
270     ReadTreeT() ;
271
272   if( strstr(opt,"P") )
273     ReadTreeP() ;
274  
275 }
276
277
278 //____________________________________________________________________________ 
279 Int_t AliEMCALGetter::EventNumber() const
280   {
281   // return the current event number
282   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
283   return static_cast<Int_t>(rl->GetEventNumber()) ;   
284 }
285
286 //____________________________________________________________________________ 
287   TClonesArray * AliEMCALGetter::Hits() const   
288 {
289   // asks the loader to return  the Hits container 
290   
291   TClonesArray * rv = 0 ; 
292   
293   rv = EmcalLoader()->Hits() ; 
294   if ( !rv ) {
295     EmcalLoader()->LoadHits("read"); 
296     rv = EmcalLoader()->Hits() ; 
297   }
298   return rv ; 
299 }
300
301 //____________________________________________________________________________ 
302 AliEMCALGetter * AliEMCALGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption) 
303 {
304   // Creates and returns the pointer of the unique instance
305   // Must be called only when the environment has changed
306   
307   if(!fgObjGetter){ // first time the getter is called 
308     fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ;
309   }
310   else { // the getter has been called previously
311     AliRunLoader * rl = AliRunLoader::GetRunLoader(fgEmcalLoader->GetTitle());
312     if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name
313       // check if the file is already open
314       TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ; 
315       
316       if ( !galiceFile ) 
317         fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ;
318       
319       else {  // the file is already open check the version name
320         TString currentVersionName = rl->GetEventFolder()->GetName() ; 
321         TString newVersionName(version) ; 
322         if (currentVersionName == newVersionName) 
323           if(fgDebug)
324             ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ;  
325         else {
326           fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ;      
327         }
328       }
329     }
330     else { 
331       AliRunLoader * rl = AliRunLoader::GetRunLoader(fgEmcalLoader->GetTitle());
332       if ( strstr(version, AliConfig::fgkDefaultEventFolderName) ) // false in case of merging
333         delete rl ; 
334       fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ;      
335     }
336   }
337   if (!fgObjGetter) 
338     ::Error("AliEMCALGetter::Instance", "Failed to create the EMCAL Getter object") ;
339   else 
340     if (fgDebug)
341       Print() ;
342   
343   return fgObjGetter ;
344 }
345
346 //____________________________________________________________________________ 
347 AliEMCALGetter *  AliEMCALGetter::Instance()
348 {
349   // Returns the pointer of the unique instance already defined
350   
351   if(!fgObjGetter && fgDebug)
352      ::Warning("AliEMCALGetter::Instance", "Getter not initialized") ;
353
354    return fgObjGetter ;
355            
356 }
357
358 //____________________________________________________________________________ 
359 Int_t AliEMCALGetter::MaxEvent() const 
360 {
361   // returns the number of events in the run (from TE)
362
363   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
364   return static_cast<Int_t>(rl->GetNumberOfEvents()) ; 
365 }
366
367 //____________________________________________________________________________ 
368 TParticle * AliEMCALGetter::Primary(Int_t index) const
369 {
370   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
371   return rl->Stack()->Particle(index) ; 
372
373
374 //____________________________________________________________________________ 
375 AliEMCAL * AliEMCALGetter:: EMCAL() const  
376 {
377   // returns the EMCAL object 
378   AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(EmcalLoader()->GetModulesFolder()->FindObject("EMCAL")) ;  
379   if (!emcal) 
380     if (fgDebug)
381       Warning("EMCAL", "EMCAL module not found in module folders: %s", EmcalLoader()->GetModulesFolder()->GetName() ) ; 
382   return emcal ; 
383 }  
384
385
386
387 //____________________________________________________________________________ 
388 AliEMCALPID * AliEMCALGetter::PID() 
389
390   // return pointer to PID Tree
391   AliEMCALPID * rv ; 
392   rv =  dynamic_cast<AliEMCALPID *>(EmcalLoader()->PIDTask()) ;
393   if (!rv) {
394     Event(0, "P") ; 
395     rv =  dynamic_cast<AliEMCALPID *>(EmcalLoader()->PIDTask()) ;
396   }
397   return rv ; 
398 }
399
400 //____________________________________________________________________________ 
401 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry() const 
402 {
403   // Returns EMCAL geometry
404
405   AliEMCALGeometry * rv = 0 ; 
406   if (EMCAL() )
407     rv =  EMCAL()->GetGeometry() ;
408   return rv ; 
409
410
411 //____________________________________________________________________________ 
412 TClonesArray * AliEMCALGetter::Primaries()  
413 {
414   // creates the Primaries container if needed
415   if ( !fPrimaries ) {
416     if (fgDebug) 
417       Info("Primaries", "Creating a new TClonesArray for primaries") ; 
418     fPrimaries = new TClonesArray("TParticle", 1000) ;
419   } 
420   return fPrimaries ; 
421 }
422
423 //____________________________________________________________________________ 
424 void  AliEMCALGetter::Print() 
425 {
426   // Print usefull information about the getter
427     
428   AliRunLoader * rl = AliRunLoader::GetRunLoader(fgEmcalLoader->GetTitle());
429   ::Info("Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ; 
430 }
431
432 //____________________________________________________________________________ 
433 void AliEMCALGetter::ReadPrimaries()  
434 {
435   // Read Primaries from Kinematics.root
436   
437   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
438   
439   // gets kine tree from the root file (Kinematics.root)
440   if ( ! rl->TreeK() )  // load treeK the first time
441     rl->LoadKinematics() ;
442   
443   fNPrimaries = (rl->GetHeader())->GetNtrack(); 
444   if (fgDebug) 
445     Info("ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ; 
446
447   // first time creates the container
448   if ( Primaries() ) 
449     fPrimaries->Clear() ; 
450   
451   Int_t index = 0 ; 
452   for (index = 0 ; index < fNPrimaries; index++) { 
453     new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
454   }
455 }
456
457 //____________________________________________________________________________ 
458 Int_t AliEMCALGetter::ReadTreeD()
459 {
460   // Read the Digits
461   
462   
463   // gets TreeD from the root file (EMCAL.SDigits.root)
464   if ( !IsLoaded("D") ) {
465     EmcalLoader()->LoadDigits("UPDATE") ;
466     EmcalLoader()->LoadDigitizer("UPDATE") ;
467     SetLoaded("D") ; 
468   } 
469   return Digits()->GetEntries() ; 
470 }
471
472 //____________________________________________________________________________ 
473 Int_t AliEMCALGetter::ReadTreeH()
474 {
475   // Read the Hits
476     
477   // gets TreeH from the root file (EMCAL.Hit.root)
478   if ( !IsLoaded("H") ) {
479     EmcalLoader()->LoadHits("READ") ;
480     SetLoaded("H") ; 
481   }  
482   return Hits()->GetEntries() ; 
483 }
484
485 //____________________________________________________________________________ 
486 Int_t AliEMCALGetter::ReadTreeR()
487 {
488   // Read the RecPoints
489   
490   
491   // gets TreeR from the root file (EMCAL.RecPoints.root)
492   if ( !IsLoaded("R") ) {
493     EmcalLoader()->LoadRecPoints("UPDATE") ;
494     EmcalLoader()->LoadClusterizer("UPDATE") ;
495     SetLoaded("R") ; 
496   }
497
498   return ECARecPoints()->GetEntries() ; 
499 }
500
501 //____________________________________________________________________________ 
502 Int_t AliEMCALGetter::ReadTreeT()
503 {
504   // Read the TrackSegments
505   
506   
507   // gets TreeT from the root file (EMCAL.TrackSegments.root)
508   if ( !IsLoaded("T") ) {
509     EmcalLoader()->LoadTracks("UPDATE") ;
510     EmcalLoader()->LoadTrackSegmentMaker("UPDATE") ;
511     SetLoaded("T") ; 
512   }
513
514   return TrackSegments()->GetEntries() ; 
515 }
516 //____________________________________________________________________________ 
517 Int_t AliEMCALGetter::ReadTreeP()
518 {
519   // Read the TrackSegments
520   
521   
522   // gets TreeT from the root file (EMCAL.TrackSegments.root)
523   if ( !IsLoaded("P") ) {
524     EmcalLoader()->LoadRecParticles("UPDATE") ;
525     EmcalLoader()->LoadPID("UPDATE") ;
526     SetLoaded("P") ; 
527   }
528
529   return RecParticles()->GetEntries() ; 
530 }
531 //____________________________________________________________________________ 
532 Int_t AliEMCALGetter::ReadTreeS()
533 {
534   // Read the SDigits
535   
536   
537   // gets TreeS from the root file (EMCAL.SDigits.root)
538    if ( !IsLoaded("S") ) {
539     EmcalLoader()->LoadSDigits("READ") ;
540     EmcalLoader()->LoadSDigitizer("READ") ;
541     SetLoaded("S") ; 
542   }
543
544   return SDigits()->GetEntries() ; 
545 }
546
547 //____________________________________________________________________________ 
548 TClonesArray * AliEMCALGetter::SDigits() const  
549 {
550   // asks the Loader to return the Digits container 
551
552   TClonesArray * rv = 0 ; 
553   
554   rv = EmcalLoader()->SDigits() ; 
555   if (!rv) {
556     EmcalLoader()->MakeSDigitsArray() ;
557     rv = EmcalLoader()->SDigits() ; 
558   }
559   return rv ; 
560 }
561
562 //____________________________________________________________________________ 
563 AliEMCALSDigitizer * AliEMCALGetter::SDigitizer() 
564
565   // Return pointer to SDigitizer task
566   AliEMCALSDigitizer * rv ; 
567   rv =  dynamic_cast<AliEMCALSDigitizer *>(EmcalLoader()->SDigitizer()) ;
568   if (!rv) {
569     Event(0, "S") ; 
570     rv =  dynamic_cast<AliEMCALSDigitizer *>(EmcalLoader()->SDigitizer()) ;
571   }
572   return rv ; 
573 }
574
575 //____________________________________________________________________________ 
576 TParticle * AliEMCALGetter::Secondary(const TParticle* p, Int_t index) const
577 {
578   // Return first (index=1) or second (index=2) secondary particle of primary particle p 
579
580   if(index <= 0) 
581     return 0 ;
582   if(index > 2)
583     return 0 ;
584
585   if(p) {
586   Int_t daughterIndex = p->GetDaughter(index-1) ; 
587   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
588   return  rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; 
589   }
590   else
591     return 0 ;
592 }
593
594 //____________________________________________________________________________ 
595 void AliEMCALGetter::Track(Int_t itrack) 
596 {
597   // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
598  
599  AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
600
601   if( !TreeH() ) // load treeH the first time
602     rl->LoadHits() ;
603
604   // first time create the container
605   TClonesArray * hits = Hits() ; 
606   if ( hits ) 
607     hits->Clear() ; 
608
609   TBranch * emcalbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("EMCAL")) ; 
610   emcalbranch->SetAddress(&hits) ;
611   emcalbranch->GetEntry(itrack) ;
612 }
613
614 //____________________________________________________________________________ 
615 TTree * AliEMCALGetter::TreeD() const 
616 {
617   // return pointer to Digits Tree
618   TTree * rv = 0 ; 
619   rv = EmcalLoader()->TreeD() ; 
620   if ( !rv ) {
621     EmcalLoader()->MakeTree("D");
622     rv = EmcalLoader()->TreeD() ;
623   } 
624   
625   return rv ; 
626 }
627
628 //____________________________________________________________________________ 
629 TTree * AliEMCALGetter::TreeH() const 
630 {
631   // return pointer to Hits Tree
632   TTree * rv = 0 ; 
633   rv = EmcalLoader()->TreeH() ; 
634   if ( !rv ) {
635     EmcalLoader()->MakeTree("H");
636     rv = EmcalLoader()->TreeH() ;
637   } 
638   
639   return rv ; 
640 }
641
642 //____________________________________________________________________________ 
643 TTree * AliEMCALGetter::TreeR() const 
644 {
645   // return pointer to RecPoints Tree
646
647   TTree * rv = 0 ; 
648   rv = EmcalLoader()->TreeR() ; 
649   if ( !rv ) {
650     EmcalLoader()->MakeTree("R");
651     rv = EmcalLoader()->TreeR() ;
652   } 
653   
654   return rv ; 
655 }
656
657 //____________________________________________________________________________ 
658 TTree * AliEMCALGetter::TreeT() const 
659 {  
660   // return pointer to TrackSegments Tree
661   TTree * rv = 0 ; 
662   rv = EmcalLoader()->TreeT() ; 
663   if ( !rv ) {
664     EmcalLoader()->MakeTree("T");
665     rv = EmcalLoader()->TreeT() ;
666   } 
667   
668   return rv ; 
669 }
670 //____________________________________________________________________________ 
671 TTree * AliEMCALGetter::TreeP() const 
672 {
673   // return pointer to RecParticles Tree
674   TTree * rv = 0 ; 
675   rv = EmcalLoader()->TreeP() ; 
676   if ( !rv ) {
677     EmcalLoader()->MakeTree("P");
678     rv = EmcalLoader()->TreeP() ;
679   } 
680   
681   return rv ; 
682 }
683
684 //____________________________________________________________________________ 
685 TTree * AliEMCALGetter::TreeS() const 
686 {
687   // return pointer to SDigits Tree
688   TTree * rv = 0 ; 
689   rv = EmcalLoader()->TreeS() ; 
690   if ( !rv ) {
691     EmcalLoader()->MakeTree("S");
692     rv = EmcalLoader()->TreeS() ;
693   } 
694   
695   return rv ; 
696 }
697
698 //____________________________________________________________________________ 
699 Bool_t AliEMCALGetter::VersionExists(TString & opt) const
700 {
701   // checks if the version with the present name already exists in the same directory
702
703   Bool_t rv = kFALSE ;
704  
705   AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle());
706   TString version( rl->GetEventFolder()->GetName() ) ; 
707
708   opt.ToLower() ; 
709   
710   if ( opt == "sdigits") {
711     // add the version name to the root file name
712     TString fileName( EmcalLoader()->GetSDigitsFileName() ) ; 
713     if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name 
714       fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
715     if ( !(gSystem->AccessPathName(fileName)) ) { 
716       Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
717       rv = kTRUE ; 
718     }
719     EmcalLoader()->SetSDigitsFileName(fileName) ;
720   }
721
722   if ( opt == "digits") {
723     // add the version name to the root file name
724     TString fileName( EmcalLoader()->GetDigitsFileName() ) ; 
725     if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name 
726       fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
727     if ( !(gSystem->AccessPathName(fileName)) ) {
728       Warning("VersionExists", "The file %s already exists", fileName.Data()) ;  
729       rv = kTRUE ; 
730     }
731   }
732
733   return rv ;
734
735 }
736
737 //____________________________________________________________________________ 
738 UShort_t AliEMCALGetter::EventPattern(void) const
739 {
740   // Return the pattern (trigger bit register) of the beam-test event
741 //   if(fBTE)
742 //     return fBTE->GetPattern() ;
743 //   else
744     return 0 ;
745 }
746 //____________________________________________________________________________ 
747 Float_t AliEMCALGetter::BeamEnergy(void) const
748 {
749   // Return the beam energy of the beam-test event
750 //   if(fBTE)
751 //     return fBTE->GetBeamEnergy() ;
752 //   else
753     return 0 ;
754 }