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