Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/celeritas/ext/GeantOpticalPhysicsOptions.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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