Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:15:42

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/Geometry/GeometryContext.hpp"
0012 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0013 #include "Acts/Material/MaterialInteraction.hpp"
0014 #include "Acts/Material/MaterialInteractionAssignment.hpp"
0015 #include "Acts/Material/TrackingGeometryMaterial.hpp"
0016 #include "Acts/Material/interface/IAssignmentFinder.hpp"
0017 #include "Acts/Material/interface/ISurfaceMaterialAccumulater.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019 
0020 #include <memory>
0021 #include <utility>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 /// @brief material mapping procedure
0026 class MaterialMapper {
0027  public:
0028   using SurfaceMaterialMap
0029       [[deprecated("Use Acts::SurfaceMaterialMaps directly")]] =
0030           SurfaceMaterialMaps;
0031   using VolumeMaterialMap
0032       [[deprecated("Use Acts::VolumeMaterialMaps directly")]] =
0033           VolumeMaterialMaps;
0034   using DetectorMaterialMaps
0035       [[deprecated("Use Acts::TrackingGeometryMaterial directly")]] =
0036           TrackingGeometryMaterial;
0037 
0038   /// @brief nested configuration struct
0039   struct Config {
0040     /// The assignment finder for material interaction assignments
0041     std::shared_ptr<const IAssignmentFinder> assignmentFinder = nullptr;
0042     /// The material accumulator for surfaces
0043     std::shared_ptr<const ISurfaceMaterialAccumulater>
0044         surfaceMaterialAccumulater = nullptr;
0045   };
0046 
0047   /// @brief nested state struct
0048   ///
0049   /// It holds the states of the sub structs
0050   struct State {
0051     /// State of the surface material accumulator
0052     std::unique_ptr<ISurfaceMaterialAccumulater::State>
0053         surfaceMaterialAccumulaterState;
0054   };
0055 
0056   /// @brief nested options struct
0057   /// holds some options for the delegated calls
0058   struct Options {
0059     /// The assignment options (including vetos and re-assignments)
0060     MaterialInteractionAssignment::Options assignmentOptions;
0061   };
0062 
0063   /// @brief MaterialMapper constructor
0064   ///
0065   /// @param cfg the configuration struct
0066   /// @param mlogger the logger instance
0067   explicit MaterialMapper(
0068       const Config& cfg,
0069       std::unique_ptr<const Logger> mlogger =
0070           getDefaultLogger("BinnedSurfaceMaterialAccumulater", Logging::INFO));
0071 
0072   /// @brief Factory for creating the state
0073   /// @return Unique pointer to a new material mapping state object
0074   std::unique_ptr<State> createState() const;
0075 
0076   /// @brief Map the material interactions to the surfaces
0077   ///
0078   /// @param state the state object holding the sub states
0079   /// @param gctx the geometry context
0080   /// @param mctx the magnetic field context
0081   /// @param rmTrack the recorded material track
0082   /// @param options the call options (see above)
0083   ///
0084   /// @return the mapped and unmapped material tracks
0085   std::pair<RecordedMaterialTrack, RecordedMaterialTrack> mapMaterial(
0086       State& state, const GeometryContext& gctx,
0087       const MagneticFieldContext& mctx, const RecordedMaterialTrack& rmTrack,
0088       const Options& options = Options{}) const;
0089 
0090   /// Finalize the maps
0091   /// @param state Material mapping state containing collected data
0092   /// @return Tracking geometry material map with finalized surface and volume materials
0093   TrackingGeometryMaterial finalizeMaps(const State& state) const;
0094 
0095  private:
0096   /// Access method to the logger
0097   const Logger& logger() const { return *m_logger; }
0098 
0099   /// The configuration
0100   Config m_cfg;
0101 
0102   /// The logger
0103   std::unique_ptr<const Logger> m_logger;
0104 };
0105 
0106 }  // namespace Acts