GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSMaterials.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 
31 #include <limits>
32 
37 
41 
43 {
44  GGcout("GGEMSMaterials", "GGEMSMaterials", 3) << "GGEMSMaterials creating..." << GGendl;
45 
46  // Allocation of cuts
48 
49  // Get the OpenCL manager
51 
52  // Get number of activated device
54 
56 
57 
58  GGcout("GGEMSMaterials", "GGEMSMaterials", 3) << "GGEMSMaterials created!!!" << GGendl;
59 }
60 
64 
66 {
67  GGcout("GGEMSMaterials", "~GGEMSMaterials", 3) << "GGEMSMaterials erasing..." << GGendl;
68 
69  if (range_cuts_) {
70  delete range_cuts_;
71  range_cuts_ = nullptr;
72  }
73 
74  GGcout("GGEMSMaterials", "~GGEMSMaterials", 3) << "GGEMSMaterials erased!!!" << GGendl;
75 }
76 
80 
82 {
83  GGcout("GGEMSMaterials", "Clean", 3) << "GGEMSMaterials cleaning..." << GGendl;
84 
86 
87  if (material_tables_) {
88  for (GGsize i = 0; i < number_activated_devices_; ++i) {
89  opencl_manager.Deallocate(material_tables_[i], sizeof(GGEMSMaterialTables), i);
90  }
91  delete[] material_tables_;
92  material_tables_ = nullptr;
93  }
94 
95  GGcout("GGEMSMaterials", "Clean", 3) << "GGEMSMaterials cleaned!!!" << GGendl;
96 }
97 
101 
102 void GGEMSMaterials::AddMaterial(std::string const& material_name)
103 {
104  // Checking the number of material
105  if (materials_.size() == 255) {
106  GGEMSMisc::ThrowException("GGEMSMaterials", "AddMaterial", "Limit of material reached. The limit is 255 materials!!!");
107  }
108 
109  // Add material and check if the material already exists
110  materials_.push_back(material_name);
111 }
115 
116 void GGEMSMaterials::SetDistanceCut(std::string const& particle_name, GGfloat const& value, std::string const& unit)
117 {
118  GGfloat cut = DistanceUnit(value, unit.c_str());
119 
120  if (particle_name == "gamma") {
122  }
123  else if (particle_name == "e+") {
125  }
126  else if (particle_name == "e-") {
128  }
129  else {
130  std::ostringstream oss(std::ostringstream::out);
131  oss << "Particle name " << particle_name << " unknown!!! The particles are:" << std::endl;
132  oss << " - gamma" << std::endl;
133  oss << " - e-" << std::endl;
134  oss << " - e+";
135  GGEMSMisc::ThrowException("GGEMSMaterials", "SetCut", oss.str());
136  }
137 }
138 
142 
144 {
145  // Get the OpenCL manager
147 
148  // Loop over the device
149  for (GGsize d = 0; d < number_activated_devices_; ++d) {
150  // Getting the OpenCL pointer on material tables
151  GGEMSMaterialTables* material_table_device = opencl_manager.GetDeviceBuffer<GGEMSMaterialTables>(material_tables_[d], sizeof(GGEMSMaterialTables), d);
152 
153  // Get the index of device
154  GGsize device_index = opencl_manager.GetIndexOfActivatedDevice(d);
155 
156  // Getting list of activated materials
157  GGcout("GGEMSMaterials", "PrintInfos", 0) << GGendl;
158  GGcout("GGEMSMaterials", "PrintInfos", 0) << "Material on device: " << opencl_manager.GetDeviceName(device_index) << GGendl;
159  GGcout("GGEMSMaterials", "PrintInfos", 0) << "Number of materials: " << static_cast<GGuint>(material_table_device->number_of_materials_) << GGendl;
160  GGcout("GGEMSMaterials", "PrintInfos", 0) << "Total number of chemical elements: " << material_table_device->total_number_of_chemical_elements_ << GGendl;
161  GGcout("GGEMSMaterials", "PrintInfos", 0) << "Activated Materials: " << GGendl;
162  GGcout("GGEMSMaterials", "PrintInfos", 0) << "-----------------------------------" << GGendl;
163  for (GGsize i = 0; i < material_table_device->number_of_materials_; ++i) {
164  GGcout("GGEMSMaterials", "PrintInfos", 0) << "* " << materials_.at(i) << GGendl;
165  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Number of chemical elements: " << static_cast<GGushort>(material_table_device->number_of_chemical_elements_[i]) << GGendl;
166  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Density: " << material_table_device->density_of_material_[i]/(g/cm3) << " g/cm3" << GGendl;
167  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Photon cut: " << BestEnergyUnit(material_table_device->photon_energy_cut_[i]) << GGendl;
168  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Electron cut: " << BestEnergyUnit(material_table_device->electron_energy_cut_[i]) << GGendl;
169  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Positron cut: " << BestEnergyUnit(material_table_device->positron_energy_cut_[i]) << GGendl;
170  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Radiation length: " << BestDistanceUnit(material_table_device->radiation_length_[i]) << GGendl;
171  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Total atomic density: " << material_table_device->number_of_atoms_by_volume_[i]/(mol/cm3) << " atom/cm3" << GGendl;
172  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Total electron density: " << material_table_device->number_of_electrons_by_volume_[i]/(mol/cm3) << " e-/cm3" << GGendl;
173  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Chemical Elements:" << GGendl;
174  for (GGsize j = 0; j < material_table_device->number_of_chemical_elements_[i]; ++j) {
175  GGsize chemical_element_id = material_table_device->index_of_chemical_elements_[i];
176  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + Z = " << static_cast<GGushort>(material_table_device->atomic_number_Z_[j+chemical_element_id]) << GGendl;
177  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + fraction of chemical element = " << material_table_device->mass_fraction_[j+chemical_element_id]/percent << " %" << GGendl;
178  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + Atomic number density = " << material_table_device->atomic_number_density_[j+chemical_element_id]/(mol/cm3) << " atom/cm3" << GGendl;
179  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + Element abundance = " << 100.0*material_table_device->atomic_number_density_[j+chemical_element_id]/material_table_device->number_of_atoms_by_volume_[i] << " %" << GGendl;
180  }
181  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Energy loss fluctuation data:" << GGendl;
182  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + Mean electron excitation energy: " << BestEnergyUnit(material_table_device->mean_excitation_energy_[i]) << GGendl;
183  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + Log mean electron excitation energy: " << material_table_device->log_mean_excitation_energy_[i] << GGendl;
184  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + f1: " << material_table_device->f1_fluct_[i] << GGendl;
185  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + f2: " << material_table_device->f2_fluct_[i] << GGendl;
186  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + energy0: " << BestEnergyUnit(material_table_device->energy0_fluct_[i]) << GGendl;
187  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + energy1: " << BestEnergyUnit(material_table_device->energy1_fluct_[i]) << GGendl;
188  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + energy2: " << BestEnergyUnit(material_table_device->energy2_fluct_[i]) << GGendl;
189  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + log energy 1: " << material_table_device->log_energy1_fluct_[i] << GGendl;
190  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + log energy 2: " << material_table_device->log_energy2_fluct_[i] << GGendl;
191  GGcout("GGEMSMaterials", "PrintInfos", 0) << " - Density correction data:" << GGendl;
192  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + x0 = " << material_table_device->x0_density_[i] << GGendl;
193  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + x1 = " << material_table_device->x1_density_[i] << GGendl;
194  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + d0 = " << material_table_device->d0_density_[i] << GGendl;
195  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + -C = " << material_table_device->c_density_[i] << GGendl;
196  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + a = " << material_table_device->a_density_[i] << GGendl;
197  GGcout("GGEMSMaterials", "PrintInfos", 0) << " + m = " << material_table_device->m_density_[i] << GGendl;
198  }
199  GGcout("GGEMSMaterials", "PrintInfos", 0) << GGendl;
200 
201  // Release the pointer, mandatory step!!!
202  opencl_manager.ReleaseDeviceBuffer(material_tables_[d], material_table_device, d);
203  }
204 }
205 
209 
211 {
212  GGcout("GGEMSMaterials", "BuildMaterialTables", 3) << "Building the material tables..." << GGendl;
213 
214  // Get the OpenCL manager
216 
217  // Get the material database manager
219 
220  // Loop over activated device and allocate particle buffer on each device
221  for (GGsize d = 0; d < number_activated_devices_; ++d) {
222  // Allocating memory for material tables in OpenCL device
223  material_tables_[d] = opencl_manager.Allocate(nullptr, sizeof(GGEMSMaterialTables), d, CL_MEM_READ_WRITE, "GGEMSMaterials");
224 
225  // Getting the OpenCL pointer on material tables
226  GGEMSMaterialTables* material_table_device = opencl_manager.GetDeviceBuffer<GGEMSMaterialTables>(material_tables_[d], sizeof(GGEMSMaterialTables), d);
227 
228  // Get the number of activated materials
229  material_table_device->number_of_materials_ = static_cast<GGuchar>(materials_.size());
230 
231  // Loop over the materials
232  GGsize index_to_chemical_element = 0;
233  for (GGsize i = 0; i < materials_.size(); ++i) {
234  // Getting the material infos from database
235  GGEMSSingleMaterial const& single_material = material_database_manager.GetMaterial(materials_.at(i));
236 
237  // Storing infos about material
238  material_table_device->number_of_chemical_elements_[i] = single_material.nb_elements_;
239  material_table_device->density_of_material_[i] = single_material.density_;
240 
241  // Initialize some counters
242  material_table_device->number_of_atoms_by_volume_[i] = 0.0f;
243  material_table_device->number_of_electrons_by_volume_[i] = 0.0f;
244 
245  // Loop over the chemical elements by material
246  for (GGsize j = 0; j < single_material.nb_elements_; ++j) {
247  // Getting the chemical element
248  GGEMSChemicalElement const& chemical_element = material_database_manager.GetChemicalElement(single_material.chemical_element_name_[j]);
249 
250  // Atomic number Z
251  material_table_device->atomic_number_Z_[j+index_to_chemical_element] = chemical_element.atomic_number_Z_;
252 
253  // Mass fraction of element by material
254  material_table_device->mass_fraction_[j+index_to_chemical_element] = single_material.mixture_f_[j];
255 
256  // Atomic number density
257  material_table_device->atomic_number_density_[j+index_to_chemical_element] = material_database_manager.GetAtomicNumberDensity(materials_.at(i), j);
258 
259  // Increment density of atoms and electrons
260  material_table_device->number_of_atoms_by_volume_[i] += material_table_device->atomic_number_density_[j+index_to_chemical_element];
261  material_table_device->number_of_electrons_by_volume_[i] += material_table_device->atomic_number_density_[j+index_to_chemical_element] * chemical_element.atomic_number_Z_;
262  }
263 
264  // Computing ionization params for a material
265  GGEMSIonizationParamsMaterial ionization_params(&single_material);
266  material_table_device->mean_excitation_energy_[i] = ionization_params.GetMeanExcitationEnergy();
267  material_table_device->log_mean_excitation_energy_[i] = ionization_params.GetLogMeanExcitationEnergy();
268  material_table_device->x0_density_[i] = ionization_params.GetX0Density();
269  material_table_device->x1_density_[i] = ionization_params.GetX1Density();
270  material_table_device->d0_density_[i] = ionization_params.GetD0Density();
271  material_table_device->c_density_[i] = ionization_params.GetCDensity();
272  material_table_device->a_density_[i] = ionization_params.GetADensity();
273  material_table_device->m_density_[i] = ionization_params.GetMDensity();
274 
275  // Energy fluctuation parameters
276  material_table_device->f1_fluct_[i] = ionization_params.GetF1Fluct();
277  material_table_device->f2_fluct_[i] = ionization_params.GetF2Fluct();
278  material_table_device->energy0_fluct_[i] = ionization_params.GetEnergy0Fluct();
279  material_table_device->energy1_fluct_[i] = ionization_params.GetEnergy1Fluct();
280  material_table_device->energy2_fluct_[i] = ionization_params.GetEnergy2Fluct();
281  material_table_device->log_energy1_fluct_[i] = ionization_params.GetLogEnergy1Fluct();
282  material_table_device->log_energy2_fluct_[i] = ionization_params.GetLogEnergy2Fluct();
283 
284  // Radiation length
285  material_table_device->radiation_length_[i] = material_database_manager.GetRadiationLength(materials_.at(i));
286 
287  // Computing the access to chemical element by material
288  material_table_device->index_of_chemical_elements_[i] = index_to_chemical_element;
289  index_to_chemical_element += material_table_device->number_of_chemical_elements_[i];
290  }
291 
292  // Storing number total of chemical elements
293  material_table_device->total_number_of_chemical_elements_ = index_to_chemical_element;
294 
295  // Release the pointer, mandatory step!!!
296  opencl_manager.ReleaseDeviceBuffer(material_tables_[d], material_table_device, d);
297  }
298 
299  // Converting length cut to energy cut
301 }
302 
306 
307 GGfloat GGEMSMaterials::GetDensity(std::string const& material_name, GGsize const& thread_index) const
308 {
309  // Get the OpenCL manager
311 
312  // Getting the OpenCL pointer on material tables
313  GGEMSMaterialTables* material_table_device = opencl_manager.GetDeviceBuffer<GGEMSMaterialTables>(material_tables_[thread_index], sizeof(GGEMSMaterialTables), thread_index);
314 
315  // Get index of material
316  std::vector<std::string>::const_iterator iter_mat = std::find(materials_.begin(), materials_.end(), material_name);
317  if (iter_mat == materials_.end()) {
318  std::ostringstream oss(std::ostringstream::out);
319  oss << "Material '" << material_name << "' not found!!!" << std::endl;
320  GGEMSMisc::ThrowException("GGEMSMaterials", "GetDensity", oss.str());
321  }
322  ptrdiff_t index = std::distance(materials_.begin(), iter_mat);
323 
324  GGfloat density = material_table_device->density_of_material_[index];
325 
326  opencl_manager.ReleaseDeviceBuffer(material_tables_[thread_index], material_table_device, thread_index);
327 
328  return density / g * cm3;
329 }
330 
334 
335 GGfloat GGEMSMaterials::GetAtomicNumberDensity(std::string const& material_name, GGsize const& thread_index) const
336 {
337  // Get the OpenCL manager
339 
340  // Getting the OpenCL pointer on material tables
341  GGEMSMaterialTables* material_table_device = opencl_manager.GetDeviceBuffer<GGEMSMaterialTables>(material_tables_[thread_index], sizeof(GGEMSMaterialTables), thread_index);
342 
343  // Get index of material
344  ptrdiff_t index = GetMaterialIndex(material_name);
345 
346  GGfloat atomic_number_density = material_table_device->atomic_number_density_[index];
347 
348  opencl_manager.ReleaseDeviceBuffer(material_tables_[thread_index], material_table_device, thread_index);
349 
350  return atomic_number_density / (mol/cm3);
351 }
352 
356 
357 GGfloat GGEMSMaterials::GetEnergyCut(std::string const& material_name, std::string const& particle_type, GGfloat const& distance, std::string const& unit, GGsize const& thread_index)
358 {
359  // Get the OpenCL manager
361 
362  // Set distance cut
363  SetDistanceCut(particle_type, distance, unit);
364 
365  // Convert cut
367 
368  // Getting the OpenCL pointer on material tables
369  GGEMSMaterialTables* material_table_device = opencl_manager.GetDeviceBuffer<GGEMSMaterialTables>(material_tables_[thread_index], sizeof(GGEMSMaterialTables), thread_index);
370 
371  // Get index of material
372  ptrdiff_t index = GetMaterialIndex(material_name);
373 
374  GGfloat energy_cut = 0.0f;
375  if (particle_type == "gamma") {
376  energy_cut = material_table_device->photon_energy_cut_[index];
377  }
378  else if (particle_type == "e+") {
379  energy_cut = material_table_device->positron_energy_cut_[index];
380  }
381  else if (particle_type == "e-") {
382  energy_cut = material_table_device->electron_energy_cut_[index];
383  }
384 
385  opencl_manager.ReleaseDeviceBuffer(material_tables_[thread_index], material_table_device, thread_index);
386 
387  return energy_cut / keV;
388 }
389 
393 
395 {
396  GGcout("GGEMSMaterials", "Initialize", 3) << "Initializing the materials..." << GGendl;
397 
398  // Build material table depending on physics and cuts
400 }
401 
405 
407 {
408  return new(std::nothrow) GGEMSMaterials;
409 }
410 
414 
415 void add_material_ggems_materials(GGEMSMaterials* materials, char const* material_name)
416 {
417  materials->AddMaterial(material_name);
418 }
419 
423 
425 {
426  materials->Initialize();
427 }
428 
432 
434 {
435  materials->PrintInfos();
436 }
437 
441 
442 GGfloat get_density_ggems_materials(GGEMSMaterials* materials, char const* material_name)
443 {
444  return materials->GetDensity(material_name, 0);
445 }
446 
450 
451 GGfloat get_energy_cut_ggems_materials(GGEMSMaterials* materials, char const* material_name, char const* particle_type, GGfloat const distance, char const* unit)
452 {
453  return materials->GetEnergyCut(material_name, particle_type, distance, unit);
454 }
455 
459 
461 {
462  return materials->GetAtomicNumberDensity(material_name, 0);
463 }
464 
468 
470 {
471  materials->Clean();
472 }
GGEMSMaterials::range_cuts_
GGEMSRangeCuts * range_cuts_
Definition: GGEMSMaterials.hh:211
GGEMSRAMManager.hh
GGEMS class handling RAM memory.
GGEMSMaterialTables_t::energy1_fluct_
GGfloat energy1_fluct_[255]
Definition: GGEMSMaterialTables.hh:64
GGEMSNavigatorManager.hh
GGEMS class handling the navigators (detector + phantom) in GGEMS.
GGEMSMaterials::GetMaterialIndex
ptrdiff_t GetMaterialIndex(std::string const &material_name) const
get the index of the material
Definition: GGEMSMaterials.hh:140
GGEMSMaterialTables_t::x0_density_
GGfloat x0_density_[255]
Definition: GGEMSMaterialTables.hh:55
GGEMSMaterialTables_t::density_of_material_
GGfloat density_of_material_[255]
Definition: GGEMSMaterialTables.hh:49
GGEMSIonizationParamsMaterial::GetLogMeanExcitationEnergy
GGfloat GetLogMeanExcitationEnergy(void) const
get the log mean excitation energy
Definition: GGEMSIonizationParamsMaterial.hh:203
GGEMSSingleMaterial
GGEMS structure managing a specific material.
Definition: GGEMSMaterialsDatabaseManager.hh:64
GGEMSRangeCuts
GGEMS class storing and converting the cut in energy cut.
Definition: GGEMSRangeCuts.hh:50
GGEMSRangeCuts::SetElectronDistanceCut
void SetElectronDistanceCut(GGfloat const &cut)
set the electron length cut by the range cut manager
Definition: GGEMSRangeCuts.cc:101
GGEMSOpenCLManager::GetNumberOfActivatedDevice
GGsize GetNumberOfActivatedDevice(void) const
get the number of activated devices
Definition: GGEMSOpenCLManager.hh:167
get_atomic_number_density_ggems_materials
GGfloat get_atomic_number_density_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Get the density of material in g.cm-3.
Definition: GGEMSMaterials.cc:460
percent
__constant GGfloat percent
Definition: GGEMSSystemOfUnits.hh:188
GGEMSMaterialTables_t::atomic_number_density_
GGfloat atomic_number_density_[255 *32]
Definition: GGEMSMaterialTables.hh:75
BestDistanceUnit
std::string BestDistanceUnit(T const &value)
Choose best distance unit.
Definition: GGEMSSystemOfUnits.hh:217
GGEMSMaterials
GGEMS class handling material(s) for a specific navigator.
Definition: GGEMSMaterials.hh:49
initialize_ggems_materials
void initialize_ggems_materials(GGEMSMaterials *materials)
Intialize the tables for the materials.
Definition: GGEMSMaterials.cc:424
GGEMSMaterialTables_t::mass_fraction_
GGfloat mass_fraction_[255 *32]
Definition: GGEMSMaterialTables.hh:76
GGEMSMaterialTables_t::energy0_fluct_
GGfloat energy0_fluct_[255]
Definition: GGEMSMaterialTables.hh:63
GGEMSIonizationParamsMaterial::GetX0Density
GGfloat GetX0Density(void) const
get the x0 density
Definition: GGEMSIonizationParamsMaterial.hh:217
GGEMSMaterialTables_t::log_energy2_fluct_
GGfloat log_energy2_fluct_[255]
Definition: GGEMSMaterialTables.hh:67
GGEMSRangeCuts::SetPhotonDistanceCut
void SetPhotonDistanceCut(GGfloat const &cut)
set the photon length cut by the range cut manager
Definition: GGEMSRangeCuts.cc:87
GGEMSIonizationParamsMaterial.hh
GGEMS class managing some physical params for ionization process for material.
GGEMSMaterialTables_t::f2_fluct_
GGfloat f2_fluct_[255]
Definition: GGEMSMaterialTables.hh:62
GGushort
#define GGushort
Definition: GGEMSTypes.hh:217
GGEMSMaterialTables_t::atomic_number_Z_
GGuchar atomic_number_Z_[255 *32]
Definition: GGEMSMaterialTables.hh:74
GGEMSIonizationParamsMaterial::GetF2Fluct
GGfloat GetF2Fluct(void) const
get the f2 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:266
GGEMSOpenCLManager::Deallocate
void Deallocate(cl::Buffer *buffer, GGsize size, GGsize const &thread_index, std::string const &class_name="Undefined")
Deallocation of OpenCL memory.
Definition: GGEMSOpenCLManager.cc:981
GGEMSIonizationParamsMaterial::GetEnergy2Fluct
GGfloat GetEnergy2Fluct(void) const
get the energy 2 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:287
GGEMSOpenCLManager::ReleaseDeviceBuffer
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...
Definition: GGEMSOpenCLManager.hh:495
GGEMSMaterialTables_t::mean_excitation_energy_
GGfloat mean_excitation_energy_[255]
Definition: GGEMSMaterialTables.hh:52
GGEMSSingleMaterial::chemical_element_name_
std::vector< std::string > chemical_element_name_
Definition: GGEMSMaterialsDatabaseManager.hh:65
GGEMSMaterialTables_t::number_of_materials_
GGsize number_of_materials_
Definition: GGEMSMaterialTables.hh:44
BestEnergyUnit
std::string BestEnergyUnit(T const &value)
Choose best energy unit, mega is the reference.
Definition: GGEMSSystemOfUnits.hh:290
GGEMSMaterials::Clean
void Clean(void)
clean all declared materials on OpenCL device
Definition: GGEMSMaterials.cc:81
GGEMSMaterialTables_t::x1_density_
GGfloat x1_density_[255]
Definition: GGEMSMaterialTables.hh:56
GGEMSRangeCuts.hh
GGEMS class storing and converting the cut in energy cut. The computations come from G4RToEConvForGam...
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGEMSIonizationParamsMaterial::GetEnergy1Fluct
GGfloat GetEnergy1Fluct(void) const
get the energy 1 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:280
GGEMSMaterials::Initialize
void Initialize(void)
Initialize the materials for a navigator/phantom.
Definition: GGEMSMaterials.cc:394
GGEMSMaterialTables_t::d0_density_
GGfloat d0_density_[255]
Definition: GGEMSMaterialTables.hh:57
keV
__constant GGfloat keV
Definition: GGEMSSystemOfUnits.hh:102
create_ggems_materials
GGEMSMaterials * create_ggems_materials(void)
Get the GGEMSMaterials pointer for python user.
Definition: GGEMSMaterials.cc:406
cm3
__constant GGfloat cm3
Definition: GGEMSSystemOfUnits.hh:59
GGEMSIonizationParamsMaterial::GetLogEnergy1Fluct
GGfloat GetLogEnergy1Fluct(void) const
get the log energy 1 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:294
GGEMSIonizationParamsMaterial::GetEnergy0Fluct
GGfloat GetEnergy0Fluct(void) const
get the energy 0 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:273
GGEMSIonizationParamsMaterial::GetLogEnergy2Fluct
GGfloat GetLogEnergy2Fluct(void) const
get the log energy 2 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:301
GGEMSOpenCLManager::Allocate
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.
Definition: GGEMSOpenCLManager.cc:945
GGEMSMaterials::BuildMaterialTables
void BuildMaterialTables(void)
Building material tables.
Definition: GGEMSMaterials.cc:210
GGEMSMaterialTables_t::c_density_
GGfloat c_density_[255]
Definition: GGEMSMaterialTables.hh:58
GGEMSMaterialTables_t::number_of_chemical_elements_
GGsize number_of_chemical_elements_[255]
Definition: GGEMSMaterialTables.hh:48
get_energy_cut_ggems_materials
GGfloat get_energy_cut_ggems_materials(GGEMSMaterials *materials, char const *material_name, char const *particle_type, GGfloat const distance, char const *unit)
Get the energy cut of material in keV.
Definition: GGEMSMaterials.cc:451
GGEMSMaterialTables_t::index_of_chemical_elements_
GGsize index_of_chemical_elements_[255]
Definition: GGEMSMaterialTables.hh:73
GGEMSIonizationParamsMaterial::GetCDensity
GGfloat GetCDensity(void) const
get the c density
Definition: GGEMSIonizationParamsMaterial.hh:238
GGEMSMaterialTables_t::radiation_length_
GGfloat radiation_length_[255]
Definition: GGEMSMaterialTables.hh:54
GGEMSIonizationParamsMaterial::GetADensity
GGfloat GetADensity(void) const
get the a density
Definition: GGEMSIonizationParamsMaterial.hh:245
GGEMSMaterialsDatabaseManager::GetInstance
static GGEMSMaterialsDatabaseManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSMaterialsDatabaseManager.hh:97
GGEMSMaterials::materials_
std::vector< std::string > materials_
Definition: GGEMSMaterials.hh:208
GGEMSIonizationParamsMaterial::GetX1Density
GGfloat GetX1Density(void) const
get the x1 density
Definition: GGEMSIonizationParamsMaterial.hh:224
GGEMSRangeCuts::SetPositronDistanceCut
void SetPositronDistanceCut(GGfloat const &cut)
set the positron length cut by the range cut manager
Definition: GGEMSRangeCuts.cc:115
GGEMSSingleMaterial::density_
GGfloat density_
Definition: GGEMSMaterialsDatabaseManager.hh:67
GGEMSMaterialTables_t::electron_energy_cut_
GGfloat electron_energy_cut_[255]
Definition: GGEMSMaterialTables.hh:69
GGEMSSingleMaterial::mixture_f_
std::vector< GGfloat > mixture_f_
Definition: GGEMSMaterialsDatabaseManager.hh:66
GGEMSMaterialsDatabaseManager::GetAtomicNumberDensity
GGfloat GetAtomicNumberDensity(std::string const &material, GGsize const &index) const
Compute the atomic number density of an element in a material.
Definition: GGEMSMaterialsDatabaseManager.hh:216
GGEMSMaterialTables_t::m_density_
GGfloat m_density_[255]
Definition: GGEMSMaterialTables.hh:60
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSMaterialTables_t::photon_energy_cut_
GGfloat photon_energy_cut_[255]
Definition: GGEMSMaterialTables.hh:68
GGEMSMaterialTables_t::f1_fluct_
GGfloat f1_fluct_[255]
Definition: GGEMSMaterialTables.hh:61
GGEMSMaterialTables_t
Structure storing the material tables on OpenCL device.
Definition: GGEMSMaterialTables.hh:42
print_material_properties_ggems_materials
void print_material_properties_ggems_materials(GGEMSMaterials *materials)
Print tables.
Definition: GGEMSMaterials.cc:433
GGEMSMaterialTables_t::energy2_fluct_
GGfloat energy2_fluct_[255]
Definition: GGEMSMaterialTables.hh:65
GGEMSChemicalElement
GGEMS structure managing a specific chemical element.
Definition: GGEMSMaterialsDatabaseManager.hh:51
g
__constant GGfloat g
Definition: GGEMSSystemOfUnits.hh:111
GGEMSMaterialsDatabaseManager::GetChemicalElement
GGEMSChemicalElement GetChemicalElement(std::string const &chemical_element_name) const
get the chemical element
Definition: GGEMSMaterialsDatabaseManager.hh:187
GGEMSOpenCLManager::GetDeviceBuffer
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!...
Definition: GGEMSOpenCLManager.hh:480
GGEMSMaterialTables
struct GGEMSMaterialTables_t GGEMSMaterialTables
GGEMSRangeCuts::ConvertCutsFromDistanceToEnergy
void ConvertCutsFromDistanceToEnergy(GGEMSMaterials *materials)
Convert cut from length to energy.
Definition: GGEMSRangeCuts.cc:590
GGEMSMaterialTables_t::a_density_
GGfloat a_density_[255]
Definition: GGEMSMaterialTables.hh:59
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
mol
__constant GGfloat mol
Definition: GGEMSSystemOfUnits.hh:161
GGEMSIonizationParamsMaterial
GGEMS class handling material(s) for a specific navigator.
Definition: GGEMSIonizationParamsMaterial.hh:150
GGEMSMaterialTables_t::log_mean_excitation_energy_
GGfloat log_mean_excitation_energy_[255]
Definition: GGEMSMaterialTables.hh:53
GGEMSOpenCLManager
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
Definition: GGEMSOpenCLManager.hh:54
GGEMSMaterialTables_t::number_of_electrons_by_volume_
GGfloat number_of_electrons_by_volume_[255]
Definition: GGEMSMaterialTables.hh:51
clean_ggems_materials
void clean_ggems_materials(GGEMSMaterials *materials)
clean all declared materials on OpenCL device
Definition: GGEMSMaterials.cc:469
GGuchar
#define GGuchar
Definition: GGEMSTypes.hh:203
GGEMSChemicalElement::atomic_number_Z_
GGuchar atomic_number_Z_
Definition: GGEMSMaterialsDatabaseManager.hh:56
add_material_ggems_materials
void add_material_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Add a material.
Definition: GGEMSMaterials.cc:415
GGEMSOpenCLManager::GetDeviceName
std::string GetDeviceName(GGsize const &device_index) const
Get the name of the activated device.
Definition: GGEMSOpenCLManager.hh:145
GGEMSMaterialTables_t::number_of_atoms_by_volume_
GGfloat number_of_atoms_by_volume_[255]
Definition: GGEMSMaterialTables.hh:50
GGEMSMaterials::PrintInfos
void PrintInfos(void) const
printing labels and materials infos
Definition: GGEMSMaterials.cc:143
GGEMSMaterialTables_t::positron_energy_cut_
GGfloat positron_energy_cut_[255]
Definition: GGEMSMaterialTables.hh:70
GGEMSMaterials::SetDistanceCut
void SetDistanceCut(std::string const &particle_name, GGfloat const &value, std::string const &unit)
set the cut for a particle in distance
Definition: GGEMSMaterials.cc:116
GGEMSMaterials::GetAtomicNumberDensity
GGfloat GetAtomicNumberDensity(std::string const &material_name, GGsize const &thread_index=0) const
get the atomic number density of material
Definition: GGEMSMaterials.cc:335
GGEMSMaterialTables_t::total_number_of_chemical_elements_
GGsize total_number_of_chemical_elements_
Definition: GGEMSMaterialTables.hh:45
GGEMSMaterials::material_tables_
cl::Buffer ** material_tables_
Definition: GGEMSMaterials.hh:209
GGEMSMaterials::~GGEMSMaterials
~GGEMSMaterials(void)
GGEMSMaterials destructor.
Definition: GGEMSMaterials.cc:65
GGEMSIonizationParamsMaterial::GetF1Fluct
GGfloat GetF1Fluct(void) const
get the f1 fluctuation
Definition: GGEMSIonizationParamsMaterial.hh:259
GGEMSIonizationParamsMaterial::GetMDensity
GGfloat GetMDensity(void) const
get the m density
Definition: GGEMSIonizationParamsMaterial.hh:252
GGEMSOpenCLManager::GetIndexOfActivatedDevice
GGsize GetIndexOfActivatedDevice(GGsize const &thread_index) const
get the index of activated device
Definition: GGEMSOpenCLManager.hh:175
GGuint
#define GGuint
Definition: GGEMSTypes.hh:231
GGEMSMaterials::GGEMSMaterials
GGEMSMaterials(void)
GGEMSMaterials constructor.
Definition: GGEMSMaterials.cc:42
GGEMSMaterials::GetEnergyCut
GGfloat GetEnergyCut(std::string const &material_name, std::string const &particle_type, GGfloat const &distance, std::string const &unit, GGsize const &thread_index=0)
Get the energy cut of material in keV.
Definition: GGEMSMaterials.cc:357
GGEMSMaterials::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSMaterials.hh:210
GGEMSMaterials::AddMaterial
void AddMaterial(std::string const &material_name)
Add a material associated to a phantom.
Definition: GGEMSMaterials.cc:102
GGEMSMaterialsDatabaseManager::GetRadiationLength
GGfloat GetRadiationLength(std::string const &material) const
get the radiation length of a material
Definition: GGEMSMaterialsDatabaseManager.hh:199
GGEMSSingleMaterial::nb_elements_
GGsize nb_elements_
Definition: GGEMSMaterialsDatabaseManager.hh:68
GGEMSMaterialsDatabaseManager
GGEMS class managing the material database.
Definition: GGEMSMaterialsDatabaseManager.hh:79
GGEMSIonizationParamsMaterial::GetD0Density
GGfloat GetD0Density(void) const
get the d0 density
Definition: GGEMSIonizationParamsMaterial.hh:231
GGEMSMaterialsDatabaseManager::GetMaterial
GGEMSSingleMaterial GetMaterial(std::string const &material_name) const
get the material
Definition: GGEMSMaterialsDatabaseManager.hh:167
GGEMSMaterials::GetDensity
GGfloat GetDensity(std::string const &material_name, GGsize const &thread_index=0) const
get the density of material
Definition: GGEMSMaterials.cc:307
GGEMSIonizationParamsMaterial::GetMeanExcitationEnergy
GGfloat GetMeanExcitationEnergy(void) const
get the mean excitation energy
Definition: GGEMSIonizationParamsMaterial.hh:196
get_density_ggems_materials
GGfloat get_density_ggems_materials(GGEMSMaterials *materials, char const *material_name)
Get the density of material in g.cm-3.
Definition: GGEMSMaterials.cc:442
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
DistanceUnit
T DistanceUnit(T const &value, std::string const &unit)
Choose best distance unit.
Definition: GGEMSSystemOfUnits.hh:243
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273
GGEMSOpenCLManager::GetInstance
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSOpenCLManager.hh:72
GGEMSMaterialTables_t::log_energy1_fluct_
GGfloat log_energy1_fluct_[255]
Definition: GGEMSMaterialTables.hh:66