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()) ;
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
114 SetTitle(branchTitle) ;
116 if ( fHeaderFile != "aliroot" ) { // to call the getter without a file
120 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
122 if(!fFile){ //if file was not opened yet, read gAlice
123 fFile = TFile::Open(fHeaderFile.Data(), "update") ;
124 if (!fFile->IsOpen()) {
125 Error("AliEMCALGetter","Cannot open %s",fHeaderFile.Data()) ;
129 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
134 Error("AliEMCALGetter","Cannot find gAlice in %s",fHeaderFile.Data()) ;
141 Info("AliEMCALGetter","Posting EMCAL to Folders") ;
143 if (gAlice->GetDetector("EMCAL")) {
144 AliConfig * conf = AliConfig::Instance() ;
145 conf->Add(static_cast<AliDetector*>(gAlice->GetDetector("EMCAL"))) ;
146 conf->Add(static_cast<AliModule*>(gAlice->GetDetector("EMCAL"))) ;
149 Error("AliEMCALGetter"," Detector EMCAL not found");
155 //____________________________________________________________________________
157 AliEMCALGetter::~AliEMCALGetter()
160 fPrimaries->Delete() ;
164 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
165 TCollection * folderslist = emcalF->GetListOfFolders() ;
166 TIter next(folderslist) ;
167 TFolder * folder = 0 ;
169 while ( (folder = static_cast<TFolder*>(next())) )
170 emcalF->Remove(folder) ;
181 //____________________________________________________________________________
183 void AliEMCALGetter::CloseFile()
189 //____________________________________________________________________________
191 const TFolder * AliEMCALGetter::Folder(const TString what) const {
193 // returns the EMCAL folder required by what
194 // what = hits, sdigits, digits
196 if ( what == "hits" )
197 return dynamic_cast<const TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
198 else if ( what == "sdigits" )
199 return dynamic_cast<const TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
200 else if ( what == "digits" )
201 return dynamic_cast<const TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
203 Error("GetFolder","%s illegal option (hits, sdigits, digits) ", what.Data()) ;
208 //____________________________________________________________________________
210 AliEMCALGetter * AliEMCALGetter::GetInstance()
212 // Returns the pointer of the unique instance already defined
222 //____________________________________________________________________________
224 AliEMCALGetter * AliEMCALGetter::GetInstance(const char* headerFile,
225 const char* branchTitle,
226 const Bool_t toSplit)
228 // Creates and returns the pointer of the unique instance
229 // Must be called only when the environment has changed
232 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
233 if(fgObjGetter->fFailed)
239 //First checks, if header file already opened
241 if(!fgObjGetter->fFile){
242 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
243 if(fgObjGetter->fFailed)
249 if(fgObjGetter->fHeaderFile.CompareTo(headerFile)==0){ //Opened the same header file
250 if((fgObjGetter->fBranchTitle.CompareTo(branchTitle) == 0)&& //Open the same branch title
251 (toSplit==fgObjGetter->fToSplit)){ //Nothing should be cleaned
253 else{ //Clean all data and AliEMCAL...zers
254 if(fgObjGetter->fToSplit)
255 fgObjGetter->CloseSplitFiles() ;
256 fgObjGetter->CleanWhiteBoard() ;
257 fgObjGetter->fToSplit = toSplit ;
258 fgObjGetter->SetTitle(branchTitle) ;
261 else{ //Close already opened files, clean memory and open new header file
265 if(fgObjGetter->fFile){
266 fgObjGetter->fFile->Close() ;
267 fgObjGetter->fFile=0;
269 if(fgObjGetter->fToSplit)
270 fgObjGetter->CloseSplitFiles() ;
271 fgObjGetter->CleanWhiteBoard() ;
272 fgObjGetter = new AliEMCALGetter(headerFile,branchTitle,toSplit) ;
279 //____________________________________________________________________________
281 const Bool_t AliEMCALGetter::BranchExists(const TString recName) const
283 //Looks in the tree Tree"name" if branch with current name olready exists
285 TString filename("") ;
286 TString name, dataname, zername;
287 if(recName == "SDigits"){
288 filename=fSDigitsFileName ;
291 zername = "AliEMCALSDigitizer" ;
293 else if(recName == "Digits"){
294 filename=fDigitsFileName ;
297 zername = "AliEMCALDigitizer" ;
299 else if(recName =="RecPoints"){
300 filename=fRecPointsFileName ;
302 dataname = "EMCALEmcRP" ;
303 zername = "AliEMCALClusterizer" ;
305 else if(recName == "TrackSegments"){
306 filename=fTrackSegmentsFileName ;
308 dataname = "EMCALTS" ;
309 zername = "AliEMCALTrackSegmentMaker" ;
311 else if(recName == "RecParticles"){
312 filename= fRecParticlesFileName ;
314 dataname = "EMCALRP" ;
315 zername = "AliEMCALPID" ;
323 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
325 file = TFile::Open(fSDigitsFileName.Data(),"update");
330 tree = (TTree *)file->Get(name.Data()) ;
335 TObjArray * lob = static_cast<TObjArray*>(tree->GetListOfBranches()) ;
337 TBranch * branch = 0 ;
338 TString titleName(fBranchTitle);
341 while ((branch = (static_cast<TBranch*>(next())))) {
342 TString branchName(branch->GetName() ) ;
343 TString branchTitle(branch->GetTitle() ) ;
344 if ( branchName.BeginsWith(dataname) && branchTitle.BeginsWith(fBranchTitle) ){
345 Warning("BranchExists", "branch %s with title %s already exits in %s", dataname.Data(), fBranchTitle.Data(), name.Data());
349 if ( branchName.BeginsWith(zername) && branchTitle.BeginsWith(titleName) ){
350 Warning("BranchExists","Branch AliEMCAL... with title %s already exits in %s",branch->GetTitle(), name.Data());
355 //We can't delete three if gAlice points to it... To be redisigned somehow???!!!
358 if(name.Contains("TreeS"))
359 if(tree!=gAlice->TreeS())
361 if(name.Contains("TreeD"))
362 if(tree!=gAlice->TreeD())
364 if(name.Contains("TreeR"))
365 if(tree!=gAlice->TreeR())
372 //____________________________________________________________________________
374 void AliEMCALGetter::ListBranches(Int_t event) const
376 TBranch * branch = 0 ;
377 if (gAlice->GetEvent(event) == -1)
380 TTree * t = gAlice->TreeH() ;
383 Info("ListBranches"," -> ****** Hits : ");
384 TObjArray * lob = t->GetListOfBranches() ;
387 while ( (branch = static_cast<TBranch*>(next())) )
388 Info("ListBranches"," %s", branch->GetName());
391 Warning("ListBranches"," -> TreeH not found for event %d",event);
393 t = gAlice->TreeS() ;
396 Info("ListBranches"," -> ****** SDigits : ");
397 TObjArray * lob = t->GetListOfBranches() ;
400 while ( (branch = static_cast<TBranch*>(next())) )
401 Info("ListBranches"," %s %s",branch->GetName(),branch->GetTitle());
403 Warning("ListBranches"," -> TreeS not found for event %d",event);
405 t = gAlice->TreeD() ;
408 Info("ListBranches"," -> ****** Digits : ");
409 TObjArray * lob = t->GetListOfBranches() ;
412 while ( (branch = static_cast<TBranch*>(next())) )
413 Info(" %s %s", branch->GetName(), branch->GetTitle());
415 Warning("ListBranches"," -> TreeD not found for event %d", event);
417 t = gAlice->TreeR() ;
420 Info("ListBranches"," -> ****** Recon : ");
421 TObjArray * lob = t->GetListOfBranches() ;
423 while ( (branch = static_cast<TBranch*>(next())) )
424 Info(" %s %s", branch->GetName(), branch->GetTitle());
426 Warning("ListBranches"," -> TreeR not found for event %d",event);
429 //____________________________________________________________________________
431 void AliEMCALGetter::NewBranch(TString name, Int_t event)
433 fBranchTitle = fSDigitsTitle = fDigitsTitle = fRecPointsTitle = fTrackSegmentsTitle = fRecParticlesTitle = name ;
437 //____________________________________________________________________________
439 Bool_t AliEMCALGetter::NewFile(TString name)
445 fFile = static_cast<TFile*>(gROOT->GetFile(fHeaderFile.Data() ) ) ;
447 if(!fFile) { //if file was not opened yet, read gAlice
448 fFile = TFile::Open(fHeaderFile.Data(),"update") ;
449 if (!fFile->IsOpen()) {
450 Error("NewFile", " -> Cannot open %s", fHeaderFile.Data());
454 gAlice = static_cast<AliRun *>(fFile->Get("gAlice")) ;
458 Error("NewFile"," -> Cannot find gAlice in %s", fHeaderFile.Data());
465 //____________________________________________________________________________
467 const AliEMCAL * AliEMCALGetter::EMCAL()
469 // returns the EMCAL object
471 AliEMCAL * emcal = dynamic_cast<AliEMCAL*>(fModuleFolder->FindObject("EMCAL")) ;
475 Warning("EMCAL"," -> EMCAL module not found in Folders" );
479 //____________________________________________________________________________
481 AliEMCALGeometry * AliEMCALGetter::EMCALGeometry()
483 AliEMCALGeometry * rv = 0 ;
485 rv = EMCAL()->GetGeometry() ;
489 //____________________________________________________________________________
491 const Bool_t AliEMCALGetter::PostPrimaries(void) const
493 //------- Primaries ----------------------
494 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
496 TFolder * primariesFolder = dynamic_cast<TFolder*>(fPrimariesFolder->FindObject("Primaries")) ;
497 if ( !primariesFolder ) {
499 Warning("PostPrimaries", "-> Folder //%s/Primaries/ not found!", fPrimariesFolder->GetName());
500 Info("PostPrimaries", "-> Adding Folder //%s/Primaries/",fPrimariesFolder->GetName());
502 primariesFolder = fPrimariesFolder->AddFolder("Primaries", "Primaries particles from TreeK") ;
505 TClonesArray *primaries= new TClonesArray("TParticle",1000) ;
506 primaries->SetName("Primaries") ;
507 primariesFolder->Add(primaries) ;
512 //____________________________________________________________________________
514 TObject** AliEMCALGetter::PrimariesRef(void) const
516 //------- Primaries ----------------------
517 // the hierarchy is //Folders/RunMC/Event/Data/Primaries
519 if ( !fPrimariesFolder ) {
520 Fatal("PrimariesRef", "-> Folder //%s not found!",fPrimariesFolder);
523 TFolder * primariesFolder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
525 if ( !primariesFolder ) {
526 Fatal("PrimariesRef", "-> Folder //%s/Primaries/ not found!",fPrimariesFolder);
529 TObject * p = primariesFolder->FindObject("Primaries") ;
532 Fatal("PrimariesRef", "-> %s/Primaries not found !",primariesFolder->GetName());
535 return primariesFolder->GetListOfFolders()->GetObjectRef(p) ;
538 //____________________________________________________________________________
540 const Bool_t AliEMCALGetter::PostHits(void) const
542 //------- Hits ----------------------
543 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
545 TFolder * emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
547 if ( !emcalFolder ) {
549 Warning("PostHits", "-> Folder //%s/EMCAL/ not found!", fHitsFolder);
550 Info("PostHits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
552 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
555 TClonesArray *hits= new TClonesArray("AliEMCALHit",1000) ;
556 hits->SetName("Hits") ;
557 emcalFolder->Add(hits) ;
562 //____________________________________________________________________________
564 TObject ** AliEMCALGetter::HitsRef(void) const
566 //------- Hits ----------------------
567 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/Hits
569 if ( !fHitsFolder ) {
570 Error("HitsRef", "-> Folder //%s not found!",fHitsFolder);
574 TFolder * emcalFolder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
575 if ( !emcalFolder ) {
576 Error("HitsRef", "-> Folder //%s/EMCAL/ not found!",fHitsFolder);
580 TObject * h = emcalFolder->FindObject("Hits") ;
583 Error("HitsRef", "-> %s/Hits not found !",emcalFolder->GetName());
587 return emcalFolder->GetListOfFolders()->GetObjectRef(h) ;
590 //____________________________________________________________________________
592 const Bool_t AliEMCALGetter::PostSDigits(const char * name, const char * headerFile) const
594 //---------- SDigits -------------------------
595 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/headerFile/sdigitsname
596 // because you can have sdigits from several hit files for mixing
598 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
600 if ( !emcalFolder ) {
602 Warning("PostSDigits", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
603 Info("PostSDigits", "-> Adding Folder //%s/EMCAL/",fHitsFolder);
605 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
608 TString subdir(headerFile) ;
609 subdir.ReplaceAll("/", "_") ;
610 TFolder * emcalSubFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject(subdir)) ;
611 if ( !emcalSubFolder )
612 emcalSubFolder = emcalFolder->AddFolder(subdir, "");
614 TObject * sd = emcalSubFolder->FindObject(name);
617 TClonesArray * sdigits = new TClonesArray("AliEMCALDigit",1) ;
618 sdigits->SetName(name) ;
619 emcalSubFolder->Add(sdigits) ;
625 //____________________________________________________________________________
627 TObject ** AliEMCALGetter::SDigitsRef(const char * name, const char * file) const
629 //------- SDigits ----------------------
630 // the hierarchy is //Folders/RunMC/Event/Data/EMCAL/SDigits/filename/SDigits
632 if ( !fSDigitsFolder ) {
633 Fatal("SDigitsRef", "-> Folder //%s not found!", fSDigitsFolder);
636 TFolder * emcalFolder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
638 if ( !emcalFolder ) {
639 Fatal("SDigitsRef", "-> Folder //%s/EMCAL/ not found!", fSDigitsFolder);
642 TFolder * emcalSubFolder = 0 ;
645 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(file)) ;
647 emcalSubFolder = dynamic_cast<TFolder *>(emcalFolder->FindObject(fHeaderFile)) ;
649 if(!emcalSubFolder) {
650 Fatal("SDigitsRef", "-> Folder //Folders/RunMC/Event/Data/EMCAL/%s not found!", file);
653 TObject * dis = emcalSubFolder->FindObject(name) ;
656 Fatal("SDigitsRef", "-> object %s not found!", name);
659 return emcalSubFolder->GetListOfFolders()->GetObjectRef(dis) ;
662 //____________________________________________________________________________
664 const Bool_t AliEMCALGetter::PostSDigitizer(AliEMCALSDigitizer * sdigitizer) const
666 //---------- SDigitizer -------------------------
667 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
669 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
672 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!",fTasksFolder);
676 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
680 Warning("PostSDigitizer", "->//%s/SDigitizer/EMCAL/ not found!",fTasksFolder);
681 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL/", fTasksFolder);
683 emcal = new TTask("EMCAL", "") ;
687 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdigitizer->GetName() ));
691 Info("PostSDigitizer", "-> Task %s already exists",sdigitizer->GetName());
692 emcal->GetListOfTasks()->Remove(emcalsd) ;
695 emcal->Add(sdigitizer) ;
700 //____________________________________________________________________________
702 TObject ** AliEMCALGetter::SDigitizerRef(const char * name) const
704 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
707 Fatal("SDigitizerRef", "-> Task //%s/SDigitizer not found!", fTasksFolder);
710 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
713 Fatal("SDigitizerRef", "-> //%s/SDigitizer/EMCAL not found!", fTasksFolder);
716 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
718 return emcal->GetListOfTasks()->GetObjectRef(task) ;
721 //____________________________________________________________________________
723 const Bool_t AliEMCALGetter::PostSDigitizer(const char * name, const char * file) const
725 //---------- SDigitizer -------------------------
726 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
728 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
731 Error("PostSDigitizer", "-> Task //%s/SDigitizer not found!", fTasksFolder);
735 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
739 Warning("PostSDigitizer", "-> //%s/SDigitizer/EMCAL/ not found!", fTasksFolder);
741 Info("PostSDigitizer", "-> Adding //%s/SDigitizer/EMCAL", fTasksFolder);
744 emcal = new TTask("EMCAL", "") ;
748 TString sdname(name) ;
751 sdname.ReplaceAll("/","_") ;
752 AliEMCALSDigitizer * emcalsd = dynamic_cast<AliEMCALSDigitizer *>(emcal->GetListOfTasks()->FindObject( sdname ));
755 emcalsd = new AliEMCALSDigitizer() ;
757 //Note, we can not call constructor with parameters: it will call Getter and screw up everething
759 emcalsd->SetName(sdname) ;
760 emcalsd->SetTitle(file) ;
761 emcal->Add(emcalsd) ;
767 //____________________________________________________________________________
769 const Bool_t AliEMCALGetter::PostDigits(const char * name) const
771 //---------- Digits -------------------------
772 // the hierarchy is //Folders/Run/Event/Data/EMCAL/SDigits/name
774 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
776 if ( !emcalFolder ) {
778 Warning("PostDigits", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
779 Info("PostDigits", "-> Adding Folder //%s/EMCAL/", fDigitsFolder);
781 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
784 TObject* dig = emcalFolder->FindObject( name ) ;
787 TClonesArray * digits = new TClonesArray("AliEMCALDigit",1000) ;
788 digits->SetName(name) ;
789 emcalFolder->Add(digits) ;
795 //____________________________________________________________________________
797 TObject ** AliEMCALGetter::DigitsRef(const char * name) const
799 //------- Digits ----------------------
800 // the hierarchy is //Folders/Run/Event/Data/EMCAL/Digits/name
802 if ( !fDigitsFolder ) {
803 Fatal("DigitsRef", "-> Folder //%s not found!", fDigitsFolder);
806 TFolder * emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
808 if ( !emcalFolder ) {
809 Fatal("DigitsRef", "-> Folder //%s/EMCAL/ not found!", fDigitsFolder);
812 TObject * d = emcalFolder->FindObject(name) ;
815 Fatal("DigitsRef", "-> object %s not found!", name);
818 return emcalFolder->GetListOfFolders()->GetObjectRef(d) ;
821 //____________________________________________________________________________
823 const Bool_t AliEMCALGetter::PostDigitizer(AliEMCALDigitizer * digitizer) const
825 //---------- Digitizer -------------------------
827 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
830 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
834 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
838 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
839 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
841 emcal = new TTask("EMCAL", "") ;
845 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(digitizer->GetName())) ;
849 emcal->GetListOfTasks()->Remove(emcald) ;
852 emcal->Add(digitizer) ;
857 //____________________________________________________________________________
859 const Bool_t AliEMCALGetter::PostDigitizer(const char * name) const
861 //---------- Digitizer -------------------------
862 // the hierarchy is //Folders/Tasks/SDigitizer/EMCAL/sdigitsname
864 TTask * d = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
868 Error("PostDigitizer", "-> Task //%s/Digitizer not found!", fTasksFolder);
872 TTask * emcal = dynamic_cast<TTask*>(d->GetListOfTasks()->FindObject("EMCAL")) ;
876 Warning("PostDigitizer", "-> //%s/Digitizer/EMCAL not found!", fTasksFolder);
878 Info("PostDigitizer", "-> Adding //%s/Digitizer/EMCAL", fTasksFolder);
880 emcal = new TTask("EMCAL", "") ;
884 AliEMCALDigitizer * emcald = dynamic_cast<AliEMCALDigitizer*>(emcal->GetListOfTasks()->FindObject(name)) ;
887 emcald = new AliEMCALDigitizer() ;
888 emcald->SetName(fDigitsTitle) ;
889 emcald->SetTitle(fHeaderFile) ;
896 //____________________________________________________________________________
898 TObject ** AliEMCALGetter::DigitizerRef(const char * name) const
901 TTask * sd = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
904 Fatal("DigitizerRef", "-> Task //%s/Digitizer not found!", fTasksFolder->GetName());
907 TTask * emcal = dynamic_cast<TTask*>(sd->GetListOfTasks()->FindObject("EMCAL")) ;
910 Fatal("DigitizerRef", "-> //%s/Digitizer/EMCAL", fTasksFolder->GetName());
913 TTask * task = dynamic_cast<TTask*>(emcal->GetListOfTasks()->FindObject(name)) ;
915 return emcal->GetListOfTasks()->GetObjectRef(task) ;
918 //____________________________________________________________________________
920 const Bool_t AliEMCALGetter::PostRecPoints(const char * name) const
922 // -------------- RecPoints -------------------------------------------
923 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
924 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
926 TFolder * emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
928 if ( !emcalFolder ) {
930 Warning("PostRecPoints", "-> Folder //%s/EMCAL/ not found!", fRecoFolder);
931 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/", fRecoFolder);
933 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
938 TFolder * emcalRPoTowerFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("TowerRecPoints")) ;
940 if ( !emcalRPoTowerFolder ) {
943 Warning("PostRecPoints", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
944 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/TowerRecPoints not found!", fRecoFolder);
946 emcalRPoTowerFolder = emcalFolder->AddFolder("TowerRecPoints", "Tower RecPoints from EMCAL") ;
949 TObject * erp = emcalFolder->FindObject( name ) ;
952 TObjArray * towerrp = new TObjArray(100) ;
953 towerrp->SetName(name) ;
954 emcalRPoTowerFolder->Add(towerrp) ;
957 // Pre Shower RecPoints
959 TFolder * emcalRPoPreShoFolder = dynamic_cast<TFolder*>(emcalFolder->FindObject("PreShowerRecPoints")) ;
961 if ( !emcalRPoPreShoFolder ) {
963 Warning("PostRecPoints", "-> Folder //%s/EMCAL/PreShowerRecPoints/ not found!", fRecoFolder);
964 Info("PostRecPoints", "-> Adding Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
966 emcalRPoPreShoFolder = emcalFolder->AddFolder("PreShowerRecPoints", "PreSho RecPoints from EMCAL") ;
969 TObject * crp = emcalRPoPreShoFolder->FindObject( name ) ;
972 TObjArray * preshorp = new TObjArray(100) ;
973 preshorp->SetName(name) ;
974 emcalRPoPreShoFolder->Add(preshorp) ;
980 //____________________________________________________________________________
982 TObject ** AliEMCALGetter::TowerRecPointsRef(const char * name) const
984 // -------------- RecPoints -------------------------------------------
985 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/TowerRecPoints/name
987 if ( !fRecoFolder ) {
988 Fatal("TowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
991 TFolder * towerFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
993 if ( !towerFolder ) {
994 Fatal("TowerRecPointsRef", "-> Folder //%s/EMCAL/TowerRecPoints/ not found!", fRecoFolder);
997 TObject * trp = towerFolder->FindObject(name ) ;
1000 Fatal("TowerRecPointsRef", "-> Object %s not found!", name);
1003 return towerFolder->GetListOfFolders()->GetObjectRef(trp) ;
1006 //____________________________________________________________________________
1008 TObject ** AliEMCALGetter::PreShowerRecPointsRef(const char * name) const
1010 // -------------- RecPoints -------------------------------------------
1011 // the hierarchy is //Folders/Run/Event/RecData/EMCAL/PreShowerRecPoints/name
1013 if ( !fRecoFolder ) {
1014 Fatal("PreShowerRecPointsRef", "-> Folder //%s not found!", fRecoFolder);
1017 TFolder * preshoFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
1019 if ( !preshoFolder ) {
1020 Fatal("PreShowerRecPointsRef", "-> Folder //%s/EMCAL/PreShowerRecPoints/", fRecoFolder);
1025 TObject * prp = preshoFolder->FindObject(name ) ;
1028 Fatal("PreShowerRecPointsRef", "-> Object %s not found!", name);
1031 return preshoFolder->GetListOfFolders()->GetObjectRef(prp) ;
1034 //____________________________________________________________________________
1036 const Bool_t AliEMCALGetter::PostClusterizer(AliEMCALClusterizer * clu) const
1038 // ------------------ AliEMCALClusterizer ------------------------
1039 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1041 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1044 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder);
1048 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1052 Warning("PostClusterizer", "-> //%s/ReconstructionerEMCAL not found!", fTasksFolder);
1053 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
1055 emcal = new TTask("EMCAL", "") ;
1059 AliEMCALClusterizerv1 * emcalcl = dynamic_cast<AliEMCALClusterizerv1*>(emcal->GetListOfTasks()->FindObject(clu->GetName())) ;
1063 Info("PostClusterizer", "-> Task %s already exists", clu->GetName());
1065 emcal->GetListOfTasks()->Remove(emcalcl) ;
1072 //____________________________________________________________________________
1074 TObject ** AliEMCALGetter::ClusterizerRef(const char * name) const
1076 // ------------------ AliEMCALClusterizer ------------------------
1078 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1081 Fatal("ClusterizerRef", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
1084 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1087 Fatal("ClusterizerRef", "-> //%s/Reconstructioner/EMCAL", fTasksFolder->GetName());
1090 TList * l = emcal->GetListOfTasks() ;
1094 TString cluname(name) ;
1097 while((task = static_cast<TTask *>(it.Next()) )){
1098 TString taskname(task->GetName()) ;
1099 if(taskname.BeginsWith(cluname)){
1106 Fatal("ClusterizerRef", "-> task %s not found!", task->GetName());
1109 return l->GetObjectRef(clu) ;
1112 //____________________________________________________________________________
1114 const Bool_t AliEMCALGetter::PostClusterizer(const char * name) const
1116 // ------------------ AliEMCALClusterizer ------------------------
1117 // the hierarchy is //Folders/Tasks/Reconstructioner/EMCAL/sdigitsname
1120 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1123 Error("PostClusterizer", "-> Task //%s/Reconstructioner not found!", fTasksFolder->GetName());
1127 TTask * emcal = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1131 Warning("PostClusterizer", "-> //%s/Reconstructioner/EMCAL not found!", fTasksFolder);
1132 Info("PostClusterizer", "-> Adding //%s/Reconstructioner/EMCAL", fTasksFolder);
1134 emcal = new TTask("EMCAL", "") ;
1138 TList * l = emcal->GetListOfTasks() ;
1140 TString clun(name) ;
1144 while((task = static_cast<TTask *>(it.Next()) )){
1145 TString taskname(task->GetName()) ;
1147 if(taskname.BeginsWith(clun))
1151 AliEMCALClusterizerv1 * emcalcl = new AliEMCALClusterizerv1() ;
1154 emcalcl->SetName(clun) ;
1155 emcalcl->SetTitle(fHeaderFile) ;
1156 emcal->Add(emcalcl) ;
1161 //____________________________________________________________________________
1163 TTree * AliEMCALGetter::TreeK(TString filename)
1165 // returns TreeK from file filename
1166 // usefull in case of split file
1168 if ( filename.IsNull() )
1169 filename = fHeaderFile ;
1173 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1175 if (!file) { // file not yet open
1176 file = TFile::Open(filename.Data(), "read") ;
1179 TString treeName("TreeK") ;
1180 treeName += EventNumber() ;
1181 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1183 if (!tree && fDebug)
1184 Warning("TreeK", "-> %s not found in %s", treeName.Data(),filename.Data());
1189 //____________________________________________________________________________
1191 TTree * AliEMCALGetter::TreeH(TString filename)
1193 // returns TreeH from file filename
1194 // usefull in case of split file
1196 if ( filename.IsNull() )
1197 filename = fHeaderFile ;
1200 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1202 if (!file) { // file not open yet
1203 file = TFile::Open(filename.Data(), "read") ;
1206 TString treeName("TreeH") ;
1207 treeName += EventNumber() ;
1208 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1210 if (!tree && fDebug)
1211 Warning("TreeH", "-> %s not found in %s", treeName.Data(), filename.Data());
1215 //____________________________________________________________________________
1217 TTree * AliEMCALGetter::TreeS(TString filename)
1219 // returns TreeS from file filename
1220 // usefull in case of split file
1222 if ( filename.IsNull() )
1223 filename = fHeaderFile ;
1226 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1228 if (!file) { // file not open yet
1229 file = TFile::Open(filename.Data(), "read") ;
1232 TString treeName("TreeS") ;
1233 treeName += EventNumber() ;
1234 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1236 if (!tree && fDebug)
1237 Warning("TreeS", "-> %s not found in %s", treeName.Data(), filename.Data());
1241 //____________________________________________________________________________
1243 TTree * AliEMCALGetter::TreeD(TString filename)
1245 // returns TreeD from file filename
1246 // usefull in case of split file
1248 if ( filename.IsNull() )
1249 filename = fHeaderFile ;
1252 file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
1254 if (!file) { // file not open yet
1255 file = TFile::Open(filename.Data(), "read") ;
1258 TString treeName("TreeD") ;
1259 treeName += EventNumber() ;
1260 TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
1262 if (!tree && fDebug)
1263 Warning("TreeD", "-> %s not found in %s", treeName.Data(), filename.Data());
1267 //____________________________________________________________________________
1269 const TParticle * AliEMCALGetter::Primary(Int_t index) const
1271 // Return primary particle numbered by <index>
1277 p = gAlice->Particle(index) ;
1282 //____________________________________________________________________________
1284 const TParticle * AliEMCALGetter::Secondary(TParticle* p, Int_t index) const
1286 // Return first (index=1) or second (index=2) secondary particle of primary particle p
1294 Int_t daughterIndex = p->GetDaughter(index-1) ;
1295 return gAlice->Particle(daughterIndex) ;
1301 //____________________________________________________________________________
1303 Int_t AliEMCALGetter::ReadTreeD(const Int_t event)
1305 // Read the digit tree gAlice->TreeD()
1309 TFile * file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName));
1311 file = TFile::Open(fDigitsFileName) ;
1313 // Get Digits Tree header from file
1315 TString treeName("TreeD") ;
1317 treeD = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1319 if(!treeD){ // TreeD not found in header file
1321 Warning("ReadTreeD", "-> Cannot find TreeD in %s", fDigitsFileName.Data());
1326 treeD = gAlice->TreeD() ;
1328 TObjArray * lob = static_cast<TObjArray*>(treeD->GetListOfBranches()) ;
1330 TBranch * branch = 0 ;
1331 TBranch * digitsbranch = 0 ;
1332 TBranch * digitizerbranch = 0 ;
1334 Bool_t emcalfound = kFALSE, digitizerfound = kFALSE ;
1336 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !digitizerfound) ) {
1337 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1338 digitsbranch = branch ;
1339 emcalfound = kTRUE ;
1341 else if ( (strcmp(branch->GetName(), "AliEMCALDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
1342 digitizerbranch = branch ;
1343 digitizerfound = kTRUE ;
1347 if ( !emcalfound || !digitizerfound ) {
1349 Warning("ReadTreeD", "-> Cannot find Digits and/or Digitizer with name %s", fDigitsTitle.Data());
1355 if(!Digits(fDigitsTitle) )
1356 PostDigits(fDigitsTitle);
1357 digitsbranch->SetAddress(DigitsRef(fDigitsTitle)) ;
1358 digitsbranch->GetEntry(0) ;
1360 // read the Digitizer
1362 RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that
1363 if(!Digitizer(fDigitsTitle))
1364 PostDigitizer(fDigitsTitle) ;
1365 digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
1366 digitizerbranch->GetEntry(0) ;
1370 if(gAlice->TreeD()!=treeD)
1376 //____________________________________________________________________________
1378 Int_t AliEMCALGetter::ReadTreeH()
1380 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1382 TTree * treeH = gAlice->TreeH() ;
1384 if(!treeH) {// TreeH not found in header file
1386 Warning("ReadTreeH", "-> Cannot find TreeH in %s", fHeaderFile.Data());
1388 TString searchFileName("EMCAL.HITS") ;
1389 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
1390 searchFileName+="." ;
1391 searchFileName += fBranchTitle ;
1394 searchFileName+=".root" ;
1396 if ( (treeH = TreeH(searchFileName)) ) { //found TreeH in the file which contains the hits
1398 Info("ReadTreeH", "-> TreeH found in %s", searchFileName.Data());
1400 Error("ReadTreeH", "-> TreeH not found ");
1405 TBranch * hitsbranch = static_cast<TBranch*>(gAlice->TreeH()->GetBranch("EMCAL")) ;
1407 if ( !hitsbranch ) {
1409 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
1416 if (hitsbranch->GetEntries() > 1 ) {
1417 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1418 TClonesArray * tempo = new TClonesArray("AliEMCALHit",1000) ;
1419 TClonesArray * hits = dynamic_cast<TClonesArray*>(*HitsRef()) ;
1420 hitsbranch->SetAddress(&tempo) ;
1425 for (i = 0 ; i < hitsbranch->GetEntries() ; i++) {
1426 hitsbranch->GetEntry(i) ;
1428 for ( j = 0 ; j < tempo->GetEntries() ; j++) {
1429 const AliEMCALHit * hit = static_cast<const AliEMCALHit *>(tempo->At(j)) ;
1430 new((*hits)[index]) AliEMCALHit( *hit ) ;
1437 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1438 hitsbranch->SetAddress(HitsRef()) ;
1439 hitsbranch->GetEntry(0) ;
1444 //____________________________________________________________________________
1446 void AliEMCALGetter::Track(const Int_t itrack)
1448 // Read the first entry of EMCAL branch in hit tree gAlice->TreeH()
1449 if(gAlice->TreeH()== 0){
1450 Error("ReadTreeH", "-> Cannot read TreeH ");
1454 TBranch * hitsbranch = dynamic_cast<TBranch*>(gAlice->TreeH()->GetListOfBranches()->FindObject("EMCAL")) ;
1456 if ( !hitsbranch ) {
1458 Warning("ReadTreeH", "-> Cannot find branch EMCAL");
1465 (dynamic_cast<TClonesArray*> (*HitsRef()))->Clear() ;
1466 hitsbranch->SetAddress(HitsRef()) ;
1467 hitsbranch->GetEntry(itrack) ;
1470 //____________________________________________________________________________
1472 void AliEMCALGetter::ReadTreeQA()
1475 Warning("ReadTreeQA", "-> %s not implemented", ClassName());
1480 //____________________________________________________________________________
1482 Int_t AliEMCALGetter::ReadTreeR(const Int_t event)
1485 // Read the reconstrunction tree gAlice->TreeR()
1486 // A particularity has been introduced here :
1487 // if gime->Event(ievent,"R") is called branches with the current title are read, the current title
1488 // being for example give in AliEMCALPID(fileName, title)
1489 // if gime(Event(ievent, "RA") is called the title of the branches is not checked anymore, "A" stands for any
1490 // This is a feature needed by PID to be able to reconstruct several times particles (each time a ther title is given)
1491 // from a given set of TrackSegments (with a given name)
1492 // This is why any is NOT used to read the branch of RecParticles
1493 // any migh have become obsolete : to be checked
1494 // See AliEMCALPIDv1
1499 TFile * file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName));
1501 file = TFile::Open(fRecPointsFileName) ;
1502 Info("ReadTreeR", "file=%s\n",fRecPointsFileName.Data());
1503 // Get Digits Tree header from file
1505 TString treeName("TreeR") ;
1507 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1509 if(!treeR){ // TreeR not found in header file
1511 Warning("ReadTreeD", "-> Cannot find TreeR in %s", fRecPointsFileName.Data());
1516 treeR = gAlice->TreeR() ;
1520 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
1522 TBranch * branch = 0 ;
1523 TBranch * towerbranch = 0 ;
1524 TBranch * preshowerbranch = 0 ;
1525 TBranch * clusterizerbranch = 0 ;
1527 Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
1529 while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1530 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
1531 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1532 towerbranch = branch ;
1533 emcalTowerRPfound = kTRUE ;
1535 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1536 preshowerbranch = branch ;
1537 emcalPreShoRPfound = kTRUE ;
1539 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1540 clusterizerbranch = branch ;
1541 clusterizerfound = kTRUE ;
1546 if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
1548 Warning("ReadTreeR", "-> Cannot find RecPoints and/or Clusterizer with name %s", fRecPointsTitle.Data());
1551 if(!TowerRecPoints(fRecPointsTitle) )
1552 PostRecPoints(fRecPointsTitle) ;
1553 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1554 towerbranch->GetEntry(0) ;
1556 preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
1557 preshowerbranch->GetEntry(0) ;
1559 if(!Clusterizer(fRecPointsTitle) )
1560 PostClusterizer(fRecPointsTitle) ;
1562 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1563 clusterizerbranch->GetEntry(0) ;
1566 if(gAlice->TreeR()!=treeR)
1571 //____________________________________________________________________________
1573 Int_t AliEMCALGetter::ReadTreeS(const Int_t event)
1575 // Reads the SDigits treeS from all files
1576 // Files, which should be opened are listed in emcalF
1577 // So, first get list of files
1579 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1582 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1584 TCollection * folderslist = emcalF->GetListOfFolders() ;
1586 // Now iterate over the list of files and read TreeS into Whiteboard
1588 TIter next(folderslist) ;
1589 TFolder * folder = 0 ;
1593 while ( (folder = static_cast<TFolder*>(next())) ) {
1594 TString fileName("") ;
1596 fileName = folder->GetTitle() ;
1598 fileName = folder->GetName() ;
1600 fileName.ReplaceAll("_","/") ;
1601 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1604 file = TFile::Open(fileName) ;
1606 // Get SDigits Tree header from file
1608 TString treeName("TreeS") ;
1610 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1612 if(!treeS){ // TreeS not found in header file
1614 Warning("ReadTreeS", "-> Cannot find TreeS in %s", fileName.Data());
1618 //set address of the SDigits and SDigitizer
1620 TBranch * sdigitsBranch = 0;
1621 TBranch * sdigitizerBranch = 0;
1622 TBranch * branch = 0 ;
1623 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1626 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1628 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1629 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1630 emcalfound = kTRUE ;
1631 sdigitsBranch = branch ;
1633 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
1634 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1635 sdigitizerfound = kTRUE ;
1636 sdigitizerBranch = branch ;
1639 if ( !emcalfound || !sdigitizerfound ) {
1641 Warning("ReadSDigits", "-> Digits and/or Digitizer branch with name %s not found", GetName());
1645 if ( !folder->FindObject(fSDigitsTitle) )
1646 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1648 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
1650 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1651 sdigitsBranch->GetEntry(0) ;
1653 TString sdname(fSDigitsTitle) ;
1655 sdname+=folder->GetName() ;
1657 if(!SDigitizer(sdname) )
1658 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1660 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1661 sdigitizerBranch->GetEntry(0) ;
1663 if(gAlice->TreeS()!=treeS)
1669 //____________________________________________________________________________
1671 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1673 // Read the summable digits fron treeS()
1675 TString filename("mergefile") ;
1678 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1679 if ( !emcalFolder ) {
1680 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1683 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1685 //set address of the SDigits and SDigitizer
1687 TBranch * sdigitsBranch = 0;
1688 TBranch * sdigitizerBranch = 0;
1689 TBranch * branch = 0 ;
1690 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1693 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1695 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1696 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1697 emcalfound = kTRUE ;
1698 sdigitsBranch = branch ;
1700 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1701 sdigitizerfound = kTRUE ;
1702 sdigitizerBranch = branch ;
1706 if ( !emcalfound || !sdigitizerfound ) {
1708 Warning("ReadTreeS", "-> Digits and/or Digitizer branch not found");
1712 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1713 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1715 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1716 sdigitsBranch->GetEntry(0) ;
1718 TString sdname(sdigitsBranch->GetTitle()) ;
1722 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1723 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1725 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1726 sdigitizerBranch->GetEntry(0) ;
1728 if(gAlice->TreeS()!=treeS)
1732 //____________________________________________________________________________
1734 void AliEMCALGetter::ReadPrimaries()
1737 // Reads specific branches of primaries
1739 TClonesArray * ar = 0 ;
1741 if(! (ar = Primaries()) ) {
1748 if (TreeK(fHeaderFile)) { // treeK found in header file
1750 Info("ReadPrimaries", "-> TreeK found in %s", fHeaderFile.Data());
1751 fNPrimaries = gAlice->GetNtrack() ;
1753 else { // treeK not found in header file
1754 Error("ReadPrimaries", "-> TreeK not found ");
1760 for (index = 0 ; index < fNPrimaries; index++) {
1761 new ((*ar)[index]) TParticle(*(Primary(index)));
1765 //____________________________________________________________________________
1767 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1769 // Reads the content of all Tree's S, D and R
1771 if (event >= gAlice->TreeE()->GetEntries() ) {
1772 Error("Event", "-> %d not found in TreeE!", event);
1776 Bool_t any = kFALSE ;
1778 if (strstr(opt,"A") ) // do not check the title of the branches
1781 gAlice->GetEvent(event) ;
1783 if( strstr(opt,"R") )
1786 if( strstr(opt,"D") )
1789 if(strstr(opt,"S") )
1792 if(strstr(opt,"H") )
1795 if( strstr(opt,"Q") )
1798 if( strstr(opt,"P") )
1802 //____________________________________________________________________________
1804 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1806 // get the object named "what" from the folder
1807 // folders are named like //Folders
1809 if ( file.IsNull() )
1810 file = fHeaderFile ;
1812 TFolder * folder = 0 ;
1813 TObject * emcalO = 0 ;
1815 if ( what.CompareTo("Primaries") == 0 ) {
1816 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1818 emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1822 else if ( what.CompareTo("Hits") == 0 ) {
1823 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1825 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1827 else if ( what.CompareTo("SDigits") == 0 ) {
1828 file.ReplaceAll("/","_") ;
1829 TString path = "EMCAL/" + file ;
1830 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1833 name = fSDigitsTitle ;
1834 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1837 else if ( what.CompareTo("Digits") == 0 ){
1838 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1841 name = fDigitsTitle ;
1842 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1845 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1846 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1849 name = fRecPointsTitle ;
1850 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1853 else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
1854 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
1857 name = fRecPointsTitle ;
1858 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1864 Warning("ReturnO", "-> Object %s not found in %s", what.Data(), folder->GetName());
1871 //____________________________________________________________________________
1873 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1875 // get the TTask named "what" from the folder
1876 // folders are named like //Folders/Tasks/what/EMCAL/name
1878 TString search(what) ;
1879 if ( what.CompareTo("Clusterizer") == 0 )
1880 search = "Reconstructioner" ;
1881 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1882 search = "Reconstructioner" ;
1883 else if ( what.CompareTo("PID") == 0 )
1884 search = "Reconstructioner" ;
1885 else if ( what.CompareTo("QATasks") == 0 )
1888 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1891 Error("AliReturnT", "-> Task %s not found!", what.Data());
1895 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1898 Error("ReturnT", "-> Task %s/EMCAL not found!", what.Data());
1902 TList * list = emcalT->GetListOfTasks() ;
1904 if (what.CompareTo("SDigitizer") == 0) {
1905 if ( name.IsNull() )
1906 name = fSDigitsTitle ;
1908 else if (what.CompareTo("Digitizer") == 0){
1909 if ( name.IsNull() )
1910 name = fDigitsTitle ;
1912 else if (what.CompareTo("Clusterizer") == 0){
1913 if ( name.IsNull() )
1914 name = fRecPointsTitle ;
1915 name.Append(":clu") ;
1921 while((task = static_cast<TTask *>(it.Next()) )){
1922 TString taskname(task->GetName()) ;
1923 if(taskname.BeginsWith(name)){
1928 Warning("ReturnT", "-> Task %s/%s not found!", search.Data(), name.Data());
1932 //____________________________________________________________________________
1934 void AliEMCALGetter::RemoveTask(TString opt, TString name) const
1937 // remove a task from the folder
1938 // path is fTasksFolder/SDigitizer/EMCAL/name
1942 TList * lofTasks = 0 ;
1944 if (opt == "S") { // SDigitizer
1945 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
1949 else if (opt == "D") { // Digitizer
1950 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
1954 else if (opt == "C") { // Clusterizer
1955 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1960 Warning("RemoveTask", "-> Unknown option %s");
1964 emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
1969 lofTasks = emcal->GetListOfTasks() ;
1974 TObject * obj = lofTasks->FindObject(name) ;
1977 lofTasks->Remove(obj) ;
1980 //____________________________________________________________________________
1982 void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
1984 // remove SDigits from the folder
1985 // path is fSDigitsFolder/fHeaderFileName/name
1987 TFolder * emcal = 0 ;
1988 TFolder * emcalmain = 0 ;
1990 if (opt == "H") { // Hits
1991 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
1996 else if ( opt == "S") { // SDigits
1997 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2000 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2004 else if (opt == "D") { // Digits
2005 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2009 else if (opt == "RT") { // Tower RecPoints
2010 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2014 else if (opt == "RP") { // Preshower RecPoints
2015 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2019 else if (opt == "T") { // TrackSegments
2020 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2024 else if (opt == "P") { // RecParticles
2025 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2030 Warning("RemoveObjects", "-> Unknown option %s", opt.Data());
2034 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
2043 emcalmain->Remove(emcal) ;
2046 //____________________________________________________________________________
2048 void AliEMCALGetter::RemoveSDigits() const
2050 TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2059 //____________________________________________________________________________
2061 void AliEMCALGetter::CleanWhiteBoard(void){
2063 TFolder * emcalmain = 0 ;
2066 TList * lofTasks = 0 ;
2068 TTask * emcalt = 0 ;
2072 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2075 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
2085 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2088 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2090 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
2097 emcalmain->Remove(emcal) ;
2102 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2105 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
2115 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2118 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2126 // PreShowerRecPoints
2128 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2131 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2141 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2144 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
2154 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2157 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
2165 //---- Now Tasks -----------
2168 TString sdname(fSDigitsTitle);
2172 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2175 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2177 lofTasks = emcalt->GetListOfTasks() ;
2179 obj = lofTasks->FindObject(sdname.Data()) ;
2181 lofTasks->Remove(obj) ;
2186 sdname.Append(":") ;
2188 // Clusterizer, TrackSegmentMaker, PID
2190 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2193 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2195 lofTasks = emcalt->GetListOfTasks() ;
2196 TIter next(lofTasks);
2197 while((obj=next())){
2198 TString oname(obj->GetName()) ;
2199 if (oname.BeginsWith(sdname)){
2200 lofTasks->Remove(obj) ;
2208 sdname.Append(fHeaderFile) ;
2209 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2212 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2214 lofTasks = emcalt->GetListOfTasks() ;
2216 obj = lofTasks->FindObject(sdname.Data()) ;
2218 lofTasks->Remove(obj) ;
2224 //____________________________________________________________________________
2226 void AliEMCALGetter::SetTitle(const char * branchTitle )
2229 fBranchTitle = branchTitle ;
2230 fSDigitsTitle = branchTitle ;
2231 fDigitsTitle = branchTitle ;
2232 fRecPointsTitle = branchTitle ;
2233 fRecParticlesTitle = branchTitle ;
2234 fTrackSegmentsTitle = branchTitle ;
2238 //First - extract full path if necessary
2240 TString sFileName(fHeaderFile) ;
2241 Ssiz_t islash = sFileName.Last('/') ;
2243 if(islash<sFileName.Length())
2244 sFileName.Remove(islash+1,sFileName.Length()) ;
2248 //Now construct file names
2250 fSDigitsFileName = sFileName ;
2251 fDigitsFileName = sFileName ;
2252 fRecPointsFileName = sFileName ;
2253 fRecParticlesFileName = sFileName ;
2254 fTrackSegmentsFileName = sFileName ;
2255 fSDigitsFileName += "EMCAL.SDigits." ;
2256 fDigitsFileName += "EMCAL.Digits." ;
2257 fRecPointsFileName += "EMCAL.RecData." ;
2258 fTrackSegmentsFileName+= "EMCAL.RecData." ;
2259 fRecParticlesFileName += "EMCAL.RecData." ;
2261 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2262 fSDigitsFileName += fBranchTitle ;
2263 fSDigitsFileName += "." ;
2264 fDigitsFileName += fBranchTitle ;
2265 fDigitsFileName += "." ;
2266 fRecPointsFileName += fBranchTitle ;
2267 fRecPointsFileName += "." ;
2268 fRecParticlesFileName += fBranchTitle ;
2269 fRecParticlesFileName += "." ;
2270 fTrackSegmentsFileName+= fBranchTitle ;
2271 fTrackSegmentsFileName+= "." ;
2274 fSDigitsFileName += "root" ;
2275 fDigitsFileName += "root" ;
2276 fRecPointsFileName += "root" ;
2277 fRecParticlesFileName += "root" ;
2278 fTrackSegmentsFileName+= "root" ;
2281 fSDigitsFileName = "" ;
2282 fDigitsFileName = "" ;
2283 fRecPointsFileName = "" ;
2284 fRecParticlesFileName = "" ;
2285 fTrackSegmentsFileName = "" ;
2288 TFolder * emcalFolder ;
2289 emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2292 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
2294 emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2297 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
2299 //Make folder for SDigits
2301 TString subdir(fHeaderFile) ;
2302 subdir.ReplaceAll("/","_") ;
2304 emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
2305 emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2308 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
2310 emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
2313 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
2316 //____________________________________________________________________________
2318 void AliEMCALGetter::CloseSplitFiles(void){
2321 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2326 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2331 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2336 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2341 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;