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