GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSProcessesManager.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 
35 
39 
41 : cross_section_table_number_of_bins_(CROSS_SECTION_TABLE_NUMBER_BINS),
42  cross_section_table_min_energy_(CROSS_SECTION_TABLE_ENERGY_MIN),
43  cross_section_table_max_energy_(CROSS_SECTION_TABLE_ENERGY_MAX),
44  is_processes_print_tables_(false)
45 {
46  GGcout("GGEMSProcessesManager", "GGEMSProcessesManager", 3) << "GGEMSProcessesManager creating..." << GGendl;
47 
48  GGcout("GGEMSProcessesManager", "GGEMSProcessesManager", 3) << "GGEMSProcessesManager created!!!" << GGendl;
49 }
50 
54 
56 {
57  GGcout("GGEMSProcessesManager", "~GGEMSProcessesManager", 3) << "GGEMSProcessesManager erasing..." << GGendl;
58 
59  GGcout("GGEMSProcessesManager", "~GGEMSProcessesManager", 3) << "GGEMSProcessesManager erased!!!" << GGendl;
60 }
61 
65 
67 {
68  GGcout("GGEMSProcessesManager", "Clean", 3) << "GGEMSProcessesManager cleaning..." << GGendl;
69 
70  GGcout("GGEMSProcessesManager", "Clean", 3) << "GGEMSProcessesManager cleaned!!!" << GGendl;
71 }
72 
76 
78 {
79  cross_section_table_number_of_bins_ = number_of_bins;
80 
81  // Checking number of bins
83  GGwarn("GGEMSProcessesManager", "SetCrossSectionTableNumberOfBins", 0) << "Warning!!! Number of bins in the cross section table > "
84  << MAX_CROSS_SECTION_TABLE_NUMBER_BINS << " the number of bins is set to "
87  }
88 }
89 
93 
95 {
97 
98  // Checking the min value
100  std::ostringstream oss(std::ostringstream::out);
101  oss << "The minimum of energy in the cross section table is 990 eV, yours is " << BestEnergyUnit(cross_section_table_min_energy_);
102  GGEMSMisc::ThrowException("GGEMSProcessesManager", "SetCrossSectionTableMinimumEnergy", oss.str());
103  }
104 }
105 
109 
111 {
113 
114  // Checking the max value
116  std::ostringstream oss(std::ostringstream::out);
117  oss << "The maximum of energy in the cross section table is 250 MeV, yours is " << BestEnergyUnit(cross_section_table_max_energy_);
118  GGEMSMisc::ThrowException("GGEMSProcessesManager", "SetCrossSectionTableMaximumEnergy", oss.str());
119  }
120 }
121 
125 
126 void GGEMSProcessesManager::AddProcess(std::string const& process_name, std::string const& particle_name, std::string const& phantom_name)
127 {
128  // Pointer on phantoms
130 
131  if (phantom_name == "all") {
132  // Loop over phantom
133  for (size_t i = 0; i < navigator_manager.GetNumberOfNavigators(); ++i) {
134  ((navigator_manager.GetNavigators())[i])->GetCrossSections()->AddProcess(process_name, particle_name);
135  }
136  }
137  else {
138  navigator_manager.GetNavigator(phantom_name)->GetCrossSections()->AddProcess(process_name, particle_name);
139  }
140 }
141 
145 
147 {
148  // Pointer on phantoms
150 
151  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << "Cross section table parameters:" << GGendl;
152  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << "-------------------------------" << GGendl;
153  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << " * Number of bins for the cross section table: " << cross_section_table_number_of_bins_ << GGendl;
154  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << " * Range in energy of cross section table: [" << BestEnergyUnit(cross_section_table_min_energy_) << ", " << BestEnergyUnit(cross_section_table_max_energy_) << "]" << GGendl;
155  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << GGendl;
156  // Loop over all phantoms
157  for (size_t i = 0; i < navigator_manager.GetNumberOfNavigators(); ++i) {
158  GGEMSCrossSections* cross_sections = ((navigator_manager.GetNavigators())[i])->GetCrossSections();
159  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << "Activated processes in phantom: " << ((navigator_manager.GetNavigators())[i])->GetNavigatorName() << GGendl;
160  for (size_t j = 0; j < cross_sections->GetNumberOfActivatedEMProcesses(); ++j) {
161  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << " * " << cross_sections->GetEMProcessesList()[j]->GetProcessName() << GGendl;
162  }
163  GGcout("GGEMSProcessesManager", "PrintInfos", 0) << GGendl;
164  }
165 }
166 
170 
172 {
173  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << "Available processes:" << GGendl;
174  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << "--------------------" << GGendl;
175  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " * 'Compton' scattering (Klein-Nishina model without atomic shell effect)" << GGendl;
176  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " - 'gamma' incident particle" << GGendl;
177  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " - 'e-' secondary particle" << GGendl;
178  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << GGendl;
179  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " * 'Photoelectric' effect (Sandia table)" << GGendl;
180  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " - 'gamma' incident particle" << GGendl;
181  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " - 'e-' secondary particle" << GGendl;
182  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << GGendl;
183  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " * 'Rayleigh' scattering (Livermore model)" << GGendl;
184  GGcout("GGEMSProcessesManager", "PrintAvailableProcesses", 0) << " - 'gamma' incident particle" << GGendl;
185 }
186 
190 
191 void GGEMSProcessesManager::PrintPhysicTables(bool const& is_processes_print_tables)
192 {
193  is_processes_print_tables_ = is_processes_print_tables;
194 }
195 
199 
201 {
203 }
204 
208 
209 void add_process_processes_manager(GGEMSProcessesManager* processes_manager, char const* process_name, char const* particle_name, char const* phantom_name)
210 {
211  processes_manager->AddProcess(process_name, particle_name, phantom_name);
212 }
213 
217 
219 {
220  processes_manager->SetCrossSectionTableNumberOfBins(number_of_bins);
221 }
222 
226 
227 void set_cross_section_table_minimum_energy_processes_manager(GGEMSProcessesManager* processes_manager, GGfloat const energy, char const* unit)
228 {
229  processes_manager->SetCrossSectionTableMinimumEnergy(energy, unit);
230 }
231 
235 
236 void set_cross_section_table_maximum_energy_processes_manager(GGEMSProcessesManager* processes_manager, GGfloat const energy, char const* unit)
237 {
238  processes_manager->SetCrossSectionTableMaximumEnergy(energy, unit);
239 }
240 
244 
246 {
247  processes_manager->PrintInfos();
248 }
249 
253 
255 {
256  processes_manager->PrintAvailableProcesses();
257 }
258 
262 
263 void print_tables_processes_manager(GGEMSProcessesManager* processes_manager, bool const is_processes_print_tables)
264 {
265  processes_manager->PrintPhysicTables(is_processes_print_tables);
266 }
GGEMSNavigatorManager.hh
GGEMS class handling the navigators (detector + phantom) in GGEMS.
MAX_CROSS_SECTION_TABLE_NUMBER_BINS
#define MAX_CROSS_SECTION_TABLE_NUMBER_BINS
Definition: GGEMSProcessConstants.hh:58
GGEMSProcessesManager::PrintInfos
void PrintInfos(void) const
Print all infos about processes.
Definition: GGEMSProcessesManager.cc:146
set_cross_section_table_minimum_energy_processes_manager
void set_cross_section_table_minimum_energy_processes_manager(GGEMSProcessesManager *processes_manager, GGfloat const energy, char const *unit)
set the minimum energy in the cross section table
Definition: GGEMSProcessesManager.cc:227
GGEMSCrossSections
GGEMS class handling the cross sections tables.
Definition: GGEMSCrossSections.hh:53
add_process_processes_manager
void add_process_processes_manager(GGEMSProcessesManager *processes_manager, char const *process_name, char const *particle_name, char const *phantom_name)
add a process for a specific phantom or all the phantom
Definition: GGEMSProcessesManager.cc:209
GGEMSNavigatorManager::GetNumberOfNavigators
GGsize GetNumberOfNavigators(void) const
Get the number of navigators.
Definition: GGEMSNavigatorManager.hh:126
CROSS_SECTION_TABLE_ENERGY_MAX
__constant GGfloat CROSS_SECTION_TABLE_ENERGY_MAX
Definition: GGEMSProcessConstants.hh:57
GGEMSCrossSections::GetCrossSections
cl::Buffer * GetCrossSections(GGsize const &thread_index) const
return the pointer to OpenCL buffer storing cross sections
Definition: GGEMSCrossSections.hh:129
GGwarn
GGEMSStream GGwarn
Definition: GGEMSPrint.cc:36
GGEMSCrossSections.hh
GGEMS class handling the cross sections tables.
GGEMSProcessesManager.hh
GGEMS class managing the processes in GGEMS simulation.
GGEMSEMProcess::GetProcessName
std::string GetProcessName(void) const
get the name of the process
Definition: GGEMSEMProcess.hh:92
GGEMSNavigator::GetCrossSections
GGEMSCrossSections * GetCrossSections(void) const
get the pointer on cross sections
Definition: GGEMSNavigator.hh:165
BestEnergyUnit
std::string BestEnergyUnit(T const &value)
Choose best energy unit, mega is the reference.
Definition: GGEMSSystemOfUnits.hh:290
GGEMSProcessesManager::cross_section_table_min_energy_
GGfloat cross_section_table_min_energy_
Definition: GGEMSProcessesManager.hh:181
GGEMSEMProcess.hh
GGEMS mother class for electromagnectic process.
GGEMSNavigatorManager::GetInstance
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSNavigatorManager.hh:60
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
CROSS_SECTION_TABLE_ENERGY_MIN
__constant GGfloat CROSS_SECTION_TABLE_ENERGY_MIN
Definition: GGEMSProcessConstants.hh:56
GGEMSCrossSections::AddProcess
void AddProcess(std::string const &process_name, std::string const &particle_type, bool const &is_secondary=false)
add a process to the GGEMS simulation
Definition: GGEMSCrossSections.cc:120
get_instance_processes_manager
GGEMSProcessesManager * get_instance_processes_manager(void)
Get the GGEMSProcessesManager pointer for python user.
Definition: GGEMSProcessesManager.cc:200
set_cross_section_table_maximum_energy_processes_manager
void set_cross_section_table_maximum_energy_processes_manager(GGEMSProcessesManager *processes_manager, GGfloat const energy, char const *unit)
set the maximum energy in the cross section table
Definition: GGEMSProcessesManager.cc:236
GGEMSNavigatorManager
GGEMS class handling the navigators (detector + phantom) in GGEMS.
Definition: GGEMSNavigatorManager.hh:42
GGEMSProcessesManager::PrintAvailableProcesses
void PrintAvailableProcesses(void) const
Print all infos about available processes.
Definition: GGEMSProcessesManager.cc:171
GGEMSProcessesManager::GGEMSProcessesManager
GGEMSProcessesManager(void)
Unable the constructor for the user.
Definition: GGEMSProcessesManager.cc:40
print_available_processes_manager
void print_available_processes_manager(GGEMSProcessesManager *processes_manager)
print infos about available processes
Definition: GGEMSProcessesManager.cc:254
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSProcessesManager::~GGEMSProcessesManager
~GGEMSProcessesManager(void)
Unable the destructor for the user.
Definition: GGEMSProcessesManager.cc:55
GGEMSNavigatorManager::GetNavigator
GGEMSNavigator * GetNavigator(std::string const &navigator_name) const
get the navigator by the name
Definition: GGEMSNavigatorManager.hh:141
GGEMSProcessesManager::PrintPhysicTables
void PrintPhysicTables(bool const &is_processes_print_tables)
print physic tables to screen
Definition: GGEMSProcessesManager.cc:191
GGEMSProcessesManager
GGEMS class managing the processes in GGEMS simulation.
Definition: GGEMSProcessesManager.hh:42
GGEMSProcessesManager::Clean
void Clean(void)
clean OpenCL data if necessary
Definition: GGEMSProcessesManager.hh:171
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
CROSS_SECTION_TABLE_NUMBER_BINS
__constant GGshort CROSS_SECTION_TABLE_NUMBER_BINS
Definition: GGEMSProcessConstants.hh:59
GGEMSProcessesManager::AddProcess
void AddProcess(std::string const &process_name, std::string const &particle_name, std::string const &phantom_name)
add a process for a specific phantom or all the phantom
Definition: GGEMSProcessesManager.cc:126
GGEMSNavigatorManager::GetNavigators
GGEMSNavigator ** GetNavigators(void) const
get the list of navigators
Definition: GGEMSNavigatorManager.hh:133
GGEMSProcessesManager::SetCrossSectionTableMinimumEnergy
void SetCrossSectionTableMinimumEnergy(GGfloat const &energy, char const *unit="keV")
set the minimum energy in the cross section table
Definition: GGEMSProcessesManager.cc:94
EnergyUnit
T EnergyUnit(T const &value, std::string const &unit)
Choose best energy unit.
Definition: GGEMSSystemOfUnits.hh:316
GGEMSProcessesManager::SetCrossSectionTableNumberOfBins
void SetCrossSectionTableNumberOfBins(GGsize const &number_of_bins)
set the number of bins in the cross section table
Definition: GGEMSProcessesManager.cc:77
GGEMSProcessesManager::SetCrossSectionTableMaximumEnergy
void SetCrossSectionTableMaximumEnergy(GGfloat const &energy, char const *unit="keV")
set the maximum energy in the cross section table
Definition: GGEMSProcessesManager.cc:110
GGEMSProcessesManager::cross_section_table_number_of_bins_
GGsize cross_section_table_number_of_bins_
Definition: GGEMSProcessesManager.hh:180
GGEMSProcessesManager::cross_section_table_max_energy_
GGfloat cross_section_table_max_energy_
Definition: GGEMSProcessesManager.hh:182
print_tables_processes_manager
void print_tables_processes_manager(GGEMSProcessesManager *processes_manager, bool const is_processes_print_tables)
print infos about physic tables
Definition: GGEMSProcessesManager.cc:263
GGEMSCrossSections::GetNumberOfActivatedEMProcesses
GGsize GetNumberOfActivatedEMProcesses(void) const
get the number of activated processes
Definition: GGEMSCrossSections.hh:121
set_cross_section_table_number_of_bins_processes_manager
void set_cross_section_table_number_of_bins_processes_manager(GGEMSProcessesManager *processes_manager, GGsize const number_of_bins)
set the number of the bins in the cross section table
Definition: GGEMSProcessesManager.cc:218
GGEMSProcessesManager::is_processes_print_tables_
bool is_processes_print_tables_
Definition: GGEMSProcessesManager.hh:183
GGEMSCrossSections::GetEMProcessesList
GGEMSEMProcess ** GetEMProcessesList(void) const
get the pointer on activated process
Definition: GGEMSCrossSections.hh:114
GGEMSProcessesManager::GetInstance
static GGEMSProcessesManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSProcessesManager.hh:60
print_infos_processes_manager
void print_infos_processes_manager(GGEMSProcessesManager *processes_manager)
print infos about processes
Definition: GGEMSProcessesManager.cc:245
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