16 #include "TEfficiency.h" 39 : myDQMrootFolder(
pset.getUntrackedParameter<
string>(
"MyDQMrootFolder")),
52 vector<string> numDenEffMEnames =
pset.getUntrackedParameter<vector<string> >(
"NumDenEffMEnames");
53 if (numDenEffMEnames.size() != 3) {
54 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"NumDenEffMEnames must have three names" << endl;
61 if (denME ==
nullptr || numME ==
nullptr) {
62 LogDebug(
"HLTriggerOfflineHeavyFlavor") <<
"Could not find MEs: " << denMEname <<
" or " << numMEname << endl;
65 TH1* den = denME->
getTH1();
68 if (den->GetNbinsX() !=
num->GetNbinsX() || den->GetNbinsY() !=
num->GetNbinsY() ||
69 den->GetNbinsZ() !=
num->GetNbinsZ()) {
70 LogDebug(
"HLTriggerOfflineHeavyFlavor")
71 <<
"Monitoring elements " << numMEname <<
" and " << denMEname <<
"are incompatible" << endl;
75 string effName = numDenEffMEnames[2];
78 if (string::npos != slashPos) {
79 effDir +=
"/" + effName.substr(0, slashPos);
80 effName.erase(0, slashPos + 1);
89 TH1D* numX = ((TH2F*)
num)->ProjectionX();
90 TH1D* denX = ((TH2F*)den)->ProjectionX();
94 TH1D* numY = ((TH2F*)
num)->ProjectionY();
95 TH1D* denY = ((TH2F*)den)->ProjectionY();
107 if (
num->GetXaxis()->GetXbins()->GetSize() == 0) {
108 eff =
new TProfile(effName.c_str(),
110 num->GetXaxis()->GetNbins(),
111 num->GetXaxis()->GetXmin(),
112 num->GetXaxis()->GetXmax());
115 effName.c_str(), effName.c_str(),
num->GetXaxis()->GetNbins(),
num->GetXaxis()->GetXbins()->GetArray());
117 eff->SetTitle(effName.c_str());
118 eff->SetXTitle(
num->GetXaxis()->GetTitle());
119 eff->SetYTitle(
"Efficiency");
120 eff->SetOption(
"PE");
121 eff->SetLineColor(2);
122 eff->SetLineWidth(2);
123 eff->SetMarkerStyle(20);
124 eff->SetMarkerSize(0.8);
125 eff->GetYaxis()->SetRangeUser(-0.001, 1.001);
126 eff->SetStats(kFALSE);
127 for (
int i = 1;
i <=
num->GetNbinsX();
i++) {
129 if (
int(den->GetBinContent(
i)) > 0.)
130 e = double(
num->GetBinContent(
i)) /
double(den->GetBinContent(
i));
133 low = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)
num->GetBinContent(
i), 0.683,
false);
134 high = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)
num->GetBinContent(
i), 0.683,
true);
138 eff->SetBinContent(
i,
e);
139 eff->SetBinEntries(
i, 1);
149 if (
num->GetXaxis()->GetXbins()->GetSize() == 0 &&
num->GetYaxis()->GetXbins()->GetSize() == 0) {
150 eff =
new TProfile2D(effName.c_str(),
152 num->GetXaxis()->GetNbins(),
153 num->GetXaxis()->GetXmin(),
154 num->GetXaxis()->GetXmax(),
155 num->GetYaxis()->GetNbins(),
156 num->GetYaxis()->GetXmin(),
157 num->GetYaxis()->GetXmax());
158 }
else if (
num->GetXaxis()->GetXbins()->GetSize() != 0 &&
num->GetYaxis()->GetXbins()->GetSize() == 0) {
159 eff =
new TProfile2D(effName.c_str(),
161 num->GetXaxis()->GetNbins(),
162 num->GetXaxis()->GetXbins()->GetArray(),
163 num->GetYaxis()->GetNbins(),
164 num->GetYaxis()->GetXmin(),
165 num->GetYaxis()->GetXmax());
166 }
else if (
num->GetXaxis()->GetXbins()->GetSize() == 0 &&
num->GetYaxis()->GetXbins()->GetSize() != 0) {
167 eff =
new TProfile2D(effName.c_str(),
169 num->GetXaxis()->GetNbins(),
170 num->GetXaxis()->GetXmin(),
171 num->GetXaxis()->GetXmax(),
172 num->GetYaxis()->GetNbins(),
173 num->GetYaxis()->GetXbins()->GetArray());
175 eff =
new TProfile2D(effName.c_str(),
177 num->GetXaxis()->GetNbins(),
178 num->GetXaxis()->GetXbins()->GetArray(),
179 num->GetYaxis()->GetNbins(),
180 num->GetYaxis()->GetXbins()->GetArray());
182 eff->SetTitle(effName.c_str());
183 eff->SetXTitle(
num->GetXaxis()->GetTitle());
184 eff->SetYTitle(
num->GetYaxis()->GetTitle());
185 eff->SetZTitle(
"Efficiency");
186 eff->SetOption(
"colztexte");
187 eff->GetZaxis()->SetRangeUser(-0.001, 1.001);
188 eff->SetStats(kFALSE);
189 for (
int i = 0;
i <
num->GetSize();
i++) {
191 if (
int(den->GetBinContent(
i)) > 0.)
192 e = double(
num->GetBinContent(
i)) /
double(den->GetBinContent(
i));
195 low = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)
num->GetBinContent(
i), 0.683,
false);
196 high = TEfficiency::Wilson((
double)den->GetBinContent(
i), (double)
num->GetBinContent(
i), 0.683,
true);
200 eff->SetBinContent(
i,
e);
201 eff->SetBinEntries(
i, 1);
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)
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())
#define DEFINE_FWK_MODULE(type)
HeavyFlavorHarvesting(const edm::ParameterSet &pset)
void calculateEfficiency2D(TH2F *num, TH2F *den, string name, DQMStore::IBooker &, DQMStore::IGetter &)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual MonitorElement * get(std::string const &fullpath) const
virtual TH1 * getTH1() const
~HeavyFlavorHarvesting() override
void calculateEfficiency(const ParameterSet &pset, DQMStore::IBooker &, DQMStore::IGetter &)