]>
Commit | Line | Data |
---|---|---|
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 "TFile.h" |
4ae78bb1 | 45 | #include "TROOT.h" |
88cb7938 | 46 | |
4ae78bb1 | 47 | |
48 | // --- Standard library --- | |
4ae78bb1 | 49 | |
50 | // --- AliRoot header files --- | |
88cb7938 | 51 | |
4ae78bb1 | 52 | #include "AliPHOSGetter.h" |
88cb7938 | 53 | #include "AliRunLoader.h" |
54 | #include "AliStack.h" | |
55 | #include "AliPHOSLoader.h" | |
56 | // #include "AliPHOSRaw2Digits.h" | |
7bb289a7 | 57 | //#include "AliPHOSCalibrationDB.h" |
58 | #include "AliPHOSBeamTestEvent.h" | |
88cb7938 | 59 | |
4ae78bb1 | 60 | ClassImp(AliPHOSGetter) |
61 | ||
88cb7938 | 62 | AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ; |
63 | AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0; | |
64 | Int_t AliPHOSGetter::fgDebug = 0; | |
65 | ||
66 | // TFile * AliPHOSGetter::fgFile = 0 ; | |
4ae78bb1 | 67 | |
68 | //____________________________________________________________________________ | |
88cb7938 | 69 | AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) |
4ae78bb1 | 70 | { |
88cb7938 | 71 | // ctor only called by Instance() |
4ae78bb1 | 72 | |
88cb7938 | 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 | } | |
fbf811ec | 84 | } |
88cb7938 | 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 | } | |
9bd3caba | 98 | |
88cb7938 | 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 | } | |
fbf811ec | 110 | |
88cb7938 | 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 | } | |
4ae78bb1 | 122 | |
88cb7938 | 123 | //____________________________________________________________________________ |
124 | TObjArray * AliPHOSGetter::CpvRecPoints() | |
125 | { | |
126 | // asks the Loader to return the CPV RecPoints container | |
4ae78bb1 | 127 | |
88cb7938 | 128 | TObjArray * rv = 0 ; |
129 | ||
130 | rv = PhosLoader()->CpvRecPoints() ; | |
131 | if (!rv) { | |
132 | PhosLoader()->MakeRecPointsArray() ; | |
133 | rv = PhosLoader()->CpvRecPoints() ; | |
134 | } | |
135 | return rv ; | |
136 | } | |
dca3a7c4 | 137 | |
88cb7938 | 138 | //____________________________________________________________________________ |
139 | TClonesArray * AliPHOSGetter::Digits() | |
140 | { | |
141 | // asks the Loader to return the Digits container | |
7bb289a7 | 142 | |
88cb7938 | 143 | TClonesArray * rv = 0 ; |
144 | rv = PhosLoader()->Digits() ; | |
7bb289a7 | 145 | |
88cb7938 | 146 | if( !rv ) { |
147 | PhosLoader()->MakeDigitsArray() ; | |
148 | rv = PhosLoader()->Digits() ; | |
4ae78bb1 | 149 | } |
88cb7938 | 150 | return rv ; |
151 | } | |
4b808d52 | 152 | |
88cb7938 | 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 ; | |
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 | //____________________________________________________________________________ |
88cb7938 | 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()) ; | |
0c87da39 | 204 | } |
88cb7938 | 205 | return rv ; |
0c87da39 | 206 | } |
207 | ||
4ae78bb1 | 208 | //____________________________________________________________________________ |
88cb7938 | 209 | TClonesArray * AliPHOSGetter::RecParticles() |
4ae78bb1 | 210 | { |
88cb7938 | 211 | // asks the Loader to return the TrackSegments container |
212 | ||
213 | TClonesArray * rv = 0 ; | |
4ae78bb1 | 214 | |
88cb7938 | 215 | rv = PhosLoader()->RecParticles() ; |
216 | if (!rv) { | |
217 | PhosLoader()->MakeRecParticlesArray() ; | |
218 | rv = PhosLoader()->RecParticles() ; | |
b134c32f | 219 | } |
88cb7938 | 220 | return rv ; |
4ae78bb1 | 221 | } |
4ae78bb1 | 222 | //____________________________________________________________________________ |
88cb7938 | 223 | void AliPHOSGetter::Event(const Int_t event, const char* opt) |
4ae78bb1 | 224 | { |
88cb7938 | 225 | // Reads the content of all Tree's S, D and R |
548f0134 | 226 | |
88cb7938 | 227 | if ( event >= MaxEvent() ) { |
228 | Error("Event", "%d not found in TreeE !", event) ; | |
229 | return ; | |
fbf811ec | 230 | } |
4ae78bb1 | 231 | |
88cb7938 | 232 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
df25f7dd | 233 | |
88cb7938 | 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) ; | |
fbf811ec | 241 | } |
88cb7938 | 242 | else{ |
243 | if(fBTE){ | |
244 | delete fBTE ; | |
245 | fBTE = 0 ; | |
fbf811ec | 246 | } |
fbf811ec | 247 | } |
88cb7938 | 248 | |
249 | // Loads the type of object(s) requested | |
b134c32f | 250 | |
88cb7938 | 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()) ; | |
fbf811ec | 286 | } |
d489fb96 | 287 | |
fbf811ec | 288 | //____________________________________________________________________________ |
88cb7938 | 289 | TClonesArray * AliPHOSGetter::Hits() |
fbf811ec | 290 | { |
88cb7938 | 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() ; | |
fbf811ec | 299 | } |
88cb7938 | 300 | return rv ; |
301 | } | |
fbf811ec | 302 | |
88cb7938 | 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 | |
d489fb96 | 308 | |
88cb7938 | 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) ; | |
fbf811ec | 313 | } |
88cb7938 | 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) ; | |
48f12df6 | 336 | } |
88cb7938 | 337 | if (!fgObjGetter) |
338 | ::Error("Instance", "Failed to create the PHOS Getter object") ; | |
339 | else | |
340 | if (fgDebug) | |
341 | Print() ; | |
4ae78bb1 | 342 | |
88cb7938 | 343 | return fgObjGetter ; |
4ae78bb1 | 344 | } |
345 | ||
6ad0e528 | 346 | //____________________________________________________________________________ |
88cb7938 | 347 | AliPHOSGetter * AliPHOSGetter::Instance() |
6ad0e528 | 348 | { |
88cb7938 | 349 | // Returns the pointer of the unique instance already defined |
fbf811ec | 350 | |
88cb7938 | 351 | if(!fgObjGetter) |
352 | ::Error("Instance", "Getter not initialized") ; | |
6ad0e528 | 353 | |
88cb7938 | 354 | return fgObjGetter ; |
355 | ||
6ad0e528 | 356 | } |
357 | ||
358 | //____________________________________________________________________________ | |
88cb7938 | 359 | Int_t AliPHOSGetter::MaxEvent() const |
6ad0e528 | 360 | { |
88cb7938 | 361 | // returns the number of events in the run (from TE) |
0bc3b8ed | 362 | |
88cb7938 | 363 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
364 | return static_cast<Int_t>(rl->GetNumberOfEvents()) ; | |
6ad0e528 | 365 | } |
366 | ||
367 | //____________________________________________________________________________ | |
88cb7938 | 368 | TParticle * AliPHOSGetter::Primary(Int_t index) const |
6ad0e528 | 369 | { |
88cb7938 | 370 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
371 | return rl->Stack()->Particle(index) ; | |
372 | } | |
6ad0e528 | 373 | |
4ae78bb1 | 374 | //____________________________________________________________________________ |
88cb7938 | 375 | AliPHOS * AliPHOSGetter:: PHOS() const |
4ae78bb1 | 376 | { |
377 | // returns the PHOS object | |
88cb7938 | 378 | AliPHOS * phos = dynamic_cast<AliPHOS*>(PhosLoader()->GetModulesFolder()->FindObject("PHOS")) ; |
7a9d98f9 | 379 | if (!phos) |
88cb7938 | 380 | if (fgDebug) |
381 | Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ; | |
7a9d98f9 | 382 | return phos ; |
4ae78bb1 | 383 | } |
384 | ||
88cb7938 | 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 | ||
4ae78bb1 | 399 | //____________________________________________________________________________ |
88cb7938 | 400 | AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const |
4ae78bb1 | 401 | { |
0bc3b8ed | 402 | // Returns PHOS geometry |
403 | ||
7a9d98f9 | 404 | AliPHOSGeometry * rv = 0 ; |
405 | if (PHOS() ) | |
406 | rv = PHOS()->GetGeometry() ; | |
407 | return rv ; | |
408 | } | |
4ae78bb1 | 409 | |
cb34a1fa | 410 | //____________________________________________________________________________ |
88cb7938 | 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 | } | |
cb34a1fa | 430 | |
88cb7938 | 431 | //____________________________________________________________________________ |
432 | void AliPHOSGetter::ReadPrimaries() | |
433 | { | |
434 | // Read Primaries from Kinematics.root | |
cb34a1fa | 435 | |
88cb7938 | 436 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
cb34a1fa | 437 | |
88cb7938 | 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() ) ; | |
cb34a1fa | 446 | |
cb34a1fa | 447 | |
88cb7938 | 448 | // first time creates the container |
449 | if ( Primaries() ) | |
450 | fPrimaries->Clear() ; | |
cb34a1fa | 451 | |
88cb7938 | 452 | Int_t index = 0 ; |
453 | for (index = 0 ; index < fNPrimaries; index++) { | |
454 | new ((*fPrimaries)[index]) TParticle(*(Primary(index))); | |
cb34a1fa | 455 | } |
cb34a1fa | 456 | } |
457 | ||
b0bba0af | 458 | //____________________________________________________________________________ |
88cb7938 | 459 | Int_t AliPHOSGetter::ReadTreeD() |
460 | { | |
461 | // Read the Digits | |
b0bba0af | 462 | |
7a9d98f9 | 463 | |
88cb7938 | 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 | } | |
7a9d98f9 | 472 | |
b0bba0af | 473 | //____________________________________________________________________________ |
88cb7938 | 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 | } | |
4ae78bb1 | 485 | |
88cb7938 | 486 | //____________________________________________________________________________ |
487 | Int_t AliPHOSGetter::ReadTreeR() | |
488 | { | |
489 | // Read the RecPoints | |
b0bba0af | 490 | |
88cb7938 | 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") ; | |
7a9d98f9 | 497 | } |
f1611b7c | 498 | |
88cb7938 | 499 | return EmcRecPoints()->GetEntries() ; |
b0bba0af | 500 | } |
7a9d98f9 | 501 | |
b0bba0af | 502 | //____________________________________________________________________________ |
88cb7938 | 503 | Int_t AliPHOSGetter::ReadTreeT() |
504 | { | |
505 | // Read the TrackSegments | |
7a9d98f9 | 506 | |
407ae4df | 507 | |
88cb7938 | 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") ; | |
407ae4df | 513 | } |
fbf811ec | 514 | |
88cb7938 | 515 | return TrackSegments()->GetEntries() ; |
516 | } | |
b0bba0af | 517 | //____________________________________________________________________________ |
88cb7938 | 518 | Int_t AliPHOSGetter::ReadTreeP() |
519 | { | |
520 | // Read the TrackSegments | |
b0bba0af | 521 | |
88cb7938 | 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") ; | |
7a9d98f9 | 528 | } |
529 | ||
88cb7938 | 530 | return RecParticles()->GetEntries() ; |
531 | } | |
532 | //____________________________________________________________________________ | |
533 | Int_t AliPHOSGetter::ReadTreeS() | |
534 | { | |
535 | // Read the SDigits | |
536 | ||
7a9d98f9 | 537 | |
88cb7938 | 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") ; | |
7a9d98f9 | 543 | } |
b0bba0af | 544 | |
88cb7938 | 545 | return SDigits()->GetEntries() ; |
546 | } | |
f1611b7c | 547 | |
88cb7938 | 548 | //____________________________________________________________________________ |
549 | TClonesArray * AliPHOSGetter::SDigits() | |
550 | { | |
551 | // asks the Loader to return the Digits container | |
b0bba0af | 552 | |
88cb7938 | 553 | TClonesArray * rv = 0 ; |
554 | ||
555 | rv = PhosLoader()->SDigits() ; | |
556 | if (!rv) { | |
557 | PhosLoader()->MakeSDigitsArray() ; | |
558 | rv = PhosLoader()->SDigits() ; | |
559 | } | |
560 | return rv ; | |
b0bba0af | 561 | } |
562 | ||
563 | //____________________________________________________________________________ | |
88cb7938 | 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()) ; | |
b0bba0af | 571 | } |
88cb7938 | 572 | return rv ; |
b0bba0af | 573 | } |
7a9d98f9 | 574 | |
b0bba0af | 575 | //____________________________________________________________________________ |
88cb7938 | 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 ; | |
b0bba0af | 584 | |
88cb7938 | 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 | } | |
4ae78bb1 | 593 | |
88cb7938 | 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()); | |
b0bba0af | 600 | |
88cb7938 | 601 | if( !TreeH() ) // load treeH the first time |
602 | rl->LoadHits() ; | |
b0bba0af | 603 | |
88cb7938 | 604 | // first time create the container |
605 | TClonesArray * hits = Hits() ; | |
606 | if ( hits ) | |
607 | hits->Clear() ; | |
b0bba0af | 608 | |
88cb7938 | 609 | TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ; |
610 | phosbranch->SetAddress(&hits) ; | |
611 | phosbranch->GetEntry(itrack) ; | |
b0bba0af | 612 | } |
613 | ||
b0bba0af | 614 | //____________________________________________________________________________ |
88cb7938 | 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() ; | |
b0bba0af | 622 | } |
b0bba0af | 623 | |
88cb7938 | 624 | return rv ; |
b0bba0af | 625 | } |
548f0134 | 626 | |
b0bba0af | 627 | //____________________________________________________________________________ |
88cb7938 | 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 ; | |
b0bba0af | 638 | } |
7a9d98f9 | 639 | |
b0bba0af | 640 | //____________________________________________________________________________ |
88cb7938 | 641 | TTree * AliPHOSGetter::TreeR() const |
0bc3b8ed | 642 | { |
88cb7938 | 643 | TTree * rv = 0 ; |
644 | rv = PhosLoader()->TreeR() ; | |
645 | if ( !rv ) { | |
646 | PhosLoader()->MakeTree("R"); | |
647 | rv = PhosLoader()->TreeR() ; | |
648 | } | |
b0bba0af | 649 | |
88cb7938 | 650 | return rv ; |
b0bba0af | 651 | } |
652 | ||
b0bba0af | 653 | //____________________________________________________________________________ |
88cb7938 | 654 | TTree * AliPHOSGetter::TreeT() const |
0bc3b8ed | 655 | { |
88cb7938 | 656 | TTree * rv = 0 ; |
657 | rv = PhosLoader()->TreeT() ; | |
658 | if ( !rv ) { | |
659 | PhosLoader()->MakeTree("T"); | |
660 | rv = PhosLoader()->TreeT() ; | |
661 | } | |
b0bba0af | 662 | |
88cb7938 | 663 | return rv ; |
b0bba0af | 664 | } |
b0bba0af | 665 | //____________________________________________________________________________ |
88cb7938 | 666 | TTree * AliPHOSGetter::TreeP() const |
0bc3b8ed | 667 | { |
88cb7938 | 668 | TTree * rv = 0 ; |
669 | rv = PhosLoader()->TreeP() ; | |
670 | if ( !rv ) { | |
671 | PhosLoader()->MakeTree("P"); | |
672 | rv = PhosLoader()->TreeP() ; | |
673 | } | |
4ae78bb1 | 674 | |
88cb7938 | 675 | return rv ; |
b0bba0af | 676 | } |
677 | ||
678 | //____________________________________________________________________________ | |
88cb7938 | 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() ; | |
b0bba0af | 686 | } |
b0bba0af | 687 | |
88cb7938 | 688 | return rv ; |
b0bba0af | 689 | } |
7a9d98f9 | 690 | |
b0bba0af | 691 | //____________________________________________________________________________ |
88cb7938 | 692 | Bool_t AliPHOSGetter::VersionExists(TString & opt) const |
693 | { | |
694 | // checks if the version with the present name already exists in the same directory | |
7a9d98f9 | 695 | |
88cb7938 | 696 | Bool_t rv = kFALSE ; |
697 | ||
698 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); | |
699 | TString version( rl->GetEventFolder()->GetName() ) ; | |
7a9d98f9 | 700 | |
88cb7938 | 701 | opt.ToLower() ; |
b0bba0af | 702 | |
88cb7938 | 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 ; | |
4ae78bb1 | 711 | } |
88cb7938 | 712 | PhosLoader()->SetSDigitsFileName(fileName) ; |
b0bba0af | 713 | } |
7a9d98f9 | 714 | |
88cb7938 | 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 ; | |
7a9d98f9 | 723 | } |
88cb7938 | 724 | PhosLoader()->SetDigitsFileName(fileName) ; |
b0bba0af | 725 | } |
7a9d98f9 | 726 | |
88cb7938 | 727 | return rv ; |
7a9d98f9 | 728 | |
b0bba0af | 729 | } |
88cb7938 | 730 | |
7bb289a7 | 731 | //____________________________________________________________________________ |
88cb7938 | 732 | UShort_t AliPHOSGetter::EventPattern(void) const |
0bc3b8ed | 733 | { |
734 | // Return the pattern (trigger bit register) of the beam-test event | |
7bb289a7 | 735 | if(fBTE) |
736 | return fBTE->GetPattern() ; | |
737 | else | |
738 | return 0 ; | |
739 | } | |
740 | //____________________________________________________________________________ | |
88cb7938 | 741 | Float_t AliPHOSGetter::BeamEnergy(void) const |
0bc3b8ed | 742 | { |
743 | // Return the beam energy of the beam-test event | |
7bb289a7 | 744 | if(fBTE) |
745 | return fBTE->GetBeamEnergy() ; | |
746 | else | |
747 | return 0 ; | |
748 | } |