Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:17

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/Polyhedron.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Utilities/BinningData.hpp"
0016 
0017 #include <vector>
0018 
0019 namespace Acts::Experimental::detail {
0020 
0021 /// A struct to access the center position
0022 ///
0023 /// This generator will provide only one filling point and hence
0024 /// only a single bin in the indexed grid.
0025 struct CenterReferenceGenerator {
0026   /// Helper to access the Center point of for filling the grid
0027   ///
0028   /// @param gctx the geometry context of this operation
0029   /// @param surface the surface for which the reference point is to be accessed
0030   ///
0031   /// @return a vector of reference points for filling
0032   const std::vector<Vector3> references(const GeometryContext& gctx,
0033                                         const Surface& surface) const {
0034     return {surface.center(gctx)};
0035   }
0036 };
0037 
0038 /// A struct to access reference positions based on bin values
0039 ///
0040 /// @tparam bVAL the binning value to be used for the binning position call
0041 ///
0042 /// This generator will provide only one filling point and hence
0043 /// only a single bin in the indexed grid.
0044 template <BinningValue bVAL = BinningValue::binValues>
0045 struct BinningValueReferenceGenerator {
0046   /// Helper to access a reference position based on binning value
0047   ///
0048   /// @param gctx the geometry context of this operation
0049   /// @param surface the surface for which the reference point is to be accessed
0050   ///
0051   /// @return a vector of reference points for filling
0052   const std::vector<Vector3> references(const GeometryContext& gctx,
0053                                         const Surface& surface) const {
0054     return {surface.binningPosition(gctx, bVAL)};
0055   }
0056 };
0057 
0058 /// A struct to access generated vertices from surface polyhedrons
0059 /// These vertices are then used to find the bin boundary box for the
0060 /// indexed grid.
0061 ///
0062 /// @tparam nSEGS the number of segments to be used for the polyhedron
0063 /// approximation of arcs between vertices
0064 /// @tparam aBARY if true, the barycenter of the polyhedron is added
0065 ///
0066 /// The grid filling then completes the empty bins in between and
0067 /// expands if necessary.
0068 template <std::size_t nSEGS = 1u, bool aBARY = true>
0069 struct PolyhedronReferenceGenerator {
0070   /// Helper to access the Center point of for filling the grid
0071   ///
0072   /// @param gctx the geometry context of this operation
0073   /// @param surface the surface for which the reference point is to be accessed
0074   ///
0075   /// @return a vector of reference points for filling
0076   const std::vector<Vector3> references(const GeometryContext& gctx,
0077                                         const Surface& surface) const {
0078     // Create the return  vector
0079     std::vector<Vector3> rPositions;
0080     auto pHedron = surface.polyhedronRepresentation(gctx, nSEGS);
0081     rPositions.insert(rPositions.end(), pHedron.vertices.begin(),
0082                       pHedron.vertices.end());
0083     // Add the barycenter if configured
0084     if constexpr (aBARY) {
0085       Vector3 bc(0., 0., 0.);
0086       std::for_each(rPositions.begin(), rPositions.end(),
0087                     [&](const auto& p) { bc += p; });
0088       bc *= 1. / rPositions.size();
0089       rPositions.push_back(bc);
0090     }
0091     return rPositions;
0092   }
0093 };
0094 
0095 }  // namespace Acts::Experimental::detail