Skip to content

Commit

Permalink
Merge pull request #13098 from cms-btv-pog/bTagRecoAndDQMcleanup
Browse files Browse the repository at this point in the history
Clean up of btag sequence in standard reco + update of DQM
  • Loading branch information
davidlange6 committed Feb 12, 2016
2 parents f9468f6 + a7f42b5 commit 23763ec
Show file tree
Hide file tree
Showing 75 changed files with 1,498 additions and 1,197 deletions.
77 changes: 31 additions & 46 deletions DQMOffline/RecoB/interface/EffPurFromHistos.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,61 @@

#include <string>

//class DQMStore;

class EffPurFromHistos {


public:

EffPurFromHistos ( const std::string & ext, TH1F * h_d, TH1F * h_u,
TH1F * h_s, TH1F * h_c, TH1F * h_b, TH1F * h_g, TH1F * h_ni,
TH1F * h_dus, TH1F * h_dusg, TH1F * h_pu,
const std::string& label, const unsigned int& mc,
int nBin = 100 , double startO = 0.005 , double endO = 1.005 ) ;
// defaults reasonable for lifetime based tags

EffPurFromHistos (const FlavourHistograms<double> * dDiscriminatorFC, const std::string& label, const unsigned int& mc, DQMStore::IBooker & ibook,
int nBin = 100 , double startO = 0.005 , double endO = 1.005 ) ;
// defaults reasonable for lifetime based tags
EffPurFromHistos (const FlavourHistograms<double> * dDiscriminatorFC, const std::string& label, const unsigned int& mc,
DQMStore::IBooker & ibook, int nBin = 100 , double startO = 0.005 , double endO = 1.005 ) ;

~EffPurFromHistos () ;

// do the computation
void compute (DQMStore::IBooker & ibook) ;

// return the newly created histos
TH1F * getEffFlavVsBEff_d () { return EffFlavVsBEff_d->getTH1F() ; };
TH1F * getEffFlavVsBEff_u () { return EffFlavVsBEff_u->getTH1F() ; };
TH1F * getEffFlavVsBEff_s () { return EffFlavVsBEff_s ->getTH1F() ; };
TH1F * getEffFlavVsBEff_c () { return EffFlavVsBEff_c ->getTH1F() ; };
TH1F * getEffFlavVsBEff_b () { return EffFlavVsBEff_b ->getTH1F() ; };
TH1F * getEffFlavVsBEff_g () { return EffFlavVsBEff_g ->getTH1F() ; };
TH1F * getEffFlavVsBEff_ni () { return EffFlavVsBEff_ni ->getTH1F() ; };
TH1F * getEffFlavVsBEff_dus () { return EffFlavVsBEff_dus ->getTH1F() ; };
TH1F * getEffFlavVsBEff_dusg () { return EffFlavVsBEff_dusg ->getTH1F(); };
TH1F * getEffFlavVsBEff_pu () { return EffFlavVsBEff_pu ->getTH1F(); };
TH1F * getEffFlavVsBEff_d () { return EffFlavVsXEff_d->getTH1F() ; };
TH1F * getEffFlavVsBEff_u () { return EffFlavVsXEff_u->getTH1F() ; };
TH1F * getEffFlavVsBEff_s () { return EffFlavVsXEff_s ->getTH1F() ; };
TH1F * getEffFlavVsBEff_c () { return EffFlavVsXEff_c ->getTH1F() ; };
TH1F * getEffFlavVsBEff_b () { return EffFlavVsXEff_b ->getTH1F() ; };
TH1F * getEffFlavVsBEff_g () { return EffFlavVsXEff_g ->getTH1F() ; };
TH1F * getEffFlavVsBEff_ni () { return EffFlavVsXEff_ni ->getTH1F() ; };
TH1F * getEffFlavVsBEff_dus () { return EffFlavVsXEff_dus ->getTH1F() ; };
TH1F * getEffFlavVsBEff_dusg () { return EffFlavVsXEff_dusg ->getTH1F(); };
TH1F * getEffFlavVsBEff_pu () { return EffFlavVsXEff_pu ->getTH1F(); };



void epsPlot(const std::string & name);

void psPlot(const std::string & name);

void plot(TPad * theCanvas = 0) ;

void plot(const std::string & name, const std::string & ext);

// void print () const ;

FlavourHistograms<double> * discriminatorNoCutEffic() const {return discrNoCutEffic;}
FlavourHistograms<double> * discriminatorCutEfficScan() const {return discrCutEfficScan;}
FlavourHistograms<double> * discriminatorNoCutEffic() const {return discrNoCutEffic.get();}
FlavourHistograms<double> * discriminatorCutEfficScan() const {return discrCutEfficScan.get();}

bool doCTagPlots(bool Ctag) {doCTagPlots_ = Ctag; return doCTagPlots_;};

private:


// consistency check (same binning)
void check () ;
bool fromDiscriminatorDistr;


unsigned int mcPlots_;
bool doCTagPlots_;
std::string label_;
// the string for the histo name extension
std::string histoExtension ;

FlavourHistograms<double> * discrNoCutEffic, *discrCutEfficScan;
std::unique_ptr<FlavourHistograms<double> > discrNoCutEffic, discrCutEfficScan;

// the input histograms (efficiency versus discriminator cut)
// IMPORTANT: IT'S ASSUMED THAT ALL HISTOS HAVE THE SAME BINNING!!
Expand All @@ -88,31 +81,23 @@ class EffPurFromHistos {
TH1F * effVersusDiscr_dusg ;
TH1F * effVersusDiscr_pu ;


// the corresponding output histograms (flavour-eff vs. b-efficiency)

// binning for output histograms
int nBinOutput ;
double startOutput ;
double endOutput ;

unsigned int mcPlots_;


MonitorElement * EffFlavVsBEff_d ;
MonitorElement * EffFlavVsBEff_u ;
MonitorElement * EffFlavVsBEff_s ;
MonitorElement * EffFlavVsBEff_c ;
MonitorElement * EffFlavVsBEff_b ;
MonitorElement * EffFlavVsBEff_g ;
MonitorElement * EffFlavVsBEff_ni ;
MonitorElement * EffFlavVsBEff_dus ;
MonitorElement * EffFlavVsBEff_dusg ;
MonitorElement * EffFlavVsBEff_pu ;

// DQMStore * dqmStore_;
std::string label_;

} ;
MonitorElement * EffFlavVsXEff_d ;
MonitorElement * EffFlavVsXEff_u ;
MonitorElement * EffFlavVsXEff_s ;
MonitorElement * EffFlavVsXEff_c ;
MonitorElement * EffFlavVsXEff_b ;
MonitorElement * EffFlavVsXEff_g ;
MonitorElement * EffFlavVsXEff_ni ;
MonitorElement * EffFlavVsXEff_dus ;
MonitorElement * EffFlavVsXEff_dusg ;
MonitorElement * EffFlavVsXEff_pu ;
};

