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