Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:51:41

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