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