Corrected bug in the current HEAD;
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Oct 2007 18:44:55 +0000 (18:44 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Oct 2007 18:44:55 +0000 (18:44 +0000)
now the efficiency maps are correctly stored in the ESD again,
in particular, an object of class AliMUONTriggerEfficiencyCellsI
is saved in the AliESDs.root file.
(Diego)

MUON/AliMUONTriggerChamberEff.cxx
MUON/AliMUONTriggerChamberEff.h
MUON/AliMUONTriggerEfficiencyCells.cxx
MUON/AliMUONTriggerEfficiencyCells.h
MUON/Calib/TriggerEfficiency/Run0_99999999_v0_s0.root
MUON/MUONTriggerChamberEfficiency.C

index b2d44ddd72f3e5dba42f7bdc7f2257ace4c2d1c6..76c83cf47422728ce68a73803b153ee91e9debc7 100644 (file)
@@ -41,6 +41,7 @@
 #include "AliMUONVTriggerStore.h"
 #include "AliMUONVTriggerTrackStore.h"
 #include "AliMUONVTrackStore.h"
+#include "AliMUONTriggerEfficiencyCells.h"
 
 #include "AliMpVSegmentation.h"
 #include "AliMpSegmentation.h"
 #include "AliMpDEManager.h"
 #include "AliMpConstants.h"
 
-#include "AliMpDDLStore.h"
-#include "AliMpDDL.h"
-#include "AliMpTriggerCrate.h"
-#include "AliMpLocalBoard.h"
-
 #include "AliLog.h"
 
+//#include "AliESDEvent.h"
+
 #include <Riostream.h>
 #include <TFile.h>
 #include <TH1F.h>
 #include <TTree.h>
 #include <TROOT.h>
 
-#include <TStyle.h>
-#include <TCanvas.h>
-#include <TH2.h>
-#include <TSystem.h>
-#include <TPaveLabel.h>
-
 #include <cassert>
 
 /// \cond CLASSIMP
@@ -762,165 +754,101 @@ void AliMUONTriggerChamberEff::EventChamberEff(const AliMUONVTriggerStore& trigg
 }
 
 //_____________________________________________________________________________
-void AliMUONTriggerChamberEff::WriteEfficiencyMap(const char* outputDir)
+void AliMUONTriggerChamberEff::GetEfficiencyHistos(TList &countList, TList &noCountList)
 {
-    //
-    /// Writes information on calculated efficiency.
-    /// It writes: triggerChamberEff.root file containing efficiency histograms.
-    //
-
-    char *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
-
-    char outFileName[100];
-
-    sprintf(outFileName, "%s/MUON.TriggerEfficiencyMap.root",outputDir);
-    TFile *outputHistoFile = new TFile(outFileName,"RECREATE");
-    TDirectory *dir = gDirectory;
-
-    char *yAxisTitle = "trigger efficiency (a.u.)";
-    char *xAxisTitle = "chamber";
-
-    const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
-
-    TH1F *histoChamber[fgkNcathodes];
-    TH1F *histoSlat[8];
-    TH1F *histoBoard[8];
-
-    // ADDED for check
-    enum {kAllChEff, kChNonEff, kNumOfHistoTypes};
-    char *histoTypeName[kNumOfHistoTypes] = {"CountInCh", "NonCountInCh"};
-    char *histoTypeTitle[kNumOfHistoTypes] = {"counted", "non counted"};
-    TH1F *histoCheckSlat[8][kNumOfHistoTypes];
-    TH1F *histoCheckBoard[8][kNumOfHistoTypes];
-    // end ADDED for check
-
-    char histoName[40];
-    char histoTitle[90];
-
-    for(Int_t cath=0; cath<fgkNcathodes; cath++){
-       sprintf(histoName, "%sChamberEff", cathCode[cath]);
-       sprintf(histoTitle, "Chamber efficiency %s", cathCode[cath]);
-       histoChamber[cath] = new TH1F(histoName, histoTitle, fgkNchambers, 11-0.5, 15-0.5);
-       histoChamber[cath]->SetXTitle(xAxisTitle);
-       histoChamber[cath]->SetYTitle(yAxisTitle);
-       histoChamber[cath]->GetXaxis()->SetNdivisions(fgkNchambers);
-       for(Int_t ch=0; ch<fgkNchambers; ch++){
-           Int_t chCath = fgkNchambers*cath + ch;
-           sprintf(histoName, "%sSlatEffChamber%i", cathCode[cath], 11+ch);
-           sprintf(histoTitle, "Chamber %i: slat efficiency %s", 11+ch, cathCode[cath]);
-           histoSlat[chCath] = new TH1F(histoName, histoTitle, fgkNslats, 0-0.5, fgkNslats-0.5);
-           histoSlat[chCath]->SetXTitle("slat");
-           histoSlat[chCath]->SetYTitle(yAxisTitle);
-           histoSlat[chCath]->GetXaxis()->SetNdivisions(fgkNslats);
-               
-           sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
-           sprintf(histoTitle, "Chamber %i: board efficiency %s", 11+ch, cathCode[cath]);
-           histoBoard[chCath] = new TH1F(histoName, histoTitle, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
-           histoBoard[chCath]->SetXTitle("boards");
-           histoBoard[chCath]->SetYTitle(yAxisTitle);
-           histoBoard[chCath]->GetXaxis()->SetNdivisions(kNumOfBoards);
-
-           // ADDED for check
-           for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
-               sprintf(histoName, "%sSlat%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
-               sprintf(histoTitle, "Chamber %i: slat %s %s", 11+ch, histoTypeTitle[hType], cathCode[cath]);
-               histoCheckSlat[chCath][hType] = new TH1F(histoName, histoTitle, fgkNslats, 0-0.5, fgkNslats-0.5);
-               histoCheckSlat[chCath][hType]->SetXTitle("slat");
-               histoCheckSlat[chCath][hType]->SetYTitle(yAxisTitle);
-               histoCheckSlat[chCath][hType]->GetXaxis()->SetNdivisions(fgkNslats);
-
-               sprintf(histoName, "%sBoard%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
-               sprintf(histoTitle, "Chamber %i: board %s %s", 11+ch, histoTypeTitle[hType], cathCode[cath]);
-               histoCheckBoard[chCath][hType] = new TH1F(histoName, histoTitle, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
-               histoCheckBoard[chCath][hType]->SetXTitle("boards");
-               histoCheckBoard[chCath][hType]->SetYTitle(yAxisTitle);
-               histoCheckBoard[chCath][hType]->GetXaxis()->SetNdivisions(kNumOfBoards);
-           }
-           // end ADDED for check
-       }
+  //
+  /// Gets lists of histograms containing number of 4/4 and 3/4
+  /// for further efficiency calculations.
+  //
+
+  char *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
+
+  char *yAxisTitle = "counts";
+
+  const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
+
+  enum {kAllChEff, kChNonEff, kNumOfHistoTypes};
+  char *histoTypeName[kNumOfHistoTypes] = {"CountInCh", "NonCountInCh"};
+  char *histoTypeTitle[kNumOfHistoTypes] = {"counted", "non counted"};
+  TH1F *histoCheckChamber[fgkNcathodes][kNumOfHistoTypes];
+  TH1F *histoCheckSlat[fgkNplanes][kNumOfHistoTypes];
+  TH1F *histoCheckBoard[fgkNplanes][kNumOfHistoTypes];
+
+  char histoName[40];
+  char histoTitle[90];
+
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
+    for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
+      sprintf(histoName, "%sChamber%s", cathCode[cath], histoTypeName[hType]);
+      sprintf(histoTitle, "%s %s", histoTypeTitle[hType], cathCode[cath]);
+      histoCheckChamber[cath][hType] = new TH1F(histoName, histoTitle, fgkNchambers, 11-0.5, 11+fgkNchambers-0.5);
+      histoCheckChamber[cath][hType]->SetXTitle("chamber");
+      histoCheckChamber[cath][hType]->SetYTitle(yAxisTitle);
+      histoCheckChamber[cath][hType]->GetXaxis()->SetNdivisions(fgkNchambers);
     }
-
-    Float_t efficiency, efficiencyError;
-    Int_t bin;
-
-    for(Int_t cath=0; cath<fgkNcathodes; cath++){
-       for(Int_t ch=0; ch<fgkNchambers; ch++){
-           Int_t chCath = fgkNchambers*cath + ch;
-           for(Int_t slat=0; slat<fgkNslats; slat++){
-               CalculateEfficiency(fHitPerSlat[chCath][slat], fHitPerSlat[chCath][slat]+fInefficientSlat[chCath][slat], efficiency, efficiencyError, kFALSE);
-               bin = histoSlat[chCath]->FindBin(slat);
-               histoSlat[chCath]->SetBinContent(bin, efficiency);
-               histoSlat[chCath]->SetBinError(bin, efficiencyError);
-
-               // ADDED for check
-               histoCheckSlat[chCath][kAllChEff]->SetBinContent(bin, fHitPerSlat[chCath][slat]);
-               histoCheckSlat[chCath][kChNonEff]->SetBinContent(bin, fInefficientSlat[chCath][slat]);
-           }
-           CalculateEfficiency(fTrigger44[cath], fTrigger34[chCath]+fTrigger44[cath], efficiency, efficiencyError, kFALSE);
-           bin = histoChamber[cath]->FindBin(11+ch);
-           histoChamber[cath]->SetBinContent(bin, efficiency);
-           histoChamber[cath]->SetBinError(bin, efficiencyError);
-
-           for(Int_t board=0; board<kNumOfBoards; board++){
-               CalculateEfficiency(fHitPerBoard[chCath][board], fHitPerBoard[chCath][board]+fInefficientBoard[chCath][board], efficiency, efficiencyError, kFALSE);
-               bin = histoBoard[chCath]->FindBin(board+1);
-               histoBoard[chCath]->SetBinContent(bin, efficiency);
-               histoBoard[chCath]->SetBinError(bin, efficiencyError);
-
-               // ADDED for check
-               histoCheckBoard[chCath][kAllChEff]->SetBinContent(bin, fHitPerBoard[chCath][board]);
-               histoCheckBoard[chCath][kChNonEff]->SetBinContent(bin, fInefficientBoard[chCath][board]);
-           }
-       }
+    
+    for(Int_t ch=0; ch<fgkNchambers; ch++){
+      Int_t chCath = fgkNchambers*cath + ch;
+      for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
+       sprintf(histoName, "%sSlat%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
+       sprintf(histoTitle, "Chamber %i: slat %s %s", 11+ch, histoTypeTitle[hType], cathCode[cath]);
+       histoCheckSlat[chCath][hType] = new TH1F(histoName, histoTitle, fgkNslats, 0-0.5, fgkNslats-0.5);
+       histoCheckSlat[chCath][hType]->SetXTitle("slat");
+       histoCheckSlat[chCath][hType]->SetYTitle(yAxisTitle);
+       histoCheckSlat[chCath][hType]->GetXaxis()->SetNdivisions(fgkNslats);
+
+       sprintf(histoName, "%sBoard%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
+       sprintf(histoTitle, "Chamber %i: board %s %s", 11+ch, histoTypeTitle[hType], cathCode[cath]);
+       histoCheckBoard[chCath][hType] = new TH1F(histoName, histoTitle, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
+       histoCheckBoard[chCath][hType]->SetXTitle("boards");
+       histoCheckBoard[chCath][hType]->SetYTitle(yAxisTitle);
+       histoCheckBoard[chCath][hType]->GetXaxis()->SetNdivisions(kNumOfBoards);
+      }
     }
+  }
 
-// write all histos
-    outputHistoFile->cd();
-    dir->GetList()->Write();
-    outputHistoFile->Close();
-}
-
+  Int_t bin;
 
-//_____________________________________________________________________________
-void AliMUONTriggerChamberEff::WriteEfficiencyMapTxt(const char* outputDir)
-{
-    //
-    /// Writes the calculated efficiency in the text file efficiencyCells.dat
-    ///
-    /// The file can be further put in $ALICE_ROOT/MUON/data
-    /// and used to run simulations with measured trigger chamber efficiencies.
-    //
-
-    Int_t effOutWidth=4;
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
+    for(Int_t ch=0; ch<fgkNchambers; ch++){
+      Int_t chCath = fgkNchambers*cath + ch;
+      for(Int_t slat=0; slat<fgkNslats; slat++){
+       bin = histoCheckSlat[chCath][kAllChEff]->FindBin(slat);
+       histoCheckSlat[chCath][kAllChEff]->SetBinContent(bin, fHitPerSlat[chCath][slat]);
+       histoCheckSlat[chCath][kChNonEff]->SetBinContent(bin, fInefficientSlat[chCath][slat]);
+      }
+      bin = histoCheckChamber[cath][kAllChEff]->FindBin(11+ch);
+      histoCheckChamber[cath][kAllChEff]->SetBinContent(bin, fTrigger44[cath]);
+      histoCheckChamber[cath][kChNonEff]->SetBinContent(bin, fTrigger34[chCath]);
+
+      for(Int_t board=0; board<kNumOfBoards; board++){
+       bin = histoCheckBoard[chCath][kAllChEff]->FindBin(board+1);
+       histoCheckBoard[chCath][kAllChEff]->SetBinContent(bin, fHitPerBoard[chCath][board]);
+       histoCheckBoard[chCath][kChNonEff]->SetBinContent(bin, fInefficientBoard[chCath][board]);
+      }
+    }
+  }
 
-    Float_t efficiency, efficiencyError;
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
+    countList.Add(histoCheckChamber[cath][kAllChEff]);
+    noCountList.Add(histoCheckChamber[cath][kChNonEff]);
+  }
 
-    Int_t aCapo[] = {16, 38, 60, 76, 92, 108, 117, 133, 155, 177, 193, 209, 225, 234};
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
+    for(Int_t ch=0; ch<fgkNchambers; ch++){
+      Int_t chCath = fgkNchambers*cath + ch;
+      countList.Add(histoCheckSlat[chCath][kAllChEff]);
+      noCountList.Add(histoCheckSlat[chCath][kChNonEff]);
+    }
+  }
 
-    char filename[70];
-    sprintf(filename, "%s/efficiencyCells.dat", outputDir);
-    ofstream outFile(filename);
-    outFile << "localBoards" << endl;
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
     for(Int_t ch=0; ch<fgkNchambers; ch++){
-       //Print information
-       outFile << "\n\ndetElemId:\t" << 11+ch;
-       outFile << "00";
-       for(Int_t cath=0; cath<fgkNcathodes; cath++){
-           outFile << "\n cathode:\t" << cath << endl;
-           Int_t chCath = fgkNchambers*cath + ch;
-           Int_t currLine=0;
-           for(Int_t board=0; board<AliMpConstants::NofLocalBoards(); board++){
-
-               if(board==aCapo[currLine]){
-                   outFile << endl;
-                   currLine++;
-               }
-               CalculateEfficiency(fHitPerBoard[chCath][board], fHitPerBoard[chCath][board]+fInefficientBoard[chCath][board], efficiency, efficiencyError, kFALSE);
-               outFile << " " << setw(effOutWidth) << efficiency;
-           }// loop on boards
-           outFile << endl;
-       }// loop on cathodes
-    }// loop on chambers    
+      Int_t chCath = fgkNchambers*cath + ch;
+      countList.Add(histoCheckBoard[chCath][kAllChEff]);
+      noCountList.Add(histoCheckBoard[chCath][kChNonEff]);
+    }
+  }
 }
 
 
@@ -967,163 +895,49 @@ Bool_t AliMUONTriggerChamberEff::IsCleanTrack(AliMUONTriggerTrack *triggerTrack,
 //_____________________________________________________________________________
 void AliMUONTriggerChamberEff::SaveInESDFile()
 {
-    //
-    /// Store AliMUONTriggerChamberEff in esd file
-    //
-    TDirectory *dir = gDirectory;
-    TFile *logFile = 0x0;
-    TSeqCollection *list = gROOT->GetListOfFiles();
-    Int_t n = list->GetEntries();
-    for(Int_t i=0; i<n; i++) {
-       logFile = (TFile*)list->At(i);
-       if (strstr(logFile->GetName(), "AliESDs.root")) break;
-    }
-    if(logFile){
-       TTree *esdTree = (TTree*)logFile->Get("esdTree");
-       if(esdTree){
-           if(!esdTree->GetUserInfo()->FindObject("AliMUONTriggerChamberEff")){
-               AliInfo(Form("Adding AliMUONTrigChamberEff in %s",logFile->GetName()));
-               esdTree->GetUserInfo()->Add(this->Clone());
-               esdTree->Write("",TObject::kOverwrite);
-           }
-       }
-    }
-    dir->cd();
-}
-
-
-//_____________________________________________________________________________
-void AliMUONTriggerChamberEff::DisplayEfficiency(Bool_t perSlat)
-{
-    //
-    /// Display calculated efficiency.
-    //
-
-    const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
-
-    Int_t side, col, line, nbx, slat;
-    Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
-    Int_t x1, y1, x2, y2, board=0;
-    char name[8], text[200];
-
-    gStyle->SetPalette(1);
-
-    TString boardName[234];
-
-    // instanciate the elec. mapping class
-    AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
-
-    // loop over the trigger DDL (Right: 20, Left: 21)
-    for (Int_t iDDL = 20; iDDL <= 21; ++iDDL) {
-
-      // get ddl object
-      AliMpDDL* ddl = ddlStore->GetDDL(iDDL);
-
-      Int_t nCrate = ddl->GetNofTriggerCrates();
+  //
+  /// Store AliMUONTriggerChamberEff in esd file
+  //
+  TList countHistoList, noCountHistoList;
+  GetEfficiencyHistos(countHistoList, noCountHistoList);
+  AliMUONTriggerEfficiencyCells *effMap = 
+    new AliMUONTriggerEfficiencyCells(&countHistoList, &noCountHistoList);
+
+  TDirectory *dir = gDirectory;
+
+  TFile *logFile = 0x0;
+  Char_t *esdFileName = "AliESDs.root";
+  TSeqCollection *list = gROOT->GetListOfFiles();
+  Bool_t reopenFile = kFALSE;
+  Int_t n = list->GetEntries();
+  for(Int_t i=0; i<n; i++) {
+    logFile = (TFile*)list->At(i);
+    if (strstr(logFile->GetName(), esdFileName)) break;
+    logFile = 0x0;
+  }
+  if(!logFile) {
+    AliWarning(Form("%s already stored on disk. Re-opening in update mode.",esdFileName));
+    logFile = new TFile(esdFileName, "update");
+    reopenFile = kTRUE;
+  }
     
-      // loop over the number of crate in DDL
-      for (Int_t index = 0; index < nCrate; ++index) {
-
-       // get crate object
-       AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(iDDL, index);
-
-       Int_t nLocal = crate->GetNofLocalBoards();
-
-       for (Int_t iLocal = 0; iLocal  < nLocal; ++iLocal) {
-
-         // get local board Id from crate object
-         board = crate->GetLocalBoardId(iLocal);
-         if(board>kNumOfBoards || board<=0) continue;
-
-         AliMpLocalBoard* localBoard = ddlStore->GetLocalBoard(board);
-         boardName[board-1] = localBoard->GetName();
-       }
+  if(logFile){
+    TTree *esdTree = (TTree*)logFile->Get("esdTree");
+    if(esdTree){
+      if(!esdTree->GetUserInfo()->FindObject("AliMUONTriggerEfficiencyCells")){
+       AliInfo(Form("Adding AliMUONTriggerEfficiencyCells in %s",esdTree->GetName()));
+       esdTree->GetUserInfo()->Add(effMap);
+       esdTree->Write("",TObject::kOverwrite);
       }
     }
-
-    char *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
-
-    Float_t boardsX = 257.00;  // cm
-    Float_t boardsY = 307.00;  // cm
-
-    TH2F *histo[8];
-    TPaveLabel *boardLabel[8][234];
-
-    char histoName[40];
-    char histoTitle[90];
-
-    Float_t efficiency, efficiencyError;
-
-    for(Int_t cath=0; cath<fgkNcathodes; cath++){
-       for(Int_t ch=0; ch<fgkNchambers; ch++){
-           Int_t chCath = fgkNchambers*cath + ch;
-           sprintf(histoName, "%sChamber%i", cathCode[cath], 11+ch);
-           sprintf(histoTitle, "Chamber %i: efficiency %s", 11+ch, cathCode[cath]);
-           histo[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
-           histo[chCath]->SetXTitle("X (cm)");
-           histo[chCath]->SetYTitle("Y (cm)");
-       }
-    }
-
-    TString mapspath = gSystem->Getenv("ALICE_ROOT");
-    mapspath.Append("/MUON/data");
-
-    sprintf(text,"%s/guimapp11.txt",mapspath.Data());
-    FILE *fmap = fopen(text,"r");
-
-    for (Int_t ib = 0; ib < kNumOfBoards; ib++) {
-       fscanf(fmap,"%d   %d   %d   %d   %f   %f   %f   %f   %f   %s   \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
-
-       slat = (line-5)%fgkNslats;
-       for(Int_t iBoard=0; iBoard<kNumOfBoards; iBoard++){
-           if(!boardName[iBoard].Contains(name)) continue;
-           board = iBoard;
-           break;
-       }
-
-       for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
-           x1 = histo[chCath]->GetXaxis()->FindBin(xCenter-xWidth/2.)+1;
-           y1 = histo[chCath]->GetYaxis()->FindBin(yCenter-yWidth/2.)+1;
-           x2 = histo[chCath]->GetXaxis()->FindBin(xCenter+xWidth/2.)-1;
-           y2 = histo[chCath]->GetYaxis()->FindBin(yCenter+yWidth/2.)-1;
-           
-           boardLabel[chCath][board] = new TPaveLabel(xCenter-xWidth/2., yCenter-yWidth/2., xCenter+xWidth/2., yCenter+yWidth/2., Form("%3d",board+1));
-           boardLabel[chCath][board]->SetFillStyle(0);
-           boardLabel[chCath][board]->SetBorderSize(0);
-
-           if(!perSlat){
-               CalculateEfficiency(fHitPerBoard[chCath][board], fHitPerBoard[chCath][board]+fInefficientBoard[chCath][board], efficiency, efficiencyError, kFALSE);
-           }
-           else{
-               CalculateEfficiency(fHitPerSlat[chCath][slat], fHitPerSlat[chCath][slat]+fInefficientSlat[chCath][slat], efficiency, efficiencyError, kFALSE);
-           }
-           
-           for(Int_t binX=x1; binX<=x2; binX++){
-               for(Int_t binY=y1; binY<=y2; binY++){
-                   histo[chCath]->SetBinContent(binX, binY, efficiency);
-                   histo[chCath]->SetBinError(binX, binY, efficiencyError);
-               }
-           }
-       }
-    }
-
-    TCanvas *can[8];
-    for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
-       sprintf(histoName, "%sCan", histo[chCath]->GetName());
-       sprintf(histoTitle, "%s", histo[chCath]->GetTitle());
-       can[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
-       can[chCath]->SetRightMargin(0.14);
-       can[chCath]->SetLeftMargin(0.12);
-       histo[chCath]->GetZaxis()->SetRangeUser(0.,1.);
-       histo[chCath]->GetYaxis()->SetTitleOffset(1.4);
-       histo[chCath]->SetStats(kFALSE);
-       histo[chCath]->Draw("COLZ");
-       for (Int_t board = 0; board < kNumOfBoards; board++) {
-           boardLabel[chCath][board]->Draw("same");
-       }
+    if(reopenFile){
+      logFile->Close();
     }
+  }
+  dir->cd();
 }
 
+
 //_____________________________________________________________________________
 void AliMUONTriggerChamberEff::CheckConstants() const
 {
index dc1864c9ca680d99188f3ddfcb3570ba3fc77dd5..ed01a77b12ae91be2e04a2efd494f8e5e38cca5e 100644 (file)
@@ -48,10 +48,6 @@ public:
     void EventChamberEff(const AliMUONVTriggerStore& triggerStore,
                         const AliMUONVTriggerTrackStore& trigTrackStore,
                         const AliMUONVTrackStore& trackStore);
-    void WriteEfficiencyMap(const char* outputDir);
-    void WriteEfficiencyMapTxt(const char* outputDir);
-    void DisplayEfficiency(Bool_t perSlat=kFALSE);
-
 
 protected:
     Int_t MatchingPad(AliMUONVDigitStore& digitStore, Int_t &detElemId, Float_t coor[2],
@@ -71,6 +67,7 @@ protected:
     Bool_t IsCleanTrack(AliMUONTriggerTrack *triggerTrack,
                        const AliMUONVTrackStore& trackStore);
     void SaveInESDFile();
+    void GetEfficiencyHistos(TList &countList, TList &noCountList);
 
     
 private:
index 2695b9550212ea640867b10a808803ad47608282..17b09649c653a2ce29d58c969d59d28d7f926068 100755 (executable)
 #include "TSystem.h"
 #include "TFile.h"
 #include "TH1F.h"
-#include "TMatrixF.h"
+#include "TMath.h"
+
+#include "TH2F.h"
+#include "TStyle.h"
+#include "TPaveLabel.h"
+#include "TCanvas.h"
 
 #include <fstream>
 #include <cassert>
@@ -80,17 +85,22 @@ ClassImp(AliMUONTriggerEfficiencyCells)
 //__________________________________________________________________________
 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
 :
-TObject()
+TObject(),
+fCountHistoList(0x0),
+fNoCountHistoList(0x0)
 {
 ///  Default constructor.
   CheckConstants();
   Reset();
+  InitHistos();
 }
 
 //__________________________________________________________________________
 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
 :
-TObject()
+TObject(),
+fCountHistoList(0x0),
+fNoCountHistoList(0x0)
 {
 ///  Constructor using an ASCII file.
   CheckConstants();
@@ -98,11 +108,68 @@ TObject()
   ReadFile(filename);
 }
 
+AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList,
+                                                            TList *noCountHistoList)
+:
+TObject(),
+fCountHistoList(countHistoList),
+fNoCountHistoList(noCountHistoList)
+{
+///  Constructor using an ASCII file.
+  CheckConstants();
+  Reset();
+  InitHistos();
+  FillHistosFromList();
+}
+
+//_____________________________________________________________________________
+AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
+:
+TObject(other),
+fCountHistoList(other.fCountHistoList),
+fNoCountHistoList(other.fNoCountHistoList)
+{
+/// Copy constructor
+
+  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+    for(Int_t slat=0; slat<fgkNslats; slat++){
+      fCellContent[chCath][slat] = other.fCellContent[chCath][slat];
+    }
+    fCellSize[chCath] = other.fCellSize[chCath];
+    fCellNumber[chCath] = other.fCellNumber[chCath];
+    fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
+    fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
+  }
+}
+
+//_____________________________________________________________________________
+AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
+{
+  /// Asignment operator
+  // check assignement to self
+  if (this == &other)
+    return *this;
+
+  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+    for(Int_t slat=0; slat<fgkNslats; slat++){
+      fCellContent[chCath][slat] = other.fCellContent[chCath][slat];
+    }
+    fCellSize[chCath] = other.fCellSize[chCath];
+    fCellNumber[chCath] = other.fCellNumber[chCath];
+    fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
+    fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
+  }
+
+  fCountHistoList = other.fCountHistoList;
+  fNoCountHistoList = other.fNoCountHistoList;
+
+  return *this;
+}
 
 //__________________________________________________________________________
 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
 {
-///  Destructor. Does nothing ;-)
+///  Destructor.
 }
 
 
@@ -130,8 +197,9 @@ void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t loc
 ///  Get the efficiencies of the 2 cathodes at a given local board
 
   Int_t chamber = FindChamberIndex(detElemId);
-  eff1 = fBoardContent[chamber][localBoard-1];
-  eff2 = fBoardContent[fgkNchambers+chamber][localBoard-1];
+  Int_t bin = fBoardEfficiency[chamber]->FindBin(localBoard);
+  eff1 = fBoardEfficiency[chamber]->GetBinContent(bin);
+  eff2 = fBoardEfficiency[fgkNchambers+chamber]->GetBinContent(bin);
 }
 
 
@@ -195,6 +263,7 @@ void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
       return;
   }
 
+  InitHistos();
   ifstream file(fileName.Data());
   char dat[50];
   if (file.good()){
@@ -251,7 +320,7 @@ void AliMUONTriggerEfficiencyCells::ReadFileXY(ifstream &file)
 void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
 {
 ///  Structure of file (.dat) containing local board efficency
-    Int_t datInt=0, detEl=0, chamber=0, chCath=0;
+  Int_t datInt=0, detEl=0, chamber=0, chCath=0, bin=0;
     Float_t datFloat=0.0;
     char dat[50];
 
@@ -263,9 +332,10 @@ void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
                chCath = fgkNchambers*cath + chamber;
                file >> dat;
                file >> datInt;
-               for(Int_t board=0; board<AliMpConstants::NofLocalBoards(); board++){
+               for(Int_t board=1; board<=AliMpConstants::NofLocalBoards(); board++){
                    file >> datFloat;
-                   fBoardContent[chCath][board] = datFloat;
+                   bin = fBoardEfficiency[chCath]->FindBin(board);
+                   fBoardEfficiency[chCath]->SetBinContent(bin, datFloat);
                }
            }
     }
@@ -283,20 +353,16 @@ void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const char *filename)
     }
     char histoName[30];
     char *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
-    TH1F *histo = 0x0;
+
     for(Int_t ch=0; ch<fgkNchambers; ch++){
        for(Int_t cath=0; cath<fgkNcathodes; cath++){
            sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
-           histo = (TH1F *)file->Get(histoName);
            if(!(TH1F *)file->Get(histoName)) {
                AliWarning(Form("Can't find histo %s in file %s",histoName, filename));
                continue;
            }
            Int_t chCath = fgkNchambers*cath + ch;
-           for(Int_t board=0; board<AliMpConstants::NofLocalBoards(); board++){
-               Int_t bin = histo->FindBin(board+1);
-               fBoardContent[chCath][board] = histo->GetBinContent(bin);
-           }
+           fBoardEfficiency[chCath] = (TH1F *)file->Get(histoName);
        }
     }
 }
@@ -349,7 +415,6 @@ AliMUONTriggerEfficiencyCells::Reset()
 ///  Sets our internal array contents to zero.
 
     for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
-       fBoardContent[chCath].Set(AliMpConstants::NofLocalBoards());
        fCellSize[chCath].Set(fgkNslats);
        fCellNumber[chCath].Set(fgkNslats);
        for(Int_t slat=0; slat<fgkNslats; slat++){
@@ -358,13 +423,308 @@ AliMUONTriggerEfficiencyCells::Reset()
     }
 
     for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
-       fBoardContent[chCath].Reset();
        fCellSize[chCath].Reset();
        fCellNumber[chCath].Reset();
        for(Int_t slat=0; slat<fgkNslats; slat++){
            fCellContent[chCath][slat].Zero();
        }
     }
