9#include <analysis/modules/VariablesToExtraInfo/VariablesToExtraInfoModule.h>
11#include <framework/logging/Logger.h>
12#include <framework/core/ModuleParam.templateDetails.h>
21 setDescription(
"For each particle in the input list the selected variables are saved in an extra-info field with the given name. Can be used when wanting to save variables before modifying them, e.g. when performing vertex fits.");
24 std::map<std::string, std::string> emptymap;
27 "Dictionary of variables and extraInfo names to save in the extra-info field.\n"
28 "Variables are taken from Variable::Manager, and are identical to those available to e.g. ParticleSelector.",
30 addParam(
"decayString",
m_decayString,
"DecayString specifying the daughter Particle to be included in the ParticleList",
33 "-1/0/1/2: Overwrite if lower / don't overwrite / overwrite if higher / always overwrite, in case if extra info with given name already exists",
37VariablesToExtraInfoModule::~VariablesToExtraInfoModule() =
default;
48 B2ERROR(
"Variable '" << pair.first <<
"' is not available in Variable::Manager!");
60 B2ERROR(
"VariablesToExtraInfoModule::initialize Invalid Decay Descriptor: " <<
m_decayString);
67 B2WARNING(
"Input list " <<
m_inputList.getName() <<
" was not created?");
71 const unsigned int numParticles =
m_inputList->getListSize();
72 for (
unsigned int i = 0; i < numParticles; i++) {
79 for (
auto& selparticle : selparticles) {
90 for (
unsigned int iVar = 0; iVar < nVars; iVar++) {
91 double value = std::numeric_limits<double>::quiet_NaN();
92 if (std::holds_alternative<double>(
m_functions[iVar](source))) {
93 value = std::get<double>(
m_functions[iVar](source));
94 }
else if (std::holds_alternative<int>(
m_functions[iVar](source))) {
96 }
else if (std::holds_alternative<bool>(
m_functions[iVar](source))) {
108 B2WARNING(
"Extra info with given name " <<
m_extraInfoNames[iVar] <<
" already set, I won't set it again.");
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class to store reconstructed particles.
void setExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
double getExtraInfo(const std::string &name) const
Return given value if set.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.