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