Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:21:03

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/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/GeometryHierarchyMap.hpp"
0014 #include "Acts/Material/MaterialInteraction.hpp"
0015 #include "Acts/Material/interface/IAssignmentFinder.hpp"
0016 
0017 #include <array>
0018 #include <functional>
0019 #include <optional>
0020 #include <tuple>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 class Surface;
0026 
0027 /// @brief Assignment of recorded material interactions to assignment candidates
0028 ///
0029 /// This turns the candidates found by an @ref Acts::IAssignmentFinder into the
0030 /// final per-surface assignments, applying global and local vetoes and optional
0031 /// re-assignments along the way.
0032 ///
0033 /// @ingroup material_mapping
0034 namespace MaterialInteractionAssignment {
0035 
0036 /// The result struct of the assignment run
0037 struct Result {
0038   /// The assigned material interactions
0039   std::vector<MaterialInteraction> assigned = {};
0040   /// The unassigned material interactions
0041   std::vector<MaterialInteraction> unassigned = {};
0042   /// Surfaces without assignment (for empty hit correction)
0043   std::vector<IAssignmentFinder::SurfaceAssignment> unassignedSurfaces = {};
0044 };
0045 
0046 /// @brief definition of a global veto for assigning material interactions
0047 ///
0048 /// This can be used to restrict the assignment to a specific volume, or
0049 /// exclude certain materials (if one wants), etc.
0050 ///
0051 /// @param materialInteraction is the material interaction to be checked for the veto
0052 ///
0053 /// It will be globally applied, i.e. every single material interaction
0054 /// will have to go through this veto
0055 using GlobalVeto =
0056     std::function<bool(const MaterialInteraction& materialInteraction)>;
0057 
0058 /// @brief definition of a local veto on a material interaction
0059 ///
0060 /// This can take already the suggested surface assignment into account
0061 /// return true if the assignment should be vetoed. This can be used for
0062 /// having exclusion rules based on surface information.
0063 ///
0064 /// @param materialInteraction is the material interaction to be checked for the veto
0065 /// @param suggestedAssignment is the suggested assignment: surface, position, direction
0066 using LocalVeto = std::function<bool(
0067     const MaterialInteraction&,
0068     const IAssignmentFinder::SurfaceAssignment& suggestedAssignment)>;
0069 
0070 /// @brief definition of possible re-assignments to next surface, this could e.g.
0071 /// be used for respecting pre/post mapping directives that are not fully
0072 /// handled by closest distance matching
0073 ///
0074 /// The provided parameters are the mutable material interaction, the suggested
0075 /// assignment and the next possible assignment, due to the ordered nature of
0076 /// the material interactions, assignment to previous is excluded
0077 ///
0078 /// @param materialInteraction is the material interaction to be checked for the veto
0079 /// @param suggestedAssignment is the suggested assignment: surface, position, direction
0080 /// @param suggestedReAssignment is the suggested assignment: surface, position, direction
0081 ///
0082 /// @note this changes the MaterialInteraction if the re-assignment is accepted
0083 using ReAssignment = std::function<void(
0084     MaterialInteraction& materialInteraction,
0085     const IAssignmentFinder::SurfaceAssignment& suggestedAssignment,
0086     const IAssignmentFinder::SurfaceAssignment& suggestedReAssignment)>;
0087 
0088 /// @brief Options for the material interaction matcher
0089 /// The options are used to specify the vetos for the assignment
0090 struct Options {
0091   /// Allow global vetos for the assignment, e.g. restricting
0092   /// the assignment to a specific volume
0093   std::vector<GlobalVeto> globalVetos = {};
0094 
0095   /// Allow specific vetoes for the assignment, e.g. only locally to
0096   /// surface, rest to next mapper (e.g. volume mapper)
0097   GeometryHierarchyMap<LocalVeto> localVetos = {};
0098 
0099   /// Allow re-assignment of the material interaction, e.g. to respect
0100   GeometryHierarchyMap<ReAssignment> reAssignments = {};
0101 };
0102 
0103 /// @brief Match the material interactions to surfaces intersections while respecting
0104 /// eventual vetos for the assignment
0105 ///
0106 /// @param gctx is the geometry context
0107 /// @param materialInteractions is the vector of material interaction
0108 /// @param intersectedSurfaces are the surfac assignment candidates
0109 /// @param options are the options for the assignment
0110 ///
0111 /// @return a pair of vectors of assigned and unassigned material interactions
0112 Result assign(const GeometryContext& gctx,
0113               const std::vector<MaterialInteraction>& materialInteractions,
0114               const std::vector<IAssignmentFinder::SurfaceAssignment>&
0115                   intersectedSurfaces,
0116               const Options& options = Options());
0117 
0118 }  // namespace MaterialInteractionAssignment
0119 
0120 }  // namespace Acts