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