]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONTriggerChamberEfficiency.C
Fixing RESOURCE_LEAK defect reported by Coverity
[u/mrichter/AliRoot.git] / MUON / MUONTriggerChamberEfficiency.C
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 #if !defined(__CINT__) || defined(__MAKECINT__)
19 // ROOT includes
20 #include "TGrid.h"
21 #include "TString.h"
22
23 // MUON includes
24 #include "AliMUONCDB.h"
25 #include "AliMUONCalibrationData.h"
26 #include "AliMUONTriggerEfficiencyCells.h"
27 #include "AliMUONTriggerChamberEfficiency.h"
28 #include "AliCDBManager.h"
29 #include "AliCDBRunRange.h"
30 #include "Riostream.h"
31
32 #endif
33
34 /// \ingroup macros
35 /// \file MUONTriggerChamberEfficiency.C
36 /// \brief Macro to view and save the trigger chamber efficiency map 
37 /// calculated during reconstruction.
38 ///
39 /// Efficiency map can be made available for next simulation.
40 ///
41 /// \author Diego Stocco, Subatech, Nantes
42
43 void MUONTriggerChamberEfficiency(TString inputFile = "./MUON.TriggerEfficiencyMap.root",
44                                   TString outputCDB = "",
45                                   Int_t firstRun=0, Int_t lastRun = AliCDBRunRange::Infinity()
46 )
47 {
48 /// \param inputFile (default "./MUON.TriggerEfficiencyMaps.root")
49 ///     File with the numerator and denominator histos for efficiency calculation
50 ///     (It is the output of the PWG3/muon/AliAnalysisTaskTrigChEff analysis
51 /// \param outputCDB (default "")
52 ///     add the map on the specified CDB
53 /// \param firstRun (default 0)
54 ///     first run of validity for CDB object
55 /// \param lastRun (default AliCDBRunRange::Infinity())
56 ///     last run of validity for CDB Object
57
58   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
59
60   AliMUONTriggerEfficiencyCells* effMap = new AliMUONTriggerEfficiencyCells(inputFile.Data());
61
62   if ( outputCDB.IsNull() ){
63     // Draw the efficiency and exit
64     AliCDBManager::Instance()->SetRun(firstRun);
65     AliMUONTriggerChamberEfficiency* trigChEff = new AliMUONTriggerChamberEfficiency(effMap);
66  
67     trigChEff->DisplayEfficiency(kFALSE,kFALSE);
68     return;
69   }
70
71
72   // Write efficiency on OCDB
73
74   AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/TriggerEfficiency", outputCDB.Data());
75   
76   AliMUONCDB::WriteToCDB(effMap, "MUON/Calib/TriggerEfficiency", firstRun, lastRun, "Measured efficiencies");
77 }
78
79 //____________________________________________________________
80 void ShowOCDBmap(Int_t runNumber = 0, TString specificCDB="", TString ocdbPath = "local://$ALICE_ROOT/OCDB")
81 {
82 /// \param runNumber (default 0)
83 ///     run number
84 /// \param specificCDB (default "")
85 ///     specific CDB for trigger efficiency
86 /// \param ocdbPath(default "local://$ALICE_ROOT/OCDB")
87 ///     path to OCDB
88   if ( ocdbPath.BeginsWith("alien://") || ocdbPath.BeginsWith("raw://"))
89     TGrid::Connect("alien://");
90
91   AliCDBManager::Instance()->SetDefaultStorage(ocdbPath.Data());
92   if ( !specificCDB.IsNull() )
93     AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/TriggerEfficiency", specificCDB.Data());
94   AliCDBManager::Instance()->SetRun(runNumber);
95   AliMUONCalibrationData calib(runNumber);
96
97   AliMUONTriggerChamberEfficiency* trigChEff = new AliMUONTriggerChamberEfficiency(calib.TriggerEfficiency());
98   trigChEff->DisplayEfficiency();
99 }
100