GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSRayleighScattering.cc
Go to the documentation of this file.
1 // ************************************************************************
2 // * This file is part of GGEMS. *
3 // * *
4 // * GGEMS is free software: you can redistribute it and/or modify *
5 // * it under the terms of the GNU General Public License as published by *
6 // * the Free Software Foundation, either version 3 of the License, or *
7 // * (at your option) any later version. *
8 // * *
9 // * GGEMS is distributed in the hope that it will be useful, *
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 // * GNU General Public License for more details. *
13 // * *
14 // * You should have received a copy of the GNU General Public License *
15 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
16 // * *
17 // ************************************************************************
18 
34 
38 
39 GGEMSRayleighScattering::GGEMSRayleighScattering(std::string const& primary_particle, bool const& is_secondary)
41 {
42  GGcout("GGEMSRayleighScattering", "GGEMSRayleighScattering", 3) << "GGEMSRayleighScattering creating..." << GGendl;
43 
44  process_name_ = "Rayleigh";
45 
46  // Check type of primary particle
47  if (primary_particle != "gamma") {
48  std::ostringstream oss(std::ostringstream::out);
49  oss << "For Rayleigh scattering, incident particle has to be a 'gamma'";
50  GGEMSMisc::ThrowException("GGEMSRayleighScattering", "GGEMSRayleighScattering", oss.str());
51  }
52 
53  // Checking secondaries
54  if (is_secondary == true) {
55  GGwarn("GGEMSRayleighScattering", "GGEMSRayleighScattering", 0) << "There is no secondary during Rayleigh process!!! Secondary flag set to false" << GGendl;
56  }
57 
59  primary_particle_ = "gamma";
60  is_secondaries_ = false;
61 
62  GGcout("GGEMSRayleighScattering", "GGEMSRayleighScattering", 3) << "GGEMSRayleighScattering created!!!" << GGendl;
63 }
64 
68 
70 {
71  GGcout("GGEMSRayleighScattering", "GGEMSRayleighScattering", 3) << "GGEMSRayleighScattering erasing..." << GGendl;
72 
73  GGcout("GGEMSRayleighScattering", "GGEMSRayleighScattering", 3) << "GGEMSRayleighScattering erased!!!" << GGendl;
74 }
75 
79 
81 {
82  // Energy in range [250 eV; 100 GeV]
83  if (energy < 250e-6f || energy > 100e3f) return 0.0f;
84 
85  GGint const kStart = GGEMSRayleighTable::kCrossSectionCumulativeIntervals[atomic_number];
86  GGint const kStop = kStart + 2 * (GGEMSRayleighTable::kCrossSectionNumberOfIntervals[atomic_number]-1);
87 
88  GGint pos = kStart;
89  for (; pos < kStop; pos += 2) {
90  if (GGEMSRayleighTable::kCrossSection[pos] >= static_cast<GGfloat>(energy)) break;
91  }
92 
93  if (energy < 1e3f) { // 1 GeV
94  return static_cast<GGfloat>(1.0e-22 * LogLogInterpolation(
95  energy,
98  }
99  else {
100  return 1.0e-22f * GGEMSRayleighTable::kCrossSection[pos-1];
101  }
102 }
GGEMSEMProcess::primary_particle_
std::string primary_particle_
Definition: GGEMSEMProcess.hh:127
GGEMSMathAlgorithms.hh
Definitions of miscellaneous mathematical functions.
GGwarn
GGEMSStream GGwarn
Definition: GGEMSPrint.cc:36
GGEMSRayleighScattering::~GGEMSRayleighScattering
~GGEMSRayleighScattering(void)
GGEMSRayleighScattering destructor.
Definition: GGEMSRayleighScattering.cc:69
GGEMSEMProcess::process_name_
std::string process_name_
Definition: GGEMSEMProcess.hh:126
GGEMSRayleighScattering::GGEMSRayleighScattering
GGEMSRayleighScattering(std::string const &primary_particle="gamma", bool const &is_secondary=false)
GGEMSRayleighScattering constructor.
Definition: GGEMSRayleighScattering.cc:39
GGint
#define GGint
Definition: GGEMSTypes.hh:224
GGEMSEMProcess
GGEMS mother class for electromagnectic process.
Definition: GGEMSEMProcess.hh:47
GGEMSRayleighTable::kCrossSectionCumulativeIntervals
__constant GGint kCrossSectionCumulativeIntervals[101]
Definition: GGEMSRayleighScattering.hh:100
GGEMSRayleighScattering.hh
Rayleigh scattering process using Livermore model.
LogLogInterpolation
GGfloat LogLogInterpolation(GGfloat x, GGfloat x0, GGfloat y0, GGfloat x1, GGfloat y1)
log log interpolation of the x value between point (x0,y0) and (x1,y1)
Definition: GGEMSMathAlgorithms.hh:108
GGEMSRayleighTable::kCrossSectionNumberOfIntervals
__constant GGint kCrossSectionNumberOfIntervals[101]
Definition: GGEMSRayleighScattering.hh:140
GGEMSEMProcess::is_secondaries_
bool is_secondaries_
Definition: GGEMSEMProcess.hh:129
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSEMProcess::process_id_
GGchar process_id_
Definition: GGEMSEMProcess.hh:125
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSMaterials.hh
GGEMS class handling material(s) for a specific navigator.
GGEMSRayleighTable::kCrossSection
__constant GGfloat kCrossSection[213816]
Definition: GGEMSRayleighScattering.hh:260
RAYLEIGH_SCATTERING
__constant GGchar RAYLEIGH_SCATTERING
Definition: GGEMSProcessConstants.hh:45
GGuchar
#define GGuchar
Definition: GGEMSTypes.hh:203
GGEMSRayleighScattering::ComputeCrossSectionPerAtom
GGfloat ComputeCrossSectionPerAtom(GGfloat const &energy, GGuchar const &atomic_number) const override
compute Compton cross section for an atom with Klein-Nishina
Definition: GGEMSRayleighScattering.cc:80
GGEMSMisc::ThrowException
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
Definition: GGEMSTools.cc:61
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273