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>
18#include <Math/Vector4D.h>
27 R
"DOC(Module to remove tracks from the lists at random. Include in your code as
31 mypath.add_module("TrackingEfficiency", particleLists=['pi+:cut'], frac=0.01)
33The 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 <int, bool> sourceToRemove;
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 mdstSource = particle->getMdstSource();
66 if (sourceToRemove.find(mdstSource) != sourceToRemove.end()) {
68 remove = sourceToRemove.at(mdstSource);
71 auto prob = gRandom->Uniform();
73 sourceToRemove.insert(std::pair{mdstSource, 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.
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
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.