Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FastSimulationManager Class Reference

#include <G4FastSimulationManager.hh>

Public Member Functions

 G4FastSimulationManager (G4Envelope *anEnvelope, G4bool IsUnique=FALSE)
 
 ~G4FastSimulationManager ()
 
void AddFastSimulationModel (G4VFastSimulationModel *)
 
void RemoveFastSimulationModel (G4VFastSimulationModel *)
 
G4bool ActivateFastSimulationModel (const G4String &)
 
G4bool InActivateFastSimulationModel (const G4String &)
 
void ListTitle () const
 
void ListModels () const
 
void ListModels (const G4ParticleDefinition *) const
 
void ListModels (const G4String &aName) const
 
const G4EnvelopeGetEnvelope () const
 
G4VFastSimulationModelGetFastSimulationModel (const G4String &modelName, const G4VFastSimulationModel *previousFound, G4bool &foundPrevious) const
 
const std::vector< G4VFastSimulationModel * > & GetFastSimulationModelList () const
 
void FlushModels ()
 
G4bool PostStepGetFastSimulationManagerTrigger (const G4Track &, const G4Navigator *a=nullptr)
 
G4VParticleChangeInvokePostStepDoIt ()
 
G4bool AtRestGetFastSimulationManagerTrigger (const G4Track &, const G4Navigator *a=nullptr)
 
G4VParticleChangeInvokeAtRestDoIt ()
 
G4bool operator== (const G4FastSimulationManager &) const
 

Detailed Description

Definition at line 73 of file G4FastSimulationManager.hh.

Constructor & Destructor Documentation

◆ G4FastSimulationManager()

G4FastSimulationManager::G4FastSimulationManager ( G4Envelope * anEnvelope,
G4bool IsUnique = FALSE )

Definition at line 52 of file G4FastSimulationManager.cc.

53 : fFastTrack(anEnvelope, IsUnique)
54{
55 // Communicates to the region that it becomes a
56 // envelope and with this fast simulation manager.
57 anEnvelope->SetFastSimulationManager(this);
58
59 // Add itself to the GlobalFastSimulationManager
61}
static G4GlobalFastSimulationManager * GetGlobalFastSimulationManager()
void AddFastSimulationManager(G4FastSimulationManager *)
void SetFastSimulationManager(G4FastSimulationManager *fsm)
Definition G4Region.cc:131

◆ ~G4FastSimulationManager()

G4FastSimulationManager::~G4FastSimulationManager ( )

Definition at line 66 of file G4FastSimulationManager.cc.

67{
68 //
69 // Check out the Envelope about this pointer. If in use,
70 // resets the Logical Volume IsEnvelope flag to avoid clash.
71 //
72 if (fFastTrack.GetEnvelope()->GetFastSimulationManager() == this)
74 // Remove itself from the GlobalFastSimulationManager
76 this);
77}
G4Envelope * GetEnvelope() const
void RemoveFastSimulationManager(G4FastSimulationManager *)
G4FastSimulationManager * GetFastSimulationManager() const
Definition G4Region.cc:140
void ClearFastSimulationManager()
Definition G4Region.cc:448

Member Function Documentation

◆ ActivateFastSimulationModel()

G4bool G4FastSimulationManager::ActivateFastSimulationModel ( const G4String & aName)

Definition at line 83 of file G4FastSimulationManager.cc.

84{
85 G4int iModel;
86
87 // If the model is already active, do nothing.
88 for (iModel = 0; iModel < (G4int)ModelList.size(); ++iModel)
89 if (ModelList[iModel]->GetName() == aName) return true;
90
91 // Look for in the fInactivatedModels list, if found push_back it back to
92 // the ModelList
93 for (iModel = 0; iModel < (G4int)fInactivatedModels.size(); ++iModel)
94 if (fInactivatedModels[iModel]->GetName() == aName) {
95 ModelList.push_back(fInactivatedModels.removeAt(iModel));
96 // forces the fApplicableModelList to be rebuild
97 fLastCrossedParticle = nullptr;
98 return true;
99 }
100 return false;
101}
int G4int
Definition G4Types.hh:85

◆ AddFastSimulationModel()

void G4FastSimulationManager::AddFastSimulationModel ( G4VFastSimulationModel * fsm)
inline

Definition at line 164 of file G4FastSimulationManager.hh.

