Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-30 07:45:38

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/Material/MaterialSlab.hpp"
0012 
0013 #include <utility>
0014 
0015 namespace Acts {
0016 
0017 /// Accumulate material properties from multiple hits/track and multiple tracks.
0018 ///
0019 /// @ingroup material_mapping
0020 ///
0021 /// This is a helper class for the `SurfaceMaterialMapper` to handle material
0022 /// accumulation and averaging for one surface bin. The accumulation procedure
0023 /// is done in two steps:
0024 ///
0025 /// 1.  The per-track store accumulates material steps from one track/particle.
0026 ///     Multiple material steps can be assigned to the same bin time by
0027 ///     one particle, e.g. if the simulation has created more than one step in
0028 ///     the material or if several components are compressed into one
0029 ///     description. Multiple steps are treated as if they are passed one after
0030 ///     the other.
0031 /// 2.  The total store averages the accumulated material properties over all
0032 ///     tracks. Each track contributes equally.
0033 class AccumulatedMaterialSlab {
0034  public:
0035   // this class does not have a custom default constructor and thus should not
0036   // provide any custom default cstors, dstor, or assignment. see ISOCPP C.20.
0037 
0038   /// Add the material to the current per-track store.
0039   ///
0040   /// @param slabAlongTrack Recorded equivalent material slab for this step
0041   /// @param pathCorrection Correction factor due to non-perpendicular incident
0042   ///
0043   /// The recoded material slab is assumed to be defined along the track
0044   /// direction. The track can have non-perpendicular incidence on the surface
0045   /// and the recorded slab has to be projected along the surface normal. The
0046   /// path correction gives the scaling factor from normal incidence to the
0047   /// recorded incidence as provided by the `Surface` interface.
0048   ///
0049   ///  Vacuum steps with a non-zero thickness can be added to account for holes
0050   ///  in material structures.
0051   void accumulate(MaterialSlab slabAlongTrack, double pathCorrection = 1.);
0052 
0053   /// Use the accumulated material to update the material variance
0054   ///
0055   /// @param slabReference reference slab (from the map) used to compute the variance
0056   /// @param useEmptyTrack indicate whether to consider an empty track store
0057   ///
0058   /// The material variance can be used to optimised the mapping process as it
0059   /// should be inversely proportional to the map quality
0060   void trackVariance(MaterialSlab slabReference, bool useEmptyTrack = false);
0061 
0062   /// Add the accumulated material for the current track to the total average.
0063   ///
0064   /// @param useEmptyTrack indicate whether to consider an empty track store
0065   ///
0066   /// This finishes the material accumulation for the current track and resets
0067   /// the per-track store. Subsequent calls to `.accumulate(...)` will start
0068   /// accumulating material for a new track.
0069   ///
0070   /// Each track contributes equally to the total average regardless of its
0071   /// measured path within the material. An empty per-track store, i.e.
0072   /// vanishing per-track material thickness, does not contribute to the total
0073   /// unless explicitly requested.
0074   void trackAverage(bool useEmptyTrack = false);
0075 
0076   /// Return the average material properties from all accumulated tracks.
0077   ///
0078   /// @returns Average material properties and the number of contributing tracks
0079   ///
0080   /// Only contains the information up to the last `.trackAverage(...)` call. If
0081   /// there have been additional calls to `.accumulate(...)` afterwards, the
0082   /// information is not part of the total average. The thickness corresponds to
0083   /// the average thickness seen by the tracks.
0084   std::pair<MaterialSlab, unsigned int> totalAverage() const;
0085 
0086   /// Return the material variance from all accumulated tracks.
0087   ///
0088   /// @returns Average material properties and the number of contributing tracks
0089   ///
0090   /// Only contains the information up to the last `.trackVariance(...)` call.
0091   /// If there have been additional calls to `.accumulate(...)` afterwards, the
0092   /// information is not part of the total average. The number of tracks is only
0093   /// updated on the call of `.trackAverage(...)`
0094   std::pair<float, unsigned int> totalVariance() const;
0095 
0096  private:
0097   /// Averaged properties for a single track.
0098   MaterialSlab m_trackAverage = MaterialSlab::Nothing();
0099   /// Averaged properties over multiple tracks.
0100   MaterialSlab m_totalAverage = MaterialSlab::Nothing();
0101   /// Averaged variance over multiple tracks.
0102   float m_totalVariance = 0.0;
0103   // Number of tracks contributing to the total average.
0104   unsigned int m_totalCount = 0u;
0105 };
0106 
0107 }  // namespace Acts