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