Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:32

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/em/data/MuPairProductionData.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Macros.hh"
0010 #include "corecel/Types.hh"
0011 #include "corecel/grid/TwodGridData.hh"
0012 #include "celeritas/Quantities.hh"
0013 #include "celeritas/Types.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * IDs used by muon pair production.
0020  */
0021 struct MuPairProductionIds
0022 {
0023     ParticleId mu_minus;
0024     ParticleId mu_plus;
0025     ParticleId electron;
0026     ParticleId positron;
0027 
0028     //! Whether the IDs are assigned
0029     explicit CELER_FUNCTION operator bool() const
0030     {
0031         return mu_minus && mu_plus && electron && positron;
0032     }
0033 };
0034 
0035 //---------------------------------------------------------------------------//
0036 /*!
0037  * Sampling table for electron-positron pair production by muons.
0038  *
0039  * The value grids are organized by atomic number, where the Z grid is a
0040  * hardcoded, problem-independent set of atomic numbers equally spaced in \f$
0041  * \log Z \f$ that is linearly interpolated on. Each 2D grid is:
0042  * - x: logarithm of the energy [MeV] of the incident charged particle
0043  * - y: logarithm of the ratio of the energy transfer to the incident particle
0044  *   energy
0045  * - value: CDF calculated from the differential cross section
0046  */
0047 template<Ownership W, MemSpace M>
0048 struct MuPairProductionTableData
0049 {
0050     //// TYPES ////
0051 
0052     template<class T>
0053     using Items = Collection<T, W, M>;
0054 
0055     //// MEMBER DATA ////
0056 
0057     ItemRange<real_type> logz_grid;
0058     Items<TwodGridData> grids;
0059 
0060     // Backend data
0061     Items<real_type> reals;
0062 
0063     //// MEMBER FUNCTIONS ////
0064 
0065     //! Whether the data is assigned
0066     explicit CELER_FUNCTION operator bool() const
0067     {
0068         return !reals.empty() && !logz_grid.empty()
0069                && logz_grid.size() == grids.size();
0070     }
0071 
0072     //! Assign from another set of data
0073     template<Ownership W2, MemSpace M2>
0074     MuPairProductionTableData&
0075     operator=(MuPairProductionTableData<W2, M2> const& other)
0076     {
0077         CELER_EXPECT(other);
0078         reals = other.reals;
0079         logz_grid = other.logz_grid;
0080         grids = other.grids;
0081         return *this;
0082     }
0083 };
0084 
0085 //---------------------------------------------------------------------------//
0086 /*!
0087  * Constant data for the muon pair production interactor.
0088  */
0089 template<Ownership W, MemSpace M>
0090 struct MuPairProductionData
0091 {
0092     //// MEMBER DATA ////
0093 
0094     //! Particle IDs
0095     MuPairProductionIds ids;
0096 
0097     //! Electron mass [MeV / c^2]
0098     units::MevMass electron_mass;
0099 
0100     // Sampling table storage
0101     MuPairProductionTableData<W, M> table;
0102 
0103     //// MEMBER FUNCTIONS ////
0104 
0105     //! Whether all data are assigned and valid
0106     explicit CELER_FUNCTION operator bool() const
0107     {
0108         return ids && electron_mass > zero_quantity() && table;
0109     }
0110 
0111     //! Assign from another set of data
0112     template<Ownership W2, MemSpace M2>
0113     MuPairProductionData& operator=(MuPairProductionData<W2, M2> const& other)
0114     {
0115         CELER_EXPECT(other);
0116         ids = other.ids;
0117         electron_mass = other.electron_mass;
0118         table = other.table;
0119         return *this;
0120     }
0121 };
0122 
0123 //---------------------------------------------------------------------------//
0124 }  // namespace celeritas