9#include <analysis/modules/VariableToReturnValue/VariableToReturnValueModule.h>
11#include <framework/dataobjects/EventExtraInfo.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/logging/Logger.h>
24 Module(), m_function(nullptr)
27 setDescription(
"Calculate event-based variable specified by the user and sets return value of the module accordingly.");
31 "Variable taken from Variable::Manager, see output of 'basf2 variables.py'.", std::string(
""));
38 B2ERROR(
"Variable '" <<
m_variable <<
"' is not available in Variable::Manager!");
47 if (std::holds_alternative<double>(
m_function(
nullptr))) {
48 returnValue = std::get<double>(
m_function(
nullptr));
49 }
else if (std::holds_alternative<int>(
m_function(
nullptr))) {
50 returnValue = std::get<int>(
m_function(
nullptr));
51 }
else if (std::holds_alternative<bool>(
m_function(
nullptr))) {
52 returnValue = std::get<bool>(
m_function(
nullptr));
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setReturnValue(int value)
Sets the return value for this module as integer.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
virtual void initialize() override
Initialize.
virtual void event() override
Method called for each event.
std::string m_variable
variable name (module parameter)
Variable::Manager::FunctionPtr m_function
function pointer corresponding to given variable.
VariableToReturnValueModule()
Constructor.
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.