11 #include "TGraphAsymmErrors.h" 39 TProfile *efficHist =
new TProfile(
name.c_str(),
41 denum->GetXaxis()->GetNbins(),
42 denum->GetXaxis()->GetXmin(),
43 denum->GetXaxis()->GetXmax());
45 for (
int i = 1;
i <= denum->GetNbinsX();
i++) {
46 double nNum =
num->GetBinContent(
i);
47 double nDenum = denum->GetBinContent(
i);
48 if (nDenum == 0 || nNum == 0) {
56 <<
"Alert! specific bin's num is bigger than denum " <<
i <<
" " << nNum <<
" " << nDenum;
58 const double effVal = nNum / nDenum;
59 efficHist->SetBinContent(
i, effVal);
60 efficHist->SetBinEntries(
i, 1);
61 efficHist->SetBinError(
i, 0);
62 const double errLo = TEfficiency::ClopperPearson((
int)nDenum, (
int)nNum, 0.683,
false);
63 const double errUp = TEfficiency::ClopperPearson((
int)nDenum, (
int)nNum, 0.683,
true);
64 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
65 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
72 if (
num !=
nullptr && den !=
nullptr) {
75 TString x_axis_title = TString(
num->GetXaxis()->GetTitle());
76 TString
title = TString::Format(
"Segment Efficiency;%s;Eff.", x_axis_title.Data());
96 TString eta_label_den = TString(
dbe_path_) +
"me0_simsegment_eta";
97 TString eta_label_num = TString(
dbe_path_) +
"me0_matchedsimsegment_eta";
98 TString pt_label_den = TString(
dbe_path_) +
"me0_simsegment_pt";
99 TString pt_label_num = TString(
dbe_path_) +
"me0_matchedsimsegment_pt";
100 TString phi_label_den = TString(
dbe_path_) +
"me0_simsegment_phi";
101 TString phi_label_num = TString(
dbe_path_) +
"me0_matchedsimsegment_phi";
103 if (ig.
get(eta_label_num.Data()) !=
nullptr && ig.
get(eta_label_den.Data()) !=
nullptr) {
104 TH1F *num_vs_eta = (TH1F *)ig.
get(eta_label_num.Data())->getTH1F()->Clone();
106 TH1F *den_vs_eta = (TH1F *)ig.
get(eta_label_den.Data())->getTH1F()->Clone();
109 ProcessBooking(ibooker, ig,
"me0segment_eff_vs_eta", num_vs_eta, den_vs_eta);
115 edm::LogWarning(
"MuonME0SegHarvestor") <<
"Can not find histograms: " << eta_label_num <<
" or " << eta_label_den;
117 if (ig.
get(pt_label_num.Data()) !=
nullptr && ig.
get(pt_label_den.Data()) !=
nullptr) {
118 TH1F *num_vs_pt = (TH1F *)ig.
get(pt_label_num.Data())->getTH1F()->Clone();
120 TH1F *den_vs_pt = (TH1F *)ig.
get(pt_label_den.Data())->getTH1F()->Clone();
123 ProcessBooking(ibooker, ig,
"me0segment_eff_vs_pt", num_vs_pt, den_vs_pt);
129 edm::LogWarning(
"MuonME0SegHarvestor") <<
"Can not find histograms: " << pt_label_num <<
" or " << pt_label_den;
131 if (ig.
get(phi_label_num.Data()) !=
nullptr && ig.
get(phi_label_den.Data()) !=
nullptr) {
132 TH1F *num_vs_phi = (TH1F *)ig.
get(phi_label_num.Data())->getTH1F()->Clone();
134 TH1F *den_vs_phi = (TH1F *)ig.
get(phi_label_den.Data())->getTH1F()->Clone();
137 ProcessBooking(ibooker, ig,
"me0segment_eff_vs_phi", num_vs_phi, den_vs_phi);
143 edm::LogWarning(
"MuonME0SegHarvestor") <<
"Can not find histograms: " << phi_label_num <<
" or " << phi_label_den;
virtual void setCurrentFolder(std::string const &fullpath)
MuonME0SegHarvestor(const edm::ParameterSet &)
constructor
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())
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, std::string nameHist, TH1F *num, TH1F *den)
~MuonME0SegHarvestor() override
destructor
#define DEFINE_FWK_MODULE(type)
TProfile * ComputeEff(TH1F *num, TH1F *denum, std::string nameHist)
virtual MonitorElement * get(std::string const &fullpath) const
Log< level::Warning, false > LogWarning
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override