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