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