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