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