]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerEfficiencyCells.cxx
In AliMUONTriggerEfficiencyCells:
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerEfficiencyCells.cxx
index 652449d9f14f4ccc157d266cdcb5d80a4ed11665..bac6f88a0e550a5a3c31ec5941278a3e2f95cdf5 100755 (executable)
@@ -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; cath<fgkNcathodes; cath++){
       for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
        histoName = Form("%sChamber%s", cathCode[cath].Data(), histoTypeName[hType].Data());
-       histo = (TH1F*)file->Get(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; ch<fgkNchambers; ch++){
        for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
          histoName = Form("%sSlat%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch);
-         histo = (TH1F*)file->Get(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; ch<fgkNchambers; ch++){
        for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
          histoName = Form("%sBoard%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch);
-         histo = (TH1F*)file->Get(histoName.Data());
+         histo = ( listInFile ) ? (TH1F*)listInFile->FindObject(histoName.Data()) : (TH1F*)file->Get(histoName.Data());
+         histo->SetDirectory(0);
          currList[hType]->Add(histo);
        }
       }
     }
 
+    file->Close();
+
     FillHistosFromList();
 }