template<class Object, class... Context>
class DAS::CorrectionlibSFApplier< Object, Context >
A generic base class to simplify applying scale factors.
- Template Parameters
-
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. |
CorrectionlibSFApplier 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 3 or 4 methods need to be implemented in the subclass:
- inputs() to retrieve the correctionlib arguments for an object;
- passes() to check whether an object should pass the cut;
- varied() to extract up/down variations;
- Optionally, binIndex() to retrieve the bin index in the histogram with the scale factors (for bin-wise correlations).
In addition, the constructor should add systematic uncertainties using addBinWiseUnc() and addGlobalUnc() (which differ in how the uncertainty will be correlated between bins of the scale factors).
Instances of classes derived from this one are 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(), inputs(), 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.
- Note
- This class is reentrant but not thread-safe.
|
void | addBinWiseUnc (const std::string &name, const correction::Variable::Type &input) |
|
void | addGlobalUnc (const std::string &name, const correction::Variable::Type &input) |
|
virtual bool | passes (const Object &obj, const Context &... ctx) const =0 |
|
virtual void | inputs (std::vector< correction::Variable::Type > &inputs, const Object &obj, const Context &... ctx) const =0 |
|
virtual std::pair< double, double > | varied (std::vector< correction::Variable::Type > &inputs, double sf, const correction::Variable::Type &uncname) const =0 |
|
virtual int | binIndex (const Object &obj, const Context &... ctx) const |
|