]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSGetter.cxx
more debug output and bugfix for sub event number
[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 "TROOT.h"
45
46
47 // --- Standard library ---
48
49 // --- AliRoot header files ---
50 #include "AliPHOSGetter.h"
51 #include "AliPHOS.h"
52 #include "AliRunLoader.h"
53 #include "AliStack.h"  
54 #include "AliPHOSLoader.h"
55 #include "AliPHOSBeamTestEvent.h"
56 #include "AliMC.h"
57
58 ClassImp(AliPHOSGetter)
59   
60 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ; 
61 AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0;
62 Int_t AliPHOSGetter::fgDebug = 0;
63
64 //  TFile * AliPHOSGetter::fgFile = 0 ; 
65
66 //____________________________________________________________________________ 
67 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption)
68 {
69   // ctor only called by Instance()
70
71   AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ; 
72   if (!rl) {
73     rl = AliRunLoader::Open(headerFile, version, openingOption);
74     if (!rl) {
75       Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ; 
76       return ;
77     } 
78     if (rl->GetAliRun() == 0x0) {
79       rl->LoadgAlice();
80       gAlice = rl->GetAliRun(); // should be removed
81     }
82   }
83   fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
84   if ( !fgPhosLoader ) 
85     Error("AliPHOSGetter", "Could not find PHOSLoader") ; 
86   else 
87     fgPhosLoader->SetTitle(version);
88   
89   
90   // initialize data members
91   SetDebug(0) ; 
92   fBTE = 0 ; 
93   fPrimaries = 0 ; 
94   fLoadingStatus = "" ; 
95 }
96
97 //____________________________________________________________________________ 
98 AliPHOSGetter::~AliPHOSGetter()
99 {
100   // dtor
101   delete fgPhosLoader ;
102   fgPhosLoader = 0 ;
103   delete fBTE ; 
104   fBTE = 0 ; 
105   fPrimaries->Delete() ; 
106   delete fPrimaries ; 
107 }
108
109 //____________________________________________________________________________ 
110 AliPHOSClusterizer * AliPHOSGetter::Clusterizer()
111
112   // Returns pointer to the Clusterizer task 
113   AliPHOSClusterizer * rv ; 
114   rv =  dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ;
115   if (!rv) {
116     Event(0, "R") ; 
117     rv =  dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ;
118   }
119   return rv ; 
120 }
121
122 //____________________________________________________________________________ 
123 TObjArray * AliPHOSGetter::CpvRecPoints() 
124 {
125   // asks the Loader to return the CPV RecPoints container 
126
127   TObjArray * rv = 0 ; 
128   
129   rv = PhosLoader()->CpvRecPoints() ; 
130   if (!rv) {
131     PhosLoader()->MakeRecPointsArray() ;
132     rv = PhosLoader()->CpvRecPoints() ; 
133   }
134   return rv ; 
135 }
136
137 //____________________________________________________________________________ 
138 TClonesArray * AliPHOSGetter::Digits() 
139 {
140   // asks the Loader to return the Digits container 
141
142   TClonesArray * rv = 0 ; 
143   rv = PhosLoader()->Digits() ; 
144
145   if( !rv ) {
146     PhosLoader()->MakeDigitsArray() ; 
147     rv = PhosLoader()->Digits() ;
148   }
149   return rv ; 
150 }
151
152 //____________________________________________________________________________ 
153 AliPHOSDigitizer * AliPHOSGetter::Digitizer() 
154
155   // Returns pointer to the Digitizer task 
156   AliPHOSDigitizer * rv ; 
157   rv =  dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
158   if (!rv) {
159     Event(0, "D") ; 
160     rv =  dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ;
161   }
162   return rv ; 
163 }
164
165
166 //____________________________________________________________________________ 
167 TObjArray * AliPHOSGetter::EmcRecPoints() 
168 {
169   // asks the Loader to return the EMC RecPoints container 
170
171   TObjArray * rv = 0 ; 
172   
173   rv = PhosLoader()->EmcRecPoints() ; 
174   if (!rv) {
175     PhosLoader()->MakeRecPointsArray() ;
176     rv = PhosLoader()->EmcRecPoints() ; 
177   }
178   return rv ; 
179 }
180
181 //____________________________________________________________________________ 
182 TClonesArray * AliPHOSGetter::TrackSegments() 
183 {
184   // asks the Loader to return the TrackSegments container 
185
186   TClonesArray * rv = 0 ; 
187   
188   rv = PhosLoader()->TrackSegments() ; 
189   if (!rv) {
190     PhosLoader()->MakeTrackSegmentsArray() ;
191     rv = PhosLoader()->TrackSegments() ; 
192   }
193   return rv ; 
194 }
195
196 //____________________________________________________________________________ 
197 AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker()
198
199   // Returns pointer to the TrackSegmentMaker task 
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   // Returns pointer to the PID task 
392   AliPHOSPID * rv ; 
393   rv =  dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
394   if (!rv) {
395     Event(0, "P") ; 
396     rv =  dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ;
397   }
398   return rv ; 
399 }
400
401 //____________________________________________________________________________ 
402 AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const 
403 {
404   // Returns PHOS geometry
405
406   AliPHOSGeometry * rv = 0 ; 
407   if (PHOS() )
408     rv =  PHOS()->GetGeometry() ;
409   return rv ; 
410
411
412 //____________________________________________________________________________ 
413 TClonesArray * AliPHOSGetter::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  AliPHOSGetter::Print() 
426 {
427   // Print usefull information about the getter
428     
429   AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle());
430   ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ; 
431 }
432
433 //____________________________________________________________________________ 
434 void AliPHOSGetter::ReadPrimaries()  
435 {
436   // Read Primaries from Kinematics.root
437   
438   AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->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->Stack()->GetNtrack() ; 
445
446   if (fgDebug) 
447     Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ; 
448
449
450   // first time creates the container
451   if ( Primaries() ) 
452     fPrimaries->Clear() ; 
453   
454   Int_t index = 0 ; 
455   for (index = 0 ; index < fNPrimaries; index++) { 
456     new ((*fPrimaries)[index]) TParticle(*(Primary(index)));
457   }
458 }
459
460 //____________________________________________________________________________ 
461 Int_t AliPHOSGetter::ReadTreeD()
462 {
463   // Read the Digits
464   
465   
466   // gets TreeD from the root file (PHOS.SDigits.root)
467   if ( !IsLoaded("D") ) {
468     PhosLoader()->LoadDigits("UPDATE") ;
469     PhosLoader()->LoadDigitizer("UPDATE") ;
470     SetLoaded("D") ; 
471   } 
472   return Digits()->GetEntries() ; 
473 }
474
475 //____________________________________________________________________________ 
476 Int_t AliPHOSGetter::ReadTreeH()
477 {
478   // Read the Hits
479     
480   // gets TreeH from the root file (PHOS.Hit.root)
481   if ( !IsLoaded("H") ) {
482     PhosLoader()->LoadHits("UPDATE") ;
483     SetLoaded("H") ; 
484   }  
485   return Hits()->GetEntries() ; 
486 }
487
488 //____________________________________________________________________________ 
489 Int_t AliPHOSGetter::ReadTreeR()
490 {
491   // Read the RecPoints
492   
493   
494   // gets TreeR from the root file (PHOS.RecPoints.root)
495   if ( !IsLoaded("R") ) {
496     PhosLoader()->LoadRecPoints("UPDATE") ;
497     PhosLoader()->LoadClusterizer("UPDATE") ;
498     SetLoaded("R") ; 
499   }
500
501   return EmcRecPoints()->GetEntries() ; 
502 }
503
504 //____________________________________________________________________________ 
505 Int_t AliPHOSGetter::ReadTreeT()
506 {
507   // Read the TrackSegments
508   
509   
510   // gets TreeT from the root file (PHOS.TrackSegments.root)
511   if ( !IsLoaded("T") ) {
512     PhosLoader()->LoadTracks("UPDATE") ;
513     PhosLoader()->LoadTrackSegmentMaker("UPDATE") ;
514     SetLoaded("T") ; 
515   }
516
517   return TrackSegments()->GetEntries() ; 
518 }
519 //____________________________________________________________________________ 
520 Int_t AliPHOSGetter::ReadTreeP()
521 {
522   // Read the TrackSegments
523   
524   
525   // gets TreeT from the root file (PHOS.TrackSegments.root)
526   if ( !IsLoaded("P") ) {
527     PhosLoader()->LoadRecParticles("UPDATE") ;
528     PhosLoader()->LoadPID("UPDATE") ;
529     SetLoaded("P") ; 
530   }
531
532   return RecParticles()->GetEntries() ; 
533 }
534 //____________________________________________________________________________ 
535 Int_t AliPHOSGetter::ReadTreeS()
536 {
537   // Read the SDigits
538   
539   
540   // gets TreeS from the root file (PHOS.SDigits.root)
541   if ( !IsLoaded("S") ) {
542     PhosLoader()->LoadSDigits("UPDATE") ;
543     PhosLoader()->LoadSDigitizer("UPDATE") ;
544     SetLoaded("S") ; 
545   }
546
547   return SDigits()->GetEntries() ; 
548 }
549
550 //____________________________________________________________________________ 
551 TClonesArray * AliPHOSGetter::SDigits() 
552 {
553   // asks the Loader to return the Digits container 
554
555   TClonesArray * rv = 0 ; 
556   
557   rv = PhosLoader()->SDigits() ; 
558   if (!rv) {
559     PhosLoader()->MakeSDigitsArray() ;
560     rv = PhosLoader()->SDigits() ; 
561   }
562   return rv ; 
563 }
564
565 //____________________________________________________________________________ 
566 AliPHOSSDigitizer * AliPHOSGetter::SDigitizer()
567
568   // Returns pointer to the SDigitizer task 
569   AliPHOSSDigitizer * rv ; 
570   rv =  dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
571   if (!rv) {
572     Event(0, "S") ; 
573     rv =  dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ;
574   }
575   return rv ; 
576 }
577
578 //____________________________________________________________________________ 
579 TParticle * AliPHOSGetter::Secondary(const TParticle* p, const Int_t index) const
580 {
581   // Return first (index=1) or second (index=2) secondary particle of primary particle p 
582
583   if(index <= 0) 
584     return 0 ;
585   if(index > 2)
586     return 0 ;
587
588   if(p) {
589   Int_t daughterIndex = p->GetDaughter(index-1) ; 
590   AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
591   return  rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; 
592   }
593   else
594     return 0 ;
595 }
596
597 //____________________________________________________________________________ 
598 void AliPHOSGetter::Track(const Int_t itrack) 
599 {
600   // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
601  
602  AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
603
604   if( !TreeH() ) // load treeH the first time
605     rl->LoadHits() ;
606
607   // first time create the container
608   TClonesArray * hits = Hits() ; 
609   if ( hits ) 
610     hits->Clear() ; 
611
612   TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ; 
613   phosbranch->SetAddress(&hits) ;
614   phosbranch->GetEntry(itrack) ;
615 }
616
617 //____________________________________________________________________________ 
618 TTree * AliPHOSGetter::TreeD() const 
619 {
620   // Returns pointer to the Digits Tree
621   TTree * rv = 0 ; 
622   rv = PhosLoader()->TreeD() ; 
623   if ( !rv ) {
624     PhosLoader()->MakeTree("D");
625     rv = PhosLoader()->TreeD() ;
626   } 
627   
628   return rv ; 
629 }
630
631 //____________________________________________________________________________ 
632 TTree * AliPHOSGetter::TreeH() const 
633 {
634   // Returns pointer to the Hits Tree
635   TTree * rv = 0 ; 
636   rv = PhosLoader()->TreeH() ; 
637   if ( !rv ) {
638     PhosLoader()->MakeTree("H");
639     rv = PhosLoader()->TreeH() ;
640   } 
641   
642   return rv ; 
643 }
644
645 //____________________________________________________________________________ 
646 TTree * AliPHOSGetter::TreeR() const 
647 {
648   // Returns pointer to the RecPoints Tree
649   TTree * rv = 0 ; 
650   rv = PhosLoader()->TreeR() ; 
651   if ( !rv ) {
652     PhosLoader()->MakeTree("R");
653     rv = PhosLoader()->TreeR() ;
654   } 
655   
656   return rv ; 
657 }
658
659 //____________________________________________________________________________ 
660 TTree * AliPHOSGetter::TreeT() const 
661 {
662   // Returns pointer to the TrackSegments Tree
663   TTree * rv = 0 ; 
664   rv = PhosLoader()->TreeT() ; 
665   if ( !rv ) {
666     PhosLoader()->MakeTree("T");
667     rv = PhosLoader()->TreeT() ;
668   } 
669   
670   return rv ; 
671 }
672 //____________________________________________________________________________ 
673 TTree * AliPHOSGetter::TreeP() const 
674 {
675   // Returns pointer to the RecParticles  Tree
676   TTree * rv = 0 ; 
677   rv = PhosLoader()->TreeP() ; 
678   if ( !rv ) {
679     PhosLoader()->MakeTree("P");
680     rv = PhosLoader()->TreeP() ;
681   } 
682   
683   return rv ; 
684 }
685
686 //____________________________________________________________________________ 
687 TTree * AliPHOSGetter::TreeS() const 
688
689  // Returns pointer to the SDigits Tree
690   TTree * rv = 0 ; 
691   rv = PhosLoader()->TreeS() ; 
692   if ( !rv ) {
693     PhosLoader()->MakeTree("S");
694     rv = PhosLoader()->TreeS() ;
695   } 
696   
697   return rv ; 
698 }
699
700 //____________________________________________________________________________ 
701 Bool_t AliPHOSGetter::VersionExists(TString & opt) const
702 {
703   // checks if the version with the present name already exists in the same directory
704
705   Bool_t rv = kFALSE ;
706  
707   AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle());
708   TString version( rl->GetEventFolder()->GetName() ) ; 
709
710   opt.ToLower() ; 
711   
712   if ( opt == "sdigits") {
713     // add the version name to the root file name
714     TString fileName( PhosLoader()->GetSDigitsFileName() ) ; 
715     if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name 
716       fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
717     if ( !(gSystem->AccessPathName(fileName)) ) { 
718       Warning("VersionExists", "The file %s already exists", fileName.Data()) ;
719       rv = kTRUE ; 
720     }
721     PhosLoader()->SetSDigitsFileName(fileName) ;
722   }
723
724   if ( opt == "digits") {
725     // add the version name to the root file name
726     TString fileName( PhosLoader()->GetDigitsFileName() ) ; 
727     if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name 
728       fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ;
729     if ( !(gSystem->AccessPathName(fileName)) ) {
730       Warning("VersionExists", "The file %s already exists", fileName.Data()) ;  
731       rv = kTRUE ; 
732     }
733     PhosLoader()->SetDigitsFileName(fileName) ;
734   }
735
736   return rv ;
737
738 }
739
740 //____________________________________________________________________________ 
741 UShort_t AliPHOSGetter::EventPattern(void) const
742 {
743   // Return the pattern (trigger bit register) of the beam-test event
744   if(fBTE)
745     return fBTE->GetPattern() ;
746   else
747     return 0 ;
748 }
749 //____________________________________________________________________________ 
750 Float_t AliPHOSGetter::BeamEnergy(void) const
751 {
752   // Return the beam energy of the beam-test event
753   if(fBTE)
754     return fBTE->GetBeamEnergy() ;
755   else
756     return 0 ;
757 }