Belle II Software development
PostProcessingParticleWeighting.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* Own header. */
10#include <analysis/utility/PostProcessingParticleWeighting.h>
11
12using namespace Belle2;
13
15 const char* lookupTableName) :
16 m_EventMetaData(-1, -1), m_LookupTable(lookupTableName)
17{
18}
19
21{
22}
23
25 std::string variableName, double value)
26{
27 m_Values[variableName] = value;
28}
29
31{
32 if ((experiment != m_EventMetaData.getExperiment()) ||
33 (run != m_EventMetaData.getRun())) {
37 }
38 WeightInfo weightInfo = m_LookupTable->getInfo(m_Values);
39 return weightInfo;
40}
41
43 int experiment, int run)
44{
45 WeightInfo weightInfo = getInfo(experiment, run);
46 PyObject* dictionary = PyDict_New();
47 for (const auto& [name, val] : weightInfo) {
48 PyObject* key = PyUnicode_FromString(name.c_str());
49 PyObject* value = PyFloat_FromDouble(val);
50 PyDict_SetItem(dictionary, key, value);
51 }
52 return dictionary;
53}
void setExperiment(int experiment)
Experiment Setter.
Definition: EventMetaData.h:73
int getRun() const
Run Getter.
void setRun(int run)
Run Setter.
Definition: EventMetaData.h:61
int getExperiment() const
Experiment Getter.
void setValue(std::string variableName, double value)
Set value.
PyObject * getInfoPython(int experiment, int run)
Get weight information (Python).
std::map< std::string, double > m_Values
Values.
PostProcessingParticleWeighting(const char *lookupTableName)
Constructor.
WeightInfo getInfo(int experiment, int run)
Get weight information.
DBObjPtr< ParticleWeightingLookUpTable > m_LookupTable
Lookup table.
std::map< std::string, double > WeightInfo
Weight information: a line from the weight lookup table.
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:26
void update()
Updates all objects that are outside their interval of validity.
Definition: DBStore.cc:77
Abstract base class for different kinds of events.