CMS 3D CMS Logo

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