Collects weights from multiple instances of WeightBase. More...
#include <WeightCollector.h>
Public Member Functions | |
WeightCollector (std::initializer_list< WeightBase const * > computers={}) | |
Constructor from a list of weight computers. | |
void | Add (WeightBase const *computer) |
Registers a new weight computer with this collector. | |
double | NominalWeight () const |
Computes the combined nominal event weight. | |
double | operator() () const |
Computes combination of default event weights. | |
int | NumVariations () const |
Total number of systematic variations in all registered computers. | |
double | RelWeight (int variation) const |
Returns relative weight for the variation with the given global index. | |
std::string_view | VariationName (int variation) const |
Returns the label of the variation with the given global index. | |
Private Member Functions | |
std::tuple< int, int > | TranslateIndex (int variation) const |
Converts a global index of a variation into the index of the computer that provides that variation and the index of the variation in that computer. | |
Private Attributes | |
std::vector< WeightBase const * > | computers_ |
Non-owning pointers to registered weight computers. |
Collects weights from multiple instances of WeightBase.
An object of this class keeps a sequence of pointers to weight computers, which inherit from WeightBase. Nominal weights given by each computer are multiplied together. Weights corresponding to systematic variations can be accessed via the global variation index that counts consecutively all variations in all registered weight computers.
WeightCollector::WeightCollector | ( | ) |
Constructor from a list of weight computers.
Providing weight computers in the argument of the constructor is equivalent to repeated call to method Add.
void WeightCollector::Add | ( | WeightBase const * | computer | ) |
Registers a new weight computer with this collector.
The pointed-to object must exist throughout the lifetime of this collector.
double WeightCollector::NominalWeight | ( | ) | const |
Computes the combined nominal event weight.
The value is computed as the product of the nominal weights from all registered computers.
double WeightCollector::operator() | ( | ) | const |
Computes combination of default event weights.
The value is computed as the product of the default weights from all registered computers.
double WeightCollector::RelWeight | ( | int | variation | ) | const |
Returns relative weight for the variation with the given global index.
This relative weight is computed with respect to the nominal weight. The argument must satisfy 0 <= variation < NumVariations()
.
std::string_view WeightCollector::VariationName | ( | int | variation | ) | const |
Returns the label of the variation with the given global index.
The argument must satisfy 0 <= variation < NumVariations()
.