#endif
86 changes: 86 additions & 0 deletions DQMOffline/RecoB/interface/EffPurFromHistos2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#ifndef EffPurFromHistos2D_H
#define EffPurFromHistos2D_H

#include "DQMOffline/RecoB/interface/FlavourHistorgrams2D.h"
#include "DQMOffline/RecoB/interface/HistoProviderDQM.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "TH2F.h"
#include "TCanvas.h"

#include <string>

class EffPurFromHistos2D {

public:

EffPurFromHistos2D ( const std::string & ext, TH2F * h_d, TH2F * h_u,
TH2F * h_s, TH2F * h_c, TH2F * h_b, TH2F * h_g, TH2F * h_ni,
TH2F * h_dus, TH2F * h_dusg, TH2F * h_pu,
const std::string& label, const unsigned int& mc,
int nBinX = 100 , double startOX = 0.05 , double endOX = 1.05) ;

EffPurFromHistos2D (const FlavourHistograms2D<double, double> * dDiscriminatorFC,
const std::string& label, const unsigned int& mc,
DQMStore::IBooker & ibook,
int nBinX = 100 , double startOX = 0.05 , double endOX = 1.05) ;

~EffPurFromHistos2D () ;

// do the computation
void compute (DQMStore::IBooker & ibook, std::vector<double> fixedEff) ;

void epsPlot(const std::string & name);
void psPlot(const std::string & name);

void plot(TPad * theCanvas = 0) ;
void plot(const std::string & name, const std::string & ext);

FlavourHistograms2D<double,double> * discriminatorNoCutEffic() const {return discrNoCutEffic.get();}
FlavourHistograms2D<double,double> * discriminatorCutEfficScan() const {return discrCutEfficScan.get();}

bool doCTagPlots(bool Ctag) {doCTagPlots_ = Ctag; return doCTagPlots_;};

private:

// consistency check (same binning)
void check () ;
bool fromDiscriminatorDistr;

unsigned int mcPlots_;
bool doCTagPlots_;
std::string label_;
// the string for the histo name extension
std::string histoExtension ;

std::unique_ptr<FlavourHistograms2D<double, double> > discrNoCutEffic, discrCutEfficScan;

// the input histograms (efficiency versus discriminator cut)
// IMPORTANT: IT'S ASSUMED THAT ALL HISTOS HAVE THE SAME BINNING!!
// (can in principle be relaxed by checking explicitely for the discriminator value
// instead of bin index)
TH2F * effVersusDiscr_d ;
TH2F * effVersusDiscr_u ;
TH2F * effVersusDiscr_s ;
TH2F * effVersusDiscr_c ;
TH2F * effVersusDiscr_b ;
TH2F * effVersusDiscr_g ;
TH2F * effVersusDiscr_ni ;
TH2F * effVersusDiscr_dus ;
TH2F * effVersusDiscr_dusg ;
TH2F * effVersusDiscr_pu ;

// the corresponding output histograms (flavour-eff vs. b-efficiency)

// binning for output histograms
int nBinOutputX;
double startOutputX;
double endOutputX;
int nBinOutputY;
double startOutputY;
double endOutputY;

std::vector<MonitorElement*> X_vs_Y_eff_at_fixedZeff;
};

