Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:46:22

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/Material/AccumulatedSurfaceMaterial.hpp"
0013 #include "Acts/Material/interface/ISurfaceMaterialAccumulator.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 
0016 namespace Acts {
0017 
0018 /// @brief The binned surface material accumulator
0019 ///
0020 /// It consumes the assigned material interactions and then accumulates
0021 /// the material on the surfaces in prepared binned containers for averaging
0022 
0023 class BinnedSurfaceMaterialAccumulator final
0024     : public ISurfaceMaterialAccumulator {
0025  public:
0026   /// @brief Nested config struct
0027   struct Config {
0028     /// Correct for empty bins (recommended)
0029     bool emptyBinCorrection = true;
0030 
0031     /// The surfaces to be used for the accumulation
0032     std::vector<const Surface*> materialSurfaces = {};
0033   };
0034 
0035   /// @brief Nested state struct
0036   struct State final : public ISurfaceMaterialAccumulator::State {
0037     /// The accumulated material per geometry ID
0038     std::map<GeometryIdentifier, AccumulatedSurfaceMaterial>
0039         accumulatedMaterial;
0040   };
0041 
0042   /// Constructor
0043   ///
0044   /// @param cfg the configuration struct
0045   /// @param mlogger the logger
0046   explicit BinnedSurfaceMaterialAccumulator(
0047       const Config& cfg,
0048       std::unique_ptr<const Logger> mlogger =
0049           getDefaultLogger("BinnedSurfaceMaterialAccumulator", Logging::INFO));
0050 
0051   /// Factory for creating the state
0052   /// @param gctx is the geometry context
0053   /// @return Unique pointer to newly created accumulator state
0054   std::unique_ptr<ISurfaceMaterialAccumulator::State> createState(
0055       const GeometryContext& gctx) const override;
0056 
0057   /// @brief Accumulate the material interaction on the surface
0058   ///
0059   /// @param state is the state of the accumulator
0060   /// @param gctx is the geometry context
0061   /// @param interactions is the material interactions, with assigned surfaces
0062   /// @param surfacesWithoutAssignment are the surfaces without assignment
0063   ///
0064   /// @note this the track average over the binned material
0065   void accumulate(ISurfaceMaterialAccumulator::State& state,
0066                   const GeometryContext& gctx,
0067                   const std::vector<MaterialInteraction>& interactions,
0068                   const std::vector<IAssignmentFinder::SurfaceAssignment>&
0069                       surfacesWithoutAssignment) const override;
0070 
0071   /// Finalize the surface material maps
0072   ///
0073   /// @param state the state of the accumulator
0074   /// @param gctx is the geometry context
0075   ///
0076   /// @note this does the run average over the (binned) material
0077   /// @return Map of surface materials indexed by geometry identifiers
0078   std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>>
0079   finalizeMaterial(ISurfaceMaterialAccumulator::State& state,
0080                    const GeometryContext& gctx) const override;
0081 
0082  private:
0083   /// Access method to the logger
0084   const Logger& logger() const { return *m_logger; }
0085 
0086   /// The configuration
0087   Config m_cfg;
0088 
0089   /// The logger
0090   std::unique_ptr<const Logger> m_logger;
0091 };
0092 
0093 }  // namespace Acts