12 #include <boost/program_options.hpp>
23 using boost::program_options::bool_switch;
27 auto opt = desc.add_options();
29 "Select particle transverse distance to the origin in mm");
31 "Select particle absolute longitudinal distance to the origin in mm");
33 "Select particle direction angle in the transverse plane in degree");
35 "Select particle pseudo-rapidity");
37 "Select particle absolute pseudo-rapidity");
39 "Select particle transverse momentum in GeV");
40 opt(
"remove-charged", bool_switch(),
"Remove charged particles");
41 opt(
"remove-neutral", bool_switch(),
"Remove neutral particles");
46 using namespace Acts::UnitLiterals;
49 auto extractInterval = [&](
const char*
name,
auto unit,
auto& lower,
51 if (vars[
name].empty()) {
55 lower = interval.
lower.value_or(lower) * unit;
56 upper = interval.upper.value_or(upper) * unit;
60 extractInterval(
"select-rho-mm", 1
_mm, cfg.rhoMin, cfg.rhoMax);
61 extractInterval(
"select-absz-mm", 1
_mm, cfg.absZMin, cfg.absZMax);
62 extractInterval(
"select-phi-degree", 1_degree, cfg.phiMin, cfg.phiMax);
63 extractInterval(
"select-eta", 1.0, cfg.etaMin, cfg.etaMax);
64 extractInterval(
"select-abseta", 1.0, cfg.absEtaMin, cfg.absEtaMax);
65 extractInterval(
"select-pt-gev", 1
_GeV, cfg.ptMin, cfg.ptMax);
66 cfg.removeCharged = vars[
"remove-charged"].as<
bool>();
67 cfg.removeNeutral = vars[
"remove-neutral"].as<
bool>();
75 throw std::invalid_argument(
"Missing input event collection");
78 throw std::invalid_argument(
"Missing output event collection");
98 using SimEvent = std::vector<SimVertex>;
101 const auto& input = ctx.
eventStore.
get<SimEvent>(m_cfg.inputEvent);
104 auto within = [](
double x,
double min,
double max) {
105 return (min <= x) and (x <
max);
112 const bool validNeutral = (
p.charge() == 0) and not m_cfg.removeNeutral;
113 const bool validCharged = (
p.charge() != 0) and not m_cfg.removeCharged;
114 const bool validCharge = validNeutral or validCharged;
115 return validCharge and
116 within(
p.transverseMomentum(), m_cfg.ptMin, m_cfg.ptMax) and
117 within(
std::abs(
eta), m_cfg.absEtaMin, m_cfg.absEtaMax) and
118 within(
eta, m_cfg.etaMin, m_cfg.etaMax) and
119 within(phi, m_cfg.phiMin, m_cfg.phiMax) and
120 within(
std::abs(
p.position().z()), m_cfg.absZMin, m_cfg.absZMax) and
121 within(rho, m_cfg.rhoMin, m_cfg.rhoMax);
124 std::size_t allParticles = 0;
125 std::size_t selectedParticles = 0;
127 selected.reserve(input.size());
128 for (
const auto& inputVertex : input) {
129 allParticles += inputVertex.incoming.size();
130 allParticles += inputVertex.outgoing.size();
132 SimVertex vertex(inputVertex.position4, inputVertex.process);
134 std::copy_if(inputVertex.incoming.begin(), inputVertex.incoming.end(),
135 std::back_inserter(vertex.
incoming), isValidParticle);
136 std::copy_if(inputVertex.outgoing.begin(), inputVertex.outgoing.end(),
137 std::back_inserter(vertex.
outgoing), isValidParticle);
144 selectedParticles += vertex.
incoming.size();
145 selectedParticles += vertex.
outgoing.size();
146 selected.push_back(std::move(vertex));
150 <<
" from " << allParticles <<
" particles");