9#include <analysis/modules/SignalSideVariablesToExtraInfo/SignalSideVariablesToExtraInfoModule.h>
10#include <framework/core/ModuleParam.templateDetails.h>
11#include <framework/datastore/StoreArray.h>
13#include <analysis/dataobjects/Particle.h>
14#include <analysis/dataobjects/RestOfEvent.h>
30 setDescription(
"The module writes property (value of specified variable) of single particle\n"
31 "found in the input ParticleList as an ExtraInfo to the Particle related to\n"
32 "the current ROE. This module is intended to be executed only in for_each ROE\n"
36 std::map<std::string, std::string> emptymap;
38 "This list should either contain at most 1 particle or all requested variables should be event-based.",
41 "Dictionary of variables and extraInfo names to save in the extra-info field.",
53 B2ERROR(
"Variable '" << pair.first <<
"' is not available in Variable::Manager!");
66 unsigned int n = plist->getListSize();
72 B2WARNING(
"Input ParticleList " <<
m_particleListName <<
" contains more than 1 particle. plist.size = " << n);
76 auto* signalSide = roe->getRelatedFrom<
Particle>();
79 for (
unsigned int iVar = 0; iVar < nVars; iVar++) {
81 B2WARNING(
"Extra info with given name " <<
m_extraInfoNames[iVar] <<
" already set, I won't set it again.");
83 double value = std::numeric_limits<double>::quiet_NaN();
84 auto var_result =
m_functions[iVar](plist->getParticle(0));
85 if (std::holds_alternative<double>(var_result)) {
86 value = std::get<double>(var_result);
87 }
else if (std::holds_alternative<int>(var_result)) {
88 value = std::get<int>(var_result);
89 }
else if (std::holds_alternative<bool>(var_result)) {
90 value = std::get<bool>(var_result);
void setDescription(const std::string &description)
Sets the description of the module.
Class to store reconstructed particles.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
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.