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