Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Add an accessor to b-tagging efficiencies and scale factors that
Browse files Browse the repository at this point in the history
requires jet flavour explicitly

This feature is useful when b-tagging efficiencies or scale factors are
used in a data-driven method, in which case Jet::GetParentID() does not
make sense.
  • Loading branch information
andrey-popov committed Mar 11, 2014
1 parent b0987f2 commit ca65563
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 18 deletions.
29 changes: 26 additions & 3 deletions core/include/BTagEffInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,36 @@ class BTagEffInterface
*/
virtual void LoadPayload(Dataset const &dataset);

/// Returns b-tagging efficiency for a given working point and a given jet
virtual double GetEfficiency(BTagger::WorkingPoint wp, Jet const &jet) const = 0;
/**
* \brief Returns b-tagging efficiency for a given working point and a given jet momentum and
* flavour
*
* Jet flavour might be negative.
*/
virtual double GetEfficiency(BTagger::WorkingPoint wp, Candidate const &jet, int flavour)
const = 0;

/**
* \brief Returns b-tagging efficiency for a given working point and a given jet
*
* Internally calls the pure virtual method with the same name.
*/
double GetEfficiency(BTagger::WorkingPoint wp, Jet const &jet) const;

/**
* \brief Returns b-tagging efficiency for a given jet momentum and flavour using the default
* working point
*
* The method is useful for prescriptions that support only one working point. Internally calls
* the pure virtual method with the same name.
*/
double GetEfficiency(Candidate const &jet, int flavour) const;

/**
* \brief Returns b-tagging efficiency for a given jet using the default working point
*
* The method is useful for prescriptions that support only one working point.
* The method is useful for prescriptions that support only one working point. Internally calls
* the pure virtual method with the same name.
*/
double GetEfficiency(Jet const &jet) const;

Expand Down
28 changes: 24 additions & 4 deletions core/include/BTagSFInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,39 @@ class BTagSFInterface
virtual BTagSFInterface *Clone() const = 0;

/**
* \brief Returns b-tagging scale factor for a given jet
* \brief Returns b-tagging scale factor for a given working point and given jet momentum and
* flavour.
*
* User is not expected to calculate scale factors for jets that fail the pseudorapidity
* coverage defined by the method GetMaxPseudorapidity. Behaviour of the method is undefined
* otherwise.
* otherwise. The flavour might be negative.
*/
virtual double GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet,
virtual double GetScaleFactor(BTagger::WorkingPoint wp, Candidate const &jet, int flavour,
Variation var = Variation::Nominal) const = 0;

/**
* \brief Returns b-tagging scale factor for a given jet
*
* Internally calls the pure virtual method with the same name.
*/
double GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet,
Variation var = Variation::Nominal) const;

/**
* \brief Returns b-tagging scale factor for given jet momentum and flavour using the default
* working point
*
* The method is useful for prescriptions that support only one working point. Internally calls
* the pure virtual method with the same name.
*/
double GetScaleFactor(Candidate const &jet, int flavour, Variation var = Variation::Nominal)
const;

/**
* \brief Returns b-tagging scale factor for a given jet using the default working point
*
* The method is useful for prescriptions that support only one working point.
* The method is useful for prescriptions that support only one working point. Internally calls
* the pure virtual method with the same name.
*/
double GetScaleFactor(Jet const &jet, Variation var = Variation::Nominal) const;

Expand Down
14 changes: 13 additions & 1 deletion core/src/BTagEffInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ void BTagEffInterface::LoadPayload(Dataset const &)
{}


double BTagEffInterface::GetEfficiency(BTagger::WorkingPoint wp, Jet const &jet) const
{
return GetEfficiency(wp, jet, jet.GetParentID());
}


double BTagEffInterface::GetEfficiency(Candidate const &jet, int flavour) const
{
return GetEfficiency(defaultWP, jet, flavour);
}


double BTagEffInterface::GetEfficiency(Jet const &jet) const
{
return GetEfficiency(defaultWP, jet);
return GetEfficiency(defaultWP, jet, jet.GetParentID());
}


Expand Down
16 changes: 15 additions & 1 deletion core/src/BTagSFInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,23 @@ BTagSFInterface::~BTagSFInterface() noexcept
{}


