Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:15

0001 #include "DQMOffline/RecoB/interface/EffPurFromHistos.h"
0002 #include "DQMOffline/RecoB/interface/Tools.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include "TStyle.h"
0005 #include "TCanvas.h"
0006 
0007 #include <iostream>
0008 #include <cmath>
0009 
0010 #include "DQMServices/Core/interface/DQMStore.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 
0013 using namespace std;
0014 using namespace RecoBTag;
0015 
0016 EffPurFromHistos::EffPurFromHistos(const std::string& ext,
0017                                    TH1F* h_d,
0018                                    TH1F* h_u,
0019                                    TH1F* h_s,
0020                                    TH1F* h_c,
0021                                    TH1F* h_b,
0022                                    TH1F* h_g,
0023                                    TH1F* h_ni,
0024                                    TH1F* h_dus,
0025                                    TH1F* h_dusg,
0026                                    TH1F* h_pu,
0027                                    const std::string& label,
0028                                    unsigned int mc,
0029                                    int nBin,
0030                                    double startO,
0031                                    double endO)
0032     : fromDiscriminatorDistr(false),
0033       mcPlots_(mc),
0034       doCTagPlots_(false),
0035       label_(label),
0036       histoExtension(ext),
0037       effVersusDiscr_d(h_d),
0038       effVersusDiscr_u(h_u),
0039       effVersusDiscr_s(h_s),
0040       effVersusDiscr_c(h_c),
0041       effVersusDiscr_b(h_b),
0042       effVersusDiscr_g(h_g),
0043       effVersusDiscr_ni(h_ni),
0044       effVersusDiscr_dus(h_dus),
0045       effVersusDiscr_dusg(h_dusg),
0046       effVersusDiscr_pu(h_pu),
0047       nBinOutput(nBin),
0048       startOutput(startO),
0049       endOutput(endO) {
0050   // consistency check
0051   check();
0052 }
0053 
0054 EffPurFromHistos::EffPurFromHistos(const FlavourHistograms<double>& dDiscriminatorFC,
0055                                    const std::string& label,
0056                                    unsigned int mc,
0057                                    DQMStore::IBooker& ibook,
0058                                    int nBin,
0059                                    double startO,
0060                                    double endO)
0061     : fromDiscriminatorDistr(true),
0062       mcPlots_(mc),
0063       doCTagPlots_(false),
0064       label_(label),
0065       nBinOutput(nBin),
0066       startOutput(startO),
0067       endOutput(endO) {
0068   histoExtension = "_" + dDiscriminatorFC.baseNameTitle();
0069 
0070   discrNoCutEffic =
0071       std::make_unique<FlavourHistograms<double>>("totalEntries" + histoExtension,
0072                                                   "Total Entries: " + dDiscriminatorFC.baseNameDescription(),
0073                                                   dDiscriminatorFC.nBins(),
0074                                                   dDiscriminatorFC.lowerBound(),
0075                                                   dDiscriminatorFC.upperBound(),
0076                                                   false,
0077                                                   true,
0078                                                   false,
0079                                                   "b",
0080                                                   label,
0081                                                   mcPlots_,
0082                                                   ibook);
0083 
0084   // conditional discriminator cut for efficiency histos
0085 
0086   discrCutEfficScan =
0087       std::make_unique<FlavourHistograms<double>>("effVsDiscrCut" + histoExtension,
0088                                                   "Eff. vs Disc. Cut: " + dDiscriminatorFC.baseNameDescription(),
0089                                                   dDiscriminatorFC.nBins(),
0090                                                   dDiscriminatorFC.lowerBound(),
0091                                                   dDiscriminatorFC.upperBound(),
0092                                                   false,
0093                                                   true,
0094                                                   false,
0095                                                   "b",
0096                                                   label,
0097                                                   mcPlots_,
0098                                                   ibook);
0099   discrCutEfficScan->SetMinimum(1E-4);
0100   if (mcPlots_) {
0101     if (mcPlots_ > 2) {
0102       effVersusDiscr_d = discrCutEfficScan->histo_d();
0103       effVersusDiscr_u = discrCutEfficScan->histo_u();
0104       effVersusDiscr_s = discrCutEfficScan->histo_s();
0105       effVersusDiscr_g = discrCutEfficScan->histo_g();
0106       effVersusDiscr_dus = discrCutEfficScan->histo_dus();
0107     } else {
0108       effVersusDiscr_d = nullptr;
0109       effVersusDiscr_u = nullptr;
0110       effVersusDiscr_s = nullptr;
0111       effVersusDiscr_g = nullptr;
0112       effVersusDiscr_dus = nullptr;
0113     }
0114     effVersusDiscr_c = discrCutEfficScan->histo_c();
0115     effVersusDiscr_b = discrCutEfficScan->histo_b();
0116     effVersusDiscr_ni = discrCutEfficScan->histo_ni();
0117     effVersusDiscr_dusg = discrCutEfficScan->histo_dusg();
0118     effVersusDiscr_pu = discrCutEfficScan->histo_pu();
0119 
0120     if (mcPlots_ > 2) {
0121       effVersusDiscr_d->SetXTitle("Discriminant");
0122       effVersusDiscr_d->GetXaxis()->SetTitleOffset(0.75);
0123       effVersusDiscr_u->SetXTitle("Discriminant");
0124       effVersusDiscr_u->GetXaxis()->SetTitleOffset(0.75);
0125       effVersusDiscr_s->SetXTitle("Discriminant");
0126       effVersusDiscr_s->GetXaxis()->SetTitleOffset(0.75);
0127       effVersusDiscr_g->SetXTitle("Discriminant");
0128       effVersusDiscr_g->GetXaxis()->SetTitleOffset(0.75);
0129       effVersusDiscr_dus->SetXTitle("Discriminant");
0130       effVersusDiscr_dus->GetXaxis()->SetTitleOffset(0.75);
0131     }
0132     effVersusDiscr_c->SetXTitle("Discriminant");
0133     effVersusDiscr_c->GetXaxis()->SetTitleOffset(0.75);
0134     effVersusDiscr_b->SetXTitle("Discriminant");
0135     effVersusDiscr_b->GetXaxis()->SetTitleOffset(0.75);
0136     effVersusDiscr_ni->SetXTitle("Discriminant");
0137     effVersusDiscr_ni->GetXaxis()->SetTitleOffset(0.75);
0138     effVersusDiscr_dusg->SetXTitle("Discriminant");
0139     effVersusDiscr_dusg->GetXaxis()->SetTitleOffset(0.75);
0140     effVersusDiscr_pu->SetXTitle("Discriminant");
0141     effVersusDiscr_pu->GetXaxis()->SetTitleOffset(0.75);
0142   } else {
0143     effVersusDiscr_d = nullptr;
0144     effVersusDiscr_u = nullptr;
0145     effVersusDiscr_s = nullptr;
0146     effVersusDiscr_c = nullptr;
0147     effVersusDiscr_b = nullptr;
0148     effVersusDiscr_g = nullptr;
0149     effVersusDiscr_ni = nullptr;
0150     effVersusDiscr_dus = nullptr;
0151     effVersusDiscr_dusg = nullptr;
0152     effVersusDiscr_pu = nullptr;
0153   }
0154 
0155   // discr. for computation
0156   vector<TH1F*> discrCfHistos = dDiscriminatorFC.getHistoVector();
0157 
0158   // discr no cut
0159   vector<TH1F*> discrNoCutHistos = discrNoCutEffic->getHistoVector();
0160 
0161   // discr no cut
0162   vector<TH1F*> discrCutHistos = discrCutEfficScan->getHistoVector();
0163 
0164   const int& dimHistos = discrCfHistos.size();  // they all have the same size
0165 
0166   // DISCR-CUT LOOP:
0167   // fill the histos for eff-pur computations by scanning the discriminatorFC histogram
0168 
0169   // better to loop over bins -> discrCut no longer needed
0170   const int& nBins = dDiscriminatorFC.nBins();
0171 
0172   // loop over flavours
0173   for (int iFlav = 0; iFlav < dimHistos; iFlav++) {
0174     if (discrCfHistos[iFlav] == nullptr)
0175       continue;
0176     discrNoCutHistos[iFlav]->SetXTitle("Discriminant");
0177     discrNoCutHistos[iFlav]->GetXaxis()->SetTitleOffset(0.75);
0178 
0179     // In Root histos, bin counting starts at 1 to nBins.
0180     // bin 0 is the underflow, and nBins+1 is the overflow.
0181     const double& nJetsFlav = discrCfHistos[iFlav]->GetEntries();
0182     double sum = discrCfHistos[iFlav]->GetBinContent(nBins + 1);  //+1 to get the overflow.
0183 
0184     for (int iDiscr = nBins; iDiscr > 0; --iDiscr) {
0185       // fill all jets into NoCut histo
0186       discrNoCutHistos[iFlav]->SetBinContent(iDiscr, nJetsFlav);
0187       discrNoCutHistos[iFlav]->SetBinError(iDiscr, sqrt(nJetsFlav));
0188       sum += discrCfHistos[iFlav]->GetBinContent(iDiscr);
0189       discrCutHistos[iFlav]->SetBinContent(iDiscr, sum);
0190       discrCutHistos[iFlav]->SetBinError(iDiscr, sqrt(sum));
0191     }
0192   }
0193 
0194   // divide to get efficiency vs. discriminator cut from absolute numbers
0195   discrCutEfficScan->divide(*discrNoCutEffic);  // does: histos including discriminator cut / flat histo
0196   discrCutEfficScan->setEfficiencyFlag();
0197 }
0198 
0199 EffPurFromHistos::~EffPurFromHistos() {}
0200 
0201 void EffPurFromHistos::epsPlot(const std::string& name) {
0202   if (fromDiscriminatorDistr) {
0203     discrNoCutEffic->epsPlot(name);
0204     discrCutEfficScan->epsPlot(name);
0205   }
0206   plot(name, ".eps");
0207 }
0208 
0209 void EffPurFromHistos::psPlot(const std::string& name) { plot(name, ".ps"); }
0210 
0211 void EffPurFromHistos::plot(const std::string& name, const std::string& ext) {
0212   std::string hX = "";
0213   std::string Title = "";
0214   if (!doCTagPlots_) {
0215     hX = "FlavEffVsBEff";
0216     Title = "b";
0217   } else {
0218     hX = "FlavEffVsCEff";
0219     Title = "c";
0220   }
0221   TCanvas tc((hX + histoExtension).c_str(),
0222              ("Flavour misidentification vs. " + Title + "-tagging efficiency " + histoExtension).c_str());
0223   plot(&tc);
0224   tc.Print((name + hX + histoExtension + ext).c_str());
0225 }
0226 
0227 void EffPurFromHistos::plot(TPad* plotCanvas /* = 0 */) {
0228   //fixme:
0229   bool btppNI = false;
0230   bool btppColour = true;
0231 
0232   //   if ( !btppTitle ) gStyle->SetOptTitle( 0 );
0233   setTDRStyle()->cd();
0234 
0235   if (plotCanvas)
0236     plotCanvas->cd();
0237 
0238   gPad->UseCurrentStyle();
0239   gPad->SetFillColor(0);
0240   gPad->SetLogy(1);
0241   gPad->SetGridx(1);
0242   gPad->SetGridy(1);
0243 
0244   int col_c;
0245   int col_g;
0246   int col_dus;
0247   int col_ni;
0248 
0249   int mStyle_c;
0250   int mStyle_g;
0251   int mStyle_dus;
0252   int mStyle_ni;
0253 
0254   // marker size(same for all)
0255   float mSize = gPad->GetWh() * gPad->GetHNDC() / 500.;  //1.2;
0256 
0257   if (btppColour) {
0258     col_c = 6;
0259     col_g = 3;    // g in green
0260     col_dus = 4;  // uds in blue
0261     col_ni = 5;   // ni in ??
0262     mStyle_c = 20;
0263     mStyle_g = 20;
0264     mStyle_dus = 20;
0265     mStyle_ni = 20;
0266   } else {
0267     col_c = 1;
0268     col_g = 1;
0269     col_dus = 1;
0270     col_ni = 1;
0271     mStyle_c = 22;
0272     mStyle_g = 29;
0273     mStyle_dus = 20;
0274     mStyle_ni = 27;
0275   }
0276 
0277   TString Title = "";
0278   if (!doCTagPlots_) {
0279     Title = "b";
0280   } else {
0281     Title = "c";
0282   }
0283 
0284   // for the moment: plot c,dus,g
0285   if (mcPlots_ > 2) {
0286     EffFlavVsXEff_dus->getTH1F()->GetXaxis()->SetTitle(Title + "-jet efficiency");
0287     EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitle("non " + Title + "-jet efficiency");
0288     EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitleOffset(0.25);
0289     EffFlavVsXEff_dus->getTH1F()->SetMaximum(1.1);
0290     EffFlavVsXEff_dus->getTH1F()->SetMinimum(1.e-5);
0291     EffFlavVsXEff_dus->getTH1F()->SetMarkerColor(col_dus);
0292     EffFlavVsXEff_dus->getTH1F()->SetLineColor(col_dus);
0293     EffFlavVsXEff_dus->getTH1F()->SetMarkerSize(mSize);
0294     EffFlavVsXEff_dus->getTH1F()->SetMarkerStyle(mStyle_dus);
0295     EffFlavVsXEff_dus->getTH1F()->SetStats(false);
0296     EffFlavVsXEff_dus->getTH1F()->Draw("pe");
0297 
0298     EffFlavVsXEff_g->getTH1F()->SetMarkerColor(col_g);
0299     EffFlavVsXEff_g->getTH1F()->SetLineColor(col_g);
0300     EffFlavVsXEff_g->getTH1F()->SetMarkerSize(mSize);
0301     EffFlavVsXEff_g->getTH1F()->SetMarkerStyle(mStyle_g);
0302     EffFlavVsXEff_g->getTH1F()->SetStats(false);
0303     EffFlavVsXEff_g->getTH1F()->Draw("peSame");
0304   }
0305   EffFlavVsXEff_c->getTH1F()->SetMarkerColor(col_c);
0306   EffFlavVsXEff_c->getTH1F()->SetLineColor(col_c);
0307   EffFlavVsXEff_c->getTH1F()->SetMarkerSize(mSize);
0308   EffFlavVsXEff_c->getTH1F()->SetMarkerStyle(mStyle_c);
0309   EffFlavVsXEff_c->getTH1F()->SetStats(false);
0310   EffFlavVsXEff_c->getTH1F()->Draw("peSame");
0311 
0312   if (mcPlots_ > 2) {
0313     EffFlavVsXEff_d->getTH1F()->SetMinimum(0.01);
0314     EffFlavVsXEff_u->getTH1F()->SetMinimum(0.01);
0315     EffFlavVsXEff_s->getTH1F()->SetMinimum(0.01);
0316     EffFlavVsXEff_g->getTH1F()->SetMinimum(0.01);
0317     EffFlavVsXEff_dus->getTH1F()->SetMinimum(0.01);
0318   }
0319   EffFlavVsXEff_c->getTH1F()->SetMinimum(0.01);
0320   EffFlavVsXEff_b->getTH1F()->SetMinimum(0.01);
0321   EffFlavVsXEff_ni->getTH1F()->SetMinimum(0.01);
0322   EffFlavVsXEff_dusg->getTH1F()->SetMinimum(0.01);
0323   EffFlavVsXEff_pu->getTH1F()->SetMinimum(0.01);
0324 
0325   // plot separately u,d and s
0326   //  EffFlavVsXEff_d ->GetXaxis()->SetTitle( Title + "-jet efficiency" );
0327   //  EffFlavVsXEff_d ->GetYaxis()->SetTitle( "non " + Title + "-jet efficiency" );
0328   //  EffFlavVsXEff_d ->GetYaxis()->SetTitleOffset( 1.25 );
0329   //  EffFlavVsXEff_d ->SetMaximum    ( 1.1 );
0330   //  EffFlavVsXEff_d ->SetMinimum    ( 1.e-5 );
0331   //  EffFlavVsXEff_d ->SetMarkerColor( col_dus );
0332   //  EffFlavVsXEff_d ->SetLineColor  ( col_dus );
0333   //  EffFlavVsXEff_d ->SetMarkerSize ( mSize );
0334   //  EffFlavVsXEff_d ->SetMarkerStyle( mStyle_dus );
0335   //  EffFlavVsXEff_d ->SetStats    ( false );
0336   //  EffFlavVsXEff_d ->Draw("pe");
0337   //
0338   //  EffFlavVsXEff_u   ->SetMarkerColor( col_g );
0339   //  EffFlavVsXEff_u   ->SetLineColor  ( col_g );
0340   //  EffFlavVsXEff_u   ->SetMarkerSize ( mSize );
0341   //  EffFlavVsXEff_u   ->SetMarkerStyle( mStyle_g );
0342   //  EffFlavVsXEff_u   ->SetStats    ( false );
0343   //  EffFlavVsXEff_u   ->Draw("peSame");
0344   //
0345   //  EffFlavVsXEff_s   ->SetMarkerColor( col_c );
0346   //  EffFlavVsXEff_s   ->SetLineColor  ( col_c );
0347   //  EffFlavVsXEff_s   ->SetMarkerSize ( mSize );
0348   //  EffFlavVsXEff_s   ->SetMarkerStyle( mStyle_c );
0349   //  EffFlavVsXEff_s   ->SetStats    ( false );
0350   //  EffFlavVsXEff_s   ->Draw("peSame");
0351 
0352   // only if asked: NI
0353   if (btppNI) {
0354     EffFlavVsXEff_ni->getTH1F()->SetMarkerColor(col_ni);
0355     EffFlavVsXEff_ni->getTH1F()->SetLineColor(col_ni);
0356     EffFlavVsXEff_ni->getTH1F()->SetMarkerSize(mSize);
0357     EffFlavVsXEff_ni->getTH1F()->SetMarkerStyle(mStyle_ni);
0358     EffFlavVsXEff_ni->getTH1F()->SetStats(false);
0359     EffFlavVsXEff_ni->getTH1F()->Draw("peSame");
0360   }
0361 }
0362 
0363 void EffPurFromHistos::check() {
0364   // number of bins
0365 
0366   int nBins_d = 0;
0367   int nBins_u = 0;
0368   int nBins_s = 0;
0369   int nBins_g = 0;
0370   int nBins_dus = 0;
0371   if (mcPlots_ > 2) {
0372     nBins_d = effVersusDiscr_d->GetNbinsX();
0373     nBins_u = effVersusDiscr_u->GetNbinsX();
0374     nBins_s = effVersusDiscr_s->GetNbinsX();
0375     nBins_g = effVersusDiscr_g->GetNbinsX();
0376     nBins_dus = effVersusDiscr_dus->GetNbinsX();
0377   }
0378   const int& nBins_c = effVersusDiscr_c->GetNbinsX();
0379   const int& nBins_b = effVersusDiscr_b->GetNbinsX();
0380   const int& nBins_ni = effVersusDiscr_ni->GetNbinsX();
0381   const int& nBins_dusg = effVersusDiscr_dusg->GetNbinsX();
0382   const int& nBins_pu = effVersusDiscr_pu->GetNbinsX();
0383 
0384   const bool& lNBins = ((nBins_d == nBins_u && nBins_d == nBins_s && nBins_d == nBins_c && nBins_d == nBins_b &&
0385                          nBins_d == nBins_g && nBins_d == nBins_ni && nBins_d == nBins_dus && nBins_d == nBins_dusg) ||
0386                         (nBins_c == nBins_b && nBins_c == nBins_dusg && nBins_c == nBins_ni && nBins_c == nBins_pu));
0387 
0388   if (!lNBins) {
0389     throw cms::Exception("Configuration") << "Input histograms do not all have the same number of bins!\n";
0390   }
0391 
0392   // start
0393   float sBin_d = 0;
0394   float sBin_u = 0;
0395   float sBin_s = 0;
0396   float sBin_g = 0;
0397   float sBin_dus = 0;
0398   if (mcPlots_ > 2) {
0399     sBin_d = effVersusDiscr_d->GetBinCenter(1);
0400     sBin_u = effVersusDiscr_u->GetBinCenter(1);
0401     sBin_s = effVersusDiscr_s->GetBinCenter(1);
0402     sBin_g = effVersusDiscr_g->GetBinCenter(1);
0403     sBin_dus = effVersusDiscr_dus->GetBinCenter(1);
0404   }
0405   const float& sBin_c = effVersusDiscr_c->GetBinCenter(1);
0406   const float& sBin_b = effVersusDiscr_b->GetBinCenter(1);
0407   const float& sBin_ni = effVersusDiscr_ni->GetBinCenter(1);
0408   const float& sBin_dusg = effVersusDiscr_dusg->GetBinCenter(1);
0409   const float& sBin_pu = effVersusDiscr_pu->GetBinCenter(1);
0410 
0411   const bool& lSBin = ((sBin_d == sBin_u && sBin_d == sBin_s && sBin_d == sBin_c && sBin_d == sBin_b &&
0412                         sBin_d == sBin_g && sBin_d == sBin_ni && sBin_d == sBin_dus && sBin_d == sBin_dusg) ||
0413                        (sBin_c == sBin_b && sBin_c == sBin_dusg && sBin_c == sBin_ni && sBin_c == sBin_pu));
0414 
0415   if (!lSBin) {
0416     throw cms::Exception("Configuration")
0417         << "EffPurFromHistos::check() : Input histograms do not all have the same start bin!\n";
0418   }
0419 
0420   // end
0421   float eBin_d = 0;
0422   float eBin_u = 0;
0423   float eBin_s = 0;
0424   float eBin_g = 0;
0425   float eBin_dus = 0;
0426   if (mcPlots_ > 2) {
0427     eBin_d = effVersusDiscr_d->GetBinCenter(nBins_d - 1);
0428     eBin_u = effVersusDiscr_u->GetBinCenter(nBins_d - 1);
0429     eBin_s = effVersusDiscr_s->GetBinCenter(nBins_d - 1);
0430     eBin_g = effVersusDiscr_g->GetBinCenter(nBins_d - 1);
0431     eBin_dus = effVersusDiscr_dus->GetBinCenter(nBins_d - 1);
0432   }
0433   const float& eBin_c = effVersusDiscr_c->GetBinCenter(nBins_d - 1);
0434   const float& eBin_b = effVersusDiscr_b->GetBinCenter(nBins_d - 1);
0435   const float& eBin_ni = effVersusDiscr_ni->GetBinCenter(nBins_d - 1);
0436   const float& eBin_dusg = effVersusDiscr_dusg->GetBinCenter(nBins_d - 1);
0437   const float& eBin_pu = effVersusDiscr_pu->GetBinCenter(nBins_d - 1);
0438 
0439   const bool& lEBin = ((eBin_d == eBin_u && eBin_d == eBin_s && eBin_d == eBin_c && eBin_d == eBin_b &&
0440                         eBin_d == eBin_g && eBin_d == eBin_ni && eBin_d == eBin_dus && eBin_d == eBin_dusg) ||
0441                        (eBin_c == eBin_b && eBin_c == eBin_dusg && eBin_c == eBin_ni && eBin_c == eBin_pu));
0442 
0443   if (!lEBin) {
0444     throw cms::Exception("Configuration")
0445         << "EffPurFromHistos::check() : Input histograms do not all have the same end bin!\n";
0446   }
0447 }
0448 
0449 void EffPurFromHistos::compute(DQMStore::IBooker& ibook) {
0450   if (!mcPlots_) {
0451     EffFlavVsXEff_d = nullptr;
0452     EffFlavVsXEff_u = nullptr;
0453     EffFlavVsXEff_s = nullptr;
0454     EffFlavVsXEff_c = nullptr;
0455     EffFlavVsXEff_b = nullptr;
0456     EffFlavVsXEff_g = nullptr;
0457     EffFlavVsXEff_ni = nullptr;
0458     EffFlavVsXEff_dus = nullptr;
0459     EffFlavVsXEff_dusg = nullptr;
0460     EffFlavVsXEff_pu = nullptr;
0461     return;
0462   }
0463 
0464   // to have shorter names ......
0465   const std::string& hE = histoExtension;
0466   std::string hX = "";
0467   TString Title = "";
0468   if (!doCTagPlots_) {
0469     hX = "FlavEffVsBEff_";
0470     Title = "b";
0471   } else {
0472     hX = "FlavEffVsCEff_";
0473     Title = "c";
0474   }
0475 
0476   // create histograms from base name and extension as given from user
0477   // BINNING MUST BE IDENTICAL FOR ALL OF THEM!!
0478   HistoProviderDQM prov("Btag", label_, ibook);
0479   if (mcPlots_ > 2) {
0480     EffFlavVsXEff_d = (prov.book1D(hX + "D" + hE, hX + "D" + hE, nBinOutput, startOutput, endOutput));
0481     EffFlavVsXEff_d->setEfficiencyFlag();
0482     EffFlavVsXEff_u = (prov.book1D(hX + "U" + hE, hX + "U" + hE, nBinOutput, startOutput, endOutput));
0483     EffFlavVsXEff_u->setEfficiencyFlag();
0484     EffFlavVsXEff_s = (prov.book1D(hX + "S" + hE, hX + "S" + hE, nBinOutput, startOutput, endOutput));
0485     EffFlavVsXEff_s->setEfficiencyFlag();
0486     EffFlavVsXEff_g = (prov.book1D(hX + "G" + hE, hX + "G" + hE, nBinOutput, startOutput, endOutput));
0487     EffFlavVsXEff_g->setEfficiencyFlag();
0488     EffFlavVsXEff_dus = (prov.book1D(hX + "DUS" + hE, hX + "DUS" + hE, nBinOutput, startOutput, endOutput));
0489     EffFlavVsXEff_dus->setEfficiencyFlag();
0490   } else {
0491     EffFlavVsXEff_d = nullptr;
0492     EffFlavVsXEff_u = nullptr;
0493     EffFlavVsXEff_s = nullptr;
0494     EffFlavVsXEff_g = nullptr;
0495     EffFlavVsXEff_dus = nullptr;
0496   }
0497   EffFlavVsXEff_c = (prov.book1D(hX + "C" + hE, hX + "C" + hE, nBinOutput, startOutput, endOutput));
0498   EffFlavVsXEff_c->setEfficiencyFlag();
0499   EffFlavVsXEff_b = (prov.book1D(hX + "B" + hE, hX + "B" + hE, nBinOutput, startOutput, endOutput));
0500   EffFlavVsXEff_b->setEfficiencyFlag();
0501   EffFlavVsXEff_ni = (prov.book1D(hX + "NI" + hE, hX + "NI" + hE, nBinOutput, startOutput, endOutput));
0502   EffFlavVsXEff_ni->setEfficiencyFlag();
0503   EffFlavVsXEff_dusg = (prov.book1D(hX + "DUSG" + hE, hX + "DUSG" + hE, nBinOutput, startOutput, endOutput));
0504   EffFlavVsXEff_dusg->setEfficiencyFlag();
0505   EffFlavVsXEff_pu = (prov.book1D(hX + "PU" + hE, hX + "PU" + hE, nBinOutput, startOutput, endOutput));
0506   EffFlavVsXEff_pu->setEfficiencyFlag();
0507 
0508   if (mcPlots_ > 2) {
0509     EffFlavVsXEff_d->getTH1F()->SetXTitle(Title + "-jet efficiency");
0510     EffFlavVsXEff_d->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0511     EffFlavVsXEff_d->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0512     EffFlavVsXEff_d->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0513     EffFlavVsXEff_u->getTH1F()->SetXTitle(Title + "-jet efficiency");
0514     EffFlavVsXEff_u->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0515     EffFlavVsXEff_u->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0516     EffFlavVsXEff_u->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0517     EffFlavVsXEff_s->getTH1F()->SetXTitle(Title + "-jet efficiency");
0518     EffFlavVsXEff_s->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0519     EffFlavVsXEff_s->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0520     EffFlavVsXEff_s->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0521     EffFlavVsXEff_g->getTH1F()->SetXTitle(Title + "-jet efficiency");
0522     EffFlavVsXEff_g->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0523     EffFlavVsXEff_g->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0524     EffFlavVsXEff_g->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0525     EffFlavVsXEff_dus->getTH1F()->SetXTitle(Title + "-jet efficiency");
0526     EffFlavVsXEff_dus->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0527     EffFlavVsXEff_dus->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0528     EffFlavVsXEff_dus->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0529   }
0530   EffFlavVsXEff_c->getTH1F()->SetXTitle(Title + "-jet efficiency");
0531   EffFlavVsXEff_c->getTH1F()->SetYTitle("c-jet efficiency");
0532   EffFlavVsXEff_c->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0533   EffFlavVsXEff_c->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0534   EffFlavVsXEff_b->getTH1F()->SetXTitle(Title + "-jet efficiency");
0535   EffFlavVsXEff_b->getTH1F()->SetYTitle("b-jet efficiency");
0536   EffFlavVsXEff_b->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0537   EffFlavVsXEff_b->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0538   EffFlavVsXEff_ni->getTH1F()->SetXTitle(Title + "-jet efficiency");
0539   EffFlavVsXEff_ni->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0540   EffFlavVsXEff_ni->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0541   EffFlavVsXEff_ni->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0542   EffFlavVsXEff_dusg->getTH1F()->SetXTitle(Title + "-jet efficiency");
0543   EffFlavVsXEff_dusg->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0544   EffFlavVsXEff_dusg->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0545   EffFlavVsXEff_dusg->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0546   EffFlavVsXEff_pu->getTH1F()->SetXTitle(Title + "-jet efficiency");
0547   EffFlavVsXEff_pu->getTH1F()->SetYTitle("non " + Title + "-jet efficiency");
0548   EffFlavVsXEff_pu->getTH1F()->GetXaxis()->SetTitleOffset(0.75);
0549   EffFlavVsXEff_pu->getTH1F()->GetYaxis()->SetTitleOffset(0.75);
0550 
0551   // loop over eff. vs. discriminator cut b-histo and look in which bin the closest entry is;
0552   // use fact that eff decreases monotonously
0553 
0554   // any of the histos to be created can be taken here:
0555   MonitorElement* EffFlavVsXEff = EffFlavVsXEff_b;
0556 
0557   const int& nBinX = EffFlavVsXEff->getTH1F()->GetNbinsX();
0558 
0559   for (int iBinX = 1; iBinX <= nBinX; iBinX++) {  // loop over the bins on the x-axis of the histograms to be filled
0560 
0561     const float& effXBinWidth = EffFlavVsXEff->getTH1F()->GetBinWidth(iBinX);
0562     const float& effXMid = EffFlavVsXEff->getTH1F()->GetBinCenter(iBinX);  // middle of b-efficiency bin
0563     const float& effXLeft = effXMid - 0.5 * effXBinWidth;                  // left edge of bin
0564     const float& effXRight = effXMid + 0.5 * effXBinWidth;                 // right edge of bin
0565     // find the corresponding bin in the efficiency versus discriminator cut histo: closest one in efficiency
0566 
0567     int binClosest = -1;
0568     if (!doCTagPlots_) {
0569       binClosest = findBinClosestYValue(effVersusDiscr_b, effXMid, effXLeft, effXRight);
0570     } else {
0571       binClosest = findBinClosestYValue(effVersusDiscr_c, effXMid, effXLeft, effXRight);
0572     }
0573 
0574     const bool& binFound = (binClosest > 0);
0575     //
0576     if (binFound) {
0577       // fill the histos
0578       if (mcPlots_ > 2) {
0579         EffFlavVsXEff_d->Fill(effXMid, effVersusDiscr_d->GetBinContent(binClosest));
0580         EffFlavVsXEff_u->Fill(effXMid, effVersusDiscr_u->GetBinContent(binClosest));
0581         EffFlavVsXEff_s->Fill(effXMid, effVersusDiscr_s->GetBinContent(binClosest));
0582         EffFlavVsXEff_g->Fill(effXMid, effVersusDiscr_g->GetBinContent(binClosest));
0583         EffFlavVsXEff_dus->Fill(effXMid, effVersusDiscr_dus->GetBinContent(binClosest));
0584       }
0585       EffFlavVsXEff_c->Fill(effXMid, effVersusDiscr_c->GetBinContent(binClosest));
0586       EffFlavVsXEff_b->Fill(effXMid, effVersusDiscr_b->GetBinContent(binClosest));
0587       EffFlavVsXEff_ni->Fill(effXMid, effVersusDiscr_ni->GetBinContent(binClosest));
0588       EffFlavVsXEff_dusg->Fill(effXMid, effVersusDiscr_dusg->GetBinContent(binClosest));
0589       EffFlavVsXEff_pu->Fill(effXMid, effVersusDiscr_pu->GetBinContent(binClosest));
0590 
0591       if (mcPlots_ > 2) {
0592         EffFlavVsXEff_d->getTH1F()->SetBinError(iBinX, effVersusDiscr_d->GetBinError(binClosest));
0593         EffFlavVsXEff_u->getTH1F()->SetBinError(iBinX, effVersusDiscr_u->GetBinError(binClosest));
0594         EffFlavVsXEff_s->getTH1F()->SetBinError(iBinX, effVersusDiscr_s->GetBinError(binClosest));
0595         EffFlavVsXEff_g->getTH1F()->SetBinError(iBinX, effVersusDiscr_g->GetBinError(binClosest));
0596         EffFlavVsXEff_dus->getTH1F()->SetBinError(iBinX, effVersusDiscr_dus->GetBinError(binClosest));
0597       }
0598       EffFlavVsXEff_c->getTH1F()->SetBinError(iBinX, effVersusDiscr_c->GetBinError(binClosest));
0599       EffFlavVsXEff_b->getTH1F()->SetBinError(iBinX, effVersusDiscr_b->GetBinError(binClosest));
0600       EffFlavVsXEff_ni->getTH1F()->SetBinError(iBinX, effVersusDiscr_ni->GetBinError(binClosest));
0601       EffFlavVsXEff_dusg->getTH1F()->SetBinError(iBinX, effVersusDiscr_dusg->GetBinError(binClosest));
0602       EffFlavVsXEff_pu->getTH1F()->SetBinError(iBinX, effVersusDiscr_pu->GetBinError(binClosest));
0603     }
0604   }
0605 }
0606 
0607 #include <memory>
0608 
0609 #include <typeinfo>