CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

BTagDifferentialPlot Class Reference

#include <BTagDifferentialPlot.h>

List of all members.

Public Types

enum  ConstVarType { constPT, constETA }

Public Member Functions

void addBinPlotter (JetTagPlotter *aPlotter)
 BTagDifferentialPlot (const double &bEff, const ConstVarType &constVariable, const std::string &tagName)
void epsPlot (const std::string &name)
TH1F * getDifferentialHistoB_b ()
TH1F * getDifferentialHistoB_c ()
TH1F * getDifferentialHistoB_d ()
TH1F * getDifferentialHistoB_dus ()
TH1F * getDifferentialHistoB_dusg ()
TH1F * getDifferentialHistoB_g ()
TH1F * getDifferentialHistoB_ni ()
TH1F * getDifferentialHistoB_s ()
TH1F * getDifferentialHistoB_u ()
void plot (TCanvas &theCanvas)
void plot (const std::string &name, const std::string &ext)
void process ()
void psPlot (const std::string &name)
 ~BTagDifferentialPlot ()

Private Member Functions

void bookHisto ()
void fillHisto ()
std::pair< double, double > getMistag (const double &fixedBEfficiency, TH1F *effPurHist)
void setVariableName ()

Private Attributes

std::string commonName
ConstVarType constVar
std::string constVariableName
std::pair< double, double > constVariableValue
std::string diffVariableName
double fixedBEfficiency
bool noProcessing
bool processed
std::vector< JetTagPlotter * > theBinPlotters
MonitorElementtheDifferentialHistoB_b
MonitorElementtheDifferentialHistoB_c
MonitorElementtheDifferentialHistoB_d
MonitorElementtheDifferentialHistoB_dus
MonitorElementtheDifferentialHistoB_dusg
MonitorElementtheDifferentialHistoB_g
MonitorElementtheDifferentialHistoB_ni
MonitorElementtheDifferentialHistoB_s
MonitorElementtheDifferentialHistoB_u

Detailed Description

Definition at line 15 of file BTagDifferentialPlot.h.


Member Enumeration Documentation

Enumerator:
constPT 
constETA 

Definition at line 19 of file BTagDifferentialPlot.h.


Constructor & Destructor Documentation

BTagDifferentialPlot::BTagDifferentialPlot ( const double &  bEff,
const ConstVarType constVariable,
const std::string &  tagName 
)

Definition at line 20 of file BTagDifferentialPlot.cc.

BTagDifferentialPlot::~BTagDifferentialPlot ( )

Definition at line 37 of file BTagDifferentialPlot.cc.

                                             {
}

Member Function Documentation

void BTagDifferentialPlot::addBinPlotter ( JetTagPlotter aPlotter) [inline]

Definition at line 26 of file BTagDifferentialPlot.h.

References theBinPlotters.

{ theBinPlotters.push_back ( aPlotter ) ; }
void BTagDifferentialPlot::bookHisto ( ) [private]

Definition at line 1066 of file PhotonAnalyzer.cc.

References newFWLiteAna::bin, DQMStore::book1D(), dbe_, max(), min, DQMStore::pwd(), and indexGen::title.

Referenced by process().

{

  int histo_index = 0;
  stringstream histo_number_stream;

  //determining which folder we're in
  if(dbe_->pwd().find( "InvMass" ) != string::npos){
    histo_index_invMass_++;
    histo_index = histo_index_invMass_;
  }
  if(dbe_->pwd().find( "Efficiencies" ) != string::npos){
    histo_index_efficiency_++;
    histo_index = histo_index_efficiency_;
  }

  histo_number_stream << "h_";
  if(histo_index<10)   histo_number_stream << "0";
  histo_number_stream << histo_index;

  return dbe_->book1D(histo_number_stream.str()+"_"+histoName,title,bin,min,max);

}
void BTagDifferentialPlot::epsPlot ( const std::string &  name)

Definition at line 155 of file BTagDifferentialPlot.cc.

References plot().

{
  plot(name, ".eps");
}
void BTagDifferentialPlot::fillHisto ( ) [private]

Definition at line 265 of file BTagDifferentialPlot.cc.

