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() ;
157 //____________________________________________________________________________
158 void AliPHOSGetter::CreateWhiteBoard() const
163 //____________________________________________________________________________
164 AliPHOSGetter * AliPHOSGetter::GetInstance()
166 // Returns the pointer of the unique instance already defined
168 AliPHOSGetter * rv = 0 ;
172 cout << "AliPHOSGetter::GetInstance ERROR: not yet initialized" << endl ;
177 //____________________________________________________________________________
178 AliPHOSGetter * AliPHOSGetter::GetInstance(const char* headerFile,
179 const char* branchTitle)
181 // Creates and returns the pointer of the unique instance
182 // Must be called only when the environment has changed
185 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
186 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0))
189 fgObjGetter->~AliPHOSGetter() ; // delete it already exists another version
191 fgObjGetter = new AliPHOSGetter(headerFile,branchTitle) ;
193 // Posts a few item to the white board (folders)
194 // fgObjGetter->CreateWhiteBoard() ;
200 //____________________________________________________________________________
201 const AliPHOS * AliPHOSGetter::PHOS()
203 // returns the PHOS object
204 AliPHOS * phos = dynamic_cast<AliPHOS*>(fModuleFolder->FindObject("PHOS")) ;
207 cout << "WARNING: AliPHOSGetter::PHOS -> PHOS module not found in Folders" << endl ;
211 //____________________________________________________________________________
212 const AliPHOSGeometry * AliPHOSGetter::PHOSGeometry()
214 AliPHOSGeometry * rv = 0 ;
216 rv = PHOS()->GetGeometry() ;
220 //____________________________________________________________________________
221 Bool_t AliPHOSGetter::PostPrimaries(void) const
222 { //------- Primaries ----------------------
224 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
226 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
227 if ( !primariesFolder ) {
229 cout << "WARNING: AliPHOSGetter::Post Primaries -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
230 cout << "INFO: AliPHOSGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder << "/Primaries/" << endl;
232 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
234 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
235 primaries->SetName("Primaries") ;
236 primariesFolder->Add(primaries) ;
241 //____________________________________________________________________________
242 TObject** AliPHOSGetter::PrimariesRef(void) const
243 { //------- Primaries ----------------------
246 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
247 if ( !fPrimariesFolder ) {
248 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
252 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
253 if ( !primariesFolder ) {
254 cerr << "ERROR: AliPHOSGetter::Post PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
258 TObject * p = primariesFolder->FindObject("Primaries") ;
260 cerr << "ERROR: AliPHOSGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
264 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
267 //____________________________________________________________________________
268 Bool_t AliPHOSGetter::PostHits(void) const
269 { //------- Hits ----------------------
271 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
273 TFolder * phosFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("PHOS")) ;
276 cout << "WARNING: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
277 cout << "INFO: AliPHOSGetter::Post H -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
279 phosFolder = fHitsFolder->AddFolder("PHOS", "Hits from PHOS") ;
281 TClonesArray *hits= new TClonesArray("AliPHOSHit",1000) ;
282 hits->SetName("Hits") ;
283 phosFolder->Add(hits) ;
288 //____________________________________________________________________________
289 TObject** AliPHOSGetter::HitsRef(void) const
290 { //------- Hits ----------------------
293 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/Hits
294 if ( !fHitsFolder ) {
295 cerr << "ERROR: AliPHOSGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
299 TFolder * phosFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
301 cerr << "ERROR: AliPHOSGetter::Post HRef -> Folder //" << fHitsFolder << "/PHOS/ not found!" << endl;
305 TObject * h = phosFolder->FindObject("Hits") ;
307 cerr << "ERROR: AliPHOSGetter::HRef -> " << phosFolder->GetName() << "/Hits not found !" << endl ;
311 return phosFolder->GetListOfFolders()->GetObjectRef(h) ;
314 //____________________________________________________________________________
315 Bool_t AliPHOSGetter::PostSDigits(const char * name, const char * headerFile) const
316 { //---------- SDigits -------------------------
319 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/headerFile/sdigitsname
320 // because you can have sdigits from several hit files for mixing
322 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
325 cout << "WARNING: AliPHOSGetter::Post S -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
326 cout << "INFO: AliPHOSGetter::Post S -> Adding Folder //" << fHitsFolder << "/PHOS/" << endl;
328 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
330 TString subdir(headerFile) ;
331 subdir.ReplaceAll("/","_") ;
332 TFolder * phosSubFolder = dynamic_cast<TFolder*>(phosFolder->FindObject(subdir)) ;
333 if ( !phosSubFolder )
334 phosSubFolder = phosFolder->AddFolder(subdir, "");
336 TObject * sd = phosSubFolder->FindObject(name);
339 cerr <<"INFO: AliPHOSGetter::Post S -> Folder " << subdir
340 << " already exists!" << endl ;
342 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit",1) ;
343 sdigits->SetName(name) ;
344 phosSubFolder->Add(sdigits) ;
349 //____________________________________________________________________________
350 TObject** AliPHOSGetter::SDigitsRef(const char * name, const char * file) const
351 { //------- SDigits ----------------------
353 // the hierarchy is //Folders/RunMC/Event/Data/PHOS/SDigits/filename/SDigits
355 if ( !fSDigitsFolder ) {
356 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
360 TFolder * phosFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
362 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //" << fSDigitsFolder << "/PHOS/ not found!" << endl;
366 TFolder * phosSubFolder = 0 ;
368 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(file)) ;
370 phosSubFolder = dynamic_cast<TFolder *>(phosFolder->FindObject(fHeaderFile)) ;
373 cerr << "ERROR: AliPHOSGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/PHOS/" << file << "not found!" << endl;
377 TObject * dis = phosSubFolder->FindObject(name) ;
381 return phosSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
385 //____________________________________________________________________________
386 Bool_t AliPHOSGetter::PostSDigitizer(AliPHOSSDigitizer * sdigitizer) const
387 { //---------- SDigitizer -------------------------
389 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
392 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
395 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
398 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
401 cout <<"WARNING: AliPHOSGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
402 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS/" << endl;
404 phos = new TTask("PHOS", "") ;
407 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
410 cout << "INFO: AliPHOSGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
411 phos->GetListOfTasks()->Remove(phossd) ;
413 phos->Add(sdigitizer) ;
418 //____________________________________________________________________________
419 TObject** AliPHOSGetter::SDigitizerRef(const char * name) const
422 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
424 cerr << "ERROR: AliPHOSGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
428 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
430 cerr <<"ERROR: AliPHOSGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/PHOS not found!" << endl;
434 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
436 return phos->GetListOfTasks()->GetObjectRef(task) ;
440 //____________________________________________________________________________
441 Bool_t AliPHOSGetter::PostSDigitizer(const char * name, const char * file) const
442 { //---------- SDigitizer -------------------------
444 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
447 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
449 cerr << "ERROR: AliPHOSGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
453 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
456 cout <<"WARNING: AliPHOSGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/PHOS/ not found!" << endl;
457 cout <<"INFO: AliPHOSGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/PHOS" << endl;
459 phos = new TTask("PHOS", "") ;
463 TString sdname(name) ;
466 sdname.ReplaceAll("/","_") ;
467 AliPHOSSDigitizer * phossd = dynamic_cast<AliPHOSSDigitizer *>(phos->GetListOfTasks()->FindObject( sdname ));
469 phossd = new AliPHOSSDigitizer() ;
470 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
471 phossd->SetName(sdname) ;
472 phossd->SetTitle(file) ;
479 //____________________________________________________________________________
480 Bool_t AliPHOSGetter::PostDigits(const char * name) const
481 { //---------- Digits -------------------------
483 // the hierarchy is //Folders/Run/Event/Data/PHOS/SDigits/name
485 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
489 cout << "WARNING: AliPHOSGetter::Post D -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
490 cout << "INFO: AliPHOSGetter::Post D -> Adding Folder //" << fDigitsFolder << "/PHOS/" << endl;
492 phosFolder = fDigitsFolder->AddFolder("PHOS", "Digits from PHOS") ;
495 TObject* dig = phosFolder->FindObject( name ) ;
497 TClonesArray * digits = new TClonesArray("AliPHOSDigit",1000) ;
498 digits->SetName(name) ;
499 phosFolder->Add(digits) ;
504 //____________________________________________________________________________
505 TObject** AliPHOSGetter::DigitsRef(const char * name) const
506 { //------- Digits ----------------------
508 // the hierarchy is //Folders/Run/Event/Data/PHOS/Digits/name
510 if ( !fDigitsFolder ) {
511 cerr << "ERROR: AliPHOSGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
515 TFolder * phosFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("PHOS")) ;
517 cerr << "ERROR: AliPHOSGetter::DRef -> Folder //" << fDigitsFolder << "/PHOS/ not found!" << endl;
521 TObject * d = phosFolder->FindObject(name) ;
525 return phosFolder->GetListOfFolders()->GetObjectRef(d) ;
529 //____________________________________________________________________________
530 Bool_t AliPHOSGetter::PostDigitizer(AliPHOSDigitizer * digitizer) const
531 { //---------- Digitizer -------------------------
533 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
536 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
539 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
542 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
543 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
545 phos = new TTask("PHOS", "") ;
549 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(digitizer->GetName())) ;
552 phos->GetListOfTasks()->Remove(phosd) ;
554 phos->Add(digitizer) ;
558 //____________________________________________________________________________
559 Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
560 { //---------- Digitizer -------------------------
562 // the hierarchy is //Folders/Tasks/SDigitizer/PHOS/sdigitsname
564 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
566 cerr << "ERROR: AliPHOSGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
570 TTask * phos = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("PHOS")) ;
573 cout <<"WARNING: AliPHOSGetter::Post Der -> //" << fTasksFolder << "/Digitizer/PHOS not found!" << endl;
574 cout <<"INFO: AliPHOSGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/PHOS" << endl;
576 phos = new TTask("PHOS", "") ;
580 AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ;
582 phosd = new AliPHOSDigitizer() ;
583 phosd->SetName(fDigitsTitle) ;
584 phosd->SetTitle(fHeaderFile) ;
590 //____________________________________________________________________________
591 TObject** AliPHOSGetter::DigitizerRef(const char * name) const
593 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
595 cerr << "ERROR: AliPHOSGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
599 TTask * phos = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("PHOS")) ;
601 cerr <<"ERROR: AliPHOSGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/PHOS" << endl;
605 TTask * task = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(name)) ;
607 return phos->GetListOfTasks()->GetObjectRef(task) ;
611 //____________________________________________________________________________
612 Bool_t AliPHOSGetter::PostRecPoints(const char * name) const
613 { // -------------- RecPoints -------------------------------------------
615 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
616 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
618 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
622 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
623 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
625 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
629 TFolder * phosRPoEMCAFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("EMCARecPoints")) ;
630 if ( !phosRPoEMCAFolder ) {
632 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
633 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints" << endl;
635 phosRPoEMCAFolder = phosFolder->AddFolder("EMCARecPoints", "EMCA RecPoints from PHOS") ;
638 TObject * erp = phosFolder->FindObject( name ) ;
640 TObjArray * emcrp = new TObjArray(100) ;
641 emcrp->SetName(name) ;
642 phosRPoEMCAFolder->Add(emcrp) ;
646 TFolder * phosRPoCPVFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("CPVRecPoints")) ;
647 if ( !phosRPoCPVFolder ) {
649 cout << "WARNING: AliPHOSGetter::Post RPo -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/ not found!" << endl;
650 cout << "INFO: AliPHOSGetter::Post Rpo -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
652 phosRPoCPVFolder = phosFolder->AddFolder("CPVRecPoints", "CPV RecPoints from PHOS") ;
655 TObject * crp = phosRPoCPVFolder->FindObject( name ) ;
657 TObjArray * cpvrp = new TObjArray(100) ;
658 cpvrp->SetName(name) ;
659 phosRPoCPVFolder->Add(cpvrp) ;
664 //____________________________________________________________________________
665 TObject** AliPHOSGetter::EmcRecPointsRef(const char * name) const
666 { // -------------- RecPoints -------------------------------------------
668 // the hierarchy is //Folders/Run/Event/RecData/PHOS/EMCARecPoints/name
670 if ( !fRecoFolder ) {
671 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
675 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
677 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/EMCARecPoints/ not found!" << endl;
682 TObject * erp = phosFolder->FindObject(name ) ;
686 return phosFolder->GetListOfFolders()->GetObjectRef(erp) ;
690 //____________________________________________________________________________
691 TObject** AliPHOSGetter::CpvRecPointsRef(const char * name) const
692 { // -------------- RecPoints -------------------------------------------
694 // the hierarchy is //Folders/Run/Event/RecData/PHOS/CPVRecPoints/name
696 if ( !fRecoFolder ) {
697 cerr << "ERROR: AliPHOSGetter::EmcRecPointsRef -> Folder //" << fRecoFolder->GetName() << " not found!" << endl;
701 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
703 cerr << "ERROR: AliPHOSGetter::CpvRecPointsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/CPVRecPoints/" << endl;
707 TObject * crp = phosFolder->FindObject(name ) ;
711 return phosFolder->GetListOfFolders()->GetObjectRef(crp) ;
715 //____________________________________________________________________________
716 Bool_t AliPHOSGetter::PostClusterizer(AliPHOSClusterizer * clu) const
717 { // ------------------ AliPHOSClusterizer ------------------------
719 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
721 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
724 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
728 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
731 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
732 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
734 phos = new TTask("PHOS", "") ;
738 AliPHOSClusterizer * phoscl = dynamic_cast<AliPHOSClusterizer*>(phos->GetListOfTasks()->FindObject(clu->GetName())) ;
741 cout << "INFO: AliPHOSGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
743 phos->GetListOfTasks()->Remove(phoscl) ;
749 //____________________________________________________________________________
750 TObject** AliPHOSGetter::ClusterizerRef(const char * name) const
751 { // ------------------ AliPHOSClusterizer ------------------------
753 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
756 cerr << "ERROR: AliPHOSGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
760 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
762 cerr <<"WARNING: AliPHOSGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
766 TList * l = phos->GetListOfTasks() ;
770 TString cluname(name) ;
772 while((task = static_cast<TTask *>(it.Next()) )){
773 TString taskname(task->GetName()) ;
774 if(taskname.BeginsWith(cluname)){
781 return l->GetObjectRef(clu) ;
786 //____________________________________________________________________________
787 Bool_t AliPHOSGetter::PostClusterizer(const char * name) const
788 { // ------------------ AliPHOSClusterizer ------------------------
790 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
792 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
795 cerr << "ERROR: AliPHOSGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
799 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
802 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
803 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
805 phos = new TTask("PHOS", "") ;
809 AliPHOSClusterizer * phoscl = new AliPHOSClusterizer() ;
811 clun+=":clusterizer" ;
812 phoscl->SetName(clun) ;
818 //____________________________________________________________________________
819 Bool_t AliPHOSGetter::PostTrackSegments(const char * name) const
820 { // ---------------TrackSegments -----------------------------------
822 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
824 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
828 cout << "WARNING: AliPHOSGetter::Post TS -> Folder //" << fRecoFolder << "/PHOS/ not found!" << endl;
829 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS" << endl;
831 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
834 TFolder * phosTSFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("TrackSegments")) ;
835 if ( !phosTSFolder ) {
837 cout << "WARNING: AliPHOSGetter::Post TS -> Folder//" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
838 cout << "INFO: AliPHOSGetter::Post TS -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/" << endl;
840 phosTSFolder = phosFolder->AddFolder("TrackSegments", "TrackSegments from PHOS") ;
843 TObject * tss = phosTSFolder->FindObject( name ) ;
845 TClonesArray * ts = new TClonesArray("AliPHOSTrackSegment",100) ;
847 phosTSFolder->Add(ts) ;
852 //____________________________________________________________________________
853 TObject** AliPHOSGetter::TrackSegmentsRef(const char * name) const
854 { // ---------------TrackSegments -----------------------------------
856 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
858 if ( !fRecoFolder ) {
859 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "not found!" << endl;
863 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
865 cerr << "ERROR: AliPHOSGetter::TrackSegmentsRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/TrackSegments/ not found!" << endl;
869 TObject * tss = phosFolder->FindObject(name) ;
873 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
876 //____________________________________________________________________________
877 Bool_t AliPHOSGetter::PostTrackSegmentMaker(AliPHOSTrackSegmentMaker * tsmaker) const
878 { //------------Track Segment Maker ------------------------------
880 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
882 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
885 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
889 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
892 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
893 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
895 phos = new TTask("PHOS", "") ;
899 AliPHOSTrackSegmentMaker * phosts =
900 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
903 phos->GetListOfTasks()->Remove(phosts) ;
909 //____________________________________________________________________________
910 Bool_t AliPHOSGetter::PostTrackSegmentMaker(const char * name) const
911 { //------------Track Segment Maker ------------------------------
913 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
916 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
919 cerr << "ERROR: AliPHOSGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
923 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
926 cout <<"WARNING: AliPHOSGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
927 cout <<"INFO: AliPHOSGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
929 phos = new TTask("PHOS", "") ;
933 AliPHOSTrackSegmentMaker * phosts =
934 dynamic_cast<AliPHOSTrackSegmentMaker*>(phos->GetListOfTasks()->FindObject(name)) ;
936 phosts = new AliPHOSTrackSegmentMaker() ;
938 tsn+=":tracksegmentmaker" ;
939 phosts->SetName(tsn) ;
946 //____________________________________________________________________________
947 TObject** AliPHOSGetter::TSMakerRef(const char * name) const
948 { //------------Track Segment Maker ------------------------------
950 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
953 cerr << "ERROR: AliPHOSGetter::Post TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
957 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
959 cerr <<"WARNING: AliPHOSGetter::Post TerRef -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
963 TList * l = phos->GetListOfTasks() ;
967 TString tsmname(name) ;
969 while((task = static_cast<TTask *>(it.Next()) )){
970 TString taskname(task->GetName()) ;
971 if(taskname.BeginsWith(tsmname)){
978 return l->GetObjectRef(tsm) ;
984 //____________________________________________________________________________
985 Bool_t AliPHOSGetter::PostRecParticles(const char * name) const
986 { // -------------------- RecParticles ------------------------
988 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
990 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS")) ;
994 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/ not found!" << endl;
995 cout << "INFO: AliPHOSGetter::Post Rpa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/" << endl;
997 phosFolder = fRecoFolder->AddFolder("PHOS", "Reconstructed data from PHOS") ;
1000 TFolder * phosRPaFolder = dynamic_cast<TFolder*>(phosFolder->FindObject("RecParticles")) ;
1001 if ( !phosRPaFolder ) {
1003 cout << "WARNING: AliPHOSGetter::Post RPa -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1004 cout << "INFO: AliPHOSGetter::Post RPa -> Adding Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/" << endl;
1006 phosRPaFolder = phosFolder->AddFolder("RecParticles", "RecParticles from PHOS") ;
1009 TObject * rps = phosRPaFolder->FindObject( name ) ;
1011 TClonesArray * rp = new TClonesArray("AliPHOSRecParticle",100) ;
1013 phosRPaFolder->Add(rp) ;
1018 //____________________________________________________________________________
1019 TObject** AliPHOSGetter::RecParticlesRef(const char * name) const
1020 { // ---------------TrackSegments -----------------------------------
1022 // the hierarchy is //Folders/Run/Event/RecData/PHOS/TrackSegments/name
1024 if ( !fRecoFolder ) {
1025 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder//" << fRecoFolder->GetName() << " not found!" << endl;
1029 TFolder * phosFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1030 if ( !phosFolder ) {
1031 cerr << "ERROR: AliPHOSGetter::RecParticlesRef -> Folder //" << fRecoFolder->GetName() << "/PHOS/RecParticles/ not found!" << endl;
1035 TObject * tss = phosFolder->FindObject(name ) ;
1039 return phosFolder->GetListOfFolders()->GetObjectRef(tss) ;
1042 //____________________________________________________________________________
1043 Bool_t AliPHOSGetter::PostPID(AliPHOSPID * pid) const
1044 { // ------------AliPHOS PID -----------------------------
1046 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1049 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1053 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1056 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1057 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1059 phos = new TTask("PHOS", "") ;
1063 AliPHOSPID * phospid = dynamic_cast<AliPHOSPID*>(phos->GetListOfTasks()->FindObject(pid->GetName())) ;
1066 cout << "INFO: AliPHOSGetter::Post Per -> Task " << pid->GetName()
1067 << " already exists" << endl ;
1068 phos->GetListOfTasks()->Remove(phospid) ;
1075 //____________________________________________________________________________
1076 Bool_t AliPHOSGetter::PostPID(const char * name) const
1078 // the hierarchy is //Folders/Tasks/Reconstructioner/PHOS/sdigitsname
1080 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1083 cerr << "ERROR: AliPHOSGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1087 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1090 cout <<"WARNING: AliPHOSGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/PHOS not found!" << endl;
1091 cout <<"INFO: AliPHOSGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/PHOS" << endl;
1093 phos = new TTask("PHOS", "") ;
1097 TList * l = phos->GetListOfTasks() ;
1099 TString pidname(name) ;
1102 while((task = static_cast<TTask *>(it.Next()) )){
1103 TString taskname(task->GetName()) ;
1104 if(taskname.BeginsWith(pidname))
1108 AliPHOSPID * phospid = new AliPHOSPID() ;
1109 phospid->SetName(pidname) ;
1110 phos->Add(phospid) ;
1115 //____________________________________________________________________________
1116 TObject** AliPHOSGetter::PIDRef(const char * name) const
1117 { //------------PID ------------------------------
1119 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1122 cerr << "ERROR: AliPHOSGetter::Post PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1126 TTask * phos = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1128 cerr <<"WARNING: AliPHOSGetter::Post PerRef -> //" << fTasksFolder << "/ReconstructionerPHOS not found!" << endl;
1132 TList * l = phos->GetListOfTasks() ;
1136 TString pidname(name) ;
1138 while((task = static_cast<TTask *>(it.Next()) )){
1139 TString taskname(task->GetName()) ;
1140 if(taskname.BeginsWith(pidname)){
1147 return l->GetObjectRef(pid) ;
1153 //____________________________________________________________________________
1154 Bool_t AliPHOSGetter::PostQA(void) const
1155 { // ------------------ QA ---------------------------------
1157 // the hierarchy is //Folders/Run/Conditions/QA/PHOS/alarmsName
1159 TFolder * phosFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("PHOS")) ;
1160 if ( !phosFolder ) {
1162 cout << "WARNING: AliPHOSGetter::Post Q -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1163 cout << "INFO: AliPHOSGetter::Post Q -> Adding Folder //" << fQAFolder << "/PHOS/" << endl;
1165 phosFolder = fQAFolder->AddFolder("PHOS", "QA from PHOS") ;
1171 //____________________________________________________________________________
1172 TObject** AliPHOSGetter::AlarmsRef(void) const
1173 { //------- Alarms ----------------------
1176 // the hierarchy is //Folders/Run/Conditions/QA/PHOS
1178 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << " not found!" << endl;
1182 TFolder * phosFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1183 if ( !phosFolder ) {
1184 cerr << "ERROR: AliPHOSGetter::Post QRef -> Folder //" << fQAFolder << "/PHOS/ not found!" << endl;
1188 return fQAFolder->GetListOfFolders()->GetObjectRef(phosFolder) ;
1191 //____________________________________________________________________________
1192 const TParticle * AliPHOSGetter::Primary(Int_t index) const
1194 // Return primary particle numbered by <index>
1198 TParticle * p = gAlice->Particle(index) ;
1199 if (p->GetFirstMother() != -1 ) {
1200 cout << "AliPHOSGetter::Primary : Not a primary " << endl ;
1205 // Int_t primaryIndex = index % 10000000 ;
1206 // Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1208 // if ( primaryList > 0 ) {
1210 // cout << " Getter does not support currently Mixing of primary " << endl ;
1211 // cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1216 // return gAlice->Particle(primaryIndex) ;
1220 //____________________________________________________________________________
1221 const TParticle * AliPHOSGetter::Secondary(TParticle* p, Int_t index) const
1223 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1231 Int_t daughterIndex = p->GetDaughter(index-1) ;
1232 return gAlice->Particle(daughterIndex) ;
1238 //____________________________________________________________________________
1239 Int_t AliPHOSGetter::ReadTreeD()
1241 // Read the digit tree gAlice->TreeD()
1242 if(gAlice->TreeD()== 0){
1243 cerr << "WARNING: AliPHOSGetter::ReadTreeD: can not read TreeD " << endl ;
1247 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1249 TBranch * branch = 0 ;
1250 TBranch * digitsbranch = 0 ;
1251 TBranch * digitizerbranch = 0 ;
1252 Bool_t phosfound = kFALSE, digitizerfound = kFALSE ;
1254 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !digitizerfound) ) {
1255 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1256 digitsbranch = branch ;
1259 else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1260 digitizerbranch = branch ;
1261 digitizerfound = kTRUE ;
1265 if ( !phosfound || !digitizerfound ) {
1267 cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1268 << fDigitsTitle << endl ;
1273 if(!Digits(fDigitsTitle) )
1274 PostDigits(fDigitsTitle);
1275 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1276 digitsbranch->GetEntry(0) ;
1279 // read the Digitizer
1280 if(!Digitizer(fDigitsTitle))
1281 PostDigitizer(fDigitsTitle) ;
1282 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1283 digitizerbranch->GetEntry(0) ;
1288 //____________________________________________________________________________
1289 Int_t AliPHOSGetter::ReadTreeH()
1291 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1293 if(gAlice->TreeH()== 0){
1294 cerr << "WARNING: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1298 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("PHOS")) ;
1299 if ( !hitsbranch ) {
1301 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1307 if (hitsbranch->GetEntries() > 1 ) {
1308 TClonesArray * tempo = new TClonesArray("AliPHOSHit",1000) ;
1309 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1310 hitsbranch->SetAddress(&tempo) ;
1313 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1314 hitsbranch->GetEntry(i) ;
1316 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1317 const AliPHOSHit * hit = static_cast<const AliPHOSHit *>(tempo->At(j)) ;
1318 new((*hits)[index]) AliPHOSHit( *hit ) ;
1325 hitsbranch->SetAddress(HitsRef()) ;
1326 hitsbranch->GetEntry(0) ;
1331 //____________________________________________________________________________
1332 void AliPHOSGetter::Track(Int_t itrack)
1334 // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
1336 if(gAlice->TreeH()== 0){
1337 cerr << "ERROR: AliPHOSGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1341 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("PHOS")) ;
1342 if ( !hitsbranch ) {
1344 cout << "WARNING: AliPHOSGetter::ReadTreeH -> Cannot find branch PHOS" << endl ;
1350 hitsbranch->SetAddress(HitsRef()) ;
1351 hitsbranch->GetEntry(itrack) ;
1355 //____________________________________________________________________________
1356 void AliPHOSGetter::ReadTreeQA()
1358 // Read the digit tree gAlice->TreeQA()
1359 // so far only PHOS knows about this Tree
1361 if(PHOS()->TreeQA()== 0){
1362 cerr << "ERROR: AliPHOSGetter::ReadTreeQA: can not read TreeQA " << endl ;
1366 TBranch * qabranch = PHOS()->TreeQA()->GetBranch("PHOS") ;
1369 cout << "WARNING: AliPHOSGetter::ReadTreeQA -> Cannot find QA Alarms for PHOS" << endl ;
1376 qabranch->SetAddress(AlarmsRef()) ;
1378 qabranch->GetEntry(0) ;
1381 // TFolder * alarmsF = Alarms() ;
1382 // alarmsF->Clear() ;
1383 // qabranch->SetAddress(&alarmsF) ;
1384 // qabranch->GetEntry(0) ;
1388 //____________________________________________________________________________
1389 Int_t AliPHOSGetter::ReadTreeR(Bool_t any)
1391 // Read the reconstrunction tree gAlice->TreeR()
1392 // A particularity has been introduced here :
1393 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1394 // being for example give in AliPHOSPID(fileName, title)
1395 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1396 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1397 // from a given set of TrackSegments (with a given name)
1398 // This is why any is NOT used to read the branch of RecParticles
1401 if(gAlice->TreeR()== 0){
1402 cerr << "WARNING: AliPHOSGetter::ReadTreeR: can not read TreeR " << endl ;
1407 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1409 TBranch * branch = 0 ;
1410 TBranch * emcbranch = 0 ;
1411 TBranch * cpvbranch = 0 ;
1412 TBranch * clusterizerbranch = 0 ;
1413 Bool_t phosemcrpfound = kFALSE, phoscpvrpfound = kFALSE, clusterizerfound = kFALSE ;
1415 while ( (branch = static_cast<TBranch*>(next())) && (!phosemcrpfound || !phoscpvrpfound || !clusterizerfound) )
1416 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 || any) {
1417 if ( strcmp(branch->GetName(), "PHOSEmcRP")==0) {
1418 emcbranch = branch ;
1419 phosemcrpfound = kTRUE ;
1421 else if ( strcmp(branch->GetName(), "PHOSCpvRP")==0) {
1422 cpvbranch = branch ;
1423 phoscpvrpfound = kTRUE ;
1425 else if(strcmp(branch->GetName(), "AliPHOSClusterizer")==0){
1426 clusterizerbranch = branch ;
1427 clusterizerfound = kTRUE ;
1431 if ( !phosemcrpfound ) {
1433 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find EmcRecPoints with title "
1434 << fRecPointsTitle << endl ;
1437 if ( !phoscpvrpfound ) {
1439 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find CpvRecPoints with title "
1440 << fRecPointsTitle << endl ;
1443 if ( !clusterizerfound ) {
1445 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Can not find Clusterizer with title "
1446 << fRecPointsTitle << endl ;
1450 // Read and Post the RecPoints
1451 if(!EmcRecPoints(fRecPointsTitle) )
1452 PostRecPoints(fRecPointsTitle) ;
1454 emcbranch->SetAddress(EmcRecPointsRef(fRecPointsTitle)) ;
1455 emcbranch->GetEntry(0) ;
1457 cpvbranch->SetAddress(CpvRecPointsRef(fRecPointsTitle)) ;
1458 cpvbranch->GetEntry(0) ;
1460 if(!Clusterizer(fRecPointsTitle) )
1461 PostClusterizer(fRecPointsTitle) ;
1463 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1464 clusterizerbranch->GetEntry(0) ;
1467 //------------------- TrackSegments ---------------------
1469 TBranch * tsbranch = 0 ;
1470 TBranch * tsmakerbranch = 0 ;
1471 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
1473 while ( (branch = static_cast<TBranch*>(next())) && (!phostsfound || !tsmakerfound) )
1474 if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 || any) {
1475 if ( strcmp(branch->GetName(), "PHOSTS")==0){
1477 phostsfound = kTRUE ;
1479 else if(strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) {
1480 tsmakerbranch = branch ;
1481 tsmakerfound = kTRUE ;
1485 if ( !phostsfound || !tsmakerfound ) {
1487 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1488 << fTrackSegmentsTitle << endl ;
1492 // Read and Post the TrackSegments
1493 if(!TrackSegments(fTrackSegmentsTitle))
1494 PostTrackSegments(fTrackSegmentsTitle) ;
1496 tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1497 tsbranch->GetEntry(0) ;
1499 // Read and Post the TrackSegment Maker
1500 if(!TrackSegmentMaker(fTrackSegmentsTitle))
1501 PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1503 tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1504 tsmakerbranch->GetEntry(0) ;
1507 //------------ RecParticles ----------------------------
1509 TBranch * rpabranch = 0 ;
1510 TBranch * pidbranch = 0 ;
1511 Bool_t phosrpafound = kFALSE, pidfound = kFALSE ;
1513 while ( (branch = static_cast<TBranch*>(next())) && (!phosrpafound || !pidfound) )
1514 if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1515 if ( strcmp(branch->GetName(), "PHOSRP")==0) {
1516 rpabranch = branch ;
1517 phosrpafound = kTRUE ;
1519 else if (strcmp(branch->GetName(), "AliPHOSPID")==0) {
1520 pidbranch = branch ;
1525 if ( !phosrpafound || !pidfound ) {
1527 cout << "WARNING: AliPHOSGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1528 << fRecParticlesTitle << endl ;
1532 // Read and Post the RecParticles
1533 if(!RecParticles(fRecParticlesTitle))
1534 PostRecParticles(fRecParticlesTitle) ;
1536 rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1537 rpabranch->GetEntry(0) ;
1539 // Read and Post the PID
1540 if(!PID(fRecParticlesTitle))
1541 PostPID(fRecParticlesTitle) ;
1543 pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1544 pidbranch->GetEntry(0) ;
1549 //____________________________________________________________________________
1550 Int_t AliPHOSGetter::ReadTreeS(Int_t event)
1552 // Read the summable digits tree gAlice->TreeS()
1554 // loop over all opened files and read their SDigits to the White Board
1555 TFolder * phosF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("PHOS")) ;
1557 phosF = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1558 TCollection * folderslist = phosF->GetListOfFolders() ;
1560 //Add current file to list if it is not there yet
1562 TString subdir(fHeaderFile) ;
1563 subdir.ReplaceAll("/","_") ;
1565 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1566 phosF->AddFolder(subdir, "");
1569 TIter next(folderslist) ;
1570 TFolder * folder = 0 ;
1573 while ( (folder = static_cast<TFolder*>(next())) ) {
1574 TString fileName(folder->GetName()) ;
1575 fileName.ReplaceAll("_","/") ;
1576 if(fHeaderFile.CompareTo(fileName) == 0 )
1577 treeS=gAlice->TreeS() ;
1579 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1582 // Get SDigits Tree header from file
1583 TString treeName("TreeS") ;
1585 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1588 cerr << "WARNING: AliPHOSGetter::ReadTreeS There is no SDigit Tree" << endl;
1592 //set address of the SDigits and SDigitizer
1593 TBranch * sdigitsBranch = 0;
1594 TBranch * sdigitizerBranch = 0;
1595 TBranch * branch = 0 ;
1596 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1598 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1600 while ( (branch = static_cast<TBranch*>(next())) && (!phosfound || !sdigitizerfound) ) {
1601 if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1603 sdigitsBranch = branch ;
1606 else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1607 sdigitizerfound = kTRUE ;
1608 sdigitizerBranch = branch ;
1611 if ( !phosfound || !sdigitizerfound ) {
1613 cout << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
1614 << " not found" << endl ;
1618 if ( !folder->FindObject(fSDigitsTitle) )
1619 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1621 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1622 sdigitsBranch->GetEntry(0) ;
1624 TString sdname(fSDigitsTitle) ;
1626 sdname+=folder->GetName() ;
1627 if(!SDigitizer(sdname) )
1628 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1630 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1631 sdigitizerBranch->GetEntry(0) ;
1635 // After SDigits have been read from all files, return to the first one
1638 folder = static_cast<TFolder*>(next());
1640 TString fileName(folder->GetName()) ;
1641 fileName.ReplaceAll("_","/") ;
1642 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1647 //____________________________________________________________________________
1648 void AliPHOSGetter::ReadTreeS(TTree * treeS, Int_t input)
1649 { // Read the summable digits fron treeS()
1652 TString filename("mergefile") ;
1655 TFolder * phosFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("PHOS")) ;
1656 if ( !phosFolder ) {
1657 phosFolder = fSDigitsFolder->AddFolder("PHOS", "SDigits from PHOS") ;
1659 TFolder * folder=(TFolder*)phosFolder->FindObject(filename) ;
1660 //set address of the SDigits and SDigitizer
1661 TBranch * sdigitsBranch = 0;
1662 TBranch * sdigitizerBranch = 0;
1663 TBranch * branch = 0 ;
1664 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1666 Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ;
1668 while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) {
1669 if ( strcmp(branch->GetName(), "PHOS")==0) {
1671 sdigitsBranch = branch ;
1674 else if ( strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) {
1675 sdigitizerfound = kTRUE ;
1676 sdigitizerBranch = branch ;
1679 if ( !phosfound || !sdigitizerfound ) {
1681 cout << "WARNING: AliPHOSGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1685 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1686 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1688 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1689 sdigitsBranch->GetEntry(0) ;
1691 TString sdname(sdigitsBranch->GetTitle()) ;
1694 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1695 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1697 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1698 sdigitizerBranch->GetEntry(0) ;
1703 //____________________________________________________________________________
1704 void AliPHOSGetter::ReadPrimaries()
1706 // a lot simplified.... if 2 files are opened then we have a problem
1708 TClonesArray * ar = 0 ;
1709 if(! (ar = Primaries()) ) {
1715 fNPrimaries = gAlice->GetNtrack() ;
1717 for (index = 0 ; index < fNPrimaries; index++) {
1718 new ((*ar)[index]) TParticle(*(Primary(index)));
1721 //____________________________________________________________________________
1722 void AliPHOSGetter::Event(const Int_t event, const char* opt)
1724 // Reads the content of all Tree's S, D and R
1726 if (event >= gAlice->TreeE()->GetEntries() ) {
1727 cerr << "ERROR: AliPHOSGetter::Event -> " << event << " not found in TreeE!" << endl ;
1731 Bool_t any = kFALSE ;
1732 if (strstr(opt,"A") ) // do not check the title of the branches
1735 gAlice->GetEvent(event) ;
1742 if(strstr(opt,"H") )
1743 rvRH = ReadTreeH() ;
1745 if(strstr(opt,"S") )
1746 rvRS = ReadTreeS(event) ;
1748 if( strstr(opt,"D") )
1749 rvRD = ReadTreeD() ;
1751 if( strstr(opt,"R") )
1752 rvRR = ReadTreeR(any) ;
1754 if( strstr(opt,"Q") )
1757 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1758 if ( gAlice->Stack() )
1763 //____________________________________________________________________________
1764 TObject * AliPHOSGetter::ReturnO(TString what, TString name, TString file) const
1766 // get the object named "what" from the folder
1767 // folders are named like //Folders
1769 if ( file.IsNull() )
1770 file = fHeaderFile ;
1772 TFolder * folder = 0 ;
1773 TObject * phosO = 0 ;
1775 // if ( name.IsNull() ) {
1776 if ( what.CompareTo("Primaries") == 0 ) {
1777 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1779 phosO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1781 else if ( what.CompareTo("Hits") == 0 ) {
1782 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("PHOS")) ;
1784 phosO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1786 else if ( what.CompareTo("SDigits") == 0 ) {
1787 file.ReplaceAll("/","_") ;
1788 TString path = "PHOS/" + file ;
1789 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1792 name = fSDigitsTitle ;
1793 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1796 else if ( what.CompareTo("Digits") == 0 ){
1797 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("PHOS")) ;
1800 name = fDigitsTitle ;
1801 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1804 else if ( what.CompareTo("EmcRecPoints") == 0 ) {
1805 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/EMCARecPoints")) ;
1808 name = fRecPointsTitle ;
1809 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1812 else if ( what.CompareTo("CpvRecPoints") == 0 ) {
1813 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/CPVRecPoints")) ;
1816 name = fRecPointsTitle ;
1817 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1820 else if ( what.CompareTo("TrackSegments") == 0 ) {
1821 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/TrackSegments")) ;
1824 name = fTrackSegmentsTitle ;
1825 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1828 else if ( what.CompareTo("RecParticles") == 0 ) {
1829 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("PHOS/RecParticles")) ;
1832 name = fRecParticlesTitle ;
1833 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1836 else if ( what.CompareTo("Alarms") == 0 ){
1838 phosO = dynamic_cast<TObject *>(fQAFolder->FindObject("PHOS")) ;
1840 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("PHOS")) ;
1844 phosO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1849 cerr << "ERROR : AliPHOSGetter::ReturnO -> Object " << what << " not found in " << fQAFolder->GetName() << endl ;
1856 //____________________________________________________________________________
1857 const TTask * AliPHOSGetter::ReturnT(TString what, TString name) const
1859 // get the TTask named "what" from the folder
1860 // folders are named like //Folders/Tasks/what/PHOS/name
1862 TString search(what) ;
1863 if ( what.CompareTo("Clusterizer") == 0 )
1864 search = "Reconstructioner" ;
1865 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1866 search = "Reconstructioner" ;
1867 else if ( what.CompareTo("PID") == 0 )
1868 search = "Reconstructioner" ;
1869 else if ( what.CompareTo("QATasks") == 0 )
1872 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1875 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << " not found!" << endl ;
1879 TTask * phosT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("PHOS")) ;
1881 cerr << "ERROR: AliPHOSGetter::ReturnT -> Task " << what << "/PHOS not found!" << endl ;
1885 TList * list = phosT->GetListOfTasks() ;
1887 if (what.CompareTo("SDigitizer") == 0) {
1888 if ( name.IsNull() )
1889 name = fSDigitsTitle ;
1890 } else if (what.CompareTo("Digitizer") == 0){
1891 if ( name.IsNull() )
1892 name = fDigitsTitle ;
1893 } else if (what.CompareTo("Clusterizer") == 0){
1894 if ( name.IsNull() )
1895 name = fRecPointsTitle ;
1896 name.Append(":clu") ;
1898 else if (what.CompareTo("TrackSegmentMaker") == 0){
1899 if ( name.IsNull() )
1900 name = fTrackSegmentsTitle ;
1901 name.Append(":tsm") ;
1903 else if (what.CompareTo("PID") == 0){
1904 if ( name.IsNull() )
1905 name = fRecParticlesTitle ;
1906 name.Append(":pid") ;
1908 else if (what.CompareTo("QATasks") == 0){
1909 if ( name.IsNull() )
1915 while((task = static_cast<TTask *>(it.Next()) )){
1916 TString taskname(task->GetName()) ;
1917 if(taskname.BeginsWith(name))
1922 cout << "WARNING: AliPHOSGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;