+
+    for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+      fBoardEfficiency[chCath] = 0x0;
+      fSlatEfficiency[chCath] = 0x0;
+    }
+    
+}
+
+
+//__________________________________________________________________________
+void
+AliMUONTriggerEfficiencyCells::InitHistos()
+{
+///  Sets our internal array contents to zero.
+
+  const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
+  Int_t chCath=0;
+  Char_t histoName[40];
+
+  Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
+
+  for(Int_t ch=0; ch<fgkNchambers; ch++){
+    for(Int_t cath=0; cath<fgkNcathodes; cath++){
+      chCath = fgkNchambers*cath + ch;
+      sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
+      fBoardEfficiency[chCath] = new TH1F(histoName, histoName, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
+      sprintf(histoName, "%sSlatEffChamber%i", cathCode[cath], 11+ch);
+      fSlatEfficiency[chCath] = new TH1F(histoName, histoName, fgkNslats, 0-0.5, fgkNslats-0.5);
+    }
+  }
+}
+
+
+//__________________________________________________________________________
+void
+AliMUONTriggerEfficiencyCells::FillHistosFromList()
+{
+///  Sets our internal array contents to zero.
+
+  Int_t nHistoBins=0;
+  TH1F *histoNum = 0x0, *histoDen=0x0, *currHisto = 0x0;
+  TString slatName = "Slat", boardName = "Board", histoName;
+  Int_t iHistoBoard = -1, iHistoSlat = -1;
+  Float_t efficiency, efficiencyError;
+
+  Int_t nentries = fCountHistoList->GetEntries();
+
+  for(Int_t iEntry=0; iEntry<nentries; iEntry++){
+    histoNum = (TH1F*)fCountHistoList->At(iEntry);
+    histoDen = (TH1F*)fNoCountHistoList->At(iEntry);
+
+    if(!histoNum) {
+      AliWarning("Histogram not found in fCountHistoList. Skip to next");
+      continue;
+    }
+    if(!histoDen) {
+      AliWarning("Histogram not found in fNoCountHistoList. Skip to next");
+      continue;
+    }
+
+    histoName = histoNum->GetName();
+    nHistoBins = histoNum->GetNbinsX();
+
+    if(histoName.Contains(boardName)){
+      iHistoBoard++;
+      currHisto = fBoardEfficiency[iHistoBoard];
+    }
+    else if(histoName.Contains(slatName)){
+      iHistoSlat++;
+      currHisto = fSlatEfficiency[iHistoSlat];
+    }
+    else continue;
+
+    for(Int_t iBin=1; iBin<=nHistoBins; iBin++){
+      CalculateEfficiency((Int_t)histoNum->GetBinContent(iBin), (Int_t)histoNum->GetBinContent(iBin) + (Int_t)histoDen->GetBinContent(iBin), efficiency, efficiencyError, kFALSE);
+
+      currHisto->SetBinContent(iBin, efficiency);
+      currHisto->SetBinError(iBin, efficiencyError);
+    }
+  }
+}
+
+
+
+//_____________________________________________________________________________
+void AliMUONTriggerEfficiencyCells::CalculateEfficiency(Int_t trigger44, Int_t trigger34,
+                                                       Float_t &efficiency, Float_t &error,
+                                                       Bool_t failuresAsInput)
+{
+    //
+    /// Returns the efficiency.
+    //
+
+    efficiency=-9.;
+    error=0.;
+    if(trigger34>0){
+       efficiency=(Double_t)trigger44/((Double_t)trigger34);
+       if(failuresAsInput)efficiency=1.-(Double_t)trigger44/((Double_t)trigger34);
+    }
+    Double_t q = TMath::Abs(1-efficiency);
+    if(efficiency<0)error=0.0;
+    else error = TMath::Sqrt(efficiency*q/((Double_t)trigger34));
+}
+
+//_____________________________________________________________________________
+void AliMUONTriggerEfficiencyCells::DisplayEfficiency(Bool_t perSlat)
+{
+  //
+  /// Display calculated efficiency.
+  //
+
+  const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
+
+  Bool_t isInitSlat = kFALSE, isInitBoard = kFALSE;
+  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+    if(fBoardEfficiency[chCath]->GetEntries()>0) isInitBoard = kTRUE;
+    if(fSlatEfficiency[chCath]->GetEntries()>0) isInitSlat = kTRUE;
+  }
+
+  if(!isInitBoard){
+    printf("Trigger efficiency not initialized per board.\nDisplay not yet implemented.\n");
+    return;
+  }
+  if(!isInitSlat && perSlat){
+    printf("Trigger efficiency not initialized for slat.\nPlease try option kFALSE.\n");
+    return;
+  }
+
+  Int_t side, col, line, nbx, slat;
+  Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
+  Float_t x1Label, x2Label, y1Label, y2Label;
+  Int_t x1, y1, x2, y2, board=0;
+  Char_t name[8], text[200];
+
+  gStyle->SetPalette(1);
+
+  Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
+
+  Float_t boardsX = 257.00;  // cm
+  Float_t boardsY = 307.00;  // cm
+
+  TH2F *histo[fgkNplanes];
+  TPaveLabel *boardLabel[fgkNplanes][234];
+  assert(kNumOfBoards==234);    
+  TArrayI boardsPerColumn[9];
+  for(Int_t iLine=0; iLine<9; iLine++){
+    boardsPerColumn[iLine].Set(7);
+    boardsPerColumn[iLine].Reset();
+  }
+
+  Char_t histoName[40], histoTitle[90], labelTxt[5];
+
+  Float_t efficiency, efficiencyError;
+
+  for(Int_t cath=0; cath<fgkNcathodes; cath++){
+    for(Int_t ch=0; ch<fgkNchambers; ch++){
+      Int_t chCath = fgkNchambers*cath + ch;
+      sprintf(histoName, "%sChamber%i", cathCode[cath], 11+ch);
+      sprintf(histoTitle, "Chamber %i: efficiency %s", 11+ch, cathCode[cath]);
+      histo[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
+      histo[chCath]->SetXTitle("X (cm)");
+      histo[chCath]->SetYTitle("Y (cm)");
+    }
+  }
+
+  TString mapspath = gSystem->Getenv("ALICE_ROOT");
+  mapspath.Append("/MUON/data");
+
+  sprintf(text,"%s/guimapp11.txt",mapspath.Data());
+
+  FileStat_t fs;
+  if(gSystem->GetPathInfo(text,fs)){
+    AliWarning(Form("Map file %s not found. Nothing done",text));
+    return;
+  }
+
+  FILE *fmap = fopen(text,"r");
+
+  for (Int_t ib = 0; ib < kNumOfBoards; ib++) {
+    fscanf(fmap,"%d   %d   %d   %d   %f   %f   %f   %f   %f   %s   \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
+    if(side==0) continue;
+    boardsPerColumn[line-1][col-1]++;
+  }
+
+  rewind(fmap);
+
+  for (Int_t ib = 0; ib < kNumOfBoards; ib++) {
+    fscanf(fmap,"%d   %d   %d   %d   %f   %f   %f   %f   %f   %s   \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
+
+    board=0;
+    for(Int_t iCol=1; iCol<=col; iCol++){
+      Int_t lastLine = 9;
+      if(iCol==col) lastLine = line-1;
+      for(Int_t iLine=1; iLine<=lastLine; iLine++){
+       board += boardsPerColumn[iLine-1][iCol-1];
+      }
+    }
+    if(side==0) board += kNumOfBoards/2;
+    board += nbx - 1;
+
+    slat = (line+13)%fgkNslats;
+    if(side==0) slat = 14-line;
+
+    for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+      x1 = histo[chCath]->GetXaxis()->FindBin(xCenter-xWidth/2.)+1;
+      y1 = histo[chCath]->GetYaxis()->FindBin(yCenter-yWidth/2.)+1;
+      x2 = histo[chCath]->GetXaxis()->FindBin(xCenter+xWidth/2.)-1;
+      y2 = histo[chCath]->GetYaxis()->FindBin(yCenter+yWidth/2.)-1;
+
+      x1Label = xCenter-xWidth/2.;
+      y1Label = yCenter-yWidth/2.;
+      x2Label = xCenter+xWidth/2.;
+      y2Label =  yCenter+yWidth/2.;
+      sprintf(labelTxt,"%3d", board+1);
+      if(perSlat){
+       x1Label = 140.;
+       x2Label = x1Label + 40.;
+       y1Label = -285. + ((Float_t)(line - 1)) * 68;
+       y2Label = y1Label + 34.;
+       if(side==0){
+         x1Label = -x2Label;
+         x2Label = x1Label + 40.;
+       }
+       sprintf(labelTxt,"%2d", slat);
+      }
+    
+      boardLabel[chCath][board] = new TPaveLabel(x1Label, y1Label, x2Label, y2Label, labelTxt);
+      boardLabel[chCath][board]->SetFillStyle(0);
+      boardLabel[chCath][board]->SetBorderSize(0);
+
+      Int_t histoBin = board+1;
+      if(perSlat) histoBin = slat+1;
+
+      if(!perSlat){
+       efficiency = fBoardEfficiency[chCath]->GetBinContent(histoBin);
+       efficiencyError = fBoardEfficiency[chCath]->GetBinError(histoBin);
+      }
+      else {
+       efficiency = fSlatEfficiency[chCath]->GetBinContent(histoBin);
+       efficiencyError = fSlatEfficiency[chCath]->GetBinError(histoBin);
+      }
+
+      for(Int_t binX=x1; binX<=x2; binX++){
+       for(Int_t binY=y1; binY<=y2; binY++){
+         histo[chCath]->SetBinContent(binX, binY, efficiency);
+         histo[chCath]->SetBinError(binX, binY, efficiencyError);
+       }
+      }
+    }
+  }
+
+  fclose(fmap);
+
+  TCanvas *can[8];
+  for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
+    sprintf(histoName, "%sCan", histo[chCath]->GetName());
+    sprintf(histoTitle, "%s", histo[chCath]->GetTitle());
+    can[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
+    can[chCath]->SetRightMargin(0.14);
+    can[chCath]->SetLeftMargin(0.12);
+    histo[chCath]->GetZaxis()->SetRangeUser(0.,1.);
+    histo[chCath]->GetYaxis()->SetTitleOffset(1.4);
+    histo[chCath]->SetStats(kFALSE);
+    histo[chCath]->Draw("COLZ");
+    for (Int_t board = 0; board < kNumOfBoards; board++) {
+      boardLabel[chCath][board]->Draw("same");
+    }
+  }
 }
 
 
+//__________________________________________________________________________
+Bool_t AliMUONTriggerEfficiencyCells::SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other)
+{
+///  Sums results from different runs and gives the efficiency
+  if(!fCountHistoList || !fNoCountHistoList) {
+    AliWarning("Histograms for efficiency calculations not implemented in object");
+    return kFALSE;
+  }
+  if(!other.fCountHistoList || !other.fNoCountHistoList) {
+    AliWarning("Histograms for efficiency calculations not implemented in object passed as argument");
+    return kFALSE;
+  }
+
+  Int_t nentries = fCountHistoList->GetEntries();
+  TH1F *currNum = 0x0, *currDen = 0x0, *otherNum = 0x0, *otherDen = 0x0;
+
+  for(Int_t iEntry=0; iEntry<nentries; iEntry++){
+    currNum = (TH1F*)fCountHistoList->At(iEntry);
+    currDen = (TH1F*)fNoCountHistoList->At(iEntry);
+    otherNum = (TH1F*)other.fCountHistoList->At(iEntry);
+    otherDen = (TH1F*)other.fNoCountHistoList->At(iEntry);
+    currNum->Add(otherNum);
+    currDen->Add(otherDen);
+  }
+
+  FillHistosFromList();
+  return kTRUE;
+}
index 22ad6f1af55bdb7a647c2cf818122081053f48b4..a22febe5265eda78610a66fca0d3d934a026a6d9 100755 (executable)
 #include "TArrayF.h"
 #include "TArrayI.h"
 #include "TVector2.h"
-#include "TString.h"
 #include "TMatrix.h"
+#include "TH1F.h"
+#include "TList.h"
 
 class AliMUONTriggerEfficiencyCells : public TObject
 {
 public:
   AliMUONTriggerEfficiencyCells();
   AliMUONTriggerEfficiencyCells(const char* filename);
+  AliMUONTriggerEfficiencyCells(TList *countHistoList, TList *noCountHistoList);
+
+  AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other); // copy constructor
+  AliMUONTriggerEfficiencyCells& operator=(const AliMUONTriggerEfficiencyCells& other); // assignment operator
 
   virtual ~AliMUONTriggerEfficiencyCells();
 
@@ -31,13 +36,19 @@ public:
   void IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2) const;
   void IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2) const;
 
