1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 29.05.2001 Yuri Kharlov:
20 Everywhere reading the treese TTree->GetEvent(i)
21 is replaced by reading the branches TBranch->GetEntry(0)
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.
33 // An example of how to use (see also class AliPHOSAnalyser):
34 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance("galice.root","test") ;
35 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36 // AliPHOSRecParticle * part = gime->RecParticle(1) ;
38 // please->GetEvent(event) ; // reads new event from galice.root
40 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
41 //*-- Completely redesigned by Dmitri Peressounko March 2001
43 //*-- YS June 2001 : renamed the original AliPHOSIndexToObject and make
44 //*-- systematic usage of TFolders without changing the interface
45 //////////////////////////////////////////////////////////////////////////////
48 // --- ROOT system ---
53 #include "TObjString.h"
55 #include "TParticle.h"
57 // --- Standard library ---
60 // --- AliRoot header files ---
63 #include "AliConfig.h"
64 #include "AliPHOSGetter.h"
66 #include "AliPHOSDigitizer.h"
67 #include "AliPHOSSDigitizer.h"
68 #include "AliPHOSClusterizer.h"
69 #include "AliPHOSClusterizer.h"
70 #include "AliPHOSTrackSegmentMaker.h"
71 #include "AliPHOSTrackSegmentMaker.h"
72 #include "AliPHOSTrackSegment.h"
73 #include "AliPHOSPID.h"
74 #include "AliPHOSPID.h"
75 #include "AliPHOSGeometry.h"
77 ClassImp(AliPHOSGetter)
79 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
81 //____________________________________________________________________________
82 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
84 //Initialize all lists
88 fHeaderFile = headerFile ;
89 fBranchTitle = branchTitle ;
90 fSDigitsTitle = branchTitle ;
91 fDigitsTitle = branchTitle ;
92 fRecPointsTitle = branchTitle ;
93 fRecParticlesTitle = branchTitle ;
94 fTrackSegmentsTitle = branchTitle ;
96 fPrimaries = new TObjArray(1) ;
98 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
99 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
100 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
101 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
102 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
103 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
104 fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
105 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
109 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
112 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
113 if(!fFile) { //if file was not opened yet, read gAlice
114 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
116 if (!fFile->IsOpen()) {
117 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
121 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
126 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
132 cout << "INFO: AliPHOSGetter -> Posting PHOS to Folders" << endl ;
133 if (gAlice->GetDetector("PHOS")) {
134 AliConfig * conf = AliConfig::Instance() ;
135 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
136 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
139 cerr << "ERROR: AliPHOSGetter -> detector PHOS not found" << endl ;
144 //____________________________________________________________________________
145 AliPHOSGetter::~AliPHOSGetter(){
148 fPrimaries->Delete() ;
152 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
153 TCollection * folderslist = phosF->GetListOfFolders() ;
154 TIter next(folderslist) ;
155 TFolder * folder = 0 ;
156 while ( (folder = static_cast<TFolder*>(next())) )
157 phosF->Remove(folder) ;
165 //____________________________________________________________________________
166 void AliPHOSGetter::CreateWhiteBoard() const
171 //____________________________________________________________________________
172 AliPHOSGetter * AliPHOSGetter::GetInstance()
174 // Returns the pointer of the unique instance already defined
176 AliPHOSGetter * rv = 0 ;
180 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
185 //____________________________________________________________________________
186 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
187 const char* branchTitle)
189 // Creates and returns the pointer of the unique instance
190 // Must be called only when the environment has changed
193 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
194 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
197 fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
199 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
201 if (fgObjGetter->HasFailed() )
205 // Posts a few item to the white board (folders)
206 // fgObjGetter->CreateWhiteBoard() ;
212 //____________________________________________________________________________
213 const AliPHOS * AliPHOSGetter::PHOS()
215 // returns the PHOS object
216 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
219 cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
223 //____________________________________________________________________________
224 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
226 AliPHOSGeometry * rv = 0 ;
228 rv = PHOS()->GetGeometry() ;
232 //____________________________________________________________________________
233 Bool_t AliPHOSGetter::PostPrimaries(void) const
234 { //------- Primaries ----------------------
236 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
238 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
239 if ( !primariesFolder ) {
241 cout << "WARNING: AliPHOSGetter::Post Primaries -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
242 cout << "INFO: AliPHOSGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder << "/Primaries/" << endl;
244 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
246 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
247 primaries->SetName("Primaries") ;
248 primariesFolder->Add(primaries) ;
253 //____________________________________________________________________________
254 TObject** AliPHOSGetter::PrimariesRef(void) const
255 { //------- Primaries ----------------------
258 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
259 if ( !fPrimariesFolder ) {
260 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
264 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
265 if ( !primariesFolder ) {
266 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
270 TObject * p = primariesFolder->FindObject("Primaries") ;
272 cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
276 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
279 //____________________________________________________________________________
280 Bool_t AliPHOSGetter::PostHits(void) const
281 { //------- Hits ----------------------
283 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
285 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
288 cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
289 cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
291 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
293 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
294 hits->SetName("Hits") ;
295 phosFolder->Add(hits) ;
300 //____________________________________________________________________________
301 TObject** AliPHOSGetter::HitsRef(void) const
302 { //------- Hits ----------------------
305 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
306 if ( !fHitsFolder ) {
307 cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
311 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
313 cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
317 TObject * h = phosFolder->FindObject("Hits") ;
319 cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
323 return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
326 //____________________________________________________________________________
327 Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
328 { //---------- SDigits -------------------------
331 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
332 // because you can have sdigits from several hit files for mixing
334 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
337 cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
338 cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
340 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
342 TString subdir(headerFile) ;
343 subdir.ReplaceAll("/","_") ;
344 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
345 if ( !phosSubFolder )
346 phosSubFolder = phosFolder->AddFolder(subdir, "");
348 TObject * sd = phosSubFolder->FindObject(name);
351 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
352 << " already exists!" << endl ;
354 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
355 sdigits->SetName(name) ;
356 phosSubFolder->Add(sdigits) ;
361 //____________________________________________________________________________
362 TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
363 { //------- SDigits ----------------------
365 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
367 if ( !fSDigitsFolder ) {
368 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
372 TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
374 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
378 TFolder * phosSubFolder = 0 ;
380 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
382 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
385 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
389 TObject * dis = phosSubFolder->FindObject(name) ;
393 return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
397 //____________________________________________________________________________
398 Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
399 { //---------- SDigitizer -------------------------
401 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
404 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
407 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
410 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
413 cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
414 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
416 phos = new TTask("PHOS", "") ;
419 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
422 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
423 phos->GetListOfTasks()->Remove(phossd) ;
425 phos->Add(sdigitizer) ;
430 //____________________________________________________________________________
431 TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
434 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
436 cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
440 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
442 cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
446 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
448 return phos->GetListOfTasks()->GetObjectRef(task) ;
452 //____________________________________________________________________________
453 Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
454 { //---------- SDigitizer -------------------------
456 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
459 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
461 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
465 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
468 cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
469 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
471 phos = new TTask("PHOS", "") ;
475 TString sdname(name) ;
478 sdname.ReplaceAll("/","_") ;
479 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
481 phossd = new AliPHOSSDigitizer() ;
482 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
483 phossd->SetName(sdname) ;
484 phossd->SetTitle(file) ;
491 //____________________________________________________________________________
492 Bool_t AliPHOSGetter::PostDigits(const char * name) const
493 { //---------- Digits -------------------------
495 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
497 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
501 cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
502 cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
504 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
507 TObject* dig = phosFolder->FindObject( name ) ;
509 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
510 digits->SetName(name) ;
511 phosFolder->Add(digits) ;
516 //____________________________________________________________________________
517 TObject** AliPHOSGetter::DigitsRef(const char * name) const
518 { //------- Digits ----------------------
520 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
522 if ( !fDigitsFolder ) {
523 cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
527 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
529 cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
533 TObject * d = phosFolder->FindObject(name) ;
537 return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
541 //____________________________________________________________________________
542 Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
543 { //---------- Digitizer -------------------------
545 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
548 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
551 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
554 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
555 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
557 phos = new TTask("PHOS", "") ;
561 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
564 phos->GetListOfTasks()->Remove(phosd) ;
566 phos->Add(digitizer) ;
570 //____________________________________________________________________________
571 Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
572 { //---------- Digitizer -------------------------
574 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
576 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
578 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
582 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
585 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
586 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
588 phos = new TTask("PHOS", "") ;
592 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
594 phosd = new AliPHOSDigitizer() ;
595 phosd->SetName(fDigitsTitle) ;
596 phosd->SetTitle(fHeaderFile) ;
602 //____________________________________________________________________________
603 TObject** AliPHOSGetter::DigitizerRef(const char * name) const
605 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
607 cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
611 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
613 cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
617 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
619 return phos->GetListOfTasks()->GetObjectRef(task) ;
623 //____________________________________________________________________________
624 Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
625 { // -------------- RecPoints -------------------------------------------
627 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
628 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
630 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
634 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
635 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
637 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
641 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
642 if ( !phosRPoEMCAFolder ) {
644 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
645 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints" << endl;
647 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
650 TObject * erp = phosFolder->FindObject( name ) ;
652 TObjArray * emcrp = new TObjArray(100) ;
653 emcrp->SetName(name) ;
654 phosRPoEMCAFolder->Add(emcrp) ;
658 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
659 if ( !phosRPoCPVFolder ) {
661 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/ not found!" << endl;
662 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
664 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
667 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
669 TObjArray * cpvrp = new TObjArray(100) ;
670 cpvrp->SetName(name) ;
671 phosRPoCPVFolder->Add(cpvrp) ;
676 //____________________________________________________________________________
677 TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
678 { // -------------- RecPoints -------------------------------------------
680 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
682 if ( !fRecoFolder ) {
683 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
687 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
689 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
694 TObject * erp = phosFolder->FindObject(name ) ;
698 return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
702 //____________________________________________________________________________
703 TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
704 { // -------------- RecPoints -------------------------------------------
706 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
708 if ( !fRecoFolder ) {
709 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
713 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
715 cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
719 TObject * crp = phosFolder->FindObject(name ) ;
723 return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
727 //____________________________________________________________________________
728 Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
729 { // ------------------ AliPHOSClusterizer ------------------------
731 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
733 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
736 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
740 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
743 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
744 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
746 phos = new TTask("PHOS", "") ;
750 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
753 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
755 phos->GetListOfTasks()->Remove(phoscl) ;
761 //____________________________________________________________________________
762 TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
763 { // ------------------ AliPHOSClusterizer ------------------------
765 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
768 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
772 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
774 cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
778 TList * l = phos->GetListOfTasks() ;
782 TString cluname(name) ;
784 while((task = static_cast<TTask *>(it.Next()) )){
785 TString taskname(task->GetName()) ;
786 if(taskname.BeginsWith(cluname)){
793 return l->GetObjectRef(clu) ;
798 //____________________________________________________________________________
799 Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
800 { // ------------------ AliPHOSClusterizer ------------------------
802 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
804 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
807 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
811 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
814 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
815 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
817 phos = new TTask("PHOS", "") ;
821 AliPHOSClusterizer * phoscl = new AliPHOSClusterizer() ;
823 clun+=":clusterizer" ;
824 phoscl->SetName(clun) ;
830 //____________________________________________________________________________
831 Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
832 { // ---------------TrackSegments -----------------------------------
834 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
836 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
840 cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
841 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS" << endl;
843 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
846 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
847 if ( !phosTSFolder ) {
849 cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
850 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/" << endl;
852 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
855 TObject * tss = phosTSFolder->FindObject( name ) ;
857 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
859 phosTSFolder->Add(ts) ;
864 //____________________________________________________________________________
865 TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
866 { // ---------------TrackSegments -----------------------------------
868 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
870 if ( !fRecoFolder ) {
871 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "not found!" << endl;
875 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
877 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
881 TObject * tss = phosFolder->FindObject(name) ;
885 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
888 //____________________________________________________________________________
889 Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
890 { //------------Track Segment Maker ------------------------------
892 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
894 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
897 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
901 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
904 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
905 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
907 phos = new TTask("PHOS", "") ;
911 AliPHOSTrackSegmentMaker * phosts =
912 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
915 phos->GetListOfTasks()->Remove(phosts) ;
921 //____________________________________________________________________________
922 Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
923 { //------------Track Segment Maker ------------------------------
925 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
928 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
931 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
935 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
938 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
939 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
941 phos = new TTask("PHOS", "") ;
945 AliPHOSTrackSegmentMaker * phosts =
946 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(name)) ;
948 phosts = new AliPHOSTrackSegmentMaker() ;
950 tsn+=":tracksegmentmaker" ;
951 phosts->SetName(tsn) ;
958 //____________________________________________________________________________
959 TObject** AliPHOSGetter::TSMakerRef(const char * name) const
960 { //------------Track Segment Maker ------------------------------
962 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
965 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
969 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
971 cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
975 TList * l = phos->GetListOfTasks() ;
979 TString tsmname(name) ;
981 while((task = static_cast<TTask *>(it.Next()) )){
982 TString taskname(task->GetName()) ;
983 if(taskname.BeginsWith(tsmname)){
990 return l->GetObjectRef(tsm) ;
996 //____________________________________________________________________________
997 Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
998 { // -------------------- RecParticles ------------------------
1000 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1002 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
1004 if ( !phosFolder ) {
1006 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
1007 cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
1009 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
1012 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
1013 if ( !phosRPaFolder ) {
1015 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1016 cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/" << endl;
1018 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
1021 TObject * rps = phosRPaFolder->FindObject( name ) ;
1023 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
1025 phosRPaFolder->Add(rp) ;
1030 //____________________________________________________________________________
1031 TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
1032 { // ---------------TrackSegments -----------------------------------
1034 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1036 if ( !fRecoFolder ) {
1037 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder->GetName() << " not found!" << endl;
1041 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1042 if ( !phosFolder ) {
1043 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1047 TObject * tss = phosFolder->FindObject(name ) ;
1051 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
1054 //____________________________________________________________________________
1055 Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
1056 { // ------------AliPHOS PID -----------------------------
1058 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1061 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1065 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1068 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1069 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1071 phos = new TTask("PHOS", "") ;
1075 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
1078 cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
1079 << " already exists" << endl ;
1080 phos->GetListOfTasks()->Remove(phospid) ;
1087 //____________________________________________________________________________
1088 Bool_t AliPHOSGetter::PostPID(const char * name) const
1090 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1092 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1095 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1099 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1102 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1103 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1105 phos = new TTask("PHOS", "") ;
1109 TList * l = phos->GetListOfTasks() ;
1111 TString pidname(name) ;
1114 while((task = static_cast<TTask *>(it.Next()) )){
1115 TString taskname(task->GetName()) ;
1116 if(taskname.BeginsWith(pidname))
1120 AliPHOSPID * phospid = new AliPHOSPID() ;
1121 phospid->SetName(pidname) ;
1122 phos->Add(phospid) ;
1127 //____________________________________________________________________________
1128 TObject** AliPHOSGetter::PIDRef(const char * name) const
1129 { //------------PID ------------------------------
1131 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1134 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1138 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1140 cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
1144 TList * l = phos->GetListOfTasks() ;
1148 TString pidname(name) ;
1150 while((task = static_cast<TTask *>(it.Next()) )){
1151 TString taskname(task->GetName()) ;
1152 if(taskname.BeginsWith(pidname)){
1159 return l->GetObjectRef(pid) ;
1165 //____________________________________________________________________________
1166 Bool_t AliPHOSGetter::PostQA(void) const
1167 { // ------------------ QA ---------------------------------
1169 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1171 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1172 if ( !phosFolder ) {
1174 cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1175 cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
1177 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1183 //____________________________________________________________________________
1184 TObject** AliPHOSGetter::AlarmsRef(void) const
1185 { //------- Alarms ----------------------
1188 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1190 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1194 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1195 if ( !phosFolder ) {
1196 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1200 return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
1203 //____________________________________________________________________________
1204 const TParticle * AliPHOSGetter::Primary(Int_t index) const
1206 // Return primary particle numbered by <index>
1210 TParticle * p = gAlice->Particle(index) ;
1211 if (p->GetFirstMother() != -1 ) {
1212 cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
1217 // Int_t primaryIndex = index % 10000000 ;
1218 // Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1220 // if ( primaryList > 0 ) {
1222 // cout << " Getter does not support currently Mixing of primary " << endl ;
1223 // cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1228 // return gAlice->Particle(primaryIndex) ;
1232 //____________________________________________________________________________
1233 const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
1235 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1243 Int_t daughterIndex = p->GetDaughter(index-1) ;
1244 return gAlice->Particle(daughterIndex) ;
1250 //____________________________________________________________________________
1251 Int_t AliPHOSGetter::ReadTreeD()
1253 // Read the digit tree gAlice->TreeD()
1254 if(gAlice->TreeD()== 0){
1255 cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
1259 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1261 TBranch * branch = 0 ;
1262 TBranch * digitsbranch = 0 ;
1263 TBranch * digitizerbranch = 0 ;
1264 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1266 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
1267 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1268 digitsbranch = branch ;
1271 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1272 digitizerbranch = branch ;
1273 digitizerfound = kTRUE ;
1277 if ( !phosfound || !digitizerfound ) {
1279 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1280 << fDigitsTitle << endl ;
1285 if(!Digits(fDigitsTitle) )
1286 PostDigits(fDigitsTitle);
1287 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1288 digitsbranch->GetEntry(0) ;
1291 // read the Digitizer
1292 if(!Digitizer(fDigitsTitle))
1293 PostDigitizer(fDigitsTitle) ;
1294 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1295 digitizerbranch->GetEntry(0) ;
1300 //____________________________________________________________________________
1301 Int_t AliPHOSGetter::ReadTreeH()
1303 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1305 if(gAlice->TreeH()== 0){
1306 cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1310 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
1311 if ( !hitsbranch ) {
1313 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1319 if (hitsbranch->GetEntries() > 1 ) {
1320 TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
1321 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1322 hitsbranch->SetAddress(&tempo) ;
1325 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1326 hitsbranch->GetEntry(i) ;
1328 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1329 const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
1330 new((*hits)[index]) AliPHOSHit( *hit ) ;
1337 hitsbranch->SetAddress(HitsRef()) ;
1338 hitsbranch->GetEntry(0) ;
1343 //____________________________________________________________________________
1344 void AliPHOSGetter::Track(Int_t itrack)
1346 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1348 if(gAlice->TreeH()== 0){
1349 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1353 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
1354 if ( !hitsbranch ) {
1356 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1362 hitsbranch->SetAddress(HitsRef()) ;
1363 hitsbranch->GetEntry(itrack) ;
1367 //____________________________________________________________________________
1368 void AliPHOSGetter::ReadTreeQA()
1370 // Read the digit tree gAlice->TreeQA()
1371 // so far only PHOS knows about this Tree
1373 if(PHOS()->TreeQA()== 0){
1374 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
1378 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1381 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
1388 qabranch->SetAddress(AlarmsRef()) ;
1390 qabranch->GetEntry(0) ;
1393 // TFolder * alarmsF = Alarms() ;
1394 // alarmsF->Clear() ;
1395 // qabranch->SetAddress(&alarmsF) ;
1396 // qabranch->GetEntry(0) ;
1400 //____________________________________________________________________________
1401 Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
1403 // Read the reconstrunction tree gAlice->TreeR()
1404 // A particularity has been introduced here :
1405 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1406 // being for example give in AliPHOSPID(fileName, title)
1407 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1408 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1409 // from a given set of TrackSegments (with a given name)
1410 // This is why any is NOT used to read the branch of RecParticles
1413 if(gAlice->TreeR()== 0){
1414 cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
1419 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1421 TBranch * branch = 0 ;
1422 TBranch * emcbranch = 0 ;
1423 TBranch * cpvbranch = 0 ;
1424 TBranch * clusterizerbranch = 0 ;
1425 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1427 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
1428 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 || any) {
1429 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1430 emcbranch = branch ;
1431 phosemcrpfound = kTRUE ;
1433 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1434 cpvbranch = branch ;
1435 phoscpvrpfound = kTRUE ;
1437 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1438 clusterizerbranch = branch ;
1439 clusterizerfound = kTRUE ;
1443 if ( !phosemcrpfound ) {
1445 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1446 << fRecPointsTitle << endl ;
1449 if ( !phoscpvrpfound ) {
1451 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1452 << fRecPointsTitle << endl ;
1455 if ( !clusterizerfound ) {
1457 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
1458 << fRecPointsTitle << endl ;
1462 // Read and Post the RecPoints
1463 if(!EmcRecPoints(fRecPointsTitle) )
1464 PostRecPoints(fRecPointsTitle) ;
1466 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1467 emcbranch->GetEntry(0) ;
1469 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
1470 cpvbranch->GetEntry(0) ;
1472 if(!Clusterizer(fRecPointsTitle) )
1473 PostClusterizer(fRecPointsTitle) ;
1475 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1476 clusterizerbranch->GetEntry(0) ;
1479 //------------------- TrackSegments ---------------------
1481 TBranch * tsbranch = 0 ;
1482 TBranch * tsmakerbranch = 0 ;
1483 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
1485 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
1486 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 || any) {
1487 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1489 phostsfound = kTRUE ;
1491 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1492 tsmakerbranch = branch ;
1493 tsmakerfound = kTRUE ;
1497 if ( !phostsfound || !tsmakerfound ) {
1499 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1500 << fTrackSegmentsTitle << endl ;
1504 // Read and Post the TrackSegments
1505 if(!TrackSegments(fTrackSegmentsTitle))
1506 PostTrackSegments(fTrackSegmentsTitle) ;
1508 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1509 tsbranch->GetEntry(0) ;
1511 // Read and Post the TrackSegment Maker
1512 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1513 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1515 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1516 tsmakerbranch->GetEntry(0) ;
1519 //------------ RecParticles ----------------------------
1521 TBranch * rpabranch = 0 ;
1522 TBranch * pidbranch = 0 ;
1523 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1525 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
1526 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1527 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1528 rpabranch = branch ;
1529 phosrpafound = kTRUE ;
1531 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1532 pidbranch = branch ;
1537 if ( !phosrpafound || !pidfound ) {
1539 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1540 << fRecParticlesTitle << endl ;
1544 // Read and Post the RecParticles
1545 if(!RecParticles(fRecParticlesTitle))
1546 PostRecParticles(fRecParticlesTitle) ;
1548 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1549 rpabranch->GetEntry(0) ;
1551 // Read and Post the PID
1552 if(!PID(fRecParticlesTitle))
1553 PostPID(fRecParticlesTitle) ;
1555 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1556 pidbranch->GetEntry(0) ;
1561 //____________________________________________________________________________
1562 Int_t AliPHOSGetter::ReadTreeS(Int_t event)
1564 // Read the summable digits tree gAlice->TreeS()
1566 // loop over all opened files and read their SDigits to the White Board
1567 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
1569 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1570 TCollection * folderslist = phosF->GetListOfFolders() ;
1572 //Add current file to list if it is not there yet
1574 TString subdir(fHeaderFile) ;
1575 subdir.ReplaceAll("/","_") ;
1577 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1578 phosF->AddFolder(subdir, "");
1581 TIter next(folderslist) ;
1582 TFolder * folder = 0 ;
1585 while ( (folder = static_cast<TFolder*>(next())) ) {
1586 TString fileName(folder->GetName()) ;
1587 fileName.ReplaceAll("_","/") ;
1588 if(fHeaderFile.CompareTo(fileName) == 0 )
1589 treeS=gAlice->TreeS() ;
1591 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1594 // Get SDigits Tree header from file
1595 TString treeName("TreeS") ;
1597 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1600 cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
1604 //set address of the SDigits and SDigitizer
1605 TBranch * sdigitsBranch = 0;
1606 TBranch * sdigitizerBranch = 0;
1607 TBranch * branch = 0 ;
1608 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1610 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1612 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
1613 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1615 sdigitsBranch = branch ;
1618 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1619 sdigitizerfound = kTRUE ;
1620 sdigitizerBranch = branch ;
1623 if ( !phosfound || !sdigitizerfound ) {
1625 cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1626 << " not found" << endl ;
1630 if ( !folder->FindObject(fSDigitsTitle) )
1631 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1633 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1634 sdigitsBranch->GetEntry(0) ;
1636 TString sdname(fSDigitsTitle) ;
1638 sdname+=folder->GetName() ;
1639 if(!SDigitizer(sdname) )
1640 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1642 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1643 sdigitizerBranch->GetEntry(0) ;
1647 // After SDigits have been read from all files, return to the first one
1650 folder = static_cast<TFolder*>(next());
1652 TString fileName(folder->GetName()) ;
1653 fileName.ReplaceAll("_","/") ;
1654 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1659 //____________________________________________________________________________
1660 void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
1661 { // Read the summable digits fron treeS()
1664 TString filename("mergefile") ;
1667 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
1668 if ( !phosFolder ) {
1669 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1671 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
1672 //set address of the SDigits and SDigitizer
1673 TBranch * sdigitsBranch = 0;
1674 TBranch * sdigitizerBranch = 0;
1675 TBranch * branch = 0 ;
1676 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1678 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1680 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
1681 if ( strcmp(branch->GetName(), "PHOS")==0) {
1683 sdigitsBranch = branch ;
1686 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
1687 sdigitizerfound = kTRUE ;
1688 sdigitizerBranch = branch ;
1691 if ( !phosfound || !sdigitizerfound ) {
1693 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1697 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1698 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1700 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1701 sdigitsBranch->GetEntry(0) ;
1703 TString sdname(sdigitsBranch->GetTitle()) ;
1706 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1707 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1709 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1710 sdigitizerBranch->GetEntry(0) ;
1715 //____________________________________________________________________________
1716 void AliPHOSGetter::ReadPrimaries()
1718 // a lot simplified.... if 2 files are opened then we have a problem
1720 TClonesArray * ar = 0 ;
1721 if(! (ar = Primaries()) ) {
1727 fNPrimaries = gAlice->GetNtrack() ;
1729 for (index = 0 ; index < fNPrimaries; index++) {
1730 new ((*ar)[index]) TParticle(*(Primary(index)));
1733 //____________________________________________________________________________
1734 void AliPHOSGetter::Event(const Int_t event, const char* opt)
1736 // Reads the content of all Tree's S, D and R
1738 if (event >= gAlice->TreeE()->GetEntries() ) {
1739 cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
1743 Bool_t any = kFALSE ;
1744 if (strstr(opt,"A") ) // do not check the title of the branches
1747 gAlice->GetEvent(event) ;
1754 if(strstr(opt,"H") )
1755 rvRH = ReadTreeH() ;
1757 if(strstr(opt,"S") )
1758 rvRS = ReadTreeS(event) ;
1760 if( strstr(opt,"D") )
1761 rvRD = ReadTreeD() ;
1763 if( strstr(opt,"R") )
1764 rvRR = ReadTreeR(any) ;
1766 if( strstr(opt,"Q") )
1769 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1770 if ( gAlice->Stack() )
1775 //____________________________________________________________________________
1776 TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
1778 // get the object named "what" from the folder
1779 // folders are named like //Folders
1781 if ( file.IsNull() )
1782 file = fHeaderFile ;
1784 TFolder * folder = 0 ;
1785 TObject * phosO = 0 ;
1787 // if ( name.IsNull() ) {
1788 if ( what.CompareTo("Primaries") == 0 ) {
1789 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1791 phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1793 else if ( what.CompareTo("Hits") == 0 ) {
1794 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
1796 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1798 else if ( what.CompareTo("SDigits") == 0 ) {
1799 file.ReplaceAll("/","_") ;
1800 TString path = "PHOS/" + file ;
1801 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1804 name = fSDigitsTitle ;
1805 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1808 else if ( what.CompareTo("Digits") == 0 ){
1809 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
1812 name = fDigitsTitle ;
1813 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1816 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1817 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
1820 name = fRecPointsTitle ;
1821 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1824 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1825 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
1828 name = fRecPointsTitle ;
1829 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1832 else if ( what.CompareTo("TrackSegments") == 0 ) {
1833 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1836 name = fTrackSegmentsTitle ;
1837 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1840 else if ( what.CompareTo("RecParticles") == 0 ) {
1841 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1844 name = fRecParticlesTitle ;
1845 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1848 else if ( what.CompareTo("Alarms") == 0 ){
1850 phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
1852 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1856 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1861 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << fQAFolder->GetName() << endl ;
1868 //____________________________________________________________________________
1869 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1871 // get the TTask named "what" from the folder
1872 // folders are named like //Folders/Tasks/what/PHOS/name
1874 TString search(what) ;
1875 if ( what.CompareTo("Clusterizer") == 0 )
1876 search = "Reconstructioner" ;
1877 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1878 search = "Reconstructioner" ;
1879 else if ( what.CompareTo("PID") == 0 )
1880 search = "Reconstructioner" ;
1881 else if ( what.CompareTo("QATasks") == 0 )
1884 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1887 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
1891 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1893 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
1897 TList * list = phosT->GetListOfTasks() ;
1899 if (what.CompareTo("SDigitizer") == 0) {
1900 if ( name.IsNull() )
1901 name = fSDigitsTitle ;
1902 } else if (what.CompareTo("Digitizer") == 0){
1903 if ( name.IsNull() )
1904 name = fDigitsTitle ;
1905 } else if (what.CompareTo("Clusterizer") == 0){
1906 if ( name.IsNull() )
1907 name = fRecPointsTitle ;
1908 name.Append(":clu") ;
1910 else if (what.CompareTo("TrackSegmentMaker") == 0){
1911 if ( name.IsNull() )
1912 name = fTrackSegmentsTitle ;
1913 name.Append(":tsm") ;
1915 else if (what.CompareTo("PID") == 0){
1916 if ( name.IsNull() )
1917 name = fRecParticlesTitle ;
1918 name.Append(":pid") ;
1920 else if (what.CompareTo("QATasks") == 0){
1921 if ( name.IsNull() )
1927 while((task = static_cast<TTask *>(it.Next()) )){
1928 TString taskname(task->GetName()) ;
1929 if(taskname.BeginsWith(name))
1934 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;