Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:22:27

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   /// @brief nested configuration struct
0029   struct Config {
0030     /// The assignment finder for material interaction assignments
0031     std::shared_ptr<const IAssignmentFinder> assignmentFinder = nullptr;
0032     /// The material accumulator for surfaces
0033     std::shared_ptr<const ISurfaceMaterialAccumulater>
0034         surfaceMaterialAccumulater = nullptr;
0035   };
0036 
0037   /// @brief nested state struct
0038   ///
0039   /// It holds the states of the sub structs
0040   struct State {
0041     /// State of the surface material accumulator
0042     std::unique_ptr<ISurfaceMaterialAccumulater::State>
0043         surfaceMaterialAccumulaterState;
0044   };
0045 
0046   /// @brief nested options struct
0047   /// holds some options for the delegated calls
0048   struct Options {
0049     /// The assignment options (including vetos and re-assignments)
0050     MaterialInteractionAssignment::Options assignmentOptions;
0051   };
0052 
0053   /// @brief MaterialMapper constructor
0054   ///
0055   /// @param cfg the configuration struct
0056   /// @param mlogger the logger instance
0057   explicit MaterialMapper(
0058       const Config& cfg,
0059       std::unique_ptr<const Logger> mlogger =
0060           getDefaultLogger("BinnedSurfaceMaterialAccumulater", Logging::INFO));
0061 
0062   /// @brief Factory for creating the state
0063   /// @return Unique pointer to a new material mapping state object
0064   std::unique_ptr<State> createState() const;
0065 
0066   /// @brief Map the material interactions to the surfaces
0067   ///
0068   /// @param state the state object holding the sub states
0069   /// @param gctx the geometry context
0070   /// @param mctx the magnetic field context
0071   /// @param rmTrack the recorded material track
0072   /// @param options the call options (see above)
0073   ///
0074   /// @return the mapped and unmapped material tracks
0075   std::pair<RecordedMaterialTrack, RecordedMaterialTrack> mapMaterial(
0076       State& state, const GeometryContext& gctx,
0077       const MagneticFieldContext& mctx, const RecordedMaterialTrack& rmTrack,
0078       const Options& options = Options{}) const;
0079 
0080   /// Finalize the maps
0081   /// @param state Material mapping state containing collected data
0082   /// @return Tracking geometry material map with finalized surface and volume materials
0083   TrackingGeometryMaterial finalizeMaps(const State& state) const;
0084 
0085  private:
0086   /// Access method to the logger
0087   const Logger& logger() const { return *m_logger; }
0088 
0089   /// The configuration
0090   Config m_cfg;
0091 
0092   /// The logger
0093   std::unique_ptr<const Logger> m_logger;
0094 };
0095 
0096 }  // namespace Acts