Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-13 08:33:31

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/GeantOpticalPhysicsOptions.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 #include "celeritas/Types.hh"
0011 
0012 namespace celeritas
0013 {
0014 //---------------------------------------------------------------------------//
0015 //! Cherenkov process options
0016 struct CherenkovPhysicsOptions
0017 {
0018     //! Enable the process
0019     bool enable{true};
0020     //! Enable generation of Cherenkov photons
0021     bool stack_photons{true};
0022     //! Track generated photons before parent
0023     bool track_secondaries_first{true};
0024     //! Maximum number of photons that can be generated before limiting step
0025     int max_photons{100};
0026     //! Maximum percentage change in particle \f$\beta\f$  before limiting step
0027     double max_beta_change{10.0};
0028 
0029     //! True if the process is activated
0030     explicit operator bool() const { return enable; }
0031 };
0032 
0033 //! Equality operator, mainly for test harness
0034 constexpr bool
0035 operator==(CherenkovPhysicsOptions const& a, CherenkovPhysicsOptions const& b)
0036 {
0037     // clang-format off
0038     return a.enable == b.enable
0039            && a.stack_photons == b.stack_photons
0040            && a.track_secondaries_first == b.track_secondaries_first
0041            && a.max_photons == b.max_photons
0042            && a.max_beta_change == b.max_beta_change;
0043     // clang-format on
0044 }
0045 
0046 //---------------------------------------------------------------------------//
0047 //! Scintillation process options
0048 struct ScintillationPhysicsOptions
0049 {
0050     //! Enable the process
0051     bool enable{true};
0052 
0053     //! Enable generation of scintillation photons
0054     bool stack_photons{true};
0055     //! Track generated photons before parent
0056     bool track_secondaries_first{true};
0057     //! Use per-particle yield and time constants for photon generation
0058     bool by_particle_type{false};
0059     //! Use material properties for sampling photon generation time
0060     bool finite_rise_time{false};
0061     //! Attach scintillation interaction information to generated photon
0062     bool track_info{false};
0063 
0064     //! True if the process is activated
0065     explicit operator bool() const { return enable; }
0066 };
0067 
0068 //! Equality operator, mainly for test harness
0069 constexpr bool operator==(ScintillationPhysicsOptions const& a,
0070                           ScintillationPhysicsOptions const& b)
0071 {
0072     // clang-format off
0073     return a.enable == b.enable
0074            && a.stack_photons == b.stack_photons
0075            && a.track_secondaries_first == b.track_secondaries_first
0076            && a.by_particle_type == b.by_particle_type
0077            && a.finite_rise_time == b.finite_rise_time
0078            && a.track_info == b.track_info;
0079     // clang-format on
0080 }
0081 
0082 //---------------------------------------------------------------------------//
0083 //! Optical wavelength shifting process options
0084 struct WavelengthShiftingOptions
0085 {
0086     //! Enable the process
0087     bool enable{true};
0088     //! Select a model for sampling reemission time
0089     WlsTimeProfile time_profile{WlsTimeProfile::delta};
0090 
0091     //! True if the process is activated
0092     explicit operator bool() const { return enable; }
0093 };
0094 
0095 //! Equality operator, mainly for test harness
0096 constexpr bool operator==(WavelengthShiftingOptions const& a,
0097                           WavelengthShiftingOptions const& b)
0098 {
0099     return a.enable == b.enable && a.time_profile == b.time_profile;
0100 }
0101 
0102 //---------------------------------------------------------------------------//
0103 //! Optical boundary process options
0104 struct BoundaryPhysicsOptions
0105 {
0106     //! Enable the process
0107     bool enable{true};
0108     //! Invoke Geant4 SD at post step point if photon deposits energy
0109     bool invoke_sd{false};
0110 
0111     //! True if the process is activated
0112     explicit operator bool() const { return enable; }
0113 };
0114 
0115 //! Equality operator, mainly for test harness
0116 constexpr bool
0117 operator==(BoundaryPhysicsOptions const& a, BoundaryPhysicsOptions const& b)
0118 {
0119     return a.enable == b.enable && a.invoke_sd == b.invoke_sd;
0120 }
0121 
0122 //---------------------------------------------------------------------------//
0123 /*!
0124  * Construction options for Geant optical physics.
0125  *
0126  * These options attempt to default to our closest match to \c
0127  * G4OpticalPhysics from Geant4 10.5 onwards.
0128  *
0129  * \todo When we require C++20, use `friend bool operator==(...) = default;`
0130  * instead of manually writing the equality operators
0131  */
0132 struct GeantOpticalPhysicsOptions
0133 {
0134     //!@{
0135     //! \name Optical photon creation physics
0136 
0137     //! Cherenkov radiation options
0138     CherenkovPhysicsOptions cherenkov;
0139     //! Scintillation options
0140     ScintillationPhysicsOptions scintillation;
0141     //!@}
0142 
0143     //!@{
0144     //! \name Optical photon physics
0145 
0146     //! Enable wavelength shifting
0147     WavelengthShiftingOptions wavelength_shifting;
0148     //! Enable second wavelength shifting
0149     WavelengthShiftingOptions wavelength_shifting2;
0150     //! Enable boundary effects
0151     BoundaryPhysicsOptions boundary;
0152     //! Enable absorption
0153     bool absorption{true};
0154     //! Enable Rayleigh scattering
0155     bool rayleigh_scattering{true};
0156     //! Enable Mie scattering
0157     bool mie_scattering{true};
0158     //!@}
0159 
0160     //! Print detailed Geant4 output
0161     bool verbose{false};
0162 
0163     //! True if any process is activated
0164     explicit operator bool() const
0165     {
0166         return cherenkov || scintillation || wavelength_shifting
0167                || wavelength_shifting2 || boundary || absorption
0168                || rayleigh_scattering || mie_scattering;
0169     }
0170 
0171     //! Return instance with all processes deactivated
0172     static GeantOpticalPhysicsOptions deactivated()
0173     {
0174         GeantOpticalPhysicsOptions opts;
0175         opts.cherenkov.enable = false;
0176         opts.scintillation.enable = false;
0177         opts.wavelength_shifting.enable = false;
0178         opts.wavelength_shifting2.enable = false;
0179         opts.boundary.enable = false;
0180         opts.absorption = false;
0181         opts.rayleigh_scattering = false;
0182         opts.mie_scattering = false;
0183         return opts;
0184     }
0185 };
0186 
0187 //! Equality operator, mainly for test harness
0188 constexpr bool operator==(GeantOpticalPhysicsOptions const& a,
0189                           GeantOpticalPhysicsOptions const& b)
0190 {
0191     // clang-format off
0192     return a.cherenkov == b.cherenkov
0193            && a.scintillation == b.scintillation
0194            && a.wavelength_shifting == b.wavelength_shifting
0195            && a.wavelength_shifting2 == b.wavelength_shifting2
0196            && a.boundary == b.boundary
0197            && a.absorption == b.absorption
0198            && a.rayleigh_scattering == b.rayleigh_scattering
0199            && a.mie_scattering == b.mie_scattering
0200            && a.verbose == b.verbose;
0201     // clang-format on
0202 }
0203 
0204 //---------------------------------------------------------------------------//
0205 // FREE FUNCTIONS
0206 //---------------------------------------------------------------------------//
0207 
0208 char const* to_cstring(WlsTimeProfile value);
0209 
0210 //---------------------------------------------------------------------------//
0211 }  // namespace celeritas