]>
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 <TF1.h> |
e4d04cf1 | 48 | #include <TGraph.h> |
2bb77d5e | 49 | #include <TCanvas.h> |
50 | #include <TStyle.h> | |
351dd634 | 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" | |
431a9211 | 63 | #include "AliPHOSPulseGenerator.h" |
88cb7938 | 64 | #include "AliRunLoader.h" |
65 | #include "AliStack.h" | |
d84933b0 | 66 | #include "AliCaloRawStream.h" |
a43c51c3 | 67 | #include "AliRawReaderFile.h" |
e4d04cf1 | 68 | #include "AliLog.h" |
7ca0684e | 69 | #include "AliCDBLocal.h" |
70 | #include "AliCDBStorage.h" | |
9e1ceb13 | 71 | #include "AliCDBManager.h" |
88cb7938 | 72 | |
4ae78bb1 | 73 | ClassImp(AliPHOSGetter) |
74 | ||
2bb77d5e | 75 | AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ; |
76 | AliPHOSLoader * AliPHOSGetter::fgPhosLoader = 0; | |
77 | AliPHOSCalibData* AliPHOSGetter::fgCalibData = 0; | |
88cb7938 | 78 | Int_t AliPHOSGetter::fgDebug = 0; |
79 | ||
80 | // TFile * AliPHOSGetter::fgFile = 0 ; | |
4ae78bb1 | 81 | |
3663622c | 82 | AliPHOSGetter::AliPHOSGetter() : |
83 | fBTE(0), | |
84 | fLoadingStatus(), | |
85 | fNPrimaries(0), | |
86 | fPrimaries(0), | |
87 | fESDFile(0), | |
88 | fESDFileName(), | |
89 | fESD(0), | |
90 | fESDTree(0), | |
91 | fRawDigits(kFALSE), | |
92 | fcdb(0) | |
93 | { | |
94 | // ctor: this is a singleton, the ctor should never be called but cint needs it as public | |
95 | Fatal("ctor", "AliPHOSGetter is a singleton default ctor not callable") ; | |
96 | } | |
97 | ||
98 | ||
4ae78bb1 | 99 | //____________________________________________________________________________ |
3663622c | 100 | AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* version, Option_t * openingOption) : |
101 | fBTE(0), | |
102 | fLoadingStatus(), | |
103 | fNPrimaries(0), | |
104 | fPrimaries(0), | |
105 | fESDFile(0), | |
106 | fESDFileName(), | |
107 | fESD(0), | |
108 | fESDTree(0), | |
109 | fRawDigits(kFALSE), | |
110 | fcdb(0) | |
4ae78bb1 | 111 | { |
88cb7938 | 112 | // ctor only called by Instance() |
4ae78bb1 | 113 | |
88cb7938 | 114 | AliRunLoader* rl = AliRunLoader::GetRunLoader(version) ; |
115 | if (!rl) { | |
116 | rl = AliRunLoader::Open(headerFile, version, openingOption); | |
117 | if (!rl) { | |
118 | Fatal("AliPHOSGetter", "Could not find the Run Loader for %s - %s",headerFile, version) ; | |
119 | return ; | |
120 | } | |
121 | if (rl->GetAliRun() == 0x0) { | |
122 | rl->LoadgAlice(); | |
123 | gAlice = rl->GetAliRun(); // should be removed | |
12a7cec1 | 124 | rl->LoadHeader(); |
88cb7938 | 125 | } |
fbf811ec | 126 | } |
88cb7938 | 127 | fgPhosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader")); |
128 | if ( !fgPhosLoader ) | |
129 | Error("AliPHOSGetter", "Could not find PHOSLoader") ; | |
130 | else | |
131 | fgPhosLoader->SetTitle(version); | |
132 | ||
88cb7938 | 133 | // initialize data members |
134 | SetDebug(0) ; | |
135 | fBTE = 0 ; | |
136 | fPrimaries = 0 ; | |
137 | fLoadingStatus = "" ; | |
d2713783 | 138 | |
139 | fESDFileName = rl->GetFileName() ; // this should be the galice.root file | |
140 | fESDFileName.ReplaceAll("galice.root", "AliESDs.root") ; | |
95635748 | 141 | fESDFile = 0 ; |
677c8a30 | 142 | fESD = 0 ; |
143 | fESDTree = 0 ; | |
66f895c8 | 144 | fRawDigits = kFALSE ; |
7ca0684e | 145 | |
88cb7938 | 146 | } |
9bd3caba | 147 | |
3663622c | 148 | AliPHOSGetter::AliPHOSGetter(const AliPHOSGetter & obj) : |
149 | TObject(obj), | |
150 | fBTE(0), | |
151 | fLoadingStatus(), | |
152 | fNPrimaries(0), | |
153 | fPrimaries(0), | |
154 | fESDFile(0), | |
155 | fESDFileName(), | |
156 | fESD(0), | |
157 | fESDTree(0), | |
158 | fRawDigits(kFALSE), | |
159 | fcdb(0) | |
160 | { | |
161 | // cpy ctor requested by Coding Convention | |
162 | Fatal("cpy ctor", "not implemented") ; | |
163 | } | |
164 | ||
165 | //____________________________________________________________________________ | |
166 | AliPHOSGetter::AliPHOSGetter(Int_t /*i*/) : | |
167 | fBTE(0), | |
168 | fLoadingStatus(), | |
169 | fNPrimaries(0), | |
170 | fPrimaries(0), | |
171 | fESDFile(0), | |
172 | fESDFileName(), | |
173 | fESD(0), | |
174 | fESDTree(0), | |
175 | fRawDigits(kFALSE), | |
176 | fcdb(0) | |
177 | { | |
178 | // special constructor for onflight | |
179 | } | |
180 | ||
181 | ||
88cb7938 | 182 | //____________________________________________________________________________ |
183 | AliPHOSGetter::~AliPHOSGetter() | |
184 | { | |
185 | // dtor | |
66f895c8 | 186 | if(fgPhosLoader){ |
187 | delete fgPhosLoader ; | |
188 | fgPhosLoader = 0 ; | |
189 | } | |
190 | if(fBTE){ | |
191 | delete fBTE ; | |
192 | fBTE = 0 ; | |
193 | } | |
194 | if(fPrimaries){ | |
195 | fPrimaries->Delete() ; | |
196 | delete fPrimaries ; | |
197 | } | |
677c8a30 | 198 | if (fESD) |
199 | delete fESD ; | |
200 | if (fESDTree) | |
66f895c8 | 201 | delete fESDTree ; |
202 | ||
7c193632 | 203 | fgObjGetter = 0; |
0ef40383 | 204 | } |
205 | ||
206 | //____________________________________________________________________________ | |
207 | void AliPHOSGetter::Reset() | |
208 | { | |
209 | // resets things in case the getter is called consecutively with different files | |
210 | // the PHOS Loader is already deleted by the Run Loader | |
211 | ||
212 | if (fPrimaries) { | |
213 | fPrimaries->Delete() ; | |
214 | delete fPrimaries ; | |
215 | } | |
216 | fgPhosLoader = 0; | |
217 | fgObjGetter = 0; | |
88cb7938 | 218 | } |
fbf811ec | 219 | |
88cb7938 | 220 | //____________________________________________________________________________ |
221 | AliPHOSClusterizer * AliPHOSGetter::Clusterizer() | |
222 | { | |
e957fea8 | 223 | // Returns pointer to the Clusterizer task |
88cb7938 | 224 | AliPHOSClusterizer * rv ; |
225 | rv = dynamic_cast<AliPHOSClusterizer *>(PhosLoader()->Reconstructioner()) ; | |
226 | if (!rv) { | |
227 | Event(0, "R") ; | |
228 | rv = dynamic_cast<AliPHOSClusterizer*>(PhosLoader()->Reconstructioner()) ; | |
229 | } | |
230 | return rv ; | |
231 | } | |
4ae78bb1 | 232 | |
88cb7938 | 233 | //____________________________________________________________________________ |
2bb77d5e | 234 | TObjArray * AliPHOSGetter::CpvRecPoints() const |
88cb7938 | 235 | { |
236 | // asks the Loader to return the CPV RecPoints container | |
4ae78bb1 | 237 | |
88cb7938 | 238 | TObjArray * rv = 0 ; |
239 | ||
240 | rv = PhosLoader()->CpvRecPoints() ; | |
241 | if (!rv) { | |
242 | PhosLoader()->MakeRecPointsArray() ; | |
243 | rv = PhosLoader()->CpvRecPoints() ; | |
244 | } | |
245 | return rv ; | |
246 | } | |
dca3a7c4 | 247 | |
88cb7938 | 248 | //____________________________________________________________________________ |
2bb77d5e | 249 | TClonesArray * AliPHOSGetter::Digits() const |
88cb7938 | 250 | { |
251 | // asks the Loader to return the Digits container | |
7bb289a7 | 252 | |
88cb7938 | 253 | TClonesArray * rv = 0 ; |
254 | rv = PhosLoader()->Digits() ; | |
7bb289a7 | 255 | |
88cb7938 | 256 | if( !rv ) { |
257 | PhosLoader()->MakeDigitsArray() ; | |
258 | rv = PhosLoader()->Digits() ; | |
4ae78bb1 | 259 | } |
88cb7938 | 260 | return rv ; |
261 | } | |
4b808d52 | 262 | |
88cb7938 | 263 | //____________________________________________________________________________ |
264 | AliPHOSDigitizer * AliPHOSGetter::Digitizer() | |
265 | { | |
e957fea8 | 266 | // Returns pointer to the Digitizer task |
88cb7938 | 267 | AliPHOSDigitizer * rv ; |
268 | rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ; | |
269 | if (!rv) { | |
270 | Event(0, "D") ; | |
271 | rv = dynamic_cast<AliPHOSDigitizer *>(PhosLoader()->Digitizer()) ; | |
272 | } | |
273 | return rv ; | |
4ae78bb1 | 274 | } |
fbf811ec | 275 | |
88cb7938 | 276 | |
4ae78bb1 | 277 | //____________________________________________________________________________ |
2bb77d5e | 278 | TObjArray * AliPHOSGetter::EmcRecPoints() const |
0bc3b8ed | 279 | { |
88cb7938 | 280 | // asks the Loader to return the EMC RecPoints container |
d489fb96 | 281 | |
88cb7938 | 282 | TObjArray * rv = 0 ; |
65549808 | 283 | |
88cb7938 | 284 | rv = PhosLoader()->EmcRecPoints() ; |
285 | if (!rv) { | |
286 | PhosLoader()->MakeRecPointsArray() ; | |
287 | rv = PhosLoader()->EmcRecPoints() ; | |
89165262 | 288 | } |
88cb7938 | 289 | return rv ; |
81bb1a45 | 290 | } |
7a9d98f9 | 291 | |
65549808 | 292 | //____________________________________________________________________________ |
2bb77d5e | 293 | TClonesArray * AliPHOSGetter::TrackSegments() const |
65549808 | 294 | { |
88cb7938 | 295 | // asks the Loader to return the TrackSegments container |
296 | ||
297 | TClonesArray * rv = 0 ; | |
298 | ||
299 | rv = PhosLoader()->TrackSegments() ; | |
300 | if (!rv) { | |
301 | PhosLoader()->MakeTrackSegmentsArray() ; | |
302 | rv = PhosLoader()->TrackSegments() ; | |
303 | } | |
304 | return rv ; | |
65549808 | 305 | } |
4ae78bb1 | 306 | |
0c87da39 | 307 | //____________________________________________________________________________ |
e957fea8 | 308 | AliPHOSTrackSegmentMaker * AliPHOSGetter::TrackSegmentMaker() |
88cb7938 | 309 | { |
e957fea8 | 310 | // Returns pointer to the TrackSegmentMaker task |
88cb7938 | 311 | AliPHOSTrackSegmentMaker * rv ; |
312 | rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ; | |
313 | if (!rv) { | |
314 | Event(0, "T") ; | |
315 | rv = dynamic_cast<AliPHOSTrackSegmentMaker *>(PhosLoader()->TrackSegmentMaker()) ; | |
0c87da39 | 316 | } |
88cb7938 | 317 | return rv ; |
0c87da39 | 318 | } |
319 | ||
4ae78bb1 | 320 | //____________________________________________________________________________ |
2bb77d5e | 321 | TClonesArray * AliPHOSGetter::RecParticles() const |
4ae78bb1 | 322 | { |
88cb7938 | 323 | // asks the Loader to return the TrackSegments container |
324 | ||
325 | TClonesArray * rv = 0 ; | |
4ae78bb1 | 326 | |
88cb7938 | 327 | rv = PhosLoader()->RecParticles() ; |
328 | if (!rv) { | |
329 | PhosLoader()->MakeRecParticlesArray() ; | |
330 | rv = PhosLoader()->RecParticles() ; | |
b134c32f | 331 | } |
88cb7938 | 332 | return rv ; |
4ae78bb1 | 333 | } |
4ae78bb1 | 334 | //____________________________________________________________________________ |
fc7e2f43 | 335 | void AliPHOSGetter::Event(Int_t event, const char* opt) |
4ae78bb1 | 336 | { |
88cb7938 | 337 | // Reads the content of all Tree's S, D and R |
548f0134 | 338 | |
66f895c8 | 339 | // if ( event >= MaxEvent() ) { |
340 | // Error("Event", "%d not found in TreeE !", event) ; | |
341 | // return ; | |
342 | // } | |
4ae78bb1 | 343 | |
88cb7938 | 344 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
df25f7dd | 345 | |
66f895c8 | 346 | // // checks if we are dealing with test-beam data |
347 | // TBranch * btb = rl->TreeE()->GetBranch("AliPHOSBeamTestEvent") ; | |
348 | // if(btb){ | |
349 | // if(!fBTE) | |
350 | // fBTE = new AliPHOSBeamTestEvent() ; | |
351 | // btb->SetAddress(&fBTE) ; | |
352 | // btb->GetEntry(event) ; | |
353 | // } | |
354 | // else{ | |
355 | // if(fBTE){ | |
356 | // delete fBTE ; | |
357 | // fBTE = 0 ; | |
358 | // } | |
359 | // } | |
88cb7938 | 360 | |
361 | // Loads the type of object(s) requested | |
b134c32f | 362 | |
88cb7938 | 363 | rl->GetEvent(event) ; |
364 | ||
66f895c8 | 365 | if(strstr(opt,"X") || (strcmp(opt,"")==0)){ |
88cb7938 | 366 | ReadPrimaries() ; |
66f895c8 | 367 | } |
368 | ||
369 | if(strstr(opt,"H") ){ | |
88cb7938 | 370 | ReadTreeH(); |
66f895c8 | 371 | } |
372 | ||
373 | if(strstr(opt,"S") ){ | |
88cb7938 | 374 | ReadTreeS() ; |
66f895c8 | 375 | } |
376 | ||
377 | if(strstr(opt,"D") ){ | |
88cb7938 | 378 | ReadTreeD() ; |
66f895c8 | 379 | } |
380 | ||
381 | if(strstr(opt,"R") ){ | |
88cb7938 | 382 | ReadTreeR() ; |
66f895c8 | 383 | } |
88cb7938 | 384 | |
66f895c8 | 385 | if( strstr(opt,"T") ){ |
88cb7938 | 386 | ReadTreeT() ; |
66f895c8 | 387 | } |
88cb7938 | 388 | |
66f895c8 | 389 | if( strstr(opt,"P") ){ |
88cb7938 | 390 | ReadTreeP() ; |
66f895c8 | 391 | } |
677c8a30 | 392 | |
66f895c8 | 393 | if( strstr(opt,"E") ){ |
677c8a30 | 394 | ReadTreeE(event) ; |
3cf4f75f | 395 | } |
396 | ||
397 | } | |
398 | ||
399 | ||
400 | //____________________________________________________________________________ | |
f5eaa851 | 401 | void AliPHOSGetter::Event(AliRawReader *rawReader, const char* opt, Bool_t isOldRCUFormat) |
3cf4f75f | 402 | { |
403 | // Reads the raw event from rawReader | |
f5eaa851 | 404 | // isOldRCUFormat defines whenever to assume |
405 | // the old RCU format or not | |
f88e2313 | 406 | |
3cf4f75f | 407 | if( strstr(opt,"W") ){ |
e1c29d81 | 408 | rawReader->NextEvent(); |
f5eaa851 | 409 | ReadRaw(rawReader,isOldRCUFormat) ; |
66f895c8 | 410 | } |
95635748 | 411 | |
88cb7938 | 412 | } |
413 | ||
414 | ||
415 | //____________________________________________________________________________ | |
416 | Int_t AliPHOSGetter::EventNumber() const | |
417 | { | |
418 | // return the current event number | |
419 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); | |
420 | return static_cast<Int_t>(rl->GetEventNumber()) ; | |
fbf811ec | 421 | } |
d489fb96 | 422 | |
fbf811ec | 423 | //____________________________________________________________________________ |
2bb77d5e | 424 | TClonesArray * AliPHOSGetter::Hits() const |
fbf811ec | 425 | { |
88cb7938 | 426 | // asks the loader to return the Hits container |
427 | ||
428 | TClonesArray * rv = 0 ; | |
429 | ||
430 | rv = PhosLoader()->Hits() ; | |
431 | if ( !rv ) { | |
432 | PhosLoader()->LoadHits("read"); | |
433 | rv = PhosLoader()->Hits() ; | |
fbf811ec | 434 | } |
88cb7938 | 435 | return rv ; |
436 | } | |
fbf811ec | 437 | |
88cb7938 | 438 | //____________________________________________________________________________ |
439 | AliPHOSGetter * AliPHOSGetter::Instance(const char* alirunFileName, const char* version, Option_t * openingOption) | |
440 | { | |
441 | // Creates and returns the pointer of the unique instance | |
442 | // Must be called only when the environment has changed | |
d489fb96 | 443 | |
88cb7938 | 444 | if(!fgObjGetter){ // first time the getter is called |
445 | fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ; | |
fbf811ec | 446 | } |
88cb7938 | 447 | else { // the getter has been called previously |
448 | AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()); | |
449 | if ( rl->GetFileName() == alirunFileName ) {// the alirunFile has the same name | |
450 | // check if the file is already open | |
451 | TFile * galiceFile = dynamic_cast<TFile *>(gROOT->FindObject(rl->GetFileName()) ) ; | |
452 | ||
453 | if ( !galiceFile ) | |
454 | fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ; | |
455 | ||
456 | else { // the file is already open check the version name | |
457 | TString currentVersionName = rl->GetEventFolder()->GetName() ; | |
458 | TString newVersionName(version) ; | |
459 | if (currentVersionName == newVersionName) | |
460 | if(fgDebug) | |
461 | ::Warning( "Instance", "Files with version %s already open", currentVersionName.Data() ) ; | |
462 | else { | |
463 | fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ; | |
464 | } | |
465 | } | |
466 | } | |
7fba1747 | 467 | else { |
468 | AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()) ; | |
e191bb57 | 469 | if ( strstr(version, AliConfig::GetDefaultEventFolderName()) ) // false in case of merging |
1c221c70 | 470 | delete rl ; |
88cb7938 | 471 | fgObjGetter = new AliPHOSGetter(alirunFileName, version, openingOption) ; |
7fba1747 | 472 | } |
48f12df6 | 473 | } |
88cb7938 | 474 | if (!fgObjGetter) |
95635748 | 475 | ::Error("AliPHOSGetter::Instance", "Failed to create the PHOS Getter object") ; |
88cb7938 | 476 | else |
477 | if (fgDebug) | |
478 | Print() ; | |
4ae78bb1 | 479 | |
88cb7938 | 480 | return fgObjGetter ; |
4ae78bb1 | 481 | } |
482 | ||
6ad0e528 | 483 | //____________________________________________________________________________ |
88cb7938 | 484 | AliPHOSGetter * AliPHOSGetter::Instance() |
6ad0e528 | 485 | { |
88cb7938 | 486 | // Returns the pointer of the unique instance already defined |
fbf811ec | 487 | |
95635748 | 488 | if(!fgObjGetter && fgDebug) |
489 | ::Warning("AliPHOSGetter::Instance", "Getter not initialized") ; | |
6ad0e528 | 490 | |
88cb7938 | 491 | return fgObjGetter ; |
492 | ||
6ad0e528 | 493 | } |
494 | ||
495 | //____________________________________________________________________________ | |
88cb7938 | 496 | Int_t AliPHOSGetter::MaxEvent() const |
6ad0e528 | 497 | { |
88cb7938 | 498 | // returns the number of events in the run (from TE) |
0bc3b8ed | 499 | |
88cb7938 | 500 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
501 | return static_cast<Int_t>(rl->GetNumberOfEvents()) ; | |
6ad0e528 | 502 | } |
503 | ||
504 | //____________________________________________________________________________ | |
88cb7938 | 505 | TParticle * AliPHOSGetter::Primary(Int_t index) const |
6ad0e528 | 506 | { |
88cb7938 | 507 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
508 | return rl->Stack()->Particle(index) ; | |
509 | } | |
6ad0e528 | 510 | |
4ae78bb1 | 511 | //____________________________________________________________________________ |
88cb7938 | 512 | AliPHOS * AliPHOSGetter:: PHOS() const |
4ae78bb1 | 513 | { |
514 | // returns the PHOS object | |
5c4bcd63 | 515 | AliPHOSLoader * loader = 0; |
516 | static AliPHOSLoader * oldloader = 0; | |
517 | static AliPHOS * phos = 0; | |
518 | ||
519 | loader = PhosLoader(); | |
520 | ||
521 | if ( loader != oldloader) { | |
522 | phos = dynamic_cast<AliPHOS*>(loader->GetModulesFolder()->FindObject("PHOS")) ; | |
523 | oldloader = loader; | |
524 | } | |
7a9d98f9 | 525 | if (!phos) |
88cb7938 | 526 | if (fgDebug) |
527 | Warning("PHOS", "PHOS module not found in module folders: %s", PhosLoader()->GetModulesFolder()->GetName() ) ; | |
7a9d98f9 | 528 | return phos ; |
4ae78bb1 | 529 | } |
530 | ||
88cb7938 | 531 | |
532 | ||
533 | //____________________________________________________________________________ | |
e957fea8 | 534 | AliPHOSPID * AliPHOSGetter::PID() |
88cb7938 | 535 | { |
e957fea8 | 536 | // Returns pointer to the PID task |
88cb7938 | 537 | AliPHOSPID * rv ; |
538 | rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ; | |
539 | if (!rv) { | |
540 | Event(0, "P") ; | |
541 | rv = dynamic_cast<AliPHOSPID *>(PhosLoader()->PIDTask()) ; | |
542 | } | |
543 | return rv ; | |
544 | } | |
545 | ||
4ae78bb1 | 546 | //____________________________________________________________________________ |
88cb7938 | 547 | AliPHOSGeometry * AliPHOSGetter::PHOSGeometry() const |
4ae78bb1 | 548 | { |
0bc3b8ed | 549 | // Returns PHOS geometry |
550 | ||
7a9d98f9 | 551 | AliPHOSGeometry * rv = 0 ; |
552 | if (PHOS() ) | |
553 | rv = PHOS()->GetGeometry() ; | |
52c5f046 | 554 | else { |
555 | rv = AliPHOSGeometry::GetInstance(); | |
556 | if (!rv) { | |
557 | AliError("Could not find PHOS geometry! Loading the default one !"); | |
558 | rv = AliPHOSGeometry::GetInstance("IHEP",""); | |
559 | } | |
560 | } | |
7a9d98f9 | 561 | return rv ; |
562 | } | |
4ae78bb1 | 563 | |
cb34a1fa | 564 | //____________________________________________________________________________ |
88cb7938 | 565 | TClonesArray * AliPHOSGetter::Primaries() |
566 | { | |
567 | // creates the Primaries container if needed | |
568 | if ( !fPrimaries ) { | |
569 | if (fgDebug) | |
570 | Info("Primaries", "Creating a new TClonesArray for primaries") ; | |
571 | fPrimaries = new TClonesArray("TParticle", 1000) ; | |
572 | } | |
573 | return fPrimaries ; | |
574 | } | |
575 | ||
576 | //____________________________________________________________________________ | |
577 | void AliPHOSGetter::Print() | |
578 | { | |
579 | // Print usefull information about the getter | |
580 | ||
581 | AliRunLoader * rl = AliRunLoader::GetRunLoader(fgPhosLoader->GetTitle()); | |
582 | ::Info( "Print", "gAlice file is %s -- version name is %s", (rl->GetFileName()).Data(), rl->GetEventFolder()->GetName() ) ; | |
583 | } | |
cb34a1fa | 584 | |
88cb7938 | 585 | //____________________________________________________________________________ |
586 | void AliPHOSGetter::ReadPrimaries() | |
587 | { | |
588 | // Read Primaries from Kinematics.root | |
cb34a1fa | 589 | |
88cb7938 | 590 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); |
cb34a1fa | 591 | |
88cb7938 | 592 | // gets kine tree from the root file (Kinematics.root) |
7fba1747 | 593 | if ( ! rl->TreeK() ) { // load treeK the first time |
88cb7938 | 594 | rl->LoadKinematics() ; |
7fba1747 | 595 | } |
88cb7938 | 596 | |
7fba1747 | 597 | fNPrimaries = (rl->GetHeader())->GetNtrack(); |
88cb7938 | 598 | if (fgDebug) |
599 | Info( "ReadTreeK", "Found %d particles in event # %d", fNPrimaries, EventNumber() ) ; | |
cb34a1fa | 600 | |
cb34a1fa | 601 | |
88cb7938 | 602 | // first time creates the container |
603 | if ( Primaries() ) | |
604 | fPrimaries->Clear() ; | |
cb34a1fa | 605 | |
88cb7938 | 606 | Int_t index = 0 ; |
607 | for (index = 0 ; index < fNPrimaries; index++) { | |
608 | new ((*fPrimaries)[index]) TParticle(*(Primary(index))); | |
cb34a1fa | 609 | } |
cb34a1fa | 610 | } |
611 | ||
95635748 | 612 | //____________________________________________________________________________ |
d2713783 | 613 | Bool_t AliPHOSGetter::OpenESDFile() |
95635748 | 614 | { |
d2713783 | 615 | //Open the ESD file |
95635748 | 616 | Bool_t rv = kTRUE ; |
d2713783 | 617 | if (!fESDFile) { |
618 | fESDFile = TFile::Open(fESDFileName) ; | |
619 | if (!fESDFile ) | |
620 | return kFALSE ; | |
621 | } | |
95635748 | 622 | else if (fESDFile->IsOpen()) { |
623 | fESDFile->Close() ; | |
624 | fESDFile = TFile::Open(fESDFileName) ; | |
625 | } | |
626 | if (!fESDFile->IsOpen()) | |
627 | rv = kFALSE ; | |
628 | return rv ; | |
629 | } | |
630 | ||
45c1ce6f | 631 | //____________________________________________________________________________ |
2bb77d5e | 632 | void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Double_t & energy, Double_t & time) const |
45c1ce6f | 633 | { |
634 | // Fits the raw signal time distribution | |
635 | ||
636 | const Int_t kNoiseThreshold = 0 ; | |
637 | Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ; | |
638 | Double_t signal = 0., signalmax = 0. ; | |
44ae287e | 639 | time = 0. ; |
640 | energy = 0. ; | |
45c1ce6f | 641 | |
431a9211 | 642 | // Create a shaper pulse object which contains all the shaper parameters |
75d640cb | 643 | AliPHOSPulseGenerator pulse; |
431a9211 | 644 | |
45c1ce6f | 645 | if (lowGainFlag) { |
646 | timezero1 = timezero2 = signalmax = timemax = 0. ; | |
75d640cb | 647 | signalF->FixParameter(0, pulse.GetRawFormatLowCharge()) ; |
648 | signalF->FixParameter(1, pulse.GetRawFormatLowGain()) ; | |
45c1ce6f | 649 | Int_t index ; |
75d640cb | 650 | for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) { |
45c1ce6f | 651 | gLowGain->GetPoint(index, time, signal) ; |
652 | if (signal > kNoiseThreshold && timezero1 == 0.) | |
653 | timezero1 = time ; | |
654 | if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.) | |
655 | timezero2 = time ; | |
656 | if (signal > signalmax) { | |
657 | signalmax = signal ; | |
658 | timemax = time ; | |
659 | } | |
660 | } | |
431a9211 | 661 | signalmax /= |
75d640cb | 662 | pulse.RawResponseFunctionMax(pulse.GetRawFormatLowCharge(), |
663 | pulse.GetRawFormatLowGain()) ; | |
664 | if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise | |
45c1ce6f | 665 | signalF->SetParameter(2, signalmax) ; |
666 | signalF->SetParameter(3, timezero1) ; | |
2bb77d5e | 667 | gLowGain->Fit(signalF, "QRO", "", 0., timezero2); //, "QRON") ; |
45c1ce6f | 668 | energy = signalF->GetParameter(2) ; |
75d640cb | 669 | time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ; |
45c1ce6f | 670 | } |
671 | } else { | |
672 | timezero1 = timezero2 = signalmax = timemax = 0. ; | |
75d640cb | 673 | signalF->FixParameter(0, pulse.GetRawFormatHighCharge()) ; |
674 | signalF->FixParameter(1, pulse.GetRawFormatHighGain()) ; | |
45c1ce6f | 675 | Int_t index ; |
75d640cb | 676 | for (index = 0; index < pulse.GetRawFormatTimeBins(); index++) { |
45c1ce6f | 677 | gHighGain->GetPoint(index, time, signal) ; |
678 | if (signal > kNoiseThreshold && timezero1 == 0.) | |
679 | timezero1 = time ; | |
680 | if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.) | |
681 | timezero2 = time ; | |
682 | if (signal > signalmax) { | |
683 | signalmax = signal ; | |
684 | timemax = time ; | |
685 | } | |
686 | } | |
75d640cb | 687 | signalmax /= pulse.RawResponseFunctionMax(pulse.GetRawFormatHighCharge(), |
688 | pulse.GetRawFormatHighGain()) ;; | |
689 | if ( timezero1 + pulse.GetRawFormatTimePeak() < pulse.GetRawFormatTimeMax() * 0.4 ) { // else its noise | |
45c1ce6f | 690 | signalF->SetParameter(2, signalmax) ; |
691 | signalF->SetParameter(3, timezero1) ; | |
2bb77d5e | 692 | gHighGain->Fit(signalF, "QRO", "", 0., timezero2) ; |
45c1ce6f | 693 | energy = signalF->GetParameter(2) ; |
75d640cb | 694 | time = signalF->GetMaximumX() - pulse.GetRawFormatTimePeak() - pulse.GetRawFormatTimeTrigger() ; |
45c1ce6f | 695 | } |
696 | } | |
44ae287e | 697 | if (time == 0) energy = 0 ; |
45c1ce6f | 698 | } |
699 | ||
44ae287e | 700 | //____________________________________________________________________________ |
701 | Int_t AliPHOSGetter::CalibrateRaw(Double_t energy, Int_t *relId) | |
702 | { | |
703 | // Convert energy into digitized amplitude for a cell relId | |
704 | // It is a user responsilibity to open CDB and set | |
705 | // AliPHOSCalibData object by the following operators: | |
706 | // | |
707 | // AliCDBLocal *loc = new AliCDBLocal("deCalibDB"); | |
708 | // AliPHOSCalibData* clb = (AliPHOSCalibData*)AliCDBStorage::Instance() | |
709 | // ->Get(path_to_calibdata,run_number); | |
710 | // AliPHOSGetter* gime = AliPHOSGetter::Instance("galice.root"); | |
711 | // gime->SetCalibData(clb); | |
712 | ||
713 | if (CalibData() == 0) | |
f88e2313 | 714 | Warning("CalibrateRaw","Calibration DB is not initiated!"); |
44ae287e | 715 | |
716 | Int_t module = relId[0]; | |
f88e2313 | 717 | Int_t column = relId[3]; |
718 | Int_t row = relId[2]; | |
719 | ||
720 | Float_t gainFactor = 0.0015; // width of one Emc ADC channel in GeV | |
721 | Float_t pedestal = 0.005; // Emc pedestals | |
722 | ||
723 | if(CalibData()) { | |
724 | gainFactor = CalibData()->GetADCchannelEmc (module,column,row); | |
725 | pedestal = CalibData()->GetADCpedestalEmc(module,column,row); | |
726 | } | |
727 | ||
44ae287e | 728 | Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ; |
729 | return amp; | |
730 | } | |
a43c51c3 | 731 | //____________________________________________________________________________ |
f5eaa851 | 732 | Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader,Bool_t isOldRCUFormat) |
a43c51c3 | 733 | { |
734 | // reads the raw format data, converts it into digits format and store digits in Digits() | |
735 | // container. | |
f5eaa851 | 736 | // isOldRCUFormat = kTRUE in case of the old RCU |
02e48b45 | 737 | // format used in the raw data readout. |
738 | // Reimplemented by Boris Polichtchouk (Jul 2006) | |
739 | // to make it working with the Jul-Aug 2006 beam test data. | |
740 | ||
d84933b0 | 741 | AliCaloRawStream in(rawReader,"PHOS"); |
f5eaa851 | 742 | in.SetOldRCUFormat(isOldRCUFormat); |
a43c51c3 | 743 | |
431a9211 | 744 | // Create a shaper pulse object |
75d640cb | 745 | AliPHOSPulseGenerator pulse; |
746 | TF1 * signalF = new TF1("signal", AliPHOSPulseGenerator::RawResponseFunction, 0, pulse.GetRawFormatTimeMax(), 4); | |
45c1ce6f | 747 | signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ; |
748 | ||
6a0d2265 | 749 | Int_t relId[4], absId =0; |
45c1ce6f | 750 | Bool_t lowGainFlag = kFALSE ; |
2bb77d5e | 751 | |
a43c51c3 | 752 | TClonesArray * digits = Digits() ; |
02e48b45 | 753 | digits->Clear() ; |
754 | ||
6a0d2265 | 755 | Int_t iBin = 0; |
756 | Int_t iDigit = 0 ; | |
69464fdb | 757 | Double_t energyHG = 0. ; |
758 | Double_t energyLG = 0. ; | |
d5a42c14 | 759 | Double_t startTime= 0. ; |
6a0d2265 | 760 | Double_t time = 0. ; |
761 | Int_t iOldDigit; | |
762 | Bool_t seen; | |
763 | TH1F* hLowGain = 0; | |
764 | TH1F* hHighGain = 0; | |
19309784 | 765 | |
45c1ce6f | 766 | while ( in.Next() ) { // PHOS entries loop |
02e48b45 | 767 | |
768 | lowGainFlag = in.IsLowGain(); | |
6a0d2265 | 769 | |
770 | // (Re)create histograms to store samples | |
771 | ||
772 | if (lowGainFlag) { | |
773 | if(!hLowGain) | |
d5a42c14 | 774 | hLowGain = new TH1F("hLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength()); |
6a0d2265 | 775 | else |
776 | if(hLowGain->GetNbinsX() != in.GetTimeLength()) { | |
777 | delete hLowGain; | |
778 | hLowGain = new TH1F("hLowGain","Low gain",in.GetTimeLength(),0,in.GetTimeLength()); | |
779 | } | |
780 | } else { | |
781 | if(!hHighGain) | |
782 | hHighGain = new TH1F("hHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength()); | |
783 | else | |
784 | if(hHighGain->GetNbinsX() != in.GetTimeLength()) { | |
785 | delete hHighGain; | |
786 | hHighGain = new TH1F("hHighGain","High gain",in.GetTimeLength(),0,in.GetTimeLength()); | |
787 | } | |
788 | } | |
789 | ||
790 | // Fill histograms with samples | |
02e48b45 | 791 | if(lowGainFlag) |
07e0a3c3 | 792 | hLowGain ->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal()); |
c89c49ca | 793 | else { |
07e0a3c3 | 794 | hHighGain->SetBinContent(in.GetTimeLength()-iBin-1,in.GetSignal()); |
c89c49ca | 795 | } |
19309784 | 796 | |
02e48b45 | 797 | iBin++; |
798 | ||
6a0d2265 | 799 | // Fit the full sample |
02e48b45 | 800 | if(iBin==in.GetTimeLength()) { |
801 | iBin=0; | |
802 | ||
02e48b45 | 803 | // Temporarily we do not fit the sample graph, but |
804 | // take the energy from the graph maximum, and the pedestal from the 0th point | |
805 | // 30 Aug 2006 | |
69464fdb | 806 | |
6a0d2265 | 807 | //FitRaw(lowGainFlag, hLowGain, hHighGain, signalF, energy, time); |
69464fdb | 808 | |
d5a42c14 | 809 | // Time is not evaluated for the moment (12.01.2007). |
810 | // Take is as a first time bin multiplied by the sample tick time | |
811 | time = pulse.GetRawFormatTimeTrigger() * in.GetTime(); | |
812 | ||
6a0d2265 | 813 | if(lowGainFlag) { |
814 | energyLG = hLowGain ->GetMaximum(); // "digit amplitude" | |
815 | // energyLG -= hLowGain ->GetBinContent(0); // "pedestal subtraction" | |
75d640cb | 816 | energyLG *= pulse.GetRawFormatHighLowGainFactor(); // *16 |
817 | if(AliLog::GetGlobalDebugLevel()>3) { | |
818 | AliDebug(4,Form("----Printing hLowGain: ----\n")) ; | |
819 | hLowGain ->Print("all"); | |
820 | } | |
821 | if(AliLog::GetGlobalDebugLevel()>2) | |
d5a42c14 | 822 | AliDebug(2,Form("(mod,col,row)=(%d,%d,%d), low gain energy=%f, time=%g\n\n", |
823 | in.GetModule(),in.GetColumn(),in.GetRow(),energyLG,time)); | |
6a0d2265 | 824 | } |
825 | ||
826 | else { | |
827 | energyHG = hHighGain->GetMaximum(); // "digit amplitude" | |
828 | // energyHG -= hHighGain->GetBinContent(0); // "pedestal subtraction" | |
75d640cb | 829 | if(AliLog::GetGlobalDebugLevel()>3) { |
830 | AliDebug(4,Form("----Printing hHighGain: ----\n")); | |
831 | hHighGain->Print("all"); | |
832 | } | |
833 | if(AliLog::GetGlobalDebugLevel()>2) | |
d5a42c14 | 834 | AliDebug(2,Form("(mod,col,row)=(%d,%d,%d), high gain energy=%f, time=%g\n\n", |
835 | in.GetModule(),in.GetColumn(),in.GetRow(),energyHG,time)); | |
45c1ce6f | 836 | } |
69464fdb | 837 | |
69464fdb | 838 | relId[0] = in.GetModule()+1; |
75d640cb | 839 | relId[1] = 0; |
840 | relId[2] = in.GetRow() +1; | |
841 | relId[3] = in.GetColumn()+1; | |
6a0d2265 | 842 | if(!PHOSGeometry()) AliFatal("Couldn't find PHOSGeometry!"); |
843 | PHOSGeometry()->RelToAbsNumbering(relId, absId); | |
844 | ||
75d640cb | 845 | AliDebug(2,Form("relId=(mod,row,col)=(%d,%d,%d), absId=%d\n\n", |
846 | relId[0],relId[2],relId[3],absId)); | |
847 | ||
6a0d2265 | 848 | // Add low gain digit only if the high gain digit does not exist in the digits array |
75d640cb | 849 | seen = kFALSE; |
6a0d2265 | 850 | if(lowGainFlag) { |
8b7c6b6c | 851 | for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) { |
75d640cb | 852 | if ((dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)))->GetId() == absId) { |
6a0d2265 | 853 | seen = kTRUE; |
854 | break; | |
855 | } | |
856 | } | |
8b7c6b6c | 857 | if (!seen) { |
6a0d2265 | 858 | new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energyLG,time); |
8b7c6b6c | 859 | iDigit++; |
860 | } | |
6a0d2265 | 861 | energyLG = 0. ; |
69464fdb | 862 | } |
eef8bd53 | 863 | // Add high gain digit only if it is not saturated; |
864 | // replace low gain digit by a high gain one | |
69464fdb | 865 | else { |
eef8bd53 | 866 | if (energyHG >= 1023) continue; |
8b7c6b6c | 867 | for (iOldDigit=iDigit-1; iOldDigit>=0; iOldDigit--) { |
75d640cb | 868 | if ((dynamic_cast<AliPHOSDigit*>(digits->At(iOldDigit)))->GetId() == absId) { |
eef8bd53 | 869 | digits->RemoveAt(iOldDigit); |
8b7c6b6c | 870 | new((*digits)[iOldDigit]) AliPHOSDigit(-1,absId,(Float_t)energyHG,time); |
75d640cb | 871 | seen = kTRUE; |
6a0d2265 | 872 | break; |
873 | } | |
874 | } | |
8b7c6b6c | 875 | if (!seen) { |
75d640cb | 876 | new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energyHG,time); |
8b7c6b6c | 877 | iDigit++; |
878 | } | |
6a0d2265 | 879 | energyHG = 0. ; |
02e48b45 | 880 | } |
66f895c8 | 881 | } |
44ae287e | 882 | } |
45c1ce6f | 883 | |
02e48b45 | 884 | // PHOS entries loop |
885 | ||
8b7c6b6c | 886 | digits->Compress() ; |
02e48b45 | 887 | digits->Sort() ; |
69464fdb | 888 | |
889 | //!!!!for debug!!! | |
890 | Int_t modMax=-111; | |
891 | Int_t colMax=-111; | |
892 | Int_t rowMax=-111; | |
893 | Float_t eMax=-333; | |
894 | //!!!for debug!!! | |
895 | ||
6a0d2265 | 896 | for(iDigit=0; iDigit<digits->GetEntries(); iDigit++) { |
69464fdb | 897 | AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit); |
898 | if(digit->GetEnergy()>eMax) { | |
899 | PHOSGeometry()->AbsToRelNumbering(digit->GetId(),relId); | |
900 | eMax=digit->GetEnergy(); | |
901 | modMax=relId[0]; | |
902 | rowMax=relId[2]; | |
903 | colMax=relId[3]; | |
904 | } | |
905 | } | |
19309784 | 906 | |
6a0d2265 | 907 | AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n", |
908 | modMax,colMax,rowMax,eMax)); | |
69464fdb | 909 | |
19309784 | 910 | delete signalF ; |
6a0d2265 | 911 | delete hHighGain; |
912 | delete hLowGain; | |
02e48b45 | 913 | |
e4d04cf1 | 914 | return digits->GetEntriesFast() ; |
a43c51c3 | 915 | } |
45c1ce6f | 916 | |
b0bba0af | 917 | //____________________________________________________________________________ |
fd31ff92 | 918 | Int_t AliPHOSGetter::ReadTreeD() const |
88cb7938 | 919 | { |
920 | // Read the Digits | |
b0bba0af | 921 | |
41c29fde | 922 | PhosLoader()->CleanDigits() ; |
ff808dc7 | 923 | PhosLoader()->LoadDigits("UPDATE") ; |
924 | PhosLoader()->LoadDigitizer("UPDATE") ; | |
88cb7938 | 925 | return Digits()->GetEntries() ; |
926 | } | |
7a9d98f9 | 927 | |
b0bba0af | 928 | //____________________________________________________________________________ |
fd31ff92 | 929 | Int_t AliPHOSGetter::ReadTreeH() const |
88cb7938 | 930 | { |
931 | // Read the Hits | |
41c29fde | 932 | PhosLoader()->CleanHits() ; |
88cb7938 | 933 | // gets TreeH from the root file (PHOS.Hit.root) |
41c29fde | 934 | //if ( !IsLoaded("H") ) { |
88cb7938 | 935 | PhosLoader()->LoadHits("UPDATE") ; |
41c29fde | 936 | // SetLoaded("H") ; |
937 | //} | |
88cb7938 | 938 | return Hits()->GetEntries() ; |
939 | } | |
4ae78bb1 | 940 | |
88cb7938 | 941 | //____________________________________________________________________________ |
fd31ff92 | 942 | Int_t AliPHOSGetter::ReadTreeR() const |
88cb7938 | 943 | { |
944 | // Read the RecPoints | |
b0bba0af | 945 | |
41c29fde | 946 | PhosLoader()->CleanRecPoints() ; |
88cb7938 | 947 | // gets TreeR from the root file (PHOS.RecPoints.root) |
41c29fde | 948 | //if ( !IsLoaded("R") ) { |
88cb7938 | 949 | PhosLoader()->LoadRecPoints("UPDATE") ; |
950 | PhosLoader()->LoadClusterizer("UPDATE") ; | |
41c29fde | 951 | // SetLoaded("R") ; |
952 | //} | |
f1611b7c | 953 | |
88cb7938 | 954 | return EmcRecPoints()->GetEntries() ; |
b0bba0af | 955 | } |
7a9d98f9 | 956 | |
b0bba0af | 957 | //____________________________________________________________________________ |
fd31ff92 | 958 | Int_t AliPHOSGetter::ReadTreeT() const |
88cb7938 | 959 | { |
960 | // Read the TrackSegments | |
7a9d98f9 | 961 | |
41c29fde | 962 | PhosLoader()->CleanTracks() ; |
88cb7938 | 963 | // gets TreeT from the root file (PHOS.TrackSegments.root) |
41c29fde | 964 | //if ( !IsLoaded("T") ) { |
88cb7938 | 965 | PhosLoader()->LoadTracks("UPDATE") ; |
966 | PhosLoader()->LoadTrackSegmentMaker("UPDATE") ; | |
41c29fde | 967 | // SetLoaded("T") ; |
968 | //} | |
fbf811ec | 969 | |
88cb7938 | 970 | return TrackSegments()->GetEntries() ; |
971 | } | |
b0bba0af | 972 | //____________________________________________________________________________ |
fd31ff92 | 973 | Int_t AliPHOSGetter::ReadTreeP() const |
88cb7938 | 974 | { |
41c29fde | 975 | // Read the RecParticles |
88cb7938 | 976 | |
41c29fde | 977 | PhosLoader()->CleanRecParticles() ; |
978 | ||
88cb7938 | 979 | // gets TreeT from the root file (PHOS.TrackSegments.root) |
41c29fde | 980 | // if ( !IsLoaded("P") ) { |
88cb7938 | 981 | PhosLoader()->LoadRecParticles("UPDATE") ; |
982 | PhosLoader()->LoadPID("UPDATE") ; | |
41c29fde | 983 | // SetLoaded("P") ; |
984 | //} | |
7a9d98f9 | 985 | |
88cb7938 | 986 | return RecParticles()->GetEntries() ; |
987 | } | |
988 | //____________________________________________________________________________ | |
fd31ff92 | 989 | Int_t AliPHOSGetter::ReadTreeS() const |
88cb7938 | 990 | { |
991 | // Read the SDigits | |
992 | ||
41c29fde | 993 | PhosLoader()->CleanSDigits() ; |
88cb7938 | 994 | // gets TreeS from the root file (PHOS.SDigits.root) |
41c29fde | 995 | //if ( !IsLoaded("S") ) { |
7b4c1168 | 996 | PhosLoader()->LoadSDigits("READ") ; |
997 | PhosLoader()->LoadSDigitizer("READ") ; | |
41c29fde | 998 | // SetLoaded("S") ; |
999 | //} | |
b0bba0af | 1000 | |
88cb7938 | 1001 | return SDigits()->GetEntries() ; |
1002 | } | |
f1611b7c | 1003 | |
677c8a30 | 1004 | //____________________________________________________________________________ |
1005 | Int_t AliPHOSGetter::ReadTreeE(Int_t event) | |
1006 | { | |
1007 | // Read the ESD | |
1008 | ||
1009 | // gets esdTree from the root file (AliESDs.root) | |
1010 | if (!fESDFile) | |
1011 | if ( !OpenESDFile() ) | |
1012 | return -1 ; | |
1013 | ||
1014 | fESDTree = static_cast<TTree*>(fESDFile->Get("esdTree")) ; | |
1015 | fESD = new AliESD; | |
1016 | if (!fESDTree) { | |
1017 | ||
1018 | Error("ReadTreeE", "no ESD tree found"); | |
1019 | return -1; | |
1020 | } | |
1021 | fESDTree->SetBranchAddress("ESD", &fESD); | |
1022 | fESDTree->GetEvent(event); | |
1023 | ||
1024 | return event ; | |
1025 | } | |
1026 | ||
88cb7938 | 1027 | //____________________________________________________________________________ |
2bb77d5e | 1028 | TClonesArray * AliPHOSGetter::SDigits() const |
88cb7938 | 1029 | { |
1030 | // asks the Loader to return the Digits container | |
b0bba0af | 1031 | |
88cb7938 | 1032 | TClonesArray * rv = 0 ; |
1033 | ||
1034 | rv = PhosLoader()->SDigits() ; | |
1035 | if (!rv) { | |
1036 | PhosLoader()->MakeSDigitsArray() ; | |
1037 | rv = PhosLoader()->SDigits() ; | |
1038 | } | |
1039 | return rv ; | |
b0bba0af | 1040 | } |
1041 | ||
1042 | //____________________________________________________________________________ | |
e957fea8 | 1043 | AliPHOSSDigitizer * AliPHOSGetter::SDigitizer() |
88cb7938 | 1044 | { |
e957fea8 | 1045 | // Returns pointer to the SDigitizer task |
88cb7938 | 1046 | AliPHOSSDigitizer * rv ; |
1047 | rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ; | |
1048 | if (!rv) { | |
1049 | Event(0, "S") ; | |
1050 | rv = dynamic_cast<AliPHOSSDigitizer *>(PhosLoader()->SDigitizer()) ; | |
b0bba0af | 1051 | } |
88cb7938 | 1052 | return rv ; |
b0bba0af | 1053 | } |
7a9d98f9 | 1054 | |
b0bba0af | 1055 | //____________________________________________________________________________ |
fc7e2f43 | 1056 | TParticle * AliPHOSGetter::Secondary(const TParticle* p, Int_t index) const |
88cb7938 | 1057 | { |
1058 | // Return first (index=1) or second (index=2) secondary particle of primary particle p | |
1059 | ||
1060 | if(index <= 0) | |
1061 | return 0 ; | |
1062 | if(index > 2) | |
1063 | return 0 ; | |
b0bba0af | 1064 | |
88cb7938 | 1065 | if(p) { |
1066 | Int_t daughterIndex = p->GetDaughter(index-1) ; | |
1067 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); | |
5d12ce38 | 1068 | return rl->GetAliRun()->GetMCApp()->Particle(daughterIndex) ; |
88cb7938 | 1069 | } |
1070 | else | |
1071 | return 0 ; | |
1072 | } | |
4ae78bb1 | 1073 | |
88cb7938 | 1074 | //____________________________________________________________________________ |
fc7e2f43 | 1075 | void AliPHOSGetter::Track(Int_t itrack) |
88cb7938 | 1076 | { |
1077 | // Read the first entry of PHOS branch in hit tree gAlice->TreeH() | |
1078 | ||
1079 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); | |
b0bba0af | 1080 | |
88cb7938 | 1081 | if( !TreeH() ) // load treeH the first time |
1082 | rl->LoadHits() ; | |
b0bba0af | 1083 | |
88cb7938 | 1084 | // first time create the container |
1085 | TClonesArray * hits = Hits() ; | |
1086 | if ( hits ) | |
1087 | hits->Clear() ; | |
b0bba0af | 1088 | |
88cb7938 | 1089 | TBranch * phosbranch = dynamic_cast<TBranch*>(TreeH()->GetBranch("PHOS")) ; |
1090 | phosbranch->SetAddress(&hits) ; | |
1091 | phosbranch->GetEntry(itrack) ; | |
b0bba0af | 1092 | } |
1093 | ||
b0bba0af | 1094 | //____________________________________________________________________________ |
88cb7938 | 1095 | TTree * AliPHOSGetter::TreeD() const |
1096 | { | |
e957fea8 | 1097 | // Returns pointer to the Digits Tree |
88cb7938 | 1098 | TTree * rv = 0 ; |
1099 | rv = PhosLoader()->TreeD() ; | |
1100 | if ( !rv ) { | |
1101 | PhosLoader()->MakeTree("D"); | |
1102 | rv = PhosLoader()->TreeD() ; | |
b0bba0af | 1103 | } |
b0bba0af | 1104 | |
88cb7938 | 1105 | return rv ; |
b0bba0af | 1106 | } |
548f0134 | 1107 | |
b0bba0af | 1108 | //____________________________________________________________________________ |
88cb7938 | 1109 | TTree * AliPHOSGetter::TreeH() const |
1110 | { | |
e957fea8 | 1111 | // Returns pointer to the Hits Tree |
88cb7938 | 1112 | TTree * rv = 0 ; |
1113 | rv = PhosLoader()->TreeH() ; | |
1114 | if ( !rv ) { | |
1115 | PhosLoader()->MakeTree("H"); | |
1116 | rv = PhosLoader()->TreeH() ; | |
1117 | } | |
1118 | ||
1119 | return rv ; | |
b0bba0af | 1120 | } |
7a9d98f9 | 1121 | |
b0bba0af | 1122 | //____________________________________________________________________________ |
88cb7938 | 1123 | TTree * AliPHOSGetter::TreeR() const |
0bc3b8ed | 1124 | { |
e957fea8 | 1125 | // Returns pointer to the RecPoints Tree |
88cb7938 | 1126 | TTree * rv = 0 ; |
1127 | rv = PhosLoader()->TreeR() ; | |
1128 | if ( !rv ) { | |
1129 | PhosLoader()->MakeTree("R"); | |
1130 | rv = PhosLoader()->TreeR() ; | |
1131 | } | |
b0bba0af | 1132 | |
88cb7938 | 1133 | return rv ; |
b0bba0af | 1134 | } |
1135 | ||
b0bba0af | 1136 | //____________________________________________________________________________ |
88cb7938 | 1137 | TTree * AliPHOSGetter::TreeT() const |
0bc3b8ed | 1138 | { |
e957fea8 | 1139 | // Returns pointer to the TrackSegments Tree |
88cb7938 | 1140 | TTree * rv = 0 ; |
1141 | rv = PhosLoader()->TreeT() ; | |
1142 | if ( !rv ) { | |
1143 | PhosLoader()->MakeTree("T"); | |
1144 | rv = PhosLoader()->TreeT() ; | |
1145 | } | |
b0bba0af | 1146 | |
88cb7938 | 1147 | return rv ; |
b0bba0af | 1148 | } |
b0bba0af | 1149 | //____________________________________________________________________________ |
88cb7938 | 1150 | TTree * AliPHOSGetter::TreeP() const |
0bc3b8ed | 1151 | { |
e957fea8 | 1152 | // Returns pointer to the RecParticles Tree |
88cb7938 | 1153 | TTree * rv = 0 ; |
1154 | rv = PhosLoader()->TreeP() ; | |
1155 | if ( !rv ) { | |
1156 | PhosLoader()->MakeTree("P"); | |
1157 | rv = PhosLoader()->TreeP() ; | |
1158 | } | |
4ae78bb1 | 1159 | |
88cb7938 | 1160 | return rv ; |
b0bba0af | 1161 | } |
1162 | ||
1163 | //____________________________________________________________________________ | |
88cb7938 | 1164 | TTree * AliPHOSGetter::TreeS() const |
e957fea8 | 1165 | { |
1166 | // Returns pointer to the SDigits Tree | |
88cb7938 | 1167 | TTree * rv = 0 ; |
1168 | rv = PhosLoader()->TreeS() ; | |
1169 | if ( !rv ) { | |
1170 | PhosLoader()->MakeTree("S"); | |
1171 | rv = PhosLoader()->TreeS() ; | |
b0bba0af | 1172 | } |
b0bba0af | 1173 | |
88cb7938 | 1174 | return rv ; |
b0bba0af | 1175 | } |
7a9d98f9 | 1176 | |
b0bba0af | 1177 | //____________________________________________________________________________ |
88cb7938 | 1178 | Bool_t AliPHOSGetter::VersionExists(TString & opt) const |
1179 | { | |
1180 | // checks if the version with the present name already exists in the same directory | |
7a9d98f9 | 1181 | |
88cb7938 | 1182 | Bool_t rv = kFALSE ; |
1183 | ||
1184 | AliRunLoader * rl = AliRunLoader::GetRunLoader(PhosLoader()->GetTitle()); | |
1185 | TString version( rl->GetEventFolder()->GetName() ) ; | |
7a9d98f9 | 1186 | |
88cb7938 | 1187 | opt.ToLower() ; |
b0bba0af | 1188 | |
88cb7938 | 1189 | if ( opt == "sdigits") { |
1190 | // add the version name to the root file name | |
1191 | TString fileName( PhosLoader()->GetSDigitsFileName() ) ; | |
e191bb57 | 1192 | if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name |
88cb7938 | 1193 | fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ; |
1194 | if ( !(gSystem->AccessPathName(fileName)) ) { | |
1195 | Warning("VersionExists", "The file %s already exists", fileName.Data()) ; | |
1196 | rv = kTRUE ; | |
4ae78bb1 | 1197 | } |
88cb7938 | 1198 | PhosLoader()->SetSDigitsFileName(fileName) ; |
b0bba0af | 1199 | } |
7a9d98f9 | 1200 | |
88cb7938 | 1201 | if ( opt == "digits") { |
1202 | // add the version name to the root file name | |
1203 | TString fileName( PhosLoader()->GetDigitsFileName() ) ; | |
e191bb57 | 1204 | if (version != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name |
88cb7938 | 1205 | fileName = fileName.ReplaceAll(".root", "") + "_" + version + ".root" ; |
1206 | if ( !(gSystem->AccessPathName(fileName)) ) { | |
1207 | Warning("VersionExists", "The file %s already exists", fileName.Data()) ; | |
1208 | rv = kTRUE ; | |
7a9d98f9 | 1209 | } |
b0bba0af | 1210 | } |
7a9d98f9 | 1211 | |
88cb7938 | 1212 | return rv ; |
7a9d98f9 | 1213 | |
b0bba0af | 1214 | } |
88cb7938 | 1215 | |
7bb289a7 | 1216 | //____________________________________________________________________________ |
88cb7938 | 1217 | UShort_t AliPHOSGetter::EventPattern(void) const |
0bc3b8ed | 1218 | { |
1219 | // Return the pattern (trigger bit register) of the beam-test event | |
7bb289a7 | 1220 | if(fBTE) |
1221 | return fBTE->GetPattern() ; | |
1222 | else | |
1223 | return 0 ; | |
1224 | } | |
1225 | //____________________________________________________________________________ | |
88cb7938 | 1226 | Float_t AliPHOSGetter::BeamEnergy(void) const |
0bc3b8ed | 1227 | { |
1228 | // Return the beam energy of the beam-test event | |
7bb289a7 | 1229 | if(fBTE) |
1230 | return fBTE->GetBeamEnergy() ; | |
1231 | else | |
1232 | return 0 ; | |
1233 | } | |
7ca0684e | 1234 | //____________________________________________________________________________ |
1235 | ||
1236 | AliPHOSCalibData* AliPHOSGetter::CalibData() | |
1237 | { | |
ef868168 | 1238 | // Check if the instance of AliPHOSCalibData exists, and return it |
7ca0684e | 1239 | |
2bb77d5e | 1240 | return fgCalibData; |
7ca0684e | 1241 | } |