DAS
3.0
Das Analysis System
|
A generic base class to simplify applying scale factors.
Object | The object type to apply scale factors for |
Context | A set of object types that are needed to derive cuts and scale factors, but to which no corrections is applied. |
GenericSFApplier can be used in situations where one wants to apply a cut to a collection of objects (e.g. photons) and correct the efficiency of this cut in MC with scale factors. This class must be subclassed before it can be used, and two methods need to be implemented in the subclass:
In addition, the constructor should load scale factors using loadNominal() and systematic uncertainties using loadBinWiseUnc() and loadGlobalUnc() (which differ in how the uncertainty will be correlated between bins of the scale factors.
Instances of classes derived from this one is used by calling the call operator on individual objects or whole object collections. Objects that do not pass the selection will be given a weight of zero. Objects passing the selection will be reweighted by the scale factor (if the correction is enabled) and new weights will be appended for systematics (again only if enabled).
Sometimes, additional inputs are needed to derive the cut and/or the scale factor. We call this contextual information. An arbitrary number of extra arguments can be passed to the call operator for context. The applier passes them directly to passes() and binIndex(), where they can be used to implement the selection or the correction. The types of context objects must be provided as class template arguments. The functions take constant references to these types.
Each uncertainty variation must be given a unique name. The names of all weights added by this class can be retrieved using the weightNames() method. This is useful to store them in the metainfo.
#include <GenericSFApplier.h>
Public Member Functions | |
GenericSFApplier (const std::filesystem::path &filePath, bool correction, bool uncertainties) | |
virtual | ~GenericSFApplier () noexcept=default |
void | operator() (Object &object, const Context &... ctx) const |
void | operator() (std::vector< Object > &objects, const Context &... ctx) const |
std::vector< std::string > | weightNames () const |
Protected Types | |
enum | Interpretation { UseBinContent, UseBinError } |
Protected Member Functions | |
void | loadNominal (const std::string &histPath) |
void | loadBinWiseUnc (const std::string &name, const std::string &histPath, Interpretation intp=UseBinContent) |
void | loadGlobalUnc (const std::string &name, const std::string &histPath, Interpretation intp=UseBinContent) |
virtual bool | passes (const Object &obj, const Context &... ctx) const =0 |
virtual int | binIndex (const Object &obj, const Context &... ctx, const std::unique_ptr< TH1 > &hist) const =0 |
Private Attributes | |
std::unique_ptr< TFile > | m_file |
bool | m_correction |
bool | m_uncertainties |
std::unique_ptr< TH1 > | m_nominal |
std::map< std::string, std::unique_ptr< TH1 > > | m_bin_wise_uncs |
std::map< std::string, std::unique_ptr< TH1 > > | m_global_uncs |
|
protected |
GenericSFApplier | ( | const std::filesystem::path & | filePath, |
bool | correction, | ||
bool | uncertainties | ||
) |
Constructor.
filePath | The path of a ROOT file to load scale factors from |
correction | Whether to apply scale factors |
uncertainties | Whether to store uncertainties |
|
virtualdefaultnoexcept |
|
protectedpure virtual |
Called to retrieve the bin to use in the scale factor histograms.
The histogram passed as second parameter is always the nominal one, and it is assumed that the bin index is the same for uncertainty variations (that is, we assume that the binnings match).
|
protected |
Loads a systematic with bin-by-bin correlations.
The histogram is expected to contain the (symmetric) uncertainty in the scale factor. This function has no effect when not applying the correction or when uncertainties are disabled.
|
protected |
Loads a fully correlated systematic.
The histogram is expected to contain the (symmetric) uncertainty in the scale factor. This function has no effect when not applying the correction or when uncertainties are disabled.
|
protected |
Loads the histogram with the nominal scale factor. Has no effect when not applying the correction.
void operator() | ( | Object & | object, |
const Context &... | ctx | ||
) | const |
Applies the selection and scale factors to a single object.
void operator() | ( | std::vector< Object > & | objects, |
const Context &... | ctx | ||
) | const |
|
protectedpure virtual |
Called to check whether an object passes the selection.
std::vector< std::string > weightNames |
Retrieves the name of weights added by this applier. Returns an empty vector when uncertainties are disabled.
|
private |
Histograms with uncertainties correlated bin-by-bin.
|
private |
Apply the scale factors?
|
private |
SFs are loaded from this file.
|
private |
Histograms with uncertainties correlated.
|
private |
Histogram with the nominal SFs.
|
private |
Calculate uncertainties?