CMS 3D CMS Logo

MuonGEMBaseHarvestor.cc
Go to the documentation of this file.
2 
3 #include "TEfficiency.h"
4 
6  : kLogCategory_(log_category) {}
7 
9  const TH1F& passed, const TH1F& total, const char* name, const char* title, Double_t confidence_level) {
10  const TAxis* total_x = total.GetXaxis();
11 
12  TProfile* eff_profile = new TProfile(name, title, total_x->GetNbins(), total_x->GetXmin(), total_x->GetXmax());
13  eff_profile->GetXaxis()->SetTitle(total_x->GetTitle());
14  eff_profile->GetYaxis()->SetTitle("#epsilon");
15 
16  for (Int_t bin = 1; bin < total.GetXaxis()->GetNbins(); bin++) {
17  Double_t num_passed = passed.GetBinContent(bin);
18  Double_t num_total = total.GetBinContent(bin);
19 
20  if (num_passed > num_total) {
21  edm::LogError(kLogCategory_) << "# of passed events > # of total events. "
22  << "These numbers are not consistent." << std::endl;
23  continue;
24  }
25 
26  if (num_total < 1) {
27  eff_profile->SetBinEntries(bin, 0);
28  continue;
29  }
30 
31  Double_t efficiency = num_passed / num_total;
32 
33  Double_t lower_bound = TEfficiency::ClopperPearson(num_total, num_passed, confidence_level, false);
34  Double_t upper_bound = TEfficiency::ClopperPearson(num_total, num_passed, confidence_level, true);
35 
37  Double_t error = std::hypot(efficiency, width);
38 
39  eff_profile->SetBinContent(bin, efficiency);
40  eff_profile->SetBinError(bin, error);
41  eff_profile->SetBinEntries(bin, 1);
42  }
43 
44  return eff_profile;
45 }
46 
48  const TH2F& total,
49  const char* name,
50  const char* title) {
51  TEfficiency eff(passed, total);
52  TH2F* eff_hist = dynamic_cast<TH2F*>(eff.CreateHistogram());
53  eff_hist->SetName(name);
54  eff_hist->SetTitle(title);
55 
56  const TAxis* total_x = total.GetXaxis();
57  TAxis* eff_hist_x = eff_hist->GetXaxis();
58  eff_hist_x->SetTitle(total_x->GetTitle());
59  for (Int_t bin = 1; bin <= total.GetNbinsX(); bin++) {
60  const char* label = total_x->GetBinLabel(bin);
61  eff_hist_x->SetBinLabel(bin, label);
62  }
63 
64  const TAxis* total_y = total.GetYaxis();
65  TAxis* eff_hist_y = eff_hist->GetYaxis();
66  eff_hist_y->SetTitle(total_y->GetTitle());
67  for (Int_t bin = 1; bin <= total.GetNbinsY(); bin++) {
68  const char* label = total_y->GetBinLabel(bin);
69  eff_hist_y->SetBinLabel(bin, label);
70  }
71 
72  return eff_hist;
73 }
74 
76  DQMStore::IGetter& getter,
77  const TString& passed_path,
78  const TString& total_path,
79  const TString& folder,
80  const TString& eff_name,
81  const TString& eff_title) {
82  TH1F* passed = getElement<TH1F>(getter, passed_path);
83  if (passed == nullptr) {
84  edm::LogError(kLogCategory_) << "failed to get " << passed_path << std::endl;
85  return;
86  }
87 
88  TH1F* total = getElement<TH1F>(getter, total_path);
89  if (total == nullptr) {
90  edm::LogError(kLogCategory_) << "failed to get " << total_path << std::endl;
91  return;
92  }
93 
94  TProfile* eff = computeEfficiency(*passed, *total, eff_name, eff_title);
95 
96  booker.setCurrentFolder(folder.Data());
97  booker.bookProfile(eff_name, eff);
98 }
99 
101  DQMStore::IGetter& getter,
102  const TString& passed_path,
103  const TString& total_path,
104  const TString& folder,
105  const TString& eff_name,
106  const TString& eff_title) {
107  TH2F* passed = getElement<TH2F>(getter, passed_path);
108  if (passed == nullptr) {
109  edm::LogError(kLogCategory_) << "failed to get " << passed_path << std::endl;
110  return;
111  }
112 
113  TH2F* total = getElement<TH2F>(getter, total_path);
114  if (total == nullptr) {
115  edm::LogError(kLogCategory_) << "failed to get " << total_path << std::endl;
116  return;
117  }
118 
119  TH2F* eff = computeEfficiency(*passed, *total, eff_name, eff_title);
120  booker.setCurrentFolder(folder.Data());
121  booker.book2D(eff_name, eff);
122 }
pfDeepBoostedJetPreprocessParams_cfi.upper_bound
upper_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:16
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
printsummarytable.folder
folder
Definition: printsummarytable.py:7
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
L1TObjectsTimingClient_cff.efficiency
efficiency
Definition: L1TObjectsTimingClient_cff.py:10
relativeConstraints.error
error
Definition: relativeConstraints.py:53
MuonGEMBaseHarvestor.h
MuonGEMBaseHarvestor::computeEfficiency
TProfile * computeEfficiency(const TH1F &passed, const TH1F &total, const char *name, const char *title, Double_t confidence_level=0.683)
Definition: MuonGEMBaseHarvestor.cc:8
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MuonGEMBaseHarvestor::bookEff2D
void bookEff2D(DQMStore::IBooker &ibooker, DQMStore::IGetter &getter, const TString &passed_path, const TString &total_path, const TString &folder, const TString &eff_name, const TString &eff_title="Efficiency")
Definition: MuonGEMBaseHarvestor.cc:100
MuonGEMBaseHarvestor::MuonGEMBaseHarvestor
MuonGEMBaseHarvestor(const edm::ParameterSet &, std::string)
Definition: MuonGEMBaseHarvestor.cc:5
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
MuonGEMBaseHarvestor::bookEff1D
void bookEff1D(DQMStore::IBooker &ibooker, DQMStore::IGetter &getter, const TString &passed_path, const TString &total_path, const TString &folder, const TString &eff_name, const TString &eff_title="Efficiency")
Definition: MuonGEMBaseHarvestor.cc:75
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
TriggerAnalyzer.passed
passed
Definition: TriggerAnalyzer.py:62
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
label
const char * label
Definition: PFTauDecayModeTools.cc:11
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MuonGEMBaseHarvestor::kLogCategory_
const std::string kLogCategory_
Definition: MuonGEMBaseHarvestor.h:46