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