Mēnsūra
Public Member Functions | List of all members
GenWeightSyst Class Reference

A plugin to compute systematic variation due to generator-level weights. More...

#include <GenWeightSyst.hpp>

Inheritance diagram for GenWeightSyst:
EventWeightPlugin AnalysisPlugin Plugin

Public Member Functions

 GenWeightSyst (std::string const name, std::initializer_list< std::pair< unsigned, unsigned >> const &systWeightsIndices)
 Constructs a new reweighting plugin with the given name. More...
 
 GenWeightSyst (std::initializer_list< std::pair< unsigned, unsigned >> const &systWeightsIndices)
 A short-cut for the above version with a default name "GenWeightSyst".
 
 GenWeightSyst (GenWeightSyst const &src)
 Copy constructor.
 
 GenWeightSyst (GenWeightSyst &&)=default
 Default move constructor.
 
GenWeightSystoperator= (GenWeightSyst const &)=delete
 Assignment operator is deleted.
 
virtual void BeginRun (Dataset const &dataset) override
 Saves pointers to dependencies and find mean weights for the current dataset. More...
 
virtual PluginClone () const override
 Creates a newly configured clone. More...
 
void NormalizeByMeanWeights (std::string const &databaseFile)
 Requests that weight are normalized by their mean values. More...
 
- Public Member Functions inherited from EventWeightPlugin
 EventWeightPlugin (std::string const &name)
 Constructs an instance with the given name.
 
double GetWeight () const
 Returns the nominal weight.
 
unsigned GetNumVariations () const noexcept
 Returns the number of systematic variations.
 
double GetWeightUp (unsigned iSource) const
 Returns an "up" systematic variation with the given index. More...
 
double GetWeightDown (unsigned iSource) const
 Returns a "down" systematic variation with the given index. More...
 
std::vector< double > const & GetWeights () const noexcept
 Returns a vector with nominal weight and all systematic variations. More...
 
- Public Member Functions inherited from AnalysisPlugin
 AnalysisPlugin (std::string const &name)
 Constructor.
 
 AnalysisPlugin (AnalysisPlugin const &)=default
 Default copy constructor.
 
 AnalysisPlugin (AnalysisPlugin &&)=default
 Default move constructor.
 
AnalysisPluginoperator= (AnalysisPlugin const &)=default
 Default assignment operator.
 
virtual ~AnalysisPlugin ()
 Trivial destructor.
 
- Public Member Functions inherited from Plugin
 Plugin (std::string const &name)
 Constructor.
 
 Plugin (Plugin const &)=default
 Default copy constructor.
 
 Plugin (Plugin &&)=default
 Default move constructor.
 
Pluginoperator= (Plugin const &)=default
 Default assignment operator.
 
virtual ~Plugin ()
 Trivial destructor.
 
virtual void EndRun ()
 Performs necessary actions needed after processing of a dataset is finished. More...
 
Processor const & GetMaster () const
 Returns a reference to the master. More...
 
std::string const & GetName () const
 Returns name of the plugin.
 
EventOutcome ProcessEventToOutcome ()
 Processes a new event from the current dataset. More...
 
void SetMaster (Processor const *processor)
 Provides a pointer to an instance of Processor class that owns the plugin. More...
 

Additional Inherited Members

- Public Types inherited from Plugin
enum  EventOutcome { EventOutcome::Ok, EventOutcome::FilterFailed, EventOutcome::NoEvents }
 Outcome of processing of an event. More...
 
- Protected Member Functions inherited from Plugin
Plugin const * GetDependencyPlugin (std::string const &name) const
 Returns a pointer to a precedent plugin in the path with the given name. More...
 
- Protected Attributes inherited from EventWeightPlugin
std::vector< double > weights
 Weights assigned to the current event. More...
 

Detailed Description

A plugin to compute systematic variation due to generator-level weights.

This reweighting plugin reads generator-level weights with specified indices and computes systematic variations based on them. Nominal weight is always unit. Weights are accessed from a GeneratorReader with a default name "Generator".

There are three modes of running. In the simplest case weights with specified indices are used directly, after they are divided by a reference weight in the current event (by default given by index 0). Using method NormalizeByMeanWeights, user can request that weights are normalized by their man values read from a database file. In this case a weight w_i is rescaled as (w_i / w_0) / (<w_i> / <w_0>), where w_0 is the reference weight, and <w> denotes corresponding mean weights. Rescaling by mean weights allows to preserve the total normalization. Finally, if the rescaling has been requested but the database file does not contain entry for the current dataset, systematic variations are not evaluated and their number is set to zero.

Constructor & Destructor Documentation

GenWeightSyst::GenWeightSyst ( std::string const  name,
std::initializer_list< std::pair< unsigned, unsigned >> const &  systWeightsIndices 
)

Constructs a new reweighting plugin with the given name.

The second argument is a vector of indices of weights for systematic variations. The indices will be used to access the weights via GeneratorReader::GetAltWeight. Each pair corresponds to an independent systematic variation, first weight is for "up" variation, second is for "down" one.

Member Function Documentation

void GenWeightSyst::BeginRun ( Dataset const &  dataset)
overridevirtual

Saves pointers to dependencies and find mean weights for the current dataset.

The method also verifies that mean weights for all requested indices are avaiable for the current dataset and throws an except otherwise.

Reimplemented from Plugin.

Reimplemented from Plugin.

Plugin * GenWeightSyst::Clone ( ) const
overridevirtual

Creates a newly configured clone.

Implemented from Plugin.

Implements Plugin.

void GenWeightSyst::NormalizeByMeanWeights ( std::string const &  databaseFile)

Requests that weight are normalized by their mean values.

The values are read from the given JSON file, whose location is resolved using FileInPath. Example structure of the file is shown below:

[ { "datasetId": "ttbar-pw_3.1.0_wdo", "meanLHEWeights": [ { "index": 0, "value": 1.0 }, { "index": 4, "value": 0.8726374369 } ] }, ... ]

Here field "datasetId" includes label uniquely identifying the sample as returned by Dataset::GetSourceDatasetID, and indices correspond to GeneratorReader::GetAltWeight.


The documentation for this class was generated from the following files: