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