References diffVariableName, Exception, fixedBEfficiency, EffPurFromHistos::getEffFlavVsBEff_b(), EffPurFromHistos::getEffFlavVsBEff_c(), EffPurFromHistos::getEffFlavVsBEff_d(), EffPurFromHistos::getEffFlavVsBEff_dus(), EffPurFromHistos::getEffFlavVsBEff_dusg(), EffPurFromHistos::getEffFlavVsBEff_g(), EffPurFromHistos::getEffFlavVsBEff_ni(), EffPurFromHistos::getEffFlavVsBEff_s(), EffPurFromHistos::getEffFlavVsBEff_u(), EtaPtBin::getEtaActive(), EtaPtBin::getEtaMax(), EtaPtBin::getEtaMin(), getMistag(), EtaPtBin::getPtActive(), EtaPtBin::getPtMax(), EtaPtBin::getPtMin(), MonitorElement::getTH1F(), theBinPlotters, theDifferentialHistoB_b, theDifferentialHistoB_c, theDifferentialHistoB_d, theDifferentialHistoB_dus, theDifferentialHistoB_dusg, theDifferentialHistoB_g, theDifferentialHistoB_ni, theDifferentialHistoB_s, theDifferentialHistoB_u, and funct::true.

Referenced by process().

                                      {
  // loop over bins and find corresponding misid. in the MisIdVs..... histo
  for ( vector<JetTagPlotter *>::const_iterator iP = theBinPlotters.begin() ;
        iP != theBinPlotters.end() ; ++iP ) {
    const EtaPtBin   & currentBin              = (*iP)->etaPtBin() ;
    EffPurFromHistos * currentEffPurFromHistos = (*iP)->getEffPurFromHistos() ;
    //
    bool   isActive   = true ;
    double valueXAxis = -999.99 ;
    // find right bin based on middle of the interval
    if ( diffVariableName == "eta" ) {
      isActive = currentBin.getEtaActive() ;
      valueXAxis = 0.5 * ( currentBin.getEtaMin() + currentBin.getEtaMax() ) ;
    } else if ( diffVariableName == "pt"  ) {
      isActive = currentBin.getPtActive() ;
      valueXAxis = 0.5 * ( currentBin.getPtMin() + currentBin.getPtMax() ) ;
    } else {
      throw cms::Exception("Configuration")
        << "====>>>> BTagDifferentialPlot::fillHisto() : illegal diffVariableName = " << diffVariableName << endl;
    }

    // for the moment: ignore inactive bins
    // (maybe later: if a Bin is inactive -> set value to fill well below left edge of histogram to have it in the underflow)

    if ( !isActive ) continue ;

    // to have less lines of code ....
    vector< pair<TH1F*,TH1F*> > effPurDifferentialPairs ;

    // all flavours (b is a good cross check! must be constant and = fixed b-efficiency)
    // get histo; find the bin of the fixed b-efficiency in the histo and get misid; fill


    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_d()    , theDifferentialHistoB_d ->getTH1F()   ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_u()    , theDifferentialHistoB_u ->getTH1F()   ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_s()    , theDifferentialHistoB_s ->getTH1F()   ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_c()    , theDifferentialHistoB_c  ->getTH1F()  ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_b()    , theDifferentialHistoB_b  ->getTH1F()  ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_g()    , theDifferentialHistoB_g  ->getTH1F()  ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_ni()   , theDifferentialHistoB_ni ->getTH1F()  ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_dus()  , theDifferentialHistoB_dus->getTH1F()  ) ) ;
    effPurDifferentialPairs.push_back ( make_pair ( currentEffPurFromHistos->getEffFlavVsBEff_dusg() , theDifferentialHistoB_dusg->getTH1F() ) ) ;

    for ( vector< pair<TH1F*,TH1F*> >::const_iterator itP  = effPurDifferentialPairs.begin() ;
                                                      itP != effPurDifferentialPairs.end()   ; ++itP ) {
      TH1F * effPurHist = itP->first  ;
      TH1F * diffHist   = itP->second ;
      pair<double, double> mistag = getMistag(fixedBEfficiency, effPurHist);
      int iBinSet = diffHist->FindBin(valueXAxis) ;
      diffHist->SetBinContent(iBinSet, mistag.first);
      diffHist->SetBinError(iBinSet, mistag.second);
    }
  }

}
TH1F* BTagDifferentialPlot::getDifferentialHistoB_b ( ) [inline]

Definition at line 47 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_b.

TH1F* BTagDifferentialPlot::getDifferentialHistoB_c ( ) [inline]

