6 #include "TEfficiency.h"
17 if (not TEfficiency::CheckConsistency(*passed, *total)) {
22 const TAxis* total_x = total->GetXaxis();
24 TProfile* eff_profile =
new TProfile(name, title, total_x->GetNbins(), total_x->GetXmin(), total_x->GetXmax());
25 eff_profile->GetXaxis()->SetTitle(total_x->GetTitle());
26 eff_profile->GetYaxis()->SetTitle(
"Efficiency");
28 for (
int bin = 1;
bin <= total->GetNbinsX();
bin++) {
29 const double num_passed = passed->GetBinContent(
bin);
30 const double num_total = total->GetBinContent(
bin);
33 eff_profile->SetBinEntries(
bin, 0);
37 const double efficiency = num_passed / num_total;
38 const double lower_boundary = TEfficiency::ClopperPearson(num_total, num_passed,
kConfidenceLevel_,
false);
39 const double upper_boundary = TEfficiency::ClopperPearson(num_total, num_passed,
kConfidenceLevel_,
true);
40 const double error =
std::max(efficiency - lower_boundary, upper_boundary - efficiency);
42 const double profile_error = std::hypot(efficiency, error);
44 eff_profile->SetBinContent(
bin, efficiency);
45 eff_profile->SetBinError(
bin, profile_error);
46 eff_profile->SetBinEntries(
bin, 1);
57 if (not TEfficiency::CheckConsistency(*passed, *total)) {
62 TEfficiency eff(*passed, *total);
63 auto eff_hist =
dynamic_cast<TH2F*
>(eff.CreateHistogram());
64 eff_hist->SetName(name);
65 eff_hist->SetTitle(title);
67 const TAxis* total_x = total->GetXaxis();
68 TAxis* eff_hist_x = eff_hist->GetXaxis();
69 eff_hist_x->SetTitle(total_x->GetTitle());
70 for (
int bin = 1;
bin <= total->GetNbinsX();
bin++) {
71 const char*
label = total_x->GetBinLabel(
bin);
72 eff_hist_x->SetBinLabel(
bin, label);
75 const TAxis* total_y = total->GetYaxis();
76 TAxis* eff_hist_y = eff_hist->GetYaxis();
77 eff_hist_y->SetTitle(total_y->GetTitle());
78 for (
int bin = 1;
bin <= total->GetNbinsY();
bin++) {
79 const char*
label = total_y->GetBinLabel(
bin);
80 eff_hist_y->SetBinLabel(
bin, label);
92 std::map<std::string, std::pair<const MonitorElement*, const MonitorElement*> > me_pairs;
102 const bool is_matched = name.find(
kMatchedSuffix_) != std::string::npos;
108 if (me_pairs.find(key) == me_pairs.end()) {
109 me_pairs[
key] = {
nullptr,
nullptr};
113 me_pairs[
key].first =
me;
115 me_pairs[
key].second =
me;
118 for (
auto& [
key,
value] : me_pairs) {
119 const auto& [me_passed, me_total] =
value;
120 if (me_passed ==
nullptr) {
125 if (me_total ==
nullptr) {
130 if (me_passed->kind() != me_total->kind()) {
139 TH1F* h_passed = me_passed->getTH1F();
140 if (h_passed ==
nullptr) {
146 TH1F* h_total = me_total->getTH1F();
147 if (h_total ==
nullptr) {
153 TProfile* eff =
computeEfficiency(h_passed, h_total, name.c_str(), title.c_str());
154 if (eff ==
nullptr) {
162 TH2F* h_passed = me_passed->
getTH2F();
163 if (h_passed ==
nullptr) {
169 TH2F* h_total = me_total->getTH2F();
170 if (h_total ==
nullptr) {
177 if (eff ==
nullptr) {
182 ibooker.
book2D(name, eff);
GEMDQMEfficiencyCalculator()
virtual TH2F * getTH2F() const
virtual void setCurrentFolder(std::string const &fullpath)
void drawEfficiency(DQMStore::IBooker &, DQMStore::IGetter &, const std::string &)
Log< level::Error, false > LogError
~GEMDQMEfficiencyCalculator()
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())
TProfile * computeEfficiency(const TH1F *, const TH1F *, const char *, const char *)
const std::string kMatchedSuffix_
virtual MonitorElement * get(std::string const &fullpath) const
tuple key
prepare the HTCondor submission files and eventually submit them
const std::string kLogCategory_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
virtual std::vector< std::string > getMEs() const
const float kConfidenceLevel_