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