-  TVector2 ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0);
+  void DisplayEfficiency(Bool_t perSlat=kFALSE);
+  Bool_t SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other);
 
   void Reset();
     
 protected:
     TArrayI CellByCoord(Int_t detElemId, Float_t x, Float_t y) const;
+    TVector2 ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0);
     void ReadFile(const char* filename="$ALICE_ROOT/MUON/data/efficiencyCells.dat");
+    void CalculateEfficiency(Int_t trigger44, Int_t trigger34,
+                            Float_t &efficiency, Float_t &error,
+                            Bool_t failuresAsInput);
+
 
 private:
     void CheckConstants() const;
@@ -46,6 +57,8 @@ private:
     void ReadFileXY(ifstream &file);
     void ReadFileBoards(ifstream &file);
     void ReadHistoBoards(const char* filename="MUON.TriggerEfficiencyMap.root");
+    void InitHistos();
+    void FillHistosFromList();
     
     static const Int_t fgkNcells=80;   ///< Number of cells
     static const Int_t fgkNcathodes=2; ///<Number of cathodes
@@ -57,8 +70,13 @@ private:
     TMatrixF fCellContent[fgkNplanes][fgkNslats]; ///< the cells content
     TArrayF  fCellSize[fgkNplanes];    ///< the size of the cells
     TArrayI  fCellNumber[fgkNplanes];  ///< id of the cells
