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