|
GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Go to the documentation of this file.
46 GGcout(
"GGEMSCrossSections",
"GGEMSCrossSections", 3) <<
"GGEMSCrossSections creating..." <<
GGendl;
67 GGcout(
"GGEMSCrossSections",
"GGEMSCrossSections", 3) <<
"GGEMSCrossSections created!!!" <<
GGendl;
76 GGcout(
"GGEMSCrossSections",
"~GGEMSCrossSections", 3) <<
"GGEMSCrossSections erasing..." <<
GGendl;
92 GGcout(
"GGEMSCrossSections",
"~GGEMSCrossSections", 3) <<
"GGEMSCrossSections erased!!!" <<
GGendl;
101 GGcout(
"GGEMSCrossSections",
"Clean", 3) <<
"GGEMSCrossSections cleaning..." <<
GGendl;
113 GGcout(
"GGEMSCrossSections",
"Clean", 3) <<
"GGEMSCrossSections cleaned!!!" <<
GGendl;
122 GGcout(
"GGEMSCrossSections",
"AddProcess", 1) <<
"Adding " << process_name <<
" scattering process..." <<
GGendl;
124 if (process_name ==
"Compton") {
131 GGwarn(
"GGEMSCrossSections",
"AddProcess", 3) <<
"Compton scattering process already activated!!!" <<
GGendl;
134 else if (process_name ==
"Photoelectric") {
141 GGwarn(
"GGEMSCrossSections",
"AddProcess", 3) <<
"PhotoElectric effect process already activated!!!" <<
GGendl;
144 else if (process_name ==
"Rayleigh") {
151 GGwarn(
"GGEMSCrossSections",
"AddProcess", 3) <<
"PhotoElectric effect process already activated!!!" <<
GGendl;
155 std::ostringstream oss(std::ostringstream::out);
156 oss <<
"Unknown process!!! The available processes in GGEMS are:" << std::endl;
157 oss <<
" * For incident gamma:" << std::endl;
158 oss <<
" - 'Compton'" << std::endl;
159 oss <<
" - 'Photoelectric'" << std::endl;
160 oss <<
" - 'Rayleigh'" << std::endl;
171 GGcout(
"GGEMSCrossSections",
"Initialize", 1) <<
"Initializing cross section tables..." <<
GGendl;
189 particle_cross_sections_device->
min_energy_ = min_energy;
190 particle_cross_sections_device->
max_energy_ = max_energy;
203 GGfloat slope = logf(max_energy/min_energy);
204 for (
GGsize i = 0; i < number_of_bins; ++i) {
205 particle_cross_sections_device->
energy_bins_[i] = min_energy * expf(slope * (
static_cast<float>(i) / (
static_cast<GGfloat>(number_of_bins)-1.0f))) *
MeV;
226 GGcout(
"GGEMSCrossSections",
"LoadPhysicTablesOnHost", 1) <<
"Loading physic tables from OpenCL device to host (RAM)..." <<
GGendl;
239 for(
GGuchar j = 0; j < 32; ++j) {
285 if (e_MeV < min_energy || e_MeV > max_energy) {
286 std::ostringstream oss(std::ostringstream::out);
287 oss <<
"Problem energy: " << e_MeV <<
" " << unit <<
" is not in the range [" << min_energy <<
", " << max_energy <<
"] MeV!!!" << std::endl;
293 if (process_name ==
"Compton") {
296 else if (process_name ==
"Photoelectric") {
299 else if (process_name ==
"Rayleigh") {
303 std::ostringstream oss(std::ostringstream::out);
304 oss <<
"Unknown process!!! The available processes for photon in GGEMS are:" << std::endl;
305 oss <<
" - 'Compton'" << std::endl;
306 oss <<
" - 'Photoelectric'" << std::endl;
307 oss <<
" - 'Rayleigh'" << std::endl;
313 for (
GGsize i = 0; i < number_of_materials; ++i) {
335 return (cross_section/density) / (
cm2/
g);
353 cross_sections->
AddProcess(process_name, particle_name, is_secondary);
380 cross_sections->
Clean();
GGsize number_of_materials_
GGsize number_activated_devices_
GGEMS class handling RAM memory.
GGEMSEMProcess ** em_processes_list_
Compton Scattering process from standard model for Geant4 (G4KleinNishinaCompton)
GGsize number_of_activated_photon_processes_
#define MAX_CROSS_SECTION_TABLE_NUMBER_BINS
Definitions of miscellaneous mathematical functions.
__constant GGchar COMPTON_SCATTERING
GGEMS class handling the cross sections tables.
struct GGEMSParticleCrossSections_t GGEMSParticleCrossSections
std::vector< bool > is_process_activated_
GGfloat energy_bins_[MAX_CROSS_SECTION_TABLE_NUMBER_BINS]
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
cl::Buffer * GetMaterialTables(GGsize const &thread_index) const
get the pointer on material tables on OpenCL device
GGEMS class handling material(s) for a specific navigator.
GGEMS class handling the cross sections tables.
GGfloat LinearInterpolation(GGfloat const xa, GGfloat const ya, GGfloat const xb, GGfloat const yb, GGfloat const x)
interpolate the x value between point A and B
Structure storing the photon cross sections for OpenCL device.
GGEMS class managing the processes in GGEMS simulation.
GGint BinarySearchLeft(GGfloat const key, GGfloat const *array, GGint const size, GGint const offset, GGint min)
Find the index of the key value in the p_array buffer.
GGfloat photon_cross_sections_[NUMBER_PHOTON_PROCESSES][256 *MAX_CROSS_SECTION_TABLE_NUMBER_BINS]
__constant GGchar PHOTOELECTRIC_EFFECT
GGsize number_of_activated_processes_
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
void ReleaseDeviceBuffer(cl::Buffer *const device_ptr, T *host_ptr, GGsize const &thread_index)
Get the device pointer on host to write on it. Mandatory after a GetDeviceBufferWrite ou GetDeviceBuf...
GGfloat GetPhotonCrossSection(std::string const &process_name, std::string const &material_name, GGfloat const &energy, std::string const &unit) const
Get the cross section value for a process for a specific energy.
void LoadPhysicTablesOnHost(void)
Load physic tables from OpenCL device to RAM. Optimization for python user.
GGsize GetCrossSectionTableNumberOfBins(void) const
get the number of bins in the cross section table
GGfloat GetCrossSectionTableMinEnergy(void) const
get the minimum energy in the cross section table
Compton Scattering process from standard model for Geant4 (G4KleinNishinaCompton)
GGEMSCrossSections * create_ggems_cross_sections(void)
Get the GGEMSCrossSections pointer for python user.
GGEMSParticleCrossSections * particle_cross_sections_host_
void AddProcess(std::string const &process_name, std::string const &particle_type, bool const &is_secondary=false)
add a process to the GGEMS simulation
GGchar photon_cs_id_[NUMBER_PHOTON_PROCESSES]
void clean_ggems_cross_sections(GGEMSCrossSections *cross_sections)
clean all cross sections on each OpenCL device
GGfloat GetCrossSectionTableMaxEnergy(void) const
get the maximum energy in the cross section table
cl::Buffer * Allocate(void *host_ptr, GGsize const &size, GGsize const &thread_index, cl_mem_flags flags, std::string const &class_name="Undefined")
Allocation of OpenCL memory.
GGEMS mother class for electromagnectic process.
cl::Buffer ** particle_cross_sections_
std::string GetMaterialName(GGsize i) const
get the name of the material at position i
Rayleigh scattering process using Livermore model.
float get_cs_cross_sections(GGEMSCrossSections *cross_sections, char const *process_name, char const *material_name, GGfloat const energy, char const *unit)
get the cross section value of process
GGsize GetNumberOfMaterials(void) const
Get the number of materials in the phantom.
static GGEMSMaterialsDatabaseManager & GetInstance(void)
Create at first time the Singleton.
__constant GGchar NUMBER_PROCESSES
#define NUMBER_PHOTON_PROCESSES
Photoelectric Effect process using Sandia table.
rayleigh scattering process using Sandia table
GGEMS class managing the processes in GGEMS simulation.
void Clean(void)
clean all cross sections on each OpenCL device
~GGEMSCrossSections(void)
GGEMSCrossSections destructor.
T * GetDeviceBuffer(cl::Buffer *device_ptr, GGsize const &size, GGsize const &thread_index)
Get the device pointer on host to write on it. ReleaseDeviceBuffer must be used after this method!...
GGEMSCrossSections(void)
GGEMSCrossSections constructor.
void initialize_ggems_cross_sections(GGEMSCrossSections *cross_sections, GGEMSMaterials *materials)
Intialize the cross section tables for process and materials.
#define GGendl
overload C++ std::endl
GGEMS class handling material(s) for a specific navigator.
GGfloat photon_cross_sections_per_atom_[NUMBER_PHOTON_PROCESSES][101 *MAX_CROSS_SECTION_TABLE_NUMBER_BINS]
Photoelectric Effect process using Sandia table.
GGchar material_names_[256][64]
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
void Initialize(GGEMSMaterials const *materials)
Initialize all the activated processes computing tables on OpenCL device.
T EnergyUnit(T const &value, std::string const &unit)
Choose best energy unit.
__constant GGchar RAYLEIGH_SCATTERING
GGEMS class managing the material database.
static GGEMSProcessesManager & GetInstance(void)
Create at first time the Singleton.
GGEMSSingleMaterial GetMaterial(std::string const &material_name) const
get the material
void add_process_ggems_cross_sections(GGEMSCrossSections *cross_sections, char const *process_name, char const *particle_name, bool const is_secondary)
Add a process to cross section table.
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.