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