10#include <analysis/modules/BiasCorrection/BiasCorrection.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/core/ModuleParam.templateDetails.h>
15#include <framework/core/Environment.h>
16#include <analysis/VariableManager/Manager.h>
18#include <Math/Vector4D.h>
37 R
"DOC(Module to modify energy from the lists. Include in your code as
41 mypath.add_module("EnergyBiasCorrection", particleLists=['gamma:cut'], scale=tableName_Weight)
43The module modifies the input particleLists by scaling energy as given by the scale in the LookUpTable
56 std::map<std::string, double> values;
57 for (
const auto& i_variable : variables) {
60 B2ERROR(
"Variable '" << i_variable <<
"' is not available in Variable::Manager!");
62 values.insert(std::make_pair(i_variable, std::get<double>(var->function(particle))));
73 B2ERROR(
"Attempting to run EnergyBiasCorrection on MC but this is only for data");
92 B2ERROR(
"ParticleList " << iList <<
" not found");
96 size_t nPart = particleList->getListSize();
97 for (
size_t iPart = 0; iPart < nPart; iPart++) {
98 auto particle = particleList->getParticle(iPart);
107 if (particle->getParticleSource() == Particle::EParticleSourceObject::c_Composite) {
108 for (
auto daughter : particle->getDaughters()) {
116 for (
auto daughter : particle->getDaughters()) {
117 px += daughter->getPx();
118 py += daughter->getPy();
119 pz += daughter->getPz();
120 E += daughter->getEnergy();
122 const ROOT::Math::PxPyPzEVector vec(px, py, pz,
E);
123 particle->set4Vector(vec);
124 }
else if (particle->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster
128 for (
const auto& entry : info) {
129 particle->writeExtraInfo(
m_tableName +
"_" + entry.first, entry.second);
131 particle->setMomentumScalingFactor(particle->getExtraInfo(
m_tableName +
"_Weight"));
132 particle->updateJacobiMatrix();
134 B2DEBUG(10,
"Called setMomentumScalingFactor for an unspecified, track-based or KLM cluster-based particle");
int getPDGCode() const
PDG code.
static const ParticleType photon
photon particle
std::vector< std::string > m_ParticleLists
input particle lists
void setEnergyScalingFactor(Particle *particle)
function to set scaling factor
virtual void event() override
Function to be executed at each event.
WeightInfo getInfo(const Particle *particle)
Get LookUp information for the particle.
std::unique_ptr< DBObjPtr< ParticleWeightingLookUpTable > > m_ParticleWeightingLookUpTable
Pointer to the table in DB.
virtual void beginRun() override
Nothing so far.
std::string m_tableName
Name of the table.
EnergyBiasCorrectionModule()
Constructor: Sets the description, the properties and the parameters of the module.
static Environment & Instance()
Static method to get a reference to the Environment instance.
void setDescription(const std::string &description)
Sets the description of the module.
Class to store reconstructed particles.
Type-safe access to single objects in the data store.
std::vector< std::string > resolveCollections(const std::vector< std::string > &variables)
Resolve Collection Returns variable names corresponding to the given collection or if it is not a col...
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
std::map< std::string, double > WeightInfo
Weight information: a line from the weight lookup table.
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.