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