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