Samples data-like run numbers in simulation. More...
#include <RunSampler.h>
Public Member Functions | |
RunSampler (Dataset &dataset, Options const &options, TabulatedRngEngine &rngEngine) | |
run_t | operator() () const |
Returns the run number for the current event. | |
Private Member Functions | |
void | Build () const |
Updates per-event cache by sampling or reading new run number. | |
void | LoadData (YAML::Node const &config) |
Loads integrated luminosities for different runs. | |
Private Attributes | |
bool | samplingEnabled_ |
Whether the run sampling is enabled. | |
EventCache | cache_ |
Implements per-event caching. | |
run_t | currentRun_ |
Sampled or read run number cached for the current event. | |
std::optional < TTreeReaderValue< UInt_t > > | srcRun_ |
Reader to access the run number from the input file. | |
TabulatedRandomGenerator | tabulatedRng_ |
Random number generator to do the sampling. | |
std::vector< std::pair< double, run_t > > | cumulProb_ |
Cumulative probabilities for the sampling. |
Samples data-like run numbers in simulation.
When processing simulation, this class samples randomly run numbers from the corresponding period in real data. The probability to sample each run number is proportional to the luminosity recorded in it. When running on data, the actual run number is returned. This allows accounting for time dependence in simulation. For example, different corrections can be applied for different run ranges.
This class reads section run_sampler
from the master configuration. The following fields in this section are checked:
luminosity
Path to YAML file with integrated luminosities for different runs. Resolved with FileInPath.range
Range of runs to filter data from the YAML file. Only runs within this range (including boundaries) will be selected. This field is optional. If missing, all runs from the YAML file will be used. void RunSampler::LoadData | ( | YAML::Node const & | config | ) | [private] |
Loads integrated luminosities for different runs.
[in] | config | YAML node "run_sampler" read from the master configuration. |
run_t RunSampler::operator() | ( | ) | const |
Returns the run number for the current event.
In simulation the returned run number is sampled randomly; in data this is the actual run number of the current event. The result is cached per event, and subsequent calls of this method for the same event will return the same value.
std::vector<std::pair<double, run_t> > RunSampler::cumulProb_ [private] |
Cumulative probabilities for the sampling.
The first element in each pair is the cumulative probability for the run given by the second element. The vector is ordered in the cumulative probability. The cumulative probability is computed post-run, i.e. it's a non-zero value for the first entry in the vector and 1 for the last entry.
bool RunSampler::samplingEnabled_ [private] |
Whether the run sampling is enabled.
If not, the run read from the input file is returned.
std::optional<TTreeReaderValue<UInt_t> > RunSampler::srcRun_ [mutable, private] |
Reader to access the run number from the input file.
Only used when samplingEnabled_ is false.