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