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