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