10#include <analysis/modules/TrackingSystematics/TrackingEfficiency.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/core/ModuleParam.templateDetails.h>
14#include <analysis/VariableManager/Manager.h>
15#include <analysis/dataobjects/ParticleList.h>
19#include <Math/Vector4D.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)
34The 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);
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.
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.
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.