Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 09:21:19

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 #include "Acts/Geometry/ReferenceGenerators.hpp"
0010 
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 
0013 const std::vector<Acts::Vector3> Acts::PolyhedronReferenceGenerator::references(
0014     const GeometryContext& gctx, const Surface& surface) const {
0015   // Create the return  vector
0016   std::vector<Vector3> rPositions;
0017   auto pHedron = surface.polyhedronRepresentation(gctx, nSegements);
0018   rPositions.insert(rPositions.end(), pHedron.vertices.begin(),
0019                     pHedron.vertices.end());
0020 
0021   // Compute the barycenter
0022   Vector3 bc(0., 0., 0.);
0023   std::ranges::for_each(rPositions, [&](const auto& p) { bc += p; });
0024   bc *= 1. / rPositions.size();
0025 
0026   // if an expansion is requested, calculate it for every vertex
0027   if (expansionValue != 0.0) {
0028     std::ranges::for_each(rPositions, [&](auto& p) {
0029       p += expansionValue * Vector3(p - bc).normalized();
0030     });
0031   }
0032 
0033   // Add the barycenter if configured
0034   if (addBarycenter) {
0035     rPositions.push_back(bc);
0036   }
0037   return rPositions;
0038 }
0039 
0040 const std::vector<Acts::Vector3> Acts::ProjectedReferenceGenerator::references(
0041     const GeometryContext& gctx, const Surface& surface) const {
0042   if (referenceSurface == nullptr) {
0043     throw std::invalid_argument(
0044         "ProjectedReferenceGenerator: reference surface is nullptr.");
0045   }
0046 
0047   // Create the test polyhedron
0048   std::vector<Vector3> tPositions;
0049   auto pHedron = surface.polyhedronRepresentation(gctx, nSegements);
0050   tPositions.insert(tPositions.end(), pHedron.vertices.begin(),
0051                     pHedron.vertices.end());
0052 
0053   // Create intersected position
0054   std::vector<Vector3> rPositions;
0055   Vector3 rCog;  // reference center of gravity
0056   // Loop over luminous regious points and project
0057   for (const auto& lp : luminousRegion) {
0058     for (const auto& tp : tPositions) {
0059       // Create the ray from luminous point to test point
0060       Vector3 rayDirection = (tp - lp).normalized();
0061       auto refMultiIntersections =
0062           referenceSurface->intersect(gctx, lp, rayDirection);
0063       // Take the closest intersection point in forward direction
0064       rPositions.push_back(refMultiIntersections.closestForward().position());
0065       rCog += rPositions.back();
0066     }
0067   }
0068 
0069   // Normalize center of gravity
0070   rCog /= rPositions.size();
0071 
0072   // if an expansion is requested, calculate it for every vertex
0073   if (expansionValue != 0.0) {
0074     std::ranges::for_each(rPositions, [&](auto& p) {
0075       p += expansionValue * Vector3(p - rCog).normalized();
0076     });
0077   }
0078 
0079   return rPositions;
0080 }