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