In AliMUONTriggerEfficiencyCells:
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jan 2010 11:46:09 +0000 (11:46 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Jan 2010 11:46:09 +0000 (11:46 +0000)
 - Allow the initialization from the output file of the analysis task.
 - Fix bug in destructor.
(Diego)

MUON/AliMUONTriggerEfficiencyCells.cxx
MUON/AliMUONTriggerEfficiencyCells.h

index 652449d..bac6f88 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();
 }
 
index bb48381..fd8a647 100755 (executable)
@@ -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();