23 throw std::invalid_argument(
"Missing input collection");
26 throw std::invalid_argument(
"Missing output collection");
32 std::vector<VertexAndTracks> selected;
36 ctx.
eventStore.
get<std::vector<VertexAndTracks>>(m_cfg.input);
38 auto within = [](
double x,
double min,
double max) {
39 return (min <= x) and (x <
max);
41 auto isValidTrack = [&](
const auto& trk) {
42 auto rho = std::hypot(trk.position().x(), trk.position().y());
43 auto phi = std::atan2(trk.momentum().y(), trk.momentum().x());
44 auto eta = std::atanh(trk.momentum().z() / trk.momentum().norm());
45 auto pt = std::hypot(trk.momentum().x(), trk.momentum().y());
46 return within(rho, 0, m_cfg.rhoMax) and
47 within(
std::abs(trk.position().z()), 0, m_cfg.absZMax) and
48 within(phi, m_cfg.phiMin, m_cfg.phiMax) and
49 within(eta, m_cfg.etaMin, m_cfg.etaMax) and
50 within(
std::abs(eta), m_cfg.absEtaMin, m_cfg.absEtaMax) and
51 within(pt, m_cfg.ptMin, m_cfg.ptMax) and
52 (m_cfg.keepNeutral or (trk.charge() != 0));
55 for (
const auto& vertexAndTracks : input) {
57 sel.
vertex = vertexAndTracks.vertex;
60 std::copy_if(vertexAndTracks.tracks.begin(), vertexAndTracks.tracks.end(),
61 std::back_inserter(sel.
tracks), isValidTrack);
63 if (not sel.
tracks.empty()) {
64 selected.push_back(std::move(sel));
69 <<
" from " << input.size() <<
" vertices.");