Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:18

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/EventData/SpacePointData.hpp"
0014 #include "Acts/EventData/SpacePointProxy.hpp"
0015 #include "Acts/EventData/Utils.hpp"
0016 #include "Acts/Utilities/Holders.hpp"
0017 #include "Acts/Utilities/detail/ContainerIterator.hpp"
0018 
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 struct SpacePointContainerConfig {
0024   bool useDetailedDoubleMeasurementInfo = false;
0025 
0026   bool isInInternalUnits = true;
0027 };
0028 
0029 struct SpacePointContainerOptions {
0030   // location of beam in x,y plane.
0031   // used as offset for Space Points
0032   Acts::Vector2 beamPos{0 * Acts::UnitConstants::mm,
0033                         0 * Acts::UnitConstants::mm};
0034 
0035   bool isInInternalUnits = true;
0036 };
0037 
0038 template <typename container_t, template <typename> class holder_t>
0039 class SpacePointContainer {
0040  public:
0041   friend class Acts::SpacePointProxy<
0042       Acts::SpacePointContainer<container_t, holder_t>>;
0043 
0044  public:
0045   using SpacePointProxyType =
0046       Acts::SpacePointProxy<Acts::SpacePointContainer<container_t, holder_t>>;
0047 
0048   using iterator = detail::ContainerIterator<
0049       Acts::SpacePointContainer<container_t, holder_t>, SpacePointProxyType&,
0050       std::size_t, false>;
0051   using const_iterator = detail::ContainerIterator<
0052       Acts::SpacePointContainer<container_t, holder_t>,
0053       const SpacePointProxyType&, std::size_t, true>;
0054 
0055   using ValueType = typename container_t::ValueType;
0056   using ProxyType = SpacePointProxyType;
0057   using value_type = ProxyType;
0058   using size_type = std::size_t;
0059 
0060  public:
0061   // Constructors
0062   // It makes sense to support both options of
0063   // taking or not the ownership
0064 
0065   // Do not take ownership
0066   // Activate only if holder_t is RefHolder
0067   template <template <typename> class H = holder_t,
0068             typename = std::enable_if_t<Acts::detail::is_same_template<
0069                 H, Acts::detail::RefHolder>::value>>
0070   SpacePointContainer(const Acts::SpacePointContainerConfig& config,
0071                       const Acts::SpacePointContainerOptions& options,
0072                       const container_t& container);
0073 
0074   // Take the ownership
0075   // Activate only if holder_t is ValueHolder
0076   template <template <typename> class H = holder_t,
0077             typename = std::enable_if_t<Acts::detail::is_same_template<
0078                 H, Acts::detail::ValueHolder>::value>>
0079   SpacePointContainer(const Acts::SpacePointContainerConfig& config,
0080                       const Acts::SpacePointContainerOptions& options,
0081                       container_t&& container);
0082 
0083   // No copy operations
0084   SpacePointContainer(SpacePointContainer& other) = delete;
0085   SpacePointContainer& operator=(SpacePointContainer& other) = delete;
0086 
0087   // move operations
0088   SpacePointContainer(SpacePointContainer&& other) noexcept = default;
0089   SpacePointContainer& operator=(SpacePointContainer&& other) noexcept =
0090       default;
0091 
0092   // Destructor
0093   ~SpacePointContainer() = default;
0094 
0095   std::size_t size() const;
0096 
0097   iterator begin();
0098   iterator end();
0099   const_iterator cbegin() const;
0100   const_iterator cend() const;
0101   const_iterator begin() const;
0102   const_iterator end() const;
0103 
0104   ProxyType& at(const std::size_t n);
0105   const ProxyType& at(const std::size_t n) const;
0106   const ValueType& sp(const std::size_t n) const;
0107 
0108  private:
0109   void initialize();
0110 
0111   const container_t& container() const;
0112   const ProxyType& proxy(const std::size_t n) const;
0113   std::vector<ProxyType>& proxies();
0114   const std::vector<ProxyType>& proxies() const;
0115 
0116   float x(const std::size_t n) const;
0117   float y(const std::size_t n) const;
0118   float z(const std::size_t n) const;
0119   float phi(const std::size_t n) const;
0120   float radius(const std::size_t n) const;
0121   float varianceR(const std::size_t n) const;
0122   float varianceZ(const std::size_t n) const;
0123 
0124   const Acts::Vector3& topStripVector(const std::size_t n) const;
0125   const Acts::Vector3& bottomStripVector(const std::size_t n) const;
0126   const Acts::Vector3& stripCenterDistance(const std::size_t n) const;
0127   const Acts::Vector3& topStripCenterPosition(const std::size_t n) const;
0128 
0129   Acts::SpacePointContainerConfig m_config;
0130   Acts::SpacePointContainerOptions m_options;
0131   Acts::SpacePointData m_data;
0132   holder_t<const container_t> m_container;
0133   std::vector<ProxyType> m_proxies;
0134 };
0135 
0136 }  // namespace Acts
0137 
0138 #include "Acts/EventData/SpacePointContainer.ipp"