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