Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:23

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