ffa6d63b |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
803d1ab0 |
16 | /* $Id$ */ |
ffa6d63b |
17 | |
18 | //_________________________________________________________________________ |
19 | // A singleton. This class should be used in the analysis stage to get |
20 | // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles, |
21 | // instead of directly reading them from galice.root file. This container |
88cb7938 |
22 | // ensures, that one reads Digits, made of these particular digits, RecPoints, |
ffa6d63b |
23 | // made of these particular RecPoints, TrackSegments and RecParticles. |
24 | // This becomes non trivial if there are several identical branches, produced with |
d75bea67 |
25 | // different set of parameters. |
ffa6d63b |
26 | // |
27 | // An example of how to use (see also class AliEMCALAnalyser): |
28 | // AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ; |
d75bea67 |
29 | // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++) |
30 | // AliEMCALRecParticle * part = gime->RecParticle(1) ; |
ffa6d63b |
31 | // ................ |
88cb7938 |
32 | // gime->Event(event) ; // reads new event from galice.root |
ffa6d63b |
33 | // |
d75bea67 |
34 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) |
35 | //*-- Completely redesigned by Dmitri Peressounko March 2001 |
36 | // |
37 | //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make |
88cb7938 |
38 | //*-- systematic usage of TFolders without changing the interface |
ffa6d63b |
39 | ////////////////////////////////////////////////////////////////////////////// |
40 | |
ffa6d63b |
41 | // --- ROOT system --- |
173558f2 |
42 | |
88cb7938 |
43 | #include "TSystem.h" |
ffa6d63b |
44 | #include "TFile.h" |
ffa6d63b |
45 | #include "TROOT.h" |
1ce25ac8 |
46 | |
ffa6d63b |
47 | |
48 | // --- Standard library --- |
173558f2 |
49 | |
ffa6d63b |
50 | // --- AliRoot header files --- |
1ce25ac8 |
51 | |
ffa6d63b |
52 | #include "AliEMCALGetter.h" |
d64c959b |
53 | #include "AliEMCAL.h" |
88cb7938 |
54 | #include "AliRunLoader.h" |
55 | #include "AliStack.h" |
56 | #include "AliEMCALLoader.h" |
5d12ce38 |
57 | #include "AliMC.h" |
ffa6d63b |
58 | |
59 | ClassImp(AliEMCALGetter) |
88cb7938 |
60 | |
61 | AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ; |
62 | AliEMCALLoader * AliEMCALGetter::fgEmcalLoader = 0; |
63 | Int_t AliEMCALGetter::fgDebug = 0; |
173558f2 |
64 | |
88cb7938 |
65 | // TFile * AliEMCALGetter::fgFile = 0 ; |
ffa6d63b |
66 | |
67 | //____________________________________________________________________________ |
88cb7938 |
68 | AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* version, Option_t * openingOption) |
ffa6d63b |
69 | { |
88cb7938 |
70 | // ctor only called by Instance() |
d75bea67 |
71 | |
88cb7938 |
72 | AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ; |
73 | if (!rl) { |
74 | rl = AliRunLoader::Open(headerFile, version, openingOption); |
75 | if (!rl) { |
76 | Fatal("AliEMCALGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ; |
77 | return ; |
78 | } |
79 | if (rl->GetAliRun() == 0x0) { |
80 | rl->LoadgAlice(); |
81 | gAlice = rl->GetAliRun(); // should be removed |
ba298680 |
82 | } |
ffa6d63b |
83 | } |
88cb7938 |
84 | fgEmcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetLoader("EMCALLoader")); |
85 | if ( !fgEmcalLoader ) |
86 | Error("AliEMCALGetter", "Could not find EMCALLoader") ; |
87 | else |
88 | fgEmcalLoader->SetTitle(version); |
89 | |
90 | |
91 | // initialize data members |
92 | SetDebug(0) ; |
93 | //fBTE = 0 ; |
94 | fPrimaries = 0 ; |
95 | fLoadingStatus = "" ; |
ffa6d63b |
96 | } |
05a92d59 |
97 | |
ffa6d63b |
98 | //____________________________________________________________________________ |
ba298680 |
99 | AliEMCALGetter::~AliEMCALGetter() |
100 | { |
88cb7938 |
101 | // dtor |
102 | delete fgEmcalLoader ; |
103 | fgEmcalLoader = 0 ; |
104 | //delete fBTE ; |
105 | // fBTE = 0 ; |
106 | fPrimaries->Delete() ; |
107 | delete fPrimaries ; |
108 | } |
d489fb96 |
109 | |
88cb7938 |
110 | //____________________________________________________________________________ |
111 | AliEMCALClusterizer * AliEMCALGetter::Clusterizer() |
112 | { |
1ce25ac8 |
113 | // return pointer to Clusterizer Tree |
88cb7938 |
114 | AliEMCALClusterizer * rv ; |
115 | rv = dynamic_cast<AliEMCALClusterizer *>(EmcalLoader()->Reconstructioner()) ; |
116 | if (!rv) { |
117 | Event(0, "R") ; |
118 | rv = dynamic_cast<AliEMCALClusterizer*>(EmcalLoader()->Reconstructioner()) ; |
05a92d59 |
119 | } |
88cb7938 |
120 | return rv ; |
ffa6d63b |
121 | } |
122 | |
173558f2 |
123 | |
88cb7938 |
124 | //____________________________________________________________________________ |
1ce25ac8 |
125 | TClonesArray * AliEMCALGetter::Digits() const |
65549808 |
126 | { |
88cb7938 |
127 | // asks the Loader to return the Digits container |
128 | |
129 | TClonesArray * rv = 0 ; |
130 | rv = EmcalLoader()->Digits() ; |
131 | |
132 | if( !rv ) { |
133 | EmcalLoader()->MakeDigitsArray() ; |
134 | rv = EmcalLoader()->Digits() ; |
135 | } |
136 | return rv ; |
65549808 |
137 | } |
138 | |
ffa6d63b |
139 | //____________________________________________________________________________ |
88cb7938 |
140 | AliEMCALDigitizer * AliEMCALGetter::Digitizer() |
141 | { |
1ce25ac8 |
142 | // return pointer to Digitizer Tree |
88cb7938 |
143 | AliEMCALDigitizer * rv ; |
144 | rv = dynamic_cast<AliEMCALDigitizer *>(EmcalLoader()->Digitizer()) ; |
145 | if (!rv) { |
146 | Event(0, "D") ; |
147 | rv = dynamic_cast<AliEMCALDigitizer *>(EmcalLoader()->Digitizer()) ; |
148 | } |
149 | return rv ; |
150 | } |
173558f2 |
151 | |
0c87da39 |
152 | |
88cb7938 |
153 | //____________________________________________________________________________ |
1ce25ac8 |
154 | TObjArray * AliEMCALGetter::PRERecPoints() const |
88cb7938 |
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 | //____________________________________________________________________________ |
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 | |
183 | //____________________________________________________________________________ |
1ce25ac8 |
184 | TObjArray * AliEMCALGetter::HCARecPoints() const |
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 | //____________________________________________________________________________ |
1ce25ac8 |
199 | TClonesArray * AliEMCALGetter::TrackSegments() const |
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 | { |
1ce25ac8 |
216 | // return pointer to TrackSegmentMaker Tree |
88cb7938 |
217 | AliEMCALTrackSegmentMaker * rv ; |
218 | rv = dynamic_cast<AliEMCALTrackSegmentMaker *>(EmcalLoader()->TrackSegmentMaker()) ; |
219 | if (!rv) { |
220 | Event(0, "T") ; |
221 | rv = dynamic_cast<AliEMCALTrackSegmentMaker *>(EmcalLoader()->TrackSegmentMaker()) ; |
48f12df6 |
222 | } |
88cb7938 |
223 | return rv ; |
05a92d59 |
224 | } |
6c58180f |
225 | |
05a92d59 |
226 | //____________________________________________________________________________ |
1ce25ac8 |
227 | TClonesArray * AliEMCALGetter::RecParticles() const |
88cb7938 |
228 | { |
229 | // asks the Loader to return the TrackSegments container |
173558f2 |
230 | |
88cb7938 |
231 | TClonesArray * rv = 0 ; |
232 | |
233 | rv = EmcalLoader()->RecParticles() ; |
234 | if (!rv) { |
235 | EmcalLoader()->MakeRecParticlesArray() ; |
236 | rv = EmcalLoader()->RecParticles() ; |
237 | } |
238 | return rv ; |
239 | } |
240 | //____________________________________________________________________________ |
241 | void AliEMCALGetter::Event(const Int_t event, const char* opt) |
05a92d59 |
242 | { |
88cb7938 |
243 | // Reads the content of all Tree's S, D and R |
d489fb96 |
244 | |
88cb7938 |
245 | if ( event >= MaxEvent() ) { |
246 | Error("Event", "%d not found in TreeE !", event) ; |
247 | return ; |
248 | } |
173558f2 |
249 | |
88cb7938 |
250 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
173558f2 |
251 | |
88cb7938 |
252 | // checks if we are dealing with test-beam data |
253 | // TBranch * btb = rl->TreeE()->GetBranch("AliEMCALBeamTestEvent") ; |
254 | // if(btb){ |
255 | // if(!fBTE) |
256 | // fBTE = new AliEMCALBeamTestEvent() ; |
257 | // btb->SetAddress(&fBTE) ; |
258 | // btb->GetEntry(event) ; |
259 | // } |
260 | // else{ |
261 | // if(fBTE){ |
262 | // delete fBTE ; |
263 | // fBTE = 0 ; |
264 | // } |
265 | // } |
173558f2 |
266 | |
88cb7938 |
267 | // Loads the type of object(s) requested |
268 | |
269 | rl->GetEvent(event) ; |
173558f2 |
270 | |
88cb7938 |
271 | if( strstr(opt,"X") || (strcmp(opt,"")==0) ) |
272 | ReadPrimaries() ; |
173558f2 |
273 | |
88cb7938 |
274 | if(strstr(opt,"H") ) |
275 | ReadTreeH(); |
173558f2 |
276 | |
88cb7938 |
277 | if(strstr(opt,"S") ) |
278 | ReadTreeS() ; |
173558f2 |
279 | |
88cb7938 |
280 | if( strstr(opt,"D") ) |
281 | ReadTreeD() ; |
173558f2 |
282 | |
88cb7938 |
283 | if( strstr(opt,"R") ) |
284 | ReadTreeR() ; |
173558f2 |
285 | |
88cb7938 |
286 | if( strstr(opt,"T") ) |
287 | ReadTreeT() ; |
173558f2 |
288 | |
88cb7938 |
289 | if( strstr(opt,"P") ) |
290 | ReadTreeP() ; |
173558f2 |
291 | |
88cb7938 |
292 | // if( strstr(opt,"Q") ) |
293 | // ReadTreeQA() ; |
294 | |
05a92d59 |
295 | } |
296 | |
88cb7938 |
297 | |
05a92d59 |
298 | //____________________________________________________________________________ |
88cb7938 |
299 | Int_t AliEMCALGetter::EventNumber() const |
300 | { |
301 | // return the current event number |
302 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
303 | return static_cast<Int_t>(rl->GetEventNumber()) ; |
304 | } |
173558f2 |
305 | |
88cb7938 |
306 | //____________________________________________________________________________ |
1ce25ac8 |
307 | TClonesArray * AliEMCALGetter::Hits() const |
05a92d59 |
308 | { |
88cb7938 |
309 | // asks the loader to return the Hits container |
310 | |
311 | TClonesArray * rv = 0 ; |
312 | |
313 | rv = EmcalLoader()->Hits() ; |
314 | if ( !rv ) { |
315 | EmcalLoader()->LoadHits("read"); |
316 | rv = EmcalLoader()->Hits() ; |
317 | } |
318 | return rv ; |
05a92d59 |
319 | } |
320 | |
321 | //____________________________________________________________________________ |
88cb7938 |
322 | AliEMCALGetter * AliEMCALGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption) |
05a92d59 |
323 | { |
88cb7938 |
324 | // Creates and returns the pointer of the unique instance |
325 | // Must be called only when the environment has changed |
326 | |
327 | //::Info("Instance","alirunFileName=%s version=%s openingOption=%s",alirunFileName,version,openingOption); |
328 | |
329 | if(!fgObjGetter){ // first time the getter is called |
330 | fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ; |
331 | } |
332 | else { // the getter has been called previously |
333 | AliRunLoader * rl = AliRunLoader::GetRunLoader(fgEmcalLoader->GetTitle()); |
334 | if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name |
335 | // check if the file is already open |
336 | TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ; |
337 | |
338 | if ( !galiceFile ) |
339 | fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ; |
340 | |
341 | else { // the file is already open check the version name |
342 | TString currentVersionName = rl->GetEventFolder()->GetName() ; |
343 | TString newVersionName(version) ; |
344 | if (currentVersionName == newVersionName) |
345 | if(fgDebug) |
346 | ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ; |
347 | else { |
348 | fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ; |
349 | } |
350 | } |
05a92d59 |
351 | } |
88cb7938 |
352 | else |
353 | fgObjGetter = new AliEMCALGetter(alirunFileName, version, openingOption) ; |
05a92d59 |
354 | } |
88cb7938 |
355 | if (!fgObjGetter) |
356 | ::Error("Instance", "Failed to create the EMCAL Getter object") ; |
357 | else |
358 | if (fgDebug) |
359 | Print() ; |
360 | |
361 | return fgObjGetter ; |
ffa6d63b |
362 | } |
363 | |
364 | //____________________________________________________________________________ |
88cb7938 |
365 | AliEMCALGetter * AliEMCALGetter::Instance() |
366 | { |
367 | // Returns the pointer of the unique instance already defined |
368 | |
369 | if(!fgObjGetter) |
370 | ::Error("Instance", "Getter not initialized") ; |
371 | |
372 | return fgObjGetter ; |
373 | |
374 | } |
173558f2 |
375 | |
88cb7938 |
376 | //____________________________________________________________________________ |
377 | Int_t AliEMCALGetter::MaxEvent() const |
ffa6d63b |
378 | { |
88cb7938 |
379 | // returns the number of events in the run (from TE) |
380 | |
381 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
382 | return static_cast<Int_t>(rl->GetNumberOfEvents()) ; |
383 | } |
173558f2 |
384 | |
88cb7938 |
385 | //____________________________________________________________________________ |
386 | TParticle * AliEMCALGetter::Primary(Int_t index) const |
387 | { |
388 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
389 | return rl->Stack()->Particle(index) ; |
390 | } |
173558f2 |
391 | |
88cb7938 |
392 | //____________________________________________________________________________ |
393 | AliEMCAL * AliEMCALGetter:: EMCAL() const |
394 | { |
395 | // returns the EMCAL object |
396 | AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(EmcalLoader()->GetModulesFolder()->FindObject("EMCAL")) ; |
ffa6d63b |
397 | if (!emcal) |
88cb7938 |
398 | if (fgDebug) |
399 | Warning("EMCAL", "EMCAL module not found in module folders: %s", EmcalLoader()->GetModulesFolder()->GetName() ) ; |
ffa6d63b |
400 | return emcal ; |
401 | } |
402 | |
88cb7938 |
403 | |
404 | |
ffa6d63b |
405 | //____________________________________________________________________________ |
88cb7938 |
406 | AliEMCALPID * AliEMCALGetter::PID() |
407 | { |
1ce25ac8 |
408 | // return pointer to PID Tree |
88cb7938 |
409 | AliEMCALPID * rv ; |
410 | rv = dynamic_cast<AliEMCALPID *>(EmcalLoader()->PIDTask()) ; |
411 | if (!rv) { |
412 | Event(0, "P") ; |
413 | rv = dynamic_cast<AliEMCALPID *>(EmcalLoader()->PIDTask()) ; |
414 | } |
415 | return rv ; |
416 | } |
173558f2 |
417 | |
88cb7938 |
418 | //____________________________________________________________________________ |
419 | AliEMCALGeometry * AliEMCALGetter::EMCALGeometry() const |
ffa6d63b |
420 | { |
88cb7938 |
421 | // Returns EMCAL geometry |
422 | |
ffa6d63b |
423 | AliEMCALGeometry * rv = 0 ; |
424 | if (EMCAL() ) |
d75bea67 |
425 | rv = EMCAL()->GetGeometry() ; |
ffa6d63b |
426 | return rv ; |
427 | } |
428 | |
9bd3caba |
429 | //____________________________________________________________________________ |
88cb7938 |
430 | TClonesArray * AliEMCALGetter::Primaries() |
431 | { |
432 | // creates the Primaries container if needed |
433 | if ( !fPrimaries ) { |
434 | if (fgDebug) |
435 | Info("Primaries", "Creating a new TClonesArray for primaries") ; |
436 | fPrimaries = new TClonesArray("TParticle", 1000) ; |
437 | } |
438 | return fPrimaries ; |
439 | } |
9bd3caba |
440 | |
441 | //____________________________________________________________________________ |
88cb7938 |
442 | void AliEMCALGetter::Print() |
443 | { |
444 | // Print usefull information about the getter |
445 | |
446 | AliRunLoader * rl = AliRunLoader::GetRunLoader(fgEmcalLoader->GetTitle()); |
447 | ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ; |
448 | } |
173558f2 |
449 | |
88cb7938 |
450 | //____________________________________________________________________________ |
451 | void AliEMCALGetter::ReadPrimaries() |
452 | { |
453 | // Read Primaries from Kinematics.root |
454 | |
455 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
456 | |
457 | // gets kine tree from the root file (Kinematics.root) |
458 | if ( ! rl->TreeK() ) // load treeK the first time |
459 | rl->LoadKinematics() ; |
460 | |
461 | fNPrimaries = rl->Stack()->GetNtrack() ; |
173558f2 |
462 | |
88cb7938 |
463 | if (fgDebug) |
464 | Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ; |
173558f2 |
465 | |
173558f2 |
466 | |
88cb7938 |
467 | // first time creates the container |
468 | if ( Primaries() ) |
469 | fPrimaries->Clear() ; |
470 | |
471 | Int_t index = 0 ; |
472 | for (index = 0 ; index < fNPrimaries; index++) { |
473 | new ((*fPrimaries)[index]) TParticle(*(Primary(index))); |
9bd3caba |
474 | } |
9bd3caba |
475 | } |
476 | |
ffa6d63b |
477 | //____________________________________________________________________________ |
88cb7938 |
478 | Int_t AliEMCALGetter::ReadTreeD() |
479 | { |
480 | // Read the Digits |
481 | |
482 | |
483 | // gets TreeD from the root file (EMCAL.SDigits.root) |
484 | if ( !IsLoaded("D") ) { |
485 | EmcalLoader()->LoadDigits("UPDATE") ; |
486 | EmcalLoader()->LoadDigitizer("UPDATE") ; |
487 | SetLoaded("D") ; |
488 | } |
489 | return Digits()->GetEntries() ; |
490 | } |
ffa6d63b |
491 | |
492 | //____________________________________________________________________________ |
88cb7938 |
493 | Int_t AliEMCALGetter::ReadTreeH() |
494 | { |
495 | // Read the Hits |
496 | |
497 | // gets TreeH from the root file (EMCAL.Hit.root) |
498 | if ( !IsLoaded("H") ) { |
499 | EmcalLoader()->LoadHits("UPDATE") ; |
500 | SetLoaded("H") ; |
501 | } |
502 | return Hits()->GetEntries() ; |
503 | } |
173558f2 |
504 | |
88cb7938 |
505 | //____________________________________________________________________________ |
506 | Int_t AliEMCALGetter::ReadTreeR() |
507 | { |
508 | // Read the RecPoints |
509 | |
510 | |
511 | // gets TreeR from the root file (EMCAL.RecPoints.root) |
512 | if ( !IsLoaded("R") ) { |
513 | EmcalLoader()->LoadRecPoints("UPDATE") ; |
514 | EmcalLoader()->LoadClusterizer("UPDATE") ; |
515 | SetLoaded("R") ; |
ffa6d63b |
516 | } |
173558f2 |
517 | |
88cb7938 |
518 | return ECARecPoints()->GetEntries() ; |
ffa6d63b |
519 | } |
520 | |
521 | //____________________________________________________________________________ |
88cb7938 |
522 | Int_t AliEMCALGetter::ReadTreeT() |
523 | { |
524 | // Read the TrackSegments |
525 | |
526 | |
527 | // gets TreeT from the root file (EMCAL.TrackSegments.root) |
528 | if ( !IsLoaded("T") ) { |
529 | EmcalLoader()->LoadTracks("UPDATE") ; |
530 | EmcalLoader()->LoadTrackSegmentMaker("UPDATE") ; |
531 | SetLoaded("T") ; |
ffa6d63b |
532 | } |
173558f2 |
533 | |
88cb7938 |
534 | return TrackSegments()->GetEntries() ; |
535 | } |
ffa6d63b |
536 | //____________________________________________________________________________ |
88cb7938 |
537 | Int_t AliEMCALGetter::ReadTreeP() |
538 | { |
539 | // Read the TrackSegments |
540 | |
541 | |
542 | // gets TreeT from the root file (EMCAL.TrackSegments.root) |
543 | if ( !IsLoaded("P") ) { |
544 | EmcalLoader()->LoadRecParticles("UPDATE") ; |
545 | EmcalLoader()->LoadPID("UPDATE") ; |
546 | SetLoaded("P") ; |
547 | } |
173558f2 |
548 | |
88cb7938 |
549 | return RecParticles()->GetEntries() ; |
550 | } |
551 | //____________________________________________________________________________ |
552 | Int_t AliEMCALGetter::ReadTreeS() |
553 | { |
554 | // Read the SDigits |
555 | |
556 | |
557 | // gets TreeS from the root file (EMCAL.SDigits.root) |
558 | if ( !IsLoaded("S") ) { |
559 | EmcalLoader()->LoadSDigits("UPDATE") ; |
560 | EmcalLoader()->LoadSDigitizer("UPDATE") ; |
561 | SetLoaded("S") ; |
562 | } |
ffa6d63b |
563 | |
88cb7938 |
564 | return SDigits()->GetEntries() ; |
565 | } |
173558f2 |
566 | |
88cb7938 |
567 | //____________________________________________________________________________ |
1ce25ac8 |
568 | TClonesArray * AliEMCALGetter::SDigits() const |
88cb7938 |
569 | { |
570 | // asks the Loader to return the Digits container |
173558f2 |
571 | |
88cb7938 |
572 | TClonesArray * rv = 0 ; |
573 | |
574 | rv = EmcalLoader()->SDigits() ; |
575 | if (!rv) { |
576 | EmcalLoader()->MakeSDigitsArray() ; |
577 | rv = EmcalLoader()->SDigits() ; |
ffa6d63b |
578 | } |
88cb7938 |
579 | return rv ; |
580 | } |
ffa6d63b |
581 | |
88cb7938 |
582 | //____________________________________________________________________________ |
583 | AliEMCALSDigitizer * AliEMCALGetter::SDigitizer() |
584 | { |
1ce25ac8 |
585 | // return pointer to SDigitizer Tree |
88cb7938 |
586 | AliEMCALSDigitizer * rv ; |
587 | rv = dynamic_cast<AliEMCALSDigitizer *>(EmcalLoader()->SDigitizer()) ; |
588 | if (!rv) { |
589 | Event(0, "S") ; |
590 | rv = dynamic_cast<AliEMCALSDigitizer *>(EmcalLoader()->SDigitizer()) ; |
ffa6d63b |
591 | } |
88cb7938 |
592 | return rv ; |
593 | } |
594 | |
595 | //____________________________________________________________________________ |
596 | TParticle * AliEMCALGetter::Secondary(const TParticle* p, const Int_t index) const |
597 | { |
598 | // Return first (index=1) or second (index=2) secondary particle of primary particle p |
ffa6d63b |
599 | |
88cb7938 |
600 | if(index <= 0) |
601 | return 0 ; |
602 | if(index > 2) |
603 | return 0 ; |
173558f2 |
604 | |
88cb7938 |
605 | if(p) { |
606 | Int_t daughterIndex = p->GetDaughter(index-1) ; |
607 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
5d12ce38 |
608 | return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; |
05a92d59 |
609 | } |
88cb7938 |
610 | else |
611 | return 0 ; |
ffa6d63b |
612 | } |
613 | |
614 | //____________________________________________________________________________ |
88cb7938 |
615 | void AliEMCALGetter::Track(const Int_t itrack) |
616 | { |
617 | // Read the first entry of EMCAL branch in hit tree gAlice->TreeH() |
618 | |
619 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
173558f2 |
620 | |
88cb7938 |
621 | if( !TreeH() ) // load treeH the first time |
622 | rl->LoadHits() ; |
ffa6d63b |
623 | |
88cb7938 |
624 | // first time create the container |
625 | TClonesArray * hits = Hits() ; |
626 | if ( hits ) |
627 | hits->Clear() ; |
173558f2 |
628 | |
88cb7938 |
629 | TBranch * emcalbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("EMCAL")) ; |
630 | emcalbranch->SetAddress(&hits) ; |
631 | emcalbranch->GetEntry(itrack) ; |
632 | } |
ffa6d63b |
633 | |
ffa6d63b |
634 | //____________________________________________________________________________ |
88cb7938 |
635 | TTree * AliEMCALGetter::TreeD() const |
ffa6d63b |
636 | { |
1ce25ac8 |
637 | // return pointer to Digits Tree |
88cb7938 |
638 | TTree * rv = 0 ; |
639 | rv = EmcalLoader()->TreeD() ; |
640 | if ( !rv ) { |
641 | EmcalLoader()->MakeTree("D"); |
642 | rv = EmcalLoader()->TreeD() ; |
9859bfc0 |
643 | } |
88cb7938 |
644 | |
645 | return rv ; |
ffa6d63b |
646 | } |
9bd3caba |
647 | |
ffa6d63b |
648 | //____________________________________________________________________________ |
88cb7938 |
649 | TTree * AliEMCALGetter::TreeH() const |
ffa6d63b |
650 | { |
1ce25ac8 |
651 | // return pointer to Hits Tree |
88cb7938 |
652 | TTree * rv = 0 ; |
653 | rv = EmcalLoader()->TreeH() ; |
654 | if ( !rv ) { |
655 | EmcalLoader()->MakeTree("H"); |
656 | rv = EmcalLoader()->TreeH() ; |
657 | } |
658 | |
659 | return rv ; |
9859bfc0 |
660 | } |
173558f2 |
661 | |
ffa6d63b |
662 | //____________________________________________________________________________ |
88cb7938 |
663 | TTree * AliEMCALGetter::TreeR() const |
ffa6d63b |
664 | { |
1ce25ac8 |
665 | // return pointer to RecPoints Tree |
666 | |
88cb7938 |
667 | TTree * rv = 0 ; |
668 | rv = EmcalLoader()->TreeR() ; |
669 | if ( !rv ) { |
670 | EmcalLoader()->MakeTree("R"); |
671 | rv = EmcalLoader()->TreeR() ; |
672 | } |
673 | |
674 | return rv ; |
ffa6d63b |
675 | } |
173558f2 |
676 | |
ffa6d63b |
677 | //____________________________________________________________________________ |
88cb7938 |
678 | TTree * AliEMCALGetter::TreeT() const |
1ce25ac8 |
679 | { |
680 | // return pointer to TrackSegments Tree |
88cb7938 |
681 | TTree * rv = 0 ; |
682 | rv = EmcalLoader()->TreeT() ; |
683 | if ( !rv ) { |
684 | EmcalLoader()->MakeTree("T"); |
685 | rv = EmcalLoader()->TreeT() ; |
686 | } |
516fff8e |
687 | |
88cb7938 |
688 | return rv ; |
ffa6d63b |
689 | } |
65549808 |
690 | //____________________________________________________________________________ |
88cb7938 |
691 | TTree * AliEMCALGetter::TreeP() const |
65549808 |
692 | { |
1ce25ac8 |
693 | // return pointer to RecParticles Tree |
88cb7938 |
694 | TTree * rv = 0 ; |
695 | rv = EmcalLoader()->TreeP() ; |
696 | if ( !rv ) { |
697 | EmcalLoader()->MakeTree("P"); |
698 | rv = EmcalLoader()->TreeP() ; |
05a92d59 |
699 | } |
88cb7938 |
700 | |
701 | return rv ; |
65549808 |
702 | } |
173558f2 |
703 | |
65549808 |
704 | //____________________________________________________________________________ |
88cb7938 |
705 | TTree * AliEMCALGetter::TreeS() const |
65549808 |
706 | { |
1ce25ac8 |
707 | // return pointer to SDigits Tree |
88cb7938 |
708 | TTree * rv = 0 ; |
709 | rv = EmcalLoader()->TreeS() ; |
710 | if ( !rv ) { |
711 | EmcalLoader()->MakeTree("S"); |
712 | rv = EmcalLoader()->TreeS() ; |
713 | } |
714 | |
715 | return rv ; |
65549808 |
716 | } |
717 | |
718 | //____________________________________________________________________________ |
88cb7938 |
719 | Bool_t AliEMCALGetter::VersionExists(TString & opt) const |
65549808 |
720 | { |
88cb7938 |
721 | // checks if the version with the present name already exists in the same directory |
05a92d59 |
722 | |
88cb7938 |
723 | Bool_t rv = kFALSE ; |
724 | |
725 | AliRunLoader * rl = AliRunLoader::GetRunLoader(EmcalLoader()->GetTitle()); |
726 | TString version( rl->GetEventFolder()->GetName() ) ; |
173558f2 |
727 | |
88cb7938 |
728 | opt.ToLower() ; |
729 | |
730 | if ( opt == "sdigits") { |
731 | // add the version name to the root file name |
732 | TString fileName( EmcalLoader()->GetSDigitsFileName() ) ; |
733 | if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name |
734 | fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ; |
735 | if ( !(gSystem->AccessPathName(fileName)) ) { |
736 | Warning("VersionExists", "The file %s already exists", fileName.Data()) ; |
737 | rv = kTRUE ; |
05a92d59 |
738 | } |
88cb7938 |
739 | EmcalLoader()->SetSDigitsFileName(fileName) ; |
05a92d59 |
740 | } |
173558f2 |
741 | |
88cb7938 |
742 | if ( opt == "digits") { |
743 | // add the version name to the root file name |
744 | TString fileName( EmcalLoader()->GetDigitsFileName() ) ; |
745 | if (version != AliConfig::fgkDefaultEventFolderName) // only if not the default folder name |
746 | fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ; |
747 | if ( !(gSystem->AccessPathName(fileName)) ) { |
748 | Warning("VersionExists", "The file %s already exists", fileName.Data()) ; |
749 | rv = kTRUE ; |
05a92d59 |
750 | } |
88cb7938 |
751 | EmcalLoader()->SetDigitsFileName(fileName) ; |
05a92d59 |
752 | } |
753 | |
88cb7938 |
754 | return rv ; |
173558f2 |
755 | |
05a92d59 |
756 | } |
173558f2 |
757 | |
05a92d59 |
758 | //____________________________________________________________________________ |
88cb7938 |
759 | UShort_t AliEMCALGetter::EventPattern(void) const |
05a92d59 |
760 | { |
88cb7938 |
761 | // Return the pattern (trigger bit register) of the beam-test event |
762 | // if(fBTE) |
763 | // return fBTE->GetPattern() ; |
764 | // else |
765 | return 0 ; |
05a92d59 |
766 | } |
767 | //____________________________________________________________________________ |
88cb7938 |
768 | Float_t AliEMCALGetter::BeamEnergy(void) const |
769 | { |
770 | // Return the beam energy of the beam-test event |
771 | // if(fBTE) |
772 | // return fBTE->GetBeamEnergy() ; |
773 | // else |
774 | return 0 ; |
9859bfc0 |
775 | } |