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 08.2002 Dmitri Peressounko:
28 //_________________________________________________________________________
29 // A singleton. This class should be used in the analysis stage to get
30 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
31 // instead of directly reading them from galice.root file. This container
32 // ensures, that one reads Digits, made of these particular digits, RecPoints,
33 // made of these particular RecPoints, TrackSegments and RecParticles.
34 // This becomes non trivial if there are several identical branches, produced with
35 // different set of parameters.
37 // An example of how to use (see also class AliEMCALAnalyser):
38 // AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
39 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
40 // AliEMCALRecParticle * part = gime->RecParticle(1) ;
42 // please->GetEvent(event) ; // reads new event from galice.root
44 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
45 //*-- Completely redesigned by Dmitri Peressounko March 2001
47 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
48 //*-- systematic usage of TFolders without changing the interface
49 //*-- YS August 2002 : clone PHOS as closely as possible and intoduction
50 // of new IO (à la PHOS)
51 //////////////////////////////////////////////////////////////////////////////
53 // --- ROOT system ---
57 #include "TObjString.h"
59 #include "TParticle.h"
61 // --- Standard library ---
64 // --- AliRoot header files ---
66 #include "AliConfig.h"
67 #include "AliEMCALGetter.h"
69 #include "AliEMCALDigitizer.h"
70 #include "AliEMCALSDigitizer.h"
71 #include "AliEMCALClusterizerv1.h"
72 //#include "AliEMCALTrackSegmentMakerv1.h"
73 //#include "AliEMCALTrackSegment.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 Bool_t toSplit)
85 // This is the ctor called by GetInstance and the only one that can be used
87 if ( fHeaderFile.Contains("_") ) {
88 cerr << "AliEMCALGetter::AliEMCALGetter -> Invalid file name (_ not allowed) " << fHeaderFile.Data() << endl ;
99 fHeaderFile = headerFile ;
101 fPrimaries = new TObjArray(1) ;
103 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
104 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
105 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
106 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
107 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
108 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
109 //fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
110 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
112 //Set titles to branches and create PHOS specific folders
113 SetTitle(branchTitle) ;
115 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
117 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
119 if(!fFile){ //if file was not opened yet, read gAlice
120 fFile = TFile::Open(fHeaderFile.Data(), "update") ;
121 if (!fFile->IsOpen()) {
122 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 ;
150 //____________________________________________________________________________
151 AliEMCALGetter::~AliEMCALGetter()
154 fPrimaries->Delete() ;
158 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
159 TCollection * folderslist = emcalF->GetListOfFolders() ;
160 TIter next(folderslist) ;
161 TFolder * folder = 0 ;
162 while ( (folder = static_cast<TFolder*>(next())) )
163 emcalF->Remove(folder) ;
174 //____________________________________________________________________________
175 void AliEMCALGetter::CloseFile()
183 //____________________________________________________________________________
184 const TFolder * AliEMCALGetter::Folder(const TString what) const {
186 // returns the EMCAL folder required by what
187 // what = hits, sdigits, digits
189 if ( what == "hits" )
190 return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
191 else if ( what == "sdigits" )
192 return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
193 else if ( what == "digits" )
194 return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
196 cerr << "ERROR: AliEMCALGetter::GetFolder -> " << what.Data() << " illegal option (hits, sdigits, digits) " << endl ;
201 //____________________________________________________________________________
202 AliEMCALGetter * AliEMCALGetter::GetInstance()
204 // Returns the pointer of the unique instance already defined
210 // cout << "AliEMCALGetter::GetInstance ERROR: not yet initialized" << endl ;
215 //____________________________________________________________________________
216 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
217 const char* branchTitle,
218 const Bool_t toSplit)
220 // Creates and returns the pointer of the unique instance
221 // Must be called only when the environment has changed
224 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
225 if(fgObjGetter->fFailed)
231 //First checks, if header file already opened
232 if(!fgObjGetter->fFile){
233 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
234 if(fgObjGetter->fFailed)
240 if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
241 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
242 (toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
245 else{ //Clean all data and AliEMCAL...zers
246 if(fgObjGetter->fToSplit)
247 fgObjGetter->CloseSplitFiles() ;
248 fgObjGetter->CleanWhiteBoard() ;
249 fgObjGetter->fToSplit = toSplit ;
250 fgObjGetter->SetTitle(branchTitle) ;
254 else{ //Close already opened files, clean memory and open new header file
258 if(fgObjGetter->fFile){
259 fgObjGetter->fFile->Close() ;
260 fgObjGetter->fFile=0;
262 if(fgObjGetter->fToSplit)
263 fgObjGetter->CloseSplitFiles() ;
264 fgObjGetter->CleanWhiteBoard() ;
265 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
272 //____________________________________________________________________________
273 const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
275 //Looks in the tree Tree"name" if branch with current name olready exists
277 TString filename("") ;
278 TString name, dataname, zername;
279 if(recName == "SDigits"){
280 filename=fSDigitsFileName ;
283 zername = "AliPHOSSDigitizer" ;
286 if(recName == "Digits"){
287 filename=fDigitsFileName ;
290 zername = "AliPHOSDigitizer" ;
293 if(recName =="RecPoints"){
294 filename=fRecPointsFileName ;
296 dataname = "PHOSEmcRP" ;
297 zername = "AliPHOSClusterizer" ;
300 if(recName == "TrackSegments"){
301 filename=fTrackSegmentsFileName ;
303 dataname = "PHOSTS" ;
304 zername = "AliPHOSTrackSegmentMaker" ;
307 if(recName == "RecParticles"){
308 filename= fRecParticlesFileName ;
310 dataname = "PHOSRP" ;
311 zername = "AliPHOSPID" ;
319 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
321 file = TFile::Open(fSDigitsFileName.Data(),"update");
326 tree = (TTree *)file->Get(name.Data()) ;
331 TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
333 TBranch * branch = 0 ;
334 TString titleName(fBranchTitle);
336 while ((branch = (static_cast<TBranch*>(next())))) {
337 TString branchName(branch->GetName() ) ;
338 TString branchTitle(branch->GetTitle() ) ;
339 if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
340 cerr << "WARNING: AliEMCALGetter::BranchExists -> branch " << dataname.Data() << " with title " << fBranchTitle << " already exits in "
341 << name.Data() << endl;
344 if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
345 cerr << "WARNING: AliEMCALGetter::BranchExists -> branch AliEMCAL... with title " << branch->GetTitle() << " already exits in "
346 << name.Data() << endl;
356 //____________________________________________________________________________
357 void AliEMCALGetter::ListBranches(Int_t event) const
360 TBranch * branch = 0 ;
361 if (gAlice->GetEvent(event) == -1)
364 TTree * t = gAlice->TreeH() ;
366 cout << "INFO: AliEMCALGetter::ListBranches -> ****** Hits : " << endl ;
367 TObjArray * lob = t->GetListOfBranches() ;
369 while ( (branch = static_cast<TBranch*>(next())) )
370 cout << " " << branch->GetName() << endl ;
372 cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeH not found for event " << event << endl ;
375 t = gAlice->TreeS() ;
377 cout << "INFO: AliEMCALGetter::ListBranches -> ****** SDigits : " << endl ;
378 TObjArray * lob = t->GetListOfBranches() ;
380 while ( (branch = static_cast<TBranch*>(next())) )
381 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
383 cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeS not found for event " << event << endl ;
385 t = gAlice->TreeD() ;
387 cout << "INFO: AliEMCALGetter::ListBranches -> ****** Digits : " << endl ;
388 TObjArray * lob = t->GetListOfBranches() ;
390 while ( (branch = static_cast<TBranch*>(next())) )
391 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
393 cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeD not found for event " << event << endl ;
396 t = gAlice->TreeR() ;
398 cout << "INFO: AliEMCALGetter::ListBranches -> ****** Recon : " << endl ;
399 TObjArray * lob = t->GetListOfBranches() ;
401 while ( (branch = static_cast<TBranch*>(next())) )
402 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
404 cerr << "WARNING::AliEMCALGetter::ListBranches -> TreeR not found for event " << event << endl ;
408 //____________________________________________________________________________
409 void AliEMCALGetter::NewBranch(TString name, Int_t event)
411 fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
415 //____________________________________________________________________________
416 Bool_t AliEMCALGetter::NewFile(TString name)
422 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
423 if(!fFile) { //if file was not opened yet, read gAlice
424 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
425 if (!fFile->IsOpen()) {
426 cerr << "ERROR : AliEMCALGetter::NewFile -> Cannot open " << fHeaderFile.Data() << endl ;
430 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
434 cerr << "ERROR : AliEMCALGetter::AliEMCALGetter -> Cannot find gAlice in " << fHeaderFile.Data() << endl ;
441 //____________________________________________________________________________
442 const AliEMCAL * AliEMCALGetter::EMCAL()
444 // returns the EMCAL object
445 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;
448 cout << "WARNING: AliEMCALGetter::EMCAL -> EMCAL module not found in Folders" << endl ;
452 //____________________________________________________________________________
453 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
455 AliEMCALGeometry * rv = 0 ;
457 rv = EMCAL()->GetGeometry() ;
461 //____________________________________________________________________________
462 const Bool_t AliEMCALGetter::PostPrimaries(void) const
463 { //------- Primaries ----------------------
465 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
467 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
468 if ( !primariesFolder ) {
470 cout << "WARNING: AliEMCALGetter::Post Primaries -> Folder //" << fPrimariesFolder->GetName() << "/Primaries/ not found!" << endl;
471 cout << "INFO: AliEMCALGetter::Post Primaries -> Adding Folder //" << fPrimariesFolder->GetName() << "/Primaries/" << endl;
473 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
475 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
476 primaries->SetName("Primaries") ;
477 primariesFolder->Add(primaries) ;
482 //____________________________________________________________________________
483 TObject** AliEMCALGetter::PrimariesRef(void) const
484 { //------- Primaries ----------------------
487 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
488 if ( !fPrimariesFolder ) {
489 cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << " not found!" << endl;
493 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
494 if ( !primariesFolder ) {
495 cerr << "ERROR: AliEMCALGetter::PrimariesRef -> Folder //" << fPrimariesFolder << "/Primaries/ not found!" << endl;
499 TObject * p = primariesFolder->FindObject("Primaries") ;
501 cerr << "ERROR: AliEMCALGetter::PrimariesRef -> " << primariesFolder->GetName() << "/Primaries not found !" << endl ;
505 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
508 //____________________________________________________________________________
509 const Bool_t AliEMCALGetter::PostHits(void) const
510 { //------- Hits ----------------------
512 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
514 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
515 if ( !emcalFolder ) {
517 cout << "WARNING: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
518 cout << "INFO: AliEMCALGetter::Post H -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
520 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
522 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
523 hits->SetName("Hits") ;
524 emcalFolder->Add(hits) ;
529 //____________________________________________________________________________
530 TObject ** AliEMCALGetter::HitsRef(void) const
531 { //------- Hits ----------------------
534 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
535 if ( !fHitsFolder ) {
536 cerr << "ERROR: AliEMCALGetter::Post H -> Folder //" << fHitsFolder << " not found!" << endl;
540 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
541 if ( !emcalFolder ) {
542 cerr << "ERROR: AliEMCALGetter::Post HRef -> Folder //" << fHitsFolder << "/EMCAL/ not found!" << endl;
546 TObject * h = emcalFolder->FindObject("Hits") ;
548 cerr << "ERROR: AliEMCALGetter::HRef -> " << emcalFolder->GetName() << "/Hits not found !" << endl ;
552 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
555 //____________________________________________________________________________
556 const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
557 { //---------- SDigits -------------------------
560 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
561 // because you can have sdigits from several hit files for mixing
563 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
564 if ( !emcalFolder ) {
566 cout << "WARNING: AliEMCALGetter::Post S -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
567 cout << "INFO: AliEMCALGetter::Post S -> Adding Folder //" << fHitsFolder << "/EMCAL/" << endl;
569 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
572 TString subdir(headerFile) ;
573 subdir.ReplaceAll("/", "_") ;
574 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
575 if ( !emcalSubFolder )
576 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
579 TObject * sd = emcalSubFolder->FindObject(name);
581 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
582 sdigits->SetName(name) ;
583 emcalSubFolder->Add(sdigits) ;
588 //____________________________________________________________________________
589 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
590 { //------- SDigits ----------------------
592 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
594 if ( !fSDigitsFolder ) {
595 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << " not found!" << endl;
599 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
600 if ( !emcalFolder ) {
601 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //" << fSDigitsFolder << "/EMCAL/ not found!" << endl;
605 TFolder * emcalSubFolder = 0 ;
607 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
609 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
611 if(!emcalSubFolder) {
612 cerr << "ERROR: AliEMCALGetter::Post SRef -> Folder //Folders/RunMC/Event/Data/EMCAL/" << file << "not found!" << endl;
616 TObject * dis = emcalSubFolder->FindObject(name) ;
618 cerr << "ERROR: AliEMCALGetter::DigitesSRef -> object " << name << " not found! " << endl ;
622 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
626 //____________________________________________________________________________
627 const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
628 { //---------- SDigitizer -------------------------
630 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
633 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
636 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
639 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
642 cout <<"WARNING: AliEMCALGetter::Post Ser ->//" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
643 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL/" << endl;
645 emcal = new TTask("EMCAL", "") ;
648 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
651 cout << "INFO: AliEMCALGetter::Post Ser -> Task " << sdigitizer->GetName() << " already exists" << endl ;
652 emcal->GetListOfTasks()->Remove(emcalsd) ;
654 emcal->Add(sdigitizer) ;
659 //____________________________________________________________________________
660 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
663 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
665 cerr << "ERROR: AliEMCALGetter::Post SerRef -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
669 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
671 cerr <<"ERROR: AliEMCALGetter::Post SerRef -> //" << fTasksFolder << "/SDigitizer/EMCAL not found!" << endl;
675 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
677 return emcal->GetListOfTasks()->GetObjectRef(task) ;
681 //____________________________________________________________________________
682 const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
683 { //---------- SDigitizer -------------------------
685 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
687 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
689 cerr << "ERROR: AliEMCALGetter::Post Ser -> Task //" << fTasksFolder << "/SDigitizer not found!" << endl;
693 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
696 cout <<"WARNING: AliEMCALGetter::Post Ser -> //" << fTasksFolder << "/SDigitizer/EMCAL/ not found!" << endl;
697 cout <<"INFO: AliEMCALGetter::Post Ser -> Adding //" << fTasksFolder << "/SDigitizer/EMCAL" << endl;
699 emcal = new TTask("EMCAL", "") ;
703 TString sdname(name) ;
706 sdname.ReplaceAll("/","_") ;
707 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
709 emcalsd = new AliEMCALSDigitizer() ;
710 //Note, we can not call constructor with parameters: it will call Getter and screw up everething
711 emcalsd->SetName(sdname) ;
712 emcalsd->SetTitle(file) ;
713 emcal->Add(emcalsd) ;
719 //____________________________________________________________________________
720 const Bool_t AliEMCALGetter::PostDigits(const char * name) const
721 { //---------- Digits -------------------------
723 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
725 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
727 if ( !emcalFolder ) {
729 cout << "WARNING: AliEMCALGetter::Post D -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
730 cout << "INFO: AliEMCALGetter::Post D -> Adding Folder //" << fDigitsFolder << "/EMCAL/" << endl;
732 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
735 TObject* dig = emcalFolder->FindObject( name ) ;
737 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
738 digits->SetName(name) ;
739 emcalFolder->Add(digits) ;
744 //____________________________________________________________________________
745 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
746 { //------- Digits ----------------------
748 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
750 if ( !fDigitsFolder ) {
751 cerr << "ERROR: AliEMCALGetter::Post DRef -> Folder //" << fDigitsFolder << " not found!" << endl;
755 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
756 if ( !emcalFolder ) {
757 cerr << "ERROR: AliEMCALGetter::DRef -> Folder //" << fDigitsFolder << "/EMCAL/ not found!" << endl;
761 TObject * d = emcalFolder->FindObject(name) ;
763 cerr << "ERROR: AliEMCALGetter::DigitsRef -> object " << name << " not found! " << endl ;
767 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
771 //____________________________________________________________________________
772 const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
773 { //---------- Digitizer -------------------------
775 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
778 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
781 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
784 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
785 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
787 emcal = new TTask("EMCAL", "") ;
791 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
794 emcal->GetListOfTasks()->Remove(emcald) ;
796 emcal->Add(digitizer) ;
800 //____________________________________________________________________________
801 const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
802 { //---------- Digitizer -------------------------
804 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
806 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
808 cerr << "ERROR: AliEMCALGetter::Post Der -> Task //" << fTasksFolder << "/Digitizer not found!" << endl;
812 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
815 cout <<"WARNING: AliEMCALGetter::Post Der -> //" << fTasksFolder << "/Digitizer/EMCAL not found!" << endl;
816 cout <<"INFO: AliEMCALGetter::Post Der -> Adding //" << fTasksFolder << "/Digitizer/EMCAL" << endl;
818 emcal = new TTask("EMCAL", "") ;
822 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
824 emcald = new AliEMCALDigitizer() ;
825 emcald->SetName(fDigitsTitle) ;
826 emcald->SetTitle(fHeaderFile) ;
832 //____________________________________________________________________________
833 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
835 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
837 cerr << "ERROR: AliEMCALGetter::Post DerRef -> Task //" << fTasksFolder->GetName() << "/Digitizer not found!" << endl;
841 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
843 cerr <<"ERROR: AliEMCALGetter::Post DerRef -> //" << fTasksFolder->GetName() << "/Digitizer/EMCAL" << endl;
847 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
849 return emcal->GetListOfTasks()->GetObjectRef(task) ;
853 //____________________________________________________________________________
854 const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
855 { // -------------- RecPoints -------------------------------------------
857 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
858 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
860 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
862 if ( !emcalFolder ) {
864 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
865 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
867 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
871 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
872 if ( !emcalRPoTowerFolder ) {
874 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
875 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints not found!" << endl;
877 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
880 TObject * erp = emcalFolder->FindObject( name ) ;
882 TObjArray * towerrp = new TObjArray(100) ;
883 towerrp->SetName(name) ;
884 emcalRPoTowerFolder->Add(towerrp) ;
887 // Pre Shower RecPoints
888 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
889 if ( !emcalRPoPreShoFolder ) {
891 cout << "WARNING: AliEMCALGetter::Post RPo -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/ not found!" << endl;
892 cout << "INFO: AliEMCALGetter::Post Rpo -> Adding Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
894 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;
897 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
899 TObjArray * preshorp = new TObjArray(100) ;
900 preshorp->SetName(name) ;
901 emcalRPoPreShoFolder->Add(preshorp) ;
906 //____________________________________________________________________________
907 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
908 { // -------------- RecPoints -------------------------------------------
910 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
912 if ( !fRecoFolder ) {
913 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
917 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
918 if ( !towerFolder ) {
919 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/TowerRecPoints/ not found!" << endl;
924 TObject * trp = towerFolder->FindObject(name ) ;
926 cerr << "ERROR: AliEMCALGetter::TowerRecPointsRef -> Object " << name << " not found!" << endl ;
929 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
933 //____________________________________________________________________________
934 TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const
935 { // -------------- RecPoints -------------------------------------------
937 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
939 if ( !fRecoFolder ) {
940 cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << " not found!" << endl;
944 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
945 if ( !preshoFolder ) {
946 cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Folder //" << fRecoFolder << "/EMCAL/PreShowerRecPoints/" << endl;
950 TObject * prp = preshoFolder->FindObject(name ) ;
952 cerr << "ERROR: AliEMCALGetter::PreShowerRecPointsRef -> Object " << name << " not found! " << endl ;
955 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
959 //____________________________________________________________________________
960 const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
961 { // ------------------ AliEMCALClusterizer ------------------------
963 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
965 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
968 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
972 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
975 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/ReconstructionerEMCAL not found!" << endl;
976 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
978 emcal = new TTask("EMCAL", "") ;
982 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
985 cout << "INFO: AliEMCALGetter::Post Rer -> Task " << clu->GetName() << " already exists" << endl ;
987 emcal->GetListOfTasks()->Remove(emcalcl) ;
993 //____________________________________________________________________________
994 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
995 { // ------------------ AliEMCALClusterizer ------------------------
997 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1000 cerr << "ERROR: AliEMCALGetter::Post RerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1004 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1006 cerr <<"WARNING: AliEMCALGetter::Post RerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1010 TList * l = emcal->GetListOfTasks() ;
1014 TString cluname(name) ;
1016 while((task = static_cast<TTask *>(it.Next()) )){
1017 TString taskname(task->GetName()) ;
1018 if(taskname.BeginsWith(cluname)){
1025 return l->GetObjectRef(clu) ;
1027 cerr << "ERROR: AliEMCALGetter::Post RerRef -> task " << task->GetName() << " not found! " << endl ;
1032 //____________________________________________________________________________
1033 const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
1034 { // ------------------ AliEMCALClusterizer ------------------------
1036 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1038 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1041 cerr << "ERROR: AliEMCALGetter::Post Rer -> Task//" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1045 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1048 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1049 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1051 emcal = new TTask("EMCAL", "") ;
1055 TList * l = emcal->GetListOfTasks() ;
1057 TString clun(name) ;
1060 while((task = static_cast<TTask *>(it.Next()) )){
1061 TString taskname(task->GetName()) ;
1062 if(taskname.BeginsWith(clun))
1066 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
1068 emcalcl->SetName(clun) ;
1069 emcalcl->SetTitle(fHeaderFile) ;
1070 emcal->Add(emcalcl) ;
1075 //____________________________________________________________________________
1076 /*const Bool_t AliEMCALGetter::PostTrackSegments(const char * name) const
1077 { // ---------------TrackSegments -----------------------------------
1079 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1081 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
1083 if ( !emcalFolder ) {
1085 cout << "WARNING: AliEMCALGetter::Post TS -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
1086 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL" << endl;
1088 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
1091 TFolder * emcalTSFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TrackSegments")) ;
1092 if ( !emcalTSFolder ) {
1094 cout << "WARNING: AliEMCALGetter::Post TS -> Folder//" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
1095 cout << "INFO: AliEMCALGetter::Post TS -> Adding Folder //" << fRecoFolder << "/EMCAL/TrackSegments/" << endl;
1097 emcalTSFolder = emcalFolder->AddFolder("TrackSegments", "TrackSegments from EMCAL") ;
1100 TObject * tss = emcalTSFolder->FindObject( name ) ;
1102 TClonesArray * ts = new TClonesArray("AliEMCALTrackSegment",100) ;
1104 emcalTSFolder->Add(ts) ;
1109 //____________________________________________________________________________
1110 TObject ** AliEMCALGetter::TrackSegmentsRef(const char * name) const
1111 { // ---------------TrackSegments -----------------------------------
1113 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1115 if ( !fRecoFolder ) {
1116 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "not found!" << endl;
1120 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
1121 if ( !emcalFolder ) {
1122 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> Folder //" << fRecoFolder << "/EMCAL/TrackSegments/ not found!" << endl;
1126 TObject * tss = emcalFolder->FindObject(name) ;
1128 cerr << "ERROR: AliEMCALGetter::TrackSegmentsRef -> object " << name << " not found! " << endl ;
1131 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1134 //____________________________________________________________________________
1135 const Bool_t AliEMCALGetter::PostTrackSegmentMaker(AliEMCALTrackSegmentMaker * tsmaker) const
1136 { //------------Track Segment Maker ------------------------------
1138 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1140 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1143 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder << "/Reconstructioner not found!" << endl;
1147 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1150 cout <<"WARNING: AliEMCALGetter::Post Rer -> //" << fTasksFolder << "/Reconstructioner/EMCAL not found!" << endl;
1151 cout <<"INFO: AliEMCALGetter::Post Rer -> Adding //" << fTasksFolder << "/Reconstructioner/EMCAL" << endl;
1153 emcal = new TTask("EMCAL", "") ;
1157 AliEMCALTrackSegmentMaker * emcalts =
1158 dynamic_cast<AliEMCALTrackSegmentMaker*>(emcal->GetListOfTasks()->FindObject(tsmaker->GetName())) ;
1161 emcal->GetListOfTasks()->Remove(emcalts) ;
1163 emcal->Add(tsmaker) ;
1167 //____________________________________________________________________________
1168 const Bool_t AliEMCALGetter::PostTrackSegmentMaker(const char * name) const
1169 { //------------Track Segment Maker ------------------------------
1171 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1173 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1176 cerr << "ERROR: AliEMCALGetter::Post Ter -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1180 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1183 cout <<"WARNING: AliEMCALGetter::Post Ter -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
1184 cout <<"INFO: AliEMCALGetter::Post Ter -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1186 emcal = new TTask("EMCAL", "") ;
1190 TList * l = emcal->GetListOfTasks() ;
1195 while((task = static_cast<TTask *>(it.Next()) )){
1196 TString taskname(task->GetName()) ;
1197 if(taskname.BeginsWith(tsn))
1201 AliEMCALTrackSegmentMakerv1 * emcalts = new AliEMCALTrackSegmentMakerv1() ;
1203 emcalts->SetName(tsn) ;
1204 emcalts->SetTitle(fHeaderFile) ;
1205 emcal->Add(emcalts) ;
1213 //____________________________________________________________________________
1214 TObject ** AliEMCALGetter::TSMakerRef(const char * name) const
1215 { //------------Track Segment Maker ------------------------------
1217 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1220 cerr << "ERROR: AliEMCALGetter::TSLakerRef TerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1224 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1226 cerr <<"WARNING: AliEMCALGetter::TSMakerRef TerRef -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
1230 TList * l = emcal->GetListOfTasks() ;
1234 TString tsmname(name) ;
1236 while((task = static_cast<TTask *>(it.Next()) )){
1237 TString taskname(task->GetName()) ;
1238 if(taskname.BeginsWith(tsmname)){
1245 return l->GetObjectRef(tsm) ;
1247 cerr << "ERROR: AliEMCALGetter::TSLakerRef -> task " << task->GetName() << " not found! " << endl ;
1252 //____________________________________________________________________________
1253 const Bool_t AliEMCALGetter::PostRecParticles(const char * name) const
1254 { // -------------------- RecParticles ------------------------
1256 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1258 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
1260 if ( !emcalFolder ) {
1262 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/ not found!" << endl;
1263 cout << "INFO: AliEMCALGetter::Post Rpa -> Adding Folder //" << fRecoFolder << "/EMCAL/" << endl;
1265 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
1268 TFolder * emcalRPaFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("RecParticles")) ;
1269 if ( !emcalRPaFolder ) {
1271 cout << "WARNING: AliEMCALGetter::Post RPa -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1272 cout << "INFO: AliEMCALGetter::Post RPa -> Adding Folder //" << fRecoFolder << "/EMCAL/RecParticles/" << endl;
1274 emcalRPaFolder = emcalFolder->AddFolder("RecParticles", "RecParticles from EMCAL") ;
1277 TObject * rps = emcalRPaFolder->FindObject( name ) ;
1279 TClonesArray * rp = new TClonesArray("AliEMCALRecParticle",100) ;
1281 emcalRPaFolder->Add(rp) ;
1286 //____________________________________________________________________________
1287 TObject ** AliEMCALGetter::RecParticlesRef(const char * name) const
1288 { // ---------------RecParticles -----------------------------------
1290 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TrackSegments/name
1292 if ( !fRecoFolder ) {
1293 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder//" << fRecoFolder << " not found!" << endl;
1297 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
1298 if ( !emcalFolder ) {
1299 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> Folder //" << fRecoFolder << "/EMCAL/RecParticles/ not found!" << endl;
1303 TObject * tss = emcalFolder->FindObject(name) ;
1305 cerr << "ERROR: AliEMCALGetter::RecParticlesRef -> object " << name << " not found! " << endl ;
1308 return emcalFolder->GetListOfFolders()->GetObjectRef(tss) ;
1311 //____________________________________________________________________________
1312 const Bool_t AliEMCALGetter::PostPID(AliEMCALPID * pid) const
1313 { // ------------AliEMCAL PID -----------------------------
1315 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1318 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1322 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1325 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
1326 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1328 emcal = new TTask("EMCAL", "") ;
1332 AliEMCALPID * emcalpid = dynamic_cast<AliEMCALPID*>(emcal->GetListOfTasks()->FindObject(pid->GetName())) ;
1335 cout << "INFO: AliEMCALGetter::Post Per -> Task " << pid->GetName()
1336 << " already exists" << endl ;
1337 emcal->GetListOfTasks()->Remove(emcalpid) ;
1344 //____________________________________________________________________________
1345 const Bool_t AliEMCALGetter::PostPID(const char * name) const
1347 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1349 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1352 cerr << "ERROR: AliEMCALGetter::Post Per -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1356 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1359 cout <<"WARNING: AliEMCALGetter::Post Per -> //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL not found!" << endl;
1360 cout <<"INFO: AliEMCALGetter::Post Per -> Adding //" << fTasksFolder->GetName() << "/Reconstructioner/EMCAL" << endl;
1362 emcal = new TTask("EMCAL", "") ;
1366 TList * l = emcal->GetListOfTasks() ;
1368 TString pidname(name) ;
1371 while((task = static_cast<TTask *>(it.Next()) )){
1372 TString taskname(task->GetName()) ;
1373 if(taskname.BeginsWith(pidname))
1377 AliEMCALPIDv1 * emcalpid = new AliEMCALPIDv1() ;
1379 emcalpid->SetName(pidname) ;
1380 emcalpid->SetTitle(fHeaderFile) ;
1381 emcal->Add(emcalpid) ;
1386 //____________________________________________________________________________
1387 TObject ** AliEMCALGetter::PIDRef(const char * name) const
1388 { //------------PID ------------------------------
1390 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1393 cerr << "ERROR: AliEMCALGetter::PIDRef PerRef -> Task //" << fTasksFolder->GetName() << "/Reconstructioner not found!" << endl;
1397 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1399 cerr <<"WARNING: AliEMCALGetter::PIDRef PerRef -> //" << fTasksFolder->GetName() << "/ReconstructionerEMCAL not found!" << endl;
1403 TList * l = emcal->GetListOfTasks() ;
1407 TString pidname(name) ;
1409 while((task = static_cast<TTask *>(it.Next()) )){
1410 TString taskname(task->GetName()) ;
1411 if(taskname.BeginsWith(pidname)){
1418 return l->GetObjectRef(pid) ;
1420 cerr << "ERROR: AliEMCALGetter::PIDRef -> task " << task->GetName() << " not found! " << endl ;
1426 //____________________________________________________________________________
1427 const Bool_t AliEMCALGetter::PostQA(void) const
1428 { // ------------------ QA ---------------------------------
1430 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL/alarmsName
1432 TFolder * emcalFolder = dynamic_cast<TFolder*>(fQAFolder->FindObject("EMCAL")) ;
1433 if ( !emcalFolder ) {
1435 cout << "WARNING: AliEMCALGetter::Post Q -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1436 cout << "INFO: AliEMCALGetter::Post Q -> Adding Folder //" << fQAFolder << "/EMCAL/" << endl;
1438 emcalFolder = fQAFolder->AddFolder("EMCAL", "QA from EMCAL") ;
1444 //____________________________________________________________________________
1445 TObject ** AliEMCALGetter::AlarmsRef(void) const
1446 { //------- Alarms ----------------------
1449 // the hierarchy is //Folders/Run/Conditions/QA/EMCAL
1451 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << " not found!" << endl;
1455 TFolder * emcalFolder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
1456 if ( !emcalFolder ) {
1457 cerr << "ERROR: AliEMCALGetter::AlarmsRef QRef -> Folder //" << fQAFolder << "/EMCAL/ not found!" << endl;
1461 return fQAFolder->GetListOfFolders()->GetObjectRef(emcalFolder) ;
1465 //____________________________________________________________________________
1466 TTree * AliEMCALGetter::TreeK(TString filename)
1469 // returns TreeK from file filename
1470 // usefull in case of split file
1472 if ( filename.IsNull() )
1473 filename = fHeaderFile ;
1476 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1477 if (file && (filename != fHeaderFile) ) { // file already open
1481 file = TFile::Open(filename.Data(), "read") ;
1482 fAlice = static_cast<AliRun *>(file->Get("gAlice")) ;
1483 TString treeName("TreeK") ;
1484 treeName += EventNumber() ;
1485 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1486 if (!tree && fDebug)
1487 cout << "WARNING: AliEMCALGetter::TreeK -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
1492 //____________________________________________________________________________
1493 TTree * AliEMCALGetter::TreeH(TString filename)
1496 // returns TreeH from file filename
1497 // usefull in case of split file
1499 if ( filename.IsNull() )
1500 filename = fHeaderFile ;
1503 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1504 if (!file) { // file not open yet
1505 file = TFile::Open(filename.Data(), "read") ;
1507 TString treeName("TreeH") ;
1508 treeName += EventNumber() ;
1509 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1510 if (!tree && fDebug)
1511 cout << "WARNING: AliEMCALGetter::TreeH -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
1516 //____________________________________________________________________________
1517 TTree * AliEMCALGetter::TreeS(TString filename)
1520 // returns TreeS from file filename
1521 // usefull in case of split file
1523 if ( filename.IsNull() )
1524 filename = fHeaderFile ;
1527 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1528 if (!file) { // file not open yet
1529 file = TFile::Open(filename.Data(), "read") ;
1531 TString treeName("TreeS") ;
1532 treeName += EventNumber() ;
1533 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1534 if (!tree && fDebug)
1535 cout << "WARNING: AliEMCALGetter::TreeS -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
1540 //____________________________________________________________________________
1541 TTree * AliEMCALGetter::TreeD(TString filename)
1544 // returns TreeD from file filename
1545 // usefull in case of split file
1547 if ( filename.IsNull() )
1548 filename = fHeaderFile ;
1551 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1552 if (!file) { // file not open yet
1553 file = TFile::Open(filename.Data(), "read") ;
1555 TString treeName("TreeD") ;
1556 treeName += EventNumber() ;
1557 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1558 if (!tree && fDebug)
1559 cout << "WARNING: AliEMCALGetter::TreeD -> " << treeName.Data() << " not found in " << filename.Data() << endl ;
1564 //____________________________________________________________________________
1565 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1567 // Return primary particle numbered by <index>
1573 p = fAlice->Particle(index) ;
1575 p = gAlice->Particle(index) ;
1581 //____________________________________________________________________________
1582 const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
1584 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1592 Int_t daughterIndex = p->GetDaughter(index-1) ;
1593 return gAlice->Particle(daughterIndex) ;
1599 //____________________________________________________________________________
1600 Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
1602 // Read the digit tree gAlice->TreeD()
1606 TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
1608 file = TFile::Open(fDigitsFileName) ;
1609 // Get Digits Tree header from file
1610 TString treeName("TreeD") ;
1612 treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1613 if(!treeD){ // TreeD not found in header file
1615 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeD in " << fDigitsFileName.Data() << endl;
1620 treeD = gAlice->TreeD() ;
1622 TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
1624 TBranch * branch = 0 ;
1625 TBranch * digitsbranch = 0 ;
1626 TBranch * digitizerbranch = 0 ;
1627 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1629 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1630 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1631 digitsbranch = branch ;
1632 emcalfound = kTRUE ;
1634 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1635 digitizerbranch = branch ;
1636 digitizerfound = kTRUE ;
1640 if ( !emcalfound || !digitizerfound ) {
1642 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name "
1643 << fDigitsTitle << endl ;
1648 if(!Digits(fDigitsTitle) )
1649 PostDigits(fDigitsTitle);
1650 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1651 digitsbranch->GetEntry(0) ;
1654 // read the Digitizer
1655 RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
1656 if(!Digitizer(fDigitsTitle))
1657 PostDigitizer(fDigitsTitle) ;
1658 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1659 digitizerbranch->GetEntry(0) ;
1662 if(gAlice->TreeD()!=treeD)
1667 //____________________________________________________________________________
1668 Int_t AliEMCALGetter::ReadTreeH()
1670 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1672 TTree * treeH = gAlice->TreeH() ;
1674 if(!treeH) {// TreeH not found in header file
1677 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find TreeH in " << fHeaderFile << endl ;
1679 TString searchFileName("EMCAL.HITS") ;
1680 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1681 searchFileName+="." ;
1682 searchFileName += fBranchTitle ;
1684 searchFileName+=".root" ;
1686 if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
1688 cout << "INFO: AliEMCALGetter::ReadTreeH -> TreeH found in " << searchFileName.Data() << endl ;
1691 cerr << "ERROR: AliEMCALGetter::ReadTreeH -> TreeH not found " << endl ;
1696 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1697 if ( !hitsbranch ) {
1699 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1705 if (hitsbranch->GetEntries() > 1 ) {
1706 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1707 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1708 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1709 hitsbranch->SetAddress(&tempo) ;
1712 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1713 hitsbranch->GetEntry(i) ;
1715 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1716 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1717 new((*hits)[index]) AliEMCALHit( *hit ) ;
1724 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1725 hitsbranch->SetAddress(HitsRef()) ;
1726 hitsbranch->GetEntry(0) ;
1731 //____________________________________________________________________________
1732 void AliEMCALGetter::Track(Int_t itrack)
1734 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1736 if(gAlice->TreeH()== 0){
1737 cerr << "ERROR: AliEMCALGetter::ReadTreeH: -> Cannot read TreeH " << endl ;
1741 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1742 if ( !hitsbranch ) {
1744 cout << "WARNING: AliEMCALGetter::ReadTreeH -> Cannot find branch EMCAL" << endl ;
1750 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1751 hitsbranch->SetAddress(HitsRef()) ;
1752 hitsbranch->GetEntry(itrack) ;
1756 //____________________________________________________________________________
1757 void AliEMCALGetter::ReadTreeQA()
1760 cout << "WARNING : " << ClassName() << "::ReadTreeQA -> not implemented" << endl ;
1761 // Read the digit tree gAlice->TreeQA()
1762 // so far only EMCAL knows about this Tree
1764 // if(EMCAL()->TreeQA()== 0){
1765 // cerr << "ERROR: AliEMCALGetter::ReadTreeQA: can not read TreeQA " << endl ;
1769 // TBranch * qabranch = EMCAL()->TreeQA()->GetBranch("EMCAL") ;
1772 // cout << "WARNING: AliEMCALGetter::ReadTreeQA -> Cannot find QA Alarms for EMCAL" << endl ;
1779 // qabranch->SetAddress(AlarmsRef()) ;
1781 // qabranch->GetEntry(0) ;
1783 // PostQA("EMCAL") ;
1784 // TFolder * alarmsF = Alarms() ;
1785 // alarmsF->Clear() ;
1786 // qabranch->SetAddress(&alarmsF) ;
1787 // qabranch->GetEntry(0) ;
1791 //____________________________________________________________________________
1792 Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
1794 // Read the reconstrunction tree gAlice->TreeR()
1795 // A particularity has been introduced here :
1796 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1797 // being for example give in AliPHOSPID(fileName, title)
1798 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1799 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1800 // from a given set of TrackSegments (with a given name)
1801 // This is why any is NOT used to read the branch of RecParticles
1802 // any migh have become obsolete : to be checked
1803 // See AliEMCALPIDv1
1807 TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
1809 file = TFile::Open(fRecPointsFileName) ;
1810 // Get Digits Tree header from file
1811 TString treeName("TreeR") ;
1813 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1814 if(!treeR){ // TreeR not found in header file
1816 cout << "WARNING: AliEMCALGetter::ReadTreeD -> Cannot find TreeR in " << fRecPointsFileName.Data() << endl;
1821 treeR = gAlice->TreeR() ;
1824 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
1826 TBranch * branch = 0 ;
1827 TBranch * towerbranch = 0 ;
1828 TBranch * preshowerbranch = 0 ;
1829 TBranch * clusterizerbranch = 0 ;
1830 Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
1833 while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1834 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
1835 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1836 towerbranch = branch ;
1837 emcalTowerRPfound = kTRUE ;
1839 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1840 preshowerbranch = branch ;
1841 emcalPreShoRPfound = kTRUE ;
1843 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1844 clusterizerbranch = branch ;
1845 clusterizerfound = kTRUE ;
1850 if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
1852 cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecPoints and/or Clusterizer with name "
1853 << fRecPointsTitle << endl ;
1856 if(!TowerRecPoints(fRecPointsTitle) )
1857 PostRecPoints(fRecPointsTitle) ;
1859 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1860 towerbranch->GetEntry(0) ;
1862 preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
1863 preshowerbranch->GetEntry(0) ;
1865 if(!Clusterizer(fRecPointsTitle) )
1866 PostClusterizer(fRecPointsTitle) ;
1868 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1869 clusterizerbranch->GetEntry(0) ;
1872 // //------------------- TrackSegments ---------------------
1874 // TBranch * tsbranch = 0 ;
1875 // TBranch * tsmakerbranch = 0 ;
1876 // Bool_t emcaltsfound = kFALSE, tsmakerfound = kFALSE ;
1877 // while ( (branch = static_cast<TBranch*>(next())) && (!emcaltsfound || !tsmakerfound) ) {
1878 // if(strcmp(branch->GetTitle(), fTrackSegmentsTitle)==0 ) {
1879 // if ( strcmp(branch->GetName(), "EMCALTS")==0){
1880 // tsbranch = branch ;
1881 // emcaltsfound = kTRUE ;
1883 // else if(strcmp(branch->GetName(), "AliEMCALTrackSegmentMaker")==0) {
1884 // tsmakerbranch = branch ;
1885 // tsmakerfound = kTRUE ;
1890 // if ( !emcaltsfound || !tsmakerfound ) {
1892 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find TrackSegments and/or TrackSegmentMaker with name "
1893 // << fTrackSegmentsTitle << endl ;
1895 // // Read and Post the TrackSegments
1896 // if(!TrackSegments(fTrackSegmentsTitle))
1897 // PostTrackSegments(fTrackSegmentsTitle) ;
1898 // tsbranch->SetAddress(TrackSegmentsRef(fTrackSegmentsTitle)) ;
1899 // tsbranch->GetEntry(0) ;
1901 // // Read and Post the TrackSegment Maker
1902 // if(!TrackSegmentMaker(fTrackSegmentsTitle))
1903 // PostTrackSegmentMaker(fTrackSegmentsTitle) ;
1904 // tsmakerbranch->SetAddress(TSMakerRef(fTrackSegmentsTitle)) ;
1905 // tsmakerbranch->GetEntry(0) ;
1909 // //------------ RecParticles ----------------------------
1911 // TBranch * rpabranch = 0 ;
1912 // TBranch * pidbranch = 0 ;
1913 // Bool_t emcalrpafound = kFALSE, pidfound = kFALSE ;
1915 // while ( (branch = static_cast<TBranch*>(next())) && (!emcalrpafound || !pidfound) )
1916 // if(strcmp(branch->GetTitle(), fRecParticlesTitle)==0) {
1917 // if ( strcmp(branch->GetName(), "EMCALRP")==0) {
1918 // rpabranch = branch ;
1919 // emcalrpafound = kTRUE ;
1921 // else if (strcmp(branch->GetName(), "AliEMCALPID")==0) {
1922 // pidbranch = branch ;
1923 // pidfound = kTRUE ;
1927 // if ( !emcalrpafound || !pidfound ) {
1929 // cout << "WARNING: AliEMCALGetter::ReadTreeR -> Cannot find RecParticles and/or PID with name "
1930 // << fRecParticlesTitle << endl ;
1932 // // Read and Post the RecParticles
1933 // if(!RecParticles(fRecParticlesTitle))
1934 // PostRecParticles(fRecParticlesTitle) ;
1935 // rpabranch->SetAddress(RecParticlesRef(fRecParticlesTitle)) ;
1936 // rpabranch->GetEntry(0) ;
1937 // // Read and Post the PID
1938 // if(!PID(fRecParticlesTitle))
1939 // PostPID(fRecParticlesTitle) ;
1940 // pidbranch->SetAddress(PIDRef(fRecParticlesTitle)) ;
1941 // pidbranch->GetEntry(0) ;
1944 if(gAlice->TreeR()!=treeR)
1949 //____________________________________________________________________________
1950 Int_t AliEMCALGetter::ReadTreeS(Int_t event)
1952 // Reads the SDigits treeS from all files
1953 // Files, which should be opened are listed in emcalF
1954 // So, first get list of files
1955 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1957 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1958 TCollection * folderslist = emcalF->GetListOfFolders() ;
1960 // Now iterate over the list of files and read TreeS into Whiteboard
1961 TIter next(folderslist) ;
1962 TFolder * folder = 0 ;
1965 while ( (folder = static_cast<TFolder*>(next())) ) {
1966 TString fileName("") ;
1968 fileName = folder->GetTitle() ;
1970 fileName = folder->GetName() ;
1971 fileName.ReplaceAll("_","/") ;
1972 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1974 file = TFile::Open(fileName) ;
1975 // Get SDigits Tree header from file
1976 TString treeName("TreeS") ;
1978 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1980 if(!treeS){ // TreeS not found in header file
1982 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Cannot find TreeS in " << fileName.Data() << endl;
1986 //set address of the SDigits and SDigitizer
1987 TBranch * sdigitsBranch = 0;
1988 TBranch * sdigitizerBranch = 0;
1989 TBranch * branch = 0 ;
1990 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1992 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1994 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1995 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1996 emcalfound = kTRUE ;
1997 sdigitsBranch = branch ;
2000 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
2001 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
2002 sdigitizerfound = kTRUE ;
2003 sdigitizerBranch = branch ;
2006 if ( !emcalfound || !sdigitizerfound ) {
2008 cout << "WARNING: AliEMCALDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName()
2009 << " not found" << endl ;
2013 if ( !folder->FindObject(fSDigitsTitle) )
2014 PostSDigits(fSDigitsTitle,folder->GetName()) ;
2016 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
2017 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
2018 sdigitsBranch->GetEntry(0) ;
2020 TString sdname(fSDigitsTitle) ;
2022 sdname+=folder->GetName() ;
2023 if(!SDigitizer(sdname) )
2024 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
2025 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2026 sdigitizerBranch->GetEntry(0) ;
2027 if(gAlice->TreeS()!=treeS)
2033 //____________________________________________________________________________
2034 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
2035 { // Read the summable digits fron treeS()
2038 TString filename("mergefile") ;
2041 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2042 if ( !emcalFolder ) {
2043 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
2045 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
2046 //set address of the SDigits and SDigitizer
2047 TBranch * sdigitsBranch = 0;
2048 TBranch * sdigitizerBranch = 0;
2049 TBranch * branch = 0 ;
2050 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
2052 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
2054 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
2055 if ( strcmp(branch->GetName(), "EMCAL")==0) {
2056 emcalfound = kTRUE ;
2057 sdigitsBranch = branch ;
2060 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
2061 sdigitizerfound = kTRUE ;
2062 sdigitizerBranch = branch ;
2065 if ( !emcalfound || !sdigitizerfound ) {
2067 cout << "WARNING: AliEMCALGetter::ReadTreeS -> Digits and/or Digitizer branch not found" << endl ;
2071 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
2072 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
2074 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
2075 sdigitsBranch->GetEntry(0) ;
2077 TString sdname(sdigitsBranch->GetTitle()) ;
2081 if(!SDigitizer(sdigitsBranch->GetTitle()) )
2082 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
2083 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
2084 sdigitizerBranch->GetEntry(0) ;
2085 if(gAlice->TreeS()!=treeS)
2090 //____________________________________________________________________________
2091 void AliEMCALGetter::ReadPrimaries()
2093 // Reads specific branches of primaries
2095 TClonesArray * ar = 0 ;
2096 if(! (ar = Primaries()) ) {
2102 if (TreeK(fHeaderFile)) { // treeK found in header file
2104 cout << "INFO: AliEMCALGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ;
2105 fNPrimaries = gAlice->GetNtrack() ;
2108 } else { // treeK not found in header file
2110 cerr << "ERROR: AliEMCALGetter::ReadPrimaries -> TreeK not found " << endl ;
2115 for (index = 0 ; index < fNPrimaries; index++) {
2116 new ((*ar)[index]) TParticle(*(Primary(index)));
2120 //____________________________________________________________________________
2121 void AliEMCALGetter::Event(const Int_t event, const char* opt)
2123 // Reads the content of all Tree's S, D and R
2125 if (event >= gAlice->TreeE()->GetEntries() ) {
2126 cerr << "ERROR: AliEMCALGetter::Event -> " << event << " not found in TreeE!" << endl ;
2130 Bool_t any = kFALSE ;
2131 if (strstr(opt,"A") ) // do not check the title of the branches
2134 gAlice->GetEvent(event) ;
2136 if( strstr(opt,"R") )
2139 if( strstr(opt,"D") )
2142 if(strstr(opt,"S") )
2145 if(strstr(opt,"H") )
2148 if( strstr(opt,"Q") )
2151 if( strstr(opt,"P") || (strcmp(opt,"")==0) )
2156 //____________________________________________________________________________
2157 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
2159 // get the object named "what" from the folder
2160 // folders are named like //Folders
2162 if ( file.IsNull() )
2163 file = fHeaderFile ;
2165 TFolder * folder = 0 ;
2166 TObject * emcalO = 0 ;
2168 if ( what.CompareTo("Primaries") == 0 ) {
2169 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
2171 emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
2175 else if ( what.CompareTo("Hits") == 0 ) {
2176 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
2178 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
2180 else if ( what.CompareTo("SDigits") == 0 ) {
2181 file.ReplaceAll("/","_") ;
2182 TString path = "EMCAL/" + file ;
2183 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
2186 name = fSDigitsTitle ;
2187 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2190 else if ( what.CompareTo("Digits") == 0 ){
2191 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
2194 name = fDigitsTitle ;
2195 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2198 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
2199 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2202 name = fRecPointsTitle ;
2203 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2206 else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
2207 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2210 name = fRecPointsTitle ;
2211 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2215 else if ( what.CompareTo("TrackSegments") == 0 ) {
2216 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2219 name = fTrackSegmentsTitle ;
2220 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2223 else if ( what.CompareTo("RecParticles") == 0 ) {
2224 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2227 name = fRecParticlesTitle ;
2228 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2231 else if ( what.CompareTo("Alarms") == 0 ){
2233 emcalO = dynamic_cast<TObject *>(fQAFolder->FindObject("EMCAL")) ;
2235 folder = dynamic_cast<TFolder *>(fQAFolder->FindObject("EMCAL")) ;
2239 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
2245 cout << "WARNING : AliEMCALGetter::ReturnO -> Object " << what << " not found in " << folder->GetName() << endl ;
2252 //____________________________________________________________________________
2253 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
2255 // get the TTask named "what" from the folder
2256 // folders are named like //Folders/Tasks/what/EMCAL/name
2258 TString search(what) ;
2259 if ( what.CompareTo("Clusterizer") == 0 )
2260 search = "Reconstructioner" ;
2261 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
2262 search = "Reconstructioner" ;
2263 else if ( what.CompareTo("PID") == 0 )
2264 search = "Reconstructioner" ;
2265 else if ( what.CompareTo("QATasks") == 0 )
2268 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
2271 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << " not found!" << endl ;
2275 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
2277 cerr << "ERROR: AliEMCALGetter::ReturnT -> Task " << what << "/EMCAL not found!" << endl ;
2281 TList * list = emcalT->GetListOfTasks() ;
2283 if (what.CompareTo("SDigitizer") == 0) {
2284 if ( name.IsNull() )
2285 name = fSDigitsTitle ;
2286 } else if (what.CompareTo("Digitizer") == 0){
2287 if ( name.IsNull() )
2288 name = fDigitsTitle ;
2289 } else if (what.CompareTo("Clusterizer") == 0){
2290 if ( name.IsNull() )
2291 name = fRecPointsTitle ;
2292 name.Append(":clu") ;
2294 // else if (what.CompareTo("TrackSegmentMaker") == 0){
2295 // if ( name.IsNull() )
2296 // name = fTrackSegmentsTitle ;
2297 // name.Append(":tsm") ;
2299 // else if (what.CompareTo("PID") == 0){
2300 // if ( name.IsNull() )
2301 // name = fRecParticlesTitle ;
2302 // name.Append(":pid") ;
2304 // else if (what.CompareTo("QATasks") == 0){
2305 // if ( name.IsNull() )
2311 while((task = static_cast<TTask *>(it.Next()) )){
2312 TString taskname(task->GetName()) ;
2313 if(taskname.BeginsWith(name)){
2318 cout << "WARNING: AliEMCALGetter::ReturnT -> Task " << search << "/" << name << " not found!" << endl ;
2322 //____________________________________________________________________________
2323 void AliEMCALGetter::RemoveTask(TString opt, TString name) const
2325 // remove a task from the folder
2326 // path is fTasksFolder/SDigitizer/EMCAL/name
2330 TList * lofTasks = 0 ;
2332 if (opt == "S") { // SDigitizer
2333 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2337 else if (opt == "D") { // Digitizer
2338 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2342 else if (opt == "C") { // Clusterizer
2343 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2348 cerr << "WARNING: AliEMCALGetter::RemoveTask -> Unknown option " << opt.Data() << endl ;
2351 emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2354 lofTasks = emcal->GetListOfTasks() ;
2357 TObject * obj = lofTasks->FindObject(name) ;
2359 lofTasks->Remove(obj) ;
2363 //____________________________________________________________________________
2364 void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
2366 // remove SDigits from the folder
2367 // path is fSDigitsFolder/fHeaderFileName/name
2369 TFolder * emcal = 0 ;
2370 TFolder * emcalmain = 0 ;
2372 if (opt == "H") { // Hits
2373 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2379 else if ( opt == "S") { // SDigits
2380 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2383 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2388 else if (opt == "D") { // Digits
2389 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2394 else if (opt == "RT") { // Tower RecPoints
2395 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2400 else if (opt == "RP") { // Preshower RecPoints
2401 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2406 else if (opt == "T") { // TrackSegments
2407 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2412 else if (opt == "P") { // RecParticles
2413 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2419 cerr << "WARNING: AliEMCALGetter::RemoveObjects -> Unknown option " << opt.Data() << endl ;
2423 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
2431 emcalmain->Remove(emcal) ;
2435 //____________________________________________________________________________
2436 void AliEMCALGetter::RemoveSDigits() const
2438 TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2446 //____________________________________________________________________________
2447 void AliEMCALGetter::CleanWhiteBoard(void){
2449 TFolder * emcalmain = 0 ;
2452 TList * lofTasks = 0 ;
2454 TTask * emcalt = 0 ;
2457 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2459 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
2468 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2470 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2472 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
2479 emcalmain->Remove(emcal) ;
2484 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2486 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
2496 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2498 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2507 // PreShowerRecPoints
2508 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2510 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2520 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2522 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
2533 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2535 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
2544 //---- Now Tasks -----------
2547 TString sdname(fSDigitsTitle);
2550 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2552 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2554 lofTasks = emcalt->GetListOfTasks() ;
2556 obj = lofTasks->FindObject(sdname.Data()) ;
2558 lofTasks->Remove(obj) ;
2564 sdname.Append(":") ;
2565 // Clusterizer, TrackSegmentMaker, PID
2566 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2568 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2570 lofTasks = emcalt->GetListOfTasks() ;
2571 TIter next(lofTasks);
2572 while((obj=next())){
2573 TString oname(obj->GetName()) ;
2574 if (oname.BeginsWith(sdname)){
2575 lofTasks->Remove(obj) ;
2583 sdname.Append(fHeaderFile) ;
2584 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2586 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2588 lofTasks = emcalt->GetListOfTasks() ;
2590 obj = lofTasks->FindObject(sdname.Data()) ;
2592 lofTasks->Remove(obj) ;
2598 //____________________________________________________________________________
2599 void AliEMCALGetter::SetTitle(const char * branchTitle )
2601 fBranchTitle = branchTitle ;
2602 fSDigitsTitle = branchTitle ;
2603 fDigitsTitle = branchTitle ;
2604 fRecPointsTitle = branchTitle ;
2605 fRecParticlesTitle = branchTitle ;
2606 fTrackSegmentsTitle = branchTitle ;
2608 //First - extract full path if necessary
2609 TString sFileName(fHeaderFile) ;
2610 Ssiz_t islash = sFileName.Last('/') ;
2611 if(islash<sFileName.Length())
2612 sFileName.Remove(islash+1,sFileName.Length()) ;
2615 //Now construct file names
2616 fSDigitsFileName = sFileName ;
2617 fDigitsFileName = sFileName ;
2618 fRecPointsFileName = sFileName ;
2619 fRecParticlesFileName = sFileName ;
2620 fTrackSegmentsFileName = sFileName ;
2621 fSDigitsFileName += "EMCAL.SDigits." ;
2622 fDigitsFileName += "EMCAL.Digits." ;
2623 fRecPointsFileName += "EMCAL.RecData." ;
2624 fTrackSegmentsFileName+= "EMCAL.RecData." ;
2625 fRecParticlesFileName += "EMCAL.RecData." ;
2626 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2627 fSDigitsFileName += fBranchTitle ;
2628 fSDigitsFileName += "." ;
2629 fDigitsFileName += fBranchTitle ;
2630 fDigitsFileName += "." ;
2631 fRecPointsFileName += fBranchTitle ;
2632 fRecPointsFileName += "." ;
2633 fRecParticlesFileName += fBranchTitle ;
2634 fRecParticlesFileName += "." ;
2635 fTrackSegmentsFileName+= fBranchTitle ;
2636 fTrackSegmentsFileName+= "." ;
2638 fSDigitsFileName += "root" ;
2639 fDigitsFileName += "root" ;
2640 fRecPointsFileName += "root" ;
2641 fRecParticlesFileName += "root" ;
2642 fTrackSegmentsFileName+= "root" ;
2644 fSDigitsFileName = "" ;
2645 fDigitsFileName = "" ;
2646 fRecPointsFileName = "" ;
2647 fRecParticlesFileName = "" ;
2648 fTrackSegmentsFileName = "" ;
2650 TFolder * emcalFolder ;
2651 emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2653 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
2655 emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2657 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
2659 //Make folder for SDigits
2660 TString subdir(fHeaderFile) ;
2661 subdir.ReplaceAll("/","_") ;
2662 emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
2665 emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2667 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
2669 emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
2671 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
2675 //____________________________________________________________________________
2676 void AliEMCALGetter::CloseSplitFiles(void){
2678 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2681 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2684 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2687 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2690 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;