10 #include <analysis/modules/ParticleSelector/ParticleSelectorModule.h>
13 #include <framework/logging/Logger.h>
16 #include <analysis/dataobjects/Particle.h>
38 setDescription(
"Removes Particles from given ParticleList that do not pass specified selection criteria.");
40 setPropertyFlags(c_ParallelProcessingCertified);
42 addParam(
"decayString", m_decayString,
43 "Input ParticleList name (see :ref:`DecayString`).");
45 addParam(
"cut", m_cutParameter,
46 "Selection criteria to be applied, see `cut_strings_selections`",
50 void ParticleSelectorModule::initialize()
53 bool valid = m_decaydescriptor.init(m_decayString);
55 B2ERROR(
"ParticleSelectorModule::initialize Invalid input DecayString: " << m_decayString);
57 int nProducts = m_decaydescriptor.getNDaughters();
59 B2ERROR(
"ParticleSelectorModule::initialize Invalid input DecayString " << m_decayString
60 <<
". DecayString should not contain any daughters, only the mother particle.");
65 const int pdgCode = mother->getPDGCode();
66 string listLabel = mother->getLabel();
67 m_listName = mother->getFullName();
71 if (Const::finalStateParticlesSet.contains(
Const::ParticleType(abs(pdgCode))) and listLabel ==
"all"
72 and not(abs(pdgCode) == Const::photon.getPDGCode() and m_cutParameter ==
"isFromECL")) {
73 B2FATAL(
"You are trying to apply a cut on the list " << m_listName <<
74 " but the label 'all' is protected for lists of final-state particles." <<
75 " It could introduce *very* dangerous bugs.");
76 }
else if (listLabel ==
"MC" or listLabel ==
"V0") {
78 B2FATAL(
"You are trying to apply a cut on the list " << m_listName <<
79 " but the label " << listLabel <<
" is protected and can not be reduced.");
82 m_particleList.isRequired(m_listName);
84 m_cut = Variable::Cut::compile(m_cutParameter);
86 B2INFO(
"ParticleSelector: " << m_listName);
87 B2INFO(
" -> With cuts : " << m_cutParameter);
90 void ParticleSelectorModule::event()
93 if (!m_cutParameter.empty()) {
94 std::vector<unsigned int> toRemove;
95 unsigned int n = m_particleList->getListSize();
96 for (
unsigned i = 0; i < n; i++) {
97 const Particle* part = m_particleList->getParticle(i);
98 if (!m_cut->check(part)) toRemove.push_back(part->getArrayIndex());
100 m_particleList->removeParticles(toRemove);
The ParticleType class for identifying different particle types.
Represents a particle in the DecayDescriptor.
Loops over all Particles in the ParticleList and removes those Particles from the ParticleList that d...
Class to store reconstructed particles.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.