12 #include "TGraphAsymmErrors.h" 49 TProfile * efficHist =
new TProfile(name.c_str(), title.c_str(),denum->GetXaxis()->GetNbins(), denum->GetXaxis()->GetXmin(),denum->GetXaxis()->GetXmax());
51 for (
int i=1;
i <= denum->GetNbinsX();
i++) {
53 double nNum = num->GetBinContent(
i);
54 double nDenum = denum->GetBinContent(
i);
55 if ( nDenum == 0 || nNum ==0 ) {
58 if ( nNum > nDenum ) {
62 edm::LogWarning(
"MuonME0SegHarvestor")<<
"Alert! specific bin's num is bigger than denum "<<
i<<
" "<<nNum<<
" "<<nDenum;
64 const double effVal = nNum/nDenum;
65 efficHist->SetBinContent(
i, effVal);
66 efficHist->SetBinEntries(
i,1);
67 efficHist->SetBinError(
i,0);
68 const double errLo = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
false);
69 const double errUp = TEfficiency::ClopperPearson((
int)nDenum,(
int)nNum,0.683,
true);
70 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
71 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
80 if( num !=
nullptr && den !=
nullptr ) {
84 TString x_axis_title = TString(num->GetXaxis()->GetTitle());
85 TString
title = TString::Format(
"Segment Efficiency;%s;Eff.",x_axis_title.Data());
87 profile->SetTitle( title.Data());
96 if ( num ==
nullptr)
edm::LogWarning(
"MuonME0SegHarvestor")<<
"num not found";
97 if ( den ==
nullptr)
edm::LogWarning(
"MuonME0SegHarvestor")<<
"den not found";
110 TString eta_label_den = TString(
dbe_path_)+
"me0_simsegment_eta";
111 TString eta_label_num = TString(
dbe_path_)+
"me0_matchedsimsegment_eta";
112 TString pt_label_den = TString(
dbe_path_)+
"me0_simsegment_pt";
113 TString pt_label_num = TString(
dbe_path_)+
"me0_matchedsimsegment_pt";
114 TString phi_label_den = TString(
dbe_path_)+
"me0_simsegment_phi";
115 TString phi_label_num = TString(
dbe_path_)+
"me0_matchedsimsegment_phi";
117 if( ig.
get(eta_label_num.Data()) !=
nullptr && ig.
get(eta_label_den.Data()) !=
nullptr ) {
119 TH1F* num_vs_eta = (TH1F*)ig.
get(eta_label_num.Data())->getTH1F()->Clone();
121 TH1F *den_vs_eta = (TH1F*)ig.
get(eta_label_den.Data())->getTH1F()->Clone();
124 ProcessBooking( ibooker, ig,
"me0segment_eff_vs_eta", num_vs_eta, den_vs_eta );
130 else edm::LogWarning(
"MuonME0SegHarvestor")<<
"Can not find histograms: "<<eta_label_num<<
" or "<<eta_label_den;
132 if( ig.
get(pt_label_num.Data()) !=
nullptr && ig.
get(pt_label_den.Data()) !=
nullptr ) {
134 TH1F* num_vs_pt = (TH1F*)ig.
get(pt_label_num.Data())->getTH1F()->Clone();
136 TH1F *den_vs_pt = (TH1F*)ig.
get(pt_label_den.Data())->getTH1F()->Clone();
139 ProcessBooking( ibooker, ig,
"me0segment_eff_vs_pt", num_vs_pt, den_vs_pt );
145 else edm::LogWarning(
"MuonME0SegHarvestor")<<
"Can not find histograms: "<<pt_label_num<<
" or "<<pt_label_den;
147 if( ig.
get(phi_label_num.Data()) !=
nullptr && ig.
get(phi_label_den.Data()) !=
nullptr ) {
149 TH1F* num_vs_phi = (TH1F*)ig.
get(phi_label_num.Data())->getTH1F()->Clone();
151 TH1F *den_vs_phi = (TH1F*)ig.
get(phi_label_den.Data())->getTH1F()->Clone();
154 ProcessBooking( ibooker, ig,
"me0segment_eff_vs_phi", num_vs_phi, den_vs_phi );
160 else edm::LogWarning(
"MuonME0SegHarvestor")<<
"Can not find histograms: "<<phi_label_num<<
" or "<<phi_label_den;
MonitorElement * bookProfile(Args &&...args)
#define DEFINE_FWK_MODULE(type)
void setCurrentFolder(std::string const &fullpath)
MuonME0SegHarvestor(const edm::ParameterSet &)
constructor
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, std::string nameHist, TH1F *num, TH1F *den)
~MuonME0SegHarvestor() override
destructor
MonitorElement * get(std::string const &path)
TProfile * ComputeEff(TH1F *num, TH1F *denum, std::string nameHist)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override