From 2236b58a5fdfa925692e7b8240c5dc828094b754 Mon Sep 17 00:00:00 2001 From: ivana Date: Fri, 22 Jan 2010 11:46:09 +0000 Subject: [PATCH] In AliMUONTriggerEfficiencyCells: - Allow the initialization from the output file of the analysis task. - Fix bug in destructor. (Diego) --- MUON/AliMUONTriggerEfficiencyCells.cxx | 39 +++++++++++++++++--------- MUON/AliMUONTriggerEfficiencyCells.h | 6 ++-- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/MUON/AliMUONTriggerEfficiencyCells.cxx b/MUON/AliMUONTriggerEfficiencyCells.cxx index 652449d9f14..bac6f88a0e5 100755 --- a/MUON/AliMUONTriggerEfficiencyCells.cxx +++ b/MUON/AliMUONTriggerEfficiencyCells.cxx @@ -93,7 +93,7 @@ fFiredDisplayHistoList(0x0) } //__________________________________________________________________________ -AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename) +AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename, const Char_t* listname) : TObject(), fCountHistoList(0x0), @@ -108,7 +108,7 @@ fFiredDisplayHistoList(0x0) CheckConstants(); Reset(); InitHistos(); - ReadFile(filename); + ReadFile(filename, listname); } @@ -181,9 +181,6 @@ AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const Al AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells() { /// Destructor. - - delete [] fBoardEfficiency; - delete [] fSlatEfficiency; Reset(); } @@ -217,13 +214,13 @@ AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bo //__________________________________________________________________________ -void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename) +void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename, const Char_t* listname) { /// Reads a file containing the efficiency map. TString fileName = gSystem->ExpandPathName(filename); if(fileName.EndsWith(".root")){ - ReadHistoBoards(fileName.Data()); + ReadHistoBoards(fileName.Data(), listname); return; } @@ -266,7 +263,7 @@ void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file) //__________________________________________________________________________ -void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename) +void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename, const Char_t* listname) { /// Structure of file (.root) containing local board efficency TFile *file = new TFile(filename, "read"); @@ -280,19 +277,31 @@ void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename) enum {kAllChEff, kChNonEff, kNumOfHistoTypes}; TString histoTypeName[2] = {"CountInCh", "NonCountInCh"}; - if(!fCountHistoList) fCountHistoList = new TList(); + if ( ! fCountHistoList ) { + fCountHistoList = new TList(); + fCountHistoList->SetOwner(); + } else fCountHistoList->Delete(); - if(!fNoCountHistoList) fNoCountHistoList = new TList(); + if( ! fNoCountHistoList) { + fNoCountHistoList = new TList(); + fNoCountHistoList->SetOwner(); + } else fNoCountHistoList->Delete(); TList *currList[2] = {fCountHistoList, fNoCountHistoList}; TH1F *histo = 0x0; + + TList* listInFile = 0x0; + TString listNameString(listname); + if ( ! listNameString.IsNull() ) + listInFile = (TList*)file->Get(listname); for(Int_t cath=0; cathGet(histoName.Data()); + histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName.Data()) : (TH1F*)file->Get(histoName.Data()); + histo->SetDirectory(0); currList[hType]->Add(histo); } } @@ -301,7 +310,8 @@ void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename) for(Int_t ch=0; chGet(histoName.Data()); + histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName.Data()) : (TH1F*)file->Get(histoName.Data()); + histo->SetDirectory(0); currList[hType]->Add(histo); } } @@ -311,12 +321,15 @@ void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename) for(Int_t ch=0; chGet(histoName.Data()); + histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName.Data()) : (TH1F*)file->Get(histoName.Data()); + histo->SetDirectory(0); currList[hType]->Add(histo); } } } + file->Close(); + FillHistosFromList(); } diff --git a/MUON/AliMUONTriggerEfficiencyCells.h b/MUON/AliMUONTriggerEfficiencyCells.h index bb48381332e..fd8a64710cf 100755 --- a/MUON/AliMUONTriggerEfficiencyCells.h +++ b/MUON/AliMUONTriggerEfficiencyCells.h @@ -21,7 +21,7 @@ class AliMUONTriggerEfficiencyCells : public TObject { public: AliMUONTriggerEfficiencyCells(); - AliMUONTriggerEfficiencyCells(const Char_t* filename); + AliMUONTriggerEfficiencyCells(const Char_t* filename, const Char_t* listname="triggerChamberEff"); AliMUONTriggerEfficiencyCells(TList *countHistoList, TList *noCountHistoList); AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other); // copy constructor @@ -47,7 +47,7 @@ public: // syntomatic of possible read-out problems in boards protected: void Reset(Bool_t resetAll = kTRUE); - void ReadFile(const Char_t* filename="$ALICE_ROOT/MUON/data/efficiencyCells.dat"); + void ReadFile(const Char_t* filename="$ALICE_ROOT/MUON/data/efficiencyCells.dat", const Char_t* listname=""); void CalculateEfficiency(Int_t trigger44, Int_t trigger34, Float_t &efficiency, Float_t &error, Bool_t failuresAsInput); @@ -57,7 +57,7 @@ private: void CheckConstants() const; Int_t FindChamberIndex(Int_t detElemId) const; void ReadFileBoards(ifstream &file); - void ReadHistoBoards(const Char_t* filename="MUON.TriggerEfficiencyMap.root"); + void ReadHistoBoards(const Char_t* filename="MUON.TriggerEfficiencyMap.root", const Char_t* listname="triggerChamberEff"); void InitHistos(); void FillHistosFromList(Bool_t useMeanValues = kFALSE); Bool_t GetListsForCheck(); -- 2.43.0