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 fFile = TFile::Open(fHeaderFile.Data(),rw) ;
116 if (!fFile->IsOpen()) {
117 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot open " << fHeaderFile.Data() << endl ;
122 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
127 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
133 cout << "INFO: AliEMCALGetter -> Posting EMCAL to Folders" << endl ;
134 if (gAlice->GetDetector("EMCAL")) {
135 AliConfig * conf = AliConfig::Instance() ;
136 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
137 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
140 cerr << "ERROR: AliEMCALGetter -> detector EMCAL not found" << endl ;
145 //____________________________________________________________________________
146 AliEMCALGetter::~AliEMCALGetter()
149 fPrimaries->Delete() ;
153 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
154 TCollection * folderslist = emcalF->GetListOfFolders() ;
155 TIter next(folderslist) ;
156 TFolder * folder = 0 ;
157 while ( (folder = static_cast<TFolder*>(next())) )
158 emcalF->Remove(folder) ;
165 //____________________________________________________________________________
166 void AliEMCALGetter::CreateWhiteBoard() const
171 //____________________________________________________________________________
172 AliEMCALGetter * AliEMCALGetter::GetInstance()
174 // Returns the pointer of the unique instance already defined
176 AliEMCALGetter * rv = 0 ;
180 cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
185 //____________________________________________________________________________
186 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
187 const char* branchTitle, const Option_t * rw)
189 // Creates and returns the pointer of the unique instance
190 // Must be called only when the environment has changed
193 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0) &&
194 (fgObjGetter->fHeaderFile.CompareTo(headerFile)==0)) {
199 fgObjGetter->~AliEMCALGetter() ; // delete it already exists another version
201 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle, rw) ;
203 if (fgObjGetter->HasFailed() )
206 // Posts a few item to the white board (folders)
207 // fgObjGetter->CreateWhiteBoard() ;
213 //____________________________________________________________________________
214 const AliEMCALv1 * AliEMCALGetter::EMCAL()
216 // returns the EMCAL object
217 AliEMCALv1 * emcal = dynamic_cast<AliEMCALv1*>(fModuleFolder->FindObject("EMCAL")) ;
220 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
224 //____________________________________________________________________________
225 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
227 AliEMCALGeometry * rv = 0 ;
229 rv = EMCAL()->GetGeometry() ;
233 //____________________________________________________________________________
234 Bool_t AliEMCALGetter::PostHits(void) const
235 { //------- Hits ----------------------
237 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
239 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
240 if ( !emcalFolder ) {
242 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
243 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
245 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
247 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
248 hits->SetName("Hits") ;
249 emcalFolder->Add(hits) ;
254 //____________________________________________________________________________
255 TObject ** AliEMCALGetter::HitsRef(void) const
256 { //------- Hits ----------------------
259 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
260 if ( !fHitsFolder ) {
261 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
265 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
266 if ( !emcalFolder ) {
267 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
271 TObject * h = emcalFolder->FindObject("Hits") ;
273 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
277 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
280 //____________________________________________________________________________
281 Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
282 { //---------- SDigits -------------------------
285 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
286 // because you can have sdigits from several hit files for mixing
288 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
289 if ( !emcalFolder ) {
291 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
292 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
294 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
296 TString subdir(headerFile) ;
297 subdir.ReplaceAll("/", "_") ;
298 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
299 if ( !emcalSubFolder )
300 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
302 TObject * sd = emcalSubFolder->FindObject(name);
305 cerr <<"INFO: AliEMCALGetter::Post S -> Folder " << subdir
306 << " already exists!" << endl ;
308 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
309 sdigits->SetName(name) ;
310 emcalSubFolder->Add(sdigits) ;
315 //____________________________________________________________________________
316 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
317 { //------- SDigits ----------------------
319 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
321 if ( !fSDigitsFolder ) {
322 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
326 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
327 if ( !emcalFolder ) {
328 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
332 TFolder * emcalSubFolder = 0 ;
334 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
336 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
338 if(!emcalSubFolder) {
339 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
343 TObject * dis = emcalSubFolder->FindObject(name) ;
347 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
351 //____________________________________________________________________________
352 Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
353 { //---------- SDigitizer -------------------------
355 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
358 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
361 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
364 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
367 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
368 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
370 emcal = new TTask("EMCAL", "") ;
373 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
376 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
377 emcal->GetListOfTasks()->Remove(emcalsd) ;
379 emcal->Add(sdigitizer) ;
384 //____________________________________________________________________________
385 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
388 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
390 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
394 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
396 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
400 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
402 return emcal->GetListOfTasks()->GetObjectRef(task) ;
406 //____________________________________________________________________________
407 Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
408 { //---------- SDigitizer -------------------------
410 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
413 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
415 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
419 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
422 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
423 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
425 emcal = new TTask("EMCAL", "") ;
429 TString sdname(name) ;
432 sdname.ReplaceAll("/","_") ;
433 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
435 emcalsd = new AliEMCALSDigitizer() ;
436 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
437 emcalsd->SetName(sdname) ;
438 emcalsd->SetTitle(file) ;
439 emcal->Add(emcalsd) ;
445 //____________________________________________________________________________
446 Bool_t AliEMCALGetter::PostDigits(const char * name) const
447 { //---------- Digits -------------------------
449 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
451 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
453 if ( !emcalFolder ) {
455 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
456 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
458 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
461 TObject* dig = emcalFolder->FindObject( name ) ;
463 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
464 digits->SetName(name) ;
465 emcalFolder->Add(digits) ;
470 //____________________________________________________________________________
471 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
472 { //------- Digits ----------------------
474 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
476 if ( !fDigitsFolder ) {
477 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
481 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
482 if ( !emcalFolder ) {
483 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
487 TObject * d = emcalFolder->FindObject(name) ;
491 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
495 //____________________________________________________________________________
496 Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
497 { //---------- Digitizer -------------------------
499 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
502 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
505 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
508 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
509 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
511 emcal = new TTask("EMCAL", "") ;
515 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
518 emcal->GetListOfTasks()->Remove(emcald) ;
520 emcal->Add(digitizer) ;
524 //____________________________________________________________________________
525 Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
526 { //---------- Digitizer -------------------------
528 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
530 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
532 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
536 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
539 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
540 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
542 emcal = new TTask("EMCAL", "") ;
546 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
548 emcald = new AliEMCALDigitizer() ;
549 emcald->SetName(fDigitsTitle) ;
550 emcald->SetTitle(fHeaderFile) ;
556 //____________________________________________________________________________
557 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
559 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
561 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
565 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
567 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
571 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
573 return emcal->GetListOfTasks()->GetObjectRef(task) ;
577 //____________________________________________________________________________
578 Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
579 { // -------------- RecPoints -------------------------------------------
581 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
582 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
584 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
586 if ( !emcalFolder ) {
588 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
589 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
591 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
595 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
596 if ( !emcalRPoTowerFolder ) {
598 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
599 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
601 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
604 TObject * erp = emcalFolder->FindObject( name ) ;
606 TObjArray * towerrp = new TObjArray(100) ;
607 towerrp->SetName(name) ;
608 emcalRPoTowerFolder->Add(towerrp) ;
611 // Pre Shower RecPoints
612 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShoRecPoints")) ;
613 if ( !emcalRPoPreShoFolder ) {
615 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/ not found!" << endl;
616 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
618 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShoRecPoints", "PreSho RecPoints from EMCAL") ;
621 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
623 TObjArray * preshorp = new TObjArray(100) ;
624 preshorp->SetName(name) ;
625 emcalRPoPreShoFolder->Add(preshorp) ;
630 //____________________________________________________________________________
631 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
632 { // -------------- RecPoints -------------------------------------------
634 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
636 if ( !fRecoFolder ) {
637 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
641 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
642 if ( !towerFolder ) {
643 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
648 TObject * trp = towerFolder->FindObject(name ) ;
650 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
653 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
657 //____________________________________________________________________________
658 TObject ** AliEMCALGetter::PreShoRecPointsRef(const char * name) const
659 { // -------------- RecPoints -------------------------------------------
661 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
663 if ( !fRecoFolder ) {
664 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
668 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
669 if ( !preshoFolder ) {
670 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
674 TObject * prp = preshoFolder->FindObject(name ) ;
676 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Object " << name << " not found! " << endl ;
679 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
683 //____________________________________________________________________________
684 Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizerv1 * clu) const
685 { // ------------------ AliEMCALClusterizer ------------------------
687 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
689 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
692 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
696 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
699 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
700 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
702 emcal = new TTask("EMCAL", "") ;
706 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
709 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
711 emcal->GetListOfTasks()->Remove(emcalcl) ;
717 //____________________________________________________________________________
718 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
719 { // ------------------ AliEMCALClusterizer ------------------------
721 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
724 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
728 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
730 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
734 TList * l = emcal->GetListOfTasks() ;
738 TString cluname(name) ;
740 while((task = static_cast<TTask *>(it.Next()) )){
741 TString taskname(task->GetName()) ;
742 if(taskname.BeginsWith(cluname)){
749 return l->GetObjectRef(clu) ;
751 cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
756 //____________________________________________________________________________
757 Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
758 { // ------------------ AliEMCALClusterizer ------------------------
760 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
762 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
765 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
769 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
772 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
773 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
775 emcal = new TTask("EMCAL", "") ;
779 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
782 emcalcl->SetName(clun) ;
783 emcal->Add(emcalcl) ;
788 //____________________________________________________________________________
789 /*Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
790 { // ---------------TrackSegments -----------------------------------
792 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
794 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
796 if ( !emcalFolder ) {
798 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
799 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
801 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
804 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
805 if ( !emcalTSFolder ) {
807 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
808 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
810 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
813 TObject * tss = emcalTSFolder->FindObject( name ) ;
815 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
817 emcalTSFolder->Add(ts) ;
822 //____________________________________________________________________________
823 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
824 { // ---------------TrackSegments -----------------------------------
826 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
828 if ( !fRecoFolder ) {
829 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
833 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
834 if ( !emcalFolder ) {
835 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
839 TObject * tss = emcalFolder->FindObject(name) ;
841 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
844 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
847 //____________________________________________________________________________
848 Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
849 { //------------Track Segment Maker ------------------------------
851 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
853 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
856 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
860 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
863 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
864 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
866 emcal = new TTask("EMCAL", "") ;
870 AliEMCALTrackSegmentMaker * emcalts =
871 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
874 emcal->GetListOfTasks()->Remove(emcalts) ;
876 emcal->Add(tsmaker) ;
880 //____________________________________________________________________________
881 Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
882 { //------------Track Segment Maker ------------------------------
884 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
887 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
890 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
894 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
897 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
898 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
900 emcal = new TTask("EMCAL", "") ;
904 AliEMCALTrackSegmentMaker * emcalts =
905 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(name)) ;
907 emcalts = new AliEMCALTrackSegmentMakerv1() ;
910 emcalts->SetName(tsn) ;
911 emcal->Add(emcalts) ;
917 //____________________________________________________________________________
918 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
919 { //------------Track Segment Maker ------------------------------
921 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
924 cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
928 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
930 cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
934 TList * l = emcal->GetListOfTasks() ;
938 TString tsmname(name) ;
940 while((task = static_cast<TTask *>(it.Next()) )){
941 TString taskname(task->GetName()) ;
942 if(taskname.BeginsWith(tsmname)){
949 return l->GetObjectRef(tsm) ;
951 cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
956 //____________________________________________________________________________
957 Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
958 { // -------------------- RecParticles ------------------------
960 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
962 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
964 if ( !emcalFolder ) {
966 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
967 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
969 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
972 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
973 if ( !emcalRPaFolder ) {
975 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
976 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
978 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
981 TObject * rps = emcalRPaFolder->FindObject( name ) ;
983 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
985 emcalRPaFolder->Add(rp) ;
990 //____________________________________________________________________________
991 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
992 { // ---------------TrackSegments -----------------------------------
994 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
996 if ( !fRecoFolder ) {
997 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
1001 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1002 if ( !emcalFolder ) {
1003 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1007 TObject * tss = emcalFolder->FindObject(name) ;
1009 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
1012 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1015 //____________________________________________________________________________
1016 Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
1017 { // ------------AliEMCAL PID -----------------------------
1019 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1022 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1026 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1029 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1030 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1032 emcal = new TTask("EMCAL", "") ;
1036 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1039 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1040 << " already exists" << endl ;
1041 emcal->GetListOfTasks()->Remove(emcalpid) ;
1048 //____________________________________________________________________________
1049 Bool_t AliEMCALGetter::PostPID(const char * name) const
1051 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1053 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1056 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1060 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1063 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1064 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1066 emcal = new TTask("EMCAL", "") ;
1070 TList * l = emcal->GetListOfTasks() ;
1072 TString pidname(name) ;
1075 while((task = static_cast<TTask *>(it.Next()) )){
1076 TString taskname(task->GetName()) ;
1077 if(taskname.BeginsWith(pidname))
1081 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1083 emcalpid->SetName(pidname) ;
1084 emcal->Add(emcalpid) ;
1089 //____________________________________________________________________________
1090 TObject ** AliEMCALGetter::PIDRef(const char * name) const
1091 { //------------PID ------------------------------
1093 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1096 cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1100 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1102 cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
1106 TList * l = emcal->GetListOfTasks() ;
1110 TString pidname(name) ;
1112 while((task = static_cast<TTask *>(it.Next()) )){
1113 TString taskname(task->GetName()) ;
1114 if(taskname.BeginsWith(pidname)){
1121 return l->GetObjectRef(pid) ;
1123 cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
1128 //____________________________________________________________________________
1129 Bool_t AliEMCALGetter::PostQA(void) const
1130 { // ------------------ QA ---------------------------------
1132 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1134 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1135 if ( !emcalFolder ) {
1137 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1138 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1140 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1146 //____________________________________________________________________________
1147 TObject ** AliEMCALGetter::AlarmsRef(void) const
1148 { //------- Alarms ----------------------
1151 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1153 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1157 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1158 if ( !emcalFolder ) {
1159 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1163 return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1166 //____________________________________________________________________________
1167 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1169 // Return primary particle numbered by <index>
1174 Int_t primaryIndex = index % 10000000 ;
1175 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1177 if ( primaryList > 0 ) {
1179 cout << " Getter does not support currently Mixing of primary " << endl ;
1180 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1185 return gAlice->Particle(primaryIndex) ;
1189 //____________________________________________________________________________
1190 void AliEMCALGetter::ReadTreeD()
1192 // Read the digit tree gAlice->TreeD()
1193 if(gAlice->TreeD()== 0){
1194 cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
1198 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1200 TBranch * branch = 0 ;
1201 TBranch * digitsbranch = 0 ;
1202 TBranch * digitizerbranch = 0 ;
1203 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1205 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1206 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1207 digitsbranch = branch ;
1208 emcalfound = kTRUE ;
1210 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1211 digitizerbranch = branch ;
1212 digitizerfound = kTRUE ;
1216 if ( !emcalfound || !digitizerfound ) {
1218 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1219 << fDigitsTitle << endl ;
1224 if(!Digits(fDigitsTitle) )
1225 PostDigits(fDigitsTitle);
1226 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1227 digitsbranch->GetEntry(0) ;
1230 // read the Digitizer
1231 if(!Digitizer(fDigitsTitle))
1232 PostDigitizer(fDigitsTitle) ;
1233 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1234 digitizerbranch->GetEntry(0) ;
1239 //____________________________________________________________________________
1240 void AliEMCALGetter::ReadTreeH()
1242 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1244 if(gAlice->TreeH()== 0){
1245 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1249 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1250 if ( !hitsbranch ) {
1252 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1258 if (hitsbranch->GetEntries() > 1 ) {
1259 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1260 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1261 hitsbranch->SetAddress(&tempo) ;
1264 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1265 hitsbranch->GetEntry(i) ;
1267 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1268 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1269 new((*hits)[index]) AliEMCALHit( *hit ) ;
1276 hitsbranch->SetAddress(HitsRef()) ;
1277 hitsbranch->GetEntry(0) ;
1281 //____________________________________________________________________________
1282 void AliEMCALGetter::Track(Int_t itrack)
1284 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1286 if(gAlice->TreeH()== 0){
1287 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1291 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1292 if ( !hitsbranch ) {
1294 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1299 hitsbranch->SetAddress(HitsRef()) ;
1300 hitsbranch->GetEntry(itrack) ;
1304 //____________________________________________________________________________
1305 // void AliEMCALGetter::ReadTreeQA()
1307 // Read the digit tree gAlice->TreeQA()
1308 // so far only EMCAL knows about this Tree
1310 // if(EMCAL()->TreeQA()== 0){
1311 // cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1315 // TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1318 // cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1325 // qabranch->SetAddress(AlarmsRef()) ;
1327 // qabranch->GetEntry(0) ;
1329 // PostQA("EMCAL") ;
1330 // TFolder * alarmsF = Alarms() ;
1331 // alarmsF->Clear() ;
1332 // qabranch->SetAddress(&alarmsF) ;
1333 // qabranch->GetEntry(0) ;
1337 //____________________________________________________________________________
1338 void AliEMCALGetter::ReadTreeR()
1340 // Read the reconstrunction tree gAlice->TreeR()
1342 if(gAlice->TreeR()== 0){
1343 cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
1348 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1350 TBranch * branch = 0 ;
1351 TBranch * towerbranch = 0 ;
1352 TBranch * preshobranch = 0 ;
1353 TBranch * clusterizerbranch = 0 ;
1354 Bool_t emcaltowerrpfound = kFALSE, emcalpreshorpfound = kFALSE, clusterizerfound = kFALSE ;
1356 while ( (branch = static_cast<TBranch*>(next())) && (!emcaltowerrpfound || !emcalpreshorpfound || !clusterizerfound) )
1357 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1358 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1359 towerbranch = branch ;
1360 emcaltowerrpfound = kTRUE ;
1362 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1363 preshobranch = branch ;
1364 emcalpreshorpfound = kTRUE ;
1366 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1367 clusterizerbranch = branch ;
1368 clusterizerfound = kTRUE ;
1372 if ( !emcaltowerrpfound ) {
1374 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TowerRecPoints with title "
1375 << fRecPointsTitle << endl ;
1378 if ( !emcalpreshorpfound ) {
1380 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find PreShoRecPoints with title "
1381 << fRecPointsTitle << endl ;
1384 if ( !clusterizerfound ) {
1386 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Can not find Clusterizer with title "
1387 << fRecPointsTitle << endl ;
1391 // Read and Post the RecPoints
1392 if(!TowerRecPoints(fRecPointsTitle) )
1393 PostRecPoints(fRecPointsTitle) ;
1394 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1395 towerbranch->GetEntry(0) ;
1397 preshobranch->SetAddress(PreShoRecPointsRef(fRecPointsTitle)) ;
1398 preshobranch->GetEntry(0) ;
1400 if(!Clusterizer(fRecPointsTitle) )
1401 PostClusterizer(fRecPointsTitle) ;
1402 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1403 clusterizerbranch->GetEntry(0) ;
1406 //------------------- TrackSegments ---------------------
1408 // TBranch * tsbranch = 0 ;
1409 // TBranch * tsmakerbranch = 0 ;
1410 // Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1412 // while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) )
1413 // if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1414 // if ( strcmp(branch->GetName(), "EMCALTS")==0){
1415 // tsbranch = branch ;
1416 // emcaltsfound = kTRUE ;
1418 // else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1419 // tsmakerbranch = branch ;
1420 // tsmakerfound = kTRUE ;
1424 // if ( !emcaltsfound || !tsmakerfound ) {
1426 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1427 // << fTrackSegmentsTitle << endl ;
1431 // // Read and Post the TrackSegments
1432 // if(!TrackSegments(fTrackSegmentsTitle))
1433 // PostTrackSegments(fTrackSegmentsTitle) ;
1434 // tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1435 // tsbranch->GetEntry(0) ;
1437 // // Read and Post the TrackSegment Maker
1438 // if(!TrackSegmentMaker(fTrackSegmentsTitle))
1439 // PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1440 // tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1441 // tsmakerbranch->GetEntry(0) ;
1444 // //------------ RecParticles ----------------------------
1446 // TBranch * rpabranch = 0 ;
1447 // TBranch * pidbranch = 0 ;
1448 // Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1450 // while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1451 // if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1452 // if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1453 // rpabranch = branch ;
1454 // emcalrpafound = kTRUE ;
1456 // else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1457 // pidbranch = branch ;
1458 // pidfound = kTRUE ;
1462 // if ( !emcalrpafound || !pidfound ) {
1464 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1465 // << fRecParticlesTitle << endl ;
1469 // // Read and Post the RecParticles
1470 // if(!RecParticles(fRecParticlesTitle))
1471 // PostRecParticles(fRecParticlesTitle) ;
1472 // rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1473 // rpabranch->GetEntry(0) ;
1475 // // Read and Post the PID
1476 // if(!PID(fRecParticlesTitle))
1477 // PostPID(fRecParticlesTitle) ;
1478 // pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1479 // pidbranch->GetEntry(0) ;
1484 //____________________________________________________________________________
1485 void AliEMCALGetter::ReadTreeS(Int_t event)
1487 // Read the summable digits tree gAlice->TreeS()
1489 // loop over all opened files and read their SDigits to the White Board
1490 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1492 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1493 TCollection * folderslist = emcalF->GetListOfFolders() ;
1495 //Add current file to list if it is not there yet
1497 TString subdir(fHeaderFile) ;
1498 subdir.ReplaceAll("/","_") ;
1500 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1501 emcalF->AddFolder(subdir, "");
1504 TIter next(folderslist) ;
1505 TFolder * folder = 0 ;
1508 while ( (folder = static_cast<TFolder*>(next())) ) {
1509 TString fileName(folder->GetName()) ;
1510 fileName.ReplaceAll("_","/") ;
1511 if(fHeaderFile.CompareTo(fileName) == 0 )
1512 treeS=gAlice->TreeS() ;
1514 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1517 // Get SDigits Tree header from file
1518 TString treeName("TreeS") ;
1520 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1523 cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
1527 //set address of the SDigits and SDigitizer
1528 TBranch * sdigitsBranch = 0;
1529 TBranch * sdigitizerBranch = 0;
1530 TBranch * branch = 0 ;
1531 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1533 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1535 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1536 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1537 emcalfound = kTRUE ;
1538 sdigitsBranch = branch ;
1541 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1542 sdigitizerfound = kTRUE ;
1543 sdigitizerBranch = branch ;
1546 if ( !emcalfound || !sdigitizerfound ) {
1548 cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
1549 << " not found" << endl ;
1553 if ( !folder->FindObject(fSDigitsTitle) )
1554 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1555 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1556 sdigitsBranch->GetEntry(0) ;
1558 TString sdname(fSDigitsTitle) ;
1560 sdname+=folder->GetName() ;
1561 if(!SDigitizer(sdname) )
1562 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1563 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1564 sdigitizerBranch->GetEntry(0) ;
1568 // After SDigits have been read from all files, return to the first one
1571 folder = static_cast<TFolder*>(next());
1573 TString fileName(folder->GetName()) ;
1574 fileName.ReplaceAll("_","/") ;
1575 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1580 //____________________________________________________________________________
1581 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1582 { // Read the summable digits fron treeS()
1585 TString filename("mergefile") ;
1588 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1589 if ( !emcalFolder ) {
1590 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1592 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1593 //set address of the SDigits and SDigitizer
1594 TBranch * sdigitsBranch = 0;
1595 TBranch * sdigitizerBranch = 0;
1596 TBranch * branch = 0 ;
1597 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1599 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1601 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1602 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1603 emcalfound = kTRUE ;
1604 sdigitsBranch = branch ;
1607 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1608 sdigitizerfound = kTRUE ;
1609 sdigitizerBranch = branch ;
1612 if ( !emcalfound || !sdigitizerfound ) {
1614 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1618 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1619 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1621 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1622 sdigitsBranch->GetEntry(0) ;
1624 TString sdname(sdigitsBranch->GetTitle()) ;
1627 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1628 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1630 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1631 sdigitizerBranch->GetEntry(0) ;
1636 //____________________________________________________________________________
1637 void AliEMCALGetter::ReadPrimaries()
1639 // Reads specific branches of primaries
1641 fNPrimaries = gAlice->GetNtrack();
1643 // //Check, is it necessary to open new files
1644 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1645 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1647 // for(input = 0; input < filenames->GetEntriesFast(); input++){
1649 // TObjString * filename = (TObjString *) filenames->At(input) ;
1651 // //Test, if this file already open
1652 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1654 // file = new TFile( filename->GetString()) ;
1657 // // Get Kine Tree from file
1658 // // char treeName[20];
1659 // // sprintf(treeName,"TreeK%d",events->At(input));
1660 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1662 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1664 // // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1666 // // // Create the particle stack
1667 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1668 // // // Build the pointer list
1669 // // if(fParticleMap) { <----
1670 // // fParticleMap->Clear();
1671 // // fParticleMap->Expand(treeK->GetEntries());
1673 // // fParticleMap = new TObjArray(treeK->GetEntries());
1675 // // From gAlice->Particle(i)
1678 // // if(!(*fParticleMap)[i]) {
1679 // // Int_t nentries = fParticles->GetEntries();
1681 // // // algorithmic way of getting entry index
1682 // // // (primary particles are filled after secondaries)
1684 // // if (i<fHeader.GetNprimary())
1685 // // entry = i+fHeader.GetNsecondary();
1687 // // entry = i-fHeader.GetNprimary();
1689 // // // only check the algorithmic way and give
1690 // // // the fatal error if it is wrong
1691 // // if (entry != fParticleFileMap[i]) {
1692 // // Fatal("Particle",
1693 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1694 // // entry, fParticleFileMap[i]);
1697 // // fTreeK->GetEntry(fParticleFileMap[i]);
1698 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1699 // // fParticleMap->AddAt((*fParticles)[nentries],i);
1701 // // return (TParticle *) (*fParticleMap)[i];
1708 // //scan over opened files and read corresponding TreeK##
1712 //____________________________________________________________________________
1713 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1715 // Reads the content of all Tree's S, D and R
1717 if (event >= gAlice->TreeE()->GetEntries() ) {
1718 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
1721 gAlice->GetEvent(event) ;
1723 if(strstr(opt,"H") )
1726 if(strstr(opt,"S") )
1729 if( strstr(opt,"D") )
1732 if( strstr(opt,"R") )
1735 // if( strstr(opt,"Q") )
1738 // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1739 // ReadPrimaries() ;
1743 //____________________________________________________________________________
1744 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1746 // get the object named "what" from the folder
1747 // folders are named like //Folders
1749 if ( file.IsNull() )
1750 file = fHeaderFile ;
1752 TFolder * folder = 0 ;
1753 TObject * emcalO = 0 ;
1755 // if ( name.IsNull() ) {
1756 if ( what.CompareTo("Hits") == 0 ) {
1757 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1759 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1761 else if ( what.CompareTo("SDigits") == 0 ) {
1762 file.ReplaceAll("/","_") ;
1763 TString path = "EMCAL/" + file ;
1764 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1767 name = fSDigitsTitle ;
1768 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1771 else if ( what.CompareTo("Digits") == 0 ){
1772 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1775 name = fDigitsTitle ;
1776 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1779 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1780 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1783 name = fRecPointsTitle ;
1784 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1787 else if ( what.CompareTo("PreShoRecPoints") == 0 ) {
1788 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
1791 name = fRecPointsTitle ;
1792 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1796 else if ( what.CompareTo("TrackSegments") == 0 ) {
1797 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1800 name = fTrackSegmentsTitle ;
1801 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1804 else if ( what.CompareTo("RecParticles") == 0 ) {
1805 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1808 name = fRecParticlesTitle ;
1809 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1812 else if ( what.CompareTo("Alarms") == 0 ){
1814 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
1816 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1820 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1826 cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
1832 //____________________________________________________________________________
1833 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1835 // get the TTask named "what" from the folder
1836 // folders are named like //Folders/Tasks/what/EMCAL/name
1838 TString search(what) ;
1839 if ( what.CompareTo("Clusterizer") == 0 )
1840 search = "Reconstructioner" ;
1841 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1842 search = "Reconstructioner" ;
1843 else if ( what.CompareTo("PID") == 0 )
1844 search = "Reconstructioner" ;
1845 else if ( what.CompareTo("QATasks") == 0 )
1848 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1851 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
1855 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1857 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
1861 TList * list = emcalT->GetListOfTasks() ;
1863 if (what.CompareTo("SDigitizer") == 0) {
1864 if ( name.IsNull() )
1865 name = fSDigitsTitle ;
1866 } else if (what.CompareTo("Digitizer") == 0){
1867 if ( name.IsNull() )
1868 name = fDigitsTitle ;
1869 } else if (what.CompareTo("Clusterizer") == 0){
1870 if ( name.IsNull() )
1871 name = fRecPointsTitle ;
1872 name.Append(":clu") ;
1874 // else if (what.CompareTo("TrackSegmentMaker") == 0){
1875 // if ( name.IsNull() )
1876 // name = fTrackSegmentsTitle ;
1877 // name.Append(":tsm") ;
1879 // else if (what.CompareTo("PID") == 0){
1880 // if ( name.IsNull() )
1881 // name = fRecParticlesTitle ;
1882 // name.Append(":pid") ;
1884 // else if (what.CompareTo("QATasks") == 0){
1885 // if ( name.IsNull() )
1891 while((task = static_cast<TTask *>(it.Next()) )){
1892 TString taskname(task->GetName()) ;
1893 if(taskname.BeginsWith(name)){
1898 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;