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