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