9#include <analysis/modules/VariablesToEventExtraInfo/VariablesToEventExtraInfoModule.h>
11#include <framework/logging/Logger.h>
12#include <framework/core/ModuleParam.templateDetails.h>
13#include <framework/datastore/StoreArray.h>
22 setDescription(
"For each particle in the input list the selected variables are saved in an event-extra-info field with the given name. Can be used to save MC truth information, for example, in a ntuple of reconstructed particles.");
25 std::map<std::string, std::string> emptymap;
28 "Dictionary of variables and extraInfo names to save in the event-extra-info field.\n"
29 "Variables are taken from Variable::Manager, and are identical to those available to e.g. ParticleSelector.",
32 "-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",
36VariablesToEventExtraInfoModule::~VariablesToEventExtraInfoModule() =
default;
47 B2ERROR(
"Variable '" << pair.first <<
"' is not available in Variable::Manager!");
59 B2WARNING(
"Input list " <<
m_inputList.getName() <<
" was not created?");
63 const unsigned int numParticles =
m_inputList->getListSize();
64 for (
unsigned int i = 0; i < numParticles; i++) {
76 for (
unsigned int iVar = 0; iVar < nVars; iVar++) {
77 double value = std::numeric_limits<double>::quiet_NaN();
78 if (std::holds_alternative<double>(
m_functions[iVar](source))) {
79 value = std::get<double>(
m_functions[iVar](source));
80 }
else if (std::holds_alternative<int>(
m_functions[iVar](source))) {
82 }
else if (std::holds_alternative<bool>(
m_functions[iVar](source))) {
95 B2WARNING(
"Extra info with given name " <<
m_extraInfoNames[iVar] <<
" already set, I won't set it again.");
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.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
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.