-    TArrayF  fBoardContent[fgkNplanes];///< the boards content
+    
+    TH1F *fBoardEfficiency[fgkNplanes];///< the boards content
+    TH1F *fSlatEfficiency[fgkNplanes];///< the slats content
+
+    TList *fCountHistoList; ///<list of efficiency numerators
+    TList *fNoCountHistoList; ///<list of efficiency denominators
 
-    ClassDef(AliMUONTriggerEfficiencyCells,3) // Trigger efficiency store
+    ClassDef(AliMUONTriggerEfficiencyCells,4) // Trigger efficiency store
 };
 #endif
index 45a5db5a7231e5b4f4d2df831da63024eca8390a..3b2ff2bec562c0854b12eec4cab47c433eee4e39 100644 (file)
Binary files a/MUON/Calib/TriggerEfficiency/Run0_99999999_v0_s0.root and b/MUON/Calib/TriggerEfficiency/Run0_99999999_v0_s0.root differ
index c0ef47c97c9f1ec696b5a2fb599f1658df9b6402..1553cf65433eff82979939262d027bace7feac02 100644 (file)
@@ -22,7 +22,6 @@
 
 // MUON includes
 #include "AliMUONCDB.h"
-#include "AliMUONTriggerChamberEff.h"
 #include "AliMUONTriggerEfficiencyCells.h"
 
 #include "Riostream.h"
 //
 // inputDir (default "."):
 //    path to AliESDs.root
