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