Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:54

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