165{
166 ModelList.push_back(fsm);
167 // forces the fApplicableModelList to be rebuild
168 fLastCrossedParticle = nullptr;
169}

Referenced by G4VFastSimulationModel::G4VFastSimulationModel().

◆ AtRestGetFastSimulationManagerTrigger()

G4bool G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger ( const G4Track & track,
const G4Navigator * a = nullptr )

Definition at line 236 of file G4FastSimulationManager.cc.

238{
239 // If particle type changed re-build the fApplicableModelList.
240 if (fLastCrossedParticle != track.GetDefinition()) {
241 fLastCrossedParticle = track.GetDefinition();
242 fApplicableModelList.clear();
243 // If Model List is empty, do nothing !
244 if (ModelList.empty()) return false;
245
246 for (auto iModel : ModelList) {
247 if (iModel->IsApplicable(*(track.GetDefinition()))) {
248 fApplicableModelList.push_back(iModel);
249 }
250 }
251 }
252
253 // If Applicable Model List is empty, do nothing !
254 if (fApplicableModelList.empty()) return false;
255
256 // -- Register current track
257 fFastTrack.SetCurrentTrack(track, theNavigator);
258
259 // -- (note: compared to the PostStepGetFastSimulationManagerTrigger,
260 // -- the test to see if the particle is on the boundary but leaving
261 // -- is irrelevant here)
262
263 // Loops on the models to see if one of them wants to trigger:
264 for (auto iModel : fApplicableModelList) {
265 if (iModel->AtRestModelTrigger(fFastTrack)) {
266 fFastStep.Initialize(fFastTrack);
267 fTriggedFastSimulationModel = iModel;
268 return true;
269 }
270 }
271 //--------------------------------------------
272 // Nobody asks to gain control, returns false
273 //--------------------------------------------
274 return false;
275}
void Initialize(const G4FastTrack &)
Definition G4FastStep.cc:53
void SetCurrentTrack(const G4Track &, const G4Navigator *a=nullptr)
G4ParticleDefinition * GetDefinition() const

Referenced by G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength().

◆ FlushModels()

void G4FastSimulationManager::FlushModels ( )

Definition at line 142 of file G4FastSimulationManager.cc.

143{
144 for (auto& iModel : ModelList) {
145 iModel->Flush();
146 }
147}

◆ GetEnvelope()

const G4Envelope * G4FastSimulationManager::GetEnvelope ( ) const
inline

Definition at line 183 of file G4FastSimulationManager.hh.

184{
185 return fFastTrack.GetEnvelope();
186}

◆ GetFastSimulationModel()

G4VFastSimulationModel * G4FastSimulationManager::GetFastSimulationModel ( const G4String & modelName,
const G4VFastSimulationModel * previousFound,
G4bool & foundPrevious ) const

Definition at line 118 of file G4FastSimulationManager.cc.

121{
122 G4VFastSimulationModel* model = nullptr;
123 for (auto iModel : ModelList) {
124 if (iModel->GetName() == modelName) {
125 if (previousFound == nullptr) {
126 model = iModel;
127 break;
128 }
129 if (iModel == previousFound) {
130 foundPrevious = true;
131 continue;
132 }
133 if (foundPrevious) {
134 model = iModel;
135 break;
136 }
137 }
138 }
139 return model;
140}

◆ GetFastSimulationModelList()

const std::vector< G4VFastSimulationModel * > & G4FastSimulationManager::GetFastSimulationModelList ( ) const
inline

Definition at line 126 of file G4FastSimulationManager.hh.

127 {
128 return ModelList;
129 }

◆ InActivateFastSimulationModel()

G4bool G4FastSimulationManager::InActivateFastSimulationModel ( const G4String & aName)

Definition at line 103 of file G4FastSimulationManager.cc.

104{
105 // Look for in the ModelList, if found remove from it and keep the pointer
106 // on the fInactivatedModels list.
107 for (G4int iModel = 0; iModel < (G4int)ModelList.size(); ++iModel)
108 if (ModelList[iModel]->GetName() == aName) {
109 fInactivatedModels.push_back(ModelList.removeAt(iModel));
110 // forces the fApplicableModelList to be rebuild
111 fLastCrossedParticle = nullptr;
112 return true;
113 }
114 return false;
115}

◆ InvokeAtRestDoIt()

G4VParticleChange * G4FastSimulationManager::InvokeAtRestDoIt ( )

