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