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