GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSRangeCutsManager.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 
40 {
41  GGcout("GGEMSRangeCutsManager", "GGEMSRangeCutsManager", 3) << "GGEMSRangeCutsManager creating..." << GGendl;
42 
43  GGcout("GGEMSRangeCutsManager", "GGEMSRangeCutsManager", 3) << "GGEMSRangeCutsManager created!!!" << GGendl;
44 }
45 
49 
51 {
52  GGcout("GGEMSRangeCutsManager", "~GGEMSRangeCutsManager", 3) << "GGEMSRangeCutsManager erasing..." << GGendl;
53 
54  GGcout("GGEMSRangeCutsManager", "~GGEMSRangeCutsManager", 3) << "GGEMSRangeCutsManager erased!!!" << GGendl;
55 }
56 
60 
62 {
63  GGcout("GGEMSRangeCutsManager", "Clean", 3) << "GGEMSRangeCutsManager cleaning..." << GGendl;
64 
65  GGcout("GGEMSRangeCutsManager", "Clean", 3) << "GGEMSRangeCutsManager cleaned!!!" << GGendl;
66 }
67 
71 
73 {
74  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << "Printing infos about range cuts" << GGendl;
75 
76  // Loop over the phantom and printing range cuts by materials in length and energy
78 
79  for (size_t i = 0; i < navigator_manager.GetNumberOfNavigators(); ++i) {
80  // Get pointer on phantom navigator
81  std::string name_of_phantom = ((navigator_manager.GetNavigators())[i])->GetNavigatorName();
82  // Get the Range cut pointer
83  GGEMSRangeCuts* range_cuts = ((navigator_manager.GetNavigators())[i])->GetMaterials()->GetRangeCuts();
84 
85  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << "Range cuts for phantom navigator: " << name_of_phantom << GGendl;
86  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << "---------------------------------" << GGendl;
87  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << "Length cuts:" << GGendl;
88  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Photon: " << BestDistanceUnit(range_cuts->GetPhotonDistanceCut()) << GGendl;
89  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Electron: " << BestDistanceUnit(range_cuts->GetElectronDistanceCut()) << GGendl;
90  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Positron: " << BestDistanceUnit(range_cuts->GetPositronDistanceCut()) << GGendl;
91  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << "Energy cuts:" << GGendl;
92  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Photon:" << GGendl;
93  EnergyCutUMap energy_cut_of_photon = range_cuts->GetPhotonEnergyCut();
94  for (auto&& j : energy_cut_of_photon) {
95  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " - " << j.first << ": " << BestEnergyUnit(j.second) << GGendl;
96  }
97  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Electron:" << GGendl;
98  EnergyCutUMap energy_cut_of_electron = range_cuts->GetElectronEnergyCut();
99  for (auto&& j : energy_cut_of_electron) {
100  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " - " << j.first << ": " << BestEnergyUnit(j.second)<< GGendl;
101  }
102  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " * Positron:" << GGendl;
103  EnergyCutUMap const energy_cut_of_positron = range_cuts->GetPositronEnergyCut();
104  for (auto&& j : energy_cut_of_positron) {
105  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << " - " << j.first << ": " << BestEnergyUnit(j.second) << GGendl;
106  }
107  GGcout("GGEMSRangeCutsManager", "PrintInfos", 0) << GGendl;
108  }
109 }
110 
114 
115 void GGEMSRangeCutsManager::SetLengthCut(std::string const& phantom_name, std::string const& particle_name, GGfloat const& value, std::string const& unit)
116 {
118 
119  if (phantom_name == "all") {
120  // Loop over phantom
121  for (size_t i = 0; i < navigator_manager.GetNumberOfNavigators(); ++i) {
122  ((navigator_manager.GetNavigators())[i])->GetMaterials()->SetDistanceCut(particle_name, value, unit);
123  }
124  }
125  else {
126  navigator_manager.GetNavigator(phantom_name)->GetMaterials()->SetDistanceCut(particle_name, value, unit);
127  }
128 }
129 
133 
135 {
137 }
138 
142 
143 void set_cut_range_cuts_manager(GGEMSRangeCutsManager* range_cut_manager, char const* phantom_name, char const* particle_name, GGfloat const value, char const* unit)
144 {
145  range_cut_manager->SetLengthCut(phantom_name, particle_name, value, unit);
146 }
GGEMSRangeCutsManager.hh
GGEMS class managing the range cuts in GGEMS simulation.
GGEMSNavigatorManager.hh
GGEMS class handling the navigators (detector + phantom) in GGEMS.
GGEMSRangeCuts::GetPositronEnergyCut
EnergyCutUMap GetPositronEnergyCut(void) const
get the map of energy cut with material for positron
Definition: GGEMSRangeCuts.hh:151
get_instance_range_cuts_manager
GGEMSRangeCutsManager * get_instance_range_cuts_manager(void)
Get the GGEMSRangeCutsManager pointer for python user.
Definition: GGEMSRangeCutsManager.cc:134
GGEMSRangeCuts
GGEMS class storing and converting the cut in energy cut.
Definition: GGEMSRangeCuts.hh:50
GGEMSNavigator::GetMaterials
GGEMSMaterials * GetMaterials(void) const
get the pointer on materials
Definition: GGEMSNavigator.hh:158
GGEMSNavigatorManager::GetNumberOfNavigators
GGsize GetNumberOfNavigators(void) const
Get the number of navigators.
Definition: GGEMSNavigatorManager.hh:126
GGEMSRangeCuts::GetPhotonDistanceCut
GGfloat GetPhotonDistanceCut(void) const
get the photon length cut
Definition: GGEMSRangeCuts.hh:116
BestDistanceUnit
std::string BestDistanceUnit(T const &value)
Choose best distance unit.
Definition: GGEMSSystemOfUnits.hh:217
GGEMSRangeCutsManager::GetInstance
static GGEMSRangeCutsManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSRangeCutsManager.hh:65
GGEMSRangeCuts::GetPhotonEnergyCut
EnergyCutUMap GetPhotonEnergyCut(void) const
get the map of energy cut with material
Definition: GGEMSRangeCuts.hh:123
GGEMSRangeCutsManager::Clean
void Clean(void)
clean OpenCL data if necessary
Definition: GGEMSRangeCutsManager.cc:61
GGEMSRangeCutsManager::~GGEMSRangeCutsManager
~GGEMSRangeCutsManager(void)
Unable the destructor for the user.
Definition: GGEMSRangeCutsManager.cc:50
BestEnergyUnit
std::string BestEnergyUnit(T const &value)
Choose best energy unit, mega is the reference.
Definition: GGEMSSystemOfUnits.hh:290
GGEMSNavigatorManager::GetInstance
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSNavigatorManager.hh:60
GGEMSRangeCuts.hh
GGEMS class storing and converting the cut in energy cut. The computations come from G4RToEConvForGam...
GGEMSRangeCutsManager::SetLengthCut
void SetLengthCut(std::string const &phantom_name, std::string const &particle_name, GGfloat const &value, std::string const &unit="mm")
set the range cut length for a phantom and a particle
Definition: GGEMSRangeCutsManager.cc:115
set_cut_range_cuts_manager
void set_cut_range_cuts_manager(GGEMSRangeCutsManager *range_cut_manager, char const *phantom_name, char const *particle_name, GGfloat const value, char const *unit)
set the range cut for a phantom and a particle
Definition: GGEMSRangeCutsManager.cc:143
GGEMSNavigatorManager
GGEMS class handling the navigators (detector + phantom) in GGEMS.
Definition: GGEMSNavigatorManager.hh:42
GGEMSRangeCutsManager::GGEMSRangeCutsManager
GGEMSRangeCutsManager(void)
Unable the constructor for the user.
Definition: GGEMSRangeCutsManager.cc:39
GGEMSRangeCutsManager::PrintInfos
void PrintInfos(void) const
print infos about range cut manager
Definition: GGEMSRangeCutsManager.cc:72
EnergyCutUMap
std::unordered_map< std::string, GGfloat > EnergyCutUMap
Definition: GGEMSRangeCuts.hh:41
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSNavigatorManager::GetNavigator
GGEMSNavigator * GetNavigator(std::string const &navigator_name) const
get the navigator by the name
Definition: GGEMSNavigatorManager.hh:141
GGEMSRangeCuts::GetElectronEnergyCut
EnergyCutUMap GetElectronEnergyCut(void) const
get the map of energy cut with material for electron
Definition: GGEMSRangeCuts.hh:137
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSNavigatorManager::GetNavigators
GGEMSNavigator ** GetNavigators(void) const
get the list of navigators
Definition: GGEMSNavigatorManager.hh:133
GGEMSRangeCuts::GetPositronDistanceCut
GGfloat GetPositronDistanceCut(void) const
get the positron length cut
Definition: GGEMSRangeCuts.hh:144
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
GGEMSRangeCuts::GetElectronDistanceCut
GGfloat GetElectronDistanceCut(void) const
get the electron length cut for photon
Definition: GGEMSRangeCuts.hh:130
GGEMSRangeCutsManager
GGEMS class managing the range cuts in GGEMS simulation.
Definition: GGEMSRangeCutsManager.hh:47
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273