Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:48

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