Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-26 10:10:08

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 <optional>
0010 
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 (use \c std::nullopt to
0052  * disable).
0053  */
0054 struct GeantMuonPhysicsOptions
0055 {
0056     //! Enable muon pair production
0057     bool pair_production{true};
0058     //! Enable muon ionization
0059     bool ionization{true};
0060     //! Enable muon bremsstrahlung
0061     bool bremsstrahlung{true};
0062     //! Enable muon single Coulomb scattering
0063     bool coulomb{false};
0064     //! Enable multiple coulomb scattering and select a model.
0065     //! Muon MSC currently requires MSC enabled for electrons and positrons
0066     MscModelSelection msc{MscModelSelection::urban};
0067 };
0068 
0069 //! Equality operator
0070 constexpr bool operator==(GeantMuonPhysicsOptions const& a,
0071                           GeantMuonPhysicsOptions const& b)
0072 {
0073     // clang-format off
0074     return a.pair_production == b.pair_production
0075            && a.ionization == b.ionization
0076            && a.bremsstrahlung == b.bremsstrahlung
0077            && a.coulomb == b.coulomb
0078            && a.msc == b.msc;
0079     // clang-format on
0080 }
0081 
0082 //---------------------------------------------------------------------------//
0083 /*!
0084  * Construction options for Geant physics.
0085  *
0086  * These options attempt to default to our closest match to \c
0087  * G4StandardEmPhysics. They are passed to the \c EmPhysicsList
0088  * and \c FtfpBert physics lists to provide an easy way to set up
0089  * physics options.
0090  *
0091  * \todo This will be moved to celeritas::inp
0092  * \todo Rename default_cutoff to be consistent (it's a production cut)
0093  */
0094 struct GeantPhysicsOptions
0095 {
0096     using MevEnergy = Quantity<units::Mev, double>;
0097     using MuonSetup = GeantMuonPhysicsOptions;
0098     using OpticalSetup = GeantOpticalPhysicsOptions;
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     //! Enable Gamma nuclear interaction
0114     bool gamma_nuclear{false};
0115     //!@}
0116 
0117     //!@{
0118     //! \name Electron and positron physics
0119 
0120     //! Enable discrete Coulomb
0121     bool coulomb_scattering{false};
0122     //! Enable e- and e+ ionization
0123     bool ionization{true};
0124     //! Enable positron annihilation
0125     bool annihilation{true};
0126     //! Enable electro nuclear interaction
0127     bool electro_nuclear{false};
0128     //! Enable bremsstrahlung and select a model
0129     BremsModelSelection brems{BremsModelSelection::all};
0130     //! Upper limit for the Seltzer-Berger bremsstrahlung model
0131     MevEnergy seltzer_berger_limit{1e3};  // 1 GeV
0132     //! Enable multiple coulomb scattering and select a model.
0133     //! Electron/positron MSC requires ionization
0134     MscModelSelection msc{MscModelSelection::urban};
0135     //! Enable atomic relaxation and select a model
0136     RelaxationSelection relaxation{RelaxationSelection::none};
0137     //!@}
0138 
0139     //!@{
0140     //! \name Physics options
0141 
0142     //! Number of log-spaced bins per factor of 10 in energy
0143     int em_bins_per_decade{7};
0144     //! Enable universal energy fluctuations
0145     bool eloss_fluctuation{true};
0146     //! Apply relativistic corrections for select models
0147     bool lpm{true};
0148     //! See \c PhysicsParamsOptions::disable_integral_xs
0149     bool integral_approach{true};
0150     //!@}
0151 
0152     //!@{
0153     //! \name Cutoff options
0154 
0155     //! Lowest energy of any EM physics process
0156     MevEnergy min_energy{0.1 * 1e-3};  // 0.1 keV
0157     //! Highest energy of any EM physics process
0158     MevEnergy max_energy{100 * 1e6};  // 100 TeV
0159     //! See \c PhysicsParamsOptions::linear_loss_limit
0160     double linear_loss_limit{0.01};
0161     //! Tracking cutoff kinetic energy for e-/e+
0162     MevEnergy lowest_electron_energy{0.001};  // 1 keV
0163     //! Tracking cutoff kinetic energy for muons/hadrons
0164     MevEnergy lowest_muhad_energy{0.001};  // 1 keV
0165     //! Kill secondaries below the production cut
0166     bool apply_cuts{false};
0167     //! Set the default production cut for all particle types [len]
0168     double default_cutoff{0.1 * units::centimeter};
0169     //!@}
0170 
0171     //!@{
0172     //! \name Multiple scattering configuration
0173 
0174     //! e-/e+ range factor for MSC models
0175     double msc_range_factor{0.04};
0176     //! Muon/hadron range factor for MSC models
0177     double msc_muhad_range_factor{0.2};
0178     //! Safety factor for MSC models
0179     double msc_safety_factor{0.6};
0180     //! Lambda limit for MSC models [len]
0181     double msc_lambda_limit{0.1 * units::centimeter};
0182     //! Polar angle limit between single and multiple Coulomb scattering
0183     double msc_theta_limit{constants::pi};
0184     //! Factor for dynamic computation of angular limit between SS and MSC
0185     double angle_limit_factor{1};
0186     //! Whether lateral displacement is enabled for e-/e+ MSC
0187     bool msc_displaced{true};
0188     //! Whether lateral displacement is enabled for muon/hadron MSC
0189     bool msc_muhad_displaced{false};
0190     //! Step limit algorithm for e-/e+ MSC models
0191     MscStepLimitAlgorithm msc_step_algorithm{MscStepLimitAlgorithm::safety};
0192     //! Step limit algorithm for muon/hadron MSC models
0193     MscStepLimitAlgorithm msc_muhad_step_algorithm{
0194         MscStepLimitAlgorithm::minimal};
0195     //! Nuclear form factor model for Coulomm scattering
0196     NuclearFormFactorType form_factor{NuclearFormFactorType::exponential};
0197     //!@}
0198 
0199     //! Print detailed Geant4 output
0200     bool verbose{false};
0201 
0202     //! Muon EM physics (null: disabled)
0203     std::optional<MuonSetup> muon;
0204 
0205     //! Muon-catalyzed fusion physics
0206     bool mucf_physics{false};
0207 
0208     //! Optical physics options (null: disabled)
0209     std::optional<OpticalSetup> optical;
0210 
0211     //! True if any EM process is activated
0212     bool em() const
0213     {
0214         return compton_scattering || photoelectric || rayleigh_scattering
0215                || gamma_conversion || gamma_general || gamma_nuclear
0216                || coulomb_scattering || ionization || annihilation
0217                || electro_nuclear || brems != BremsModelSelection::none
0218                || msc != MscModelSelection::none;
0219     }
0220 
0221     //! Initialize with no physics
0222     static GeantPhysicsOptions deactivated()
0223     {
0224         GeantPhysicsOptions opt;
0225         // Gamma
0226         opt.compton_scattering = false;
0227         opt.photoelectric = false;
0228         opt.rayleigh_scattering = false;
0229         opt.gamma_conversion = false;
0230         opt.gamma_general = false;
0231         opt.gamma_nuclear = false;
0232         // Electron/positron
0233         opt.coulomb_scattering = false;
0234         opt.ionization = false;
0235         opt.annihilation = false;
0236         opt.electro_nuclear = false;
0237         opt.brems = BremsModelSelection::none;
0238         opt.msc = MscModelSelection::none;
0239         opt.relaxation = RelaxationSelection::none;
0240         // Muon and Optical default to nullopt (disabled)
0241         opt.mucf_physics = false;
0242         return opt;
0243     }
0244 };
0245 
0246 //! Equality operator, mainly for test harness
0247 // TODO: when we require C++20, use `friend bool operator==(...) = default;`
0248 constexpr bool operator==(GeantPhysicsOptions const& a,
0249                           GeantPhysicsOptions const& b)
0250 {
0251     // clang-format off
0252     return a.compton_scattering == b.compton_scattering
0253         && a.photoelectric == b.photoelectric
0254         && a.rayleigh_scattering == b.rayleigh_scattering
0255         && a.gamma_conversion == b.gamma_conversion
0256         && a.gamma_general == b.gamma_general
0257         && a.gamma_nuclear == b.gamma_nuclear
0258         // Electron and positron
0259         && a.coulomb_scattering == b.coulomb_scattering
0260         && a.ionization == b.ionization
0261         && a.annihilation == b.annihilation
0262         && a.electro_nuclear == b.electro_nuclear
0263         && a.brems == b.brems
0264         && a.seltzer_berger_limit == b.seltzer_berger_limit
0265         && a.msc == b.msc
0266         && a.relaxation == b.relaxation
0267         // Muon EM physics
0268         && a.muon == b.muon
0269         // Muon-catalyzed fusion physics
0270         && a.mucf_physics == b.mucf_physics
0271         // Physics options
0272         && a.em_bins_per_decade == b.em_bins_per_decade
0273         && a.eloss_fluctuation == b.eloss_fluctuation
0274         && a.lpm == b.lpm
0275         && a.integral_approach == b.integral_approach
0276         // Cutoff options
0277         && a.min_energy == b.min_energy
0278         && a.max_energy == b.max_energy
0279         && a.linear_loss_limit == b.linear_loss_limit
0280         && a.lowest_electron_energy == b.lowest_electron_energy
0281         && a.lowest_muhad_energy == b.lowest_muhad_energy
0282         && a.apply_cuts == b.apply_cuts
0283         && a.default_cutoff == b.default_cutoff
0284         // Multiple scattering configuration
0285         && a.msc_range_factor == b.msc_range_factor
0286         && a.msc_muhad_range_factor == b.msc_muhad_range_factor
0287         && a.msc_safety_factor == b.msc_safety_factor
0288         && a.msc_lambda_limit == b.msc_lambda_limit
0289         && a.msc_theta_limit == b.msc_theta_limit
0290         && a.angle_limit_factor == b.angle_limit_factor
0291         && a.msc_displaced == b.msc_displaced
0292         && a.msc_muhad_displaced == b.msc_muhad_displaced
0293         && a.msc_step_algorithm == b.msc_step_algorithm
0294         && a.msc_muhad_step_algorithm == b.msc_muhad_step_algorithm
0295         && a.form_factor == b.form_factor
0296         && a.verbose == b.verbose
0297         && a.optical == b.optical;
0298     // clang-format on
0299 }
0300 
0301 //---------------------------------------------------------------------------//
0302 // FREE FUNCTIONS
0303 //---------------------------------------------------------------------------//
0304 
0305 char const* to_cstring(BremsModelSelection value);
0306 char const* to_cstring(MscModelSelection value);
0307 char const* to_cstring(RelaxationSelection value);
0308 
0309 //---------------------------------------------------------------------------//
0310 // Helper to read the options from a file or stream.
0311 std::istream& operator>>(std::istream& is, GeantPhysicsOptions&);
0312 
0313 //---------------------------------------------------------------------------//
0314 // Helper to write the options to a file or stream.
0315 std::ostream& operator<<(std::ostream& os, GeantPhysicsOptions const&);
0316 
0317 //---------------------------------------------------------------------------//
0318 }  // namespace celeritas