CMS 3D CMS Logo

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