Definition at line 46 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_c.

TH1F* BTagDifferentialPlot::getDifferentialHistoB_d ( ) [inline]

Definition at line 43 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_d.

TH1F* BTagDifferentialPlot::getDifferentialHistoB_dus ( ) [inline]
TH1F* BTagDifferentialPlot::getDifferentialHistoB_dusg ( ) [inline]
TH1F* BTagDifferentialPlot::getDifferentialHistoB_g ( ) [inline]

Definition at line 48 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_g.

TH1F* BTagDifferentialPlot::getDifferentialHistoB_ni ( ) [inline]
TH1F* BTagDifferentialPlot::getDifferentialHistoB_s ( ) [inline]

Definition at line 45 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_s.

TH1F* BTagDifferentialPlot::getDifferentialHistoB_u ( ) [inline]

Definition at line 44 of file BTagDifferentialPlot.h.

References MonitorElement::getTH1F(), and theDifferentialHistoB_u.

pair< double, double > BTagDifferentialPlot::getMistag ( const double &  fixedBEfficiency,
TH1F *  effPurHist 
) [private]

Definition at line 322 of file BTagDifferentialPlot.cc.

References i.

Referenced by fillHisto().

{
  int iBinGet = effPurHist->FindBin ( fixedBEfficiency ) ;
  double effForBEff    = effPurHist->GetBinContent ( iBinGet ) ;
  double effForBEffErr = effPurHist->GetBinError   ( iBinGet ) ;

  if (effForBEff==0. && effForBEffErr==0.) {
    // The bin was empty. Could be that it was not filled, as the scan-plot
    //  did not have an entry at the requested value, or that the curve
    // is above or below.
    // Fit a plynomial, and evaluate the mistag at the requested value.
    int fitStatus;
    try {
    fitStatus = effPurHist->Fit("pol4", "q");
    }catch (...){
  return pair<double, double>(effForBEff, effForBEffErr);
}
    if (fitStatus != 0) {
      edm::LogWarning("BTagDifferentialPlot")<<"Fit failed to hisogram " << effPurHist->GetTitle() << " , perhaps because too few entries = " << effPurHist->GetEntries() <<". This bin will be missing in plots at fixed b efficiency.";
      //    } else {
      //      edm::LogInfo("BTagDifferentialPlot")<<"Fit OK to hisogram " << effPurHist->GetTitle() << " entries = " << effPurHist->GetEntries();
      return pair<double, double>(effForBEff, effForBEffErr);
    }
    TF1 *myfunc = effPurHist->GetFunction("pol4");
    effForBEff = myfunc->Eval(fixedBEfficiency);
    effPurHist->RecursiveRemove(myfunc);
    //Error: first non-empty bin on the right and take its error
    for (int i = iBinGet+1; i< effPurHist->GetNbinsX(); ++i) {
      if (effPurHist->GetBinContent(i)!=0) {
        effForBEffErr = effPurHist->GetBinError(i);
        break;
      }
    }
  }

  return pair<double, double>(effForBEff, effForBEffErr);
}
void BTagDifferentialPlot::plot ( const std::string &  name,
const std::string &  ext 
)

Definition at line 165 of file BTagDifferentialPlot.cc.

References commonName, plot(), and processed.

{
  if (!processed) return;
   TCanvas tc(commonName.c_str(), commonName.c_str());
   plot(tc);
   tc.Print((name + commonName + ext).c_str());
}
void BTagDifferentialPlot::plot ( TCanvas &  theCanvas)

Definition at line 45 of file BTagDifferentialPlot.cc.

References MonitorElement::getTH1F(), processed, theDifferentialHistoB_c, theDifferentialHistoB_dus, theDifferentialHistoB_g, and theDifferentialHistoB_ni.