#endif
124 changes: 124 additions & 0 deletions DQMOffline/RecoB/interface/FlavourHistorgrams2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ class FlavourHistograms2D {


void settitle(const char* titleX, const char* titleY) ;

void plot (TPad * theCanvas = 0) ;
void epsPlot(const std::string& name);

// needed for efficiency computations -> this / b
// (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
void divide ( const FlavourHistograms2D<T, G> & bHD ) const ;
void setEfficiencyFlag();

inline void SetMaximum(const double& max) { theMax = max;}
inline void SetMinimum(const double& min) { theMin = min;}
Expand Down Expand Up @@ -524,6 +528,108 @@ void FlavourHistograms2D<T, G>::settitle(const char* titleX, const char* titleY)
}
}

template <class T, class G>
void FlavourHistograms2D<T, G>::plot (TPad * theCanvas /* = 0 */) {

//fixme:
bool btppNI = false;
bool btppColour = true;

if (theCanvas)
theCanvas->cd();

RecoBTag::setTDRStyle()->cd();
gPad->UseCurrentStyle();
gPad->SetLogy ( 0 ) ;
gPad->SetGridx ( 0 ) ;
gPad->SetGridy ( 0 ) ;
gPad->SetTitle ( 0 ) ;

MonitorElement * histo[4];
int col[4], lineStyle[4], markerStyle[4];
int lineWidth = 1 ;

const double markerSize = gPad->GetWh() * gPad->GetHNDC() / 500.;
histo[0] = theHisto_dusg ;
histo[1] = theHisto_b ;
histo[2] = theHisto_c ;
histo[3]= 0 ;

double max = theMax;
if (theMax<=0.) {
max = theHisto_dusg->getTH2F()->GetMaximum();
if (theHisto_b->getTH2F()->GetMaximum() > max) max = theHisto_b->getTH2F()->GetMaximum();
if (theHisto_c->getTH2F()->GetMaximum() > max) max = theHisto_c->getTH2F()->GetMaximum();
}

if (btppNI) {
histo[3] = theHisto_ni ;
if (theHisto_ni->getTH2F()->GetMaximum() > max) max = theHisto_ni->getTH2F()->GetMaximum();
}

if ( btppColour ) { // print colours
col[0] = 4 ;
col[1] = 2 ;
col[2] = 6 ;
col[3] = 3 ;
lineStyle[0] = 1 ;
lineStyle[1] = 1 ;
lineStyle[2] = 1 ;
lineStyle[3] = 1 ;
markerStyle[0] = 20 ;
markerStyle[1] = 21 ;
markerStyle[2] = 22 ;
markerStyle[3] = 23 ;
lineWidth = 1 ;
}
else { // different marker/line styles
col[1] = 1 ;
col[2] = 1 ;
col[3] = 1 ;
col[0] = 1 ;
lineStyle[0] = 2 ;
lineStyle[1] = 1 ;
lineStyle[2] = 3 ;
lineStyle[3] = 4 ;
markerStyle[0] = 20 ;
markerStyle[1] = 21 ;
markerStyle[2] = 22 ;
markerStyle[3] = 23 ;
}

histo[0] ->getTH2F()->GetXaxis()->SetTitle ( theBaseNameDescription.c_str() ) ;
histo[0] ->getTH2F()->GetYaxis()->SetTitle ( "Arbitrary Units" ) ;
histo[0] ->getTH2F()->GetYaxis()->SetTitleOffset(1.25) ;

for (int i=0; i != 4; ++i) {
if (histo[i]== 0 ) continue;
histo[i] ->getTH2F()->SetStats ( false ) ;
histo[i] ->getTH2F()->SetLineStyle ( lineStyle[i] ) ;
histo[i] ->getTH2F()->SetLineWidth ( lineWidth ) ;
histo[i] ->getTH2F()->SetLineColor ( col[i] ) ;
histo[i] ->getTH2F()->SetMarkerStyle ( markerStyle[i] ) ;
histo[i] ->getTH2F()->SetMarkerColor ( col[i] ) ;
histo[i] ->getTH2F()->SetMarkerSize ( markerSize ) ;
}

histo[0]->getTH2F()->SetMaximum(max*1.05);
if (theMin!=-1.) histo[0]->getTH2F()->SetMinimum(theMin);
histo[0]->getTH2F()->Draw() ;
histo[1]->getTH2F()->Draw("Same") ;
histo[2]->getTH2F()->Draw("Same") ;
if ( histo[3] != 0 ) histo[3]->getTH2F()->Draw("Same") ;

}

