Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-13 07:50:07

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/EventData/SpacePointContainer.hpp"
0012 
0013 #include "Acts/Utilities/HashedString.hpp"
0014 
0015 #include <any>
0016 #include <cmath>
0017 
0018 namespace Acts {
0019 
0020 template <typename container_t, template <typename> class holder_t>
0021 template <template <typename> class, typename>
0022 SpacePointContainer<container_t, holder_t>::SpacePointContainer(
0023     const SpacePointContainerConfig& config,
0024     const SpacePointContainerOptions& options, const container_t& container)
0025     : m_config(config), m_options(options), m_container(container) {
0026   initialize();
0027 }
0028 
0029 template <typename container_t, template <typename> class holder_t>
0030 template <template <typename> class, typename>
0031 SpacePointContainer<container_t, holder_t>::SpacePointContainer(
0032     const SpacePointContainerConfig& config,
0033     const SpacePointContainerOptions& options, container_t&& container)
0034     : m_config(config), m_options(options), m_container(std::move(container)) {
0035   initialize();
0036 }
0037 
0038 template <typename container_t, template <typename> class holder_t>
0039 void SpacePointContainer<container_t, holder_t>::initialize() {
0040   m_data.resize(size(), m_config.useDetailedDoubleMeasurementInfo);
0041   m_proxies.reserve(size());
0042   const auto& external_container = container();
0043   for (std::size_t i(0); i < size(); ++i) {
0044     m_data.setX(i, external_container.x_impl(i) - m_options.beamPos[0]);
0045     m_data.setY(i, external_container.y_impl(i) - m_options.beamPos[1]);
0046     m_data.setZ(i, external_container.z_impl(i));
0047     m_data.setRadius(
0048         i, std::sqrt(m_data.x(i) * m_data.x(i) + m_data.y(i) * m_data.y(i)));
0049     m_data.setPhi(i, std::atan2(m_data.y(i), m_data.x(i)));
0050     m_data.setVarianceR(i, external_container.varianceR_impl(i));
0051     m_data.setVarianceZ(i, external_container.varianceZ_impl(i));
0052 
0053     m_proxies.emplace_back(*this, i);
0054   }
0055 
0056   // Dynamic variables
0057   if (m_config.useDetailedDoubleMeasurementInfo) {
0058     using namespace HashedStringLiteral;
0059     for (std::size_t i(0); i < size(); ++i) {
0060       m_data.setTopStripVector(
0061           i, std::any_cast<Vector3>(
0062                  external_container.component_impl("TopStripVector"_hash, i)));
0063       m_data.setBottomStripVector(
0064           i, std::any_cast<Vector3>(external_container.component_impl(
0065                  "BottomStripVector"_hash, i)));
0066       m_data.setStripCenterDistance(
0067           i, std::any_cast<Vector3>(external_container.component_impl(
0068                  "StripCenterDistance"_hash, i)));
0069       m_data.setTopStripCenterPosition(
0070           i, std::any_cast<Vector3>(external_container.component_impl(
0071                  "TopStripCenterPosition"_hash, i)));
0072     }
0073   }
0074 }
0075 
0076 template <typename container_t, template <typename> class holder_t>
0077 const Vector3& SpacePointContainer<container_t, holder_t>::topStripVector(
0078     const std::size_t n) const {
0079   return m_data.topStripVector(n);
0080 }
0081 
0082 template <typename container_t, template <typename> class holder_t>
0083 const Vector3& SpacePointContainer<container_t, holder_t>::bottomStripVector(
0084     const std::size_t n) const {
0085   return m_data.bottomStripVector(n);
0086 }
0087 
0088 template <typename container_t, template <typename> class holder_t>
0089 const Vector3& SpacePointContainer<container_t, holder_t>::stripCenterDistance(
0090     const std::size_t n) const {
0091   return m_data.stripCenterDistance(n);
0092 }
0093 
0094 template <typename container_t, template <typename> class holder_t>
0095 const Vector3&
0096 SpacePointContainer<container_t, holder_t>::topStripCenterPosition(
0097     const std::size_t n) const {
0098   return m_data.topStripCenterPosition(n);
0099 }
0100 
0101 template <typename container_t, template <typename> class holder_t>
0102 std::size_t SpacePointContainer<container_t, holder_t>::size() const {
0103   return container().size_impl();
0104 }
0105 
0106 template <typename container_t, template <typename> class holder_t>
0107 typename SpacePointContainer<container_t, holder_t>::iterator
0108 SpacePointContainer<container_t, holder_t>::begin() {
0109   return {*this, 0};
0110 }
0111 
0112 template <typename container_t, template <typename> class holder_t>
0113 typename SpacePointContainer<container_t, holder_t>::iterator
0114 SpacePointContainer<container_t, holder_t>::end() {
0115   return {*this, size()};
0116 }
0117 
0118 template <typename container_t, template <typename> class holder_t>
0119 typename SpacePointContainer<container_t, holder_t>::const_iterator
0120 SpacePointContainer<container_t, holder_t>::begin() const {
0121   return {*this, 0};
0122 }
0123 
0124 template <typename container_t, template <typename> class holder_t>
0125 typename SpacePointContainer<container_t, holder_t>::const_iterator
0126 SpacePointContainer<container_t, holder_t>::end() const {
0127   return {*this, size()};
0128 }
0129 
0130 template <typename container_t, template <typename> class holder_t>
0131 typename SpacePointContainer<container_t, holder_t>::const_iterator
0132 SpacePointContainer<container_t, holder_t>::cbegin() const {
0133   return {*this, 0};
0134 }
0135 
0136 template <typename container_t, template <typename> class holder_t>
0137 typename SpacePointContainer<container_t, holder_t>::const_iterator
0138 SpacePointContainer<container_t, holder_t>::cend() const {
0139   return {*this, size()};
0140 }
0141 
0142 template <typename container_t, template <typename> class holder_t>
0143 const container_t& SpacePointContainer<container_t, holder_t>::container()
0144     const {
0145   return *m_container;
0146 }
0147 
0148 template <typename container_t, template <typename> class holder_t>
0149 typename SpacePointContainer<container_t, holder_t>::ProxyType&
0150 SpacePointContainer<container_t, holder_t>::at(const std::size_t n) {
0151   return proxies().at(n);
0152 }
0153 
0154 template <typename container_t, template <typename> class holder_t>
0155 const typename SpacePointContainer<container_t, holder_t>::ProxyType&
0156 SpacePointContainer<container_t, holder_t>::at(const std::size_t n) const {
0157   return proxies().at(n);
0158 }
0159 
0160 template <typename container_t, template <typename> class holder_t>
0161 const typename SpacePointContainer<container_t, holder_t>::ValueType&
0162 SpacePointContainer<container_t, holder_t>::sp(const std::size_t n) const {
0163   return container().get_impl(n);
0164 }
0165 
0166 template <typename container_t, template <typename> class holder_t>
0167 float SpacePointContainer<container_t, holder_t>::x(const std::size_t n) const {
0168   return m_data.x(n);
0169 }
0170 
0171 template <typename container_t, template <typename> class holder_t>
0172 float SpacePointContainer<container_t, holder_t>::y(const std::size_t n) const {
0173   return m_data.y(n);
0174 }
0175 
0176 template <typename container_t, template <typename> class holder_t>
0177 float SpacePointContainer<container_t, holder_t>::z(const std::size_t n) const {
0178   return m_data.z(n);
0179 }
0180 
0181 template <typename container_t, template <typename> class holder_t>
0182 float SpacePointContainer<container_t, holder_t>::phi(
0183     const std::size_t n) const {
0184   return m_data.phi(n);
0185 }
0186 
0187 template <typename container_t, template <typename> class holder_t>
0188 float SpacePointContainer<container_t, holder_t>::radius(
0189     const std::size_t n) const {
0190   return m_data.radius(n);
0191 }
0192 
0193 template <typename container_t, template <typename> class holder_t>
0194 float SpacePointContainer<container_t, holder_t>::varianceR(
0195     const std::size_t n) const {
0196   return m_data.varianceR(n);
0197 }
0198 
0199 template <typename container_t, template <typename> class holder_t>
0200 float SpacePointContainer<container_t, holder_t>::varianceZ(
0201     const std::size_t n) const {
0202   return m_data.varianceZ(n);
0203 }
0204 
0205 template <typename container_t, template <typename> class holder_t>
0206 const typename SpacePointContainer<container_t, holder_t>::ProxyType&
0207 SpacePointContainer<container_t, holder_t>::proxy(const std::size_t n) const {
0208   assert(n < proxies().size());
0209   return proxies()[n];
0210 }
0211 
0212 template <typename container_t, template <typename> class holder_t>
0213 std::vector<typename SpacePointContainer<container_t, holder_t>::ProxyType>&
0214 SpacePointContainer<container_t, holder_t>::proxies() {
0215   return m_proxies;
0216 }
0217 
0218 template <typename container_t, template <typename> class holder_t>
0219 const std::vector<
0220     typename SpacePointContainer<container_t, holder_t>::ProxyType>&
0221 SpacePointContainer<container_t, holder_t>::proxies() const {
0222   return m_proxies;
0223 }
0224 
0225 }  // namespace Acts