CMS 3D CMS Logo

EffPurFromHistos.cc
Go to the documentation of this file.
4 #include "TStyle.h"
5 #include "TCanvas.h"
6 
7 #include <iostream>
8 #include <cmath>
9 
12 
13 using namespace std;
14 using namespace RecoBTag;
15 
17  TH1F* h_d,
18  TH1F* h_u,
19  TH1F* h_s,
20  TH1F* h_c,
21  TH1F* h_b,
22  TH1F* h_g,
23  TH1F* h_ni,
24  TH1F* h_dus,
25  TH1F* h_dusg,
26  TH1F* h_pu,
27  const std::string& label,
28  unsigned int mc,
29  int nBin,
30  double startO,
31  double endO)
32  : fromDiscriminatorDistr(false),
33  mcPlots_(mc),
34  doCTagPlots_(false),
35  label_(label),
36  histoExtension(ext),
37  effVersusDiscr_d(h_d),
38  effVersusDiscr_u(h_u),
39  effVersusDiscr_s(h_s),
40  effVersusDiscr_c(h_c),
41  effVersusDiscr_b(h_b),
42  effVersusDiscr_g(h_g),
43  effVersusDiscr_ni(h_ni),
44  effVersusDiscr_dus(h_dus),
45  effVersusDiscr_dusg(h_dusg),
46  effVersusDiscr_pu(h_pu),
47  nBinOutput(nBin),
48  startOutput(startO),
49  endOutput(endO) {
50  // consistency check
51  check();
52 }
53 
55  const std::string& label,
56  unsigned int mc,
57  DQMStore::IBooker& ibook,
58  int nBin,
59  double startO,
60  double endO)
61  : fromDiscriminatorDistr(true),
62  mcPlots_(mc),
63  doCTagPlots_(false),
64  label_(label),
65  nBinOutput(nBin),
66  startOutput(startO),
67  endOutput(endO) {
68  histoExtension = "_" + dDiscriminatorFC.baseNameTitle();
69 
70  discrNoCutEffic.reset(new FlavourHistograms<double>("totalEntries" + histoExtension,
71  "Total Entries: " + dDiscriminatorFC.baseNameDescription(),
72  dDiscriminatorFC.nBins(),
73  dDiscriminatorFC.lowerBound(),
74  dDiscriminatorFC.upperBound(),
75  false,
76  true,
77  false,
78  "b",
79  label,
80  mcPlots_,
81  ibook));
82 
83  // conditional discriminator cut for efficiency histos
84 
86  "Eff. vs Disc. Cut: " + dDiscriminatorFC.baseNameDescription(),
87  dDiscriminatorFC.nBins(),
88  dDiscriminatorFC.lowerBound(),
89  dDiscriminatorFC.upperBound(),
90  false,
91  true,
92  false,
93  "b",
94  label,
95  mcPlots_,
96  ibook));
97  discrCutEfficScan->SetMinimum(1E-4);
98  if (mcPlots_) {
99  if (mcPlots_ > 2) {
100  effVersusDiscr_d = discrCutEfficScan->histo_d();
101  effVersusDiscr_u = discrCutEfficScan->histo_u();
102  effVersusDiscr_s = discrCutEfficScan->histo_s();
103  effVersusDiscr_g = discrCutEfficScan->histo_g();
104  effVersusDiscr_dus = discrCutEfficScan->histo_dus();
105  } else {
106  effVersusDiscr_d = nullptr;
107  effVersusDiscr_u = nullptr;
108  effVersusDiscr_s = nullptr;
109  effVersusDiscr_g = nullptr;
110  effVersusDiscr_dus = nullptr;
111  }
112  effVersusDiscr_c = discrCutEfficScan->histo_c();
113  effVersusDiscr_b = discrCutEfficScan->histo_b();
114  effVersusDiscr_ni = discrCutEfficScan->histo_ni();
115  effVersusDiscr_dusg = discrCutEfficScan->histo_dusg();
116  effVersusDiscr_pu = discrCutEfficScan->histo_pu();
117 
118  if (mcPlots_ > 2) {
119  effVersusDiscr_d->SetXTitle("Discriminant");
120  effVersusDiscr_d->GetXaxis()->SetTitleOffset(0.75);
121  effVersusDiscr_u->SetXTitle("Discriminant");
122  effVersusDiscr_u->GetXaxis()->SetTitleOffset(0.75);
123  effVersusDiscr_s->SetXTitle("Discriminant");
124  effVersusDiscr_s->GetXaxis()->SetTitleOffset(0.75);
125  effVersusDiscr_g->SetXTitle("Discriminant");
126  effVersusDiscr_g->GetXaxis()->SetTitleOffset(0.75);
127  effVersusDiscr_dus->SetXTitle("Discriminant");
128  effVersusDiscr_dus->GetXaxis()->SetTitleOffset(0.75);
129  }
130  effVersusDiscr_c->SetXTitle("Discriminant");
131  effVersusDiscr_c->GetXaxis()->SetTitleOffset(0.75);
132  effVersusDiscr_b->SetXTitle("Discriminant");
133  effVersusDiscr_b->GetXaxis()->SetTitleOffset(0.75);
134  effVersusDiscr_ni->SetXTitle("Discriminant");
135  effVersusDiscr_ni->GetXaxis()->SetTitleOffset(0.75);
136  effVersusDiscr_dusg->SetXTitle("Discriminant");
137  effVersusDiscr_dusg->GetXaxis()->SetTitleOffset(0.75);
138  effVersusDiscr_pu->SetXTitle("Discriminant");
139  effVersusDiscr_pu->GetXaxis()->SetTitleOffset(0.75);
140  } else {
141  effVersusDiscr_d = nullptr;
142  effVersusDiscr_u = nullptr;
143  effVersusDiscr_s = nullptr;
144  effVersusDiscr_c = nullptr;
145  effVersusDiscr_b = nullptr;
146  effVersusDiscr_g = nullptr;
147  effVersusDiscr_ni = nullptr;
148  effVersusDiscr_dus = nullptr;
149  effVersusDiscr_dusg = nullptr;
150  effVersusDiscr_pu = nullptr;
151  }
152 
153  // discr. for computation
154  vector<TH1F*> discrCfHistos = dDiscriminatorFC.getHistoVector();
155 
156  // discr no cut
157  vector<TH1F*> discrNoCutHistos = discrNoCutEffic->getHistoVector();
158 
159  // discr no cut
160  vector<TH1F*> discrCutHistos = discrCutEfficScan->getHistoVector();
161 
162  const int& dimHistos = discrCfHistos.size(); // they all have the same size
163 
164  // DISCR-CUT LOOP:
165  // fill the histos for eff-pur computations by scanning the discriminatorFC histogram
166 
167  // better to loop over bins -> discrCut no longer needed
168  const int& nBins = dDiscriminatorFC.nBins();
169 
170  // loop over flavours
171  for (int iFlav = 0; iFlav < dimHistos; iFlav++) {
172  if (discrCfHistos[iFlav] == nullptr)
173  continue;
174  discrNoCutHistos[iFlav]->SetXTitle("Discriminant");
175  discrNoCutHistos[iFlav]->GetXaxis()->SetTitleOffset(0.75);
176 
177  // In Root histos, bin counting starts at 1 to nBins.
178  // bin 0 is the underflow, and nBins+1 is the overflow.
179  const double& nJetsFlav = discrCfHistos[iFlav]->GetEntries();
180  double sum = discrCfHistos[iFlav]->GetBinContent(nBins + 1); //+1 to get the overflow.
181 
182  for (int iDiscr = nBins; iDiscr > 0; --iDiscr) {
183  // fill all jets into NoCut histo
184  discrNoCutHistos[iFlav]->SetBinContent(iDiscr, nJetsFlav);
185  discrNoCutHistos[iFlav]->SetBinError(iDiscr, sqrt(nJetsFlav));
186  sum += discrCfHistos[iFlav]->GetBinContent(iDiscr);
187  discrCutHistos[iFlav]->SetBinContent(iDiscr, sum);
188  discrCutHistos[iFlav]->SetBinError(iDiscr, sqrt(sum));
189  }
190  }
191 
192  // divide to get efficiency vs. discriminator cut from absolute numbers
193  discrCutEfficScan->divide(*discrNoCutEffic); // does: histos including discriminator cut / flat histo
194  discrCutEfficScan->setEfficiencyFlag();
195 }
196 
198 
201  discrNoCutEffic->epsPlot(name);
202  discrCutEfficScan->epsPlot(name);
203  }
204  plot(name, ".eps");
205 }
206 
208 
210  std::string hX = "";
211  std::string Title = "";
212  if (!doCTagPlots_) {
213  hX = "FlavEffVsBEff";
214  Title = "b";
215  } else {
216  hX = "FlavEffVsCEff";
217  Title = "c";
218  }
219  TCanvas tc((hX + histoExtension).c_str(),
220  ("Flavour misidentification vs. " + Title + "-tagging efficiency " + histoExtension).c_str());
221  plot(&tc);
222  tc.Print((name + hX + histoExtension + ext).c_str());
223 }
224 
225 void EffPurFromHistos::plot(TPad* plotCanvas /* = 0 */) {
226  //fixme:
227  bool btppNI = false;
228  bool btppColour = true;
229 
230  // if ( !btppTitle ) gStyle->SetOptTitle( 0 );
231  setTDRStyle()->cd();
232 
233  if (plotCanvas)
234  plotCanvas->cd();
235 
236  gPad->UseCurrentStyle();
237  gPad->SetFillColor(0);
238  gPad->SetLogy(1);
239  gPad->SetGridx(1);
240  gPad->SetGridy(1);
241 
242  int col_c;
243  int col_g;
244  int col_dus;
245  int col_ni;
246 
247  int mStyle_c;
248  int mStyle_g;
249  int mStyle_dus;
250  int mStyle_ni;
251 
252  // marker size(same for all)
253  float mSize = gPad->GetWh() * gPad->GetHNDC() / 500.; //1.2;
254 
255  if (btppColour) {
256  col_c = 6;
257  col_g = 3; // g in green
258  col_dus = 4; // uds in blue
259  col_ni = 5; // ni in ??
260  mStyle_c = 20;
261  mStyle_g = 20;
262  mStyle_dus = 20;
263  mStyle_ni = 20;
264  } else {
265  col_c = 1;
266  col_g = 1;
267  col_dus = 1;
268  col_ni = 1;
269  mStyle_c = 22;
270  mStyle_g = 29;
271  mStyle_dus = 20;
272  mStyle_ni = 27;
273  }
274 
275  TString Title = "";
276  if (!doCTagPlots_) {
277  Title = "b";
278  } else {
279  Title = "c";
280  }
281 
282  // for the moment: plot c,dus,g
283  if (mcPlots_ > 2) {
284  EffFlavVsXEff_dus->getTH1F()->GetXaxis()->SetTitle(Title + "-jet efficiency");
285  EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitle("non " + Title + "-jet efficiency");
286  EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitleOffset(0.25);
287  EffFlavVsXEff_dus->getTH1F()->SetMaximum(1.1);
288  EffFlavVsXEff_dus->getTH1F()->SetMinimum(1.e-5);
289  EffFlavVsXEff_dus->getTH1F()->SetMarkerColor(col_dus);
290  EffFlavVsXEff_dus->getTH1F()->SetLineColor(col_dus);
291  EffFlavVsXEff_dus->getTH1F()->SetMarkerSize(mSize);
292  EffFlavVsXEff_dus->getTH1F()->SetMarkerStyle(mStyle_dus);
293  EffFlavVsXEff_dus->getTH1F()->SetStats(false);
294  EffFlavVsXEff_dus->getTH1F()->Draw("pe");
295 
296  EffFlavVsXEff_g->getTH1F()->SetMarkerColor(col_g);
297  EffFlavVsXEff_g->getTH1F()->SetLineColor(col_g);
298  EffFlavVsXEff_g->getTH1F()->SetMarkerSize(mSize);
299  EffFlavVsXEff_g->getTH1F()->SetMarkerStyle(mStyle_g);
300  EffFlavVsXEff_g->getTH1F()->SetStats(false);
301  EffFlavVsXEff_g->getTH1F()->Draw("peSame");
302  }
303  EffFlavVsXEff_c->getTH1F()->SetMarkerColor(col_c);
304  EffFlavVsXEff_c->getTH1F()->SetLineColor(col_c);
305  EffFlavVsXEff_c->getTH1F()->SetMarkerSize(mSize);
306  EffFlavVsXEff_c->getTH1F()->SetMarkerStyle(mStyle_c);
307  EffFlavVsXEff_c->getTH1F()->SetStats(false);
308  EffFlavVsXEff_c->getTH1F()->Draw("peSame");
309 
310  if (mcPlots_ > 2) {
311  EffFlavVsXEff_d->getTH1F()->SetMinimum(0.01);
312  EffFlavVsXEff_u->getTH1F()->SetMinimum(0.01);
313  EffFlavVsXEff_s->getTH1F()->SetMinimum(0.01);
314  EffFlavVsXEff_g->getTH1F()->SetMinimum(0.01);
315  EffFlavVsXEff_dus->getTH1F()->SetMinimum(0.01);
316  }
317  EffFlavVsXEff_c->getTH1F()->SetMinimum(0.01);
318  EffFlavVsXEff_b->getTH1F()->SetMinimum(0.01);
319  EffFlavVsXEff_ni->getTH1F()->SetMinimum(0.01);
320  EffFlavVsXEff_dusg->getTH1F()->SetMinimum(0.01);
321  EffFlavVsXEff_pu->getTH1F()->SetMinimum(0.01);
322 
323  // plot separately u,d and s
324  // EffFlavVsXEff_d ->GetXaxis()->SetTitle( Title + "-jet efficiency" );
325  // EffFlavVsXEff_d ->GetYaxis()->SetTitle( "non " + Title + "-jet efficiency" );
326  // EffFlavVsXEff_d ->GetYaxis()->SetTitleOffset( 1.25 );
327  // EffFlavVsXEff_d ->SetMaximum ( 1.1 );
328  // EffFlavVsXEff_d ->SetMinimum ( 1.e-5 );
329  // EffFlavVsXEff_d ->SetMarkerColor( col_dus );
330  // EffFlavVsXEff_d ->SetLineColor ( col_dus );
331  // EffFlavVsXEff_d ->SetMarkerSize ( mSize );
332  // EffFlavVsXEff_d ->SetMarkerStyle( mStyle_dus );
333  // EffFlavVsXEff_d ->SetStats ( false );
334  // EffFlavVsXEff_d ->Draw("pe");
335  //
336  // EffFlavVsXEff_u ->SetMarkerColor( col_g );
337  // EffFlavVsXEff_u ->SetLineColor ( col_g );
338  // EffFlavVsXEff_u ->SetMarkerSize ( mSize );
339  // EffFlavVsXEff_u ->SetMarkerStyle( mStyle_g );
340  // EffFlavVsXEff_u ->SetStats ( false );
341  // EffFlavVsXEff_u ->Draw("peSame");
342  //
343  // EffFlavVsXEff_s ->SetMarkerColor( col_c );
344  // EffFlavVsXEff_s ->SetLineColor ( col_c );
345  // EffFlavVsXEff_s ->SetMarkerSize ( mSize );
346  // EffFlavVsXEff_s ->SetMarkerStyle( mStyle_c );
347  // EffFlavVsXEff_s ->SetStats ( false );
348  // EffFlavVsXEff_s ->Draw("peSame");
349 
350  // only if asked: NI
351  if (btppNI) {
352  EffFlavVsXEff_ni->getTH1F()->SetMarkerColor(col_ni);
353  EffFlavVsXEff_ni->getTH1F()->SetLineColor(col_ni);
354  EffFlavVsXEff_ni->getTH1F()->SetMarkerSize(mSize);
355  EffFlavVsXEff_ni->getTH1F()->SetMarkerStyle(mStyle_ni);
356  EffFlavVsXEff_ni->getTH1F()->SetStats(false);
357  EffFlavVsXEff_ni->getTH1F()->Draw("peSame");
358  }
359 }
360 
362  // number of bins
363 
364  int nBins_d = 0;
365  int nBins_u = 0;
366  int nBins_s = 0;
367  int nBins_g = 0;
368  int nBins_dus = 0;
369  if (mcPlots_ > 2) {
370  nBins_d = effVersusDiscr_d->GetNbinsX();
371  nBins_u = effVersusDiscr_u->GetNbinsX();
372  nBins_s = effVersusDiscr_s->GetNbinsX();
373  nBins_g = effVersusDiscr_g->GetNbinsX();
374  nBins_dus = effVersusDiscr_dus->GetNbinsX();
375  }
376  const int& nBins_c = effVersusDiscr_c->GetNbinsX();
377  const int& nBins_b = effVersusDiscr_b->GetNbinsX();
378  const int& nBins_ni = effVersusDiscr_ni->GetNbinsX();
379  const int& nBins_dusg = effVersusDiscr_dusg->GetNbinsX();
380  const int& nBins_pu = effVersusDiscr_pu->GetNbinsX();
381 
382  const bool& lNBins = ((nBins_d == nBins_u && nBins_d == nBins_s && nBins_d == nBins_c && nBins_d == nBins_b &&
383  nBins_d == nBins_g && nBins_d == nBins_ni && nBins_d == nBins_dus && nBins_d == nBins_dusg) ||
384  (nBins_c == nBins_b && nBins_c == nBins_dusg && nBins_c == nBins_ni && nBins_c == nBins_pu));
385 
386  if (!lNBins) {
387  throw cms::Exception("Configuration") << "Input histograms do not all have the same number of bins!\n";
388  }
389 
390  // start
391  float sBin_d = 0;
392  float sBin_u = 0;
393  float sBin_s = 0;
394  float sBin_g = 0;
395  float sBin_dus = 0;
396  if (mcPlots_ > 2) {
397  sBin_d = effVersusDiscr_d->GetBinCenter(1);
398  sBin_u = effVersusDiscr_u->GetBinCenter(1);
399  sBin_s = effVersusDiscr_s->GetBinCenter(1);
400  sBin_g = effVersusDiscr_g->GetBinCenter(1);
401  sBin_dus = effVersusDiscr_dus->GetBinCenter(1);
402  }
403  const float& sBin_c = effVersusDiscr_c->GetBinCenter(1);
404  const float& sBin_b = effVersusDiscr_b->GetBinCenter(1);
405  const float& sBin_ni = effVersusDiscr_ni->GetBinCenter(1);
406  const float& sBin_dusg = effVersusDiscr_dusg->GetBinCenter(1);
407  const float& sBin_pu = effVersusDiscr_pu->GetBinCenter(1);
408 
409  const bool& lSBin = ((sBin_d == sBin_u && sBin_d == sBin_s && sBin_d == sBin_c && sBin_d == sBin_b &&
410  sBin_d == sBin_g && sBin_d == sBin_ni && sBin_d == sBin_dus && sBin_d == sBin_dusg) ||
411  (sBin_c == sBin_b && sBin_c == sBin_dusg && sBin_c == sBin_ni && sBin_c == sBin_pu));
412 
413  if (!lSBin) {
414  throw cms::Exception("Configuration")
415  << "EffPurFromHistos::check() : Input histograms do not all have the same start bin!\n";
416  }
417 
418  // end
419  float eBin_d = 0;
420  float eBin_u = 0;
421  float eBin_s = 0;
422  float eBin_g = 0;
423  float eBin_dus = 0;
424  if (mcPlots_ > 2) {
425  eBin_d = effVersusDiscr_d->GetBinCenter(nBins_d - 1);
426  eBin_u = effVersusDiscr_u->GetBinCenter(nBins_d - 1);
427  eBin_s = effVersusDiscr_s->GetBinCenter(nBins_d - 1);
428  eBin_g = effVersusDiscr_g->GetBinCenter(nBins_d - 1);
429  eBin_dus = effVersusDiscr_dus->GetBinCenter(nBins_d - 1);
430  }
431  const float& eBin_c = effVersusDiscr_c->GetBinCenter(nBins_d - 1);
432  const float& eBin_b = effVersusDiscr_b->GetBinCenter(nBins_d - 1);
433  const float& eBin_ni = effVersusDiscr_ni->GetBinCenter(nBins_d - 1);
434  const float& eBin_dusg = effVersusDiscr_dusg->GetBinCenter(nBins_d - 1);
435  const float& eBin_pu = effVersusDiscr_pu->GetBinCenter(nBins_d - 1);
436 
437  const bool& lEBin = ((eBin_d == eBin_u && eBin_d == eBin_s && eBin_d == eBin_c && eBin_d == eBin_b &&
438  eBin_d == eBin_g && eBin_d == eBin_ni && eBin_d == eBin_dus && eBin_d == eBin_dusg) ||
439  (eBin_c == eBin_b && eBin_c == eBin_dusg && eBin_c == eBin_ni && eBin_c == eBin_pu));
440 
441  if (!lEBin) {
442  throw cms::Exception("Configuration")
443  << "EffPurFromHistos::check() : Input histograms do not all have the same end bin!\n";
444  }
445 }
446 
448  if (!mcPlots_) {
449  EffFlavVsXEff_d = nullptr;
450  EffFlavVsXEff_u = nullptr;
451  EffFlavVsXEff_s = nullptr;
452  EffFlavVsXEff_c = nullptr;
453  EffFlavVsXEff_b = nullptr;
454  EffFlavVsXEff_g = nullptr;
455  EffFlavVsXEff_ni = nullptr;
456  EffFlavVsXEff_dus = nullptr;
457  EffFlavVsXEff_dusg = nullptr;
458  EffFlavVsXEff_pu = nullptr;
459  return;
460  }
461 
462  // to have shorter names ......
463  const std::string& hE = histoExtension;
464  std::string hX = "";
465  TString Title = "";
466  if (!doCTagPlots_) {
467  hX = "FlavEffVsBEff_";
468  Title = "b";
469  } else {
470  hX = "FlavEffVsCEff_";
471  Title = "c";
472  }
473 
474  // create histograms from base name and extension as given from user
475  // BINNING MUST BE IDENTICAL FOR ALL OF THEM!!
476  HistoProviderDQM prov("Btag", label_, ibook);
477  if (mcPlots_ > 2) {
478  EffFlavVsXEff_d = (prov.book1D(hX + "D" + hE, hX + "D" + hE, nBinOutput, startOutput, endOutput));
480  EffFlavVsXEff_u = (prov.book1D(hX + "U" + hE, hX + "U" + hE, nBinOutput, startOutput, endOutput));
482  EffFlavVsXEff_s = (prov.book1D(hX + "S" + hE, hX + "S" + hE, nBinOutput, startOutput, endOutput));
484  EffFlavVsXEff_g = (prov.book1D(hX + "G" + hE, hX + "G" + hE, nBinOutput, startOutput, endOutput));
486  EffFlavVsXEff_dus = (prov.book1D(hX + "DUS" + hE, hX + "DUS" + hE, nBinOutput, startOutput, endOutput));
488  } else {
489  EffFlavVsXEff_d = nullptr;
490  EffFlavVsXEff_u = nullptr;
491  EffFlavVsXEff_s = nullptr;
492  EffFlavVsXEff_g = nullptr;
493  EffFlavVsXEff_dus = nullptr;
494  }
495  EffFlavVsXEff_c = (prov.book1D(hX + "C" + hE, hX + "C" + hE, nBinOutput, startOutput, endOutput));
497  EffFlavVsXEff_b = (prov.book1D(hX + "B" + hE, hX + "B" + hE, nBinOutput, startOutput, endOutput));
499  EffFlavVsXEff_ni = (prov.book1D(hX + "NI" + hE, hX + "NI" + hE, nBinOutput, startOutput, endOutput));
501  EffFlavVsXEff_dusg = (prov.book1D(hX + "DUSG" + hE, hX + "DUSG" + hE, nBinOutput, startOutput, endOutput));
503  EffFlavVsXEff_pu = (prov.book1D(hX + "PU" + hE, hX + "PU" + hE, nBinOutput, startOutput, endOutput));
505 
506  if (mcPlots_ > 2) {
507  EffFlavVsXEff_d->getTH1F()->SetXTitle(Title + "-jet efficiency");
508  EffFlavVsXEff_d->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
509  EffFlavVsXEff_d->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
510  EffFlavVsXEff_d->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
511  EffFlavVsXEff_u->getTH1F()->SetXTitle(Title + "-jet efficiency");
512  EffFlavVsXEff_u->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
513  EffFlavVsXEff_u->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
514  EffFlavVsXEff_u->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
515  EffFlavVsXEff_s->getTH1F()->SetXTitle(Title + "-jet efficiency");
516  EffFlavVsXEff_s->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
517  EffFlavVsXEff_s->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
518  EffFlavVsXEff_s->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
519  EffFlavVsXEff_g->getTH1F()->SetXTitle(Title + "-jet efficiency");
520  EffFlavVsXEff_g->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
521  EffFlavVsXEff_g->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
522  EffFlavVsXEff_g->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
523  EffFlavVsXEff_dus->getTH1F()->SetXTitle(Title + "-jet efficiency");
524  EffFlavVsXEff_dus->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
525  EffFlavVsXEff_dus->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
526  EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
527  }
528  EffFlavVsXEff_c->getTH1F()->SetXTitle(Title + "-jet efficiency");
529  EffFlavVsXEff_c->getTH1F()->SetYTitle("c-jet efficiency");
530  EffFlavVsXEff_c->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
531  EffFlavVsXEff_c->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
532  EffFlavVsXEff_b->getTH1F()->SetXTitle(Title + "-jet efficiency");
533  EffFlavVsXEff_b->getTH1F()->SetYTitle("b-jet efficiency");
534  EffFlavVsXEff_b->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
535  EffFlavVsXEff_b->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
536  EffFlavVsXEff_ni->getTH1F()->SetXTitle(Title + "-jet efficiency");
537  EffFlavVsXEff_ni->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
538  EffFlavVsXEff_ni->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
539  EffFlavVsXEff_ni->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
540  EffFlavVsXEff_dusg->getTH1F()->SetXTitle(Title + "-jet efficiency");
541  EffFlavVsXEff_dusg->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
542  EffFlavVsXEff_dusg->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
543  EffFlavVsXEff_dusg->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
544  EffFlavVsXEff_pu->getTH1F()->SetXTitle(Title + "-jet efficiency");
545  EffFlavVsXEff_pu->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
546  EffFlavVsXEff_pu->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
547  EffFlavVsXEff_pu->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
548 
549  // loop over eff. vs. discriminator cut b-histo and look in which bin the closest entry is;
550  // use fact that eff decreases monotonously
551 
552  // any of the histos to be created can be taken here:
553  MonitorElement* EffFlavVsXEff = EffFlavVsXEff_b;
554 
555  const int& nBinX = EffFlavVsXEff->getTH1F()->GetNbinsX();
556 
557  for (int iBinX = 1; iBinX <= nBinX; iBinX++) { // loop over the bins on the x-axis of the histograms to be filled
558 
559  const float& effXBinWidth = EffFlavVsXEff->getTH1F()->GetBinWidth(iBinX);
560  const float& effXMid = EffFlavVsXEff->getTH1F()->GetBinCenter(iBinX); // middle of b-efficiency bin
561  const float& effXLeft = effXMid - 0.5 * effXBinWidth; // left edge of bin
562  const float& effXRight = effXMid + 0.5 * effXBinWidth; // right edge of bin
563  // find the corresponding bin in the efficiency versus discriminator cut histo: closest one in efficiency
564 
565  int binClosest = -1;
566  if (!doCTagPlots_) {
567  binClosest = findBinClosestYValue(effVersusDiscr_b, effXMid, effXLeft, effXRight);
568  } else {
569  binClosest = findBinClosestYValue(effVersusDiscr_c, effXMid, effXLeft, effXRight);
570  }
571 
572  const bool& binFound = (binClosest > 0);
573  //
574  if (binFound) {
575  // fill the histos
576  if (mcPlots_ > 2) {
577  EffFlavVsXEff_d->Fill(effXMid, effVersusDiscr_d->GetBinContent(binClosest));
578  EffFlavVsXEff_u->Fill(effXMid, effVersusDiscr_u->GetBinContent(binClosest));
579  EffFlavVsXEff_s->Fill(effXMid, effVersusDiscr_s->GetBinContent(binClosest));
580  EffFlavVsXEff_g->Fill(effXMid, effVersusDiscr_g->GetBinContent(binClosest));
581  EffFlavVsXEff_dus->Fill(effXMid, effVersusDiscr_dus->GetBinContent(binClosest));
582  }
583  EffFlavVsXEff_c->Fill(effXMid, effVersusDiscr_c->GetBinContent(binClosest));
584  EffFlavVsXEff_b->Fill(effXMid, effVersusDiscr_b->GetBinContent(binClosest));
585  EffFlavVsXEff_ni->Fill(effXMid, effVersusDiscr_ni->GetBinContent(binClosest));
586  EffFlavVsXEff_dusg->Fill(effXMid, effVersusDiscr_dusg->GetBinContent(binClosest));
587  EffFlavVsXEff_pu->Fill(effXMid, effVersusDiscr_pu->GetBinContent(binClosest));
588 
589  if (mcPlots_ > 2) {
590  EffFlavVsXEff_d->getTH1F()->SetBinError(iBinX, effVersusDiscr_d->GetBinError(binClosest));
591  EffFlavVsXEff_u->getTH1F()->SetBinError(iBinX, effVersusDiscr_u->GetBinError(binClosest));
592  EffFlavVsXEff_s->getTH1F()->SetBinError(iBinX, effVersusDiscr_s->GetBinError(binClosest));
593  EffFlavVsXEff_g->getTH1F()->SetBinError(iBinX, effVersusDiscr_g->GetBinError(binClosest));
594  EffFlavVsXEff_dus->getTH1F()->SetBinError(iBinX, effVersusDiscr_dus->GetBinError(binClosest));
595  }
596  EffFlavVsXEff_c->getTH1F()->SetBinError(iBinX, effVersusDiscr_c->GetBinError(binClosest));
597  EffFlavVsXEff_b->getTH1F()->SetBinError(iBinX, effVersusDiscr_b->GetBinError(binClosest));
598  EffFlavVsXEff_ni->getTH1F()->SetBinError(iBinX, effVersusDiscr_ni->GetBinError(binClosest));
599  EffFlavVsXEff_dusg->getTH1F()->SetBinError(iBinX, effVersusDiscr_dusg->GetBinError(binClosest));
600  EffFlavVsXEff_pu->getTH1F()->SetBinError(iBinX, effVersusDiscr_pu->GetBinError(binClosest));
601  }
602  }
603 }
604 
605 #include <typeinfo>
FlavourHistograms::baseNameDescription
std::string baseNameDescription() const
Definition: FlavourHistorgrams.h:78
ext
Definition: memstream.h:15
EffPurFromHistos::check
void check()
Definition: EffPurFromHistos.cc:361
funct::false
false
Definition: Factorize.h:34
EffPurFromHistos::EffFlavVsXEff_pu
MonitorElement * EffFlavVsXEff_pu
Definition: EffPurFromHistos.h:118
EffPurFromHistos::effVersusDiscr_s
TH1F * effVersusDiscr_s
Definition: EffPurFromHistos.h:93
CaloTowersParam_cfi.mc
mc
Definition: CaloTowersParam_cfi.py:8
EffPurFromHistos::EffFlavVsXEff_dusg
MonitorElement * EffFlavVsXEff_dusg
Definition: EffPurFromHistos.h:117
EffPurFromHistos::effVersusDiscr_dusg
TH1F * effVersusDiscr_dusg
Definition: EffPurFromHistos.h:99
EffPurFromHistos::histoExtension
std::string histoExtension
Definition: EffPurFromHistos.h:83
dqm::impl::MonitorElement::setEfficiencyFlag
void setEfficiencyFlag()
Definition: MonitorElement.h:267
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
EffPurFromHistos::EffPurFromHistos
EffPurFromHistos(const std::string &ext, TH1F *h_d, TH1F *h_u, TH1F *h_s, TH1F *h_c, TH1F *h_b, TH1F *h_g, TH1F *h_ni, TH1F *h_dus, TH1F *h_dusg, TH1F *h_pu, const std::string &label, unsigned int mc, int nBin=100, double startO=0.005, double endO=1.005)
Definition: EffPurFromHistos.cc:16
FlavourHistograms::upperBound
double upperBound() const
Definition: FlavourHistorgrams.h:81
EffPurFromHistos::doCTagPlots_
bool doCTagPlots_
Definition: EffPurFromHistos.h:80
EffPurFromHistos.h
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:478
FlavourHistograms::getHistoVector
std::vector< TH1F * > getHistoVector() const
Definition: FlavourHistorgrams.h:701
PFElectronDQMAnalyzer_cfi.nBin
nBin
Definition: PFElectronDQMAnalyzer_cfi.py:25
FlavourHistograms::baseNameTitle
std::string baseNameTitle() const
Definition: FlavourHistorgrams.h:77
EffPurFromHistos::endOutput
double endOutput
Definition: EffPurFromHistos.h:107
plotscripts.setTDRStyle
def setTDRStyle()
Definition: plotscripts.py:89
RecoBTag::findBinClosestYValue
int findBinClosestYValue(const TH1F *, const float &yVal, const float &yLow, const float &yHigh)
Definition: Tools.cc:225
EffPurFromHistos::effVersusDiscr_pu
TH1F * effVersusDiscr_pu
Definition: EffPurFromHistos.h:100
FlavourHistograms::lowerBound
double lowerBound() const
Definition: FlavourHistorgrams.h:80
FlavourHistograms
Definition: FlavourHistorgrams.h:26
EffPurFromHistos::mcPlots_
unsigned int mcPlots_
Definition: EffPurFromHistos.h:79
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
EffPurFromHistos::effVersusDiscr_g
TH1F * effVersusDiscr_g
Definition: EffPurFromHistos.h:96
EffPurFromHistos::label_
std::string label_
Definition: EffPurFromHistos.h:81
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EffPurFromHistos::EffFlavVsXEff_b
MonitorElement * EffFlavVsXEff_b
Definition: EffPurFromHistos.h:113
FlavourHistograms::nBins
int nBins() const
Definition: FlavourHistorgrams.h:79
EffPurFromHistos::EffFlavVsXEff_dus
MonitorElement * EffFlavVsXEff_dus
Definition: EffPurFromHistos.h:116
funct::true
true
Definition: Factorize.h:173
EffPurFromHistos::fromDiscriminatorDistr
bool fromDiscriminatorDistr
Definition: EffPurFromHistos.h:77
EffPurFromHistos::plot
void plot(TPad *theCanvas=nullptr)
Definition: EffPurFromHistos.cc:225
HistoProviderDQM::book1D
virtual MonitorElement * book1D(const std::string &name, const std::string &title, const int &nchX, const double &lowX, const double &highX)
Definition: HistoProviderDQM.cc:15
EffPurFromHistos::EffFlavVsXEff_s
MonitorElement * EffFlavVsXEff_s
Definition: EffPurFromHistos.h:111
EffPurFromHistos::psPlot
void psPlot(const std::string &name)
Definition: EffPurFromHistos.cc:207
EffPurFromHistos::discrNoCutEffic
std::unique_ptr< FlavourHistograms< double > > discrNoCutEffic
Definition: EffPurFromHistos.h:85
EffPurFromHistos::effVersusDiscr_dus
TH1F * effVersusDiscr_dus
Definition: EffPurFromHistos.h:98
EffPurFromHistos::EffFlavVsXEff_u
MonitorElement * EffFlavVsXEff_u
Definition: EffPurFromHistos.h:110
EffPurFromHistos::effVersusDiscr_d
TH1F * effVersusDiscr_d
Definition: EffPurFromHistos.h:91
EffPurFromHistos::effVersusDiscr_b
TH1F * effVersusDiscr_b
Definition: EffPurFromHistos.h:95
EffPurFromHistos::startOutput
double startOutput
Definition: EffPurFromHistos.h:106
RecoBTag
Definition: Tools.h:22
EffPurFromHistos::epsPlot
void epsPlot(const std::string &name)
Definition: EffPurFromHistos.cc:199
EffPurFromHistos::effVersusDiscr_c
TH1F * effVersusDiscr_c
Definition: EffPurFromHistos.h:94
EffPurFromHistos::compute
void compute(DQMStore::IBooker &ibook)
Definition: EffPurFromHistos.cc:447
std
Definition: JetResolutionObject.h:76
EffPurFromHistos::discrCutEfficScan
std::unique_ptr< FlavourHistograms< double > > discrCutEfficScan
Definition: EffPurFromHistos.h:85
EffPurFromHistos::~EffPurFromHistos
~EffPurFromHistos()
Definition: EffPurFromHistos.cc:197
EffPurFromHistos::EffFlavVsXEff_d
MonitorElement * EffFlavVsXEff_d
Definition: EffPurFromHistos.h:109
Exception
Definition: hltDiff.cc:246
anotherprimaryvertexanalyzer_cfi.nBinX
nBinX
Definition: anotherprimaryvertexanalyzer_cfi.py:12
EffPurFromHistos::nBinOutput
int nBinOutput
Definition: EffPurFromHistos.h:105
EffPurFromHistos::EffFlavVsXEff_g
MonitorElement * EffFlavVsXEff_g
Definition: EffPurFromHistos.h:114
EffPurFromHistos::effVersusDiscr_u
TH1F * effVersusDiscr_u
Definition: EffPurFromHistos.h:92
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
EffPurFromHistos::EffFlavVsXEff_c
MonitorElement * EffFlavVsXEff_c
Definition: EffPurFromHistos.h:112
HistoProviderDQM
Definition: HistoProviderDQM.h:8
Tools.h
EffPurFromHistos::effVersusDiscr_ni
TH1F * effVersusDiscr_ni
Definition: EffPurFromHistos.h:97
EffPurFromHistos::EffFlavVsXEff_ni
MonitorElement * EffFlavVsXEff_ni
Definition: EffPurFromHistos.h:115
label
const char * label
Definition: PFTauDecayModeTools.cc:11
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37