File indexing completed on 2025-01-18 09:28:01
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "ActsExamples/Utilities/GroupBy.hpp"
0012 #include "ActsFatras/EventData/Particle.hpp"
0013
0014 #include <boost/container/flat_set.hpp>
0015
0016 namespace ActsExamples {
0017 namespace detail {
0018 struct CompareParticleId {
0019 using is_transparent = void;
0020 constexpr bool operator()(const ActsFatras::Particle& lhs,
0021 const ActsFatras::Particle& rhs) const {
0022 return lhs.particleId() < rhs.particleId();
0023 }
0024 constexpr bool operator()(ActsFatras::Barcode lhs,
0025 const ActsFatras::Particle& rhs) const {
0026 return lhs < rhs.particleId();
0027 }
0028 constexpr bool operator()(const ActsFatras::Particle& lhs,
0029 ActsFatras::Barcode rhs) const {
0030 return lhs.particleId() < rhs;
0031 }
0032 };
0033 struct PrimaryVertexIdGetter {
0034 constexpr ActsFatras::Barcode operator()(
0035 const ActsFatras::Particle& particle) const {
0036 return ActsFatras::Barcode(0u).setVertexPrimary(
0037 particle.particleId().vertexPrimary());
0038 }
0039 };
0040 struct SecondaryVertexIdGetter {
0041 constexpr ActsFatras::Barcode operator()(
0042 const ActsFatras::Particle& particle) const {
0043 return ActsFatras::Barcode(0u)
0044 .setVertexPrimary(particle.particleId().vertexPrimary())
0045 .setVertexSecondary(particle.particleId().vertexSecondary());
0046 }
0047 };
0048 }
0049
0050 using SimBarcode = ::ActsFatras::Barcode;
0051 using SimParticle = ::ActsFatras::Particle;
0052
0053 using SimBarcodeContainer = ::boost::container::flat_set<SimBarcode>;
0054 using SimParticleContainer =
0055 ::boost::container::flat_set<SimParticle, detail::CompareParticleId>;
0056
0057
0058 inline GroupBy<SimParticleContainer::const_iterator,
0059 detail::PrimaryVertexIdGetter>
0060 groupByPrimaryVertex(const SimParticleContainer& container) {
0061 return makeGroupBy(container, detail::PrimaryVertexIdGetter());
0062 }
0063
0064
0065
0066
0067
0068
0069 inline GroupBy<SimParticleContainer::const_iterator,
0070 detail::SecondaryVertexIdGetter>
0071 groupBySecondaryVertex(const SimParticleContainer& container) {
0072 return makeGroupBy(container, detail::SecondaryVertexIdGetter());
0073 }
0074
0075 }