Referenced by epsPlot(), plot(), and psPlot().

                                                         {

//   thePlotCanvas = new TCanvas(  commonName ,
//                              commonName ,
//                              btppXCanvas , btppYCanvas ) ;
//
//   if ( !btppTitle ) gStyle->SetOptTitle ( 0 ) ;

  if (!processed) return;
//fixme:
  bool btppNI = false;
  bool btppColour = true;

  thePlotCanvas.SetFillColor ( 0 ) ;
  thePlotCanvas.cd ( 1 ) ;
  gPad->SetLogy  ( 1 ) ;
  gPad->SetGridx ( 1 ) ;
  gPad->SetGridy ( 1 ) ;

  int col_b   ;
  int col_c   ;
  int col_g   ;
  int col_dus ;
  int col_ni  ;

  int mStyle_b   ;
  int mStyle_c   ;
  int mStyle_g   ;
  int mStyle_dus ;
  int mStyle_ni  ;

  // marker size (same for all)
  float mSize = 1.5 ;

  if ( btppColour ) {
    col_b    = 2 ;
    col_c    = 6 ;
    col_g    = 3 ;
    col_dus  = 4 ;
    col_ni   = 5 ;
    mStyle_b   = 20 ;
    mStyle_c   = 20 ;
    mStyle_g   = 20 ;
    mStyle_dus = 20 ;
    mStyle_ni  = 20 ;
  }
  else {
    col_b    = 1 ;
    col_c    = 1 ;
    col_g    = 1 ;
    col_dus  = 1 ;
    col_ni   = 1 ;
    mStyle_b   = 12 ;
    mStyle_c   = 22 ;
    mStyle_g   = 29 ;
    mStyle_dus = 20 ;
    mStyle_ni  = 27 ;
  }

  // for the moment: plot b (to see what the constant b-efficiency is), c, g, uds
  // b in red
  // No, do not plot b (because only visible for the soft leptons)
  // theDifferentialHistoB_b   -> GetXaxis()->SetTitle ( diffVariableName ) ;
  // theDifferentialHistoB_b   -> GetYaxis()->SetTitle ( "non b-jet efficiency" ) ;
  // theDifferentialHistoB_b   -> GetYaxis()->SetTitleOffset ( 1.25 ) ;
  // theDifferentialHistoB_b   -> SetMaximum ( 0.4 )  ;
  // theDifferentialHistoB_b   -> SetMinimum ( 1.e-4 )  ;
  // theDifferentialHistoB_b   -> SetMarkerColor ( col_b ) ;
  // theDifferentialHistoB_b   -> SetLineColor   ( col_b ) ;
  // theDifferentialHistoB_b   -> SetMarkerSize  ( mSize ) ;
  // theDifferentialHistoB_b   -> SetMarkerStyle ( mStyle_b ) ;
  // theDifferentialHistoB_b   -> SetStats ( false ) ;
  // theDifferentialHistoB_b   -> Draw ( "pe" ) ;
  // c in magenta
  theDifferentialHistoB_c ->getTH1F()  -> SetMaximum ( 0.4 )  ;
  theDifferentialHistoB_c ->getTH1F()  -> SetMinimum ( 1.e-4 )  ;
  theDifferentialHistoB_c ->getTH1F()  -> SetMarkerColor ( col_c ) ;
  theDifferentialHistoB_c ->getTH1F()  -> SetLineColor   ( col_c ) ;
  theDifferentialHistoB_c ->getTH1F()  -> SetMarkerSize  ( mSize ) ;
  theDifferentialHistoB_c ->getTH1F()  -> SetMarkerStyle ( mStyle_c ) ;
  theDifferentialHistoB_c ->getTH1F()  -> SetStats     ( false ) ;
  //  theDifferentialHistoB_c   -> Draw("peSame") ;
  theDifferentialHistoB_c   ->getTH1F()-> Draw("pe") ;
  // uds in blue
  theDifferentialHistoB_dus ->getTH1F()-> SetMarkerColor ( col_dus ) ;
  theDifferentialHistoB_dus ->getTH1F()-> SetLineColor   ( col_dus ) ;
  theDifferentialHistoB_dus ->getTH1F()-> SetMarkerSize  ( mSize ) ;
  theDifferentialHistoB_dus ->getTH1F()-> SetMarkerStyle ( mStyle_dus ) ;
  theDifferentialHistoB_dus ->getTH1F()-> SetStats     ( false ) ;
  theDifferentialHistoB_dus ->getTH1F()-> Draw("peSame") ;
  // g in green
  // only uds not to confuse
  theDifferentialHistoB_g   ->getTH1F()-> SetMarkerColor ( col_g ) ;
  theDifferentialHistoB_g   ->getTH1F()-> SetLineColor   ( col_g ) ;
  theDifferentialHistoB_g   ->getTH1F()-> SetMarkerSize  ( mSize ) ;
  theDifferentialHistoB_g   ->getTH1F()-> SetMarkerStyle ( mStyle_g ) ;
  theDifferentialHistoB_g   ->getTH1F()-> SetStats     ( false ) ;
  theDifferentialHistoB_g   ->getTH1F()-> Draw("peSame") ;

  // NI if wanted
  if ( btppNI ) {
    theDifferentialHistoB_ni ->getTH1F()-> SetMarkerColor ( col_ni ) ;
    theDifferentialHistoB_ni ->getTH1F()-> SetLineColor   ( col_ni ) ;
    theDifferentialHistoB_ni ->getTH1F()-> SetMarkerSize  ( mSize ) ;
    theDifferentialHistoB_ni ->getTH1F()-> SetMarkerStyle ( mStyle_ni ) ;
    theDifferentialHistoB_ni ->getTH1F()-> SetStats     ( false ) ;
    theDifferentialHistoB_ni ->getTH1F()-> Draw("peSame") ;
  }
}
void BTagDifferentialPlot::process ( )

