Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:01

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
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 }  // namespace detail
0049 
0050 using SimBarcode = ::ActsFatras::Barcode;
0051 using SimParticle = ::ActsFatras::Particle;
0052 /// Store particles ordered by particle identifier.
0053 using SimBarcodeContainer = ::boost::container::flat_set<SimBarcode>;
0054 using SimParticleContainer =
0055     ::boost::container::flat_set<SimParticle, detail::CompareParticleId>;
0056 
0057 /// Iterate over groups of particles belonging to the same primary vertex.
0058 inline GroupBy<SimParticleContainer::const_iterator,
0059                detail::PrimaryVertexIdGetter>
0060 groupByPrimaryVertex(const SimParticleContainer& container) {
0061   return makeGroupBy(container, detail::PrimaryVertexIdGetter());
0062 }
0063 
0064 /// Iterate over groups of particles belonging to the same secondary vertex.
0065 ///
0066 /// For each primary vertex, this yields one group of particles belonging
0067 /// directly to the primary vertex (secondary vertex id 0) and a group for
0068 /// each secondary vertex.
0069 inline GroupBy<SimParticleContainer::const_iterator,
0070                detail::SecondaryVertexIdGetter>
0071 groupBySecondaryVertex(const SimParticleContainer& container) {
0072   return makeGroupBy(container, detail::SecondaryVertexIdGetter());
0073 }
0074 
0075 }  // namespace ActsExamples