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