GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSNavigatorManager.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 : navigators_(nullptr),
41  number_of_navigators_(0),
42  world_(nullptr)
43 {
44  GGcout("GGEMSNavigatorManager", "GGEMSNavigatorManager", 3) << "GGEMSNavigatorManager creating..." << GGendl;
45 
46  GGcout("GGEMSNavigatorManager", "GGEMSNavigatorManager", 3) << "GGEMSNavigatorManager created!!!" << GGendl;
47 }
48 
52 
54 {
55  GGcout("GGEMSNavigatorManager", "~GGEMSNavigatorManager", 3) << "GGEMSNavigatorManager erasing..." << GGendl;
56 
57  if (navigators_) {
58  delete[] navigators_;
59  navigators_ = nullptr;
60  }
61 
62  GGcout("GGEMSNavigatorManager", "~GGEMSNavigatorManager", 3) << "GGEMSNavigatorManager erased!!!" << GGendl;
63 }
64 
68 
70 {
71  GGcout("GGEMSNavigatorManager", "Clean", 3) << "GGEMSNavigatorManager cleaning..." << GGendl;
72 
73  GGcout("GGEMSNavigatorManager", "Clean", 3) << "GGEMSNavigatorManager cleaned!!!" << GGendl;
74 }
75 
79 
81 {
82  GGcout("GGEMSNavigatorManager", "Store", 3) << "Storing new navigator in GGEMS..." << GGendl;
83 
84  // Set index of navigator and store the pointer
86 
87  if (number_of_navigators_ == 0) {
88  navigators_ = new GGEMSNavigator*[1];
89  navigators_[0] = navigator;
90  }
91  else {
93  for (GGsize i = 0; i < number_of_navigators_; ++i) {
94  tmp[i] = navigators_[i];
95  }
96 
97  tmp[number_of_navigators_] = navigator;
98 
99  delete[] navigators_;
100  navigators_ = tmp;
101  }
102 
104 }
105 
109 
111 {
112  GGcout("GGEMSNavigatorManager", "StoreWorld", 3) << "Storing world in GGEMS..." << GGendl;
113  world_ = world;
114 }
115 
119 
121 {
122  for (GGsize i = 0; i < number_of_navigators_; ++i) {
123  navigators_[i]->SaveResults();
124  }
125 
126  // Checking if world exists
127  if (world_) world_->SaveResults();
128 }
129 
133 
134 void GGEMSNavigatorManager::Initialize(bool const& is_tracking) const
135 {
136  GGcout("GGEMSNavigatorManager", "Initialize", 3) << "Initializing the GGEMS navigator(s)..." << GGendl;
137 
138  // A navigator must be declared
139  if (number_of_navigators_ == 0) {
140  std::ostringstream oss(std::ostringstream::out);
141  oss << "A navigator (detector or phantom) has to be declared!!!";
142  GGEMSMisc::ThrowException("GGEMSNavigatorManager", "Initialize", oss.str());
143  }
144 
145  // Initialization of world
146  if (world_) {
147  if (is_tracking) world_->EnableTracking();
148  world_->Initialize();
149  }
150 
151  // Initialization of phantoms
152  for (GGsize i = 0; i < number_of_navigators_; ++i) {
153  if (is_tracking) navigators_[i]->EnableTracking();
154  navigators_[i]->Initialize();
155  }
156 }
157 
161 
163 {
164  GGcout("GGEMSNavigatorManager", "PrintInfos", 0) << "Printing infos about phantom navigators" << GGendl;
165  GGcout("GGEMSNavigatorManager", "PrintInfos", 0) << "Number of navigator(s): " << number_of_navigators_ << GGendl;
166 
167  for (GGsize i = 0; i < number_of_navigators_; ++i) {
168  navigators_[i]->PrintInfos();
169  }
170 }
171 
175 
176 void GGEMSNavigatorManager::FindSolid(GGsize const& thread_index) const
177 {
178  for (GGsize i = 0; i < number_of_navigators_; ++i) {
179  navigators_[i]->ParticleSolidDistance(thread_index);
180  }
181 }
182 
186 
187 void GGEMSNavigatorManager::ProjectToSolid(GGsize const& thread_index) const
188 {
189  for (GGsize i = 0; i < number_of_navigators_; ++i) {
190  navigators_[i]->ProjectToSolid(thread_index);
191  }
192 }
193 
197 
198 void GGEMSNavigatorManager::TrackThroughSolid(GGsize const& thread_index) const
199 {
200  for (GGsize i = 0; i < number_of_navigators_; ++i) {
201  navigators_[i]->TrackThroughSolid(thread_index);
202  }
203 }
204 
208 
209 void GGEMSNavigatorManager::WorldTracking(GGsize const& thread_index) const
210 {
211  // Checking if world exists
212  if (world_) world_->Tracking(thread_index);
213 }
214 
218 
220 {
221  for (GGsize i = 0; i < number_of_navigators_; ++i) {
222  navigators_[i]->ComputeDose(thread_index);
223  }
224 }
GGEMSNavigator::PrintInfos
void PrintInfos(void) const
Print infos about navigator.
Definition: GGEMSNavigator.cc:441
GGEMSNavigatorManager::ProjectToSolid
void ProjectToSolid(GGsize const &thread_index) const
Project particle to selected solid.
Definition: GGEMSNavigatorManager.cc:187
GGEMSRangeCutsManager.hh
GGEMS class managing the range cuts in GGEMS simulation.
GGEMSNavigator::Initialize
virtual void Initialize(void)
Definition: GGEMSNavigator.cc:198
GGEMSNavigator::ParticleSolidDistance
void ParticleSolidDistance(GGsize const &thread_index)
Compute distance between particle and solid.
Definition: GGEMSNavigator.cc:225
GGEMSNavigatorManager::Store
void Store(GGEMSNavigator *navigator)
storing the navigator pointer to navigator manager
Definition: GGEMSNavigatorManager.cc:80
GGEMSNavigatorManager::GGEMSNavigatorManager
GGEMSNavigatorManager(void)
Unable the constructor for the user.
Definition: GGEMSNavigatorManager.cc:39
GGEMSNavigatorManager::number_of_navigators_
GGsize number_of_navigators_
Definition: GGEMSNavigatorManager.hh:218
GGEMSNavigatorManager::navigators_
GGEMSNavigator ** navigators_
Definition: GGEMSNavigatorManager.hh:217
GGEMSNavigatorManager::Clean
void Clean(void)
clean OpenCL data if necessary
Definition: GGEMSNavigatorManager.cc:69
GGEMSNavigator::SetNavigatorID
void SetNavigatorID(GGsize const &navigator_id)
set the navigator index
Definition: GGEMSNavigator.cc:157
GGEMSNavigatorManager::PrintInfos
void PrintInfos(void) const
Printing infos about the navigators.
Definition: GGEMSNavigatorManager.cc:162
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGEMSNavigator::SaveResults
virtual void SaveResults(void)=0
save all results from solid
GGEMSNavigatorManager::world_
GGEMSWorld * world_
Definition: GGEMSNavigatorManager.hh:219
GGEMSWorld::SaveResults
void SaveResults(void) const
save all results from world
Definition: GGEMSWorld.cc:374
GGEMSNavigatorManager::WorldTracking
void WorldTracking(GGsize const &thread_index) const
Tracking particles through world.
Definition: GGEMSNavigatorManager.cc:209
GGEMSNavigator::TrackThroughSolid
void TrackThroughSolid(GGsize const &thread_index)
Move particle through solid.
Definition: GGEMSNavigator.cc:329
GGEMSWorld
GGEMS class handling global world (space between navigators) in GGEMS.
Definition: GGEMSWorld.hh:56
GGEMSNavigatorManager::Initialize
void Initialize(bool const &is_tracking=false) const
Initialize a GGEMS navigators.
Definition: GGEMSNavigatorManager.cc:134
GGEMSNavigator::ComputeDose
void ComputeDose(GGsize const &thread_index)
Compute dose in volume.
Definition: GGEMSNavigator.cc:432
GGEMSNavigatorManager::TrackThroughSolid
void TrackThroughSolid(GGsize const &thread_index) const
Track particles through selected solid.
Definition: GGEMSNavigatorManager.cc:198
GGEMSWorld::EnableTracking
void EnableTracking(void)
Enable tracking during simulation.
Definition: GGEMSWorld.cc:244
GGEMSNavigatorManager::SaveResults
void SaveResults(void) const
save all results from navigator in files
Definition: GGEMSNavigatorManager.cc:120
GGEMSSolid.hh
GGEMS class for solid. This class store geometry about phantom or detector.
GGEMSNavigatorManager::~GGEMSNavigatorManager
~GGEMSNavigatorManager(void)
Unable the destructor for the user.
Definition: GGEMSNavigatorManager.cc:53
GGEMSNavigator
Parent GGEMS class for navigator.
Definition: GGEMSNavigator.hh:55
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSWorld::Tracking
void Tracking(GGsize const &thread_index)
track particles through world
Definition: GGEMSWorld.cc:317
GGEMSSourceManager.hh
GGEMS class handling the source(s)
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSNavigatorManager::StoreWorld
void StoreWorld(GGEMSWorld *world)
storing the world pointer
Definition: GGEMSNavigatorManager.cc:110
GGEMSNavigator::EnableTracking
void EnableTracking(void)
Enable tracking during simulation.
Definition: GGEMSNavigator.cc:166
GGEMSNavigatorManager::FindSolid
void FindSolid(GGsize const &thread_index) const
Find closest solid before project particle to it.
Definition: GGEMSNavigatorManager.cc:176
GGEMSWorld::Initialize
void Initialize(void)
initialize and check parameters for world
Definition: GGEMSWorld.cc:275
GGEMSNavigatorManager::ComputeDose
void ComputeDose(GGsize const &thread_index)
Compute dose in volume.
Definition: GGEMSNavigatorManager.cc:219
GGEMSNavigator::ProjectToSolid
void ProjectToSolid(GGsize const &thread_index)
Project particle to entry of closest solid.
Definition: GGEMSNavigator.cc:277
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