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