double BTagSFInterface::GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet,
Variation var /*= Variation::Nominal*/) const
{
return GetScaleFactor(wp, jet, jet.GetParentID(), var);
}


double BTagSFInterface::GetScaleFactor(Candidate const &jet, int flavour,
Variation var /*= Variation::Nominal*/) const
{
return GetScaleFactor(defaultWP, jet, flavour, var);
}


double BTagSFInterface::GetScaleFactor(Jet const &jet, Variation var /*= Variation::Nominal*/) const
{
return GetScaleFactor(defaultWP, jet, var);
return GetScaleFactor(defaultWP, jet, jet.GetParentID(), var);
}


Expand Down
5 changes: 3 additions & 2 deletions extensions/include/BTagEfficiencies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ class BTagEfficiencies: public BTagEffInterface
virtual void LoadPayload(Dataset const &dataset);

/**
* \brief Returns b-tagging efficiency for a given working point and a given jet
* \brief Returns b-tagging efficiency for a given working point and given jet momentum and
* flavour
*
* The efficiency is read from a histogram selected according to jet flavour and requested
* working point. Appropriate bin of the histogram is identified by jet transverse momentum and
* (signed) pseudorapidity; overflow bins are expected to be filled in a meaningful way. If
* required histogram is not found, an exception is thrown.
*/
virtual double GetEfficiency(BTagger::WorkingPoint wp, Jet const &jet) const;
virtual double GetEfficiency(BTagger::WorkingPoint wp, Candidate const &jet, int flavour) const;

/**
* \brief Returns a text label for a b-tagging working point
Expand Down
5 changes: 3 additions & 2 deletions extensions/include/BTagScaleFactors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class BTagScaleFactors: public BTagSFInterface
virtual BTagSFInterface *Clone() const;

/**
* \brief Returns b-tagging scale factor for a given working point and a given jet
* \brief Returns b-tagging scale factor for a given working point and given jet momentum and
* flavour
*
* The method constrains jet transverse momentum to the appropriate range described in [1] and
* calls specific automatically generated methods to obtain the scale factor. If the scale
Expand All @@ -75,7 +76,7 @@ class BTagScaleFactors: public BTagSFInterface
* an exception is thrown as well.
* [1] https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagPOG
*/
virtual double GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet,
virtual double GetScaleFactor(BTagger::WorkingPoint wp, Candidate const &jet, int flavour,
Variation var = Variation::Nominal) const;

private:
Expand Down
7 changes: 4 additions & 3 deletions extensions/src/BTagEfficiencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,17 @@ void BTagEfficiencies::LoadPayload(Dataset const &dataset)
}


double BTagEfficiencies::GetEfficiency(BTagger::WorkingPoint wp, Jet const &jet) const
double BTagEfficiencies::GetEfficiency(BTagger::WorkingPoint wp, Candidate const &jet, int flavour)
const
{
// Find the appropriate efficiency histogram
auto histIt = effHists.find(make_pair(wp, abs(jet.GetParentID())));
auto histIt = effHists.find(make_pair(wp, abs(flavour)));

if (histIt == effHists.end())
{
ostringstream ost;
ost << "BTagEfficiencies::GetEfficiency: Failed to find an efficiency histogram for " <<
"working point " << int(wp) << " and jet flavour " << jet.GetParentID() << ".";
"working point " << int(wp) << " and jet flavour " << flavour << ".";

throw runtime_error(ost.str());
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/src/BTagScaleFactors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ BTagSFInterface *BTagScaleFactors::Clone() const
}


double BTagScaleFactors::GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet,
double BTagScaleFactors::GetScaleFactor(BTagger::WorkingPoint wp, Candidate const &jet, int flavour,
Variation var /*= Variation::Nominal*/) const
{
// Get pointers to the scale factor methods for the given working point
Expand All @@ -171,7 +171,7 @@ double BTagScaleFactors::GetScaleFactor(BTagger::WorkingPoint wp, Jet const &jet


// Switch between heavy-flavour and light-flavour jets
unsigned const absFlavour = abs(jet.GetParentID());
unsigned const absFlavour = abs(flavour);

if (absFlavour == 4 or absFlavour == 5) // b- or c-quark jets
{
Expand Down

0 comments on commit ca65563

Please sign in to comment.