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