Definition at line 277 of file G4FastSimulationManager.cc.

278{
279 fTriggedFastSimulationModel->AtRestDoIt(fFastTrack, fFastStep);
280 return &fFastStep;
281}
virtual void AtRestDoIt(const G4FastTrack &, G4FastStep &)

Referenced by G4FastSimulationManagerProcess::AtRestDoIt().

◆ InvokePostStepDoIt()

G4VParticleChange * G4FastSimulationManager::InvokePostStepDoIt ( )

Definition at line 226 of file G4FastSimulationManager.cc.

227{
228 fTriggedFastSimulationModel->DoIt(fFastTrack, fFastStep);
229 return &fFastStep;
230}
virtual void DoIt(const G4FastTrack &, G4FastStep &)=0

Referenced by G4FastSimulationManagerProcess::PostStepDoIt().

◆ ListModels() [1/3]

void G4FastSimulationManager::ListModels ( ) const

Definition at line 295 of file G4FastSimulationManager.cc.

296{
297 G4cout << "Current Models for the ";
298 ListTitle();
299 G4cout << " envelope:\n";
300
301 for (auto iModel : ModelList)
302 G4cout << " " << iModel->GetName() << "\n";
303
304 for (auto iModel : fInactivatedModels)
305 G4cout << " " << iModel->GetName() << "(inactivated)\n";
306}
G4GLOB_DLL std::ostream G4cout

◆ ListModels() [2/3]

void G4FastSimulationManager::ListModels ( const G4ParticleDefinition * particleDefinition) const

Definition at line 354 of file G4FastSimulationManager.cc.

355{
356 std::size_t iModel;
357 G4bool unique = true;
358
359 // Active Models
360 for (iModel = 0; iModel < ModelList.size(); ++iModel)
361 if (ModelList[iModel]->IsApplicable(*particleDefinition)) {
362 G4cout << "Envelope ";
363 ListTitle();
364 G4cout << ", Model " << ModelList[iModel]->GetName() << "." << G4endl;
365 // -- Verify unicity of model attached to particleDefinition:
366 for (auto jModel = iModel + 1; jModel < ModelList.size(); jModel++)
367 if (ModelList[jModel]->IsApplicable(*particleDefinition)) unique = false;
368 }
369
370 // Inactive Models
371 for (iModel = 0; iModel < fInactivatedModels.size(); ++iModel)
372 if (fInactivatedModels[iModel]->IsApplicable(*particleDefinition)) {
373 G4cout << "Envelope ";
374 ListTitle();
375 G4cout << ", Model " << fInactivatedModels[iModel]->GetName() << " (inactivated)." << G4endl;
376 }
377
378 if (!unique) {
380 ed << "Two or more active Models are available for the same particle type, in the same "
381 "envelope/region."
382 << G4endl;
384 "G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const",
385 "FastSim001", JustWarning, ed, "Models risk to exclude each other.");
386 }
387 unique = false;
388}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
bool G4bool
Definition G4Types.hh:86
#define G4endl
Definition G4ios.hh:67

◆ ListModels() [3/3]

void G4FastSimulationManager::ListModels ( const G4String & aName) const

Definition at line 308 of file G4FastSimulationManager.cc.

309{
310 std::size_t iModel;
311 G4int titled = 0;
313
314 // Active Models
315 for (iModel = 0; iModel < ModelList.size(); ++iModel)
316 if (ModelList[iModel]->GetName() == modelName || modelName == "all") {
317 if ((titled++) == 0) {
318 G4cout << "In the envelope ";
319 ListTitle();
320 G4cout << ",\n";
321 }
322 G4cout << " the model " << ModelList[iModel]->GetName() << " is applicable for :\n ";
323
324 G4int list_started = 0;
325 for (G4int iParticle = 0; iParticle < theParticleTable->entries(); iParticle++)
326 if (ModelList[iModel]->IsApplicable(*(theParticleTable->GetParticle(iParticle)))) {
327 if ((list_started++) != 0) G4cout << ", ";
328 G4cout << theParticleTable->GetParticle(iParticle)->GetParticleName();
329 }
330 G4cout << G4endl;
331 }
332
333 // Inactive Models
334 for (iModel = 0; iModel < fInactivatedModels.size(); ++iModel)
335 if (fInactivatedModels[iModel]->GetName() == modelName || modelName == "all") {
336 if ((titled++) == 0) {
337 G4cout << "In the envelope ";
338 ListTitle();
339 G4cout << ",\n";
340 }
341 G4cout << " the model " << fInactivatedModels[iModel]->GetName()
342 << " (inactivated) is applicable for :\n ";
343
344 G4int list_started = 0;
345 for (G4int iParticle = 0; iParticle < theParticleTable->entries(); iParticle++)
346 if (fInactivatedModels[iModel]->IsApplicable(*(theParticleTable->GetParticle(iParticle)))) {
347 if ((list_started++) != 0) G4cout << ", ";
348 G4cout << theParticleTable->GetParticle(iParticle)->GetParticleName();
349 }
350 G4cout << G4endl;
351 }
352}
const G4String & GetParticleName() const
G4ParticleDefinition * GetParticle(G4int index) const
G4int entries() const
static G4ParticleTable * GetParticleTable()

