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