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