-// outDir (default 0x0)
-//    directory where to store output file "MUON.TriggerEfficiencyMap.root"
-//    (if not set outDir=inputDir is assumed)
 
 void MUONTriggerChamberEfficiency(Bool_t addMapInSimulation=kFALSE,
-                                 const char *inputDir=".",
-                                 const char *outDir=0x0)
+                                 const char *inputDir=".")
 {
-    char filename[150], outfileDir[150];
+    Char_t filename[150], *className = "AliMUONTriggerEfficiencyCells";
     sprintf(filename,"%s/AliESDs.root",inputDir);
 
     TFile *file = new TFile(filename,"read");
@@ -64,24 +59,17 @@ void MUONTriggerChamberEfficiency(Bool_t addMapInSimulation=kFALSE,
        return;
     }
     
-    AliMUONTriggerChamberEff *chEff = (AliMUONTriggerChamberEff*)esdTree->GetUserInfo()->FindObject("AliMUONTriggerChamberEff");
-    if(!chEff){
-       cerr << "Cannot find AliMUONTriggerChamberEff in esdTree.\nExit!" << endl;
+    AliMUONTriggerEfficiencyCells *effMap = 
+      (AliMUONTriggerEfficiencyCells*)esdTree->GetUserInfo()->FindObject(className);
+    if(!effMap){
+       cerr << "Cannot find " << className << " in esdTree.\nExit!" << endl;
        return;
     }
 
-    if(!outDir) sprintf(outfileDir,"%s",inputDir);
-    else sprintf(outfileDir,"%s",outDir);
-
-    chEff->WriteEfficiencyMap(outfileDir);
-    chEff->DisplayEfficiency();
+    effMap->DisplayEfficiency();
 
     if(!addMapInSimulation) return;
 
-    char outFileName[150];
-    sprintf(outFileName,"%s/MUON.TriggerEfficiencyMap.root",outfileDir);
-    
-    AliMUONTriggerEfficiencyCells *effCells = new AliMUONTriggerEfficiencyCells(outFileName);
     AliMUONCDB muonCDB;
-    muonCDB.WriteToCDB("MUON/Calib/TriggerEfficiency",effCells,0,99999999,true);
+    muonCDB.WriteToCDB("MUON/Calib/TriggerEfficiency",effMap,0,99999999,true);
 }