10#include <analysis/modules/TrackingSystematics/TrackingEnergyLossCorrection.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/core/ModuleParam.templateDetails.h>
14#include <framework/core/Environment.h>
15#include <analysis/VariableManager/Manager.h>
16#include <analysis/dataobjects/ParticleList.h>
20#include <Math/Vector4D.h>
29 R
"DOC(Module to modify Energy of tracks from the lists. Include in your code as
33 mypath.add_module("TrackingEnergyLossCorrection", particleLists=['pi+:cut'], correction=0.001)
35The module modifies the input particleLists by subtracting the correction value to the track energy and rescaling the momenta
40 addParam(
"correction",
m_correction,
"correction value to be subtracted from the particle energy",
49 B2FATAL(
"It's not allowed to provide both a valid value for the scale parameter and a non-empty table name. Please decide for one of the two options!");
51 B2FATAL(
"Neither a valid value for the scale parameter nor a non-empty table name was provided. Please set (exactly) one of the two options!");
62 for (
const auto& i_variable : variables) {
65 B2FATAL(
"Variable '" << i_variable <<
"' is not available in Variable::Manager!");
78 B2ERROR(
"ParticleList " << iList <<
" not found");
82 size_t nPart = particleList->getListSize();
83 for (
size_t iPart = 0; iPart < nPart; iPart++) {
84 auto particle = particleList->getParticle(iPart);
85 if (particle->getParticleSource() != Particle::EParticleSourceObject::c_Composite and
86 particle->getParticleSource() != Particle::EParticleSourceObject::c_V0 and
87 particle->getParticleSource() != Particle::EParticleSourceObject::c_Track) {
88 B2WARNING(
"particle source " << particle->getParticleSource() <<
89 " is not within the expected values. please check before continuing");
104 std::map<std::string, double> values;
105 for (
const auto& i_variable : variables) {
107 double value = std::get<double>(var->function(particle));
108 values.insert(std::make_pair(i_variable, value));
111 for (
const auto& entry : info) {
122 if (particle->getParticleSource() == Particle::EParticleSourceObject::c_Composite or
123 particle->getParticleSource() == Particle::EParticleSourceObject::c_V0) {
124 for (
auto daughter : particle->getDaughters()) {
131 for (
auto daughter : particle->getDaughters()) {
132 px += daughter->getPx();
133 py += daughter->getPy();
134 pz += daughter->getPz();
135 E += daughter->getEnergy();
137 const ROOT::Math::PxPyPzEVector vec(px, py, pz,
E);
138 particle->set4Vector(vec);
139 }
else if (particle->getParticleSource() == Particle::EParticleSourceObject::c_Track) {
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 > m_ParticleLists
input particle lists
virtual void initialize() override
Initializes the modules and checks the validity of the input parameters.
virtual void event() override
Function to be executed at each event.
double getCorrectionValue(Particle *particle)
Returns the needed correction for particle based on payloadName and correctionName.
TrackingEnergyLossCorrectionModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_payloadName
Name of the table
void setEnergyLossCorrection(Particle *particle)
function to set the Energy correction value
std::unique_ptr< DBObjPtr< ParticleWeightingLookUpTable > > m_ParticleWeightingLookUpTable
Pointer to the table in DB.
double m_correction
input Energy scale modifier
std::string m_correctionName
Name of the correction from table.
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.
TString getInfo(const TObject *obj)
Get object info HTML (e.g.
Abstract base class for different kinds of events.
A variable returning a floating-point value for a given Particle.