]>
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 | { | |
315 | Int_t reval = AliLoader::PostHits(); | |
316 | if (reval) | |
d64c959b | 317 | { |
88cb7938 | 318 | Error("PostHits","AliLoader:: returned error"); |
319 | return reval; | |
d64c959b | 320 | } |
88cb7938 | 321 | return ReadHits(); |
322 | } | |
88cb7938 | 323 | |
d64c959b | 324 | //____________________________________________________________________________ |
88cb7938 | 325 | Int_t AliEMCALLoader::PostSDigits() |
326 | { | |
d64c959b | 327 | // Posts the SDigits array to the folder structure |
88cb7938 | 328 | Int_t reval = AliLoader::PostSDigits(); |
329 | if (reval) | |
330 | { | |
331 | Error("PostSDigits","AliLoader::PostSDigits returned error"); | |
332 | return reval; | |
333 | } | |
334 | return ReadSDigits(); | |
335 | } | |
88cb7938 | 336 | |
d64c959b | 337 | //____________________________________________________________________________ |
88cb7938 | 338 | Int_t AliEMCALLoader::PostDigits() |
339 | { | |
d64c959b | 340 | // Posts the Digits array to the folder structure |
88cb7938 | 341 | Int_t reval = AliLoader::PostDigits(); |
342 | if (reval) | |
d64c959b | 343 | { |
344 | Error("PostDigits","AliLoader::PostDigits returned error"); | |
345 | return reval; | |
346 | } | |
88cb7938 | 347 | return ReadDigits(); |
348 | } | |
88cb7938 | 349 | |
d64c959b | 350 | //____________________________________________________________________________ |
88cb7938 | 351 | Int_t AliEMCALLoader::PostRecPoints() |
352 | { | |
d64c959b | 353 | // Posts the RecPoints array to the folder structure |
88cb7938 | 354 | Int_t reval = AliLoader::PostRecPoints(); |
355 | if (reval) | |
356 | { | |
357 | Error("PostRecPoints","AliLoader::PostRecPoints returned error"); | |
358 | return reval; | |
359 | } | |
360 | return ReadRecPoints(); | |
361 | } | |
362 | ||
363 | //____________________________________________________________________________ | |
88cb7938 | 364 | Int_t AliEMCALLoader::PostRecParticles() |
365 | { | |
d64c959b | 366 | // Posts the RecParticles array to the folder structure |
367 | ||
88cb7938 | 368 | Int_t reval = AliLoader::PostRecParticles(); |
369 | if (reval) | |
d64c959b | 370 | { |
371 | Error("PostRecParticles","AliLoader::PostRecParticles returned error"); | |
372 | return reval; | |
373 | } | |
88cb7938 | 374 | return ReadRecParticles(); |
375 | } | |
88cb7938 | 376 | |
d64c959b | 377 | //____________________________________________________________________________ |
88cb7938 | 378 | Int_t AliEMCALLoader::PostTracks() |
379 | { | |
d64c959b | 380 | // Posts the Tracks array to the folder structure |
88cb7938 | 381 | Int_t reval = AliLoader::PostTracks(); |
382 | if (reval) | |
d64c959b | 383 | { |
384 | Error("PostTracks","AliLoader::PostTracks returned error"); | |
385 | return reval; | |
386 | } | |
88cb7938 | 387 | return ReadTracks(); |
388 | } | |
88cb7938 | 389 | |
390 | //____________________________________________________________________________ | |
391 | Int_t AliEMCALLoader::ReadHits() | |
392 | { | |
d64c959b | 393 | // If there is no Clones Array in folder creates it and sends to folder |
394 | // then tries to read | |
395 | // Reads the first entry of EMCAL branch in hit tree TreeH() | |
396 | // Reads data from TreeH and stores it in TClonesArray that sits in DetectorDataFolder | |
397 | // | |
88cb7938 | 398 | TObject** hitref = HitsRef(); |
399 | if(hitref == 0x0) | |
d64c959b | 400 | { |
401 | MakeHitsArray(); | |
88cb7938 | 402 | hitref = HitsRef(); |
d64c959b | 403 | } |
404 | ||
88cb7938 | 405 | TClonesArray* hits = dynamic_cast<TClonesArray*>(*hitref); |
d64c959b | 406 | |
88cb7938 | 407 | TTree* treeh = TreeH(); |
408 | ||
409 | if(treeh == 0) | |
d64c959b | 410 | { |
411 | Error("ReadHits"," Cannot read TreeH from folder"); | |
412 | return 1; | |
413 | } | |
88cb7938 | 414 | |
415 | TBranch * hitsbranch = treeh->GetBranch(fDetectorName); | |
416 | if (hitsbranch == 0) | |
d64c959b | 417 | { |
418 | Error("ReadHits"," Cannot find branch EMCAL"); | |
419 | return 1; | |
420 | } | |
88cb7938 | 421 | |
d64c959b | 422 | if (GetDebug()) |
fdebddeb | 423 | printf("ReadHits: Reading Hits"); |
88cb7938 | 424 | |
425 | if (hitsbranch->GetEntries() > 1) | |
d64c959b | 426 | { |
427 | TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000); | |
428 | ||
429 | hitsbranch->SetAddress(&tempo); | |
430 | Int_t index = 0 ; | |
431 | Int_t i = 0 ; | |
432 | for (i = 0 ; i < hitsbranch->GetEntries(); i++) | |
433 | { | |
434 | hitsbranch->GetEntry(i) ; | |
435 | Int_t j = 0 ; | |
436 | for ( j = 0 ; j < tempo->GetEntries() ; j++) | |
437 | { | |
438 | AliEMCALHit* hit = (AliEMCALHit*)tempo->At(j); | |
439 | new((*hits)[index]) AliEMCALHit( *hit ) ; | |
440 | index++ ; | |
441 | } | |
442 | } | |
0ef40383 | 443 | tempo->Delete() ; |
d64c959b | 444 | delete tempo; |
445 | } | |
88cb7938 | 446 | else |
d64c959b | 447 | { |
448 | hitsbranch->SetAddress(hitref); | |
449 | hitsbranch->GetEntry(0) ; | |
450 | } | |
451 | ||
88cb7938 | 452 | return 0; |
453 | } | |
d64c959b | 454 | |
88cb7938 | 455 | //____________________________________________________________________________ |
456 | Int_t AliEMCALLoader::ReadSDigits() | |
457 | { | |
d64c959b | 458 | // Read the summable digits tree TreeS(): |
459 | // Check if TClones is in folder | |
460 | // if not create and add to folder | |
461 | // connect to tree if available | |
462 | // Read the data | |
463 | ||
88cb7938 | 464 | TObject** sdref = SDigitsRef(); |
465 | if(sdref == 0x0) | |
d64c959b | 466 | { |
467 | MakeSDigitsArray(); | |
468 | sdref = SDigitsRef(); | |
469 | } | |
470 | ||
88cb7938 | 471 | TTree * treeS = TreeS(); |
472 | if(treeS==0) | |
d64c959b | 473 | { |
474 | //May happen if file is truncated or new in LoadSDigits | |
475 | //Error("ReadSDigits","There is no SDigit Tree"); | |
476 | return 0; | |
477 | } | |
88cb7938 | 478 | |
479 | TBranch * branch = treeS->GetBranch(fDetectorName); | |
480 | if (branch == 0) | |
d64c959b | 481 | {//easy, maybe just a new tree |
482 | //Error("ReadSDigits"," Cannot find branch EMCAL"); | |
483 | return 0; | |
484 | } | |
485 | ||
88cb7938 | 486 | branch->SetAddress(SDigitsRef()); |
487 | branch->GetEntry(0); | |
488 | return 0; | |
489 | } | |
490 | ||
491 | //____________________________________________________________________________ | |
492 | Int_t AliEMCALLoader::ReadDigits() | |
493 | { | |
d64c959b | 494 | // Read the summable digits tree TreeS(): |
495 | // Check if TClones is in folder | |
496 | // if not create and add to folder | |
497 | // connect to tree if available | |
498 | // Read the data | |
88cb7938 | 499 | |
500 | TObject** dref = DigitsRef(); | |
501 | if(dref == 0x0) | |
d64c959b | 502 | {//if there is not array in folder, create it and put it there |
503 | MakeDigitsArray(); | |
504 | dref = DigitsRef(); | |
505 | } | |
506 | ||
88cb7938 | 507 | TTree * treeD = TreeD(); |
508 | if(treeD==0) | |
d64c959b | 509 | { |
510 | //May happen if file is truncated or new in LoadSDigits | |
511 | //Error("ReadDigits","There is no Digit Tree"); | |
512 | return 0; | |
513 | } | |
514 | ||
88cb7938 | 515 | TBranch * branch = treeD->GetBranch(fDetectorName); |
516 | if (branch == 0) | |
d64c959b | 517 | {//easy, maybe just a new tree |
518 | //Error("ReadDigits"," Cannot find branch ",fDetectorName.Data()); | |
519 | return 0; | |
520 | } | |
88cb7938 | 521 | |
522 | branch->SetAddress(dref);//connect branch to buffer sitting in folder | |
523 | branch->GetEntry(0);//get first event | |
d64c959b | 524 | |
88cb7938 | 525 | return 0; |
526 | } | |
88cb7938 | 527 | |
d64c959b | 528 | //____________________________________________________________________________ |
88cb7938 | 529 | void AliEMCALLoader::UnloadRecParticles() |
530 | { | |
d64c959b | 531 | // Unloads the RecParticles array fromthe folder structure |
88cb7938 | 532 | fRecParticlesLoaded = kFALSE; |
533 | CleanRecParticles(); | |
534 | if (fTracksLoaded == kFALSE) UnloadTracks(); | |
535 | } | |
88cb7938 | 536 | |
d64c959b | 537 | //____________________________________________________________________________ |
88cb7938 | 538 | void AliEMCALLoader::UnloadTracks() |
539 | { | |
d64c959b | 540 | // Unloads the Tracks array fromthe folder structure |
541 | CleanTracks();//free the memory | |
542 | //in case RecPart are loaded we can not onload tree and close the file | |
543 | if (fRecParticlesLoaded == kFALSE) AliLoader::UnloadTracks(); | |
544 | fTracksLoaded = kFALSE;//mark that nobody needs them | |
88cb7938 | 545 | } |
88cb7938 | 546 | |
d64c959b | 547 | //____________________________________________________________________________ |
88cb7938 | 548 | void AliEMCALLoader::Track(Int_t itrack) |
549 | { | |
d64c959b | 550 | // Read the first entry of EMCAL branch in hit tree gAlice->TreeH() |
88cb7938 | 551 | if(TreeH()== 0) |
d64c959b | 552 | { |
553 | if (LoadHits()) | |
554 | { | |
555 | Error("Track","Can not load hits."); | |
556 | return; | |
557 | } | |
558 | } | |
88cb7938 | 559 | |
560 | TBranch * hitsbranch = dynamic_cast<TBranch*>(TreeH()->GetListOfBranches()->FindObject("EMCAL")) ; | |
561 | if ( !hitsbranch ) { | |
562 | if (fDebug) | |
563 | cout << "WARNING: AliEMCALLoader::ReadTreeH -> Cannot find branch EMCAL" << endl ; | |
564 | return ; | |
565 | } | |
566 | if(!Hits()) PostHits(); | |
d64c959b | 567 | |
88cb7938 | 568 | hitsbranch->SetAddress(HitsRef()); |
569 | hitsbranch->GetEntry(itrack); | |
d64c959b | 570 | |
88cb7938 | 571 | } |
d64c959b | 572 | |
88cb7938 | 573 | //____________________________________________________________________________ |
574 | Int_t AliEMCALLoader::ReadRecPoints() | |
575 | { | |
d64c959b | 576 | //Creates and posts to folder an array container, |
577 | //connects branch in tree (if exists), and reads data to array | |
88cb7938 | 578 | |
579 | MakeRecPointsArray(); | |
fdebddeb | 580 | |
581 | TObjArray * eca = 0x0 ; | |
88cb7938 | 582 | |
583 | TTree * treeR = TreeR(); | |
d64c959b | 584 | |
88cb7938 | 585 | if(treeR==0) |
d64c959b | 586 | { |
587 | //May happen if file is truncated or new in LoadSDigits | |
588 | return 0; | |
589 | } | |
590 | ||
88cb7938 | 591 | Int_t retval = 0; |
fdebddeb | 592 | |
88cb7938 | 593 | TBranch * ecabranch = treeR->GetBranch(fgkECARecPointsBranchName); |
594 | if (ecabranch == 0x0) | |
d64c959b | 595 | { |
596 | Error("ReadRecPoints","Can not get branch with ECA Rec. Points named %s",fgkECARecPointsBranchName.Data()); | |
597 | retval = 2; | |
598 | } | |
88cb7938 | 599 | else |
fdebddeb | 600 | { |
601 | ecabranch->SetAddress(&eca); | |
602 | ecabranch->GetEntry(0) ; | |
603 | } | |
604 | ||
605 | ||
88cb7938 | 606 | Int_t ii ; |
fdebddeb | 607 | |
88cb7938 | 608 | Int_t maxeca = eca->GetEntries() ; |
609 | for ( ii= 0 ; ii < maxeca ; ii++ ) | |
610 | ECARecPoints()->Add(eca->At(ii)) ; | |
fdebddeb | 611 | |
88cb7938 | 612 | return retval; |
613 | } | |
614 | ||
615 | //____________________________________________________________________________ | |
616 | Int_t AliEMCALLoader::ReadTracks() | |
617 | { | |
d64c959b | 618 | //Creates and posts to folder an array container, |
619 | //connects branch in tree (if exists), and reads data to arry | |
620 | ||
88cb7938 | 621 | TObject** trkref = TracksRef(); |
622 | if ( trkref == 0x0 ) | |
d64c959b | 623 | {//Create and post array |
624 | MakeTrackSegmentsArray(); | |
625 | trkref = TracksRef(); | |
626 | } | |
627 | ||
88cb7938 | 628 | TTree * treeT = TreeT(); |
629 | if(treeT==0) | |
d64c959b | 630 | { |
631 | //May happen if file is truncated or new in LoadSDigits, or the file is in update mode, | |
632 | //but tracking was not performed yet for a current event | |
633 | //Error("ReadTracks","There is no Tree with Tracks"); | |
634 | return 0; | |
635 | } | |
88cb7938 | 636 | |
637 | TBranch * branch = treeT->GetBranch(fgkTrackSegmentsBranchName); | |
638 | if (branch == 0) | |
d64c959b | 639 | {//easy, maybe just a new tree |
640 | Error("ReadTracks"," Cannot find branch named %s",fgkTrackSegmentsBranchName.Data()); | |
641 | return 0; | |
642 | } | |
643 | ||
88cb7938 | 644 | branch->SetAddress(trkref);//connect branch to buffer sitting in folder |
645 | branch->GetEntry(0);//get first event | |
646 | ||
647 | return 0; | |
648 | } | |
88cb7938 | 649 | |
d64c959b | 650 | //____________________________________________________________________________ |
88cb7938 | 651 | Int_t AliEMCALLoader::ReadRecParticles() |
652 | { | |
d64c959b | 653 | //Reads Reconstructed Particles from file |
654 | //Creates and posts to folder an array container, | |
655 | //connects branch in tree (if exists), and reads data to arry | |
88cb7938 | 656 | |
657 | TObject** recpartref = RecParticlesRef(); | |
658 | ||
659 | if ( recpartref == 0x0 ) | |
d64c959b | 660 | {//Create and post array |
661 | MakeRecParticlesArray(); | |
662 | recpartref = RecParticlesRef(); | |
663 | } | |
664 | ||
88cb7938 | 665 | TTree * treeP = TreeP(); |
666 | if(treeP==0) | |
d64c959b | 667 | { |
668 | //May happen if file is truncated or new in LoadSDigits, | |
669 | //or the file is in update mode, | |
670 | //but tracking was not performed yet for a current event | |
671 | // Error("ReadRecParticles","There is no Tree with Tracks and Reconstructed Particles"); | |
672 | return 0; | |
673 | } | |
88cb7938 | 674 | |
675 | TBranch * branch = treeP->GetBranch(fgkRecParticlesBranchName); | |
676 | if (branch == 0) | |
d64c959b | 677 | {//easy, maybe just a new tree |
678 | Error("ReadRecParticles"," Cannot find branch %s",fgkRecParticlesBranchName.Data()); | |
679 | return 0; | |
680 | } | |
681 | ||
88cb7938 | 682 | branch->SetAddress(recpartref);//connect branch to buffer sitting in folder |
683 | branch->GetEntry(0);//get first event | |
684 | ||
685 | return 0; | |
686 | } | |
687 | ||
d64c959b | 688 | //____________________________________________________________________________ |
88cb7938 | 689 | AliEMCALGeometry* AliEMCALLoader::GetEMCALGeometry() |
690 | { | |
d64c959b | 691 | //returns EMCAL geometry from gAlice |
692 | //static Method used by some classes where it is not convienient to pass eventfoldername | |
693 | if (gAlice == 0x0) | |
694 | return 0x0; | |
695 | AliEMCAL* emcal=dynamic_cast<AliEMCAL*>(gAlice->GetDetector("EMCAL")); | |
696 | if (emcal == 0x0) | |
697 | return 0x0; | |
698 | return emcal->GetGeometry(); | |
88cb7938 | 699 | } |
88cb7938 | 700 | |
d64c959b | 701 | //____________________________________________________________________________ |
88cb7938 | 702 | AliEMCALLoader* AliEMCALLoader::GetEMCALLoader(const char* eventfoldername) |
703 | { | |
d64c959b | 704 | // Get an instance of the EMCALLoader object |
88cb7938 | 705 | AliRunLoader* rn = AliRunLoader::GetRunLoader(eventfoldername); |
706 | if (rn == 0x0) | |
d64c959b | 707 | { |
708 | cerr<<"Error: <AliEMCALLoader::GetEMCALLoader>: " | |
709 | << "Can not find Run Loader in folder "<<eventfoldername<<endl; | |
710 | return 0x0; | |
711 | } | |
88cb7938 | 712 | return dynamic_cast<AliEMCALLoader*>(rn->GetLoader("EMCALLoader")); |
713 | } | |
88cb7938 | 714 | |
d64c959b | 715 | //____________________________________________________________________________ |
88cb7938 | 716 | Bool_t AliEMCALLoader::BranchExists(const TString& recName) |
d64c959b | 717 | { |
88cb7938 | 718 | if (fBranchTitle.IsNull()) return kFALSE; |
719 | TString dataname, zername ; | |
720 | TTree* tree; | |
721 | if(recName == "SDigits") { | |
722 | tree = TreeS(); | |
723 | dataname = GetDetectorName(); | |
724 | zername = "AliEMCALSDigitizer" ; | |
725 | } | |
726 | else if(recName == "Digits"){ | |
727 | tree = TreeD(); | |
728 | dataname = GetDetectorName(); | |
729 | zername = "AliEMCALDigitizer" ; | |
730 | } | |
88cb7938 | 731 | else if(recName == "ECARecPoints"){ |
732 | tree = TreeR(); | |
733 | dataname = fgkECARecPointsBranchName; | |
734 | zername = "AliEMCALClusterizer" ; | |
735 | } | |
88cb7938 | 736 | else if(recName == "TrackSegments"){ |
737 | tree = TreeT(); | |
738 | dataname = fgkTrackSegmentsBranchName; | |
739 | zername = "AliEMCALTrackSegmentMaker"; | |
740 | } | |
741 | else if(recName == "RecParticles"){ | |
742 | tree = TreeP(); | |
743 | dataname = fgkRecParticlesBranchName; | |
744 | zername = "AliEMCALPID"; | |
745 | } | |
746 | else | |
747 | return kFALSE ; | |
88cb7938 | 748 | |
749 | if(!tree ) | |
750 | return kFALSE ; | |
d64c959b | 751 | |
88cb7938 | 752 | TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ; |
753 | TIter next(lob) ; | |
754 | TBranch * branch = 0 ; | |
755 | TString titleName(fBranchTitle); | |
756 | titleName+=":"; | |
d64c959b | 757 | |
88cb7938 | 758 | while ((branch = (static_cast<TBranch*>(next())))) { |
759 | TString branchName(branch->GetName() ) ; | |
760 | TString branchTitle(branch->GetTitle() ) ; | |
761 | if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){ | |
762 | Warning("BranchExists","branch %s with title %s ",dataname.Data(),fBranchTitle.Data()); | |
763 | return kTRUE ; | |
764 | } | |
765 | if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){ | |
766 | Warning("BranchExists","branch AliEMCAL... with title %s ",branch->GetTitle()); | |
767 | return kTRUE ; | |
768 | } | |
769 | } | |
770 | return kFALSE ; | |
d64c959b | 771 | |
772 | } | |
88cb7938 | 773 | |
d64c959b | 774 | //____________________________________________________________________________ |
88cb7938 | 775 | void AliEMCALLoader::SetBranchTitle(const TString& btitle) |
d64c959b | 776 | { |
777 | // Gives a name to a branch in the folder structure | |
88cb7938 | 778 | if (btitle.CompareTo(fBranchTitle) == 0) return; |
779 | fBranchTitle = btitle; | |
780 | ReloadAll(); | |
d64c959b | 781 | } |
88cb7938 | 782 | |
d64c959b | 783 | //____________________________________________________________________________ |
88cb7938 | 784 | void AliEMCALLoader::CleanHits() |
785 | { | |
786 | AliLoader::CleanHits(); | |
787 | //Clear an array | |
788 | TClonesArray* hits = Hits(); | |
0ef40383 | 789 | if (hits) |
790 | hits->Clear(); | |
88cb7938 | 791 | } |
88cb7938 | 792 | |
d64c959b | 793 | //____________________________________________________________________________ |
88cb7938 | 794 | void AliEMCALLoader::CleanSDigits() |
795 | { | |
d64c959b | 796 | // Cleans the SDigits array in the folder structure |
88cb7938 | 797 | AliLoader::CleanSDigits(); |
798 | TClonesArray* sdigits = SDigits(); | |
799 | if (sdigits) sdigits->Clear(); | |
800 | ||
801 | } | |
802 | //____________________________________________________________________________ | |
803 | ||
804 | void AliEMCALLoader::CleanDigits() | |
805 | { | |
d64c959b | 806 | // Cleans the Digits array in the folder structure |
88cb7938 | 807 | AliLoader::CleanDigits(); |
808 | TClonesArray* digits = Digits(); | |
809 | if (digits) digits->Clear(); | |
810 | } | |
88cb7938 | 811 | |
d64c959b | 812 | //____________________________________________________________________________ |
88cb7938 | 813 | void AliEMCALLoader::CleanRecPoints() |
814 | { | |
d64c959b | 815 | // Cleans the RecPoints array in the folder structure |
88cb7938 | 816 | AliLoader::CleanRecPoints(); |
fdebddeb | 817 | TObjArray* recpoints = ECARecPoints(); |
818 | if (recpoints) recpoints->Clear(); | |
819 | ||
88cb7938 | 820 | } |
88cb7938 | 821 | |
d64c959b | 822 | //____________________________________________________________________________ |
88cb7938 | 823 | void AliEMCALLoader::CleanTracks() |
824 | { | |
d64c959b | 825 | // Cleans the Tracks array in the folder structure |
88cb7938 | 826 | AliLoader::CleanTracks();//tree |
88cb7938 | 827 | //and clear the array |
828 | TClonesArray* tracks = TrackSegments(); | |
d64c959b | 829 | if (tracks) |
830 | tracks->Clear(); | |
88cb7938 | 831 | } |
88cb7938 | 832 | |
d64c959b | 833 | //____________________________________________________________________________ |
88cb7938 | 834 | void AliEMCALLoader::CleanRecParticles() |
d64c959b | 835 | { |
836 | // Cleans the RecParticles array in the folder structure | |
837 | TClonesArray *recpar = RecParticles(); | |
838 | if (recpar) | |
839 | recpar->Clear(); | |
840 | } | |
88cb7938 | 841 | |
88cb7938 | 842 | //____________________________________________________________________________ |
88cb7938 | 843 | // void AliEMCALLoader::ReadCalibrationDB(const char * database,const char * filename) |
844 | // { | |
845 | ||
846 | // if(fcdb && (strcmp(database,fcdb->GetTitle())==0)) | |
847 | // return ; | |
848 | ||
849 | // TFile * file = gROOT->GetFile(filename) ; | |
850 | // if(!file) | |
851 | // file = TFile::Open(filename); | |
852 | // if(!file){ | |
853 | // Error ("ReadCalibrationDB", "Cannot open file %s", filename) ; | |
854 | // return ; | |
855 | // } | |
856 | // if(fcdb) | |
857 | // fcdb->Delete() ; | |
858 | // fcdb = dynamic_cast<AliEMCALCalibrationDB *>(file->Get("AliEMCALCalibrationDB")) ; | |
859 | // if(!fcdb) | |
860 | // Error ("ReadCalibrationDB", "No database %s in file %s", database, filename) ; | |
861 | // } | |
862 | //____________________________________________________________________________ | |
863 | ||
864 | // AliEMCALSDigitizer* AliEMCALLoader::EMCALSDigitizer() | |
865 | // { | |
866 | // //return EMCAL SDigitizer | |
867 | // return dynamic_cast<AliEMCALSDigitizer*>(SDigitizer()) ; | |
868 | // } | |
869 | ||
870 | //____________________________________________________________________________ | |
871 | void AliEMCALLoader::MakeHitsArray() | |
872 | { | |
d64c959b | 873 | // Create the array for Hits |
88cb7938 | 874 | if (Hits()) return; |
875 | TClonesArray* hits = new TClonesArray("AliEMCALHit",1000); | |
876 | hits->SetName(fgkHitsName); | |
877 | GetDetectorDataFolder()->Add(hits); | |
878 | } | |
879 | ||
880 | //____________________________________________________________________________ | |
881 | void AliEMCALLoader::MakeSDigitsArray() | |
882 | { | |
d64c959b | 883 | // Create the array for SDigits |
88cb7938 | 884 | if ( SDigits()) return; |
885 | TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",1); | |
886 | sdigits->SetName(fgkSDigitsName); | |
887 | GetDetectorDataFolder()->Add(sdigits); | |
888 | } | |
889 | ||
890 | //____________________________________________________________________________ | |
891 | void AliEMCALLoader::MakeDigitsArray() | |
892 | { | |
d64c959b | 893 | // Create the array for Digits |
88cb7938 | 894 | if ( Digits()) return; |
895 | TClonesArray* digits = new TClonesArray("AliEMCALDigit",1); | |
896 | digits->SetName(fgkDigitsName); | |
897 | GetDetectorDataFolder()->Add(digits); | |
898 | ||
899 | } | |
900 | ||
901 | //____________________________________________________________________________ | |
902 | void AliEMCALLoader::MakeRecPointsArray() | |
fdebddeb | 903 | { |
88cb7938 | 904 | if ( ECARecPoints() == 0x0) { |
905 | if (GetDebug()>9) | |
fdebddeb | 906 | printf("MakeRecPointsArray: Making array for ECA"); |
88cb7938 | 907 | TObjArray* eca = new TObjArray(100) ; |
908 | eca->SetName(fgkECARecPointsName) ; | |
909 | GetDetectorDataFolder()->Add(eca); | |
fdebddeb | 910 | } |
88cb7938 | 911 | } |
912 | ||
913 | //____________________________________________________________________________ | |
914 | void AliEMCALLoader::MakeTrackSegmentsArray() | |
915 | { | |
d64c959b | 916 | // Create the array for TrackSegments |
917 | if ( TrackSegments()) | |
918 | return; | |
88cb7938 | 919 | TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ; |
920 | ts->SetName(fgkTracksName); | |
921 | GetDetectorDataFolder()->Add(ts); | |
88cb7938 | 922 | } |
923 | ||
924 | //____________________________________________________________________________ | |
925 | void AliEMCALLoader::MakeRecParticlesArray() | |
d64c959b | 926 | { |
927 | // Create the array for RecParticles | |
88cb7938 | 928 | if ( RecParticles()) return; |
929 | TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ; | |
930 | rp->SetName(fgkRecParticlesName); | |
931 | GetDetectorDataFolder()->Add(rp); | |
932 | } |