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