Skip to content

Commit

Permalink
feat: Add ability to remove secondaries in ParticleSelector (#2265)
Browse files Browse the repository at this point in the history
Allows to filter secondary particles with `ParticleSelector`

blocked by
- #2266
  • Loading branch information
andiwand committed Jul 5, 2023
1 parent 260bc5a commit ccbed15
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
<< ")");
ACTS_DEBUG("remove charged particles " << m_cfg.removeCharged);
ACTS_DEBUG("remove neutral particles " << m_cfg.removeNeutral);
ACTS_DEBUG("remove secondary particles " << m_cfg.removeSecondaries);
}

ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
Expand All @@ -65,7 +66,8 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
const bool validNeutral = (p.charge() == 0) and not m_cfg.removeNeutral;
const bool validCharged = (p.charge() != 0) and not m_cfg.removeCharged;
const bool validCharge = validNeutral or validCharged;
return validCharge and
const bool validSecondary = not m_cfg.removeSecondaries or !p.isSecondary();
return validCharge and validSecondary and
within(p.transverseMomentum(), m_cfg.ptMin, m_cfg.ptMax) and
within(std::abs(eta), m_cfg.absEtaMin, m_cfg.absEtaMax) and
within(eta, m_cfg.etaMin, m_cfg.etaMax) and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class ParticleSelector final : public IAlgorithm {
bool removeCharged = false;
/// Remove neutral particles.
bool removeNeutral = false;

/// Remove secondaries.
bool removeSecondaries = false;
};

ParticleSelector(const Config& config, Acts::Logging::Level level);
Expand Down
4 changes: 3 additions & 1 deletion Examples/Python/python/acts/examples/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
"m", # (min,max)
"removeCharged", # bool
"removeNeutral", # bool
"removeSecondaries", # bool
],
defaults=[(None, None)] * 8 + [None] * 2,
defaults=[(None, None)] * 8 + [None] * 3,
)


Expand Down Expand Up @@ -371,6 +372,7 @@ def addParticleSelection(
mMax=config.m[1],
removeCharged=config.removeCharged,
removeNeutral=config.removeNeutral,
removeSecondaries=config.removeSecondaries,
),
level=customLogLevel(),
inputParticles=inputParticles,
Expand Down
1 change: 1 addition & 0 deletions Examples/Python/src/TruthTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void addTruthTracking(Context& ctx) {
ACTS_PYTHON_MEMBER(ptMax);
ACTS_PYTHON_MEMBER(removeCharged);
ACTS_PYTHON_MEMBER(removeNeutral);
ACTS_PYTHON_MEMBER(removeSecondaries);
ACTS_PYTHON_STRUCT_END();

pythonRangeProperty(c, "rho", &Config::rhoMin, &Config::rhoMax);
Expand Down

0 comments on commit ccbed15

Please sign in to comment.