◆ ListTitle()

void G4FastSimulationManager::ListTitle ( ) const

Definition at line 283 of file G4FastSimulationManager.cc.

284{
285 G4cout << fFastTrack.GetEnvelope()->GetName();
286 if (fFastTrack.GetEnvelope()->GetWorldPhysical()
289 ->GetWorldVolume())
290 G4cout << " (mass geom.)";
291 else
292 G4cout << " (// geom.)";
293}
G4VPhysicalVolume * GetWorldVolume() const
G4VPhysicalVolume * GetWorldPhysical() const
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const

Referenced by ListModels(), ListModels(), and ListModels().

◆ operator==()

G4bool G4FastSimulationManager::operator== ( const G4FastSimulationManager & fsm) const
inline

Definition at line 178 of file G4FastSimulationManager.hh.

179{
180 return this == &fsm;
181}

◆ PostStepGetFastSimulationManagerTrigger()

G4bool G4FastSimulationManager::PostStepGetFastSimulationManagerTrigger ( const G4Track & track,
const G4Navigator * a = nullptr )

Definition at line 172 of file G4FastSimulationManager.cc.

174{
175 // If particle type changed re-build the fApplicableModelList.
176 if (fLastCrossedParticle != track.GetDefinition()) {
177 fLastCrossedParticle = track.GetDefinition();
178 fApplicableModelList.clear();
179 // If Model List is empty, do nothing !
180 if (ModelList.empty()) return false;
181
182 for (auto iModel : ModelList) {
183 if (iModel->IsApplicable(*(track.GetDefinition()))) {
184 fApplicableModelList.push_back(iModel);
185 }
186 }
187 }
188
189 // If Applicable Model List is empty, do nothing !
190 if (fApplicableModelList.empty()) return false;
191
192 // -- Register current track
193 fFastTrack.SetCurrentTrack(track, theNavigator);
194
195 // tests if particle are on the boundary and leaving,
196 // in this case do nothing !
197 if (fFastTrack.OnTheBoundaryButExiting()) return false;
198
199 // Loops on the ModelTrigger() methods
200 for (auto iModel : fApplicableModelList)
201 //---------------------------------------------------
202 // Asks the ModelTrigger method if it must be trigged now.
203 //---------------------------------------------------
204
205 if (iModel->ModelTrigger(fFastTrack)) {
206 //--------------------------------------------------
207 // The model will be applied. Initializes the G4FastStep
208 // with the current state of the G4Track and
209 // same usefull parameters.
210 // In particular it does SetLocalEnergyDeposit(0.0).
211 //--------------------------------------------------
212 fFastStep.Initialize(fFastTrack);
213
214 // Keeps the FastSimulationModel pointer to call the
215 // DoIt() method.
216 fTriggedFastSimulationModel = iModel;
217 return true;
218 }
219
220 //--------------------------------------------
221 // Nobody asks to gain control, returns false
222 //--------------------------------------------
223 return false;
224}
G4bool OnTheBoundaryButExiting() const

Referenced by G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength().

◆ RemoveFastSimulationModel()

void G4FastSimulationManager::RemoveFastSimulationModel ( G4VFastSimulationModel * fsm)
inline

Definition at line 171 of file G4FastSimulationManager.hh.

172{
173 if (ModelList.remove(fsm) == nullptr) fInactivatedModels.remove(fsm);
174 // forces the fApplicableModelList to be rebuild
175 fLastCrossedParticle = nullptr;
176}
T * remove(const T *)

The documentation for this class was generated from the following files: