Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:20

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