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