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 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, const unsigned int& mc,
21  int nBin, double startO, double endO) :
22  fromDiscriminatorDistr(false),
23  histoExtension(ext), effVersusDiscr_d(h_d), effVersusDiscr_u(h_u),
24  effVersusDiscr_s(h_s), effVersusDiscr_c(h_c), effVersusDiscr_b(h_b),
25  effVersusDiscr_g(h_g), effVersusDiscr_ni(h_ni), effVersusDiscr_dus(h_dus),
26  effVersusDiscr_dusg(h_dusg), effVersusDiscr_pu(h_pu),
27  nBinOutput(nBin), startOutput(startO),
28  endOutput(endO), mcPlots_(mc), label_(label)
29 {
30  // consistency check
31  check();
32 }
33 
35  const unsigned int& mc, DQMStore::IBooker & ibook, int nBin,
36  double startO, double endO) :
37  fromDiscriminatorDistr(true), nBinOutput(nBin), startOutput(startO), endOutput(endO), mcPlots_(mc), label_(label){
38  histoExtension = "_"+dDiscriminatorFC->baseNameTitle();
39 
40 
42  "totalEntries" + histoExtension, "Total Entries: " + dDiscriminatorFC->baseNameDescription(),
43  dDiscriminatorFC->nBins(), dDiscriminatorFC->lowerBound(),
44  dDiscriminatorFC->upperBound(), false, true, false, "b", label, mcPlots_, ibook );
45 
46  // conditional discriminator cut for efficiency histos
47 
49  "effVsDiscrCut" + histoExtension, "Eff. vs Disc. Cut: " + dDiscriminatorFC->baseNameDescription(),
50  dDiscriminatorFC->nBins(), dDiscriminatorFC->lowerBound(),
51  dDiscriminatorFC->upperBound(), false, true, false, "b", label , mcPlots_, ibook );
52  discrCutEfficScan->SetMinimum(1E-4);
53  if (mcPlots_){
54 
55  if(mcPlots_>2){
56  effVersusDiscr_d = discrCutEfficScan->histo_d ();
57  effVersusDiscr_u = discrCutEfficScan->histo_u ();
58  effVersusDiscr_s = discrCutEfficScan->histo_s ();
59  effVersusDiscr_g = discrCutEfficScan->histo_g ();
60  effVersusDiscr_dus = discrCutEfficScan->histo_dus ();
61  }
62  else{
63  effVersusDiscr_d = 0;
64  effVersusDiscr_u = 0;
65  effVersusDiscr_s = 0;
66  effVersusDiscr_g = 0;
68  }
69  effVersusDiscr_c = discrCutEfficScan->histo_c ();
70  effVersusDiscr_b = discrCutEfficScan->histo_b ();
71  effVersusDiscr_ni = discrCutEfficScan->histo_ni ();
72  effVersusDiscr_dusg = discrCutEfficScan->histo_dusg();
73  effVersusDiscr_pu = discrCutEfficScan->histo_pu();
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  effVersusDiscr_pu->SetXTitle ( "Discriminant" );
97  effVersusDiscr_pu->GetXaxis()->SetTitleOffset ( 0.75 );
98  }
99  else{
100  effVersusDiscr_d = 0;
101  effVersusDiscr_u = 0;
102  effVersusDiscr_s = 0;
103  effVersusDiscr_c = 0;
104  effVersusDiscr_b = 0;
105  effVersusDiscr_g = 0;
106  effVersusDiscr_ni = 0;
107  effVersusDiscr_dus = 0;
109  effVersusDiscr_pu = 0;
110  }
111 
112  // discr. for computation
113  vector<TH1F*> discrCfHistos = dDiscriminatorFC->getHistoVector();
114 
115  // discr no cut
116  vector<TH1F*> discrNoCutHistos = discrNoCutEffic->getHistoVector();
117 
118  // discr no cut
119  vector<TH1F*> discrCutHistos = discrCutEfficScan->getHistoVector();
120 
121  const int& dimHistos = discrCfHistos.size(); // they all have the same size
122 
123  // DISCR-CUT LOOP:
124  // fill the histos for eff-pur computations by scanning the discriminatorFC histogram
125 
126  // better to loop over bins -> discrCut no longer needed
127  const int& nBins = dDiscriminatorFC->nBins();
128 
129  // loop over flavours
130  for ( int iFlav = 0; iFlav < dimHistos; iFlav++ ) {
131  if (discrCfHistos[iFlav] == 0) continue;
132  discrNoCutHistos[iFlav]->SetXTitle ( "Discriminant" );
133  discrNoCutHistos[iFlav]->GetXaxis()->SetTitleOffset ( 0.75 );
134 
135  // In Root histos, bin counting starts at 1 to nBins.
136  // bin 0 is the underflow, and nBins+1 is the overflow.
137  const double& nJetsFlav = discrCfHistos[iFlav]->GetEntries ();
138  double sum = discrCfHistos[iFlav]->GetBinContent( nBins+1 ); //+1 to get the overflow.
139 
140  for ( int iDiscr = nBins; iDiscr > 0 ; --iDiscr ) {
141  // fill all jets into NoCut histo
142  discrNoCutHistos[iFlav]->SetBinContent ( iDiscr, nJetsFlav );
143  discrNoCutHistos[iFlav]->SetBinError ( iDiscr, sqrt(nJetsFlav) );
144  sum += discrCfHistos[iFlav]->GetBinContent( iDiscr );
145  discrCutHistos[iFlav]->SetBinContent ( iDiscr, sum );
146  discrCutHistos[iFlav]->SetBinError ( iDiscr, sqrt(sum) );
147  }
148  }
149 
150 
151  // divide to get efficiency vs. discriminator cut from absolute numbers
152  discrCutEfficScan->divide ( *discrNoCutEffic ); // does: histos including discriminator cut / flat histo
153 }
154 
155 
157  /* delete EffFlavVsBEff_d ;
158  delete EffFlavVsBEff_u ;
159  delete EffFlavVsBEff_s ;
160  delete EffFlavVsBEff_c ;
161  delete EffFlavVsBEff_b ;
162  delete EffFlavVsBEff_g ;
163  delete EffFlavVsBEff_ni ;
164  delete EffFlavVsBEff_dus ;
165  delete EffFlavVsBEff_dusg;
166  if ( fromDiscriminatorDistr) {
167  delete discrNoCutEffic;
168  delete discrCutEfficScan;
169  }*/
170 }
171 
172 
173 
174 
176 {
177  if ( fromDiscriminatorDistr) {
178  discrNoCutEffic->epsPlot(name);
179  discrCutEfficScan->epsPlot(name);
180  }
181  plot(name, ".eps");
182 }
183 
185 {
186  plot(name, ".ps");
187 }
188 
190 {
191  TCanvas tc (("FlavEffVsBEff" +histoExtension).c_str() ,
192  ("Flavour misidentification vs. b-tagging efficiency " + histoExtension).c_str());
193  plot(&tc);
194  tc.Print((name + "FlavEffVsBEff" + histoExtension + ext).c_str());
195 }
196 
197 void EffPurFromHistos::plot (TPad * plotCanvas /* = 0 */) {
198 
199 //fixme:
200  bool btppNI = false;
201  bool btppColour = true;
202 
203 // if ( !btppTitle ) gStyle->SetOptTitle ( 0 );
204  setTDRStyle()->cd();
205 
206  if (plotCanvas)
207  plotCanvas->cd();
208 
209  gPad->UseCurrentStyle();
210  gPad->SetFillColor ( 0 );
211  gPad->SetLogy ( 1 );
212  gPad->SetGridx ( 1 );
213  gPad->SetGridy ( 1 );
214 
215  int col_c ;
216  int col_g ;
217  int col_dus;
218  int col_ni ;
219 
220  int mStyle_c ;
221  int mStyle_g ;
222  int mStyle_dus;
223  int mStyle_ni ;
224 
225  // marker size (same for all)
226  float mSize = gPad->GetWh() * gPad->GetHNDC() / 500.; //1.2;
227 
228  if ( btppColour ) {
229  col_c = 6;
230  col_g = 3; // g in green
231  col_dus = 4; // uds in blue
232  col_ni = 5; // ni in ??
233  mStyle_c = 20;
234  mStyle_g = 20;
235  mStyle_dus = 20;
236  mStyle_ni = 20;
237  }
238  else {
239  col_c = 1;
240  col_g = 1;
241  col_dus = 1;
242  col_ni = 1;
243  mStyle_c = 22;
244  mStyle_g = 29;
245  mStyle_dus = 20;
246  mStyle_ni = 27;
247  }
248 
249 
250  // for the moment: plot c,dus,g
251  if(mcPlots_>2){
252  EffFlavVsBEff_dus ->getTH1F()->GetXaxis()->SetTitle ( "b-jet efficiency" );
253  EffFlavVsBEff_dus ->getTH1F()->GetYaxis()->SetTitle ( "non b-jet efficiency" );
254  EffFlavVsBEff_dus ->getTH1F()->GetYaxis()->SetTitleOffset ( 0.25 );
255  EffFlavVsBEff_dus ->getTH1F()->SetMaximum ( 1.1 );
256  EffFlavVsBEff_dus ->getTH1F()->SetMinimum ( 1.e-5 );
257  EffFlavVsBEff_dus ->getTH1F()->SetMarkerColor ( col_dus );
258  EffFlavVsBEff_dus ->getTH1F()->SetLineColor ( col_dus );
259  EffFlavVsBEff_dus ->getTH1F()->SetMarkerSize ( mSize );
260  EffFlavVsBEff_dus ->getTH1F()->SetMarkerStyle ( mStyle_dus );
261  EffFlavVsBEff_dus ->getTH1F()->SetStats ( false );
262  EffFlavVsBEff_dus ->getTH1F()->Draw("pe");
263 
264  EffFlavVsBEff_g ->getTH1F()->SetMarkerColor ( col_g );
265  EffFlavVsBEff_g ->getTH1F()->SetLineColor ( col_g );
266  EffFlavVsBEff_g ->getTH1F()->SetMarkerSize ( mSize );
267  EffFlavVsBEff_g ->getTH1F()->SetMarkerStyle ( mStyle_g );
268  EffFlavVsBEff_g ->getTH1F()->SetStats ( false );
269  EffFlavVsBEff_g ->getTH1F()->Draw("peSame");
270  }
271  EffFlavVsBEff_c ->getTH1F()->SetMarkerColor ( col_c );
272  EffFlavVsBEff_c ->getTH1F()->SetLineColor ( col_c );
273  EffFlavVsBEff_c ->getTH1F()->SetMarkerSize ( mSize );
274  EffFlavVsBEff_c ->getTH1F()->SetMarkerStyle ( mStyle_c );
275  EffFlavVsBEff_c ->getTH1F()->SetStats ( false );
276  EffFlavVsBEff_c ->getTH1F()->Draw("peSame");
277 
278  if(mcPlots_>2){
279  EffFlavVsBEff_d ->getTH1F()-> SetMinimum(0.01);
280  EffFlavVsBEff_u ->getTH1F()-> SetMinimum(0.01);
281  EffFlavVsBEff_s ->getTH1F()-> SetMinimum(0.01);
282  EffFlavVsBEff_g ->getTH1F()-> SetMinimum(0.01);
283  EffFlavVsBEff_dus ->getTH1F()-> SetMinimum(0.01);
284  }
285  EffFlavVsBEff_c ->getTH1F()-> SetMinimum(0.01);
286  EffFlavVsBEff_b ->getTH1F()-> SetMinimum(0.01);
287  EffFlavVsBEff_ni ->getTH1F()-> SetMinimum(0.01);
288  EffFlavVsBEff_dusg ->getTH1F()-> SetMinimum(0.01);
289  EffFlavVsBEff_pu ->getTH1F()-> SetMinimum(0.01);
290 
291  // plot separately u,d and s
292 // EffFlavVsBEff_d ->GetXaxis()->SetTitle ( "b-jet efficiency" );
293 // EffFlavVsBEff_d ->GetYaxis()->SetTitle ( "non b-jet efficiency" );
294 // EffFlavVsBEff_d ->GetYaxis()->SetTitleOffset ( 1.25 );
295 // EffFlavVsBEff_d ->SetMaximum ( 1.1 );
296 // EffFlavVsBEff_d ->SetMinimum ( 1.e-5 );
297 // EffFlavVsBEff_d ->SetMarkerColor ( col_dus );
298 // EffFlavVsBEff_d ->SetLineColor ( col_dus );
299 // EffFlavVsBEff_d ->SetMarkerSize ( mSize );
300 // EffFlavVsBEff_d ->SetMarkerStyle ( mStyle_dus );
301 // EffFlavVsBEff_d ->SetStats ( false );
302 // EffFlavVsBEff_d ->Draw("pe");
303 //
304 // EffFlavVsBEff_u ->SetMarkerColor ( col_g );
305 // EffFlavVsBEff_u ->SetLineColor ( col_g );
306 // EffFlavVsBEff_u ->SetMarkerSize ( mSize );
307 // EffFlavVsBEff_u ->SetMarkerStyle ( mStyle_g );
308 // EffFlavVsBEff_u ->SetStats ( false );
309 // EffFlavVsBEff_u ->Draw("peSame");
310 //
311 // EffFlavVsBEff_s ->SetMarkerColor ( col_c );
312 // EffFlavVsBEff_s ->SetLineColor ( col_c );
313 // EffFlavVsBEff_s ->SetMarkerSize ( mSize );
314 // EffFlavVsBEff_s ->SetMarkerStyle ( mStyle_c );
315 // EffFlavVsBEff_s ->SetStats ( false );
316 // EffFlavVsBEff_s ->Draw("peSame");
317 
318  // only if asked: NI
319  if ( btppNI ) {
320  EffFlavVsBEff_ni ->getTH1F()->SetMarkerColor ( col_ni );
321  EffFlavVsBEff_ni ->getTH1F()->SetLineColor ( col_ni );
322  EffFlavVsBEff_ni ->getTH1F()->SetMarkerSize ( mSize );
323  EffFlavVsBEff_ni ->getTH1F()->SetMarkerStyle ( mStyle_ni );
324  EffFlavVsBEff_ni ->getTH1F()->SetStats ( false );
325  EffFlavVsBEff_ni ->getTH1F()->Draw("peSame");
326  }
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  EffFlavVsBEff_d = 0;
456  EffFlavVsBEff_u = 0;
457  EffFlavVsBEff_s = 0;
458  EffFlavVsBEff_c = 0;
459  EffFlavVsBEff_b = 0;
460  EffFlavVsBEff_g = 0;
461  EffFlavVsBEff_ni = 0;
462  EffFlavVsBEff_dus = 0;
463  EffFlavVsBEff_dusg = 0;
464  EffFlavVsBEff_pu = 0;
465 
466  return;
467 
468  }
469 
470 
471  // to have shorter names ......
472  const std::string & hE = histoExtension;
473  const std::string & hB = "FlavEffVsBEff_";
474 
475 
476  // create histograms from base name and extension as given from user
477  // BINNING MUST BE IDENTICAL FOR ALL OF THEM!!
478  HistoProviderDQM prov("Btag",label_,ibook);
479  if(mcPlots_>2){
480  EffFlavVsBEff_d = (prov.book1D ( hB + "D" + hE , hB + "D" + hE , nBinOutput , startOutput , endOutput ));
481  EffFlavVsBEff_u = (prov.book1D ( hB + "U" + hE , hB + "U" + hE , nBinOutput , startOutput , endOutput )) ;
482  EffFlavVsBEff_s = (prov.book1D ( hB + "S" + hE , hB + "S" + hE , nBinOutput , startOutput , endOutput )) ;
483  EffFlavVsBEff_g = (prov.book1D ( hB + "G" + hE , hB + "G" + hE , nBinOutput , startOutput , endOutput )) ;
484  EffFlavVsBEff_dus = (prov.book1D ( hB + "DUS" + hE , hB + "DUS" + hE , nBinOutput , startOutput , endOutput )) ;
485  }
486  else {
487  EffFlavVsBEff_d = 0;
488  EffFlavVsBEff_u = 0;
489  EffFlavVsBEff_s = 0;
490  EffFlavVsBEff_g = 0;
491  EffFlavVsBEff_dus = 0;
492  }
493  EffFlavVsBEff_c = (prov.book1D ( hB + "C" + hE , hB + "C" + hE , nBinOutput , startOutput , endOutput )) ;
494  EffFlavVsBEff_b = (prov.book1D ( hB + "B" + hE , hB + "B" + hE , nBinOutput , startOutput , endOutput )) ;
495  EffFlavVsBEff_ni = (prov.book1D ( hB + "NI" + hE , hB + "NI" + hE , nBinOutput , startOutput , endOutput )) ;
496  EffFlavVsBEff_dusg = (prov.book1D ( hB + "DUSG" + hE , hB + "DUSG" + hE , nBinOutput , startOutput , endOutput )) ;
497  EffFlavVsBEff_pu = (prov.book1D ( hB + "PU" + hE , hB + "PU" + hE , nBinOutput , startOutput , endOutput )) ;
498 
499  if(mcPlots_>2){
500  EffFlavVsBEff_d->getTH1F()->SetXTitle ( "b-jet efficiency" );
501  EffFlavVsBEff_d->getTH1F()->SetYTitle ( "non b-jet efficiency" );
502  EffFlavVsBEff_d->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
503  EffFlavVsBEff_d->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
504  EffFlavVsBEff_u->getTH1F()->SetXTitle ( "b-jet efficiency" );
505  EffFlavVsBEff_u->getTH1F()->SetYTitle ( "non b-jet efficiency" );
506  EffFlavVsBEff_u->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
507  EffFlavVsBEff_u->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
508  EffFlavVsBEff_s->getTH1F()->SetXTitle ( "b-jet efficiency" );
509  EffFlavVsBEff_s->getTH1F()->SetYTitle ( "non b-jet efficiency" );
510  EffFlavVsBEff_s->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
511  EffFlavVsBEff_s->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
512  EffFlavVsBEff_g->getTH1F()->SetXTitle ( "b-jet efficiency" );
513  EffFlavVsBEff_g->getTH1F()->SetYTitle ( "non b-jet efficiency" );
514  EffFlavVsBEff_g->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
515  EffFlavVsBEff_g->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
516  EffFlavVsBEff_dus->getTH1F()->SetXTitle ( "b-jet efficiency" );
517  EffFlavVsBEff_dus->getTH1F()->SetYTitle ( "non b-jet efficiency" );
518  EffFlavVsBEff_dus->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
519  EffFlavVsBEff_dus->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
520  }
521  EffFlavVsBEff_c->getTH1F()->SetXTitle ( "b-jet efficiency" );
522  EffFlavVsBEff_c->getTH1F()->SetYTitle ( "non b-jet efficiency" );
523  EffFlavVsBEff_c->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
524  EffFlavVsBEff_c->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
525  EffFlavVsBEff_b->getTH1F()->SetXTitle ( "b-jet efficiency" );
526  EffFlavVsBEff_b->getTH1F()->SetYTitle ( "b-jet efficiency" );
527  EffFlavVsBEff_b->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
528  EffFlavVsBEff_b->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
529  EffFlavVsBEff_ni->getTH1F()->SetXTitle ( "b-jet efficiency" );
530  EffFlavVsBEff_ni->getTH1F()->SetYTitle ( "non b-jet efficiency" );
531  EffFlavVsBEff_ni->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
532  EffFlavVsBEff_ni->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
533  EffFlavVsBEff_dusg->getTH1F()->SetXTitle ( "b-jet efficiency" );
534  EffFlavVsBEff_dusg->getTH1F()->SetYTitle ( "non b-jet efficiency" );
535  EffFlavVsBEff_dusg->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
536  EffFlavVsBEff_dusg->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
537  EffFlavVsBEff_pu->getTH1F()->SetXTitle ( "b-jet efficiency" );
538  EffFlavVsBEff_pu->getTH1F()->SetYTitle ( "non b-jet efficiency" );
539  EffFlavVsBEff_pu->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
540  EffFlavVsBEff_pu->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
541 
542 
543  // loop over eff. vs. discriminator cut b-histo and look in which bin the closest entry is;
544  // use fact that eff decreases monotonously
545 
546  // any of the histos to be created can be taken here:
547  MonitorElement * EffFlavVsBEff = EffFlavVsBEff_b;
548 
549  const int& nBinB = EffFlavVsBEff->getTH1F()->GetNbinsX();
550 
551  for ( int iBinB = 1; iBinB <= nBinB; iBinB++ ) { // loop over the bins on the x-axis of the histograms to be filled
552 
553  const float& effBBinWidth = EffFlavVsBEff->getTH1F()->GetBinWidth ( iBinB );
554  const float& effBMid = EffFlavVsBEff->getTH1F()->GetBinCenter ( iBinB ); // middle of b-efficiency bin
555  const float& effBLeft = effBMid - 0.5*effBBinWidth; // left edge of bin
556  const float& effBRight = effBMid + 0.5*effBBinWidth; // right edge of bin
557  // find the corresponding bin in the efficiency versus discriminator cut histo: closest one in efficiency
558  const int& binClosest = findBinClosestYValue ( effVersusDiscr_b , effBMid , effBLeft , effBRight );
559  const bool& binFound = ( binClosest > 0 ) ;
560  //
561  if ( binFound ) {
562  // fill the histos
563  if(mcPlots_>2){
564  EffFlavVsBEff_d -> Fill ( effBMid , effVersusDiscr_d ->GetBinContent ( binClosest ) );
565  EffFlavVsBEff_u -> Fill ( effBMid , effVersusDiscr_u ->GetBinContent ( binClosest ) );
566  EffFlavVsBEff_s -> Fill ( effBMid , effVersusDiscr_s ->GetBinContent ( binClosest ) );
567  EffFlavVsBEff_g -> Fill ( effBMid , effVersusDiscr_g ->GetBinContent ( binClosest ) );
568  EffFlavVsBEff_dus -> Fill ( effBMid , effVersusDiscr_dus ->GetBinContent ( binClosest ) );
569  }
570  EffFlavVsBEff_c -> Fill ( effBMid , effVersusDiscr_c ->GetBinContent ( binClosest ) );
571  EffFlavVsBEff_b -> Fill ( effBMid , effVersusDiscr_b ->GetBinContent ( binClosest ) );
572  EffFlavVsBEff_ni -> Fill ( effBMid , effVersusDiscr_ni ->GetBinContent ( binClosest ) );
573  EffFlavVsBEff_dusg -> Fill ( effBMid , effVersusDiscr_dusg->GetBinContent ( binClosest ) );
574  EffFlavVsBEff_pu -> Fill ( effBMid , effVersusDiscr_pu ->GetBinContent ( binClosest ) );
575 
576  if(mcPlots_>2){
577  EffFlavVsBEff_d ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_d ->GetBinError ( binClosest ) );
578  EffFlavVsBEff_u ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_u ->GetBinError ( binClosest ) );
579  EffFlavVsBEff_s ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_s ->GetBinError ( binClosest ) );
580  EffFlavVsBEff_g ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_g ->GetBinError ( binClosest ) );
581  EffFlavVsBEff_dus->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_dus ->GetBinError ( binClosest ) );
582  }
583  EffFlavVsBEff_c ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_c ->GetBinError ( binClosest ) );
584  EffFlavVsBEff_b ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_b ->GetBinError ( binClosest ) );
585  EffFlavVsBEff_ni ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_ni ->GetBinError ( binClosest ) );
586  EffFlavVsBEff_dusg->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_dusg->GetBinError ( binClosest ) );
587  EffFlavVsBEff_pu ->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_pu ->GetBinError ( binClosest ) );
588  }
589  else {
590  //cout << "Did not find right bin for b-efficiency : " << effBMid << endl;
591  }
592 
593  }
594 
595 }
596 
597 
598 #include <typeinfo>
599 
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