Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:48:25

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/ext/GeantPhysicsOptions.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 #include "celeritas/Constants.hh"
0011 #include "celeritas/Quantities.hh"
0012 
0013 #include "GeantOpticalPhysicsOptions.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 //! Brems selection (TODO: make bitset)
0019 enum class BremsModelSelection
0020 {
0021     none,
0022     seltzer_berger,
0023     relativistic,
0024     all,
0025     size_
0026 };
0027 
0028 //---------------------------------------------------------------------------//
0029 //! MSC selection (TODO: make bitset?)
0030 enum class MscModelSelection
0031 {
0032     none,
0033     urban,  //!< Urban for all energies
0034     wentzelvi,  //!< Wentzel VI for all energies
0035     urban_wentzelvi,  //!< Urban below 100 MeV, Wentzel VI above
0036     size_
0037 };
0038 
0039 //---------------------------------------------------------------------------//
0040 //! Atomic relaxation options
0041 enum class RelaxationSelection
0042 {
0043     none,
0044     radiative,
0045     all,
0046     size_
0047 };
0048 
0049 //---------------------------------------------------------------------------//
0050 /*!
0051  * Construction options for Geant muon EM physics.
0052  */
0053 struct GeantMuonPhysicsOptions
0054 {
0055     //! Enable muon pair production
0056     bool pair_production{false};
0057     //! Enable muon ionization
0058     bool ionization{false};
0059     //! Enable muon bremsstrahlung
0060     bool bremsstrahlung{false};
0061     //! Enable muon single Coulomb scattering
0062     bool coulomb{false};
0063     //! Enable multiple coulomb scattering and select a model
0064     MscModelSelection msc{MscModelSelection::none};
0065 
0066     //! True if any process is activated
0067     explicit operator bool() const
0068     {
0069         return pair_production || ionization || bremsstrahlung || coulomb
0070                || msc != MscModelSelection::none;
0071     }
0072 };
0073 
0074 //! Equality operator
0075 constexpr bool
0076 operator==(GeantMuonPhysicsOptions const& a, GeantMuonPhysicsOptions const& b)
0077 {
0078     // clang-format off
0079     return a.pair_production == b.pair_production
0080            && a.ionization == b.ionization
0081            && a.bremsstrahlung == b.bremsstrahlung
0082            && a.coulomb == b.coulomb
0083            && a.msc == b.msc;
0084     // clang-format on
0085 }
0086 
0087 //---------------------------------------------------------------------------//
0088 /*!
0089  * Construction options for Geant physics.
0090  *
0091  * These options attempt to default to our closest match to \c
0092  * G4StandardEmPhysics. They are passed to the \c EmPhysicsList
0093  * and \c FtfpBert physics lists to provide an easy way to set up
0094  * physics options.
0095  */
0096 struct GeantPhysicsOptions
0097 {
0098     using MevEnergy = Quantity<units::Mev, double>;
0099 
0100     //!@{
0101     //! \name Gamma physics
0102 
0103     //! Enable Compton scattering
0104     bool compton_scattering{true};
0105     //! Enable the photoelectric effect
0106     bool photoelectric{true};
0107     //! Enable Rayleigh scattering
0108     bool rayleigh_scattering{true};
0109     //! Enable electron pair production
0110     bool gamma_conversion{true};
0111     //! Use G4GammaGeneral instead of individual gamma processes
0112     bool gamma_general{false};
0113     //!@}
0114 
0115     //!@{
0116     //! \name Electron and positron physics
0117 
0118     //! Enable discrete Coulomb
0119     bool coulomb_scattering{false};
0120     //! Enable e- and e+ ionization
0121     bool ionization{true};
0122     //! Enable positron annihilation
0123     bool annihilation{true};
0124     //! Enable bremsstrahlung and select a model
0125     BremsModelSelection brems{BremsModelSelection::all};
0126     //! Upper limit for the Seltzer-Berger bremsstrahlung model
0127     MevEnergy seltzer_berger_limit{1e3};  // 1 GeV
0128     //! Enable multiple coulomb scattering and select a model
0129     MscModelSelection msc{MscModelSelection::urban};
0130     //! Enable atomic relaxation and select a model
0131     RelaxationSelection relaxation{RelaxationSelection::none};
0132     //!@}
0133 
0134     //! Muon EM physics
0135     GeantMuonPhysicsOptions muon;
0136 
0137     //!@{
0138     //! \name Physics options
0139 
0140     //! Number of log-spaced bins per factor of 10 in energy
0141     int em_bins_per_decade{7};
0142     //! Enable universal energy fluctuations
0143     bool eloss_fluctuation{true};
0144     //! Apply relativistic corrections for select models
0145     bool lpm{true};
0146     //! See \c PhysicsParamsOptions::disable_integral_xs
0147     bool integral_approach{true};
0148     //!@}
0149 
0150     //!@{
0151     //! \name Cutoff options
0152 
0153     //! Lowest energy of any EM physics process
0154     MevEnergy min_energy{0.1 * 1e-3};  // 0.1 keV
0155     //! Highest energy of any EM physics process
0156     MevEnergy max_energy{100 * 1e6};  // 100 TeV
0157     //! See \c PhysicsParamsOptions::linear_loss_limit
0158     double linear_loss_limit{0.01};
0159     //! Tracking cutoff kinetic energy for e-/e+
0160     MevEnergy lowest_electron_energy{0.001};  // 1 keV
0161     //! Tracking cutoff kinetic energy for muons/hadrons
0162     MevEnergy lowest_muhad_energy{0.001};  // 1 keV
0163     //! Kill secondaries below the production cut
0164     bool apply_cuts{false};
0165     //! Set the default production cut for all particle types [len]
0166     double default_cutoff{0.1 * units::centimeter};
0167     //!@}
0168 
0169     //!@{
0170     //! \name Multiple scattering configuration
0171 
0172     //! e-/e+ range factor for MSC models
0173     double msc_range_factor{0.04};
0174     //! Muon/hadron range factor for MSC models
0175     double msc_muhad_range_factor{0.2};
0176     //! Safety factor for MSC models
0177     double msc_safety_factor{0.6};
0178     //! Lambda limit for MSC models [len]
0179     double msc_lambda_limit{0.1 * units::centimeter};
0180     //! Polar angle limit between single and multiple Coulomb scattering
0181     double msc_theta_limit{constants::pi};
0182     //! Factor for dynamic computation of angular limit between SS and MSC
0183     double angle_limit_factor{1};
0184     //! Whether lateral displacement is enabled for e-/e+ MSC
0185     bool msc_displaced{true};
0186     //! Whether lateral displacement is enabled for muon/hadron MSC
0187     bool msc_muhad_displaced{false};
0188     //! Step limit algorithm for e-/e+ MSC models
0189     MscStepLimitAlgorithm msc_step_algorithm{MscStepLimitAlgorithm::safety};
0190     //! Step limit algorithm for muon/hadron MSC models
0191     MscStepLimitAlgorithm msc_muhad_step_algorithm{
0192         MscStepLimitAlgorithm::minimal};
0193     //! Nuclear form factor model for Coulomm scattering
0194     NuclearFormFactorType form_factor{NuclearFormFactorType::exponential};
0195     //!@}
0196 
0197     //! Print detailed Geant4 output
0198     bool verbose{false};
0199 
0200     //! Optical physics options
0201     GeantOpticalPhysicsOptions optical{
0202         GeantOpticalPhysicsOptions::deactivated()};
0203 };
0204 
0205 //! Equality operator, mainly for test harness
0206 // TODO: when we require C++20, use `friend bool operator==(...) = default;`
0207 constexpr bool
0208 operator==(GeantPhysicsOptions const& a, GeantPhysicsOptions const& b)
0209 {
0210     // clang-format off
0211     return a.coulomb_scattering == b.coulomb_scattering
0212            && a.photoelectric == b.photoelectric
0213            && a.rayleigh_scattering == b.rayleigh_scattering
0214            && a.gamma_conversion == b.gamma_conversion
0215            && a.gamma_general == b.gamma_general
0216            && a.compton_scattering == b.compton_scattering
0217            && a.ionization == b.ionization
0218            && a.annihilation == b.annihilation
0219            && a.brems == b.brems
0220            && a.seltzer_berger_limit == b.seltzer_berger_limit
0221            && a.msc == b.msc
0222            && a.relaxation == b.relaxation
0223            && a.em_bins_per_decade == b.em_bins_per_decade
0224            && a.eloss_fluctuation == b.eloss_fluctuation
0225            && a.lpm == b.lpm
0226            && a.integral_approach == b.integral_approach
0227            && a.min_energy == b.min_energy
0228            && a.max_energy == b.max_energy
0229            && a.linear_loss_limit == b.linear_loss_limit
0230            && a.lowest_electron_energy == b.lowest_electron_energy
0231            && a.lowest_muhad_energy == b.lowest_muhad_energy
0232            && a.apply_cuts == b.apply_cuts
0233            && a.msc_range_factor == b.msc_range_factor
0234            && a.msc_muhad_range_factor == b.msc_muhad_range_factor
0235            && a.msc_safety_factor == b.msc_safety_factor
0236            && a.msc_lambda_limit == b.msc_lambda_limit
0237            && a.msc_theta_limit == b.msc_theta_limit
0238            && a.angle_limit_factor == b.angle_limit_factor
0239            && a.msc_displaced == b.msc_displaced
0240            && a.msc_muhad_displaced == b.msc_muhad_displaced
0241            && a.msc_step_algorithm == b.msc_step_algorithm
0242            && a.msc_muhad_step_algorithm == b.msc_muhad_step_algorithm
0243            && a.form_factor == b.form_factor
0244            && a.verbose == b.verbose
0245            && a.optical == b.optical;
0246     // clang-format on
0247 }
0248 
0249 //---------------------------------------------------------------------------//
0250 // FREE FUNCTIONS
0251 //---------------------------------------------------------------------------//
0252 
0253 char const* to_cstring(BremsModelSelection value);
0254 char const* to_cstring(MscModelSelection value);
0255 char const* to_cstring(RelaxationSelection value);
0256 
0257 //---------------------------------------------------------------------------//
0258 }  // namespace celeritas