10 #include <analysis/modules/TrackingSystematics/TrackingSystematics.h>
13 #include <analysis/dataobjects/ParticleList.h>
15 #include <framework/datastore/StoreObjPtr.h>
28 R
"DOC(Module to remove tracks from the lists at random. Include in your code as
32 mypath.add_module("TrackingEfficiency", particleLists=['pi+:cut'], frac=0.01)
34 The module modifies the input particleLists by randomly removing tracks with the probability frac.
39 addParam(
"frac",
m_frac,
"probability to remove the particle", 0.0);
45 std::map <unsigned, bool> indexToRemove;
52 B2ERROR(
"ParticleList " << iList <<
" not found");
57 B2ERROR(
"The provided particlelist " << iList <<
" does not contain track-based particles.");
60 std::vector<unsigned int> toRemove;
61 size_t nPart = particleList->getListSize();
62 for (
size_t iPart = 0; iPart < nPart; iPart++) {
63 auto particle = particleList->getParticle(iPart);
64 unsigned mdstIndex = particle->getMdstArrayIndex();
66 if (indexToRemove.find(mdstIndex) != indexToRemove.end()) {
68 remove = indexToRemove.at(mdstIndex);
71 auto prob = gRandom->Uniform();
73 indexToRemove.insert(std::pair{mdstIndex, remove});
75 if (remove) toRemove.push_back(particle->getArrayIndex());
77 particleList->removeParticles(toRemove);
84 R
"DOC(Module to modify momentum of tracks from the lists. Include in your code as
88 mypath.add_module("TrackingMomentum", particleLists=['pi+:cut'], scale=0.999)
90 The module modifies the input particleLists by scaling track momenta as given by the parameter scale
94 addParam(
"particleLists", m_ParticleLists,
"input particle lists");
95 addParam(
"scale", m_scale,
"scale factor to be applied to 3-momentum", 0.999);
105 B2ERROR(
"ParticleList " << iList <<
" not found");
109 size_t nPart = particleList->getListSize();
110 for (
size_t iPart = 0; iPart < nPart; iPart++) {
111 auto particle = particleList->getParticle(iPart);
119 if (particle->getParticleSource() == Particle::EParticleSourceObject::c_Composite or
120 particle->getParticleSource() == Particle::EParticleSourceObject::c_V0) {
121 for (
auto daughter : particle->getDaughters()) {
128 for (
auto daughter : particle->getDaughters()) {
129 px += daughter->getPx();
130 py += daughter->getPy();
131 pz += daughter->getPz();
132 E += daughter->getEnergy();
134 const TLorentzVector vec(px, py, pz, E);
135 particle->set4Vector(vec);
136 }
else if (particle->getParticleSource() == Particle::EParticleSourceObject::c_Track) {
137 particle->setMomentumScalingFactor(
m_scale);
The ParticleType class for identifying different particle types.
static const ParticleSet chargedStableSet
set of charged stable particles
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 event() override
Function to be executed at each event.
double m_frac
fraction of particles to be removed from the particlelist
TrackingEfficiencyModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::vector< std::string > m_ParticleLists
input particle lists
virtual void event() override
Function to be executed at each event.
void setMomentumScalingFactor(Particle *particle)
function to set momentum scaling factor
double m_scale
input momentum scale modifier
TrackingMomentumModule()
Constructor: Sets the description, the properties and the parameters of the module.
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.