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 AliEMCALAnalyser):
34 // AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
35 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
36 // AliEMCALRecParticle * 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 AliEMCALIndexToObject and make
44 //*-- systematic usage of TFolders without changing the interface
45 //////////////////////////////////////////////////////////////////////////////
48 // --- ROOT system ---
53 #include "TObjString.h"
56 // --- Standard library ---
59 // --- AliRoot header files ---
62 #include "AliConfig.h"
63 #include "AliEMCALGetter.h"
64 #include "AliEMCALHit.h"
65 #include "AliEMCALv1.h"
66 #include "AliEMCALDigitizer.h"
67 #include "AliEMCALSDigitizer.h"
68 #include "AliEMCALClusterizer.h"
69 #include "AliEMCALClusterizerv1.h"
70 //#include "AliEMCALTrackSegmentMaker.h"
71 //#include "AliEMCALTrackSegmentMakerv1.h"
72 //#include "AliEMCALTrackSegment.h"
73 //#include "AliEMCALPID.h"
74 //#include "AliEMCALPIDv1.h"
75 #include "AliEMCALGeometry.h"
77 ClassImp(AliEMCALGetter)
79 AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ;
80 TFile * AliEMCALGetter::fFile = 0 ;
82 //____________________________________________________________________________
83 AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle, const Option_t * rw)
85 //Initialize all lists
89 fHeaderFile = headerFile ;
90 fBranchTitle = branchTitle ;
91 fSDigitsTitle = branchTitle ;
92 fDigitsTitle = branchTitle ;
93 fRecPointsTitle = branchTitle ;
94 //fRecParticlesTitle = branchTitle ;
95 //fTrackSegmentsTitle = branchTitle ;
97 fPrimaries = new TObjArray(1) ;
99 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
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 if ( fHeaderFile.Contains("_") ) {
115 cerr << "AliPHOSGetter::AliPHOSGetter -> Invalid file name (_ not allowed) " << fHeaderFile.Data() << endl ;
118 fFile = TFile::Open(fHeaderFile.Data(),rw) ;
120 if (!fFile->IsOpen()) {
121 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ;
126 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
131 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
137 cout << "INFO: AliEMCALGetter -> Posting EMCAL to Folders" << endl ;
138 if (gAlice->GetDetector("EMCAL")) {
139 AliConfig * conf = AliConfig::Instance() ;
140 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
141 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
144 cerr << "ERROR: AliEMCALGetter -> detector EMCAL not found" << endl ;
149 //____________________________________________________________________________
150 AliEMCALGetter::~AliEMCALGetter()
153 fPrimaries->Delete() ;
157 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
158 TCollection * folderslist = emcalF->GetListOfFolders() ;
159 TIter next(folderslist) ;
160 TFolder * folder = 0 ;
161 while ( (folder = static_cast<TFolder*>(next())) )
162 emcalF->Remove(folder) ;
169 //____________________________________________________________________________
170 void AliEMCALGetter::CreateWhiteBoard() const
175 //____________________________________________________________________________
176 AliEMCALGetter * AliEMCALGetter::GetInstance()
178 // Returns the pointer of the unique instance already defined
180 AliEMCALGetter * rv = 0 ;
184 cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
190 //____________________________________________________________________________
191 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
192 const char* branchTitle, const Option_t * rw)
194 // Creates and returns the pointer of the unique instance
195 // Must be called only when the environment has changed
198 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
199 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0)) {
204 fgObjGetter->~AliEMCALGetter() ; // delete it already exists another version
206 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle, rw) ;
208 if (fgObjGetter->HasFailed() )
216 //____________________________________________________________________________
217 const AliEMCALv1 * AliEMCALGetter::EMCAL()
219 // returns the EMCAL object
220 AliEMCALv1 * emcal = dynamic_cast<AliEMCALv1*>(fModuleFolder->FindObject("EMCAL")) ;
223 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
227 //____________________________________________________________________________
228 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
230 AliEMCALGeometry * rv = 0 ;
232 rv = EMCAL()->GetGeometry() ;
236 //____________________________________________________________________________
237 Bool_t AliEMCALGetter::PostHits(void) const
238 { //------- Hits ----------------------
240 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
242 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
243 if ( !emcalFolder ) {
245 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
246 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
248 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
250 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
251 hits->SetName("Hits") ;
252 emcalFolder->Add(hits) ;
257 //____________________________________________________________________________
258 TObject ** AliEMCALGetter::HitsRef(void) const
259 { //------- Hits ----------------------
262 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
263 if ( !fHitsFolder ) {
264 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
268 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
269 if ( !emcalFolder ) {
270 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
274 TObject * h = emcalFolder->FindObject("Hits") ;
276 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
280 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
283 //____________________________________________________________________________
284 Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
285 { //---------- SDigits -------------------------
288 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
289 // because you can have sdigits from several hit files for mixing
291 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
292 if ( !emcalFolder ) {
294 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
295 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
297 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
299 TString subdir(headerFile) ;
300 subdir.ReplaceAll("/", "_") ;
301 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
302 if ( !emcalSubFolder )
303 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
305 TObject * sd = emcalSubFolder->FindObject(name);
308 cerr <<"INFO: AliEMCALGetter::Post S -> Folder " << subdir
309 << " already exists!" << endl ;
311 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
312 sdigits->SetName(name) ;
313 emcalSubFolder->Add(sdigits) ;
318 //____________________________________________________________________________
319 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
320 { //------- SDigits ----------------------
322 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
324 if ( !fSDigitsFolder ) {
325 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
329 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
330 if ( !emcalFolder ) {
331 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
335 TFolder * emcalSubFolder = 0 ;
337 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
339 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
341 if(!emcalSubFolder) {
342 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
346 TObject * dis = emcalSubFolder->FindObject(name) ;
350 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
354 //____________________________________________________________________________
355 Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
356 { //---------- SDigitizer -------------------------
358 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
361 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
364 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
367 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
370 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
371 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
373 emcal = new TTask("EMCAL", "") ;
376 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
379 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
380 emcal->GetListOfTasks()->Remove(emcalsd) ;
382 emcal->Add(sdigitizer) ;
387 //____________________________________________________________________________
388 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
391 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
393 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
397 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
399 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
403 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
405 return emcal->GetListOfTasks()->GetObjectRef(task) ;
409 //____________________________________________________________________________
410 Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
411 { //---------- SDigitizer -------------------------
413 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
416 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
418 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
422 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
425 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
426 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
428 emcal = new TTask("EMCAL", "") ;
432 TString sdname(name) ;
435 sdname.ReplaceAll("/","_") ;
436 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
438 emcalsd = new AliEMCALSDigitizer() ;
439 //Note, we can not call constructor with parameters: it will call Getter and screw up everething
440 emcalsd->SetName(sdname) ;
441 emcalsd->SetTitle(file) ;
442 emcal->Add(emcalsd) ;
448 //____________________________________________________________________________
449 Bool_t AliEMCALGetter::PostDigits(const char * name) const
450 { //---------- Digits -------------------------
452 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
454 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
456 if ( !emcalFolder ) {
458 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
459 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
461 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
464 TObject* dig = emcalFolder->FindObject( name ) ;
466 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
467 digits->SetName(name) ;
468 emcalFolder->Add(digits) ;
473 //____________________________________________________________________________
474 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
475 { //------- Digits ----------------------
477 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
479 if ( !fDigitsFolder ) {
480 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
484 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
485 if ( !emcalFolder ) {
486 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
490 TObject * d = emcalFolder->FindObject(name) ;
494 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
498 //____________________________________________________________________________
499 Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
500 { //---------- Digitizer -------------------------
502 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
505 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
508 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
511 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
512 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
514 emcal = new TTask("EMCAL", "") ;
518 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
521 emcal->GetListOfTasks()->Remove(emcald) ;
523 emcal->Add(digitizer) ;
527 //____________________________________________________________________________
528 Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
529 { //---------- Digitizer -------------------------
531 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
533 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
535 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
539 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
542 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
543 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
545 emcal = new TTask("EMCAL", "") ;
549 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
551 emcald = new AliEMCALDigitizer() ;
552 emcald->SetName(fDigitsTitle) ;
553 emcald->SetTitle(fHeaderFile) ;
559 //____________________________________________________________________________
560 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
562 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
564 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
568 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
570 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
574 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
576 return emcal->GetListOfTasks()->GetObjectRef(task) ;
580 //____________________________________________________________________________
581 Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
582 { // -------------- RecPoints -------------------------------------------
584 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
585 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
587 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
589 if ( !emcalFolder ) {
591 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
592 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
594 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
598 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
599 if ( !emcalRPoTowerFolder ) {
601 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
602 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
604 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
607 TObject * erp = emcalFolder->FindObject( name ) ;
609 TObjArray * towerrp = new TObjArray(100) ;
610 towerrp->SetName(name) ;
611 emcalRPoTowerFolder->Add(towerrp) ;
614 // Pre Shower RecPoints
615 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShoRecPoints")) ;
616 if ( !emcalRPoPreShoFolder ) {
618 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/ not found!" << endl;
619 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
621 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShoRecPoints", "PreSho RecPoints from EMCAL") ;
624 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
626 TObjArray * preshorp = new TObjArray(100) ;
627 preshorp->SetName(name) ;
628 emcalRPoPreShoFolder->Add(preshorp) ;
633 //____________________________________________________________________________
634 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
635 { // -------------- RecPoints -------------------------------------------
637 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
639 if ( !fRecoFolder ) {
640 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
644 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
645 if ( !towerFolder ) {
646 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
651 TObject * trp = towerFolder->FindObject(name ) ;
653 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
656 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
660 //____________________________________________________________________________
661 TObject ** AliEMCALGetter::PreShoRecPointsRef(const char * name) const
662 { // -------------- RecPoints -------------------------------------------
664 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
666 if ( !fRecoFolder ) {
667 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
671 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
672 if ( !preshoFolder ) {
673 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
677 TObject * prp = preshoFolder->FindObject(name ) ;
679 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Object " << name << " not found! " << endl ;
682 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
686 //____________________________________________________________________________
687 Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizerv1 * clu) const
688 { // ------------------ AliEMCALClusterizer ------------------------
690 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
692 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
695 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
699 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
702 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
703 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
705 emcal = new TTask("EMCAL", "") ;
709 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
712 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
714 emcal->GetListOfTasks()->Remove(emcalcl) ;
720 //____________________________________________________________________________
721 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
722 { // ------------------ AliEMCALClusterizer ------------------------
724 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
727 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
731 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
733 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
737 TList * l = emcal->GetListOfTasks() ;
741 TString cluname(name) ;
743 while((task = static_cast<TTask *>(it.Next()) )){
744 TString taskname(task->GetName()) ;
745 if(taskname.BeginsWith(cluname)){
752 return l->GetObjectRef(clu) ;
754 cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
759 //____________________________________________________________________________
760 Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
761 { // ------------------ AliEMCALClusterizer ------------------------
763 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
765 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
768 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
772 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
775 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
776 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
778 emcal = new TTask("EMCAL", "") ;
782 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
785 emcalcl->SetName(clun) ;
786 emcal->Add(emcalcl) ;
791 //____________________________________________________________________________
792 /*Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
793 { // ---------------TrackSegments -----------------------------------
795 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
797 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
799 if ( !emcalFolder ) {
801 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
802 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
804 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
807 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
808 if ( !emcalTSFolder ) {
810 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
811 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
813 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
816 TObject * tss = emcalTSFolder->FindObject( name ) ;
818 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
820 emcalTSFolder->Add(ts) ;
825 //____________________________________________________________________________
826 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
827 { // ---------------TrackSegments -----------------------------------
829 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
831 if ( !fRecoFolder ) {
832 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
836 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
837 if ( !emcalFolder ) {
838 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
842 TObject * tss = emcalFolder->FindObject(name) ;
844 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
847 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
850 //____________________________________________________________________________
851 Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
852 { //------------Track Segment Maker ------------------------------
854 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
856 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
859 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
863 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
866 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
867 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
869 emcal = new TTask("EMCAL", "") ;
873 AliEMCALTrackSegmentMaker * emcalts =
874 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
877 emcal->GetListOfTasks()->Remove(emcalts) ;
879 emcal->Add(tsmaker) ;
883 //____________________________________________________________________________
884 Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
885 { //------------Track Segment Maker ------------------------------
887 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
890 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
893 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
897 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
900 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
901 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
903 emcal = new TTask("EMCAL", "") ;
907 AliEMCALTrackSegmentMaker * emcalts =
908 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(name)) ;
910 emcalts = new AliEMCALTrackSegmentMakerv1() ;
913 emcalts->SetName(tsn) ;
914 emcal->Add(emcalts) ;
920 //____________________________________________________________________________
921 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
922 { //------------Track Segment Maker ------------------------------
924 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
927 cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
931 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
933 cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
937 TList * l = emcal->GetListOfTasks() ;
941 TString tsmname(name) ;
943 while((task = static_cast<TTask *>(it.Next()) )){
944 TString taskname(task->GetName()) ;
945 if(taskname.BeginsWith(tsmname)){
952 return l->GetObjectRef(tsm) ;
954 cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
959 //____________________________________________________________________________
960 Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
961 { // -------------------- RecParticles ------------------------
963 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
965 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
967 if ( !emcalFolder ) {
969 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
970 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
972 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
975 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
976 if ( !emcalRPaFolder ) {
978 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
979 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
981 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
984 TObject * rps = emcalRPaFolder->FindObject( name ) ;
986 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
988 emcalRPaFolder->Add(rp) ;
993 //____________________________________________________________________________
994 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
995 { // ---------------TrackSegments -----------------------------------
997 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
999 if ( !fRecoFolder ) {
1000 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
1004 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1005 if ( !emcalFolder ) {
1006 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1010 TObject * tss = emcalFolder->FindObject(name) ;
1012 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
1015 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1018 //____________________________________________________________________________
1019 Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
1020 { // ------------AliEMCAL PID -----------------------------
1022 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1025 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1029 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1032 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1033 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1035 emcal = new TTask("EMCAL", "") ;
1039 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1042 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1043 << " already exists" << endl ;
1044 emcal->GetListOfTasks()->Remove(emcalpid) ;
1051 //____________________________________________________________________________
1052 Bool_t AliEMCALGetter::PostPID(const char * name) const
1054 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1056 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1059 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1063 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1066 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1067 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1069 emcal = new TTask("EMCAL", "") ;
1073 TList * l = emcal->GetListOfTasks() ;
1075 TString pidname(name) ;
1078 while((task = static_cast<TTask *>(it.Next()) )){
1079 TString taskname(task->GetName()) ;
1080 if(taskname.BeginsWith(pidname))
1084 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1086 emcalpid->SetName(pidname) ;
1087 emcal->Add(emcalpid) ;
1092 //____________________________________________________________________________
1093 TObject ** AliEMCALGetter::PIDRef(const char * name) const
1094 { //------------PID ------------------------------
1096 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1099 cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1103 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1105 cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
1109 TList * l = emcal->GetListOfTasks() ;
1113 TString pidname(name) ;
1115 while((task = static_cast<TTask *>(it.Next()) )){
1116 TString taskname(task->GetName()) ;
1117 if(taskname.BeginsWith(pidname)){
1124 return l->GetObjectRef(pid) ;
1126 cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
1131 //____________________________________________________________________________
1132 Bool_t AliEMCALGetter::PostQA(void) const
1133 { // ------------------ QA ---------------------------------
1135 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1137 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1138 if ( !emcalFolder ) {
1140 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1141 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1143 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1149 //____________________________________________________________________________
1150 TObject ** AliEMCALGetter::AlarmsRef(void) const
1151 { //------- Alarms ----------------------
1154 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1156 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1160 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1161 if ( !emcalFolder ) {
1162 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1166 return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1169 //____________________________________________________________________________
1170 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1172 // Return primary particle numbered by <index>
1177 Int_t primaryIndex = index % 10000000 ;
1178 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1180 if ( primaryList > 0 ) {
1182 cout << " Getter does not support currently Mixing of primary " << endl ;
1183 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1188 return gAlice->Particle(primaryIndex) ;
1192 //____________________________________________________________________________
1193 void AliEMCALGetter::ReadTreeD()
1195 // Read the digit tree gAlice->TreeD()
1196 if(gAlice->TreeD()== 0){
1197 cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
1201 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1203 TBranch * branch = 0 ;
1204 TBranch * digitsbranch = 0 ;
1205 TBranch * digitizerbranch = 0 ;
1206 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1208 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1209 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1210 digitsbranch = branch ;
1211 emcalfound = kTRUE ;
1213 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1214 digitizerbranch = branch ;
1215 digitizerfound = kTRUE ;
1219 if ( !emcalfound || !digitizerfound ) {
1221 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1222 << fDigitsTitle << endl ;
1227 if(!Digits(fDigitsTitle) )
1228 PostDigits(fDigitsTitle);
1229 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1230 digitsbranch->GetEntry(0) ;
1233 // read the Digitizer
1234 if(!Digitizer(fDigitsTitle))
1235 PostDigitizer(fDigitsTitle) ;
1236 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1237 digitizerbranch->GetEntry(0) ;
1242 //____________________________________________________________________________
1243 void AliEMCALGetter::ReadTreeH()
1245 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1247 if(gAlice->TreeH()== 0){
1248 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1252 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1253 if ( !hitsbranch ) {
1255 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1261 if (hitsbranch->GetEntries() > 1 ) {
1262 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1263 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1264 hitsbranch->SetAddress(&tempo) ;
1267 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1268 hitsbranch->GetEntry(i) ;
1270 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1271 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1272 new((*hits)[index]) AliEMCALHit( *hit ) ;
1279 hitsbranch->SetAddress(HitsRef()) ;
1280 hitsbranch->GetEntry(0) ;
1284 //____________________________________________________________________________
1285 void AliEMCALGetter::Track(Int_t itrack)
1287 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1289 if(gAlice->TreeH()== 0){
1290 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1294 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1295 if ( !hitsbranch ) {
1297 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1302 hitsbranch->SetAddress(HitsRef()) ;
1303 hitsbranch->GetEntry(itrack) ;
1307 //____________________________________________________________________________
1308 // void AliEMCALGetter::ReadTreeQA()
1310 // Read the digit tree gAlice->TreeQA()
1311 // so far only EMCAL knows about this Tree
1313 // if(EMCAL()->TreeQA()== 0){
1314 // cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1318 // TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1321 // cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1328 // qabranch->SetAddress(AlarmsRef()) ;
1330 // qabranch->GetEntry(0) ;
1332 // PostQA("EMCAL") ;
1333 // TFolder * alarmsF = Alarms() ;
1334 // alarmsF->Clear() ;
1335 // qabranch->SetAddress(&alarmsF) ;
1336 // qabranch->GetEntry(0) ;
1340 //____________________________________________________________________________
1341 void AliEMCALGetter::ReadTreeR()
1343 // Read the reconstrunction tree gAlice->TreeR()
1345 if(gAlice->TreeR()== 0){
1346 cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
1351 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1353 TBranch * branch = 0 ;
1354 TBranch * towerbranch = 0 ;
1355 TBranch * preshobranch = 0 ;
1356 TBranch * clusterizerbranch = 0 ;
1357 Bool_t emcaltowerrpfound = kFALSE, emcalpreshorpfound = kFALSE, clusterizerfound = kFALSE ;
1359 while ( (branch = static_cast<TBranch*>(next())) && (!emcaltowerrpfound || !emcalpreshorpfound || !clusterizerfound) )
1360 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1361 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1362 towerbranch = branch ;
1363 emcaltowerrpfound = kTRUE ;
1365 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1366 preshobranch = branch ;
1367 emcalpreshorpfound = kTRUE ;
1369 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1370 clusterizerbranch = branch ;
1371 clusterizerfound = kTRUE ;
1375 if ( !emcaltowerrpfound ) {
1377 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TowerRecPoints with title "
1378 << fRecPointsTitle << endl ;
1381 if ( !emcalpreshorpfound ) {
1383 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find PreShoRecPoints with title "
1384 << fRecPointsTitle << endl ;
1387 if ( !clusterizerfound ) {
1389 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Can not find Clusterizer with title "
1390 << fRecPointsTitle << endl ;
1394 // Read and Post the RecPoints
1395 if(!TowerRecPoints(fRecPointsTitle) )
1396 PostRecPoints(fRecPointsTitle) ;
1397 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1398 towerbranch->GetEntry(0) ;
1400 preshobranch->SetAddress(PreShoRecPointsRef(fRecPointsTitle)) ;
1401 preshobranch->GetEntry(0) ;
1403 if(!Clusterizer(fRecPointsTitle) )
1404 PostClusterizer(fRecPointsTitle) ;
1405 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1406 clusterizerbranch->GetEntry(0) ;
1409 //------------------- TrackSegments ---------------------
1411 // TBranch * tsbranch = 0 ;
1412 // TBranch * tsmakerbranch = 0 ;
1413 // Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1415 // while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) )
1416 // if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1417 // if ( strcmp(branch->GetName(), "EMCALTS")==0){
1418 // tsbranch = branch ;
1419 // emcaltsfound = kTRUE ;
1421 // else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1422 // tsmakerbranch = branch ;
1423 // tsmakerfound = kTRUE ;
1427 // if ( !emcaltsfound || !tsmakerfound ) {
1429 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1430 // << fTrackSegmentsTitle << endl ;
1434 // // Read and Post the TrackSegments
1435 // if(!TrackSegments(fTrackSegmentsTitle))
1436 // PostTrackSegments(fTrackSegmentsTitle) ;
1437 // tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1438 // tsbranch->GetEntry(0) ;
1440 // // Read and Post the TrackSegment Maker
1441 // if(!TrackSegmentMaker(fTrackSegmentsTitle))
1442 // PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1443 // tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1444 // tsmakerbranch->GetEntry(0) ;
1447 // //------------ RecParticles ----------------------------
1449 // TBranch * rpabranch = 0 ;
1450 // TBranch * pidbranch = 0 ;
1451 // Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1453 // while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1454 // if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1455 // if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1456 // rpabranch = branch ;
1457 // emcalrpafound = kTRUE ;
1459 // else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1460 // pidbranch = branch ;
1461 // pidfound = kTRUE ;
1465 // if ( !emcalrpafound || !pidfound ) {
1467 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1468 // << fRecParticlesTitle << endl ;
1472 // // Read and Post the RecParticles
1473 // if(!RecParticles(fRecParticlesTitle))
1474 // PostRecParticles(fRecParticlesTitle) ;
1475 // rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1476 // rpabranch->GetEntry(0) ;
1478 // // Read and Post the PID
1479 // if(!PID(fRecParticlesTitle))
1480 // PostPID(fRecParticlesTitle) ;
1481 // pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1482 // pidbranch->GetEntry(0) ;
1487 //____________________________________________________________________________
1488 void AliEMCALGetter::ReadTreeS(Int_t event)
1490 // Read the summable digits tree gAlice->TreeS()
1492 // loop over all opened files and read their SDigits to the White Board
1493 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1495 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1496 TCollection * folderslist = emcalF->GetListOfFolders() ;
1498 //Add current file to list if it is not there yet
1500 TString subdir(fHeaderFile) ;
1501 subdir.ReplaceAll("/","_") ;
1503 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1504 emcalF->AddFolder(subdir, "");
1507 TIter next(folderslist) ;
1508 TFolder * folder = 0 ;
1511 while ( (folder = static_cast<TFolder*>(next())) ) {
1512 TString fileName(folder->GetName()) ;
1513 fileName.ReplaceAll("_","/") ;
1514 if(fHeaderFile.CompareTo(fileName) == 0 )
1515 treeS=gAlice->TreeS() ;
1517 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1520 // Get SDigits Tree header from file
1521 TString treeName("TreeS") ;
1523 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1526 cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
1530 //set address of the SDigits and SDigitizer
1531 TBranch * sdigitsBranch = 0;
1532 TBranch * sdigitizerBranch = 0;
1533 TBranch * branch = 0 ;
1534 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1536 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1538 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1539 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1540 emcalfound = kTRUE ;
1541 sdigitsBranch = branch ;
1544 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1545 sdigitizerfound = kTRUE ;
1546 sdigitizerBranch = branch ;
1549 if ( !emcalfound || !sdigitizerfound ) {
1551 cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
1552 << " not found" << endl ;
1556 if ( !folder->FindObject(fSDigitsTitle) )
1557 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1558 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1559 sdigitsBranch->GetEntry(0) ;
1561 TString sdname(fSDigitsTitle) ;
1563 sdname+=folder->GetName() ;
1564 if(!SDigitizer(sdname) )
1565 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1566 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1567 sdigitizerBranch->GetEntry(0) ;
1571 // After SDigits have been read from all files, return to the first one
1574 folder = static_cast<TFolder*>(next());
1576 TString fileName(folder->GetName()) ;
1577 fileName.ReplaceAll("_","/") ;
1578 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1583 //____________________________________________________________________________
1584 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1585 { // Read the summable digits fron treeS()
1588 TString filename("mergefile") ;
1591 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1592 if ( !emcalFolder ) {
1593 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1595 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1596 //set address of the SDigits and SDigitizer
1597 TBranch * sdigitsBranch = 0;
1598 TBranch * sdigitizerBranch = 0;
1599 TBranch * branch = 0 ;
1600 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1602 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1604 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1605 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1606 emcalfound = kTRUE ;
1607 sdigitsBranch = branch ;
1610 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1611 sdigitizerfound = kTRUE ;
1612 sdigitizerBranch = branch ;
1615 if ( !emcalfound || !sdigitizerfound ) {
1617 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1621 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1622 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1624 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1625 sdigitsBranch->GetEntry(0) ;
1627 TString sdname(sdigitsBranch->GetTitle()) ;
1630 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1631 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1633 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1634 sdigitizerBranch->GetEntry(0) ;
1639 //____________________________________________________________________________
1640 void AliEMCALGetter::ReadPrimaries()
1642 // Reads specific branches of primaries
1644 fNPrimaries = gAlice->GetNtrack();
1646 // //Check, is it necessary to open new files
1647 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1648 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1650 // for(input = 0; input < filenames->GetEntriesFast(); input++){
1652 // TObjString * filename = (TObjString *) filenames->At(input) ;
1654 // //Test, if this file already open
1655 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1657 // file = new TFile( filename->GetString()) ;
1660 // // Get Kine Tree from file
1661 // // char treeName[20];
1662 // // sprintf(treeName,"TreeK%d",events->At(input));
1663 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1665 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1667 // // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1669 // // // Create the particle stack
1670 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1671 // // // Build the pointer list
1672 // // if(fParticleMap) { <----
1673 // // fParticleMap->Clear();
1674 // // fParticleMap->Expand(treeK->GetEntries());
1676 // // fParticleMap = new TObjArray(treeK->GetEntries());
1678 // // From gAlice->Particle(i)
1681 // // if(!(*fParticleMap)[i]) {
1682 // // Int_t nentries = fParticles->GetEntries();
1684 // // // algorithmic way of getting entry index
1685 // // // (primary particles are filled after secondaries)
1687 // // if (i<fHeader.GetNprimary())
1688 // // entry = i+fHeader.GetNsecondary();
1690 // // entry = i-fHeader.GetNprimary();
1692 // // // only check the algorithmic way and give
1693 // // // the fatal error if it is wrong
1694 // // if (entry != fParticleFileMap[i]) {
1695 // // Fatal("Particle",
1696 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1697 // // entry, fParticleFileMap[i]);
1700 // // fTreeK->GetEntry(fParticleFileMap[i]);
1701 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1702 // // fParticleMap->AddAt((*fParticles)[nentries],i);
1704 // // return (TParticle *) (*fParticleMap)[i];
1711 // //scan over opened files and read corresponding TreeK##
1715 //____________________________________________________________________________
1716 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1718 // Reads the content of all Tree's S, D and R
1720 if (event >= gAlice->TreeE()->GetEntries() ) {
1721 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
1724 gAlice->GetEvent(event) ;
1726 if(strstr(opt,"H") )
1729 if(strstr(opt,"S") )
1732 if( strstr(opt,"D") )
1735 if( strstr(opt,"R") )
1738 // if( strstr(opt,"Q") )
1741 // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1742 // ReadPrimaries() ;
1746 //____________________________________________________________________________
1747 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1749 // get the object named "what" from the folder
1750 // folders are named like //Folders
1752 if ( file.IsNull() )
1753 file = fHeaderFile ;
1755 TFolder * folder = 0 ;
1756 TObject * emcalO = 0 ;
1758 // if ( name.IsNull() ) {
1759 if ( what.CompareTo("Hits") == 0 ) {
1760 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1762 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1764 else if ( what.CompareTo("SDigits") == 0 ) {
1765 file.ReplaceAll("/","_") ;
1766 TString path = "EMCAL/" + file ;
1767 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1770 name = fSDigitsTitle ;
1771 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1774 else if ( what.CompareTo("Digits") == 0 ){
1775 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1778 name = fDigitsTitle ;
1779 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1782 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1783 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1786 name = fRecPointsTitle ;
1787 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1790 else if ( what.CompareTo("PreShoRecPoints") == 0 ) {
1791 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
1794 name = fRecPointsTitle ;
1795 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1799 else if ( what.CompareTo("TrackSegments") == 0 ) {
1800 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1803 name = fTrackSegmentsTitle ;
1804 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1807 else if ( what.CompareTo("RecParticles") == 0 ) {
1808 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1811 name = fRecParticlesTitle ;
1812 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1815 else if ( what.CompareTo("Alarms") == 0 ){
1817 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
1819 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1823 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1829 cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
1835 //____________________________________________________________________________
1836 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1838 // get the TTask named "what" from the folder
1839 // folders are named like //Folders/Tasks/what/EMCAL/name
1841 TString search(what) ;
1842 if ( what.CompareTo("Clusterizer") == 0 )
1843 search = "Reconstructioner" ;
1844 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1845 search = "Reconstructioner" ;
1846 else if ( what.CompareTo("PID") == 0 )
1847 search = "Reconstructioner" ;
1848 else if ( what.CompareTo("QATasks") == 0 )
1851 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1854 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
1858 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1860 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
1864 TList * list = emcalT->GetListOfTasks() ;
1866 if (what.CompareTo("SDigitizer") == 0) {
1867 if ( name.IsNull() )
1868 name = fSDigitsTitle ;
1869 } else if (what.CompareTo("Digitizer") == 0){
1870 if ( name.IsNull() )
1871 name = fDigitsTitle ;
1872 } else if (what.CompareTo("Clusterizer") == 0){
1873 if ( name.IsNull() )
1874 name = fRecPointsTitle ;
1875 name.Append(":clu") ;
1877 // else if (what.CompareTo("TrackSegmentMaker") == 0){
1878 // if ( name.IsNull() )
1879 // name = fTrackSegmentsTitle ;
1880 // name.Append(":tsm") ;
1882 // else if (what.CompareTo("PID") == 0){
1883 // if ( name.IsNull() )
1884 // name = fRecParticlesTitle ;
1885 // name.Append(":pid") ;
1887 // else if (what.CompareTo("QATasks") == 0){
1888 // if ( name.IsNull() )
1894 while((task = static_cast<TTask *>(it.Next()) )){
1895 TString taskname(task->GetName()) ;
1896 if(taskname.BeginsWith(name)){
1901 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;