10#include <analysis/modules/TrackingSystematics/TrackingEfficiency.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/core/ModuleParam.templateDetails.h>
14#include <analysis/dataobjects/ParticleList.h>
17#include <Math/Vector4D.h>
29 R
"DOC(Module to remove tracks from the lists at random. Include in your code as
33 mypath.add_module("TrackingEfficiency", particleLists=['pi+:cut'], frac=0.01)
35The module modifies the input particleLists by randomly removing tracks with the probability frac.
41 addParam(
"frac",
m_frac,
"probability to remove the particle", 0.0);
47 std::map <int, bool> sourceToRemove;
54 B2ERROR(
"ParticleList " << iList <<
" not found");
59 B2ERROR(
"The provided particlelist " << iList <<
" does not contain track-based particles.");
62 std::vector<unsigned int> toRemove;
63 size_t nPart = particleList->getListSize();
64 for (
size_t iPart = 0; iPart < nPart; iPart++) {
65 auto particle = particleList->getParticle(iPart);
66 unsigned mdstSource = particle->getMdstSource();
68 if (sourceToRemove.find(mdstSource) != sourceToRemove.end()) {
70 remove = sourceToRemove.at(mdstSource);
73 auto prob = gRandom->Uniform();
75 sourceToRemove.insert(std::pair{mdstSource, remove});
77 if (remove) toRemove.push_back(particle->getArrayIndex());
79 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.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Type-safe access to single objects in the data store.
std::vector< std::string > m_ParticleLists
input particle lists
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.