Belle II Software light-2406-ragdoll
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
12/* Basf2 headers. */
13#include <framework/database/Database.h>
14
15using namespace Belle2;
16
18 const char* lookupTableName) :
19 m_EventMetaData(-1, -1), m_LookupTable(lookupTableName)
20{
21}
22
24{
25}
26
28 std::string variableName, double value)
29{
30 m_Values[variableName] = value;
31}
32
34{
35 if ((experiment != m_EventMetaData.getExperiment()) ||
36 (run != m_EventMetaData.getRun())) {
40 }
41 WeightInfo weightInfo = m_LookupTable->getInfo(m_Values);
42 return weightInfo;
43}
44
46 int experiment, int run)
47{
48 WeightInfo weightInfo = getInfo(experiment, run);
49 PyObject* dictionary = PyDict_New();
50 for (const auto& [name, val] : weightInfo) {
51 PyObject* key = PyUnicode_FromString(name.c_str());
52 PyObject* value = PyFloat_FromDouble(val);
53 PyDict_SetItem(dictionary, key, value);
54 }
55 return dictionary;
56}
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:28
void update()
Updates all objects that are outside their interval of validity.
Definition: DBStore.cc:79
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24