template <class T, class G>
void FlavourHistograms2D<T, G>::epsPlot(const std::string& name)
{
TCanvas tc(theBaseNameTitle.c_str() , theBaseNameDescription.c_str());

plot(&tc);
tc.Print((name + theBaseNameTitle + ".eps").c_str());
}

// needed for efficiency computations -> this / b
// (void : alternative would be not to overwrite the histos but to return a cloned HistoDescription)
template <class T, class G>
Expand All @@ -550,6 +656,24 @@ void FlavourHistograms2D<T, G>::divide ( const FlavourHistograms2D<T, G> & bHD )
}
}

template <class T, class G>
void FlavourHistograms2D<T, G>::setEfficiencyFlag(){
if(theHisto_all) theHisto_all ->setEfficiencyFlag();
if (mcPlots_) {
if (mcPlots_>2 ) {
theHisto_d ->setEfficiencyFlag();
theHisto_u ->setEfficiencyFlag();
theHisto_s ->setEfficiencyFlag();
theHisto_g ->setEfficiencyFlag();
theHisto_dus ->setEfficiencyFlag();
}
theHisto_c ->setEfficiencyFlag();
theHisto_b ->setEfficiencyFlag();
theHisto_ni ->setEfficiencyFlag();
theHisto_dusg ->setEfficiencyFlag();
theHisto_pu ->setEfficiencyFlag();
}
}

template <class T, class G>
void FlavourHistograms2D<T, G>::fillVariable ( const int & flavour , const T & varX , const G & varY , const float & w) const {
Expand Down

0 comments on commit 23763ec

Please sign in to comment.