10 #include <analysis/modules/ParticleWeighting/ParticleWeightingModule.h>
12 #include <framework/core/ModuleParam.templateDetails.h>
13 #include <analysis/VariableManager/Manager.h>
16 #include <framework/logging/Logger.h>
42 setDescription(
"Weights particles according to LookUp table");
43 addParam(
"tableName", m_tableName,
"ID of table used for reweighing");
44 addParam(
"particleList", m_inputListName,
"Name of the ParticleList to reduce to the best candidates");
51 std::vector<std::string> variables = Variable::Manager::Instance().resolveCollections((
52 *m_ParticleWeightingLookUpTable.get())->getAxesNames());
53 std::map<std::string, double> values;
54 for (
const auto& i_variable : variables) {
57 B2ERROR(
"Variable '" << i_variable <<
"' is not available in Variable::Manager!");
59 values.insert(std::make_pair(i_variable, var->function(p)));
62 return (*m_ParticleWeightingLookUpTable.get())->getInfo(values);
66 void ParticleWeightingModule::initialize()
68 m_particles.isRequired();
69 m_inputList.isRequired(m_inputListName);
70 m_ParticleWeightingLookUpTable = std::make_unique<DBObjPtr<ParticleWeightingLookUpTable>>(m_tableName);
74 void ParticleWeightingModule::event()
77 B2WARNING(
"Input list " << m_inputList.getName() <<
" was not created?");
80 const unsigned int numParticles = m_inputList->getListSize();
81 for (
unsigned int i = 0; i < numParticles; i++) {
82 const Particle* ppointer = m_inputList->getParticle(i);
86 for (
const auto& entry : info) {
87 p->addExtraInfo(m_tableName +
"_" + entry.first, entry.second);
Module to apply weights from the database to particles and store added info in ExtraInfo.
Class to store reconstructed particles.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
std::map< std::string, double > WeightInfo
Weight information: a line from the weight lookup table.
#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.