]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONTriggerChamberEfficiency.C
- Add information in the trigger chamber efficiency object in order to take into...
[u/mrichter/AliRoot.git] / MUON / MUONTriggerChamberEfficiency.C
index 1553cf65433eff82979939262d027bace7feac02..95bda5c7976976aa1a7a0b89c82233e475a1cc8d 100644 (file)
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 // ROOT includes
-#include "TFile.h"
-#include "TTree.h"
+#include "TGrid.h"
+#include "TString.h"
 
 // MUON includes
 #include "AliMUONCDB.h"
+#include "AliMUONCalibrationData.h"
 #include "AliMUONTriggerEfficiencyCells.h"
-
+#include "AliMUONTriggerChamberEfficiency.h"
+#include "AliCDBManager.h"
+#include "AliCDBRunRange.h"
 #include "Riostream.h"
 
 #endif
 
-// Macro to view and save the trigger chamber efficiency map 
-// calculated during reconstruction.
-// Efficiency map can be made available for next simulation.
-
-// Arguments:
-//
-// addMapInSimulation (default kFALSE):
-//    kTRUE: creates file MUON/Calib/TriggerEfficiency/Run0_99999999_v0_s?.root
-//           with calculated chamber efficiency which can be used in the next simulation
-//
-// inputDir (default "."):
-//    path to AliESDs.root
+/// \ingroup macros
+/// \file MUONTriggerChamberEfficiency.C
+/// \brief Macro to view and save the trigger chamber efficiency map 
+/// calculated during reconstruction.
+///
+/// Efficiency map can be made available for next simulation.
+///
+/// \author Diego Stocco, Subatech, Nantes
 
-void MUONTriggerChamberEfficiency(Bool_t addMapInSimulation=kFALSE,
-                                 const char *inputDir=".")
+void MUONTriggerChamberEfficiency(const Char_t* inputFile="./MUON.TriggerEfficiencyMap.root",
+                                 Bool_t addMapInLocalOCDB = kFALSE,
+                                 Int_t firstRun=0, Int_t lastRun = AliCDBRunRange::Infinity())
 {
-    Char_t filename[150], *className = "AliMUONTriggerEfficiencyCells";
-    sprintf(filename,"%s/AliESDs.root",inputDir);
+/// \param inputFile (default "./MUON.TriggerEfficiencyMaps.root")
+///     File with the numerator and denominator histos for efficiency calculation
+///     (It is the output of the PWG3/muon/AliAnalysisTaskTrigChEff analysis
+/// \param addMapInLocalOCDB (default kFALSE)
+///     if the map is OK, add it in local OCDB
+/// \param firstRun (default 0)
+///     first run of validity for CDB object
+/// \param lastRun (default AliCDBRunRange::Infinity())
+///     last run of validity for CDB Object
+
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
 
-    TFile *file = new TFile(filename,"read");
-    if(!file){
-       cerr << "Cannot find " << filename << "\nExit!" << endl;
-       return;
-    }
-    
-    TTree *esdTree = (TTree*)file->Get("esdTree");
-    if(!esdTree){
-       cerr << "Cannot find esdTree in " << filename << "\nExit!" << endl;
-       return;
-    }
-    
-    AliMUONTriggerEfficiencyCells *effMap = 
-      (AliMUONTriggerEfficiencyCells*)esdTree->GetUserInfo()->FindObject(className);
-    if(!effMap){
-       cerr << "Cannot find " << className << " in esdTree.\nExit!" << endl;
-       return;
-    }
+  AliMUONTriggerEfficiencyCells* effMap = new AliMUONTriggerEfficiencyCells(inputFile);
+  if ( ! addMapInLocalOCDB ){
+    AliCDBManager::Instance()->SetRun(firstRun);
+    AliMUONTriggerChamberEfficiency trigChEff(effMap);
+    trigChEff.DisplayEfficiency();
+  }
+  else
+    AliMUONCDB::WriteToCDB("MUON/Calib/TriggerEfficiency", effMap, firstRun, lastRun,true);
+}
 
-    effMap->DisplayEfficiency();
+//____________________________________________________________
+void ShowOCDBmap(Int_t runNumber = 0, TString ocdbPath="local://$ALICE_ROOT/OCDB")
+{
+/// \param runNumber (default 0)
+///     run number
+/// \param ocdbPath(default "local://$ALICE_ROOT/OCDB")
+///     path to OCDB
+  if ( ocdbPath.BeginsWith("alien://") || ocdbPath.BeginsWith("raw://"))
+    TGrid::Connect("alien://");
 
-    if(!addMapInSimulation) return;
+  AliCDBManager::Instance()->SetDefaultStorage(ocdbPath.Data());
+  AliCDBManager::Instance()->SetRun(runNumber);
+  AliMUONCalibrationData calib(runNumber);
 
-    AliMUONCDB muonCDB;
-    muonCDB.WriteToCDB("MUON/Calib/TriggerEfficiency",effMap,0,99999999,true);
+  AliMUONTriggerChamberEfficiency trigChEff(calib.TriggerEfficiency());
+  trigChEff.DisplayEfficiency();
 }
+