CMS 3D CMS Logo

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