14 #include "TGraphAsymmErrors.h" 57 TProfile *efficHist =
new TProfile(name.c_str(),
59 denum->GetXaxis()->GetNbins(),
60 denum->GetXaxis()->GetXmin(),
61 denum->GetXaxis()->GetXmax());
63 for (
int i = 1;
i <= denum->GetNbinsX();
i++) {
64 double nNum = num->GetBinContent(
i);
65 double nDenum = denum->GetBinContent(
i);
66 if (nDenum == 0 || nNum == 0) {
73 std::cout <<
"Alert! specific bin's num is bigger than denum" << std::endl;
75 const double effVal = nNum / nDenum;
76 efficHist->SetBinContent(
i, effVal);
77 efficHist->SetBinEntries(
i, 1);
78 efficHist->SetBinError(
i, 0);
79 const double errLo = TEfficiency::ClopperPearson((
int)nDenum, (
int)nNum, 0.683,
false);
80 const double errUp = TEfficiency::ClopperPearson((
int)nDenum, (
int)nNum, 0.683,
true);
81 const double errVal = (effVal - errLo > errUp - effVal) ? effVal - errLo : errUp - effVal;
82 efficHist->SetBinError(
i,
sqrt(effVal * effVal + errVal * errVal));
94 if (ig.
get(dbe_label.Data()) !=
nullptr && sh_hist !=
nullptr && track_hist !=
nullptr) {
95 TH1F *
hist = (TH1F *)ig.
get(dbe_label.Data())->getTH1F()->Clone();
97 TProfile *profile_sh =
ComputeEff(hist, sh_hist);
98 profile_sh->SetName((profile->GetName() +
std::string(
"_sh")).c_str());
99 TString x_axis_title = TString(hist->GetXaxis()->GetTitle());
100 TString
title = TString::Format(
101 "Eff. for a SimTrack to have an associated GEM RecHits in %s;%s;Eff.", suffix.Data(), x_axis_title.Data());
102 TString title2 = TString::Format(
103 "Eff. for a SimTrack to have an associated GEM RecHits " 104 "in %s with a matched SimHit;%s;Eff.",
106 x_axis_title.Data());
107 profile->SetTitle(title.Data());
108 profile_sh->SetTitle(title2.Data());
110 ibooker.
bookProfile(profile_sh->GetName(), profile_sh);
112 std::cout <<
"Can not found histogram of " << dbe_label << std::endl;
113 if (track_hist ==
nullptr)
114 std::cout <<
"track not found" << std::endl;
115 if (sh_hist ==
nullptr)
116 std::cout <<
"sh_hist not found" << std::endl;
132 for (
unsigned int i = 0;
i <
s_suffix.size();
i++) {
135 if (ig.
get(eta_label.Data()) !=
nullptr) {
136 gem_trk_eta[
i] = (TH1F *)ig.
get(eta_label.Data())->getTH1F()->Clone();
137 gem_trk_eta[
i]->Sumw2();
139 std::cout <<
"Can not found track_eta" << std::endl;
140 for (
unsigned int k = 0;
k <
c_suffix.size();
k++) {
142 if (ig.
get(phi_label.Data()) !=
nullptr) {
143 gem_trk_phi[
i][
k] = (TH1F *)ig.
get(phi_label.Data())->getTH1F()->Clone();
144 gem_trk_phi[
i][
k]->Sumw2();
146 std::cout <<
"Can not found track_phi" << std::endl;
149 if (ig.
get(eta_label.Data()) !=
nullptr && ig.
get(phi_label.Data()) !=
nullptr) {
150 for (
unsigned int j = 0; j <
l_suffix.size(); j++) {
153 if (ig.
get(eta_label.Data()) !=
nullptr) {
154 sh_eta[
i][j] = (TH1F *)ig.
get(eta_label.Data())->getTH1F()->Clone();
155 sh_eta[
i][j]->Sumw2();
157 std::cout <<
"Can not found eta histogram : " << eta_label << std::endl;
158 ProcessBooking(ibooker, ig,
"rh_eta", suffix, gem_trk_eta[i], sh_eta[i][j]);
159 for (
unsigned int k = 0;
k <
c_suffix.size();
k++) {
162 if (ig.
get(phi_label.Data()) !=
nullptr) {
163 sh_phi[
i][j][
k] = (TH1F *)ig.
get(phi_label.Data())->getTH1F()->Clone();
164 sh_phi[
i][j][
k]->Sumw2();
166 std::cout <<
"Can not found phi plots : " << phi_label << std::endl;
169 ProcessBooking(ibooker, ig,
"rh_phi", suffix, gem_trk_phi[i][k], sh_phi[i][j][k]);
173 std::cout <<
"Can not find eta or phi of all track" << std::endl;
T getUntrackedParameter(std::string const &, T const &) const
static const std::array< std::string, 4 > l_suffix
MonitorElement * bookProfile(Args &&...args)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setCurrentFolder(std::string const &fullpath)
static const std::array< std::string, 2 > s_suffix
#define DEFINE_FWK_MODULE(type)
TProfile * ComputeEff(TH1F *num, TH1F *denum)
MuonGEMRecHitsHarvestor(const edm::ParameterSet &)
constructor
MonitorElement * get(std::string const &path)
void ProcessBooking(DQMStore::IBooker &, DQMStore::IGetter &, const char *label, TString suffix, TH1F *track_hist, TH1F *sh_hist)
~MuonGEMRecHitsHarvestor() override
destructor
static const std::array< std::string, 3 > c_suffix