9 #include <generators/modules/RemoveMCParticlesModule.h>
11 #include <framework/logging/Logger.h>
12 #include <framework/gearbox/Unit.h>
13 #include <framework/datastore/StoreArray.h>
28 inline bool alwaysCut(
double min,
double max,
double value)
30 return (value < min || value >= max);
33 inline bool optionalCut(
double min,
double max,
double value)
35 if (min < max)
return (value < min || value >= max);
44 Remove particles from the MCParticle Collection.
47 At the moment, Relations to that MCParticle collection will become invalid
48 and are not fixed automatically
54 "Minimum Z value of Particles to be kept. If bigger or equal to maxZ, no cut on z is performed", 0.0);
56 "Maximum Z value of Particles to be kept. If smaller or equal to minZ, no cut on z is performed", 0.0);
58 "Minimum Rphi value of Particles to be kept. If bigger or equal to maxR, no cut on Rphi is performed", 0.0);
60 "Maximum Rphi value of Particles to be kept. If smaller or equal to minR, no cut on Rphi is performed", 0.0);
62 "Minimum theta value of Particles to be kept", 0.0);
64 "Maximum theta value of Particles to be kept", 180.0);
66 "Minimum Pt value of Particles to be kept. If bigger or equal to maxPt, no cut on Pt is performed", 0.0);
68 "Maximum Pt value of Particles to be kept. If smaller or equal to minPt, no cut on Pt is performed", 0.0);
70 "If true, all children of a particle are removed together with the particle, otherwise children are kept",
true);
72 "If not empty, cuts will only be performed on particles matching the given PDG codes. "
73 "To remove all particles with a given code just set maxTheta to 0 and fill this list "
91 B2WARNING(
"No MCParticle collection with name \"" <<
m_particleList <<
"\", cannot remove anything");
102 for (
unsigned i = 0; i < nPart; ++i) {
123 cut |= optionalCut(
m_minZ,
m_maxZ, particle.getProductionVertex().Z());
124 cut |= optionalCut(
m_minR,
m_maxR, particle.getProductionVertex().Rho());
125 cut |= optionalCut(
m_minPt,
m_maxPt, particle.getMomentum().Rho());
130 if (cut)
m_mpg[particle.getArrayIndex()].setIgnore(
true);
133 for (
MCParticle* daughter : particle.getDaughters()) {
@ c_clearParticles
Clear the particle list before adding the graph.
void loadList(const std::string &name="")
Load the MCParticle list given by name into the Graph.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
A Class to store the Monte Carlo particle information.
void setDescription(const std::string &description)
Sets the description of the module.
void applyCuts(const MCParticle &particle, bool cut=false)
Apply cuts on a Particle and call for all daugthers recursively.
double m_maxTheta
Maximum Theta value of particles to keep.
virtual void initialize() override
Initializes the module.
virtual void event() override
Method is called for each event.
double m_minR
Minimum Rphi value of particles to keep.
virtual void terminate() override
Terminates the module.
double m_maxZ
Maximum Z value of particles to keep.
bool m_alsoChildren
If true, also remove all children of a particle if it fails any cut.
double m_minZ
Minimum Z value of particles to keep.
double m_minTheta
Minimum Theta value of particles to keep.
double m_minPt
Minimum Pt value of particles to keep.
std::string m_particleList
Name of the MCParticle collection to work on.
std::vector< int > m_pdgCodes
List of pdgCodes wo apply cuts on.
double m_maxPt
Maximum Pt value of particles to keep.
MCParticleGraph m_mpg
ParticleGraph used for reformatting MCParticle collection.
double m_maxR
Maximum Rphi value of particles to keep.
RemoveMCParticlesModule()
Constructor.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
int getEntries() const
Get the number of objects in the array.
static const double deg
degree to radians
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
MCParticle * getMother() const
Returns a pointer to the mother particle.
void clear()
Reset particles and decay information to make the class reusable.
Abstract base class for different kinds of events.