Definition at line 174 of file BTagDifferentialPlot.cc.

References bookHisto(), fillHisto(), noProcessing, processed, and setVariableName().

                                    {
  setVariableName () ; // also sets noProcessing if not OK
  if ( noProcessing ) return ;
  bookHisto () ;
  fillHisto () ;
  processed = true;
}
void BTagDifferentialPlot::psPlot ( const std::string &  name)

Definition at line 160 of file BTagDifferentialPlot.cc.

References plot().

{
  plot(name, ".ps");
}
void BTagDifferentialPlot::setVariableName ( ) [private]

Definition at line 183 of file BTagDifferentialPlot.cc.

References constETA, constPT, constVar, constVariableName, constVariableValue, diffVariableName, and theBinPlotters.

Referenced by process().

{
  if ( constVar==constETA ) {
    constVariableName  = "eta" ;
    diffVariableName   = "pt"  ;
    constVariableValue = make_pair ( theBinPlotters[0]->etaPtBin().getEtaMin() , theBinPlotters[0]->etaPtBin().getEtaMax() ) ;
  }
  if ( constVar==constPT  ) {
    constVariableName = "pt"  ;
    diffVariableName  = "eta" ;
    constVariableValue = make_pair ( theBinPlotters[0]->etaPtBin().getPtMin() , theBinPlotters[0]->etaPtBin().getPtMax() ) ;
  }

  /*  std::cout
     << "====>>>> BTagDifferentialPlot::setVariableName() : set const/diffVariableName to : "
     << constVariableName << " / " << diffVariableName << endl
     << "====>>>>                                            constant value interval : "
     << constVariableValue.first  << " - " << constVariableValue.second << endl ;
  */
}

Member Data Documentation

std::string BTagDifferentialPlot::commonName [private]

Definition at line 85 of file BTagDifferentialPlot.h.

Referenced by plot().

Definition at line 75 of file BTagDifferentialPlot.h.

Referenced by setVariableName().

Definition at line 77 of file BTagDifferentialPlot.h.

Referenced by setVariableName().

std::pair<double,double> BTagDifferentialPlot::constVariableValue [private]

Definition at line 82 of file BTagDifferentialPlot.h.

Referenced by setVariableName().

Definition at line 79 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and setVariableName().

Definition at line 69 of file BTagDifferentialPlot.h.

Referenced by fillHisto().

Definition at line 72 of file BTagDifferentialPlot.h.

Referenced by process().

Definition at line 73 of file BTagDifferentialPlot.h.

Referenced by plot(), and process().

Definition at line 89 of file BTagDifferentialPlot.h.

Referenced by addBinPlotter(), fillHisto(), and setVariableName().

Definition at line 96 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and getDifferentialHistoB_b().

Definition at line 95 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), getDifferentialHistoB_c(), and plot().

Definition at line 92 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and getDifferentialHistoB_d().

Definition at line 99 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), getDifferentialHistoB_dus(), and plot().

Definition at line 100 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and getDifferentialHistoB_dusg().

Definition at line 97 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), getDifferentialHistoB_g(), and plot().

Definition at line 98 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), getDifferentialHistoB_ni(), and plot().

Definition at line 94 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and getDifferentialHistoB_s().

Definition at line 93 of file BTagDifferentialPlot.h.

Referenced by fillHisto(), and getDifferentialHistoB_u().