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() ;
218 //____________________________________________________________________________
219 const AliEMCALv1 * AliEMCALGetter::EMCAL()
221 // returns the EMCAL object
222 AliEMCALv1 * emcal = dynamic_cast<AliEMCALv1*>(fModuleFolder->FindObject("EMCAL")) ;
225 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
229 //____________________________________________________________________________
230 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
232 AliEMCALGeometry * rv = 0 ;
234 rv = EMCAL()->GetGeometry() ;
238 //____________________________________________________________________________
239 Bool_t AliEMCALGetter::PostHits(void) const
240 { //------- Hits ----------------------
242 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
244 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
245 if ( !emcalFolder ) {
247 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
248 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
250 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
252 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
253 hits->SetName("Hits") ;
254 emcalFolder->Add(hits) ;
259 //____________________________________________________________________________
260 TObject ** AliEMCALGetter::HitsRef(void) const
261 { //------- Hits ----------------------
264 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
265 if ( !fHitsFolder ) {
266 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
270 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
271 if ( !emcalFolder ) {
272 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
276 TObject * h = emcalFolder->FindObject("Hits") ;
278 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
282 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
285 //____________________________________________________________________________
286 Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
287 { //---------- SDigits -------------------------
290 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
291 // because you can have sdigits from several hit files for mixing
293 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
294 if ( !emcalFolder ) {
296 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
297 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
299 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
301 TString subdir(headerFile) ;
302 subdir.ReplaceAll("/", "_") ;
303 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
304 if ( !emcalSubFolder )
305 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
307 TObject * sd = emcalSubFolder->FindObject(name);
310 cerr <<"INFO: AliEMCALGetter::Post S -> Folder " << subdir
311 << " already exists!" << endl ;
313 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
314 sdigits->SetName(name) ;
315 emcalSubFolder->Add(sdigits) ;
320 //____________________________________________________________________________
321 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
322 { //------- SDigits ----------------------
324 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
326 if ( !fSDigitsFolder ) {
327 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
331 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
332 if ( !emcalFolder ) {
333 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
337 TFolder * emcalSubFolder = 0 ;
339 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
341 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
343 if(!emcalSubFolder) {
344 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
348 TObject * dis = emcalSubFolder->FindObject(name) ;
352 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
356 //____________________________________________________________________________
357 Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
358 { //---------- SDigitizer -------------------------
360 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
363 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
366 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
369 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
372 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
373 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
375 emcal = new TTask("EMCAL", "") ;
378 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
381 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
382 emcal->GetListOfTasks()->Remove(emcalsd) ;
384 emcal->Add(sdigitizer) ;
389 //____________________________________________________________________________
390 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
393 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
395 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
399 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
401 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
405 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
407 return emcal->GetListOfTasks()->GetObjectRef(task) ;
411 //____________________________________________________________________________
412 Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
413 { //---------- SDigitizer -------------------------
415 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
418 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
420 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
424 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
427 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
428 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
430 emcal = new TTask("EMCAL", "") ;
434 TString sdname(name) ;
437 sdname.ReplaceAll("/","_") ;
438 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
440 emcalsd = new AliEMCALSDigitizer() ;
441 //Note, we can not call constructor with parameters: it will call Getter and scrud up everething
442 emcalsd->SetName(sdname) ;
443 emcalsd->SetTitle(file) ;
444 emcal->Add(emcalsd) ;
450 //____________________________________________________________________________
451 Bool_t AliEMCALGetter::PostDigits(const char * name) const
452 { //---------- Digits -------------------------
454 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
456 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
458 if ( !emcalFolder ) {
460 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
461 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
463 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
466 TObject* dig = emcalFolder->FindObject( name ) ;
468 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
469 digits->SetName(name) ;
470 emcalFolder->Add(digits) ;
475 //____________________________________________________________________________
476 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
477 { //------- Digits ----------------------
479 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
481 if ( !fDigitsFolder ) {
482 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
486 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
487 if ( !emcalFolder ) {
488 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
492 TObject * d = emcalFolder->FindObject(name) ;
496 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
500 //____________________________________________________________________________
501 Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
502 { //---------- Digitizer -------------------------
504 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
507 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
510 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
513 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
514 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
516 emcal = new TTask("EMCAL", "") ;
520 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
523 emcal->GetListOfTasks()->Remove(emcald) ;
525 emcal->Add(digitizer) ;
529 //____________________________________________________________________________
530 Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
531 { //---------- Digitizer -------------------------
533 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
535 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
537 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
541 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
544 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
545 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
547 emcal = new TTask("EMCAL", "") ;
551 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
553 emcald = new AliEMCALDigitizer() ;
554 emcald->SetName(fDigitsTitle) ;
555 emcald->SetTitle(fHeaderFile) ;
561 //____________________________________________________________________________
562 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
564 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
566 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
570 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
572 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
576 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
578 return emcal->GetListOfTasks()->GetObjectRef(task) ;
582 //____________________________________________________________________________
583 Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
584 { // -------------- RecPoints -------------------------------------------
586 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
587 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
589 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
591 if ( !emcalFolder ) {
593 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
594 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
596 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
600 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
601 if ( !emcalRPoTowerFolder ) {
603 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
604 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
606 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
609 TObject * erp = emcalFolder->FindObject( name ) ;
611 TObjArray * towerrp = new TObjArray(100) ;
612 towerrp->SetName(name) ;
613 emcalRPoTowerFolder->Add(towerrp) ;
616 // Pre Shower RecPoints
617 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShoRecPoints")) ;
618 if ( !emcalRPoPreShoFolder ) {
620 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/ not found!" << endl;
621 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
623 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShoRecPoints", "PreSho RecPoints from EMCAL") ;
626 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
628 TObjArray * preshorp = new TObjArray(100) ;
629 preshorp->SetName(name) ;
630 emcalRPoPreShoFolder->Add(preshorp) ;
635 //____________________________________________________________________________
636 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
637 { // -------------- RecPoints -------------------------------------------
639 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
641 if ( !fRecoFolder ) {
642 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
646 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
647 if ( !towerFolder ) {
648 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
653 TObject * trp = towerFolder->FindObject(name ) ;
655 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
658 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
662 //____________________________________________________________________________
663 TObject ** AliEMCALGetter::PreShoRecPointsRef(const char * name) const
664 { // -------------- RecPoints -------------------------------------------
666 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShoRecPoints/name
668 if ( !fRecoFolder ) {
669 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
673 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
674 if ( !preshoFolder ) {
675 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShoRecPoints/" << endl;
679 TObject * prp = preshoFolder->FindObject(name ) ;
681 cerr << "ERROR: AliEMCALGetter::PreShoRecPointsRef -> Object " << name << " not found! " << endl ;
684 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
688 //____________________________________________________________________________
689 Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizerv1 * clu) const
690 { // ------------------ AliEMCALClusterizer ------------------------
692 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
694 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
697 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
701 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
704 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
705 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
707 emcal = new TTask("EMCAL", "") ;
711 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
714 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
716 emcal->GetListOfTasks()->Remove(emcalcl) ;
722 //____________________________________________________________________________
723 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
724 { // ------------------ AliEMCALClusterizer ------------------------
726 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
729 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
733 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
735 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
739 TList * l = emcal->GetListOfTasks() ;
743 TString cluname(name) ;
745 while((task = static_cast<TTask *>(it.Next()) )){
746 TString taskname(task->GetName()) ;
747 if(taskname.BeginsWith(cluname)){
754 return l->GetObjectRef(clu) ;
756 cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
761 //____________________________________________________________________________
762 Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
763 { // ------------------ AliEMCALClusterizer ------------------------
765 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
767 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
770 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder << "/Reconstructioner not found!" << endl;
774 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
777 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
778 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
780 emcal = new TTask("EMCAL", "") ;
784 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
787 emcalcl->SetName(clun) ;
788 emcal->Add(emcalcl) ;
793 //____________________________________________________________________________
794 /*Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
795 { // ---------------TrackSegments -----------------------------------
797 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
799 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
801 if ( !emcalFolder ) {
803 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
804 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
806 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
809 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
810 if ( !emcalTSFolder ) {
812 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
813 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
815 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
818 TObject * tss = emcalTSFolder->FindObject( name ) ;
820 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
822 emcalTSFolder->Add(ts) ;
827 //____________________________________________________________________________
828 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
829 { // ---------------TrackSegments -----------------------------------
831 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
833 if ( !fRecoFolder ) {
834 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
838 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
839 if ( !emcalFolder ) {
840 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
844 TObject * tss = emcalFolder->FindObject(name) ;
846 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
849 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
852 //____________________________________________________________________________
853 Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
854 { //------------Track Segment Maker ------------------------------
856 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
858 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
861 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
865 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
868 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
869 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
871 emcal = new TTask("EMCAL", "") ;
875 AliEMCALTrackSegmentMaker * emcalts =
876 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
879 emcal->GetListOfTasks()->Remove(emcalts) ;
881 emcal->Add(tsmaker) ;
885 //____________________________________________________________________________
886 Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
887 { //------------Track Segment Maker ------------------------------
889 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
892 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
895 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
899 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
902 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
903 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
905 emcal = new TTask("EMCAL", "") ;
909 AliEMCALTrackSegmentMaker * emcalts =
910 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(name)) ;
912 emcalts = new AliEMCALTrackSegmentMakerv1() ;
915 emcalts->SetName(tsn) ;
916 emcal->Add(emcalts) ;
922 //____________________________________________________________________________
923 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
924 { //------------Track Segment Maker ------------------------------
926 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
929 cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
933 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
935 cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
939 TList * l = emcal->GetListOfTasks() ;
943 TString tsmname(name) ;
945 while((task = static_cast<TTask *>(it.Next()) )){
946 TString taskname(task->GetName()) ;
947 if(taskname.BeginsWith(tsmname)){
954 return l->GetObjectRef(tsm) ;
956 cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
961 //____________________________________________________________________________
962 Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
963 { // -------------------- RecParticles ------------------------
965 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
967 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
969 if ( !emcalFolder ) {
971 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
972 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
974 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
977 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
978 if ( !emcalRPaFolder ) {
980 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
981 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
983 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
986 TObject * rps = emcalRPaFolder->FindObject( name ) ;
988 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
990 emcalRPaFolder->Add(rp) ;
995 //____________________________________________________________________________
996 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
997 { // ---------------TrackSegments -----------------------------------
999 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1001 if ( !fRecoFolder ) {
1002 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
1006 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1007 if ( !emcalFolder ) {
1008 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1012 TObject * tss = emcalFolder->FindObject(name) ;
1014 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
1017 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1020 //____________________________________________________________________________
1021 Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
1022 { // ------------AliEMCAL PID -----------------------------
1024 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1027 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1031 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1034 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1035 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1037 emcal = new TTask("EMCAL", "") ;
1041 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1044 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1045 << " already exists" << endl ;
1046 emcal->GetListOfTasks()->Remove(emcalpid) ;
1053 //____________________________________________________________________________
1054 Bool_t AliEMCALGetter::PostPID(const char * name) const
1056 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1058 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1061 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1065 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1068 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1069 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1071 emcal = new TTask("EMCAL", "") ;
1075 TList * l = emcal->GetListOfTasks() ;
1077 TString pidname(name) ;
1080 while((task = static_cast<TTask *>(it.Next()) )){
1081 TString taskname(task->GetName()) ;
1082 if(taskname.BeginsWith(pidname))
1086 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1088 emcalpid->SetName(pidname) ;
1089 emcal->Add(emcalpid) ;
1094 //____________________________________________________________________________
1095 TObject ** AliEMCALGetter::PIDRef(const char * name) const
1096 { //------------PID ------------------------------
1098 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1101 cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1105 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1107 cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
1111 TList * l = emcal->GetListOfTasks() ;
1115 TString pidname(name) ;
1117 while((task = static_cast<TTask *>(it.Next()) )){
1118 TString taskname(task->GetName()) ;
1119 if(taskname.BeginsWith(pidname)){
1126 return l->GetObjectRef(pid) ;
1128 cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
1133 //____________________________________________________________________________
1134 Bool_t AliEMCALGetter::PostQA(void) const
1135 { // ------------------ QA ---------------------------------
1137 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1139 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1140 if ( !emcalFolder ) {
1142 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1143 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1145 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1151 //____________________________________________________________________________
1152 TObject ** AliEMCALGetter::AlarmsRef(void) const
1153 { //------- Alarms ----------------------
1156 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1158 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1162 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1163 if ( !emcalFolder ) {
1164 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1168 return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1171 //____________________________________________________________________________
1172 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1174 // Return primary particle numbered by <index>
1179 Int_t primaryIndex = index % 10000000 ;
1180 Int_t primaryList = (Int_t ) ((index-primaryIndex)/10000000.) ;
1182 if ( primaryList > 0 ) {
1184 cout << " Getter does not support currently Mixing of primary " << endl ;
1185 cout << " can not return primary: " << index<< " (list "<< primaryList<< " primary # " << primaryIndex << " )"<<endl ;
1190 return gAlice->Particle(primaryIndex) ;
1194 //____________________________________________________________________________
1195 void AliEMCALGetter::ReadTreeD()
1197 // Read the digit tree gAlice->TreeD()
1198 if(gAlice->TreeD()== 0){
1199 cerr << "ERROR: AliEMCALGetter::ReadTreeD: can not read TreeD " << endl ;
1203 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeD()->GetListOfBranches()) ;
1205 TBranch * branch = 0 ;
1206 TBranch * digitsbranch = 0 ;
1207 TBranch * digitizerbranch = 0 ;
1208 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1210 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1211 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1212 digitsbranch = branch ;
1213 emcalfound = kTRUE ;
1215 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1216 digitizerbranch = branch ;
1217 digitizerfound = kTRUE ;
1221 if ( !emcalfound || !digitizerfound ) {
1223 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1224 << fDigitsTitle << endl ;
1229 if(!Digits(fDigitsTitle) )
1230 PostDigits(fDigitsTitle);
1231 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1232 digitsbranch->GetEntry(0) ;
1235 // read the Digitizer
1236 if(!Digitizer(fDigitsTitle))
1237 PostDigitizer(fDigitsTitle) ;
1238 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1239 digitizerbranch->GetEntry(0) ;
1244 //____________________________________________________________________________
1245 void AliEMCALGetter::ReadTreeH()
1247 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1249 if(gAlice->TreeH()== 0){
1250 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1254 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1255 if ( !hitsbranch ) {
1257 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1263 if (hitsbranch->GetEntries() > 1 ) {
1264 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1265 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1266 hitsbranch->SetAddress(&tempo) ;
1269 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1270 hitsbranch->GetEntry(i) ;
1272 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1273 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1274 new((*hits)[index]) AliEMCALHit( *hit ) ;
1281 hitsbranch->SetAddress(HitsRef()) ;
1282 hitsbranch->GetEntry(0) ;
1286 //____________________________________________________________________________
1287 void AliEMCALGetter::Track(Int_t itrack)
1289 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1291 if(gAlice->TreeH()== 0){
1292 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1296 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1297 if ( !hitsbranch ) {
1299 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1304 hitsbranch->SetAddress(HitsRef()) ;
1305 hitsbranch->GetEntry(itrack) ;
1309 //____________________________________________________________________________
1310 // void AliEMCALGetter::ReadTreeQA()
1312 // Read the digit tree gAlice->TreeQA()
1313 // so far only EMCAL knows about this Tree
1315 // if(EMCAL()->TreeQA()== 0){
1316 // cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1320 // TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1323 // cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1330 // qabranch->SetAddress(AlarmsRef()) ;
1332 // qabranch->GetEntry(0) ;
1334 // PostQA("EMCAL") ;
1335 // TFolder * alarmsF = Alarms() ;
1336 // alarmsF->Clear() ;
1337 // qabranch->SetAddress(&alarmsF) ;
1338 // qabranch->GetEntry(0) ;
1342 //____________________________________________________________________________
1343 void AliEMCALGetter::ReadTreeR()
1345 // Read the reconstrunction tree gAlice->TreeR()
1347 if(gAlice->TreeR()== 0){
1348 cerr << "ERROR: AliEMCALGetter::ReadTreeR: can not read TreeR " << endl ;
1353 TObjArray * lob = static_cast<TObjArray*>(gAlice->TreeR()->GetListOfBranches()) ;
1355 TBranch * branch = 0 ;
1356 TBranch * towerbranch = 0 ;
1357 TBranch * preshobranch = 0 ;
1358 TBranch * clusterizerbranch = 0 ;
1359 Bool_t emcaltowerrpfound = kFALSE, emcalpreshorpfound = kFALSE, clusterizerfound = kFALSE ;
1361 while ( (branch = static_cast<TBranch*>(next())) && (!emcaltowerrpfound || !emcalpreshorpfound || !clusterizerfound) )
1362 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0) {
1363 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1364 towerbranch = branch ;
1365 emcaltowerrpfound = kTRUE ;
1367 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1368 preshobranch = branch ;
1369 emcalpreshorpfound = kTRUE ;
1371 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1372 clusterizerbranch = branch ;
1373 clusterizerfound = kTRUE ;
1377 if ( !emcaltowerrpfound ) {
1379 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TowerRecPoints with title "
1380 << fRecPointsTitle << endl ;
1383 if ( !emcalpreshorpfound ) {
1385 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find PreShoRecPoints with title "
1386 << fRecPointsTitle << endl ;
1389 if ( !clusterizerfound ) {
1391 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Can not find Clusterizer with title "
1392 << fRecPointsTitle << endl ;
1396 // Read and Post the RecPoints
1397 if(!TowerRecPoints(fRecPointsTitle) )
1398 PostRecPoints(fRecPointsTitle) ;
1399 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1400 towerbranch->GetEntry(0) ;
1402 preshobranch->SetAddress(PreShoRecPointsRef(fRecPointsTitle)) ;
1403 preshobranch->GetEntry(0) ;
1405 if(!Clusterizer(fRecPointsTitle) )
1406 PostClusterizer(fRecPointsTitle) ;
1407 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1408 clusterizerbranch->GetEntry(0) ;
1411 //------------------- TrackSegments ---------------------
1413 // TBranch * tsbranch = 0 ;
1414 // TBranch * tsmakerbranch = 0 ;
1415 // Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1417 // while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) )
1418 // if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0) {
1419 // if ( strcmp(branch->GetName(), "EMCALTS")==0){
1420 // tsbranch = branch ;
1421 // emcaltsfound = kTRUE ;
1423 // else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1424 // tsmakerbranch = branch ;
1425 // tsmakerfound = kTRUE ;
1429 // if ( !emcaltsfound || !tsmakerfound ) {
1431 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1432 // << fTrackSegmentsTitle << endl ;
1436 // // Read and Post the TrackSegments
1437 // if(!TrackSegments(fTrackSegmentsTitle))
1438 // PostTrackSegments(fTrackSegmentsTitle) ;
1439 // tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1440 // tsbranch->GetEntry(0) ;
1442 // // Read and Post the TrackSegment Maker
1443 // if(!TrackSegmentMaker(fTrackSegmentsTitle))
1444 // PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1445 // tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1446 // tsmakerbranch->GetEntry(0) ;
1449 // //------------ RecParticles ----------------------------
1451 // TBranch * rpabranch = 0 ;
1452 // TBranch * pidbranch = 0 ;
1453 // Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1455 // while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1456 // if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1457 // if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1458 // rpabranch = branch ;
1459 // emcalrpafound = kTRUE ;
1461 // else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1462 // pidbranch = branch ;
1463 // pidfound = kTRUE ;
1467 // if ( !emcalrpafound || !pidfound ) {
1469 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1470 // << fRecParticlesTitle << endl ;
1474 // // Read and Post the RecParticles
1475 // if(!RecParticles(fRecParticlesTitle))
1476 // PostRecParticles(fRecParticlesTitle) ;
1477 // rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1478 // rpabranch->GetEntry(0) ;
1480 // // Read and Post the PID
1481 // if(!PID(fRecParticlesTitle))
1482 // PostPID(fRecParticlesTitle) ;
1483 // pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1484 // pidbranch->GetEntry(0) ;
1489 //____________________________________________________________________________
1490 void AliEMCALGetter::ReadTreeS(Int_t event)
1492 // Read the summable digits tree gAlice->TreeS()
1494 // loop over all opened files and read their SDigits to the White Board
1495 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1497 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1498 TCollection * folderslist = emcalF->GetListOfFolders() ;
1500 //Add current file to list if it is not there yet
1502 TString subdir(fHeaderFile) ;
1503 subdir.ReplaceAll("/","_") ;
1505 if ( (subdir != "aliroot") && ( !folderslist->Contains(subdir) ) ){
1506 emcalF->AddFolder(subdir, "");
1509 TIter next(folderslist) ;
1510 TFolder * folder = 0 ;
1513 while ( (folder = static_cast<TFolder*>(next())) ) {
1514 TString fileName(folder->GetName()) ;
1515 fileName.ReplaceAll("_","/") ;
1516 if(fHeaderFile.CompareTo(fileName) == 0 )
1517 treeS=gAlice->TreeS() ;
1519 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1522 // Get SDigits Tree header from file
1523 TString treeName("TreeS") ;
1525 treeS = dynamic_cast<TTree*>(gDirectory->Get(treeName.Data()));
1528 cerr << "ERROR: AliEMCALGetter::ReadTreeS There is no SDigit Tree" << endl;
1532 //set address of the SDigits and SDigitizer
1533 TBranch * sdigitsBranch = 0;
1534 TBranch * sdigitizerBranch = 0;
1535 TBranch * branch = 0 ;
1536 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1538 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1540 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1541 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1542 emcalfound = kTRUE ;
1543 sdigitsBranch = branch ;
1546 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1547 sdigitizerfound = kTRUE ;
1548 sdigitizerBranch = branch ;
1551 if ( !emcalfound || !sdigitizerfound ) {
1553 cout << "WARNING: AliEMCALGetter::ReadSDigits -> Digits and/or Digitizer branch with name " << fSDigitsTitle
1554 << " not found" << endl ;
1558 if ( !folder->FindObject(fSDigitsTitle) )
1559 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1560 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1561 sdigitsBranch->GetEntry(0) ;
1563 TString sdname(fSDigitsTitle) ;
1565 sdname+=folder->GetName() ;
1566 if(!SDigitizer(sdname) )
1567 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1568 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1569 sdigitizerBranch->GetEntry(0) ;
1573 // After SDigits have been read from all files, return to the first one
1576 folder = static_cast<TFolder*>(next());
1578 TString fileName(folder->GetName()) ;
1579 fileName.ReplaceAll("_","/") ;
1580 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1585 //____________________________________________________________________________
1586 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1587 { // Read the summable digits fron treeS()
1590 TString filename("mergefile") ;
1593 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1594 if ( !emcalFolder ) {
1595 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1597 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1598 //set address of the SDigits and SDigitizer
1599 TBranch * sdigitsBranch = 0;
1600 TBranch * sdigitizerBranch = 0;
1601 TBranch * branch = 0 ;
1602 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1604 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1606 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1607 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1608 emcalfound = kTRUE ;
1609 sdigitsBranch = branch ;
1612 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1613 sdigitizerfound = kTRUE ;
1614 sdigitizerBranch = branch ;
1617 if ( !emcalfound || !sdigitizerfound ) {
1619 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
1623 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1624 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1626 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1627 sdigitsBranch->GetEntry(0) ;
1629 TString sdname(sdigitsBranch->GetTitle()) ;
1632 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1633 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1635 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1636 sdigitizerBranch->GetEntry(0) ;
1641 //____________________________________________________________________________
1642 void AliEMCALGetter::ReadPrimaries()
1644 // Reads specific branches of primaries
1646 fNPrimaries = gAlice->GetNtrack();
1648 // //Check, is it necessary to open new files
1649 // TArrayI* events = fDigitizer->GetCurrentEvents() ;
1650 // TClonesArray * filenames = fDigitizer->GetHeadersFiles() ;
1652 // for(input = 0; input < filenames->GetEntriesFast(); input++){
1654 // TObjString * filename = (TObjString *) filenames->At(input) ;
1656 // //Test, if this file already open
1657 // TFile *file = (TFile*) gROOT->GetFile( filename->GetString() ) ;
1659 // file = new TFile( filename->GetString()) ;
1662 // // Get Kine Tree from file
1663 // // char treeName[20];
1664 // // sprintf(treeName,"TreeK%d",events->At(input));
1665 // // TTree * treeK = (TTree*)gDirectory->Get(treeName);
1667 // // treeK->SetBranchAddress("Particles", &fParticleBuffer);
1669 // // cout << "AliEMCALGetter: cannot find Kine Tree for event:" << events->At(input) << endl;
1671 // // // Create the particle stack
1672 // // if(!fParticles) fParticles = new TClonesArray("TParticle",1000);
1673 // // // Build the pointer list
1674 // // if(fParticleMap) { <----
1675 // // fParticleMap->Clear();
1676 // // fParticleMap->Expand(treeK->GetEntries());
1678 // // fParticleMap = new TObjArray(treeK->GetEntries());
1680 // // From gAlice->Particle(i)
1683 // // if(!(*fParticleMap)[i]) {
1684 // // Int_t nentries = fParticles->GetEntries();
1686 // // // algorithmic way of getting entry index
1687 // // // (primary particles are filled after secondaries)
1689 // // if (i<fHeader.GetNprimary())
1690 // // entry = i+fHeader.GetNsecondary();
1692 // // entry = i-fHeader.GetNprimary();
1694 // // // only check the algorithmic way and give
1695 // // // the fatal error if it is wrong
1696 // // if (entry != fParticleFileMap[i]) {
1697 // // Fatal("Particle",
1698 // // "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
1699 // // entry, fParticleFileMap[i]);
1702 // // fTreeK->GetEntry(fParticleFileMap[i]);
1703 // // new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
1704 // // fParticleMap->AddAt((*fParticles)[nentries],i);
1706 // // return (TParticle *) (*fParticleMap)[i];
1713 // //scan over opened files and read corresponding TreeK##
1717 //____________________________________________________________________________
1718 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1720 // Reads the content of all Tree's S, D and R
1722 if (event >= gAlice->TreeE()->GetEntries() ) {
1723 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
1726 gAlice->GetEvent(event) ;
1728 if(strstr(opt,"H") )
1731 if(strstr(opt,"S") )
1734 if( strstr(opt,"D") )
1737 if( strstr(opt,"R") )
1740 // if( strstr(opt,"Q") )
1743 // if( strstr(opt,"P") || (strcmp(opt,"")==0) )
1744 // ReadPrimaries() ;
1748 //____________________________________________________________________________
1749 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1751 // get the object named "what" from the folder
1752 // folders are named like //Folders
1754 if ( file.IsNull() )
1755 file = fHeaderFile ;
1757 TFolder * folder = 0 ;
1758 TObject * emcalO = 0 ;
1760 // if ( name.IsNull() ) {
1761 if ( what.CompareTo("Hits") == 0 ) {
1762 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1764 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1766 else if ( what.CompareTo("SDigits") == 0 ) {
1767 file.ReplaceAll("/","_") ;
1768 TString path = "EMCAL/" + file ;
1769 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1772 name = fSDigitsTitle ;
1773 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1776 else if ( what.CompareTo("Digits") == 0 ){
1777 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1780 name = fDigitsTitle ;
1781 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1784 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1785 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1788 name = fRecPointsTitle ;
1789 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1792 else if ( what.CompareTo("PreShoRecPoints") == 0 ) {
1793 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShoRecPoints")) ;
1796 name = fRecPointsTitle ;
1797 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1801 else if ( what.CompareTo("TrackSegments") == 0 ) {
1802 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1805 name = fTrackSegmentsTitle ;
1806 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1809 else if ( what.CompareTo("RecParticles") == 0 ) {
1810 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1813 name = fRecParticlesTitle ;
1814 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1817 else if ( what.CompareTo("Alarms") == 0 ){
1819 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
1821 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1825 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1831 cerr << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
1837 //____________________________________________________________________________
1838 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1840 // get the TTask named "what" from the folder
1841 // folders are named like //Folders/Tasks/what/EMCAL/name
1843 TString search(what) ;
1844 if ( what.CompareTo("Clusterizer") == 0 )
1845 search = "Reconstructioner" ;
1846 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1847 search = "Reconstructioner" ;
1848 else if ( what.CompareTo("PID") == 0 )
1849 search = "Reconstructioner" ;
1850 else if ( what.CompareTo("QATasks") == 0 )
1853 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1856 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
1860 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1862 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
1866 TList * list = emcalT->GetListOfTasks() ;
1868 if (what.CompareTo("SDigitizer") == 0) {
1869 if ( name.IsNull() )
1870 name = fSDigitsTitle ;
1871 } else if (what.CompareTo("Digitizer") == 0){
1872 if ( name.IsNull() )
1873 name = fDigitsTitle ;
1874 } else if (what.CompareTo("Clusterizer") == 0){
1875 if ( name.IsNull() )
1876 name = fRecPointsTitle ;
1877 name.Append(":clu") ;
1879 // else if (what.CompareTo("TrackSegmentMaker") == 0){
1880 // if ( name.IsNull() )
1881 // name = fTrackSegmentsTitle ;
1882 // name.Append(":tsm") ;
1884 // else if (what.CompareTo("PID") == 0){
1885 // if ( name.IsNull() )
1886 // name = fRecParticlesTitle ;
1887 // name.Append(":pid") ;
1889 // else if (what.CompareTo("QATasks") == 0){
1890 // if ( name.IsNull() )
1896 while((task = static_cast<TTask *>(it.Next()) )){
1897 TString taskname(task->GetName()) ;
1898 if(taskname.BeginsWith(name)){
1903 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;