]>
Commit | Line | Data |
---|---|---|
88cb7938 | 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$ */ |
88cb7938 | 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 AliEMCALAnalyser): | |
28 | // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++) | |
29 | // AliEMCALRecParticle * part = gime->RecParticle(1) ; | |
30 | // ................ | |
31 | // please->GetEvent(event) ; // reads new event from galice.root | |
32 | // | |
33 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) | |
34 | //*-- Completely redesigned by Dmitri Peressounko March 2001 | |
35 | // | |
36 | //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make | |
37 | //*-- systematic usage of TFolders without changing the interface | |
38 | ////////////////////////////////////////////////////////////////////////////// | |
39 | ||
40 | ||
41 | // --- ROOT system --- | |
42 | ||
88cb7938 | 43 | #include "TTree.h" |
88cb7938 | 44 | |
45 | // --- Standard library --- | |
88cb7938 | 46 | |
47 | // --- AliRoot header files --- | |
48 | ||
88cb7938 | 49 | #include "AliEMCALLoader.h" |
50 | #include "AliEMCAL.h" | |
d64c959b | 51 | #include "AliEMCALHit.h" |
bb30e79d | 52 | #include "AliEMCALGetter.h" |
88cb7938 | 53 | |
54 | ClassImp(AliEMCALLoader) | |
d64c959b | 55 | |
56 | ||
88cb7938 | 57 | const TString AliEMCALLoader::fgkHitsName("HITS");//Name for TClonesArray with hits from one event |
58 | const TString AliEMCALLoader::fgkSDigitsName("SDIGITS");//Name for TClonesArray | |
59 | const TString AliEMCALLoader::fgkDigitsName("DIGITS");//Name for TClonesArray | |
88cb7938 | 60 | const TString AliEMCALLoader::fgkECARecPointsName("ECARECPOINTS");//Name for TClonesArray |
88cb7938 | 61 | const TString AliEMCALLoader::fgkTracksName("TRACKS");//Name for TClonesArray |
62 | const TString AliEMCALLoader::fgkRecParticlesName("RECPARTICLES");//Name for TClonesArray | |
63 | ||
88cb7938 | 64 | const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points |
88cb7938 | 65 | const TString AliEMCALLoader::fgkTrackSegmentsBranchName("EMCALTS");//Name for branch with TrackSegments |
66 | const TString AliEMCALLoader::fgkRecParticlesBranchName("EMCALRP");//Name for branch with Reconstructed Particles | |
d64c959b | 67 | |
88cb7938 | 68 | //____________________________________________________________________________ |
69 | AliEMCALLoader::AliEMCALLoader() | |
d64c959b | 70 | { |
88cb7938 | 71 | fDebug = 0; |
72 | fRecParticlesLoaded = kFALSE; | |
d64c959b | 73 | } |
74 | ||
88cb7938 | 75 | //____________________________________________________________________________ |
76 | AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername): | |
d64c959b | 77 | AliLoader(detname,eventfoldername) |
88cb7938 | 78 | { |
79 | fDebug=0; | |
80 | fRecParticlesLoaded = kFALSE; | |
81 | } | |
88cb7938 | 82 | |
d64c959b | 83 | //____________________________________________________________________________ |
88cb7938 | 84 | AliEMCALLoader::~AliEMCALLoader() |
85 | { | |
86 | //remove and delete arrays | |
87 | Clean(fgkHitsName); | |
88 | Clean(fgkSDigitsName); | |
89 | Clean(fgkDigitsName); | |
88cb7938 | 90 | Clean(fgkECARecPointsName); |
88cb7938 | 91 | Clean(fgkTracksName); |
92 | Clean(fgkRecParticlesName); | |
0ef40383 | 93 | CleanFolders() ; |
94 | // set to 0x0 the objgetter in AliGetter ... weird isn it ! | |
6b10bdac | 95 | /* |
bb30e79d | 96 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
8537c7e8 | 97 | if (gime) |
98 | gime->Reset() ; | |
6b10bdac | 99 | */ |
88cb7938 | 100 | } |
88cb7938 | 101 | |
88cb7938 | 102 | //____________________________________________________________________________ |
d64c959b | 103 | void AliEMCALLoader::CleanFolders() |
104 | { | |
105 | CleanRecParticles(); | |
106 | AliLoader::CleanFolders(); | |
107 | } | |
88cb7938 | 108 | |
d64c959b | 109 | //____________________________________________________________________________ |
88cb7938 | 110 | Int_t AliEMCALLoader::SetEvent() |
111 | { | |
d64c959b | 112 | //Cleans loaded stuff and and sets Files and Directories |
113 | // do not post any data to folder/tasks | |
88cb7938 | 114 | |
d64c959b | 115 | |
116 | Int_t retval = AliLoader::SetEvent(); | |
88cb7938 | 117 | if (retval) |
118 | { | |
119 | Error("SetEvent","AliLoader::SetEvent returned error"); | |
120 | return retval; | |
121 | } | |
122 | ||
123 | ||
124 | if (Hits()) Hits()->Clear(); | |
125 | if (SDigits()) SDigits()->Clear(); | |
126 | if (Digits()) Digits()->Clear(); | |
88cb7938 | 127 | if (ECARecPoints()) ECARecPoints()->Clear(); |
88cb7938 | 128 | if (TrackSegments()) TrackSegments()->Clear(); |
129 | if (RecParticles()) RecParticles()->Clear(); | |
130 | ||
131 | return 0; | |
132 | } | |
88cb7938 | 133 | |
d64c959b | 134 | //____________________________________________________________________________ |
88cb7938 | 135 | Int_t AliEMCALLoader::GetEvent() |
136 | { | |
d64c959b | 137 | //Overloads GetEvent method called by AliRunLoader::GetEvent(Int_t) method |
138 | //to add Rec Particles specific for EMCAL | |
139 | ||
140 | //First call the original method to get whatever from std. setup is needed | |
88cb7938 | 141 | Int_t retval; |
142 | ||
143 | retval = AliLoader::GetEvent(); | |
144 | if (retval) | |
d64c959b | 145 | { |
146 | Error("GetEvent","AliLoader::GetEvent returned error"); | |
147 | return retval; | |
148 | } | |
88cb7938 | 149 | |
150 | if (GetHitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadHits(); | |
151 | if (GetSDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadSDigits(); | |
152 | if (GetDigitsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadDigits(); | |
153 | if (GetRecPointsDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecPoints(); | |
154 | if (GetTracksDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadTracks(); | |
155 | if (GetRecParticlesDataLoader()->GetBaseDataLoader()->IsLoaded()) ReadRecParticles(); | |
156 | ||
157 | ||
d64c959b | 158 | //Now, check if RecPart were loaded |
88cb7938 | 159 | return 0; |
160 | } | |
88cb7938 | 161 | |
162 | //____________________________________________________________________________ | |
163 | const AliEMCAL * AliEMCALLoader::EMCAL() | |
164 | { | |
165 | // returns the EMCAL object | |
166 | AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(GetModulesFolder()->FindObject(fDetectorName)); | |
167 | if ( emcal == 0x0) | |
168 | if (fDebug) | |
169 | cout << "WARNING: AliEMCALLoader::EMCAL -> EMCAL module not found in Folders" << endl ; | |
170 | return emcal ; | |
171 | } | |
172 | ||
173 | //____________________________________________________________________________ | |
174 | const AliEMCALGeometry * AliEMCALLoader::EMCALGeometry() | |
175 | { | |
d64c959b | 176 | // Gets the EMCAL Geometry object |
88cb7938 | 177 | AliEMCALGeometry * rv = 0 ; |
178 | if (EMCAL() ) | |
179 | rv = EMCAL()->GetGeometry(); | |
180 | return rv ; | |
181 | } | |
182 | ||
88cb7938 | 183 | //____________________________________________________________________________ |
184 | Int_t AliEMCALLoader::LoadHits(Option_t* opt) | |
185 | { | |
d64c959b | 186 | //------- Hits ---------------------- |
187 | //Overload (extends) LoadHits implemented in AliLoader | |
188 | // | |
88cb7938 | 189 | Int_t res; |
190 | ||
191 | //First call the AliLoader's method to send the TreeH to folder | |
192 | res = AliLoader::LoadHits(opt); | |
193 | ||
194 | if (res) | |
195 | {//oops, error | |
196 | Error("LoadHits","AliLoader::LoadHits returned error"); | |
197 | return res; | |
198 | } | |
199 | ||
200 | //read the data from tree in folder and send it to folder | |
201 | res = ReadHits(); | |
202 | return 0; | |
203 | } | |
204 | ||
88cb7938 | 205 | //____________________________________________________________________________ |
206 | Int_t AliEMCALLoader::LoadSDigits(Option_t* opt) | |
d64c959b | 207 | { |
208 | // Loads the SDigits array in the folder structure | |
88cb7938 | 209 | Int_t res; |
210 | //First call the AliLoader's method to send the TreeS to folder | |
211 | res = AliLoader::LoadSDigits(opt); | |
212 | if (res) | |
d64c959b | 213 | {//oops, error |
214 | Error("PostSDigits","AliLoader::LoadSDigits returned error"); | |
215 | return res; | |
216 | } | |
88cb7938 | 217 | return ReadSDigits(); |
d64c959b | 218 | |
88cb7938 | 219 | } |
d64c959b | 220 | |
88cb7938 | 221 | //____________________________________________________________________________ |
222 | Int_t AliEMCALLoader::LoadDigits(Option_t* opt) | |
223 | { | |
d64c959b | 224 | // Loads the Digits array in the folder structure |
225 | ||
88cb7938 | 226 | Int_t res; |
227 | //First call the AliLoader's method to send the TreeS to folder | |
228 | res = AliLoader::LoadDigits(opt); | |
229 | if (res) | |
d64c959b | 230 | {//oops, error |
231 | Error("LoadDigits","AliLoader::LoadDigits returned error"); | |
232 | return res; | |
233 | } | |
88cb7938 | 234 | return ReadDigits(); |
235 | } | |
d64c959b | 236 | |
88cb7938 | 237 | //____________________________________________________________________________ |
238 | Int_t AliEMCALLoader::LoadRecPoints(Option_t* opt) | |
d64c959b | 239 | { |
240 | // Loads the RecPoints array in the folder structure | |
88cb7938 | 241 | Int_t res; |
242 | //First call the AliLoader's method to send the TreeR to folder | |
243 | res = AliLoader::LoadRecPoints(opt); | |
244 | if (res) | |
d64c959b | 245 | {//oops, error |
246 | Error("LoadRecPoints","AliLoader::LoadRecPoints returned error"); | |
247 | return res; | |
248 | } | |
249 | ||
88cb7938 | 250 | TFolder * emcalFolder = GetDetectorDataFolder(); |
251 | if ( emcalFolder == 0x0 ) | |
d64c959b | 252 | { |
253 | Error("LoadRecPoints","Can not get detector data folder"); | |
254 | return 1; | |
255 | } | |
88cb7938 | 256 | return ReadRecPoints(); |
257 | } | |
88cb7938 | 258 | |
d64c959b | 259 | //____________________________________________________________________________ |
88cb7938 | 260 | Int_t AliEMCALLoader::LoadTracks(Option_t* opt) |
261 | { | |
d64c959b | 262 | //Loads Tracks: Open File, Reads Tree and posts, Read Data and Posts |
263 | if (GetDebug()) | |
fdebddeb | 264 | printf("LoadTracks: opt = %s",opt); |
d64c959b | 265 | if (fTracksLoaded) |
266 | { | |
267 | Warning("LoadTracks","Tracks are already loaded"); | |
268 | return 0; | |
269 | } | |
270 | Int_t res; | |
88cb7938 | 271 | //First call the AliLoader's method to send the TreeS to folder |
d64c959b | 272 | if (GetTracksDataLoader()->GetBaseLoader(0)->IsLoaded() == kFALSE) |
273 | {//tracks can be loaded by LoadRecPoints | |
274 | res = AliLoader::LoadTracks(opt); | |
275 | if (res) | |
276 | {//oops, error | |
277 | Error("LoadTracks","AliLoader::LoadTracks returned error"); | |
278 | return res; | |
279 | } | |
280 | } | |
281 | res = ReadTracks(); | |
282 | if (res) | |
283 | { | |
284 | Error("LoadTracks","Error occured while reading Tracks"); | |
88cb7938 | 285 | return res; |
286 | } | |
d64c959b | 287 | |
288 | fTracksLoaded = kTRUE; | |
289 | return 0; | |
88cb7938 | 290 | } |
291 | ||
292 | //____________________________________________________________________________ | |
293 | Int_t AliEMCALLoader::LoadRecParticles(Option_t* opt) | |
d64c959b | 294 | { |
295 | // Loads the RecParticles array in the folder structure | |
88cb7938 | 296 | Int_t res; |
297 | //First call the AliLoader's method to send the TreeS to folder | |
298 | res = AliLoader::LoadRecParticles(opt); | |
299 | if (res) | |
d64c959b | 300 | {//oops, error |
301 | Error("LoadRecParticles","AliLoader::LoadRecParticles returned error"); | |
302 | return res; | |
303 | } | |
304 | ||
88cb7938 | 305 | TFolder * emcalFolder = GetDetectorDataFolder(); |
306 | if ( emcalFolder == 0x0 ) | |
d64c959b | 307 | { |
308 | Error("PostDigits","Can not get detector data folder"); | |
309 | return 1; | |
310 | } | |
88cb7938 | 311 | return ReadRecParticles(); |
312 | } | |
313 | ||
314 | //____________________________________________________________________________ | |
88cb7938 | 315 | Int_t AliEMCALLoader::PostHits() |
316 | { | |
9a2579c5 | 317 | // Post Hits |
88cb7938 | 318 | Int_t reval = AliLoader::PostHits(); |
319 | if (reval) | |
d64c959b | 320 | { |
88cb7938 | 321 | Error("PostHits","AliLoader:: returned error"); |
322 | return reval; | |
d64c959b | 323 | } |
88cb7938 | 324 | return ReadHits(); |
325 | } | |
88cb7938 | 326 | |
d64c959b | 327 | //____________________________________________________________________________ |
88cb7938 | 328 | Int_t AliEMCALLoader::PostSDigits() |
329 | { | |
d64c959b | 330 | // Posts the SDigits array to the folder structure |
88cb7938 | 331 | Int_t reval = AliLoader::PostSDigits(); |
332 | if (reval) | |
333 | { | |
334 | Error("PostSDigits","AliLoader::PostSDigits returned error"); | |
335 | return reval; | |
336 | } | |
337 | return ReadSDigits(); | |
338 | } | |
88cb7938 | 339 | |
d64c959b | 340 | //____________________________________________________________________________ |
88cb7938 | 341 | Int_t AliEMCALLoader::PostDigits() |
342 | { | |
d64c959b | 343 | // Posts the Digits array to the folder structure |
88cb7938 | 344 | Int_t reval = AliLoader::PostDigits(); |
345 | if (reval) | |
d64c959b | 346 | { |
347 | Error("PostDigits","AliLoader::PostDigits returned error"); | |
348 | return reval; | |
349 | } | |
88cb7938 | 350 | return ReadDigits(); |
351 | } | |
88cb7938 | 352 | |
d64c959b | 353 | //____________________________________________________________________________ |
88cb7938 | 354 | Int_t AliEMCALLoader::PostRecPoints() |
355 | { | |
d64c959b | 356 | // Posts the RecPoints array to the folder structure |
88cb7938 | 357 | Int_t reval = AliLoader::PostRecPoints(); |
358 | if (reval) | |
359 | { | |
360 | Error("PostRecPoints","AliLoader::PostRecPoints returned error"); | |
361 | return reval; | |
362 | } | |
363 | return ReadRecPoints(); | |
364 | } | |
365 | ||
366 | //____________________________________________________________________________ | |
88cb7938 | 367 | Int_t AliEMCALLoader::PostRecParticles() |
368 | { | |
d64c959b | 369 | // Posts the RecParticles array to the folder structure |
370 | ||
88cb7938 | 371 | Int_t reval = AliLoader::PostRecParticles(); |
372 | if (reval) | |
d64c959b | 373 | { |
374 | Error("PostRecParticles","AliLoader::PostRecParticles returned error"); | |
375 | return reval; | |
376 | } | |
88cb7938 | 377 | return ReadRecParticles(); |
378 | } | |
88cb7938 | 379 | |
d64c959b | 380 | //____________________________________________________________________________ |
88cb7938 | 381 | Int_t AliEMCALLoader::PostTracks() |
382 | { | |
d64c959b | 383 | // Posts the Tracks array to the folder structure |
88cb7938 | 384 | Int_t reval = AliLoader::PostTracks(); |
385 | if (reval) | |
d64c959b | 386 | { |
387 | Error("PostTracks","AliLoader::PostTracks returned error"); | |
388 | return reval; | |
389 | } | |
88cb7938 | 390 | return ReadTracks(); |
391 | } | |
88cb7938 | 392 | |
393 | //____________________________________________________________________________ | |
394 | Int_t AliEMCALLoader::ReadHits() | |
395 | { | |
d64c959b | 396 | // If there is no Clones Array in folder creates it and sends to folder |
397 | // then tries to read | |
398 | // Reads the first entry of EMCAL branch in hit tree TreeH() | |
399 | // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder | |
400 | // | |
88cb7938 | 401 | TObject** hitref = HitsRef(); |
402 | if(hitref == 0x0) | |
d64c959b | 403 | { |
404 | MakeHitsArray(); | |
88cb7938 | 405 | hitref = HitsRef(); |
d64c959b | 406 | } |
407 | ||
88cb7938 | 408 | TClonesArray* hits = dynamic_cast<TClonesArray*>(*hitref); |
d64c959b | 409 | |
88cb7938 | 410 | TTree* treeh = TreeH(); |
411 | ||
412 | if(treeh == 0) | |
d64c959b | 413 | { |
414 | Error("ReadHits"," Cannot read TreeH from folder"); | |
415 | return 1; | |
416 | } | |
88cb7938 | 417 | |
418 | TBranch * hitsbranch = treeh->GetBranch(fDetectorName); | |
419 | if (hitsbranch == 0) | |
d64c959b | 420 | { |
421 | Error("ReadHits"," Cannot find branch EMCAL"); | |
422 | return 1; | |
423 | } | |
88cb7938 | 424 | |
d64c959b | 425 | if (GetDebug()) |
fdebddeb | 426 | printf("ReadHits: Reading Hits"); |
88cb7938 | 427 | |
428 | if (hitsbranch->GetEntries() > 1) | |
d64c959b | 429 | { |
430 | TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000); | |
431 | ||
432 | hitsbranch->SetAddress(&tempo); | |
433 | Int_t index = 0 ; | |
434 | Int_t i = 0 ; | |
435 | for (i = 0 ; i < hitsbranch->GetEntries(); i++) | |
436 | { | |
437 | hitsbranch->GetEntry(i) ; | |
438 | Int_t j = 0 ; | |
439 | for ( j = 0 ; j < tempo->GetEntries() ; j++) | |
440 | { | |
441 | AliEMCALHit* hit = (AliEMCALHit*)tempo->At(j); | |
442 | new((*hits)[index]) AliEMCALHit( *hit ) ; | |
443 | index++ ; | |
444 | } | |
445 | } | |
0ef40383 | 446 | tempo->Delete() ; |
d64c959b | 447 | delete tempo; |
448 | } | |
88cb7938 | 449 | else |
d64c959b | 450 | { |
451 | hitsbranch->SetAddress(hitref); | |
452 | hitsbranch->GetEntry(0) ; | |
453 | } | |
454 | ||
88cb7938 | 455 | return 0; |
456 | } | |
d64c959b | 457 | |
88cb7938 | 458 | //____________________________________________________________________________ |
459 | Int_t AliEMCALLoader::ReadSDigits() | |
460 | { | |
d64c959b | 461 | // Read the summable digits tree TreeS(): |
462 | // Check if TClones is in folder | |
463 | // if not create and add to folder | |
464 | // connect to tree if available | |
465 | // Read the data | |
466 | ||
88cb7938 | 467 | TObject** sdref = SDigitsRef(); |
468 | if(sdref == 0x0) | |
d64c959b | 469 | { |
470 | MakeSDigitsArray(); | |
471 | sdref = SDigitsRef(); | |
472 | } | |
473 | ||
88cb7938 | 474 | TTree * treeS = TreeS(); |
475 | if(treeS==0) | |
d64c959b | 476 | { |
477 | //May happen if file is truncated or new in LoadSDigits | |
478 | //Error("ReadSDigits","There is no SDigit Tree"); | |
479 | return 0; | |
480 | } | |
88cb7938 | 481 | |
482 | TBranch * branch = treeS->GetBranch(fDetectorName); | |
483 | if (branch == 0) | |
d64c959b | 484 | {//easy, maybe just a new tree |
485 | //Error("ReadSDigits"," Cannot find branch EMCAL"); | |
486 | return 0; | |
487 | } | |
488 | ||
88cb7938 | 489 | branch->SetAddress(SDigitsRef()); |
490 | branch->GetEntry(0); | |
491 | return 0; | |
492 | } | |
493 | ||
494 | //____________________________________________________________________________ | |
495 | Int_t AliEMCALLoader::ReadDigits() | |
496 | { | |
d64c959b | 497 | // Read the summable digits tree TreeS(): |
498 | // Check if TClones is in folder | |
499 | // if not create and add to folder | |
500 | // connect to tree if available | |
501 | // Read the data | |
88cb7938 | 502 | |
503 | TObject** dref = DigitsRef(); | |
504 | if(dref == 0x0) | |
d64c959b | 505 | {//if there is not array in folder, create it and put it there |
506 | MakeDigitsArray(); | |
507 | dref = DigitsRef(); | |
508 | } | |
509 | ||
88cb7938 | 510 | TTree * treeD = TreeD(); |
511 | if(treeD==0) | |
d64c959b | 512 | { |
513 | //May happen if file is truncated or new in LoadSDigits | |
514 | //Error("ReadDigits","There is no Digit Tree"); | |
515 | return 0; | |
516 | } | |
517 | ||
88cb7938 | 518 | TBranch * branch = treeD->GetBranch(fDetectorName); |
519 | if (branch == 0) | |
d64c959b | 520 | {//easy, maybe just a new tree |
521 | //Error("ReadDigits"," Cannot find branch ",fDetectorName.Data()); | |
522 | return 0; | |
523 | } | |
88cb7938 | 524 | |
525 | branch->SetAddress(dref);//connect branch to buffer sitting in folder | |
526 | branch->GetEntry(0);//get first event | |
d64c959b | 527 | |
88cb7938 | 528 | return 0; |
529 | } | |
88cb7938 | 530 | |
d64c959b | 531 | //____________________________________________________________________________ |
88cb7938 | 532 | void AliEMCALLoader::UnloadRecParticles() |
533 | { | |
d64c959b | 534 | // Unloads the RecParticles array fromthe folder structure |
88cb7938 | 535 | fRecParticlesLoaded = kFALSE; |
536 | CleanRecParticles(); | |
537 | if (fTracksLoaded == kFALSE) UnloadTracks(); | |
538 | } | |
88cb7938 | 539 | |
d64c959b | 540 | //____________________________________________________________________________ |
88cb7938 | 541 | void AliEMCALLoader::UnloadTracks() |
542 | { | |
d64c959b | 543 | // Unloads the Tracks array fromthe folder structure |
544 | CleanTracks();//free the memory | |
545 | //in case RecPart are loaded we can not onload tree and close the file | |
546 | if (fRecParticlesLoaded == kFALSE) AliLoader::UnloadTracks(); | |
547 | fTracksLoaded = kFALSE;//mark that nobody needs them | |
88cb7938 | 548 | } |
88cb7938 | 549 | |
d64c959b | 550 | //____________________________________________________________________________ |
88cb7938 | 551 | void AliEMCALLoader::Track(Int_t itrack) |
552 | { | |
d64c959b | 553 | // Read the first entry of EMCAL branch in hit tree gAlice->TreeH() |
88cb7938 | 554 | if(TreeH()== 0) |
d64c959b | 555 | { |
556 | if (LoadHits()) | |
557 | { | |
558 | Error("Track","Can not load hits."); | |
559 | return; | |
560 | } | |
561 | } | |
88cb7938 | 562 | |
563 | TBranch * hitsbranch = dynamic_cast<TBranch*>(TreeH()->GetListOfBranches()->FindObject("EMCAL")) ; | |
564 | if ( !hitsbranch ) { | |
565 | if (fDebug) | |
566 | cout << "WARNING: AliEMCALLoader::ReadTreeH -> Cannot find branch EMCAL" << endl ; | |
567 | return ; | |
568 | } | |
569 | if(!Hits()) PostHits(); | |
d64c959b | 570 | |
88cb7938 | 571 | hitsbranch->SetAddress(HitsRef()); |
572 | hitsbranch->GetEntry(itrack); | |
d64c959b | 573 | |
88cb7938 | 574 | } |
d64c959b | 575 | |
88cb7938 | 576 | //____________________________________________________________________________ |
577 | Int_t AliEMCALLoader::ReadRecPoints() | |
578 | { | |
d64c959b | 579 | //Creates and posts to folder an array container, |
580 | //connects branch in tree (if exists), and reads data to array | |
88cb7938 | 581 | |
582 | MakeRecPointsArray(); | |
fdebddeb | 583 | |
584 | TObjArray * eca = 0x0 ; | |
88cb7938 | 585 | |
586 | TTree * treeR = TreeR(); | |
d64c959b | 587 | |
88cb7938 | 588 | if(treeR==0) |
d64c959b | 589 | { |
590 | //May happen if file is truncated or new in LoadSDigits | |
591 | return 0; | |
592 | } | |
593 | ||
88cb7938 | 594 | Int_t retval = 0; |
fdebddeb | 595 | |
88cb7938 | 596 | TBranch * ecabranch = treeR->GetBranch(fgkECARecPointsBranchName); |
597 | if (ecabranch == 0x0) | |
d64c959b | 598 | { |
599 | Error("ReadRecPoints","Can not get branch with ECA Rec. Points named %s",fgkECARecPointsBranchName.Data()); | |
600 | retval = 2; | |
601 | } | |
88cb7938 | 602 | else |
fdebddeb | 603 | { |
604 | ecabranch->SetAddress(&eca); | |
605 | ecabranch->GetEntry(0) ; | |
606 | } | |
607 | ||
608 | ||
88cb7938 | 609 | Int_t ii ; |
fdebddeb | 610 | |
88cb7938 | 611 | Int_t maxeca = eca->GetEntries() ; |
612 | for ( ii= 0 ; ii < maxeca ; ii++ ) | |
613 | ECARecPoints()->Add(eca->At(ii)) ; | |
fdebddeb | 614 | |
88cb7938 | 615 | return retval; |
616 | } | |
617 | ||
618 | //____________________________________________________________________________ | |
619 | Int_t AliEMCALLoader::ReadTracks() | |
620 | { | |
d64c959b | 621 | //Creates and posts to folder an array container, |
622 | //connects branch in tree (if exists), and reads data to arry | |
623 | ||
88cb7938 | 624 | TObject** trkref = TracksRef(); |
625 | if ( trkref == 0x0 ) | |
d64c959b | 626 | {//Create and post array |
627 | MakeTrackSegmentsArray(); | |
628 | trkref = TracksRef(); | |
629 | } | |
630 | ||
88cb7938 | 631 | TTree * treeT = TreeT(); |
632 | if(treeT==0) | |
d64c959b | 633 | { |
634 | //May happen if file is truncated or new in LoadSDigits, or the file is in update mode, | |
635 | //but tracking was not performed yet for a current event | |
636 | //Error("ReadTracks","There is no Tree with Tracks"); | |
637 | return 0; | |
638 | } | |
88cb7938 | 639 | |
640 | TBranch * branch = treeT->GetBranch(fgkTrackSegmentsBranchName); | |
641 | if (branch == 0) | |
d64c959b | 642 | {//easy, maybe just a new tree |
643 | Error("ReadTracks"," Cannot find branch named %s",fgkTrackSegmentsBranchName.Data()); | |
644 | return 0; | |
645 | } | |
646 | ||
88cb7938 | 647 | branch->SetAddress(trkref);//connect branch to buffer sitting in folder |
648 | branch->GetEntry(0);//get first event | |
649 | ||
650 | return 0; | |
651 | } | |
88cb7938 | 652 | |
d64c959b | 653 | //____________________________________________________________________________ |
88cb7938 | 654 | Int_t AliEMCALLoader::ReadRecParticles() |
655 | { | |
d64c959b | 656 | //Reads Reconstructed Particles from file |
657 | //Creates and posts to folder an array container, | |
658 | //connects branch in tree (if exists), and reads data to arry | |
88cb7938 | 659 | |
660 | TObject** recpartref = RecParticlesRef(); | |
661 | ||
662 | if ( recpartref == 0x0 ) | |
d64c959b | 663 | {//Create and post array |
664 | MakeRecParticlesArray(); | |
665 | recpartref = RecParticlesRef(); | |
666 | } | |
667 | ||
88cb7938 | 668 | TTree * treeP = TreeP(); |
669 | if(treeP==0) | |
d64c959b | 670 | { |
671 | //May happen if file is truncated or new in LoadSDigits, | |
672 | //or the file is in update mode, | |
673 | //but tracking was not performed yet for a current event | |
674 | // Error("ReadRecParticles","There is no Tree with Tracks and Reconstructed Particles"); | |
675 | return 0; | |
676 | } | |
88cb7938 | 677 | |
678 | TBranch * branch = treeP->GetBranch(fgkRecParticlesBranchName); | |
679 | if (branch == 0) | |
d64c959b | 680 | {//easy, maybe just a new tree |
681 | Error("ReadRecParticles"," Cannot find branch %s",fgkRecParticlesBranchName.Data()); | |
682 | return 0; | |
683 | } | |
684 | ||
88cb7938 | 685 | branch->SetAddress(recpartref);//connect branch to buffer sitting in folder |
686 | branch->GetEntry(0);//get first event | |
687 | ||
688 | return 0; | |
689 | } | |
690 | ||
d64c959b | 691 | //____________________________________________________________________________ |
88cb7938 | 692 | AliEMCALGeometry* AliEMCALLoader::GetEMCALGeometry() |
693 | { | |
d64c959b | 694 | //returns EMCAL geometry from gAlice |
695 | //static Method used by some classes where it is not convienient to pass eventfoldername | |
696 | if (gAlice == 0x0) | |
697 | return 0x0; | |
698 | AliEMCAL* emcal=dynamic_cast<AliEMCAL*>(gAlice->GetDetector("EMCAL")); | |
699 | if (emcal == 0x0) | |
700 | return 0x0; | |
701 | return emcal->GetGeometry(); | |
88cb7938 | 702 | } |
88cb7938 | 703 | |
d64c959b | 704 | //____________________________________________________________________________ |
88cb7938 | 705 | AliEMCALLoader* AliEMCALLoader::GetEMCALLoader(const char* eventfoldername) |
706 | { | |
d64c959b | 707 | // Get an instance of the EMCALLoader object |
88cb7938 | 708 | AliRunLoader* rn = AliRunLoader::GetRunLoader(eventfoldername); |
709 | if (rn == 0x0) | |
d64c959b | 710 | { |
711 | cerr<<"Error: <AliEMCALLoader::GetEMCALLoader>: " | |
712 | << "Can not find Run Loader in folder "<<eventfoldername<<endl; | |
713 | return 0x0; | |
714 | } | |
88cb7938 | 715 | return dynamic_cast<AliEMCALLoader*>(rn->GetLoader("EMCALLoader")); |
716 | } | |
88cb7938 | 717 | |
d64c959b | 718 | //____________________________________________________________________________ |
88cb7938 | 719 | Bool_t AliEMCALLoader::BranchExists(const TString& recName) |
9a2579c5 | 720 | { |
721 | // Check is branch exists | |
88cb7938 | 722 | if (fBranchTitle.IsNull()) return kFALSE; |
723 | TString dataname, zername ; | |
724 | TTree* tree; | |
725 | if(recName == "SDigits") { | |
726 | tree = TreeS(); | |
727 | dataname = GetDetectorName(); | |
728 | zername = "AliEMCALSDigitizer" ; | |
729 | } | |
730 | else if(recName == "Digits"){ | |
731 | tree = TreeD(); | |
732 | dataname = GetDetectorName(); | |
733 | zername = "AliEMCALDigitizer" ; | |
734 | } | |
88cb7938 | 735 | else if(recName == "ECARecPoints"){ |
736 | tree = TreeR(); | |
737 | dataname = fgkECARecPointsBranchName; | |
738 | zername = "AliEMCALClusterizer" ; | |
739 | } | |
88cb7938 | 740 | else if(recName == "TrackSegments"){ |
741 | tree = TreeT(); | |
742 | dataname = fgkTrackSegmentsBranchName; | |
743 | zername = "AliEMCALTrackSegmentMaker"; | |
744 | } | |
745 | else if(recName == "RecParticles"){ | |
746 | tree = TreeP(); | |
747 | dataname = fgkRecParticlesBranchName; | |
748 | zername = "AliEMCALPID"; | |
749 | } | |
750 | else | |
751 | return kFALSE ; | |
88cb7938 | 752 | |
753 | if(!tree ) | |
754 | return kFALSE ; | |
d64c959b | 755 | |
88cb7938 | 756 | TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ; |
757 | TIter next(lob) ; | |
758 | TBranch * branch = 0 ; | |
759 | TString titleName(fBranchTitle); | |
760 | titleName+=":"; | |
d64c959b | 761 | |
88cb7938 | 762 | while ((branch = (static_cast<TBranch*>(next())))) { |
763 | TString branchName(branch->GetName() ) ; | |
764 | TString branchTitle(branch->GetTitle() ) ; | |
765 | if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){ | |
766 | Warning("BranchExists","branch %s with title %s ",dataname.Data(),fBranchTitle.Data()); | |
767 | return kTRUE ; | |
768 | } | |
769 | if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){ | |
770 | Warning("BranchExists","branch AliEMCAL... with title %s ",branch->GetTitle()); | |
771 | return kTRUE ; | |
772 | } | |
773 | } | |
774 | return kFALSE ; | |
d64c959b | 775 | |
776 | } | |
88cb7938 | 777 | |
d64c959b | 778 | //____________________________________________________________________________ |
88cb7938 | 779 | void AliEMCALLoader::SetBranchTitle(const TString& btitle) |
d64c959b | 780 | { |
781 | // Gives a name to a branch in the folder structure | |
88cb7938 | 782 | if (btitle.CompareTo(fBranchTitle) == 0) return; |
783 | fBranchTitle = btitle; | |
784 | ReloadAll(); | |
d64c959b | 785 | } |
88cb7938 | 786 | |
d64c959b | 787 | //____________________________________________________________________________ |
88cb7938 | 788 | void AliEMCALLoader::CleanHits() |
789 | { | |
9a2579c5 | 790 | // Clean hits |
88cb7938 | 791 | AliLoader::CleanHits(); |
792 | //Clear an array | |
793 | TClonesArray* hits = Hits(); | |
0ef40383 | 794 | if (hits) |
795 | hits->Clear(); | |
88cb7938 | 796 | } |
88cb7938 | 797 | |
d64c959b | 798 | //____________________________________________________________________________ |
88cb7938 | 799 | void AliEMCALLoader::CleanSDigits() |
800 | { | |
d64c959b | 801 | // Cleans the SDigits array in the folder structure |
88cb7938 | 802 | AliLoader::CleanSDigits(); |
803 | TClonesArray* sdigits = SDigits(); | |
804 | if (sdigits) sdigits->Clear(); | |
805 | ||
806 | } | |
807 | //____________________________________________________________________________ | |
808 | ||
809 | void AliEMCALLoader::CleanDigits() | |
810 | { | |
d64c959b | 811 | // Cleans the Digits array in the folder structure |
88cb7938 | 812 | AliLoader::CleanDigits(); |
813 | TClonesArray* digits = Digits(); | |
814 | if (digits) digits->Clear(); | |
815 | } | |
88cb7938 | 816 | |
d64c959b | 817 | //____________________________________________________________________________ |
88cb7938 | 818 | void AliEMCALLoader::CleanRecPoints() |
819 | { | |
d64c959b | 820 | // Cleans the RecPoints array in the folder structure |
88cb7938 | 821 | AliLoader::CleanRecPoints(); |
fdebddeb | 822 | TObjArray* recpoints = ECARecPoints(); |
823 | if (recpoints) recpoints->Clear(); | |
824 | ||
88cb7938 | 825 | } |
88cb7938 | 826 | |
d64c959b | 827 | //____________________________________________________________________________ |
88cb7938 | 828 | void AliEMCALLoader::CleanTracks() |
829 | { | |
d64c959b | 830 | // Cleans the Tracks array in the folder structure |
88cb7938 | 831 | AliLoader::CleanTracks();//tree |
88cb7938 | 832 | //and clear the array |
833 | TClonesArray* tracks = TrackSegments(); | |
d64c959b | 834 | if (tracks) |
835 | tracks->Clear(); | |
88cb7938 | 836 | } |
88cb7938 | 837 | |
d64c959b | 838 | //____________________________________________________________________________ |
88cb7938 | 839 | void AliEMCALLoader::CleanRecParticles() |
d64c959b | 840 | { |
841 | // Cleans the RecParticles array in the folder structure | |
842 | TClonesArray *recpar = RecParticles(); | |
843 | if (recpar) | |
844 | recpar->Clear(); | |
845 | } | |
88cb7938 | 846 | |
88cb7938 | 847 | //____________________________________________________________________________ |
88cb7938 | 848 | // void AliEMCALLoader::ReadCalibrationDB(const char * database,const char * filename) |
849 | // { | |
850 | ||
851 | // if(fcdb && (strcmp(database,fcdb->GetTitle())==0)) | |
852 | // return ; | |
853 | ||
854 | // TFile * file = gROOT->GetFile(filename) ; | |
855 | // if(!file) | |
856 | // file = TFile::Open(filename); | |
857 | // if(!file){ | |
858 | // Error ("ReadCalibrationDB", "Cannot open file %s", filename) ; | |
859 | // return ; | |
860 | // } | |
861 | // if(fcdb) | |
862 | // fcdb->Delete() ; | |
863 | // fcdb = dynamic_cast<AliEMCALCalibrationDB *>(file->Get("AliEMCALCalibrationDB")) ; | |
864 | // if(!fcdb) | |
865 | // Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ; | |
866 | // } | |
867 | //____________________________________________________________________________ | |
868 | ||
869 | // AliEMCALSDigitizer* AliEMCALLoader::EMCALSDigitizer() | |
870 | // { | |
871 | // //return EMCAL SDigitizer | |
872 | // return dynamic_cast<AliEMCALSDigitizer*>(SDigitizer()) ; | |
873 | // } | |
874 | ||
875 | //____________________________________________________________________________ | |
876 | void AliEMCALLoader::MakeHitsArray() | |
877 | { | |
d64c959b | 878 | // Create the array for Hits |
88cb7938 | 879 | if (Hits()) return; |
880 | TClonesArray* hits = new TClonesArray("AliEMCALHit",1000); | |
881 | hits->SetName(fgkHitsName); | |
882 | GetDetectorDataFolder()->Add(hits); | |
883 | } | |
884 | ||
885 | //____________________________________________________________________________ | |
886 | void AliEMCALLoader::MakeSDigitsArray() | |
887 | { | |
d64c959b | 888 | // Create the array for SDigits |
88cb7938 | 889 | if ( SDigits()) return; |
890 | TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",1); | |
891 | sdigits->SetName(fgkSDigitsName); | |
892 | GetDetectorDataFolder()->Add(sdigits); | |
893 | } | |
894 | ||
895 | //____________________________________________________________________________ | |
896 | void AliEMCALLoader::MakeDigitsArray() | |
897 | { | |
d64c959b | 898 | // Create the array for Digits |
88cb7938 | 899 | if ( Digits()) return; |
900 | TClonesArray* digits = new TClonesArray("AliEMCALDigit",1); | |
901 | digits->SetName(fgkDigitsName); | |
902 | GetDetectorDataFolder()->Add(digits); | |
903 | ||
904 | } | |
905 | ||
906 | //____________________________________________________________________________ | |
907 | void AliEMCALLoader::MakeRecPointsArray() | |
fdebddeb | 908 | { |
9a2579c5 | 909 | // Make recpoints array |
88cb7938 | 910 | if ( ECARecPoints() == 0x0) { |
911 | if (GetDebug()>9) | |
fdebddeb | 912 | printf("MakeRecPointsArray: Making array for ECA"); |
88cb7938 | 913 | TObjArray* eca = new TObjArray(100) ; |
914 | eca->SetName(fgkECARecPointsName) ; | |
915 | GetDetectorDataFolder()->Add(eca); | |
fdebddeb | 916 | } |
88cb7938 | 917 | } |
918 | ||
919 | //____________________________________________________________________________ | |
920 | void AliEMCALLoader::MakeTrackSegmentsArray() | |
921 | { | |
d64c959b | 922 | // Create the array for TrackSegments |
923 | if ( TrackSegments()) | |
924 | return; | |
88cb7938 | 925 | TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ; |
926 | ts->SetName(fgkTracksName); | |
927 | GetDetectorDataFolder()->Add(ts); | |
88cb7938 | 928 | } |
929 | ||
930 | //____________________________________________________________________________ | |
931 | void AliEMCALLoader::MakeRecParticlesArray() | |
d64c959b | 932 | { |
933 | // Create the array for RecParticles | |
88cb7938 | 934 | if ( RecParticles()) return; |
935 | TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ; | |
936 | rp->SetName(fgkRecParticlesName); | |
937 | GetDetectorDataFolder()->Add(rp); | |
938 | } |