CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DQMOffline/RecoB/src/EffPurFromHistos.cc

Go to the documentation of this file.
00001 #include "DQMOffline/RecoB/interface/EffPurFromHistos.h"
00002 #include "DQMOffline/RecoB/interface/Tools.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 #include "TStyle.h"
00005 #include "TCanvas.h"
00006 
00007 #include <iostream>
00008 #include <math.h>
00009 
00010 #include "DQMServices/Core/interface/DQMStore.h"
00011 #include "DQMServices/Core/interface/MonitorElement.h"
00012 #include "FWCore/ServiceRegistry/interface/Service.h" 
00013 
00014 
00015 using namespace std;
00016 using namespace RecoBTag;
00017 
00018 
00019 
00020 EffPurFromHistos::EffPurFromHistos ( const std::string & ext, TH1F * h_d, TH1F * h_u,
00021         TH1F * h_s, TH1F * h_c, TH1F * h_b, TH1F * h_g, TH1F * h_ni,
00022         TH1F * h_dus, TH1F * h_dusg, const std::string& label, const unsigned int& mc, int nBin, double startO, double endO) :
00023         //BTagPlotPrintC(),
00024         fromDiscriminatorDistr(false),
00025         histoExtension(ext), effVersusDiscr_d(h_d), effVersusDiscr_u(h_u),
00026         effVersusDiscr_s(h_s), effVersusDiscr_c(h_c), effVersusDiscr_b(h_b),
00027         effVersusDiscr_g(h_g), effVersusDiscr_ni(h_ni), effVersusDiscr_dus(h_dus),
00028         effVersusDiscr_dusg(h_dusg), nBinOutput(nBin), startOutput(startO),
00029         endOutput(endO),  mcPlots_(mc), label_(label)
00030 {
00031   // consistency check
00032   check();
00033 }
00034 
00035 EffPurFromHistos::EffPurFromHistos 
00036         (const FlavourHistograms<double> * dDiscriminatorFC, const std::string& label, const unsigned int& mc, int nBin,
00037         double startO, double endO) :
00038           fromDiscriminatorDistr(true), nBinOutput(nBin), startOutput(startO), endOutput(endO),  mcPlots_(mc), label_(label){
00039   histoExtension = "_"+dDiscriminatorFC->baseNameTitle();
00040 
00041 
00042   discrNoCutEffic = new FlavourHistograms<double> (
00043         "totalEntries" + histoExtension, "Total Entries: " + dDiscriminatorFC->baseNameDescription(),
00044         dDiscriminatorFC->nBins(), dDiscriminatorFC->lowerBound(),
00045         dDiscriminatorFC->upperBound(), false, true, false, "b", false, label, mcPlots_ );
00046 
00047   // conditional discriminator cut for efficiency histos
00048 
00049   discrCutEfficScan = new FlavourHistograms<double> (
00050         "effVsDiscrCut" + histoExtension, "Eff. vs Disc. Cut: " + dDiscriminatorFC->baseNameDescription(),
00051         dDiscriminatorFC->nBins(), dDiscriminatorFC->lowerBound(),
00052         dDiscriminatorFC->upperBound(), false, true, false, "b", false, label , mcPlots_ );
00053   discrCutEfficScan->SetMinimum(1E-4);
00054   if (mcPlots_){ 
00055 
00056     if(mcPlots_>2){
00057       effVersusDiscr_d =    discrCutEfficScan->histo_d   ();
00058       effVersusDiscr_u =    discrCutEfficScan->histo_u   ();
00059       effVersusDiscr_s =    discrCutEfficScan->histo_s   ();
00060       effVersusDiscr_g =    discrCutEfficScan->histo_g   ();
00061       effVersusDiscr_dus =  discrCutEfficScan->histo_dus ();
00062     }
00063     else{
00064       effVersusDiscr_d   =  0;
00065       effVersusDiscr_u   =  0; 
00066       effVersusDiscr_s   =  0;
00067       effVersusDiscr_g   =  0;
00068       effVersusDiscr_dus =  0;
00069     }
00070     effVersusDiscr_c =    discrCutEfficScan->histo_c   ();
00071     effVersusDiscr_b =    discrCutEfficScan->histo_b   ();
00072     effVersusDiscr_ni =   discrCutEfficScan->histo_ni  ();
00073     effVersusDiscr_dusg = discrCutEfficScan->histo_dusg();
00074 
00075   
00076     if(mcPlots_>2){
00077       effVersusDiscr_d->SetXTitle ( "Discriminant" );
00078       effVersusDiscr_d->GetXaxis()->SetTitleOffset ( 0.75 );
00079       effVersusDiscr_u->SetXTitle ( "Discriminant" );
00080       effVersusDiscr_u->GetXaxis()->SetTitleOffset ( 0.75 );
00081       effVersusDiscr_s->SetXTitle ( "Discriminant" );
00082       effVersusDiscr_s->GetXaxis()->SetTitleOffset ( 0.75 );
00083       effVersusDiscr_g->SetXTitle ( "Discriminant" );
00084       effVersusDiscr_g->GetXaxis()->SetTitleOffset ( 0.75 );
00085       effVersusDiscr_dus->SetXTitle ( "Discriminant" );
00086       effVersusDiscr_dus->GetXaxis()->SetTitleOffset ( 0.75 );
00087     }
00088     effVersusDiscr_c->SetXTitle ( "Discriminant" );
00089     effVersusDiscr_c->GetXaxis()->SetTitleOffset ( 0.75 );
00090     effVersusDiscr_b->SetXTitle ( "Discriminant" );
00091     effVersusDiscr_b->GetXaxis()->SetTitleOffset ( 0.75 );
00092     effVersusDiscr_ni->SetXTitle ( "Discriminant" );
00093     effVersusDiscr_ni->GetXaxis()->SetTitleOffset ( 0.75 );
00094     effVersusDiscr_dusg->SetXTitle ( "Discriminant" );
00095     effVersusDiscr_dusg->GetXaxis()->SetTitleOffset ( 0.75 );
00096   }
00097   else{
00098     effVersusDiscr_d =    0;
00099     effVersusDiscr_u =    0; 
00100     effVersusDiscr_s =    0;
00101     effVersusDiscr_c =    0; 
00102     effVersusDiscr_b =    0;
00103     effVersusDiscr_g =    0;
00104     effVersusDiscr_ni =   0;
00105     effVersusDiscr_dus =  0;
00106     effVersusDiscr_dusg = 0;
00107   }
00108 
00109   // discr. for computation
00110   vector<TH1F*> discrCfHistos = dDiscriminatorFC->getHistoVector();
00111 
00112   // discr no cut
00113   vector<TH1F*> discrNoCutHistos = discrNoCutEffic->getHistoVector();
00114 
00115   // discr no cut
00116   vector<TH1F*> discrCutHistos = discrCutEfficScan->getHistoVector();
00117 
00118   const int& dimHistos = discrCfHistos.size(); // they all have the same size
00119 
00120   // DISCR-CUT LOOP:
00121   // fill the histos for eff-pur computations by scanning the discriminatorFC histogram
00122 
00123   // better to loop over bins -> discrCut no longer needed
00124   const int& nBins = dDiscriminatorFC->nBins();
00125 
00126   // loop over flavours
00127   for ( int iFlav = 0; iFlav < dimHistos; iFlav++ ) {
00128     if (discrCfHistos[iFlav] == 0) continue;
00129     discrNoCutHistos[iFlav]->SetXTitle ( "Discriminant" );
00130     discrNoCutHistos[iFlav]->GetXaxis()->SetTitleOffset ( 0.75 );
00131 
00132     // In Root histos, bin counting starts at 1 to nBins.
00133     // bin 0 is the underflow, and nBins+1 is the overflow.
00134     const double& nJetsFlav = discrCfHistos[iFlav]->GetEntries ();
00135     double sum = discrCfHistos[iFlav]->GetBinContent( nBins+1 ); //+1 to get the overflow.
00136     
00137     for ( int iDiscr = nBins; iDiscr > 0 ; --iDiscr ) {
00138       // fill all jets into NoCut histo
00139       discrNoCutHistos[iFlav]->SetBinContent ( iDiscr, nJetsFlav );
00140       discrNoCutHistos[iFlav]->SetBinError   ( iDiscr, sqrt(nJetsFlav) );
00141       sum += discrCfHistos[iFlav]->GetBinContent( iDiscr );
00142       discrCutHistos[iFlav]->SetBinContent ( iDiscr, sum );
00143       discrCutHistos[iFlav]->SetBinError   ( iDiscr, sqrt(sum) );
00144     }
00145   }
00146 
00147 
00148   // divide to get efficiency vs. discriminator cut from absolute numbers
00149   discrCutEfficScan->divide ( *discrNoCutEffic );  // does: histos including discriminator cut / flat histo
00150 }
00151 
00152 
00153 EffPurFromHistos::~EffPurFromHistos () {
00154   /*  delete EffFlavVsBEff_d   ;
00155   delete EffFlavVsBEff_u   ;
00156   delete EffFlavVsBEff_s   ;
00157   delete EffFlavVsBEff_c   ;
00158   delete EffFlavVsBEff_b   ;
00159   delete EffFlavVsBEff_g   ;
00160   delete EffFlavVsBEff_ni  ;
00161   delete EffFlavVsBEff_dus ;
00162   delete EffFlavVsBEff_dusg;
00163   if ( fromDiscriminatorDistr) {
00164     delete discrNoCutEffic;
00165     delete discrCutEfficScan;
00166     }*/
00167 }
00168 
00169 
00170 
00171 
00172 void EffPurFromHistos::epsPlot(const std::string & name)
00173 {
00174   if ( fromDiscriminatorDistr) {
00175     discrNoCutEffic->epsPlot(name);
00176     discrCutEfficScan->epsPlot(name);
00177   }
00178   plot(name, ".eps");
00179 }
00180 
00181 void EffPurFromHistos::psPlot(const std::string & name)
00182 {
00183   plot(name, ".ps");
00184 }
00185 
00186 void EffPurFromHistos::plot(const std::string & name, const std::string & ext)
00187 {
00188    TCanvas tc (("FlavEffVsBEff" +histoExtension).c_str() ,
00189         ("Flavour misidentification vs. b-tagging efficiency " + histoExtension).c_str());
00190    plot(&tc);
00191    tc.Print((name + "FlavEffVsBEff" + histoExtension + ext).c_str());
00192 }
00193 
00194 void EffPurFromHistos::plot (TPad * plotCanvas /* = 0 */) {
00195 
00196 //fixme:
00197   bool btppNI = false;
00198   bool btppColour = true;
00199 
00200 //   if ( !btppTitle ) gStyle->SetOptTitle ( 0 );
00201   setTDRStyle()->cd();
00202 
00203   if (plotCanvas)
00204     plotCanvas->cd();
00205   
00206   gPad->UseCurrentStyle();
00207   gPad->SetFillColor ( 0 );
00208   gPad->SetLogy  ( 1 );
00209   gPad->SetGridx ( 1 );
00210   gPad->SetGridy ( 1 );
00211 
00212   int col_c  ;
00213   int col_g  ;
00214   int col_dus;
00215   int col_ni ;
00216 
00217   int mStyle_c  ;
00218   int mStyle_g  ;
00219   int mStyle_dus;
00220   int mStyle_ni ;
00221 
00222   // marker size (same for all)
00223   float mSize = gPad->GetWh() * gPad->GetHNDC() / 500.; //1.2;
00224 
00225   if ( btppColour ) {
00226     col_c    = 6;
00227     col_g    = 3; // g in green
00228     col_dus  = 4; // uds in blue
00229     col_ni   = 5; // ni in ??
00230     mStyle_c   = 20;
00231     mStyle_g   = 20;
00232     mStyle_dus = 20;
00233     mStyle_ni  = 20;
00234   }
00235   else {
00236     col_c    = 1;
00237     col_g    = 1;
00238     col_dus  = 1;
00239     col_ni   = 1;
00240     mStyle_c   = 22;
00241     mStyle_g   = 29;
00242     mStyle_dus = 20;
00243     mStyle_ni  = 27;
00244   }
00245 
00246 
00247   // for the moment: plot c,dus,g
00248   if(mcPlots_>2){
00249     EffFlavVsBEff_dus ->getTH1F()->GetXaxis()->SetTitle ( "b-jet efficiency" );
00250     EffFlavVsBEff_dus ->getTH1F()->GetYaxis()->SetTitle ( "non b-jet efficiency" );
00251     EffFlavVsBEff_dus ->getTH1F()->GetYaxis()->SetTitleOffset ( 0.25 );
00252     EffFlavVsBEff_dus ->getTH1F()->SetMaximum     ( 1.1 );
00253     EffFlavVsBEff_dus ->getTH1F()->SetMinimum     ( 1.e-5 );
00254     EffFlavVsBEff_dus ->getTH1F()->SetMarkerColor ( col_dus );
00255     EffFlavVsBEff_dus ->getTH1F()->SetLineColor   ( col_dus );
00256     EffFlavVsBEff_dus ->getTH1F()->SetMarkerSize  ( mSize );
00257     EffFlavVsBEff_dus ->getTH1F()->SetMarkerStyle ( mStyle_dus );
00258     EffFlavVsBEff_dus ->getTH1F()->SetStats     ( false );
00259     EffFlavVsBEff_dus ->getTH1F()->Draw("pe");
00260 
00261     EffFlavVsBEff_g   ->getTH1F()->SetMarkerColor ( col_g );
00262     EffFlavVsBEff_g   ->getTH1F()->SetLineColor   ( col_g );
00263     EffFlavVsBEff_g   ->getTH1F()->SetMarkerSize  ( mSize );
00264     EffFlavVsBEff_g   ->getTH1F()->SetMarkerStyle ( mStyle_g );
00265     EffFlavVsBEff_g   ->getTH1F()->SetStats     ( false );
00266     EffFlavVsBEff_g   ->getTH1F()->Draw("peSame");
00267   }
00268   EffFlavVsBEff_c   ->getTH1F()->SetMarkerColor ( col_c );
00269   EffFlavVsBEff_c   ->getTH1F()->SetLineColor   ( col_c );
00270   EffFlavVsBEff_c   ->getTH1F()->SetMarkerSize  ( mSize );
00271   EffFlavVsBEff_c   ->getTH1F()->SetMarkerStyle ( mStyle_c );
00272   EffFlavVsBEff_c   ->getTH1F()->SetStats     ( false );
00273   EffFlavVsBEff_c   ->getTH1F()->Draw("peSame");
00274 
00275   if(mcPlots_>2){
00276     EffFlavVsBEff_d ->getTH1F()-> SetMinimum(0.01);
00277     EffFlavVsBEff_u ->getTH1F()-> SetMinimum(0.01);
00278     EffFlavVsBEff_s ->getTH1F()-> SetMinimum(0.01);
00279     EffFlavVsBEff_g ->getTH1F()-> SetMinimum(0.01);
00280     EffFlavVsBEff_dus ->getTH1F()-> SetMinimum(0.01);
00281   }
00282   EffFlavVsBEff_c ->getTH1F()-> SetMinimum(0.01);
00283   EffFlavVsBEff_b ->getTH1F()-> SetMinimum(0.01);
00284   EffFlavVsBEff_ni ->getTH1F()-> SetMinimum(0.01);
00285   EffFlavVsBEff_dusg ->getTH1F()-> SetMinimum(0.01);
00286 
00287   // plot separately u,d and s
00288 //  EffFlavVsBEff_d ->GetXaxis()->SetTitle ( "b-jet efficiency" );
00289 //  EffFlavVsBEff_d ->GetYaxis()->SetTitle ( "non b-jet efficiency" );
00290 //  EffFlavVsBEff_d ->GetYaxis()->SetTitleOffset ( 1.25 );
00291 //  EffFlavVsBEff_d ->SetMaximum     ( 1.1 );
00292 //  EffFlavVsBEff_d ->SetMinimum     ( 1.e-5 );
00293 //  EffFlavVsBEff_d ->SetMarkerColor ( col_dus );
00294 //  EffFlavVsBEff_d ->SetLineColor   ( col_dus );
00295 //  EffFlavVsBEff_d ->SetMarkerSize  ( mSize );
00296 //  EffFlavVsBEff_d ->SetMarkerStyle ( mStyle_dus );
00297 //  EffFlavVsBEff_d ->SetStats     ( false );
00298 //  EffFlavVsBEff_d ->Draw("pe");
00299 //
00300 //  EffFlavVsBEff_u   ->SetMarkerColor ( col_g );
00301 //  EffFlavVsBEff_u   ->SetLineColor   ( col_g );
00302 //  EffFlavVsBEff_u   ->SetMarkerSize  ( mSize );
00303 //  EffFlavVsBEff_u   ->SetMarkerStyle ( mStyle_g );
00304 //  EffFlavVsBEff_u   ->SetStats     ( false );
00305 //  EffFlavVsBEff_u   ->Draw("peSame");
00306 //
00307 //  EffFlavVsBEff_s   ->SetMarkerColor ( col_c );
00308 //  EffFlavVsBEff_s   ->SetLineColor   ( col_c );
00309 //  EffFlavVsBEff_s   ->SetMarkerSize  ( mSize );
00310 //  EffFlavVsBEff_s   ->SetMarkerStyle ( mStyle_c );
00311 //  EffFlavVsBEff_s   ->SetStats     ( false );
00312 //  EffFlavVsBEff_s   ->Draw("peSame");
00313 
00314   // only if asked: NI
00315   if ( btppNI ) {
00316     EffFlavVsBEff_ni   ->getTH1F()->SetMarkerColor ( col_ni );
00317     EffFlavVsBEff_ni   ->getTH1F()->SetLineColor   ( col_ni );
00318     EffFlavVsBEff_ni   ->getTH1F()->SetMarkerSize  ( mSize );
00319     EffFlavVsBEff_ni   ->getTH1F()->SetMarkerStyle ( mStyle_ni );
00320     EffFlavVsBEff_ni   ->getTH1F()->SetStats     ( false );
00321     EffFlavVsBEff_ni   ->getTH1F()->Draw("peSame");
00322   }
00323 
00324 }
00325 
00326 
00327 void EffPurFromHistos::check () {
00328   // number of bins
00329 
00330   int nBins_d    = 0;
00331   int nBins_u    = 0;
00332   int nBins_s    = 0;
00333   int nBins_g    = 0;
00334   int nBins_dus  = 0;
00335   if(mcPlots_>2){
00336     nBins_d    = effVersusDiscr_d    -> GetNbinsX();
00337     nBins_u    = effVersusDiscr_u    -> GetNbinsX();
00338     nBins_s    = effVersusDiscr_s    -> GetNbinsX();
00339     nBins_g    = effVersusDiscr_g    -> GetNbinsX();
00340     nBins_dus  = effVersusDiscr_dus  -> GetNbinsX();
00341   }
00342   const int& nBins_c    = effVersusDiscr_c    -> GetNbinsX();
00343   const int& nBins_b    = effVersusDiscr_b    -> GetNbinsX();
00344   const int& nBins_ni   = effVersusDiscr_ni   -> GetNbinsX();
00345   const int& nBins_dusg = effVersusDiscr_dusg -> GetNbinsX();
00346 
00347   const bool& lNBins =
00348     ( (nBins_d == nBins_u    &&
00349        nBins_d == nBins_s    &&
00350        nBins_d == nBins_c    &&
00351        nBins_d == nBins_b    &&
00352        nBins_d == nBins_g    &&
00353        nBins_d == nBins_ni   &&
00354        nBins_d == nBins_dus  &&
00355        nBins_d == nBins_dusg)||
00356       (nBins_c == nBins_b    &&
00357        nBins_c == nBins_dusg &&
00358        nBins_c == nBins_ni)    );
00359 
00360   if ( !lNBins ) {
00361     throw cms::Exception("Configuration")
00362       << "Input histograms do not all have the same number of bins!\n";
00363   }
00364 
00365 
00366   // start
00367   float sBin_d    = 0;
00368   float sBin_u    = 0;
00369   float sBin_s    = 0;
00370   float sBin_g    = 0;
00371   float sBin_dus  = 0;
00372   if(mcPlots_>2){
00373     sBin_d    = effVersusDiscr_d    -> GetBinCenter(1);
00374     sBin_u    = effVersusDiscr_u    -> GetBinCenter(1);
00375     sBin_s    = effVersusDiscr_s    -> GetBinCenter(1);
00376     sBin_g    = effVersusDiscr_g    -> GetBinCenter(1);
00377     sBin_dus  = effVersusDiscr_dus  -> GetBinCenter(1);
00378   }
00379   const float& sBin_c    = effVersusDiscr_c    -> GetBinCenter(1);
00380   const float& sBin_b    = effVersusDiscr_b    -> GetBinCenter(1);
00381   const float& sBin_ni   = effVersusDiscr_ni   -> GetBinCenter(1);
00382   const float& sBin_dusg = effVersusDiscr_dusg -> GetBinCenter(1);
00383 
00384   const bool& lSBin =
00385     ( (sBin_d == sBin_u    &&
00386        sBin_d == sBin_s    &&
00387        sBin_d == sBin_c    &&
00388        sBin_d == sBin_b    &&
00389        sBin_d == sBin_g    &&
00390        sBin_d == sBin_ni   &&
00391        sBin_d == sBin_dus  &&
00392        sBin_d == sBin_dusg)||
00393       (sBin_c == sBin_b    &&
00394        sBin_c == sBin_dusg &&
00395        sBin_c == sBin_ni)    );
00396 
00397   if ( !lSBin ) {
00398     throw cms::Exception("Configuration")
00399       << "EffPurFromHistos::check() : Input histograms do not all have the same start bin!\n";
00400   }
00401 
00402 
00403   // end
00404   float eBin_d    = 0;
00405   float eBin_u    = 0;
00406   float eBin_s    = 0;
00407   float eBin_g    = 0;
00408   float eBin_dus  = 0;
00409   if(mcPlots_>2){
00410     eBin_d    = effVersusDiscr_d    -> GetBinCenter( nBins_d - 1 );
00411     eBin_u    = effVersusDiscr_u    -> GetBinCenter( nBins_d - 1 );
00412     eBin_s    = effVersusDiscr_s    -> GetBinCenter( nBins_d - 1 );
00413     eBin_g    = effVersusDiscr_g    -> GetBinCenter( nBins_d - 1 );
00414     eBin_dus  = effVersusDiscr_dus  -> GetBinCenter( nBins_d - 1 );
00415   }
00416   const float& eBin_c    = effVersusDiscr_c    -> GetBinCenter( nBins_d - 1 );
00417   const float& eBin_b    = effVersusDiscr_b    -> GetBinCenter( nBins_d - 1 );
00418   const float& eBin_ni   = effVersusDiscr_ni   -> GetBinCenter( nBins_d - 1 );
00419   const float& eBin_dusg = effVersusDiscr_dusg -> GetBinCenter( nBins_d - 1 );
00420 
00421   const bool& lEBin =
00422     ( (eBin_d == eBin_u    &&
00423        eBin_d == eBin_s    &&
00424        eBin_d == eBin_c    &&
00425        eBin_d == eBin_b    &&
00426        eBin_d == eBin_g    &&
00427        eBin_d == eBin_ni   &&
00428        eBin_d == eBin_dus  &&
00429        eBin_d == eBin_dusg)||
00430       (eBin_c == eBin_b    &&
00431        eBin_c == eBin_dusg &&
00432        eBin_c == eBin_ni)     );
00433 
00434   if ( !lEBin ) {
00435     throw cms::Exception("Configuration")
00436       << "EffPurFromHistos::check() : Input histograms do not all have the same end bin!\n";
00437   }
00438 }
00439 
00440 
00441 void EffPurFromHistos::compute ()
00442 {
00443   if (!mcPlots_) {
00444 
00445     EffFlavVsBEff_d = 0;
00446     EffFlavVsBEff_u = 0; 
00447     EffFlavVsBEff_s = 0; 
00448     EffFlavVsBEff_c = 0; 
00449     EffFlavVsBEff_b = 0; 
00450     EffFlavVsBEff_g = 0; 
00451     EffFlavVsBEff_ni = 0; 
00452     EffFlavVsBEff_dus = 0; 
00453     EffFlavVsBEff_dusg = 0; 
00454     
00455     return; 
00456  
00457   }
00458  
00459 
00460   // to have shorter names ......
00461   const std::string & hE = histoExtension;
00462   const std::string & hB = "FlavEffVsBEff_";
00463 
00464 
00465   // create histograms from base name and extension as given from user
00466   // BINNING MUST BE IDENTICAL FOR ALL OF THEM!!
00467   HistoProviderDQM prov("Btag",label_);
00468   if(mcPlots_>2){
00469     EffFlavVsBEff_d    = (prov.book1D ( hB + "D"    + hE , hB + "D"    + hE , nBinOutput , startOutput , endOutput ));
00470     EffFlavVsBEff_u    = (prov.book1D ( hB + "U"    + hE , hB + "U"    + hE , nBinOutput , startOutput , endOutput )) ;
00471     EffFlavVsBEff_s    = (prov.book1D ( hB + "S"    + hE , hB + "S"    + hE , nBinOutput , startOutput , endOutput )) ;
00472     EffFlavVsBEff_g    = (prov.book1D ( hB + "G"    + hE , hB + "G"    + hE , nBinOutput , startOutput , endOutput )) ;
00473     EffFlavVsBEff_dus  = (prov.book1D ( hB + "DUS"  + hE , hB + "DUS"  + hE , nBinOutput , startOutput , endOutput )) ;
00474   }
00475   else {
00476     EffFlavVsBEff_d = 0;
00477     EffFlavVsBEff_u = 0;
00478     EffFlavVsBEff_s = 0;
00479     EffFlavVsBEff_g = 0;
00480     EffFlavVsBEff_dus = 0;
00481   }
00482   EffFlavVsBEff_c    = (prov.book1D ( hB + "C"    + hE , hB + "C"    + hE , nBinOutput , startOutput , endOutput )) ;
00483   EffFlavVsBEff_b    = (prov.book1D ( hB + "B"    + hE , hB + "B"    + hE , nBinOutput , startOutput , endOutput )) ;
00484   EffFlavVsBEff_ni   = (prov.book1D ( hB + "NI"   + hE , hB + "NI"   + hE , nBinOutput , startOutput , endOutput )) ;
00485   EffFlavVsBEff_dusg = (prov.book1D ( hB + "DUSG" + hE , hB + "DUSG" + hE , nBinOutput , startOutput , endOutput )) ;
00486 
00487   if(mcPlots_>2){
00488     EffFlavVsBEff_d->getTH1F()->SetXTitle ( "b-jet efficiency" );
00489     EffFlavVsBEff_d->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00490     EffFlavVsBEff_d->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00491     EffFlavVsBEff_d->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00492     EffFlavVsBEff_u->getTH1F()->SetXTitle ( "b-jet efficiency" );
00493     EffFlavVsBEff_u->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00494     EffFlavVsBEff_u->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00495     EffFlavVsBEff_u->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00496     EffFlavVsBEff_s->getTH1F()->SetXTitle ( "b-jet efficiency" );
00497     EffFlavVsBEff_s->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00498     EffFlavVsBEff_s->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00499     EffFlavVsBEff_s->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00500     EffFlavVsBEff_g->getTH1F()->SetXTitle ( "b-jet efficiency" );
00501     EffFlavVsBEff_g->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00502     EffFlavVsBEff_g->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00503     EffFlavVsBEff_g->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00504     EffFlavVsBEff_dus->getTH1F()->SetXTitle ( "b-jet efficiency" );
00505     EffFlavVsBEff_dus->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00506     EffFlavVsBEff_dus->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00507     EffFlavVsBEff_dus->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00508   }
00509   EffFlavVsBEff_c->getTH1F()->SetXTitle ( "b-jet efficiency" );
00510   EffFlavVsBEff_c->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00511   EffFlavVsBEff_c->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00512   EffFlavVsBEff_c->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00513   EffFlavVsBEff_b->getTH1F()->SetXTitle ( "b-jet efficiency" );
00514   EffFlavVsBEff_b->getTH1F()->SetYTitle ( "b-jet efficiency" );
00515   EffFlavVsBEff_b->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00516   EffFlavVsBEff_b->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00517   EffFlavVsBEff_ni->getTH1F()->SetXTitle ( "b-jet efficiency" );
00518   EffFlavVsBEff_ni->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00519   EffFlavVsBEff_ni->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00520   EffFlavVsBEff_ni->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00521   EffFlavVsBEff_dusg->getTH1F()->SetXTitle ( "b-jet efficiency" );
00522   EffFlavVsBEff_dusg->getTH1F()->SetYTitle ( "non b-jet efficiency" );
00523   EffFlavVsBEff_dusg->getTH1F()->GetXaxis()->SetTitleOffset ( 0.75 );
00524   EffFlavVsBEff_dusg->getTH1F()->GetYaxis()->SetTitleOffset ( 0.75 );
00525 
00526 
00527   // loop over eff. vs. discriminator cut b-histo and look in which bin the closest entry is;
00528   // use fact that eff decreases monotonously
00529 
00530   // any of the histos to be created can be taken here:
00531   MonitorElement * EffFlavVsBEff = EffFlavVsBEff_b;
00532 
00533   const int& nBinB = EffFlavVsBEff->getTH1F()->GetNbinsX();
00534 
00535   for ( int iBinB = 1; iBinB <= nBinB; iBinB++ ) {  // loop over the bins on the x-axis of the histograms to be filled
00536 
00537     const float& effBBinWidth = EffFlavVsBEff->getTH1F()->GetBinWidth  ( iBinB );
00538     const float& effBMid      = EffFlavVsBEff->getTH1F()->GetBinCenter ( iBinB ); // middle of b-efficiency bin
00539     const float& effBLeft     = effBMid - 0.5*effBBinWidth;              // left edge of bin
00540     const float& effBRight    = effBMid + 0.5*effBBinWidth;              // right edge of bin
00541     // find the corresponding bin in the efficiency versus discriminator cut histo: closest one in efficiency
00542     const int&   binClosest = findBinClosestYValue ( effVersusDiscr_b , effBMid , effBLeft , effBRight );
00543     const bool&  binFound   = ( binClosest > 0 ) ;
00544     //
00545     if ( binFound ) {
00546       // fill the histos
00547       if(mcPlots_>2){
00548         EffFlavVsBEff_d    -> Fill ( effBMid , effVersusDiscr_d   ->GetBinContent ( binClosest ) );
00549         EffFlavVsBEff_u    -> Fill ( effBMid , effVersusDiscr_u   ->GetBinContent ( binClosest ) );
00550         EffFlavVsBEff_s    -> Fill ( effBMid , effVersusDiscr_s   ->GetBinContent ( binClosest ) );
00551         EffFlavVsBEff_g    -> Fill ( effBMid , effVersusDiscr_g   ->GetBinContent ( binClosest ) );
00552         EffFlavVsBEff_dus  -> Fill ( effBMid , effVersusDiscr_dus ->GetBinContent ( binClosest ) );
00553       }
00554       EffFlavVsBEff_c    -> Fill ( effBMid , effVersusDiscr_c   ->GetBinContent ( binClosest ) );
00555       EffFlavVsBEff_b    -> Fill ( effBMid , effVersusDiscr_b   ->GetBinContent ( binClosest ) );
00556       EffFlavVsBEff_ni   -> Fill ( effBMid , effVersusDiscr_ni  ->GetBinContent ( binClosest ) );
00557       EffFlavVsBEff_dusg -> Fill ( effBMid , effVersusDiscr_dusg->GetBinContent ( binClosest ) );
00558 
00559       if(mcPlots_>2){
00560         EffFlavVsBEff_d  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_d   ->GetBinError ( binClosest ) );
00561         EffFlavVsBEff_u  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_u   ->GetBinError ( binClosest ) );
00562         EffFlavVsBEff_s  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_s   ->GetBinError ( binClosest ) );
00563         EffFlavVsBEff_g  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_g   ->GetBinError ( binClosest ) );
00564         EffFlavVsBEff_dus->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_dus ->GetBinError ( binClosest ) );
00565       }
00566       EffFlavVsBEff_c  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_c   ->GetBinError ( binClosest ) );
00567       EffFlavVsBEff_b  ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_b   ->GetBinError ( binClosest ) );
00568       EffFlavVsBEff_ni ->getTH1F()  -> SetBinError ( iBinB , effVersusDiscr_ni  ->GetBinError ( binClosest ) );
00569       EffFlavVsBEff_dusg->getTH1F() -> SetBinError ( iBinB , effVersusDiscr_dusg->GetBinError ( binClosest ) );
00570     }
00571     else {
00572       //cout << "Did not find right bin for b-efficiency : " << effBMid << endl;
00573     }
00574     
00575   }
00576   
00577 }
00578 
00579 
00580 #include <typeinfo>
00581