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