17 #include "TEfficiency.h"
40 : myDQMrootFolder(pset.getUntrackedParameter<
string>(
"MyDQMrootFolder")),
41 efficiencies(pset.getUntrackedParameter<
VParameterSet>(
"Efficiencies")) {}
54 if (numDenEffMEnames.size() != 3) {
55 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"NumDenEffMEnames must have three names" << endl;
62 if (denME ==
nullptr || numME ==
nullptr) {
63 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not find MEs: " << denMEname <<
" or " << numMEname << endl;
66 TH1* den = denME->
getTH1();
69 if (den->GetNbinsX() != num->GetNbinsX() || den->GetNbinsY() != num->GetNbinsY() ||
70 den->GetNbinsZ() != num->GetNbinsZ()) {
71 LogDebug(
"HLTriggerOfflineHeavyFlavor")
72 <<
"Monitoring elements " << numMEname <<
" and " << denMEname <<
"are incompatible" << endl;
76 string effName = numDenEffMEnames[2];
79 if (string::npos != slashPos) {
80 effDir +=
"/" + effName.substr(0, slashPos);
81 effName.erase(0, slashPos + 1);
85 int dimensions = num->GetDimension();
86 if (dimensions == 1) {
88 }
else if (dimensions == 2) {
90 TH1D* numX = ((TH2F*)num)->ProjectionX();
91 TH1D* denX = ((TH2F*)den)->ProjectionX();
95 TH1D* numY = ((TH2F*)num)->ProjectionY();
96 TH1D* denY = ((TH2F*)den)->ProjectionY();
108 if (num->GetXaxis()->GetXbins()->GetSize() == 0) {
109 eff =
new TProfile(effName.c_str(),
111 num->GetXaxis()->GetNbins(),
112 num->GetXaxis()->GetXmin(),
113 num->GetXaxis()->GetXmax());
116 effName.c_str(), effName.c_str(), num->GetXaxis()->GetNbins(), num->GetXaxis()->GetXbins()->GetArray());
118 eff->SetTitle(effName.c_str());
119 eff->SetXTitle(num->GetXaxis()->GetTitle());
120 eff->SetYTitle(
"Efficiency");
121 eff->SetOption(
"PE");
122 eff->SetLineColor(2);
123 eff->SetLineWidth(2);
124 eff->SetMarkerStyle(20);
125 eff->SetMarkerSize(0.8);
126 eff->GetYaxis()->SetRangeUser(-0.001, 1.001);
127 eff->SetStats(kFALSE);
128 for (
int i = 1;
i <= num->GetNbinsX();
i++) {
130 if (
int(den->GetBinContent(
i)) > 0.)
131 e = double(num->GetBinContent(
i)) /
double(den->GetBinContent(
i));
134 low = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)num->GetBinContent(
i), 0.683,
false);
135 high = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)num->GetBinContent(
i), 0.683,
true);
137 double err = e - low > high - e ? e - low : high -
e;
139 eff->SetBinContent(
i, e);
140 eff->SetBinEntries(
i, 1);
141 eff->SetBinError(
i,
sqrt(e * e + err * err));
150 if (num->GetXaxis()->GetXbins()->GetSize() == 0 && num->GetYaxis()->GetXbins()->GetSize() == 0) {
151 eff =
new TProfile2D(effName.c_str(),
153 num->GetXaxis()->GetNbins(),
154 num->GetXaxis()->GetXmin(),
155 num->GetXaxis()->GetXmax(),
156 num->GetYaxis()->GetNbins(),
157 num->GetYaxis()->GetXmin(),
158 num->GetYaxis()->GetXmax());
159 }
else if (num->GetXaxis()->GetXbins()->GetSize() != 0 && num->GetYaxis()->GetXbins()->GetSize() == 0) {
160 eff =
new TProfile2D(effName.c_str(),
162 num->GetXaxis()->GetNbins(),
163 num->GetXaxis()->GetXbins()->GetArray(),
164 num->GetYaxis()->GetNbins(),
165 num->GetYaxis()->GetXmin(),
166 num->GetYaxis()->GetXmax());
167 }
else if (num->GetXaxis()->GetXbins()->GetSize() == 0 && num->GetYaxis()->GetXbins()->GetSize() != 0) {
168 eff =
new TProfile2D(effName.c_str(),
170 num->GetXaxis()->GetNbins(),
171 num->GetXaxis()->GetXmin(),
172 num->GetXaxis()->GetXmax(),
173 num->GetYaxis()->GetNbins(),
174 num->GetYaxis()->GetXbins()->GetArray());
176 eff =
new TProfile2D(effName.c_str(),
178 num->GetXaxis()->GetNbins(),
179 num->GetXaxis()->GetXbins()->GetArray(),
180 num->GetYaxis()->GetNbins(),
181 num->GetYaxis()->GetXbins()->GetArray());
183 eff->SetTitle(effName.c_str());
184 eff->SetXTitle(num->GetXaxis()->GetTitle());
185 eff->SetYTitle(num->GetYaxis()->GetTitle());
186 eff->SetZTitle(
"Efficiency");
187 eff->SetOption(
"colztexte");
188 eff->GetZaxis()->SetRangeUser(-0.001, 1.001);
189 eff->SetStats(kFALSE);
190 for (
int i = 0;
i < num->GetSize();
i++) {
192 if (
int(den->GetBinContent(
i)) > 0.)
193 e = double(num->GetBinContent(
i)) /
double(den->GetBinContent(
i));
196 low = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)num->GetBinContent(
i), 0.683,
false);
197 high = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)num->GetBinContent(
i), 0.683,
true);
199 double err = e - low > high - e ? e - low : high -
e;
201 eff->SetBinContent(
i, e);
202 eff->SetBinEntries(
i, 1);
203 eff->SetBinError(
i,
sqrt(e * e + err * err));
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
virtual void setCurrentFolder(std::string const &fullpath)
#define DEFINE_FWK_MODULE(type)
std::vector< ParameterSet > VParameterSet
void calculateEfficiency1D(TH1 *num, TH1 *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
const VParameterSet efficiencies
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())
virtual MonitorElement * get(std::string const &fullpath) const
HeavyFlavorHarvesting(const edm::ParameterSet &pset)
void calculateEfficiency2D(TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
~HeavyFlavorHarvesting() override
void calculateEfficiency(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)
virtual TH1 * getTH1() const