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