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