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 // Get Digits Tree header from file
1504 TString treeName("TreeR") ;
1506 treeR = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1508 if(!treeR){ // TreeR not found in header file
1510 Warning("ReadTreeD", "-> Cannot find TreeR in %s", fRecPointsFileName.Data());
1515 treeR = gAlice->TreeR() ;
1519 TObjArray * lob = static_cast<TObjArray*>(treeR->GetListOfBranches()) ;
1521 TBranch * branch = 0 ;
1522 TBranch * towerbranch = 0 ;
1523 TBranch * preshowerbranch = 0 ;
1524 TBranch * clusterizerbranch = 0 ;
1526 Bool_t emcalTowerRPfound = kFALSE, emcalPreShoRPfound = kFALSE, clusterizerfound = kFALSE ;
1528 while ( (branch = static_cast<TBranch*>(next())) && (!emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) ) {
1529 if(strcmp(branch->GetTitle(), fRecPointsTitle)==0 ) {
1530 if ( strcmp(branch->GetName(), "EMCALTowerRP")==0) {
1531 towerbranch = branch ;
1532 emcalTowerRPfound = kTRUE ;
1534 else if ( strcmp(branch->GetName(), "EMCALPreShoRP")==0) {
1535 preshowerbranch = branch ;
1536 emcalPreShoRPfound = kTRUE ;
1538 else if(strcmp(branch->GetName(), "AliEMCALClusterizer")==0){
1539 clusterizerbranch = branch ;
1540 clusterizerfound = kTRUE ;
1545 if ( !emcalTowerRPfound || !emcalPreShoRPfound || !clusterizerfound) {
1547 Warning("ReadTreeR", "-> Cannot find RecPoints and/or Clusterizer with name %s", fRecPointsTitle.Data());
1550 if(!TowerRecPoints(fRecPointsTitle) )
1551 PostRecPoints(fRecPointsTitle) ;
1552 towerbranch->SetAddress(TowerRecPointsRef(fRecPointsTitle)) ;
1553 towerbranch->GetEntry(0) ;
1555 preshowerbranch->SetAddress(PreShowerRecPointsRef(fRecPointsTitle)) ;
1556 preshowerbranch->GetEntry(0) ;
1558 if(!Clusterizer(fRecPointsTitle) )
1559 PostClusterizer(fRecPointsTitle) ;
1561 clusterizerbranch->SetAddress(ClusterizerRef(fRecPointsTitle)) ;
1562 clusterizerbranch->GetEntry(0) ;
1565 if(gAlice->TreeR()!=treeR)
1570 //____________________________________________________________________________
1572 Int_t AliEMCALGetter::ReadTreeS(const Int_t event)
1574 // Reads the SDigits treeS from all files
1575 // Files, which should be opened are listed in emcalF
1576 // So, first get list of files
1578 TFolder * emcalF = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject("EMCAL")) ;
1581 emcalF = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1583 TCollection * folderslist = emcalF->GetListOfFolders() ;
1585 // Now iterate over the list of files and read TreeS into Whiteboard
1587 TIter next(folderslist) ;
1588 TFolder * folder = 0 ;
1592 while ( (folder = static_cast<TFolder*>(next())) ) {
1593 TString fileName("") ;
1595 fileName = folder->GetTitle() ;
1597 fileName = folder->GetName() ;
1599 fileName.ReplaceAll("_","/") ;
1600 file = static_cast<TFile*>(gROOT->GetFile(fileName));
1603 file = TFile::Open(fileName) ;
1605 // Get SDigits Tree header from file
1607 TString treeName("TreeS") ;
1609 treeS = dynamic_cast<TTree*>(file->Get(treeName.Data()));
1611 if(!treeS){ // TreeS not found in header file
1613 Warning("ReadTreeS", "-> Cannot find TreeS in %s", fileName.Data());
1617 //set address of the SDigits and SDigitizer
1619 TBranch * sdigitsBranch = 0;
1620 TBranch * sdigitizerBranch = 0;
1621 TBranch * branch = 0 ;
1622 TObjArray * lob = static_cast<TObjArray*>(treeS->GetListOfBranches()) ;
1625 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1627 while ( (branch = static_cast<TBranch*>(next())) && (!emcalfound || !sdigitizerfound) ) {
1628 if ( (strcmp(branch->GetName(), "EMCAL")==0) && (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1629 emcalfound = kTRUE ;
1630 sdigitsBranch = branch ;
1632 else if ( (strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) &&
1633 (strcmp(branch->GetTitle(), fSDigitsTitle)==0) ) {
1634 sdigitizerfound = kTRUE ;
1635 sdigitizerBranch = branch ;
1638 if ( !emcalfound || !sdigitizerfound ) {
1640 Warning("ReadSDigits", "-> Digits and/or Digitizer branch with name %s not found", GetName());
1644 if ( !folder->FindObject(fSDigitsTitle) )
1645 PostSDigits(fSDigitsTitle,folder->GetName()) ;
1647 ((TClonesArray*) (*SDigitsRef(fSDigitsTitle,folder->GetName())))->Clear() ;
1649 sdigitsBranch->SetAddress(SDigitsRef(fSDigitsTitle,folder->GetName())) ;
1650 sdigitsBranch->GetEntry(0) ;
1652 TString sdname(fSDigitsTitle) ;
1654 sdname+=folder->GetName() ;
1656 if(!SDigitizer(sdname) )
1657 PostSDigitizer(fSDigitsTitle,folder->GetName()) ;
1659 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1660 sdigitizerBranch->GetEntry(0) ;
1662 if(gAlice->TreeS()!=treeS)
1668 //____________________________________________________________________________
1670 void AliEMCALGetter::ReadTreeS(TTree * treeS, Int_t input)
1672 // Read the summable digits fron treeS()
1674 TString filename("mergefile") ;
1677 TFolder * emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1678 if ( !emcalFolder ) {
1679 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
1682 TFolder * folder=(TFolder*)emcalFolder->FindObject(filename) ;
1684 //set address of the SDigits and SDigitizer
1686 TBranch * sdigitsBranch = 0;
1687 TBranch * sdigitizerBranch = 0;
1688 TBranch * branch = 0 ;
1689 TObjArray * lob = (TObjArray*)treeS->GetListOfBranches() ;
1692 Bool_t emcalfound = kFALSE, sdigitizerfound = kFALSE ;
1694 while ( (branch = (TBranch*)next()) && (!emcalfound || !sdigitizerfound) ) {
1695 if ( strcmp(branch->GetName(), "EMCAL")==0) {
1696 emcalfound = kTRUE ;
1697 sdigitsBranch = branch ;
1699 else if ( strcmp(branch->GetName(), "AliEMCALSDigitizer")==0) {
1700 sdigitizerfound = kTRUE ;
1701 sdigitizerBranch = branch ;
1705 if ( !emcalfound || !sdigitizerfound ) {
1707 Warning("ReadTreeS", "-> Digits and/or Digitizer branch not found");
1711 if (!folder || !(folder->FindObject(sdigitsBranch->GetTitle()) ) )
1712 PostSDigits(sdigitsBranch->GetTitle(),filename) ;
1714 sdigitsBranch->SetAddress(SDigitsRef(sdigitsBranch->GetTitle(),filename)) ;
1715 sdigitsBranch->GetEntry(0) ;
1717 TString sdname(sdigitsBranch->GetTitle()) ;
1721 if(!SDigitizer(sdigitsBranch->GetTitle()) )
1722 PostSDigitizer(sdigitsBranch->GetTitle(),filename) ;
1724 sdigitizerBranch->SetAddress(SDigitizerRef(sdname)) ;
1725 sdigitizerBranch->GetEntry(0) ;
1727 if(gAlice->TreeS()!=treeS)
1731 //____________________________________________________________________________
1733 void AliEMCALGetter::ReadPrimaries()
1736 // Reads specific branches of primaries
1738 TClonesArray * ar = 0 ;
1740 if(! (ar = Primaries()) ) {
1747 if (TreeK(fHeaderFile)) { // treeK found in header file
1749 Info("ReadPrimaries", "-> TreeK found in %s", fHeaderFile.Data());
1750 fNPrimaries = gAlice->GetNtrack() ;
1752 else { // treeK not found in header file
1753 Error("ReadPrimaries", "-> TreeK not found ");
1759 for (index = 0 ; index < fNPrimaries; index++) {
1760 new ((*ar)[index]) TParticle(*(Primary(index)));
1764 //____________________________________________________________________________
1766 void AliEMCALGetter::Event(const Int_t event, const char* opt)
1768 // Reads the content of all Tree's S, D and R
1770 if (event >= gAlice->TreeE()->GetEntries() ) {
1771 Error("Event", "-> %d not found in TreeE!", event);
1775 Bool_t any = kFALSE ;
1777 if (strstr(opt,"A") ) // do not check the title of the branches
1780 gAlice->GetEvent(event) ;
1782 if( strstr(opt,"R") )
1785 if( strstr(opt,"D") )
1788 if(strstr(opt,"S") )
1791 if(strstr(opt,"H") )
1794 if( strstr(opt,"Q") )
1797 if( strstr(opt,"P") )
1801 //____________________________________________________________________________
1803 TObject * AliEMCALGetter::ReturnO(TString what, TString name, TString file) const
1805 // get the object named "what" from the folder
1806 // folders are named like //Folders
1808 if ( file.IsNull() )
1809 file = fHeaderFile ;
1811 TFolder * folder = 0 ;
1812 TObject * emcalO = 0 ;
1814 if ( what.CompareTo("Primaries") == 0 ) {
1815 folder = dynamic_cast<TFolder *>(fPrimariesFolder->FindObject("Primaries")) ;
1817 emcalO = dynamic_cast<TObject *>(folder->FindObject("Primaries")) ;
1821 else if ( what.CompareTo("Hits") == 0 ) {
1822 folder = dynamic_cast<TFolder *>(fHitsFolder->FindObject("EMCAL")) ;
1824 emcalO = dynamic_cast<TObject *>(folder->FindObject("Hits")) ;
1826 else if ( what.CompareTo("SDigits") == 0 ) {
1827 file.ReplaceAll("/","_") ;
1828 TString path = "EMCAL/" + file ;
1829 folder = dynamic_cast<TFolder *>(fSDigitsFolder->FindObject(path.Data())) ;
1832 name = fSDigitsTitle ;
1833 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1836 else if ( what.CompareTo("Digits") == 0 ){
1837 folder = dynamic_cast<TFolder *>(fDigitsFolder->FindObject("EMCAL")) ;
1840 name = fDigitsTitle ;
1841 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1844 else if ( what.CompareTo("TowerRecPoints") == 0 ) {
1845 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
1848 name = fRecPointsTitle ;
1849 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1852 else if ( what.CompareTo("PreShowerRecPoints") == 0 ) {
1853 folder = dynamic_cast<TFolder *>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
1856 name = fRecPointsTitle ;
1857 emcalO = dynamic_cast<TObject *>(folder->FindObject(name)) ;
1863 Warning("ReturnO", "-> Object %s not found in %s", what.Data(), folder->GetName());
1870 //____________________________________________________________________________
1872 const TTask * AliEMCALGetter::ReturnT(TString what, TString name) const
1874 // get the TTask named "what" from the folder
1875 // folders are named like //Folders/Tasks/what/EMCAL/name
1877 TString search(what) ;
1878 if ( what.CompareTo("Clusterizer") == 0 )
1879 search = "Reconstructioner" ;
1880 else if ( what.CompareTo("TrackSegmentMaker") == 0 )
1881 search = "Reconstructioner" ;
1882 else if ( what.CompareTo("PID") == 0 )
1883 search = "Reconstructioner" ;
1884 else if ( what.CompareTo("QATasks") == 0 )
1887 TTask * tasks = dynamic_cast<TTask*>(fTasksFolder->FindObject(search)) ;
1890 Error("AliReturnT", "-> Task %s not found!", what.Data());
1894 TTask * emcalT = dynamic_cast<TTask*>(tasks->GetListOfTasks()->FindObject("EMCAL")) ;
1897 Error("ReturnT", "-> Task %s/EMCAL not found!", what.Data());
1901 TList * list = emcalT->GetListOfTasks() ;
1903 if (what.CompareTo("SDigitizer") == 0) {
1904 if ( name.IsNull() )
1905 name = fSDigitsTitle ;
1907 else if (what.CompareTo("Digitizer") == 0){
1908 if ( name.IsNull() )
1909 name = fDigitsTitle ;
1911 else if (what.CompareTo("Clusterizer") == 0){
1912 if ( name.IsNull() )
1913 name = fRecPointsTitle ;
1914 name.Append(":clu") ;
1920 while((task = static_cast<TTask *>(it.Next()) )){
1921 TString taskname(task->GetName()) ;
1922 if(taskname.BeginsWith(name)){
1927 Warning("ReturnT", "-> Task %s/%s not found!", search.Data(), name.Data());
1931 //____________________________________________________________________________
1933 void AliEMCALGetter::RemoveTask(TString opt, TString name) const
1936 // remove a task from the folder
1937 // path is fTasksFolder/SDigitizer/EMCAL/name
1941 TList * lofTasks = 0 ;
1943 if (opt == "S") { // SDigitizer
1944 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
1948 else if (opt == "D") { // Digitizer
1949 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
1953 else if (opt == "C") { // Clusterizer
1954 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
1959 Warning("RemoveTask", "-> Unknown option %s");
1963 emcal = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
1968 lofTasks = emcal->GetListOfTasks() ;
1973 TObject * obj = lofTasks->FindObject(name) ;
1976 lofTasks->Remove(obj) ;
1979 //____________________________________________________________________________
1981 void AliEMCALGetter::RemoveObjects(TString opt, TString name) const
1983 // remove SDigits from the folder
1984 // path is fSDigitsFolder/fHeaderFileName/name
1986 TFolder * emcal = 0 ;
1987 TFolder * emcalmain = 0 ;
1989 if (opt == "H") { // Hits
1990 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
1995 else if ( opt == "S") { // SDigits
1996 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
1999 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2003 else if (opt == "D") { // Digits
2004 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2008 else if (opt == "RT") { // Tower RecPoints
2009 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2013 else if (opt == "RP") { // Preshower RecPoints
2014 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2018 else if (opt == "T") { // TrackSegments
2019 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2023 else if (opt == "P") { // RecParticles
2024 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2029 Warning("RemoveObjects", "-> Unknown option %s", opt.Data());
2033 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject(name)) ;
2042 emcalmain->Remove(emcal) ;
2045 //____________________________________________________________________________
2047 void AliEMCALGetter::RemoveSDigits() const
2049 TFolder * emcal= dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2058 //____________________________________________________________________________
2060 void AliEMCALGetter::CleanWhiteBoard(void){
2062 TFolder * emcalmain = 0 ;
2065 TList * lofTasks = 0 ;
2067 TTask * emcalt = 0 ;
2071 emcal = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2074 TObjArray * ar = dynamic_cast<TObjArray*>(emcal->FindObject("Hits")) ;
2084 emcalmain = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2087 emcal = dynamic_cast<TFolder*>(emcalmain->FindObject(fHeaderFile)) ;
2089 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fSDigitsTitle)) ;
2096 emcalmain->Remove(emcal) ;
2101 emcal = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2104 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fDigitsTitle)) ;
2114 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TowerRecPoints")) ;
2117 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2125 // PreShowerRecPoints
2127 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/PreShowerRecPoints")) ;
2130 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecPointsTitle)) ;
2140 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/TrackSegments")) ;
2143 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fTrackSegmentsTitle)) ;
2153 emcal = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL/RecParticles")) ;
2156 ar = dynamic_cast<TObjArray*>(emcal->FindObject(fRecParticlesTitle)) ;
2164 //---- Now Tasks -----------
2167 TString sdname(fSDigitsTitle);
2171 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Digitizer")) ;
2174 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2176 lofTasks = emcalt->GetListOfTasks() ;
2178 obj = lofTasks->FindObject(sdname.Data()) ;
2180 lofTasks->Remove(obj) ;
2185 sdname.Append(":") ;
2187 // Clusterizer, TrackSegmentMaker, PID
2189 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("Reconstructioner")) ;
2192 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2194 lofTasks = emcalt->GetListOfTasks() ;
2195 TIter next(lofTasks);
2196 while((obj=next())){
2197 TString oname(obj->GetName()) ;
2198 if (oname.BeginsWith(sdname)){
2199 lofTasks->Remove(obj) ;
2207 sdname.Append(fHeaderFile) ;
2208 task = dynamic_cast<TTask*>(fTasksFolder->FindObject("SDigitizer")) ;
2211 emcalt = dynamic_cast<TTask*>(task->GetListOfTasks()->FindObject("EMCAL")) ;
2213 lofTasks = emcalt->GetListOfTasks() ;
2215 obj = lofTasks->FindObject(sdname.Data()) ;
2217 lofTasks->Remove(obj) ;
2223 //____________________________________________________________________________
2225 void AliEMCALGetter::SetTitle(const char * branchTitle )
2228 fBranchTitle = branchTitle ;
2229 fSDigitsTitle = branchTitle ;
2230 fDigitsTitle = branchTitle ;
2231 fRecPointsTitle = branchTitle ;
2232 fRecParticlesTitle = branchTitle ;
2233 fTrackSegmentsTitle = branchTitle ;
2237 //First - extract full path if necessary
2239 TString sFileName(fHeaderFile) ;
2240 Ssiz_t islash = sFileName.Last('/') ;
2242 if(islash<sFileName.Length())
2243 sFileName.Remove(islash+1,sFileName.Length()) ;
2247 //Now construct file names
2249 fSDigitsFileName = sFileName ;
2250 fDigitsFileName = sFileName ;
2251 fRecPointsFileName = sFileName ;
2252 fRecParticlesFileName = sFileName ;
2253 fTrackSegmentsFileName = sFileName ;
2254 fSDigitsFileName += "EMCAL.SDigits." ;
2255 fDigitsFileName += "EMCAL.Digits." ;
2256 fRecPointsFileName += "EMCAL.RecData." ;
2257 fTrackSegmentsFileName+= "EMCAL.RecData." ;
2258 fRecParticlesFileName += "EMCAL.RecData." ;
2260 if((strcmp(fBranchTitle.Data(),"Default")!=0)&&(strcmp(fBranchTitle.Data(),"")!=0)){
2261 fSDigitsFileName += fBranchTitle ;
2262 fSDigitsFileName += "." ;
2263 fDigitsFileName += fBranchTitle ;
2264 fDigitsFileName += "." ;
2265 fRecPointsFileName += fBranchTitle ;
2266 fRecPointsFileName += "." ;
2267 fRecParticlesFileName += fBranchTitle ;
2268 fRecParticlesFileName += "." ;
2269 fTrackSegmentsFileName+= fBranchTitle ;
2270 fTrackSegmentsFileName+= "." ;
2273 fSDigitsFileName += "root" ;
2274 fDigitsFileName += "root" ;
2275 fRecPointsFileName += "root" ;
2276 fRecParticlesFileName += "root" ;
2277 fTrackSegmentsFileName+= "root" ;
2280 fSDigitsFileName = "" ;
2281 fDigitsFileName = "" ;
2282 fRecPointsFileName = "" ;
2283 fRecParticlesFileName = "" ;
2284 fTrackSegmentsFileName = "" ;
2287 TFolder * emcalFolder ;
2288 emcalFolder = dynamic_cast<TFolder*>(fHitsFolder->FindObject("EMCAL")) ;
2291 emcalFolder = fHitsFolder->AddFolder("EMCAL", "Hits from EMCAL") ;
2293 emcalFolder = dynamic_cast<TFolder*>(fSDigitsFolder->FindObject("EMCAL")) ;
2296 emcalFolder = fSDigitsFolder->AddFolder("EMCAL", "SDigits from EMCAL") ;
2298 //Make folder for SDigits
2300 TString subdir(fHeaderFile) ;
2301 subdir.ReplaceAll("/","_") ;
2303 emcalFolder->AddFolder(subdir, fSDigitsFileName.Data());
2304 emcalFolder = dynamic_cast<TFolder*>(fDigitsFolder->FindObject("EMCAL")) ;
2307 emcalFolder = fDigitsFolder->AddFolder("EMCAL", "Digits from EMCAL") ;
2309 emcalFolder = dynamic_cast<TFolder*>(fRecoFolder->FindObject("EMCAL")) ;
2312 emcalFolder = fRecoFolder->AddFolder("EMCAL", "Reconstructed data from EMCAL") ;
2315 //____________________________________________________________________________
2317 void AliEMCALGetter::CloseSplitFiles(void){
2320 file = static_cast<TFile*>(gROOT->GetFile(fSDigitsFileName.Data() ) ) ;
2325 file = static_cast<TFile*>(gROOT->GetFile(fDigitsFileName.Data() ) ) ;
2330 file = static_cast<TFile*>(gROOT->GetFile(fRecPointsFileName.Data() ) ) ;
2335 file = static_cast<TFile*>(gROOT->GetFile(fTrackSegmentsFileName.Data() ) ) ;
2340 file = static_cast<TFile*>(gROOT->GetFile(fRecParticlesFileName.Data() ) ) ;