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 "AliPHOSClusterizerv1.h"
69 #include "AliPHOSTrackSegmentMakerv1.h"
70 #include "AliPHOSTrackSegment.h"
71 #include "AliPHOSPIDv1.h"
72 #include "AliPHOSGeometry.h"
74 ClassImp(AliPHOSGetter)
76 AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ;
78 //____________________________________________________________________________
79 AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle )
81 //Initialize all lists
85 fHeaderFile = headerFile ;
86 fBranchTitle = branchTitle ;
87 fSDigitsTitle = branchTitle ;
88 fDigitsTitle = branchTitle ;
89 fRecPointsTitle = branchTitle ;
90 fRecParticlesTitle = branchTitle ;
91 fTrackSegmentsTitle = branchTitle ;
93 fPrimaries = new TObjArray(1) ;
95 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
96 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
97 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
98 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
99 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
100 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
101 fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
102 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
106 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
109 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
110 if(!fFile) { //if file was not opened yet, read gAlice
111 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
113 if (!fFile->IsOpen()) {
114 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot open " << fHeaderFile.Data() << endl ;
118 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
123 cerr << "ERROR : AliPHOSGetter::AliPHOSGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
129 cout << "INFO: AliPHOSGetter -> Posting PHOS to Folders" << endl ;
130 if (gAlice->GetDetector("PHOS")) {
131 AliConfig * conf = AliConfig::Instance() ;
132 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("PHOS"))) ;
133 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("PHOS"))) ;
136 cerr << "ERROR: AliPHOSGetter -> detector PHOS not found" << endl ;
141 //____________________________________________________________________________
142 AliPHOSGetter::~AliPHOSGetter(){
145 fPrimaries->Delete() ;
149 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
150 TCollection * folderslist = phosF->GetListOfFolders() ;
151 TIter next(folderslist) ;
152 TFolder * folder = 0 ;
153 while ( (folder = static_cast<TFolder*>(next())) )
154 phosF->Remove(folder) ;
162 //____________________________________________________________________________
163 void AliPHOSGetter::CreateWhiteBoard() const
168 //____________________________________________________________________________
169 AliPHOSGetter * AliPHOSGetter::GetInstance()
171 // Returns the pointer of the unique instance already defined
173 AliPHOSGetter * rv = 0 ;
177 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
182 //____________________________________________________________________________
183 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
184 const char* branchTitle)
186 // Creates and returns the pointer of the unique instance
187 // Must be called only when the environment has changed
190 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
191 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
194 fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
196 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
198 if (fgObjGetter->HasFailed() )
202 // Posts a few item to the white board (folders)
203 // fgObjGetter->CreateWhiteBoard() ;
209 //____________________________________________________________________________
210 const AliPHOS * AliPHOSGetter::PHOS()
212 // returns the PHOS object
213 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
216 cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
220 //____________________________________________________________________________
221 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
223 AliPHOSGeometry * rv = 0 ;
225 rv = PHOS()->GetGeometry() ;
229 //____________________________________________________________________________
230 Bool_t AliPHOSGetter::PostPrimaries(void) const
231 { //------- Primaries ----------------------
233 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
235 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
236 if ( !primariesFolder ) {
238 cout << "WARNING: AliPHOSGetter::Post Primaries -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
239 cout << "INFO: AliPHOSGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder << "/Primaries/" << endl;
241 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
243 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
244 primaries->SetName("Primaries") ;
245 primariesFolder->Add(primaries) ;
250 //____________________________________________________________________________
251 TObject** AliPHOSGetter::PrimariesRef(void) const
252 { //------- Primaries ----------------------
255 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
256 if ( !fPrimariesFolder ) {
257 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
261 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
262 if ( !primariesFolder ) {
263 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
267 TObject * p = primariesFolder->FindObject("Primaries") ;
269 cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
273 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
276 //____________________________________________________________________________
277 Bool_t AliPHOSGetter::PostHits(void) const
278 { //------- Hits ----------------------
280 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
282 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
285 cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
286 cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
288 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
290 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
291 hits->SetName("Hits") ;
292 phosFolder->Add(hits) ;
297 //____________________________________________________________________________
298 TObject** AliPHOSGetter::HitsRef(void) const
299 { //------- Hits ----------------------
302 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
303 if ( !fHitsFolder ) {
304 cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
308 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
310 cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
314 TObject * h = phosFolder->FindObject("Hits") ;
316 cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
320 return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
323 //____________________________________________________________________________
324 Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
325 { //---------- SDigits -------------------------
328 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
329 // because you can have sdigits from several hit files for mixing
331 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
334 cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
335 cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
337 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
339 TString subdir(headerFile) ;
340 subdir.ReplaceAll("/","_") ;
341 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
342 if ( !phosSubFolder )
343 phosSubFolder = phosFolder->AddFolder(subdir, "");
345 TObject * sd = phosSubFolder->FindObject(name);
348 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
349 << " already exists!" << endl ;
351 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
352 sdigits->SetName(name) ;
353 phosSubFolder->Add(sdigits) ;
358 //____________________________________________________________________________
359 TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
360 { //------- SDigits ----------------------
362 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
364 if ( !fSDigitsFolder ) {
365 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
369 TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
371 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
375 TFolder * phosSubFolder = 0 ;
377 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
379 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
382 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
386 TObject * dis = phosSubFolder->FindObject(name) ;
390 return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
394 //____________________________________________________________________________
395 Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
396 { //---------- SDigitizer -------------------------
398 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
401 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
404 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
407 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
410 cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
411 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
413 phos = new TTask("PHOS", "") ;
416 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
419 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
420 phos->GetListOfTasks()->Remove(phossd) ;
422 phos->Add(sdigitizer) ;
427 //____________________________________________________________________________
428 TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
431 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
433 cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
437 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
439 cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
443 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
445 return phos->GetListOfTasks()->GetObjectRef(task) ;
449 //____________________________________________________________________________
450 Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
451 { //---------- SDigitizer -------------------------
453 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
456 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
458 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
462 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
465 cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
466 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
468 phos = new TTask("PHOS", "") ;
472 TString sdname(name) ;
475 sdname.ReplaceAll("/","_") ;
476 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
478 phossd = new AliPHOSSDigitizer() ;
479 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
480 phossd->SetName(sdname) ;
481 phossd->SetTitle(file) ;
488 //____________________________________________________________________________
489 Bool_t AliPHOSGetter::PostDigits(const char * name) const
490 { //---------- Digits -------------------------
492 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
494 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
498 cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
499 cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
501 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
504 TObject* dig = phosFolder->FindObject( name ) ;
506 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
507 digits->SetName(name) ;
508 phosFolder->Add(digits) ;
513 //____________________________________________________________________________
514 TObject** AliPHOSGetter::DigitsRef(const char * name) const
515 { //------- Digits ----------------------
517 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
519 if ( !fDigitsFolder ) {
520 cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
524 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
526 cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
530 TObject * d = phosFolder->FindObject(name) ;
534 return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
538 //____________________________________________________________________________
539 Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
540 { //---------- Digitizer -------------------------
542 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
545 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
548 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
551 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
552 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
554 phos = new TTask("PHOS", "") ;
558 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
561 phos->GetListOfTasks()->Remove(phosd) ;
563 phos->Add(digitizer) ;
567 //____________________________________________________________________________
568 Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
569 { //---------- Digitizer -------------------------
571 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
573 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
575 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
579 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
582 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
583 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
585 phos = new TTask("PHOS", "") ;
589 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
591 phosd = new AliPHOSDigitizer() ;
592 phosd->SetName(fDigitsTitle) ;
593 phosd->SetTitle(fHeaderFile) ;
599 //____________________________________________________________________________
600 TObject** AliPHOSGetter::DigitizerRef(const char * name) const
602 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
604 cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
608 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
610 cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
614 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
616 return phos->GetListOfTasks()->GetObjectRef(task) ;
620 //____________________________________________________________________________
621 Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
622 { // -------------- RecPoints -------------------------------------------
624 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
625 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
627 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
631 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
632 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
634 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
638 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
639 if ( !phosRPoEMCAFolder ) {
641 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
642 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints" << endl;
644 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
647 TObject * erp = phosFolder->FindObject( name ) ;
649 TObjArray * emcrp = new TObjArray(100) ;
650 emcrp->SetName(name) ;
651 phosRPoEMCAFolder->Add(emcrp) ;
655 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
656 if ( !phosRPoCPVFolder ) {
658 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/ not found!" << endl;
659 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
661 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
664 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
666 TObjArray * cpvrp = new TObjArray(100) ;
667 cpvrp->SetName(name) ;
668 phosRPoCPVFolder->Add(cpvrp) ;
673 //____________________________________________________________________________
674 TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
675 { // -------------- RecPoints -------------------------------------------
677 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
679 if ( !fRecoFolder ) {
680 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
684 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
686 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
691 TObject * erp = phosFolder->FindObject(name ) ;
695 return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
699 //____________________________________________________________________________
700 TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
701 { // -------------- RecPoints -------------------------------------------
703 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
705 if ( !fRecoFolder ) {
706 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
710 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
712 cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
716 TObject * crp = phosFolder->FindObject(name ) ;
720 return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
724 //____________________________________________________________________________
725 Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
726 { // ------------------ AliPHOSClusterizer ------------------------
728 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
730 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
733 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
737 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
740 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
741 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
743 phos = new TTask("PHOS", "") ;
747 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
750 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
752 phos->GetListOfTasks()->Remove(phoscl) ;
758 //____________________________________________________________________________
759 TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
760 { // ------------------ AliPHOSClusterizer ------------------------
762 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
765 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
769 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
771 cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
775 TList * l = phos->GetListOfTasks() ;
779 TString cluname(name) ;
780 cluname+=":clusterizer" ;
781 while((task = static_cast<TTask *>(it.Next()) )){
782 TString taskname(task->GetName()) ;
783 if(taskname.BeginsWith(cluname)){
790 return l->GetObjectRef(clu) ;
792 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner/clusterizer name not found!" << endl;
797 //____________________________________________________________________________
798 Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
799 { // ------------------ AliPHOSClusterizer ------------------------
801 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
803 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
806 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
810 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
813 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
814 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
816 phos = new TTask("PHOS", "") ;
820 AliPHOSClusterizerv1 * phoscl = new AliPHOSClusterizerv1() ;
822 clun+=":clusterizerv1" ;
823 phoscl->SetName(clun) ;
829 //____________________________________________________________________________
830 Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
831 { // ---------------TrackSegments -----------------------------------
833 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
835 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
839 cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
840 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS" << endl;
842 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
845 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
846 if ( !phosTSFolder ) {
848 cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
849 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/" << endl;
851 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
854 TObject * tss = phosTSFolder->FindObject( name ) ;
856 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
858 phosTSFolder->Add(ts) ;
863 //____________________________________________________________________________
864 TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
865 { // ---------------TrackSegments -----------------------------------
867 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
869 if ( !fRecoFolder ) {
870 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "not found!" << endl;
874 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
876 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
880 TObject * tss = phosFolder->FindObject(name) ;
884 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
887 //____________________________________________________________________________
888 Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
889 { //------------Track Segment Maker ------------------------------
891 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
893 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
896 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
900 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
903 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
904 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
906 phos = new TTask("PHOS", "") ;
910 AliPHOSTrackSegmentMaker * phosts =
911 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
914 phos->GetListOfTasks()->Remove(phosts) ;
920 //____________________________________________________________________________
921 Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
922 { //------------Track Segment Maker ------------------------------
924 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
927 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
930 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
934 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
937 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
938 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
940 phos = new TTask("PHOS", "") ;
944 AliPHOSTrackSegmentMakerv1 * phosts =
945 dynamic_cast<AliPHOSTrackSegmentMakerv1*>(phos->GetListOfTasks()->FindObject(name)) ;
947 phosts = new AliPHOSTrackSegmentMakerv1() ;
949 tsn+=":tracksegmentmakerv1" ;
950 phosts->SetName(tsn) ;
957 //____________________________________________________________________________
958 TObject** AliPHOSGetter::TSMakerRef(const char * name) const
959 { //------------Track Segment Maker ------------------------------
961 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
964 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
968 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
970 cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
974 TList * l = phos->GetListOfTasks() ;
978 TString tsmname(name) ;
979 tsmname+=":tracksegmentmaker" ;
980 while((task = static_cast<TTask *>(it.Next()) )){
981 TString taskname(task->GetName()) ;
982 if(taskname.BeginsWith(tsmname)){
989 return l->GetObjectRef(tsm) ;
992 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner/TrackSegmentMarker name not found!" << endl;
998 //____________________________________________________________________________
999 Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
1000 { // -------------------- RecParticles ------------------------
1002 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1004 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
1006 if ( !phosFolder ) {
1008 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
1009 cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
1011 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
1014 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
1015 if ( !phosRPaFolder ) {
1017 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1018 cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/" << endl;
1020 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
1023 TObject * rps = phosRPaFolder->FindObject( name ) ;
1025 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
1027 phosRPaFolder->Add(rp) ;
1032 //____________________________________________________________________________
1033 TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
1034 { // ---------------TrackSegments -----------------------------------
1036 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1038 if ( !fRecoFolder ) {
1039 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder->GetName() << " not found!" << endl;
1043 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1044 if ( !phosFolder ) {
1045 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1049 TObject * tss = phosFolder->FindObject(name ) ;
1053 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
1056 //____________________________________________________________________________
1057 Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
1058 { // ------------AliPHOS PID -----------------------------
1060 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1063 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1067 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1070 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1071 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1073 phos = new TTask("PHOS", "") ;
1077 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
1080 cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
1081 << " already exists" << endl ;
1082 phos->GetListOfTasks()->Remove(phospid) ;
1089 //____________________________________________________________________________
1090 Bool_t AliPHOSGetter::PostPID(const char * name) const
1092 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1094 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1097 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1101 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1104 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1105 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1107 phos = new TTask("PHOS", "") ;
1111 TList * l = phos->GetListOfTasks() ;
1113 TString pidname(name) ;
1116 while((task = static_cast<TTask *>(it.Next()) )){
1117 TString taskname(task->GetName()) ;
1118 if(taskname.BeginsWith(pidname))
1122 AliPHOSPIDv1 * phospid = new AliPHOSPIDv1() ;
1123 phospid->SetName(pidname) ;
1124 phos->Add(phospid) ;
1129 //____________________________________________________________________________
1130 TObject** AliPHOSGetter::PIDRef(const char * name) const
1131 { //------------PID ------------------------------
1133 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1136 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1140 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1142 cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1146 TList * l = phos->GetListOfTasks() ;
1150 TString pidname(name) ;
1152 while((task = static_cast<TTask *>(it.Next()) )){
1153 TString taskname(task->GetName()) ;
1154 if(taskname.BeginsWith(pidname)){
1161 return l->GetObjectRef(pid) ;
1163 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner/PID name not found!" << endl;
1169 //____________________________________________________________________________
1170 Bool_t AliPHOSGetter::PostQA(void) const
1171 { // ------------------ QA ---------------------------------
1173 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1175 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1176 if ( !phosFolder ) {
1178 cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1179 cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
1181 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1187 //____________________________________________________________________________
1188 TObject** AliPHOSGetter::AlarmsRef(void) const
1189 { //------- Alarms ----------------------
1192 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1194 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1198 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1199 if ( !phosFolder ) {
1200 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1204 return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
1207 //____________________________________________________________________________
1208 const TParticle * AliPHOSGetter::Primary(Int_t index) const
1210 // Return primary particle numbered by <index>
1214 TParticle * p = gAlice->Particle(index) ;
1215 // if (p->GetFirstMother() != -1 ) {
1216 // cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
1221 // Int_t primaryIndex = index % 10000000 ;
1222 // Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1224 // if ( primaryList > 0 ) {
1226 // cout << " Getter does not support currently Mixing of primary " << endl ;
1227 // cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1232 // return gAlice->Particle(primaryIndex) ;
1236 //____________________________________________________________________________
1237 const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
1239 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1247 Int_t daughterIndex = p->GetDaughter(index-1) ;
1248 return gAlice->Particle(daughterIndex) ;
1254 //____________________________________________________________________________
1255 Int_t AliPHOSGetter::ReadTreeD()
1257 // Read the digit tree gAlice->TreeD()
1258 if(gAlice->TreeD()== 0){
1259 cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
1263 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1265 TBranch * branch = 0 ;
1266 TBranch * digitsbranch = 0 ;
1267 TBranch * digitizerbranch = 0 ;
1268 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1270 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
1271 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1272 digitsbranch = branch ;
1275 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1276 digitizerbranch = branch ;
1277 digitizerfound = kTRUE ;
1281 if ( !phosfound || !digitizerfound ) {
1283 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1284 << fDigitsTitle << endl ;
1289 if(!Digits(fDigitsTitle) )
1290 PostDigits(fDigitsTitle);
1291 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1292 digitsbranch->GetEntry(0) ;
1295 // read the Digitizer
1296 if(!Digitizer(fDigitsTitle))
1297 PostDigitizer(fDigitsTitle) ;
1298 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1299 digitizerbranch->GetEntry(0) ;
1304 //____________________________________________________________________________
1305 Int_t AliPHOSGetter::ReadTreeH()
1307 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1309 if(gAlice->TreeH()== 0){
1310 cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1314 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
1315 if ( !hitsbranch ) {
1317 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1323 if (hitsbranch->GetEntries() > 1 ) {
1324 TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
1325 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1326 hitsbranch->SetAddress(&tempo) ;
1329 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1330 hitsbranch->GetEntry(i) ;
1332 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1333 const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
1334 new((*hits)[index]) AliPHOSHit( *hit ) ;
1341 hitsbranch->SetAddress(HitsRef()) ;
1342 hitsbranch->GetEntry(0) ;
1347 //____________________________________________________________________________
1348 void AliPHOSGetter::Track(Int_t itrack)
1350 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1352 if(gAlice->TreeH()== 0){
1353 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1357 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
1358 if ( !hitsbranch ) {
1360 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1366 hitsbranch->SetAddress(HitsRef()) ;
1367 hitsbranch->GetEntry(itrack) ;
1371 //____________________________________________________________________________
1372 void AliPHOSGetter::ReadTreeQA()
1374 // Read the digit tree gAlice->TreeQA()
1375 // so far only PHOS knows about this Tree
1377 if(PHOS()->TreeQA()== 0){
1378 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
1382 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1385 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
1392 qabranch->SetAddress(AlarmsRef()) ;
1394 qabranch->GetEntry(0) ;
1397 // TFolder * alarmsF = Alarms() ;
1398 // alarmsF->Clear() ;
1399 // qabranch->SetAddress(&alarmsF) ;
1400 // qabranch->GetEntry(0) ;
1404 //____________________________________________________________________________
1405 Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
1407 // Read the reconstrunction tree gAlice->TreeR()
1408 // A particularity has been introduced here :
1409 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1410 // being for example give in AliPHOSPID(fileName, title)
1411 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1412 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1413 // from a given set of TrackSegments (with a given name)
1414 // This is why any is NOT used to read the branch of RecParticles
1417 if(gAlice->TreeR()== 0){
1418 cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
1422 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1424 TBranch * branch = 0 ;
1425 TBranch * emcbranch = 0 ;
1426 TBranch * cpvbranch = 0 ;
1427 TBranch * clusterizerbranch = 0 ;
1428 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1430 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
1431 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 || any) {
1432 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1433 emcbranch = branch ;
1434 phosemcrpfound = kTRUE ;
1436 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1437 cpvbranch = branch ;
1438 phoscpvrpfound = kTRUE ;
1440 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1441 clusterizerbranch = branch ;
1442 clusterizerfound = kTRUE ;
1446 if ( !phosemcrpfound ) {
1448 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1449 << fRecPointsTitle << endl ;
1452 if ( !phoscpvrpfound ) {
1454 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1455 << fRecPointsTitle << endl ;
1458 if ( !clusterizerfound ) {
1460 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
1461 << fRecPointsTitle << endl ;
1465 // Read and Post the RecPoints
1466 if(!EmcRecPoints(fRecPointsTitle) )
1467 PostRecPoints(fRecPointsTitle) ;
1469 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1470 emcbranch->GetEntry(0) ;
1472 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
1473 cpvbranch->GetEntry(0) ;
1475 if(!Clusterizer(fRecPointsTitle) )
1476 PostClusterizer(fRecPointsTitle) ;
1478 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1479 clusterizerbranch->GetEntry(0) ;
1482 //------------------- TrackSegments ---------------------
1484 TBranch * tsbranch = 0 ;
1485 TBranch * tsmakerbranch = 0 ;
1486 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
1488 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
1489 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 || any) {
1490 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1492 phostsfound = kTRUE ;
1494 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1495 tsmakerbranch = branch ;
1496 tsmakerfound = kTRUE ;
1500 if ( !phostsfound || !tsmakerfound ) {
1502 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1503 << fTrackSegmentsTitle << endl ;
1507 // Read and Post the TrackSegments
1508 if(!TrackSegments(fTrackSegmentsTitle))
1509 PostTrackSegments(fTrackSegmentsTitle) ;
1511 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1512 tsbranch->GetEntry(0) ;
1514 // Read and Post the TrackSegment Maker
1515 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1516 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1518 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1519 tsmakerbranch->GetEntry(0) ;
1522 //------------ RecParticles ----------------------------
1524 TBranch * rpabranch = 0 ;
1525 TBranch * pidbranch = 0 ;
1526 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1528 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
1529 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1530 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1531 rpabranch = branch ;
1532 phosrpafound = kTRUE ;
1534 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1535 pidbranch = branch ;
1540 if ( !phosrpafound || !pidfound ) {
1542 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1543 << fRecParticlesTitle << endl ;
1547 // Read and Post the RecParticles
1548 if(!RecParticles(fRecParticlesTitle))
1549 PostRecParticles(fRecParticlesTitle) ;
1551 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1552 rpabranch->GetEntry(0) ;
1554 // Read and Post the PID
1555 if(!PID(fRecParticlesTitle))
1556 PostPID(fRecParticlesTitle) ;
1558 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1559 pidbranch->GetEntry(0) ;
1564 //____________________________________________________________________________
1565 Int_t AliPHOSGetter::ReadTreeS(Int_t event)
1567 // Read the summable digits tree gAlice->TreeS()
1569 // loop over all opened files and read their SDigits to the White Board
1570 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
1572 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1573 TCollection * folderslist = phosF->GetListOfFolders() ;
1575 //Add current file to list if it is not there yet
1577 TString subdir(fHeaderFile) ;
1578 subdir.ReplaceAll("/","_") ;
1580 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1581 phosF->AddFolder(subdir, "");
1584 TIter next(folderslist) ;
1585 TFolder * folder = 0 ;
1588 while ( (folder = static_cast<TFolder*>(next())) ) {
1589 TString fileName(folder->GetName()) ;
1590 fileName.ReplaceAll("_","/") ;
1591 if(fHeaderFile.CompareTo(fileName) == 0 )
1592 treeS=gAlice->TreeS() ;
1594 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1597 // Get SDigits Tree header from file
1598 TString treeName("TreeS") ;
1600 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1603 cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
1607 //set address of the SDigits and SDigitizer
1608 TBranch * sdigitsBranch = 0;
1609 TBranch * sdigitizerBranch = 0;
1610 TBranch * branch = 0 ;
1611 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1613 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1615 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
1616 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1618 sdigitsBranch = branch ;
1621 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1622 sdigitizerfound = kTRUE ;
1623 sdigitizerBranch = branch ;
1626 if ( !phosfound || !sdigitizerfound ) {
1628 cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1629 << " not found" << endl ;
1633 if ( !folder->FindObject(fSDigitsTitle) )
1634 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1636 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1637 sdigitsBranch->GetEntry(0) ;
1639 TString sdname(fSDigitsTitle) ;
1641 sdname+=folder->GetName() ;
1642 if(!SDigitizer(sdname) )
1643 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1645 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1646 sdigitizerBranch->GetEntry(0) ;
1650 // After SDigits have been read from all files, return to the first one
1653 folder = static_cast<TFolder*>(next());
1655 TString fileName(folder->GetName()) ;
1656 fileName.ReplaceAll("_","/") ;
1657 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1662 //____________________________________________________________________________
1663 void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
1664 { // Read the summable digits fron treeS()
1667 TString filename("mergefile") ;
1670 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
1671 if ( !phosFolder ) {
1672 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1674 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
1675 //set address of the SDigits and SDigitizer
1676 TBranch * sdigitsBranch = 0;
1677 TBranch * sdigitizerBranch = 0;
1678 TBranch * branch = 0 ;
1679 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1681 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1683 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
1684 if ( strcmp(branch->GetName(), "PHOS")==0) {
1686 sdigitsBranch = branch ;
1689 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
1690 sdigitizerfound = kTRUE ;
1691 sdigitizerBranch = branch ;
1694 if ( !phosfound || !sdigitizerfound ) {
1696 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1700 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1701 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1703 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1704 sdigitsBranch->GetEntry(0) ;
1706 TString sdname(sdigitsBranch->GetTitle()) ;
1709 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1710 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1712 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1713 sdigitizerBranch->GetEntry(0) ;
1718 //____________________________________________________________________________
1719 void AliPHOSGetter::ReadPrimaries()
1721 // a lot simplified.... if 2 files are opened then we have a problem
1723 TClonesArray * ar = 0 ;
1724 if(! (ar = Primaries()) ) {
1730 fNPrimaries = gAlice->GetNtrack() ;
1732 for (index = 0 ; index < fNPrimaries; index++) {
1733 new ((*ar)[index]) TParticle(*(Primary(index)));
1736 //____________________________________________________________________________
1737 void AliPHOSGetter::Event(const Int_t event, const char* opt)
1739 // Reads the content of all Tree's S, D and R
1741 if (event >= gAlice->TreeE()->GetEntries() ) {
1742 cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
1746 Bool_t any = kFALSE ;
1747 if (strstr(opt,"A") ) // do not check the title of the branches
1750 gAlice->GetEvent(event) ;
1757 if(strstr(opt,"H") )
1758 rvRH = ReadTreeH() ;
1760 if(strstr(opt,"S") )
1761 rvRS = ReadTreeS(event) ;
1763 if( strstr(opt,"D") )
1764 rvRD = ReadTreeD() ;
1766 if( strstr(opt,"R") )
1767 rvRR = ReadTreeR(any) ;
1769 if( strstr(opt,"Q") )
1772 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1773 if ( gAlice->Stack() )
1778 //____________________________________________________________________________
1779 TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
1781 // get the object named "what" from the folder
1782 // folders are named like //Folders
1784 if ( file.IsNull() )
1785 file = fHeaderFile ;
1787 TFolder * folder = 0 ;
1788 TObject * phosO = 0 ;
1790 // if ( name.IsNull() ) {
1791 if ( what.CompareTo("Primaries") == 0 ) {
1792 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1794 phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1796 else if ( what.CompareTo("Hits") == 0 ) {
1797 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
1799 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1801 else if ( what.CompareTo("SDigits") == 0 ) {
1802 file.ReplaceAll("/","_") ;
1803 TString path = "PHOS/" + file ;
1804 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1807 name = fSDigitsTitle ;
1808 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1811 else if ( what.CompareTo("Digits") == 0 ){
1812 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
1815 name = fDigitsTitle ;
1816 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1819 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1820 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
1823 name = fRecPointsTitle ;
1824 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1827 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1828 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
1831 name = fRecPointsTitle ;
1832 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1835 else if ( what.CompareTo("TrackSegments") == 0 ) {
1836 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1839 name = fTrackSegmentsTitle ;
1840 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1843 else if ( what.CompareTo("RecParticles") == 0 ) {
1844 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1847 name = fRecParticlesTitle ;
1848 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1851 else if ( what.CompareTo("Alarms") == 0 ){
1853 phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
1855 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1859 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1864 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << fQAFolder->GetName() << endl ;
1871 //____________________________________________________________________________
1872 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1874 // get the TTask named "what" from the folder
1875 // folders are named like //Folders/Tasks/what/PHOS/name
1877 TString search(what) ;
1878 if ( what.CompareTo("Clusterizer") == 0 )
1879 search = "Reconstructioner" ;
1880 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1881 search = "Reconstructioner" ;
1882 else if ( what.CompareTo("PID") == 0 )
1883 search = "Reconstructioner" ;
1884 else if ( what.CompareTo("QATasks") == 0 )
1887 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1890 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
1894 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1896 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
1900 TList * list = phosT->GetListOfTasks() ;
1902 if (what.CompareTo("SDigitizer") == 0) {
1903 if ( name.IsNull() )
1904 name = fSDigitsTitle ;
1905 } else if (what.CompareTo("Digitizer") == 0){
1906 if ( name.IsNull() )
1907 name = fDigitsTitle ;
1908 } else if (what.CompareTo("Clusterizer") == 0){
1909 if ( name.IsNull() )
1910 name = fRecPointsTitle ;
1911 name.Append(":clusterizer") ;
1913 else if (what.CompareTo("TrackSegmentMaker") == 0){
1914 if ( name.IsNull() )
1915 name = fTrackSegmentsTitle ;
1916 name.Append(":tracksegmentmaker") ;
1918 else if (what.CompareTo("PID") == 0){
1919 if ( name.IsNull() )
1920 name = fRecParticlesTitle ;
1921 name.Append(":pid") ;
1923 else if (what.CompareTo("QATasks") == 0){
1924 if ( name.IsNull() )
1930 while((task = static_cast<TTask *>(it.Next()) )){
1931 TString taskname(task->GetName()) ;
1932 if(taskname.BeginsWith(name))
1937 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;