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 ;
189 //____________________________________________________________________________
190 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
191 const char* branchTitle, const Option_t * rw)
193 // Creates and returns the pointer of the unique instance
194 // Must be called only when the environment has changed
197 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
198 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0)) {
203 fgObjGetter->~AliEMCALGetter() ; // delete it already exists another version
205 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle, rw) ;
207 if (fgObjGetter->HasFailed() )
210 // Posts a few item to the white board (folders)
211 // fgObjGetter->CreateWhiteBoard() ;
217 //____________________________________________________________________________
218 const AliEMCALv1 * AliEMCALGetter::EMCAL()
220 // returns the EMCAL object
221 AliEMCALv1 * emcal = dynamic_cast<AliEMCALv1*>(fModuleFolder->FindObject("EMCAL")) ;
224 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
228 //____________________________________________________________________________
229 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
231 AliEMCALGeometry * rv = 0 ;
233 rv = EMCAL()->GetGeometry() ;
237 //____________________________________________________________________________
238 Bool_t AliEMCALGetter::PostHits(void) const
239 { //------- Hits ----------------------
241 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
243 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
244 if ( !emcalFolder ) {
246 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
247 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
249 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
251 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
252 hits->SetName("Hits") ;
253 emcalFolder->Add(hits) ;
258 //____________________________________________________________________________
259 TObject ** AliEMCALGetter::HitsRef(void) const
260 { //------- Hits ----------------------
263 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
264 if ( !fHitsFolder ) {
265 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
269 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
270 if ( !emcalFolder ) {
271 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
275 TObject * h = emcalFolder->FindObject("Hits") ;
277 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
281 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
284 //____________________________________________________________________________
285 Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
286 { //---------- SDigits -------------------------
289 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
290 // because you can have sdigits from several hit files for mixing
292 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
293 if ( !emcalFolder ) {
295 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
296 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
298 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
300 TString subdir(headerFile) ;
301 subdir.ReplaceAll("/", "_") ;
302 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
303 if ( !emcalSubFolder )
304 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
306 TObject * sd = emcalSubFolder->FindObject(name);
309 cerr <<"INFO: AliEMCALGetter::Post S -> Folder " << subdir
310 << " already exists!" << endl ;
312 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
313 sdigits->SetName(name) ;
314 emcalSubFolder->Add(sdigits) ;
319 //____________________________________________________________________________
320 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
321 { //------- SDigits ----------------------
323 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
325 if ( !fSDigitsFolder ) {
326 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
330 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
331 if ( !emcalFolder ) {
332 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
336 TFolder * emcalSubFolder = 0 ;
338 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
340 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
342 if(!emcalSubFolder) {
343 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
347 TObject * dis = emcalSubFolder->FindObject(name) ;
351 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
355 //____________________________________________________________________________
356 Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
357 { //---------- SDigitizer -------------------------
359 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
362 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
365 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
368 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
371 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
372 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
374 emcal = new TTask("EMCAL", "") ;
377 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
380 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
381 emcal->GetListOfTasks()->Remove(emcalsd) ;
383 emcal->Add(sdigitizer) ;
388 //____________________________________________________________________________
389 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
392 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
394 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
398 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
400 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
404 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
406 return emcal->GetListOfTasks()->GetObjectRef(task) ;
410 //____________________________________________________________________________
411 Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
412 { //---------- SDigitizer -------------------------
414 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
417 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
419 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
423 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
426 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
427 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
429 emcal = new TTask("EMCAL", "") ;
433 TString sdname(name) ;
436 sdname.ReplaceAll("/","_") ;
437 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
439 emcalsd = new AliEMCALSDigitizer() ;
440 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
441 emcalsd->SetName(sdname) ;
442 emcalsd->SetTitle(file) ;
443 emcal->Add(emcalsd) ;
449 //____________________________________________________________________________
450 Bool_t AliEMCALGetter::PostDigits(const char * name) const
451 { //---------- Digits -------------------------
453 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
455 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
457 if ( !emcalFolder ) {
459 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
460 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
462 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
465 TObject* dig = emcalFolder->FindObject( name ) ;
467 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
468 digits->SetName(name) ;
469 emcalFolder->Add(digits) ;
474 //____________________________________________________________________________
475 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
476 { //------- Digits ----------------------
478 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
480 if ( !fDigitsFolder ) {
481 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
485 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
486 if ( !emcalFolder ) {
487 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
491 TObject * d = emcalFolder->FindObject(name) ;
495 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
499 //____________________________________________________________________________
500 Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
501 { //---------- Digitizer -------------------------
503 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
506 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
509 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
512 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
513 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
515 emcal = new TTask("EMCAL", "") ;
519 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
522 emcal->GetListOfTasks()->Remove(emcald) ;
524 emcal->Add(digitizer) ;
528 //____________________________________________________________________________
529 Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
530 { //---------- Digitizer -------------------------
532 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
534 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
536 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
540 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
543 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
544 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
546 emcal = new TTask("EMCAL", "") ;
550 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
552 emcald = new AliEMCALDigitizer() ;
553 emcald->SetName(fDigitsTitle) ;
554 emcald->SetTitle(fHeaderFile) ;
560 //____________________________________________________________________________
561 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
563 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
565 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
569 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
571 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
575 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
577 return emcal->GetListOfTasks()->GetObjectRef(task) ;
581 //____________________________________________________________________________
582 Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
583 { // -------------- RecPoints -------------------------------------------
585 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
586 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
588 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
590 if ( !emcalFolder ) {
592 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
593 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
595 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
599 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
600 if ( !emcalRPoTowerFolder ) {
602 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
603 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
605 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
608 TObject * erp = emcalFolder->FindObject( name ) ;
610 TObjArray * towerrp = new TObjArray(100) ;
611 towerrp->SetName(name) ;
612 emcalRPoTowerFolder->Add(towerrp) ;
615 // Pre Shower RecPoints
616 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShoRecPoints")) ;
617 if ( !emcalRPoPreShoFolder ) {
619 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/ not found!" << endl;
620 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
622 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShoRecPoints", "PreSho RecPoints from EMCAL") ;
625 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
627 TObjArray * preshorp = new TObjArray(100) ;
628 preshorp->SetName(name) ;
629 emcalRPoPreShoFolder->Add(preshorp) ;
634 //____________________________________________________________________________
635 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
636 { // -------------- RecPoints -------------------------------------------
638 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
640 if ( !fRecoFolder ) {
641 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
645 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
646 if ( !towerFolder ) {
647 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
652 TObject * trp = towerFolder->FindObject(name ) ;
654 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
657 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
661 //____________________________________________________________________________
662 TObject ** AliEMCALGetter::PreShoRecPointsRef(const char * name) const
663 { // -------------- RecPoints -------------------------------------------
665 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
667 if ( !fRecoFolder ) {
668 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
672 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
673 if ( !preshoFolder ) {
674 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
678 TObject * prp = preshoFolder->FindObject(name ) ;
680 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Object " << name << " not found! " << endl ;
683 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
687 //____________________________________________________________________________
688 Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizerv1 * clu) const
689 { // ------------------ AliEMCALClusterizer ------------------------
691 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
693 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
696 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
700 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
703 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
704 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
706 emcal = new TTask("EMCAL", "") ;
710 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
713 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
715 emcal->GetListOfTasks()->Remove(emcalcl) ;
721 //____________________________________________________________________________
722 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
723 { // ------------------ AliEMCALClusterizer ------------------------
725 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
728 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
732 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
734 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
738 TList * l = emcal->GetListOfTasks() ;
742 TString cluname(name) ;
744 while((task = static_cast<TTask *>(it.Next()) )){
745 TString taskname(task->GetName()) ;
746 if(taskname.BeginsWith(cluname)){
753 return l->GetObjectRef(clu) ;
755 cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
760 //____________________________________________________________________________
761 Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
762 { // ------------------ AliEMCALClusterizer ------------------------
764 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
766 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
769 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
773 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
776 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
777 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
779 emcal = new TTask("EMCAL", "") ;
783 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
786 emcalcl->SetName(clun) ;
787 emcal->Add(emcalcl) ;
792 //____________________________________________________________________________
793 /*Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
794 { // ---------------TrackSegments -----------------------------------
796 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
798 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
800 if ( !emcalFolder ) {
802 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
803 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
805 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
808 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
809 if ( !emcalTSFolder ) {
811 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
812 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
814 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
817 TObject * tss = emcalTSFolder->FindObject( name ) ;
819 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
821 emcalTSFolder->Add(ts) ;
826 //____________________________________________________________________________
827 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
828 { // ---------------TrackSegments -----------------------------------
830 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
832 if ( !fRecoFolder ) {
833 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
837 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
838 if ( !emcalFolder ) {
839 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
843 TObject * tss = emcalFolder->FindObject(name) ;
845 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
848 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
851 //____________________________________________________________________________
852 Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
853 { //------------Track Segment Maker ------------------------------
855 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
857 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
860 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
864 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
867 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
868 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
870 emcal = new TTask("EMCAL", "") ;
874 AliEMCALTrackSegmentMaker * emcalts =
875 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
878 emcal->GetListOfTasks()->Remove(emcalts) ;
880 emcal->Add(tsmaker) ;
884 //____________________________________________________________________________
885 Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
886 { //------------Track Segment Maker ------------------------------
888 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
891 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
894 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
898 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
901 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
902 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
904 emcal = new TTask("EMCAL", "") ;
908 AliEMCALTrackSegmentMaker * emcalts =
909 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(name)) ;
911 emcalts = new AliEMCALTrackSegmentMakerv1() ;
914 emcalts->SetName(tsn) ;
915 emcal->Add(emcalts) ;
921 //____________________________________________________________________________
922 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
923 { //------------Track Segment Maker ------------------------------
925 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
928 cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
932 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
934 cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
938 TList * l = emcal->GetListOfTasks() ;
942 TString tsmname(name) ;
944 while((task = static_cast<TTask *>(it.Next()) )){
945 TString taskname(task->GetName()) ;
946 if(taskname.BeginsWith(tsmname)){
953 return l->GetObjectRef(tsm) ;
955 cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
960 //____________________________________________________________________________
961 Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
962 { // -------------------- RecParticles ------------------------
964 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
966 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
968 if ( !emcalFolder ) {
970 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
971 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
973 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
976 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
977 if ( !emcalRPaFolder ) {
979 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
980 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
982 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
985 TObject * rps = emcalRPaFolder->FindObject( name ) ;
987 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
989 emcalRPaFolder->Add(rp) ;
994 //____________________________________________________________________________
995 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
996 { // ---------------TrackSegments -----------------------------------
998 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1000 if ( !fRecoFolder ) {
1001 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
1005 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1006 if ( !emcalFolder ) {
1007 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1011 TObject * tss = emcalFolder->FindObject(name) ;
1013 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
1016 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1019 //____________________________________________________________________________
1020 Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
1021 { // ------------AliEMCAL PID -----------------------------
1023 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1026 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1030 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1033 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1034 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1036 emcal = new TTask("EMCAL", "") ;
1040 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1043 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1044 << " already exists" << endl ;
1045 emcal->GetListOfTasks()->Remove(emcalpid) ;
1052 //____________________________________________________________________________
1053 Bool_t AliEMCALGetter::PostPID(const char * name) const
1055 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1057 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1060 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1064 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1067 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1068 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1070 emcal = new TTask("EMCAL", "") ;
1074 TList * l = emcal->GetListOfTasks() ;
1076 TString pidname(name) ;
1079 while((task = static_cast<TTask *>(it.Next()) )){
1080 TString taskname(task->GetName()) ;
1081 if(taskname.BeginsWith(pidname))
1085 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1087 emcalpid->SetName(pidname) ;
1088 emcal->Add(emcalpid) ;
1093 //____________________________________________________________________________
1094 TObject ** AliEMCALGetter::PIDRef(const char * name) const
1095 { //------------PID ------------------------------
1097 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1100 cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1104 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1106 cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
1110 TList * l = emcal->GetListOfTasks() ;
1114 TString pidname(name) ;
1116 while((task = static_cast<TTask *>(it.Next()) )){
1117 TString taskname(task->GetName()) ;
1118 if(taskname.BeginsWith(pidname)){
1125 return l->GetObjectRef(pid) ;
1127 cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
1132 //____________________________________________________________________________
1133 Bool_t AliEMCALGetter::PostQA(void) const
1134 { // ------------------ QA ---------------------------------
1136 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1138 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1139 if ( !emcalFolder ) {
1141 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1142 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1144 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1150 //____________________________________________________________________________
1151 TObject ** AliEMCALGetter::AlarmsRef(void) const
1152 { //------- Alarms ----------------------
1155 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1157 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1161 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1162 if ( !emcalFolder ) {
1163 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1167 return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1170 //____________________________________________________________________________
1171 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1173 // Return primary particle numbered by <index>
1178 Int_t primaryIndex = index % 10000000 ;
1179 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1181 if ( primaryList > 0 ) {
1183 cout << " Getter does not support currently Mixing of primary " << endl ;
1184 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1189 return gAlice->Particle(primaryIndex) ;
1193 //____________________________________________________________________________
1194 void AliEMCALGetter::ReadTreeD()
1196 // Read the digit tree gAlice->TreeD()
1197 if(gAlice->TreeD()== 0){
1198 cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
1202 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1204 TBranch * branch = 0 ;
1205 TBranch * digitsbranch = 0 ;
1206 TBranch * digitizerbranch = 0 ;
1207 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1209 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1210 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1211 digitsbranch = branch ;
1212 emcalfound = kTRUE ;
1214 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1215 digitizerbranch = branch ;
1216 digitizerfound = kTRUE ;
1220 if ( !emcalfound || !digitizerfound ) {
1222 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1223 << fDigitsTitle << endl ;
1228 if(!Digits(fDigitsTitle) )
1229 PostDigits(fDigitsTitle);
1230 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1231 digitsbranch->GetEntry(0) ;
1234 // read the Digitizer
1235 if(!Digitizer(fDigitsTitle))
1236 PostDigitizer(fDigitsTitle) ;
1237 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1238 digitizerbranch->GetEntry(0) ;
1243 //____________________________________________________________________________
1244 void AliEMCALGetter::ReadTreeH()
1246 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1248 if(gAlice->TreeH()== 0){
1249 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1253 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1254 if ( !hitsbranch ) {
1256 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1262 if (hitsbranch->GetEntries() > 1 ) {
1263 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1264 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1265 hitsbranch->SetAddress(&tempo) ;
1268 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1269 hitsbranch->GetEntry(i) ;
1271 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1272 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1273 new((*hits)[index]) AliEMCALHit( *hit ) ;
1280 hitsbranch->SetAddress(HitsRef()) ;
1281 hitsbranch->GetEntry(0) ;
1285 //____________________________________________________________________________
1286 void AliEMCALGetter::Track(Int_t itrack)
1288 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1290 if(gAlice->TreeH()== 0){
1291 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1295 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1296 if ( !hitsbranch ) {
1298 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1303 hitsbranch->SetAddress(HitsRef()) ;
1304 hitsbranch->GetEntry(itrack) ;
1308 //____________________________________________________________________________
1309 // void AliEMCALGetter::ReadTreeQA()
1311 // Read the digit tree gAlice->TreeQA()
1312 // so far only EMCAL knows about this Tree
1314 // if(EMCAL()->TreeQA()== 0){
1315 // cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1319 // TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1322 // cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1329 // qabranch->SetAddress(AlarmsRef()) ;
1331 // qabranch->GetEntry(0) ;
1333 // PostQA("EMCAL") ;
1334 // TFolder * alarmsF = Alarms() ;
1335 // alarmsF->Clear() ;
1336 // qabranch->SetAddress(&alarmsF) ;
1337 // qabranch->GetEntry(0) ;
1341 //____________________________________________________________________________
1342 void AliEMCALGetter::ReadTreeR()
1344 // Read the reconstrunction tree gAlice->TreeR()
1346 if(gAlice->TreeR()== 0){
1347 cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
1352 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1354 TBranch * branch = 0 ;
1355 TBranch * towerbranch = 0 ;
1356 TBranch * preshobranch = 0 ;
1357 TBranch * clusterizerbranch = 0 ;
1358 Bool_t emcaltowerrpfound = kFALSE, emcalpreshorpfound = kFALSE, clusterizerfound = kFALSE ;
1360 while ( (branch = static_cast<TBranch*>(next())) && (!emcaltowerrpfound || !emcalpreshorpfound || !clusterizerfound) )
1361 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1362 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1363 towerbranch = branch ;
1364 emcaltowerrpfound = kTRUE ;
1366 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1367 preshobranch = branch ;
1368 emcalpreshorpfound = kTRUE ;
1370 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1371 clusterizerbranch = branch ;
1372 clusterizerfound = kTRUE ;
1376 if ( !emcaltowerrpfound ) {
1378 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TowerRecPoints with title "
1379 << fRecPointsTitle << endl ;
1382 if ( !emcalpreshorpfound ) {
1384 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find PreShoRecPoints with title "
1385 << fRecPointsTitle << endl ;
1388 if ( !clusterizerfound ) {
1390 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Can not find Clusterizer with title "
1391 << fRecPointsTitle << endl ;
1395 // Read and Post the RecPoints
1396 if(!TowerRecPoints(fRecPointsTitle) )
1397 PostRecPoints(fRecPointsTitle) ;
1398 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1399 towerbranch->GetEntry(0) ;
1401 preshobranch->SetAddress(PreShoRecPointsRef(fRecPointsTitle)) ;
1402 preshobranch->GetEntry(0) ;
1404 if(!Clusterizer(fRecPointsTitle) )
1405 PostClusterizer(fRecPointsTitle) ;
1406 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1407 clusterizerbranch->GetEntry(0) ;
1410 //------------------- TrackSegments ---------------------
1412 // TBranch * tsbranch = 0 ;
1413 // TBranch * tsmakerbranch = 0 ;
1414 // Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1416 // while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) )
1417 // if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1418 // if ( strcmp(branch->GetName(), "EMCALTS")==0){
1419 // tsbranch = branch ;
1420 // emcaltsfound = kTRUE ;
1422 // else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1423 // tsmakerbranch = branch ;
1424 // tsmakerfound = kTRUE ;
1428 // if ( !emcaltsfound || !tsmakerfound ) {
1430 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1431 // << fTrackSegmentsTitle << endl ;
1435 // // Read and Post the TrackSegments
1436 // if(!TrackSegments(fTrackSegmentsTitle))
1437 // PostTrackSegments(fTrackSegmentsTitle) ;
1438 // tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1439 // tsbranch->GetEntry(0) ;
1441 // // Read and Post the TrackSegment Maker
1442 // if(!TrackSegmentMaker(fTrackSegmentsTitle))
1443 // PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1444 // tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1445 // tsmakerbranch->GetEntry(0) ;
1448 // //------------ RecParticles ----------------------------
1450 // TBranch * rpabranch = 0 ;
1451 // TBranch * pidbranch = 0 ;
1452 // Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1454 // while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1455 // if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1456 // if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1457 // rpabranch = branch ;
1458 // emcalrpafound = kTRUE ;
1460 // else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1461 // pidbranch = branch ;
1462 // pidfound = kTRUE ;
1466 // if ( !emcalrpafound || !pidfound ) {
1468 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1469 // << fRecParticlesTitle << endl ;
1473 // // Read and Post the RecParticles
1474 // if(!RecParticles(fRecParticlesTitle))
1475 // PostRecParticles(fRecParticlesTitle) ;
1476 // rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1477 // rpabranch->GetEntry(0) ;
1479 // // Read and Post the PID
1480 // if(!PID(fRecParticlesTitle))
1481 // PostPID(fRecParticlesTitle) ;
1482 // pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1483 // pidbranch->GetEntry(0) ;
1488 //____________________________________________________________________________
1489 void AliEMCALGetter::ReadTreeS(Int_t event)
1491 // Read the summable digits tree gAlice->TreeS()
1493 // loop over all opened files and read their SDigits to the White Board
1494 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1496 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1497 TCollection * folderslist = emcalF->GetListOfFolders() ;
1499 //Add current file to list if it is not there yet
1501 TString subdir(fHeaderFile) ;
1502 subdir.ReplaceAll("/","_") ;
1504 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1505 emcalF->AddFolder(subdir, "");
1508 TIter next(folderslist) ;
1509 TFolder * folder = 0 ;
1512 while ( (folder = static_cast<TFolder*>(next())) ) {
1513 TString fileName(folder->GetName()) ;
1514 fileName.ReplaceAll("_","/") ;
1515 if(fHeaderFile.CompareTo(fileName) == 0 )
1516 treeS=gAlice->TreeS() ;
1518 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1521 // Get SDigits Tree header from file
1522 TString treeName("TreeS") ;
1524 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1527 cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
1531 //set address of the SDigits and SDigitizer
1532 TBranch * sdigitsBranch = 0;
1533 TBranch * sdigitizerBranch = 0;
1534 TBranch * branch = 0 ;
1535 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1537 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1539 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1540 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1541 emcalfound = kTRUE ;
1542 sdigitsBranch = branch ;
1545 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1546 sdigitizerfound = kTRUE ;
1547 sdigitizerBranch = branch ;
1550 if ( !emcalfound || !sdigitizerfound ) {
1552 cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
1553 << " not found" << endl ;
1557 if ( !folder->FindObject(fSDigitsTitle) )
1558 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1559 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1560 sdigitsBranch->GetEntry(0) ;
1562 TString sdname(fSDigitsTitle) ;
1564 sdname+=folder->GetName() ;
1565 if(!SDigitizer(sdname) )
1566 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1567 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1568 sdigitizerBranch->GetEntry(0) ;
1572 // After SDigits have been read from all files, return to the first one
1575 folder = static_cast<TFolder*>(next());
1577 TString fileName(folder->GetName()) ;
1578 fileName.ReplaceAll("_","/") ;
1579 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1584 //____________________________________________________________________________
1585 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1586 { // Read the summable digits fron treeS()
1589 TString filename("mergefile") ;
1592 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1593 if ( !emcalFolder ) {
1594 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1596 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1597 //set address of the SDigits and SDigitizer
1598 TBranch * sdigitsBranch = 0;
1599 TBranch * sdigitizerBranch = 0;
1600 TBranch * branch = 0 ;
1601 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1603 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1605 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1606 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1607 emcalfound = kTRUE ;
1608 sdigitsBranch = branch ;
1611 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1612 sdigitizerfound = kTRUE ;
1613 sdigitizerBranch = branch ;
1616 if ( !emcalfound || !sdigitizerfound ) {
1618 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1622 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1623 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1625 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1626 sdigitsBranch->GetEntry(0) ;
1628 TString sdname(sdigitsBranch->GetTitle()) ;
1631 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1632 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1634 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1635 sdigitizerBranch->GetEntry(0) ;
1640 //____________________________________________________________________________
1641 void AliEMCALGetter::ReadPrimaries()
1643 // Reads specific branches of primaries
1645 fNPrimaries = gAlice->GetNtrack();
1647 // //Check, is it necessary to open new files
1648 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1649 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1651 // for(input = 0; input < filenames->GetEntriesFast(); input++){
1653 // TObjString * filename = (TObjString *) filenames->At(input) ;
1655 // //Test, if this file already open
1656 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1658 // file = new TFile( filename->GetString()) ;
1661 // // Get Kine Tree from file
1662 // // char treeName[20];
1663 // // sprintf(treeName,"TreeK%d",events->At(input));
1664 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1666 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1668 // // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1670 // // // Create the particle stack
1671 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1672 // // // Build the pointer list
1673 // // if(fParticleMap) { <----
1674 // // fParticleMap->Clear();
1675 // // fParticleMap->Expand(treeK->GetEntries());
1677 // // fParticleMap = new TObjArray(treeK->GetEntries());
1679 // // From gAlice->Particle(i)
1682 // // if(!(*fParticleMap)[i]) {
1683 // // Int_t nentries = fParticles->GetEntries();
1685 // // // algorithmic way of getting entry index
1686 // // // (primary particles are filled after secondaries)
1688 // // if (i<fHeader.GetNprimary())
1689 // // entry = i+fHeader.GetNsecondary();
1691 // // entry = i-fHeader.GetNprimary();
1693 // // // only check the algorithmic way and give
1694 // // // the fatal error if it is wrong
1695 // // if (entry != fParticleFileMap[i]) {
1696 // // Fatal("Particle",
1697 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1698 // // entry, fParticleFileMap[i]);
1701 // // fTreeK->GetEntry(fParticleFileMap[i]);
1702 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1703 // // fParticleMap->AddAt((*fParticles)[nentries],i);
1705 // // return (TParticle *) (*fParticleMap)[i];
1712 // //scan over opened files and read corresponding TreeK##
1716 //____________________________________________________________________________
1717 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1719 // Reads the content of all Tree's S, D and R
1721 if (event >= gAlice->TreeE()->GetEntries() ) {
1722 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
1725 gAlice->GetEvent(event) ;
1727 if(strstr(opt,"H") )
1730 if(strstr(opt,"S") )
1733 if( strstr(opt,"D") )
1736 if( strstr(opt,"R") )
1739 // if( strstr(opt,"Q") )
1742 // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1743 // ReadPrimaries() ;
1747 //____________________________________________________________________________
1748 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1750 // get the object named "what" from the folder
1751 // folders are named like //Folders
1753 if ( file.IsNull() )
1754 file = fHeaderFile ;
1756 TFolder * folder = 0 ;
1757 TObject * emcalO = 0 ;
1759 // if ( name.IsNull() ) {
1760 if ( what.CompareTo("Hits") == 0 ) {
1761 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1763 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1765 else if ( what.CompareTo("SDigits") == 0 ) {
1766 file.ReplaceAll("/","_") ;
1767 TString path = "EMCAL/" + file ;
1768 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1771 name = fSDigitsTitle ;
1772 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1775 else if ( what.CompareTo("Digits") == 0 ){
1776 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1779 name = fDigitsTitle ;
1780 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1783 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1784 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1787 name = fRecPointsTitle ;
1788 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1791 else if ( what.CompareTo("PreShoRecPoints") == 0 ) {
1792 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
1795 name = fRecPointsTitle ;
1796 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1800 else if ( what.CompareTo("TrackSegments") == 0 ) {
1801 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1804 name = fTrackSegmentsTitle ;
1805 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1808 else if ( what.CompareTo("RecParticles") == 0 ) {
1809 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1812 name = fRecParticlesTitle ;
1813 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1816 else if ( what.CompareTo("Alarms") == 0 ){
1818 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
1820 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1824 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1830 cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
1836 //____________________________________________________________________________
1837 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1839 // get the TTask named "what" from the folder
1840 // folders are named like //Folders/Tasks/what/EMCAL/name
1842 TString search(what) ;
1843 if ( what.CompareTo("Clusterizer") == 0 )
1844 search = "Reconstructioner" ;
1845 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1846 search = "Reconstructioner" ;
1847 else if ( what.CompareTo("PID") == 0 )
1848 search = "Reconstructioner" ;
1849 else if ( what.CompareTo("QATasks") == 0 )
1852 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1855 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
1859 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1861 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
1865 TList * list = emcalT->GetListOfTasks() ;
1867 if (what.CompareTo("SDigitizer") == 0) {
1868 if ( name.IsNull() )
1869 name = fSDigitsTitle ;
1870 } else if (what.CompareTo("Digitizer") == 0){
1871 if ( name.IsNull() )
1872 name = fDigitsTitle ;
1873 } else if (what.CompareTo("Clusterizer") == 0){
1874 if ( name.IsNull() )
1875 name = fRecPointsTitle ;
1876 name.Append(":clu") ;
1878 // else if (what.CompareTo("TrackSegmentMaker") == 0){
1879 // if ( name.IsNull() )
1880 // name = fTrackSegmentsTitle ;
1881 // name.Append(":tsm") ;
1883 // else if (what.CompareTo("PID") == 0){
1884 // if ( name.IsNull() )
1885 // name = fRecParticlesTitle ;
1886 // name.Append(":pid") ;
1888 // else if (what.CompareTo("QATasks") == 0){
1889 // if ( name.IsNull() )
1895 while((task = static_cast<TTask *>(it.Next()) )){
1896 TString taskname(task->GetName()) ;
1897 if(taskname.BeginsWith(name)){
1902 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;