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