Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 07:45:47

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/Material/AccumulatedMaterialSlab.hpp"
0013 #include "Acts/Material/MaterialSlab.hpp"
0014 #include "Acts/Utilities/BinUtility.hpp"
0015 
0016 #include <array>
0017 #include <cstddef>
0018 #include <memory>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 class ISurfaceMaterial;
0024 
0025 /// @class AccumulatedSurfaceMaterial
0026 ///
0027 /// @ingroup material_mapping
0028 ///
0029 /// This class is used by the SurfaceMaterialMapper in order to
0030 /// accumulate/collect material information during the mapping process.
0031 ///
0032 /// It performs event- and run-average when called, and returns
0033 /// a new SurfaceMaterial object as a unique_ptr after finalisation
0034 class AccumulatedSurfaceMaterial {
0035  public:
0036   /// Type alias for vector of accumulated material slabs
0037   using AccumulatedVector = std::vector<AccumulatedMaterialSlab>;
0038   /// Type alias for matrix (vector of vectors) of accumulated material slabs
0039   using AccumulatedMatrix = std::vector<AccumulatedVector>;
0040 
0041   /// Default Constructor - for homogeneous material
0042   ///
0043   /// @param splitFactor is the pre/post splitting directive
0044   explicit AccumulatedSurfaceMaterial(double splitFactor = 0.);
0045 
0046   /// Explicit constructor with only full MaterialSlab,
0047   /// for one-dimensional binning.
0048   ///
0049   /// The split factors:
0050   ///    - 1. : oppositePre
0051   ///    - 0. : alongPre
0052   ///  ===> 1 Dimensional array
0053   ///
0054   /// @param binUtility defines the binning structure on the surface
0055   /// @param splitFactor is the pre/post splitting directive
0056   explicit AccumulatedSurfaceMaterial(const BinUtility& binUtility,
0057                                       double splitFactor = 0.);
0058 
0059   /// Copy Constructor
0060   ///
0061   /// @param asma is the source object to be copied
0062   AccumulatedSurfaceMaterial(const AccumulatedSurfaceMaterial& asma) = default;
0063 
0064   /// Copy Move Constructor
0065   ///
0066   /// @param asma is the source object to be copied
0067   AccumulatedSurfaceMaterial(AccumulatedSurfaceMaterial&& asma) = default;
0068 
0069   /// Assignment Move operator
0070   ///
0071   /// @param asma is the source object to be copied
0072   /// @return Reference to this object after move assignment
0073   AccumulatedSurfaceMaterial& operator=(AccumulatedSurfaceMaterial&& asma) =
0074       default;
0075 
0076   /// Assignment operator
0077   ///
0078   /// @param asma is the source object to be copied
0079   /// @return Reference to this object after copy assignment
0080   AccumulatedSurfaceMaterial& operator=(
0081       const AccumulatedSurfaceMaterial& asma) = default;
0082 
0083   /// Destructor
0084   ~AccumulatedSurfaceMaterial() = default;
0085 
0086   /// Return the BinUtility
0087   /// @return Reference to the bin utility used for material binning
0088   const BinUtility& binUtility() const;
0089 
0090   /// Assign a material properties object
0091   ///
0092   /// @param lp local position for the bin assignment
0093   /// @param mp material properties to be assigned
0094   /// @param pathCorrection Correction factor for the effective path length
0095   ///
0096   /// @return the bin triple to which the material was assigned
0097   std::array<std::size_t, 3> accumulate(const Vector2& lp,
0098                                         const MaterialSlab& mp,
0099                                         double pathCorrection = 1.);
0100 
0101   /// Assign a material properties object
0102   ///
0103   /// @param gp global position for the bin assignment
0104   /// @param mp material properties to be assigned
0105   /// @param pathCorrection Correction factor for the effective path length
0106   ///
0107   /// @return the bin triple to which the material was assigned
0108   std::array<std::size_t, 3> accumulate(const Vector3& gp,
0109                                         const MaterialSlab& mp,
0110                                         double pathCorrection = 1.);
0111 
0112   /// Use the accumulated material to update the material variance
0113   ///
0114   /// @param trackBins The bins that were touched by this event
0115   /// @param emptyHit indicator if this is an empty assignment
0116   /// @param slabReference reference slab (from the map) used to compute the variance
0117   /// If none is given, the average runs over all bins in the surface map
0118   void trackVariance(const std::vector<std::array<std::size_t, 3>>& trackBins,
0119                      MaterialSlab slabReference, bool emptyHit = false);
0120 
0121   /// Use the accumulated material to update the material variance
0122   ///
0123   /// @param gp global position for the bin assignment
0124   /// @param emptyHit indicator if this is an empty assignment
0125   /// @param slabReference indicator if this is an empty assignment
0126   void trackVariance(const Vector3& gp, MaterialSlab slabReference,
0127                      bool emptyHit = false);
0128 
0129   /// Average the information accumulated from one mapped track
0130   ///
0131   /// @param trackBins The bins that were touched by this event
0132   /// @param emptyHit indicator if this is an empty assignment
0133   /// If none is given, the average runs over all bins in the surface map
0134   void trackAverage(
0135       const std::vector<std::array<std::size_t, 3>>& trackBins = {},
0136       bool emptyHit = false);
0137 
0138   /// Average the information accumulated from one mapped track
0139   ///
0140   /// @param gp global position for the bin assignment
0141   /// @param emptyHit indicator if this is an empty assignment
0142   void trackAverage(const Vector3& gp, bool emptyHit = false);
0143 
0144   /// Total average creates SurfaceMaterial
0145   /// @return Unique pointer to the averaged surface material
0146   std::unique_ptr<const ISurfaceMaterial> totalAverage();
0147 
0148   /// Access to the accumulated material
0149   /// @return Reference to the matrix of accumulated material data
0150   const AccumulatedMatrix& accumulatedMaterial() const;
0151 
0152   /// Access to the split factor
0153   /// @return The split factor used for material averaging
0154   double splitFactor() const;
0155 
0156  private:
0157   /// The helper for the bin finding
0158   BinUtility m_binUtility{};
0159 
0160   /// the split factor
0161   double m_splitFactor{0.};
0162 
0163   /// The stored accumulated material matrix
0164   AccumulatedMatrix m_accumulatedMaterial;
0165 };
0166 
0167 inline const BinUtility& AccumulatedSurfaceMaterial::binUtility() const {
0168   return m_binUtility;
0169 }
0170 
0171 inline const AccumulatedSurfaceMaterial::AccumulatedMatrix&
0172 AccumulatedSurfaceMaterial::accumulatedMaterial() const {
0173   return m_accumulatedMaterial;
0174 }
0175 
0176 inline double AccumulatedSurfaceMaterial::splitFactor() const {
0177   return m_splitFactor;
0178 }
0179 }  // namespace Acts