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 **************************************************************************/
18 29.05.2001 Yuri Kharlov:
19 Everywhere reading the treese TTree->GetEvent(i)
20 is replaced by reading the branches TBranch->GetEntry(0)
24 08.2002 Dmitri Peressounko:
27 //_________________________________________________________________________
28 // A singleton. This class should be used in the analysis stage to get
29 // reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
30 // instead of directly reading them from galice.root file. This container
31 // ensures, that one reads Digits, made of these particular digits, RecPoints,
32 // made of these particular RecPoints, TrackSegments and RecParticles.
33 // This becomes non trivial if there are several identical branches, produced with
34 // different set of parameters.
36 // An example of how to use (see also class AliEMCALAnalyser):
37 // AliEMCALGetter * gime = AliEMCALGetter::GetInstance("galice.root","test") ;
38 // for(Int_t irecp = 0; irecp < gime->NRecParticles() ; irecp++)
39 // AliEMCALRecParticle * part = gime->RecParticle(1) ;
41 // please->GetEvent(event) ; // reads new event from galice.root
43 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
44 //*-- Completely redesigned by Dmitri Peressounko March 2001
46 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
47 //*-- systematic usage of TFolders without changing the interface
48 //*-- YS August 2002 : clone PHOS as closely as possible and intoduction
49 // of new IO (à la PHOS)
51 //////////////////////////////////////////////////////////////////////////////
55 // --- ROOT system ---
60 #include "TObjString.h"
62 #include "TParticle.h"
64 // --- Standard library ---
66 #include <Riostream.h>
68 // --- AliRoot header files ---
71 #include "AliConfig.h"
72 #include "AliEMCALGetter.h"
74 #include "AliEMCALDigitizer.h"
75 #include "AliEMCALSDigitizer.h"
76 #include "AliEMCALClusterizerv1.h"
77 #include "AliEMCALGeometry.h"
79 ClassImp(AliEMCALGetter)
81 AliEMCALGetter * AliEMCALGetter::fgObjGetter = 0 ;
82 TFile * AliEMCALGetter::fFile = 0 ;
84 //____________________________________________________________________________
86 AliEMCALGetter::AliEMCALGetter(const char* headerFile, const char* branchTitle, const Bool_t toSplit)
88 // This is the ctor called by GetInstance and the only one that can be used
90 if ( fHeaderFile.Contains("_") ) {
91 Fatal("AliEMCALGetter","Invalid file name (_ not allowed) %s",fHeaderFile.Data()) ;
101 fHeaderFile = headerFile ;
103 fPrimaries = new TObjArray(1) ;
105 fModuleFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Configuration/Modules"));
106 fPrimariesFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data"));
107 fHitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/Hits"));
108 fSDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/RunMC/Event/Data/SDigits"));
109 fDigitsFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/Data"));
110 fRecoFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Event/RecData"));
111 //fQAFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Run/Conditions/QA"));
112 fTasksFolder = dynamic_cast<TFolder*>(gROOT->FindObjectAny("Folders/Tasks")) ;
114 //Set titles to branches and create EMCAL specific folders
116 SetTitle(branchTitle) ;
118 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
122 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
124 if(!fFile){ //if file was not opened yet, read gAlice
125 fFile = TFile::Open(fHeaderFile.Data(), "update") ;
126 if (!fFile->IsOpen()) {
127 Error("AliEMCALGetter","Cannot open %s",fHeaderFile.Data()) ;
132 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
136 Error("AliEMCALGetter","Cannot find gAlice in %s",fHeaderFile.Data()) ;
142 Info("AliEMCALGetter","Posting EMCAL to Folders") ;
144 if (gAlice->GetDetector("EMCAL")) {
145 AliConfig * conf = AliConfig::Instance() ;
146 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
147 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
150 Error("AliEMCALGetter"," Detector EMCAL not found");
156 //____________________________________________________________________________
158 AliEMCALGetter::~AliEMCALGetter()
161 fPrimaries->Delete() ;
165 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
166 TCollection * folderslist = emcalF->GetListOfFolders() ;
167 TIter next(folderslist) ;
168 TFolder * folder = 0 ;
170 while ( (folder = static_cast<TFolder*>(next())) )
171 emcalF->Remove(folder) ;
182 //____________________________________________________________________________
184 void AliEMCALGetter::CloseFile()
192 //____________________________________________________________________________
194 const TFolder * AliEMCALGetter::Folder(const TString what) const {
196 // returns the EMCAL folder required by what
197 // what = hits, sdigits, digits
199 if ( what == "hits" )
200 return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
201 else if ( what == "sdigits" )
202 return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
203 else if ( what == "digits" )
204 return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
206 Error("GetFolder","%s illegal option (hits, sdigits, digits) ", what.Data()) ;
211 //____________________________________________________________________________
213 AliEMCALGetter * AliEMCALGetter::GetInstance()
215 // Returns the pointer of the unique instance already defined
225 //____________________________________________________________________________
227 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
228 const char* branchTitle,
229 const Bool_t toSplit)
231 // Creates and returns the pointer of the unique instance
232 // Must be called only when the environment has changed
235 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
236 if(fgObjGetter->fFailed)
242 //First checks, if header file already opened
244 if(!fgObjGetter->fFile){
245 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
246 if(fgObjGetter->fFailed)
252 if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
253 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
254 (toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
256 else{ //Clean all data and AliEMCAL...zers
257 if(fgObjGetter->fToSplit)
258 fgObjGetter->CloseSplitFiles() ;
259 //fgObjGetter->CleanWhiteBoard() ;
260 fgObjGetter->fToSplit = toSplit ;
261 fgObjGetter->SetTitle(branchTitle) ;
264 else{ //Close already opened files, clean memory and open new header file
265 if(gAlice){ //should first delete gAlice, then close file
266 //Should be in dtor of EMCAL, but if one changes path ...
267 fgObjGetter->fModuleFolder->Remove(fgObjGetter->fModuleFolder->FindObject("EMCAL")) ;
270 if(fgObjGetter->fFile){
271 fgObjGetter->fFile->Close() ;
272 fgObjGetter->fFile=0;
274 if(fgObjGetter->fToSplit)
275 fgObjGetter->CloseSplitFiles() ;
276 fgObjGetter->CleanWhiteBoard() ;
277 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
284 //____________________________________________________________________________
286 const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
288 //Looks in the tree Tree"name" if branch with current name olready exists
290 TString filename("") ;
291 TString name, dataname, zername;
292 if(recName == "SDigits"){
293 filename=fSDigitsFileName ;
296 zername = "AliEMCALSDigitizer" ;
298 else if(recName == "Digits"){
299 filename=fDigitsFileName ;
302 zername = "AliEMCALDigitizer" ;
304 else if(recName =="RecPoints"){
305 filename=fRecPointsFileName ;
307 dataname = "EMCALEmcRP" ;
308 zername = "AliEMCALClusterizer" ;
310 else if(recName == "TrackSegments"){
311 filename=fTrackSegmentsFileName ;
313 dataname = "EMCALTS" ;
314 zername = "AliEMCALTrackSegmentMaker" ;
316 else if(recName == "RecParticles"){
317 filename= fRecParticlesFileName ;
319 dataname = "EMCALRP" ;
320 zername = "AliEMCALPID" ;
328 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
330 file = TFile::Open(fSDigitsFileName.Data(),"update");
335 tree = (TTree *)file->Get(name.Data()) ;
340 TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
342 TBranch * branch = 0 ;
343 TString titleName(fBranchTitle);
346 while ((branch = (static_cast<TBranch*>(next())))) {
347 TString branchName(branch->GetName() ) ;
348 TString branchTitle(branch->GetTitle() ) ;
349 if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
350 Warning("BranchExists", "branch %s with title %s already exits in %s", dataname.Data(), fBranchTitle.Data(), name.Data());
354 if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
355 Warning("BranchExists","Branch AliEMCAL... with title %s already exits in %s",branch->GetTitle(), name.Data());
360 //We can't delete three if gAlice points to it... To be redisigned somehow???!!!
363 if(name.Contains("TreeS"))
364 if(tree!=gAlice->TreeS())
366 if(name.Contains("TreeD"))
367 if(tree!=gAlice->TreeD())
369 if(name.Contains("TreeR"))
370 if(tree!=gAlice->TreeR())
377 //____________________________________________________________________________
379 void AliEMCALGetter::ListBranches(Int_t event) const
381 TBranch * branch = 0 ;
382 if (gAlice->GetEvent(event) == -1)
385 TTree * t = gAlice->TreeH() ;
388 Info("ListBranches"," -> ****** Hits : ");
389 TObjArray * lob = t->GetListOfBranches() ;
392 while ( (branch = static_cast<TBranch*>(next())) )
393 Info("ListBranches"," %s", branch->GetName());
396 Warning("ListBranches"," -> TreeH not found for event %d",event);
398 t = gAlice->TreeS() ;
401 Info("ListBranches"," -> ****** SDigits : ");
402 TObjArray * lob = t->GetListOfBranches() ;
405 while ( (branch = static_cast<TBranch*>(next())) )
406 Info("ListBranches"," %s %s",branch->GetName(),branch->GetTitle());
408 Warning("ListBranches"," -> TreeS not found for event %d",event);
410 t = gAlice->TreeD() ;
413 Info("ListBranches"," -> ****** Digits : ");
414 TObjArray * lob = t->GetListOfBranches() ;
417 while ( (branch = static_cast<TBranch*>(next())) )
418 Info(" %s %s", branch->GetName(), branch->GetTitle());
420 Warning("ListBranches"," -> TreeD not found for event %d", event);
422 t = gAlice->TreeR() ;
425 Info("ListBranches"," -> ****** Recon : ");
426 TObjArray * lob = t->GetListOfBranches() ;
428 while ( (branch = static_cast<TBranch*>(next())) )
429 Info(" %s %s", branch->GetName(), branch->GetTitle());
431 Warning("ListBranches"," -> TreeR not found for event %d",event);
434 //____________________________________________________________________________
436 void AliEMCALGetter::NewBranch(TString name, Int_t event)
438 fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
442 //____________________________________________________________________________
444 Bool_t AliEMCALGetter::NewFile(TString name)
450 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
452 if(!fFile) { //if file was not opened yet, read gAlice
453 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
454 if (!fFile->IsOpen()) {
455 Error("NewFile", " -> Cannot open %s", fHeaderFile.Data());
459 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
463 Error("NewFile"," -> Cannot find gAlice in %s", fHeaderFile.Data());
470 //____________________________________________________________________________
472 const AliEMCAL * AliEMCALGetter::EMCAL()
474 // returns the EMCAL object
476 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;
480 Warning("EMCAL"," -> EMCAL module not found in Folders" );
484 //____________________________________________________________________________
486 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
488 AliEMCALGeometry * rv = 0 ;
490 rv = EMCAL()->GetGeometry() ;
494 //____________________________________________________________________________
496 const Bool_t AliEMCALGetter::PostPrimaries(void) const
498 //------- Primaries ----------------------
499 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
501 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
502 if ( !primariesFolder ) {
504 Warning("PostPrimaries", "-> Folder //%s/Primaries/ not found!", fPrimariesFolder->GetName());
505 Info("PostPrimaries", "-> Adding Folder //%s/Primaries/",fPrimariesFolder->GetName());
507 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
510 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
511 primaries->SetName("Primaries") ;
512 primariesFolder->Add(primaries) ;
517 //____________________________________________________________________________
519 TObject** AliEMCALGetter::PrimariesRef(void) const
521 //------- Primaries ----------------------
522 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
524 if ( !fPrimariesFolder ) {
525 Fatal("PrimariesRef", "-> Folder //%s not found!",fPrimariesFolder);
528 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
530 if ( !primariesFolder ) {
531 Fatal("PrimariesRef", "-> Folder //%s/Primaries/ not found!",fPrimariesFolder);
534 TObject * p = primariesFolder->FindObject("Primaries") ;
537 Fatal("PrimariesRef", "-> %s/Primaries not found !",primariesFolder->GetName());
540 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
543 //____________________________________________________________________________
545 const Bool_t AliEMCALGetter::PostHits(void) const
547 //------- Hits ----------------------
548 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
550 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
552 if ( !emcalFolder ) {
554 Warning("PostHits", "-> Folder //%s/EMCAL/ not found!", fHitsFolder);
555 Info("PostHits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
557 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
560 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
561 hits->SetName("Hits") ;
562 emcalFolder->Add(hits) ;
567 //____________________________________________________________________________
569 TObject ** AliEMCALGetter::HitsRef(void) const
571 //------- Hits ----------------------
572 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
574 if ( !fHitsFolder ) {
575 Error("HitsRef", "-> Folder //%s not found!",fHitsFolder);
579 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
580 if ( !emcalFolder ) {
581 Error("HitsRef", "-> Folder //%s/EMCAL/ not found!",fHitsFolder);
585 TObject * h = emcalFolder->FindObject("Hits") ;
588 Error("HitsRef", "-> %s/Hits not found !",emcalFolder->GetName());
592 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
595 //____________________________________________________________________________
597 const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
599 //---------- SDigits -------------------------
600 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
601 // because you can have sdigits from several hit files for mixing
603 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
605 if ( !emcalFolder ) {
607 Warning("PostSDigits", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
608 Info("PostSDigits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
610 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
613 TString subdir(headerFile) ;
614 subdir.ReplaceAll("/", "_") ;
615 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
616 if ( !emcalSubFolder )
617 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
619 TObject * sd = emcalSubFolder->FindObject(name);
622 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
623 sdigits->SetName(name) ;
624 emcalSubFolder->Add(sdigits) ;
630 //____________________________________________________________________________
632 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
634 //------- SDigits ----------------------
635 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
637 if ( !fSDigitsFolder ) {
638 Fatal("SDigitsRef", "-> Folder //%s not found!", fSDigitsFolder);
641 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
643 if ( !emcalFolder ) {
644 Fatal("SDigitsRef", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
647 TFolder * emcalSubFolder = 0 ;
650 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
652 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
654 if(!emcalSubFolder) {
655 Fatal("SDigitsRef", "-> Folder //Folders/RunMC/Event/Data/EMCAL/%s not found!", file);
658 TObject * dis = emcalSubFolder->FindObject(name) ;
661 Fatal("SDigitsRef", "-> object %s not found!", name);
664 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
667 //____________________________________________________________________________
669 const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
671 //---------- SDigitizer -------------------------
672 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
674 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
677 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!",fTasksFolder);
681 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
685 Warning("PostSDigitizer", "->//%s/SDigitizer/EMCAL/ not found!",fTasksFolder);
686 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL/", fTasksFolder);
688 emcal = new TTask("EMCAL", "") ;
692 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
696 Info("PostSDigitizer", "-> Task %s already exists",sdigitizer->GetName());
697 emcal->GetListOfTasks()->Remove(emcalsd) ;
700 emcal->Add(sdigitizer) ;
705 //____________________________________________________________________________
707 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
709 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
712 Fatal("SDigitizerRef", "-> Task //%s/SDigitizer not found!", fTasksFolder);
715 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
718 Fatal("SDigitizerRef", "-> //%s/SDigitizer/EMCAL not found!", fTasksFolder);
721 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
723 return emcal->GetListOfTasks()->GetObjectRef(task) ;
726 //____________________________________________________________________________
728 const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
730 //---------- SDigitizer -------------------------
731 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
733 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
736 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!", fTasksFolder);
740 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
744 Warning("PostSDigitizer", "-> //%s/SDigitizer/EMCAL/ not found!", fTasksFolder);
746 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL", fTasksFolder);
749 emcal = new TTask("EMCAL", "") ;
753 TString sdname(name) ;
756 sdname.ReplaceAll("/","_") ;
757 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
760 emcalsd = new AliEMCALSDigitizer() ;
762 //Note, we can not call constructor with parameters: it will call Getter and screw up everething
764 emcalsd->SetName(sdname) ;
765 emcalsd->SetTitle(file) ;
766 emcal->Add(emcalsd) ;
772 //____________________________________________________________________________
774 const Bool_t AliEMCALGetter::PostDigits(const char * name) const
776 //---------- Digits -------------------------
777 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
779 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
781 if ( !emcalFolder ) {
783 Warning("PostDigits", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
784 Info("PostDigits", "-> Adding Folder //%s/EMCAL/", fDigitsFolder);
786 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
789 TObject* dig = emcalFolder->FindObject( name ) ;
792 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
793 digits->SetName(name) ;
794 emcalFolder->Add(digits) ;
800 //____________________________________________________________________________
802 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
804 //------- Digits ----------------------
805 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
807 if ( !fDigitsFolder ) {
808 Fatal("DigitsRef", "-> Folder //%s not found!", fDigitsFolder);
811 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
813 if ( !emcalFolder ) {
814 Fatal("DigitsRef", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
817 TObject * d = emcalFolder->FindObject(name) ;
820 Fatal("DigitsRef", "-> object %s not found!", name);
823 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
826 //____________________________________________________________________________
828 const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
830 //---------- Digitizer -------------------------
832 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
835 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
839 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
843 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
844 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
846 emcal = new TTask("EMCAL", "") ;
850 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
854 emcal->GetListOfTasks()->Remove(emcald) ;
857 emcal->Add(digitizer) ;
862 //____________________________________________________________________________
864 const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
866 //---------- Digitizer -------------------------
867 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
869 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
873 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
877 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
881 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
883 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
885 emcal = new TTask("EMCAL", "") ;
889 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
892 emcald = new AliEMCALDigitizer() ;
893 emcald->SetName(fDigitsTitle) ;
894 emcald->SetTitle(fHeaderFile) ;
901 //____________________________________________________________________________
903 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
906 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
909 Fatal("DigitizerRef", "-> Task //%s/Digitizer not found!", fTasksFolder->GetName());
912 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
915 Fatal("DigitizerRef", "-> //%s/Digitizer/EMCAL", fTasksFolder->GetName());
918 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
920 return emcal->GetListOfTasks()->GetObjectRef(task) ;
923 //____________________________________________________________________________
925 const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
927 // -------------- RecPoints -------------------------------------------
928 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
929 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
931 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
933 if ( !emcalFolder ) {
935 Warning("PostRecPoints", "-> Folder //%s/EMCAL/ not found!", fRecoFolder);
936 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/", fRecoFolder);
938 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
943 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
945 if ( !emcalRPoTowerFolder ) {
948 Warning("PostRecPoints", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
949 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/TowerRecPoints not found!", fRecoFolder);
951 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
954 TObject * erp = emcalFolder->FindObject( name ) ;
957 TObjArray * towerrp = new TObjArray(100) ;
958 towerrp->SetName(name) ;
959 emcalRPoTowerFolder->Add(towerrp) ;
962 // Pre Shower RecPoints
964 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
966 if ( !emcalRPoPreShoFolder ) {
968 Warning("PostRecPoints", "-> Folder //%s/EMCAL/PreShowerRecPoints/ not found!", fRecoFolder);
969 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
971 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;
974 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
977 TObjArray * preshorp = new TObjArray(100) ;
978 preshorp->SetName(name) ;
979 emcalRPoPreShoFolder->Add(preshorp) ;
985 //____________________________________________________________________________
987 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
989 // -------------- RecPoints -------------------------------------------
990 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
992 if ( !fRecoFolder ) {
993 Fatal("TowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
996 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
998 if ( !towerFolder ) {
999 Fatal("TowerRecPointsRef", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
1002 TObject * trp = towerFolder->FindObject(name ) ;
1005 Fatal("TowerRecPointsRef", "-> Object %s not found!", name);
1008 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
1011 //____________________________________________________________________________
1013 TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const
1015 // -------------- RecPoints -------------------------------------------
1016 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
1018 if ( !fRecoFolder ) {
1019 Fatal("PreShowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
1022 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
1024 if ( !preshoFolder ) {
1025 Fatal("PreShowerRecPointsRef", "-> Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
1030 TObject * prp = preshoFolder->FindObject(name ) ;
1033 Fatal("PreShowerRecPointsRef", "-> Object %s not found!", name);
1036 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
1039 //____________________________________________________________________________
1041 const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
1043 // ------------------ AliEMCALClusterizer ------------------------
1044 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1046 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1049 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder);
1053 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1057 Warning("PostClusterizer", "-> //%s/ReconstructionerEMCAL not found!", fTasksFolder);
1058 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
1060 emcal = new TTask("EMCAL", "") ;
1064 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
1068 Info("PostClusterizer", "-> Task %s already exists", clu->GetName());
1070 emcal->GetListOfTasks()->Remove(emcalcl) ;
1077 //____________________________________________________________________________
1079 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
1081 // ------------------ AliEMCALClusterizer ------------------------
1083 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1086 Fatal("ClusterizerRef", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
1089 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1092 Fatal("ClusterizerRef", "-> //%s/Reconstructioner/EMCAL", fTasksFolder->GetName());
1095 TList * l = emcal->GetListOfTasks() ;
1099 TString cluname(name) ;
1102 while((task = static_cast<TTask *>(it.Next()) )){
1103 TString taskname(task->GetName()) ;
1104 if(taskname.BeginsWith(cluname)){
1111 Fatal("ClusterizerRef", "-> task %s not found!", task->GetName());
1114 return l->GetObjectRef(clu) ;
1117 //____________________________________________________________________________
1119 const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
1121 // ------------------ AliEMCALClusterizer ------------------------
1122 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1125 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1128 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
1132 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1136 Warning("PostClusterizer", "-> //%s/Reconstructioner/EMCAL not found!", fTasksFolder);
1137 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
1139 emcal = new TTask("EMCAL", "") ;
1143 TList * l = emcal->GetListOfTasks() ;
1145 TString clun(name) ;
1149 while((task = static_cast<TTask *>(it.Next()) )){
1150 TString taskname(task->GetName()) ;
1152 if(taskname.BeginsWith(clun))
1156 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
1159 emcalcl->SetName(clun) ;
1160 emcalcl->SetTitle(fHeaderFile) ;
1161 emcal->Add(emcalcl) ;
1166 //____________________________________________________________________________
1168 TTree * AliEMCALGetter::TreeK(TString filename)
1170 // returns TreeK from file filename
1171 // usefull in case of split file
1173 if ( filename.IsNull() )
1174 filename = fHeaderFile ;
1178 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1180 if (!file || !file->IsOpen()) // file not yet open
1181 file = TFile::Open(filename.Data(), "read") ;
1183 if(filename != fHeaderFile ){
1184 fAlice = dynamic_cast<AliRun *>(file->Get("gAlice")) ;
1187 TString treeName("TreeK") ;
1188 treeName += EventNumber() ;
1189 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1191 if (!tree && fDebug)
1192 Warning("TreeK", "-> %s not found in %s", treeName.Data(),filename.Data());
1197 //____________________________________________________________________________
1199 TTree * AliEMCALGetter::TreeH(TString filename)
1201 // returns TreeH from file filename
1202 // usefull in case of split file
1204 if ( filename.IsNull() )
1205 filename = fHeaderFile ;
1208 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1210 if (!file) { // file not open yet
1211 file = TFile::Open(filename.Data(), "read") ;
1214 TString treeName("TreeH") ;
1215 treeName += EventNumber() ;
1216 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1218 if (!tree && fDebug)
1219 Warning("TreeH", "-> %s not found in %s", treeName.Data(), filename.Data());
1223 //____________________________________________________________________________
1225 TTree * AliEMCALGetter::TreeS(TString filename)
1227 // returns TreeS from file filename
1228 // usefull in case of split file
1230 if ( filename.IsNull() )
1231 filename = fHeaderFile ;
1234 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1236 if (!file) { // file not open yet
1237 file = TFile::Open(filename.Data(), "read") ;
1240 TString treeName("TreeS") ;
1241 treeName += EventNumber() ;
1242 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1244 if (!tree && fDebug)
1245 Warning("TreeS", "-> %s not found in %s", treeName.Data(), filename.Data());
1249 //____________________________________________________________________________
1251 TTree * AliEMCALGetter::TreeD(TString filename)
1253 // returns TreeD from file filename
1254 // usefull in case of split file
1256 if ( filename.IsNull() )
1257 filename = fHeaderFile ;
1260 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1262 if (!file) { // file not open yet
1263 file = TFile::Open(filename.Data(), "read") ;
1266 TString treeName("TreeD") ;
1267 treeName += EventNumber() ;
1268 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1270 if (!tree && fDebug)
1271 Warning("TreeD", "-> %s not found in %s", treeName.Data(), filename.Data());
1275 //____________________________________________________________________________
1277 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1279 // Return primary particle numbered by <index>
1286 p = fAlice->Particle(index) ;
1288 p = gAlice->Particle(index) ;
1293 //____________________________________________________________________________
1295 const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
1297 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1305 Int_t daughterIndex = p->GetDaughter(index-1) ;
1306 return gAlice->Particle(daughterIndex) ;
1312 //____________________________________________________________________________
1314 Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
1316 // Read the digit tree gAlice->TreeD()
1320 TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
1322 file = TFile::Open(fDigitsFileName) ;
1324 // Get Digits Tree header from file
1326 TString treeName("TreeD") ;
1328 treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1330 if(!treeD){ // TreeD not found in header file
1332 Warning("ReadTreeD", "-> Cannot find TreeD in %s", fDigitsFileName.Data());
1337 treeD = gAlice->TreeD() ;
1339 TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
1341 TBranch * branch = 0 ;
1342 TBranch * digitsbranch = 0 ;
1343 TBranch * digitizerbranch = 0 ;
1345 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1347 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1348 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1349 digitsbranch = branch ;
1350 emcalfound = kTRUE ;
1352 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1353 digitizerbranch = branch ;
1354 digitizerfound = kTRUE ;
1358 if ( !emcalfound || !digitizerfound ) {
1360 Warning("ReadTreeD", "-> Cannot find Digits and/or Digitizer with name %s", fDigitsTitle.Data());
1366 if(!Digits(fDigitsTitle) )
1367 PostDigits(fDigitsTitle);
1368 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1369 digitsbranch->GetEntry(0) ;
1371 // read the Digitizer
1373 RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
1374 if(!Digitizer(fDigitsTitle))
1375 PostDigitizer(fDigitsTitle) ;
1376 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1377 digitizerbranch->GetEntry(0) ;
1381 if(gAlice->TreeD()!=treeD)
1387 //____________________________________________________________________________
1389 Int_t AliEMCALGetter::ReadTreeH()
1391 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1393 TTree * treeH = gAlice->TreeH() ;
1395 if(!treeH) {// TreeH not found in header file
1397 Warning("ReadTreeH", "-> Cannot find TreeH in %s", fHeaderFile.Data());
1399 TString searchFileName("EMCAL.HITS") ;
1400 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1401 searchFileName+="." ;
1402 searchFileName += fBranchTitle ;
1405 searchFileName+=".root" ;
1407 if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
1409 Info("ReadTreeH", "-> TreeH found in %s", searchFileName.Data());
1411 Error("ReadTreeH", "-> TreeH not found ");
1416 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1418 if ( !hitsbranch ) {
1420 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
1427 if (hitsbranch->GetEntries() > 1 ) {
1428 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1429 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1430 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1431 hitsbranch->SetAddress(&tempo) ;
1436 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1437 hitsbranch->GetEntry(i) ;
1439 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1440 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1441 new((*hits)[index]) AliEMCALHit( *hit ) ;
1448 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1449 hitsbranch->SetAddress(HitsRef()) ;
1450 hitsbranch->GetEntry(0) ;
1455 //____________________________________________________________________________
1457 void AliEMCALGetter::Track(const Int_t itrack)
1459 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1460 if(gAlice->TreeH()== 0){
1461 Error("ReadTreeH", "-> Cannot read TreeH ");
1465 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1467 if ( !hitsbranch ) {
1469 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
1476 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1477 hitsbranch->SetAddress(HitsRef()) ;
1478 hitsbranch->GetEntry(itrack) ;
1481 //____________________________________________________________________________
1483 void AliEMCALGetter::ReadTreeQA()
1486 Warning("ReadTreeQA", "-> %s not implemented", ClassName());
1491 //____________________________________________________________________________
1493 Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
1496 // Read the reconstrunction tree gAlice->TreeR()
1497 // A particularity has been introduced here :
1498 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1499 // being for example give in AliEMCALPID(fileName, title)
1500 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1501 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1502 // from a given set of TrackSegments (with a given name)
1503 // This is why any is NOT used to read the branch of RecParticles
1504 // any migh have become obsolete : to be checked
1505 // See AliEMCALPIDv1
1510 TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
1512 file = TFile::Open(fRecPointsFileName) ;
1513 // Get Digits Tree header from file
1515 TString treeName("TreeR") ;
1517 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1519 if(!treeR){ // TreeR not found in header file
1521 Warning("ReadTreeD", "-> Cannot find TreeR in %s", fRecPointsFileName.Data());
1526 treeR = gAlice->TreeR() ;
1530 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
1532 TBranch * branch = 0 ;
1533 TBranch * towerbranch = 0 ;
1534 TBranch * preshowerbranch = 0 ;
1535 TBranch * clusterizerbranch = 0 ;
1537 Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
1539 while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1540 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
1541 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1542 towerbranch = branch ;
1543 emcalTowerRPfound = kTRUE ;
1545 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1546 preshowerbranch = branch ;
1547 emcalPreShoRPfound = kTRUE ;
1549 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1550 clusterizerbranch = branch ;
1551 clusterizerfound = kTRUE ;
1556 if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
1558 Warning("ReadTreeR", "-> Cannot find RecPoints and/or Clusterizer with name %s", fRecPointsTitle.Data());
1561 if(!TowerRecPoints(fRecPointsTitle) )
1562 PostRecPoints(fRecPointsTitle) ;
1563 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1564 towerbranch->GetEntry(0) ;
1566 preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
1567 preshowerbranch->GetEntry(0) ;
1569 if(!Clusterizer(fRecPointsTitle) )
1570 PostClusterizer(fRecPointsTitle) ;
1572 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1573 clusterizerbranch->GetEntry(0) ;
1576 if(gAlice->TreeR()!=treeR)
1581 //____________________________________________________________________________
1583 Int_t AliEMCALGetter::ReadTreeS(const Int_t event)
1585 // Reads the SDigits treeS from all files
1586 // Files, which should be opened are listed in emcalF
1587 // So, first get list of files
1589 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1592 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1594 TCollection * folderslist = emcalF->GetListOfFolders() ;
1596 // Now iterate over the list of files and read TreeS into Whiteboard
1598 TIter next(folderslist) ;
1599 TFolder * folder = 0 ;
1603 while ( (folder = static_cast<TFolder*>(next())) ) {
1604 TString fileName("") ;
1606 fileName = folder->GetTitle() ;
1608 fileName = folder->GetName() ;
1610 fileName.ReplaceAll("_","/") ;
1611 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1614 file = TFile::Open(fileName) ;
1616 // Get SDigits Tree header from file
1618 TString treeName("TreeS") ;
1620 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1622 if(!treeS){ // TreeS not found in header file
1624 Warning("ReadTreeS", "-> Cannot find TreeS in %s", fileName.Data());
1628 //set address of the SDigits and SDigitizer
1630 TBranch * sdigitsBranch = 0;
1631 TBranch * sdigitizerBranch = 0;
1632 TBranch * branch = 0 ;
1633 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1636 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1638 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1639 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1640 emcalfound = kTRUE ;
1641 sdigitsBranch = branch ;
1643 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
1644 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1645 sdigitizerfound = kTRUE ;
1646 sdigitizerBranch = branch ;
1649 if ( !emcalfound || !sdigitizerfound ) {
1651 Warning("ReadSDigits", "-> Digits and/or Digitizer branch with name %s not found", GetName());
1655 if ( !folder->FindObject(fSDigitsTitle) )
1656 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1658 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
1660 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1661 sdigitsBranch->GetEntry(0) ;
1663 TString sdname(fSDigitsTitle) ;
1665 sdname+=folder->GetName() ;
1667 if(!SDigitizer(sdname) )
1668 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1670 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1671 sdigitizerBranch->GetEntry(0) ;
1673 if(gAlice->TreeS()!=treeS)
1679 //____________________________________________________________________________
1681 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1683 // Read the summable digits fron treeS()
1685 TString filename("mergefile") ;
1688 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1689 if ( !emcalFolder ) {
1690 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1693 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1695 //set address of the SDigits and SDigitizer
1697 TBranch * sdigitsBranch = 0;
1698 TBranch * sdigitizerBranch = 0;
1699 TBranch * branch = 0 ;
1700 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1703 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1705 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1706 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1707 emcalfound = kTRUE ;
1708 sdigitsBranch = branch ;
1710 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1711 sdigitizerfound = kTRUE ;
1712 sdigitizerBranch = branch ;
1716 if ( !emcalfound || !sdigitizerfound ) {
1718 Warning("ReadTreeS", "-> Digits and/or Digitizer branch not found");
1722 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1723 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1725 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1726 sdigitsBranch->GetEntry(0) ;
1728 TString sdname(sdigitsBranch->GetTitle()) ;
1732 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1733 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1735 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1736 sdigitizerBranch->GetEntry(0) ;
1738 if(gAlice->TreeS()!=treeS)
1742 //____________________________________________________________________________
1744 void AliEMCALGetter::ReadPrimaries()
1747 // Reads specific branches of primaries
1749 TClonesArray * ar = 0 ;
1751 if(! (ar = Primaries()) ) {
1758 if (TreeK(fHeaderFile)) { // treeK found in header file
1760 Info("ReadPrimaries", "-> TreeK found in %s", fHeaderFile.Data());
1761 fNPrimaries = gAlice->GetNtrack() ;
1764 else { // treeK not found in header file
1765 Error("ReadPrimaries", "-> TreeK not found ");
1771 for (index = 0 ; index < fNPrimaries; index++) {
1772 new ((*ar)[index]) TParticle(*(Primary(index)));
1776 //____________________________________________________________________________
1778 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1780 // Reads the content of all Tree's S, D and R
1782 if (event >= gAlice->TreeE()->GetEntries() ) {
1783 Error("Event", "-> %d not found in TreeE!", event);
1787 Bool_t any = kFALSE ;
1789 if (strstr(opt,"A") ) // do not check the title of the branches
1792 gAlice->GetEvent(event) ;
1794 if( strstr(opt,"R") )
1797 if( strstr(opt,"D") )
1800 if(strstr(opt,"S") )
1803 if(strstr(opt,"H") )
1806 if( strstr(opt,"Q") )
1809 if( strstr(opt,"P") )
1813 //____________________________________________________________________________
1815 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1817 // get the object named "what" from the folder
1818 // folders are named like //Folders
1820 if ( file.IsNull() )
1821 file = fHeaderFile ;
1823 TFolder * folder = 0 ;
1824 TObject * emcalO = 0 ;
1826 if ( what.CompareTo("Primaries") == 0 ) {
1827 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1829 emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1833 else if ( what.CompareTo("Hits") == 0 ) {
1834 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1836 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1838 else if ( what.CompareTo("SDigits") == 0 ) {
1839 file.ReplaceAll("/","_") ;
1840 TString path = "EMCAL/" + file ;
1841 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1844 name = fSDigitsTitle ;
1845 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1848 else if ( what.CompareTo("Digits") == 0 ){
1849 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1852 name = fDigitsTitle ;
1853 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1856 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1857 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1860 name = fRecPointsTitle ;
1861 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1864 else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
1865 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
1868 name = fRecPointsTitle ;
1869 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1875 Warning("ReturnO", "-> Object %s not found in %s", what.Data(), folder->GetName());
1882 //____________________________________________________________________________
1884 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1886 // get the TTask named "what" from the folder
1887 // folders are named like //Folders/Tasks/what/EMCAL/name
1889 TString search(what) ;
1890 if ( what.CompareTo("Clusterizer") == 0 )
1891 search = "Reconstructioner" ;
1892 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1893 search = "Reconstructioner" ;
1894 else if ( what.CompareTo("PID") == 0 )
1895 search = "Reconstructioner" ;
1896 else if ( what.CompareTo("QATasks") == 0 )
1899 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1902 Error("AliReturnT", "-> Task %s not found!", what.Data());
1906 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1909 Error("ReturnT", "-> Task %s/EMCAL not found!", what.Data());
1913 TList * list = emcalT->GetListOfTasks() ;
1915 if (what.CompareTo("SDigitizer") == 0) {
1916 if ( name.IsNull() )
1917 name = fSDigitsTitle ;
1919 else if (what.CompareTo("Digitizer") == 0){
1920 if ( name.IsNull() )
1921 name = fDigitsTitle ;
1923 else if (what.CompareTo("Clusterizer") == 0){
1924 if ( name.IsNull() )
1925 name = fRecPointsTitle ;
1926 name.Append(":clu") ;
1932 while((task = static_cast<TTask *>(it.Next()) )){
1933 TString taskname(task->GetName()) ;
1934 if(taskname.BeginsWith(name)){
1939 Warning("ReturnT", "-> Task %s/%s not found!", search.Data(), name.Data());
1943 //____________________________________________________________________________
1945 void AliEMCALGetter::RemoveTask(TString opt, TString name) const
1948 // remove a task from the folder
1949 // path is fTasksFolder/SDigitizer/EMCAL/name
1953 TList * lofTasks = 0 ;
1955 if (opt == "S") { // SDigitizer
1956 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
1960 else if (opt == "D") { // Digitizer
1961 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
1965 else if (opt == "C") { // Clusterizer
1966 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1971 Warning("RemoveTask", "-> Unknown option %s");
1975 emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
1980 lofTasks = emcal->GetListOfTasks() ;
1985 TObject * obj = lofTasks->FindObject(name) ;
1988 lofTasks->Remove(obj) ;
1991 //____________________________________________________________________________
1993 void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
1995 // remove SDigits from the folder
1996 // path is fSDigitsFolder/fHeaderFileName/name
1998 TFolder * emcal = 0 ;
1999 TFolder * emcalmain = 0 ;
2001 if (opt == "H") { // Hits
2002 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2007 else if ( opt == "S") { // SDigits
2008 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2011 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2015 else if (opt == "D") { // Digits
2016 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2020 else if (opt == "RT") { // Tower RecPoints
2021 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2025 else if (opt == "RP") { // Preshower RecPoints
2026 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2030 else if (opt == "T") { // TrackSegments
2031 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2035 else if (opt == "P") { // RecParticles
2036 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2041 Warning("RemoveObjects", "-> Unknown option %s", opt.Data());
2045 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
2054 emcalmain->Remove(emcal) ;
2057 //____________________________________________________________________________
2059 void AliEMCALGetter::RemoveSDigits() const
2061 TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2070 //____________________________________________________________________________
2072 void AliEMCALGetter::CleanWhiteBoard(void){
2074 TFolder * emcalmain = 0 ;
2077 TList * lofTasks = 0 ;
2079 TTask * emcalt = 0 ;
2083 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2086 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
2096 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2099 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2101 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
2108 emcalmain->Remove(emcal) ;
2113 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2116 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
2126 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2129 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2137 // PreShowerRecPoints
2139 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2142 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2152 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2155 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
2165 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2168 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
2176 //---- Now Tasks -----------
2179 TString sdname(fSDigitsTitle);
2183 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2186 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2188 lofTasks = emcalt->GetListOfTasks() ;
2190 obj = lofTasks->FindObject(sdname.Data()) ;
2192 lofTasks->Remove(obj) ;
2197 sdname.Append(":") ;
2199 // Clusterizer, TrackSegmentMaker, PID
2201 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2204 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2206 lofTasks = emcalt->GetListOfTasks() ;
2207 TIter next(lofTasks);
2208 while((obj=next())){
2209 TString oname(obj->GetName()) ;
2210 if (oname.BeginsWith(sdname)){
2211 lofTasks->Remove(obj) ;
2219 sdname.Append(fHeaderFile) ;
2220 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2223 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2225 lofTasks = emcalt->GetListOfTasks() ;
2227 obj = lofTasks->FindObject(sdname.Data()) ;
2229 lofTasks->Remove(obj) ;
2235 //____________________________________________________________________________
2237 void AliEMCALGetter::SetTitle(const char * branchTitle )
2240 fBranchTitle = branchTitle ;
2241 fSDigitsTitle = branchTitle ;
2242 fDigitsTitle = branchTitle ;
2243 fRecPointsTitle = branchTitle ;
2244 fRecParticlesTitle = branchTitle ;
2245 fTrackSegmentsTitle = branchTitle ;
2249 //First - extract full path if necessary
2251 TString sFileName(fHeaderFile) ;
2252 Ssiz_t islash = sFileName.Last('/') ;
2254 if(islash<sFileName.Length())
2255 sFileName.Remove(islash+1,sFileName.Length()) ;
2259 //Now construct file names
2261 fSDigitsFileName = sFileName ;
2262 fDigitsFileName = sFileName ;
2263 fRecPointsFileName = sFileName ;
2264 fRecParticlesFileName = sFileName ;
2265 fTrackSegmentsFileName = sFileName ;
2266 fSDigitsFileName += "EMCAL.SDigits." ;
2267 fDigitsFileName += "EMCAL.Digits." ;
2268 fRecPointsFileName += "EMCAL.RecData." ;
2269 fTrackSegmentsFileName+= "EMCAL.RecData." ;
2270 fRecParticlesFileName += "EMCAL.RecData." ;
2272 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2273 fSDigitsFileName += fBranchTitle ;
2274 fSDigitsFileName += "." ;
2275 fDigitsFileName += fBranchTitle ;
2276 fDigitsFileName += "." ;
2277 fRecPointsFileName += fBranchTitle ;
2278 fRecPointsFileName += "." ;
2279 fRecParticlesFileName += fBranchTitle ;
2280 fRecParticlesFileName += "." ;
2281 fTrackSegmentsFileName+= fBranchTitle ;
2282 fTrackSegmentsFileName+= "." ;
2285 fSDigitsFileName += "root" ;
2286 fDigitsFileName += "root" ;
2287 fRecPointsFileName += "root" ;
2288 fRecParticlesFileName += "root" ;
2289 fTrackSegmentsFileName+= "root" ;
2292 fSDigitsFileName = "" ;
2293 fDigitsFileName = "" ;
2294 fRecPointsFileName = "" ;
2295 fRecParticlesFileName = "" ;
2296 fTrackSegmentsFileName = "" ;
2299 TFolder * emcalFolder ;
2300 emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2303 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
2305 emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2308 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
2310 //Make folder for SDigits
2312 TString subdir(fHeaderFile) ;
2313 subdir.ReplaceAll("/","_") ;
2315 emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
2316 emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2319 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
2321 emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
2324 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
2327 //____________________________________________________________________________
2329 void AliEMCALGetter::CloseSplitFiles(void){
2332 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2337 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2342 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2347 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2352 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;