Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylindricalDetectorHelper.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylindricalDetectorHelper.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
14 #include "Acts/Detector/Portal.hpp"
19 
20 #include <array>
21 #include <limits>
22 #include <map>
23 #include <memory>
24 #include <vector>
25 
26 namespace Acts {
27 
28 namespace Experimental {
29 
30 class DetectorVolume;
31 class Portal;
32 
33 namespace detail {
34 namespace CylindricalDetectorHelper {
35 
48  const GeometryContext& gctx,
49  std::vector<std::shared_ptr<DetectorVolume>>& volumes,
50  const std::vector<unsigned int>& selectedOnly = {},
52 
65  const GeometryContext& gctx,
66  std::vector<std::shared_ptr<DetectorVolume>>& volumes,
67  const std::vector<unsigned int>& selectedOnly = {},
69 
82  const GeometryContext& gctx,
83  std::vector<std::shared_ptr<DetectorVolume>>& volumes,
84  const std::vector<unsigned int>& selectedOnly = {},
86 
98  const GeometryContext& gctx,
99  std::vector<std::shared_ptr<DetectorVolume>>& volumes,
101 
114  const GeometryContext& gctx,
115  const std::vector<DetectorComponent::PortalContainer>& containers,
116  const std::vector<unsigned int>& selectedOnly = {},
118 
131  const GeometryContext& gctx,
132  const std::vector<DetectorComponent::PortalContainer>& containers,
133  const std::vector<unsigned int>& selectedOnly = {},
135 
148  const GeometryContext& gctx,
149  const std::vector<DetectorComponent::PortalContainer>& containers,
150  const std::vector<unsigned int>& selectedOnly = {},
152 
164  const GeometryContext& gctx,
165  const std::vector<DetectorComponent::PortalContainer>& containers,
167 
178 template <typename volume_container_t>
179 std::array<std::vector<ActsScalar>, 3u> rzphiBoundaries(
180  const GeometryContext& gctx, const volume_container_t& volumes,
182  // The local logger
183  ACTS_LOCAL_LOGGER(getDefaultLogger("CylindricalDetectorHelper", logLevel));
184 
185  ACTS_DEBUG("Estimate R/z/phi boundaries of " << volumes.size()
186  << " volumes.");
187 
188  // The return boundaries
189  std::array<std::set<ActsScalar>, 3u> uniqueBoundaries;
190 
191  // Loop over the volumes and collect boundaries
192  for (const auto& v : volumes) {
193  if (v->volumeBounds().type() == VolumeBounds::BoundsType::eCylinder) {
194  const auto& bValues = v->volumeBounds().values();
195  // The min/max values
196  ActsScalar rMin = bValues[CylinderVolumeBounds::BoundValues::eMinR];
197  ActsScalar rMax = bValues[CylinderVolumeBounds::BoundValues::eMaxR];
198  ActsScalar zCenter = v->transform(gctx).translation().z();
199  ActsScalar zHalfLength =
200  bValues[CylinderVolumeBounds::BoundValues::eHalfLengthZ];
201  ActsScalar zMin = zCenter - zHalfLength;
202  ActsScalar zMax = zCenter + zHalfLength;
203  ActsScalar phiCenter =
204  bValues[CylinderVolumeBounds::BoundValues::eAveragePhi];
205  ActsScalar phiSector =
206  bValues[CylinderVolumeBounds::BoundValues::eHalfPhiSector];
207  ActsScalar phiMin = phiCenter - phiSector;
208  ActsScalar phiMax = phiCenter + phiSector;
209  // Fill the sets
210  uniqueBoundaries[0].insert(rMin);
211  uniqueBoundaries[0].insert(rMax);
212  uniqueBoundaries[1].insert(zMin);
213  uniqueBoundaries[1].insert(zMax);
214  uniqueBoundaries[2].insert(phiMin);
215  uniqueBoundaries[2].insert(phiMax);
216  }
217  }
218 
219  ACTS_VERBOSE("- did yield " << uniqueBoundaries[0u].size()
220  << " boundaries in R.");
221  ACTS_VERBOSE("- did yield " << uniqueBoundaries[1u].size()
222  << " boundaries in z.");
223  ACTS_VERBOSE("- did yield " << uniqueBoundaries[2u].size()
224  << " boundaries in phi.");
225 
226  return {{std::vector<ActsScalar>(uniqueBoundaries[0].begin(),
227  uniqueBoundaries[0].end()),
228  std::vector<ActsScalar>(uniqueBoundaries[1].begin(),
229  uniqueBoundaries[1].end()),
230  std::vector<ActsScalar>(uniqueBoundaries[2].begin(),
231  uniqueBoundaries[2].end())}};
232 }
233 
234 } // namespace CylindricalDetectorHelper
235 } // namespace detail
236 } // namespace Experimental
237 } // namespace Acts