Geant4 11.1.1
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, bool &foundPrevious) const
 
const std::vector< G4VFastSimulationModel * > & GetFastSimulationModelList () const
 
void FlushModels ()
 
G4bool PostStepGetFastSimulationManagerTrigger (const G4Track &, const G4Navigator *a=0)
 
G4VParticleChangeInvokePostStepDoIt ()
 
G4bool AtRestGetFastSimulationManagerTrigger (const G4Track &, const G4Navigator *a=0)
 
G4VParticleChangeInvokeAtRestDoIt ()
 
G4bool operator== (const G4FastSimulationManager &) const
 

Detailed Description

Definition at line 77 of file G4FastSimulationManager.hh.

Constructor & Destructor Documentation

◆ G4FastSimulationManager()

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

Definition at line 51 of file G4FastSimulationManager.cc.

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

◆ ~G4FastSimulationManager()

G4FastSimulationManager::~G4FastSimulationManager ( )

Definition at line 69 of file G4FastSimulationManager.cc.

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

Member Function Documentation

◆ ActivateFastSimulationModel()

G4bool G4FastSimulationManager::ActivateFastSimulationModel ( const G4String aName)

Definition at line 87 of file G4FastSimulationManager.cc.

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

◆ AddFastSimulationModel()

void G4FastSimulationManager::AddFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 179 of file G4FastSimulationManager.hh.

180{
181 ModelList.push_back(fsm);
182 // forces the fApplicableModelList to be rebuild
183 fLastCrossedParticle = 0;
184}

Referenced by G4VFastSimulationModel::G4VFastSimulationModel().

◆ AtRestGetFastSimulationManagerTrigger()

G4bool G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger ( const G4Track track,
const G4Navigator a = 0 
)

Definition at line 256 of file G4FastSimulationManager.cc.

258{
259 std::size_t iModel;
260
261 // If particle type changed re-build the fApplicableModelList.
262 if(fLastCrossedParticle!=track.GetDefinition()) {
263 fLastCrossedParticle=track.GetDefinition();
264 fApplicableModelList.clear();
265 // If Model List is empty, do nothing !
266 if(ModelList.size()==0) return false;
267 for (iModel=0; iModel<ModelList.size(); ++iModel)
268 if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
269 fApplicableModelList.push_back (ModelList[iModel]);
270 }
271
272 // If Applicable Model List is empty, do nothing !
273 if(fApplicableModelList.size()==0) return false;
274
275 // -- Register current track
276 fFastTrack.SetCurrentTrack(track,theNavigator);
277
278 // -- (note: compared to the PostStepGetFastSimulationManagerTrigger,
279 // -- the test to see if the particle is on the boundary but leaving
280 // -- is irrelevant here)
281
282 // Loops on the models to see if one of them wants to trigger:
283 for (iModel=0; iModel < fApplicableModelList.size(); ++iModel)
284 if(fApplicableModelList[iModel]->AtRestModelTrigger(fFastTrack))
285 {
286 fFastStep.Initialize(fFastTrack);
287 fTriggedFastSimulationModel=fApplicableModelList[iModel];
288 return true;
289 }
290
291 //--------------------------------------------
292 // Nobody asks to gain control, returns false
293 //--------------------------------------------
294 return false;
295}
void Initialize(const G4FastTrack &)
Definition: G4FastStep.cc:53
void SetCurrentTrack(const G4Track &, const G4Navigator *a=0)
Definition: G4FastTrack.cc:70
G4ParticleDefinition * GetDefinition() const

Referenced by G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength().

◆ FlushModels()

void G4FastSimulationManager::FlushModels ( )

Definition at line 157 of file G4FastSimulationManager.cc.

158{
159 for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
160 {
161 ModelList[iModel]->Flush();
162 }
163}

◆ GetEnvelope()

const G4Envelope * G4FastSimulationManager::GetEnvelope ( ) const
inline

Definition at line 201 of file G4FastSimulationManager.hh.

202{
203 return fFastTrack.GetEnvelope();
204}

◆ GetFastSimulationModel()

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

Definition at line 125 of file G4FastSimulationManager.cc.

128{
129 G4VFastSimulationModel* model = 0;
130 for (std::size_t iModel=0; iModel<ModelList.size(); ++iModel)
131 {
132 if(ModelList[iModel]->GetName() == modelName)
133 {
134 if (previousFound == 0)
135 {
136 model = ModelList[iModel];
137 break;
138 }
139 else
140 {
141 if (ModelList[iModel] == previousFound)
142 {
143 foundPrevious = true;
144 continue;
145 }
146 if (foundPrevious)
147 {
148 model = ModelList[iModel];
149 break;
150 }
151 }
152 }
153 }
154 return model;
155}

◆ GetFastSimulationModelList()

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

Definition at line 140 of file G4FastSimulationManager.hh.

141 {return ModelList;}

◆ InActivateFastSimulationModel()

G4bool G4FastSimulationManager::InActivateFastSimulationModel ( const G4String aName)

Definition at line 110 of file G4FastSimulationManager.cc.

111{
112 // Look for in the ModelList, if found remove from it and keep the pointer
113 // on the fInactivatedModels list.
114 for (G4int iModel=0; iModel<(G4int)ModelList.size(); ++iModel)
115 if(ModelList[iModel]->GetName() == aName) {
116 fInactivatedModels.push_back (ModelList.removeAt(iModel));
117 // forces the fApplicableModelList to be rebuild
118 fLastCrossedParticle=0;
119 return true;
120 }
121 return false;
122}

◆ InvokeAtRestDoIt()

G4VParticleChange * G4FastSimulationManager::InvokeAtRestDoIt ( )

Definition at line 297 of file G4FastSimulationManager.cc.

298{
299 fTriggedFastSimulationModel->AtRestDoIt(fFastTrack,fFastStep);
300 return &fFastStep;
301}
virtual void AtRestDoIt(const G4FastTrack &, G4FastStep &)

Referenced by G4FastSimulationManagerProcess::AtRestDoIt().

◆ InvokePostStepDoIt()

G4VParticleChange * G4FastSimulationManager::InvokePostStepDoIt ( )

Definition at line 245 of file G4FastSimulationManager.cc.

246{
247 // const G4FastTrack& parFastTrack=fFastTrack;
248 fTriggedFastSimulationModel->DoIt(fFastTrack,fFastStep);
249 return &fFastStep;
250}
virtual void DoIt(const G4FastTrack &, G4FastStep &)=0

Referenced by G4FastSimulationManagerProcess::PostStepDoIt().

◆ ListModels() [1/3]

void G4FastSimulationManager::ListModels ( ) const

Definition at line 314 of file G4FastSimulationManager.cc.

315{
316 std::size_t iModel;
317
318 G4cout << "Current Models for the ";
319 ListTitle();
320 G4cout << " envelope:\n";
321
322 for (iModel=0; iModel<ModelList.size(); ++iModel)
323 G4cout << " " << ModelList[iModel]->GetName() << "\n";
324
325 for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
326 G4cout << " " << fInactivatedModels[iModel]->GetName()
327 << "(inactivated)\n";
328}
G4GLOB_DLL std::ostream G4cout

◆ ListModels() [2/3]

void G4FastSimulationManager::ListModels ( const G4ParticleDefinition particleDefinition) const

Definition at line 385 of file G4FastSimulationManager.cc.

386{
387 std::size_t iModel;
388 G4bool unique = true;
389
390 // Active Models
391 for ( iModel=0; iModel<ModelList.size(); ++iModel )
392 if ( ModelList[iModel]->IsApplicable(*particleDefinition) )
393 {
394 G4cout << "Envelope ";
395 ListTitle();
396 G4cout << ", Model "
397 << ModelList[iModel]->GetName()
398 << "." << G4endl;
399 // -- Verify unicity of model attached to particleDefinition:
400 for ( auto jModel = iModel + 1; jModel < ModelList.size(); jModel++ )
401 if ( ModelList[jModel]->IsApplicable(*particleDefinition) ) unique = false;
402 }
403
404 // Inactive Models
405 for ( iModel=0; iModel<fInactivatedModels.size(); ++iModel )
406 if( fInactivatedModels[iModel]->IsApplicable(*particleDefinition) )
407 {
408 G4cout << "Envelope ";
409 ListTitle();
410 G4cout << ", Model "
411 << fInactivatedModels[iModel]->GetName()
412 << " (inactivated)." << G4endl;
413 }
414
415 if( !unique )
416 {
418 ed << "Two or more active Models are available for the same particle type, in the same envelope/region." << G4endl;
419 G4Exception("G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const",
420 "FastSim001",
421 JustWarning, ed,
422 "Models risk to exclude each other.");
423 }
424 unique=false;
425}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57

◆ ListModels() [3/3]

void G4FastSimulationManager::ListModels ( const G4String aName) const

Definition at line 330 of file G4FastSimulationManager.cc.

331{
332 std::size_t iModel;
333 G4int titled = 0;
335
336 // Active Models
337 for ( iModel=0; iModel<ModelList.size(); ++iModel )
338 if( ModelList[iModel]->GetName() == modelName || modelName == "all" )
339 {
340 if( !(titled++) )
341 {
342 G4cout << "In the envelope ";
343 ListTitle();
344 G4cout << ",\n";
345 }
346 G4cout << " the model " << ModelList[iModel]->GetName()
347 << " is applicable for :\n ";
348
349 G4int list_started=0;
350 for ( G4int iParticle = 0; iParticle<theParticleTable->entries(); iParticle++)
351 if( ModelList[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
352 {
353 if(list_started++) G4cout << ", ";
354 G4cout << theParticleTable->
355 GetParticle(iParticle)->GetParticleName();
356 }
357 G4cout <<G4endl;
358 }
359
360 // Inactive Models
361 for (iModel=0; iModel<fInactivatedModels.size(); ++iModel)
362 if(fInactivatedModels[iModel]->GetName() == modelName || modelName == "all" )
363 {
364 if( !(titled++) )
365 {
366 G4cout << "In the envelope ";
367 ListTitle();
368 G4cout << ",\n";
369 }
370 G4cout << " the model " << fInactivatedModels[iModel]->GetName()
371 << " (inactivated) is applicable for :\n ";
372
373 G4int list_started=0;
374 for ( G4int iParticle=0; iParticle<theParticleTable->entries(); iParticle++ )
375 if( fInactivatedModels[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
376 {
377 if(list_started++) G4cout << ", ";
378 G4cout << theParticleTable->
379 GetParticle(iParticle)->GetParticleName();
380 }
381 G4cout <<G4endl;
382 }
383}
G4ParticleDefinition * GetParticle(G4int index) const
G4int entries() const
static G4ParticleTable * GetParticleTable()
const G4String & GetParticleName(G4int index) const

◆ ListTitle()

void G4FastSimulationManager::ListTitle ( ) const

Definition at line 304 of file G4FastSimulationManager.cc.

305{
306 G4cout << fFastTrack.GetEnvelope()->GetName();
307 // if(GhostPlacements.size()!=0) G4cout << " (ghost)";
309 else G4cout << " (// geom.)";
310
311}
G4VPhysicalVolume * GetWorldVolume() const
G4VPhysicalVolume * GetWorldPhysical() const
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const

Referenced by ListModels().

◆ operator==()

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

Definition at line 195 of file G4FastSimulationManager.hh.

196{
197 return (this==&fsm) ? true : false;
198}

◆ PostStepGetFastSimulationManagerTrigger()

G4bool G4FastSimulationManager::PostStepGetFastSimulationManagerTrigger ( const G4Track track,
const G4Navigator a = 0 
)

Definition at line 190 of file G4FastSimulationManager.cc.

193{
194 std::size_t iModel;
195
196 // If particle type changed re-build the fApplicableModelList.
197 if(fLastCrossedParticle!=track.GetDefinition()) {
198 fLastCrossedParticle=track.GetDefinition();
199 fApplicableModelList.clear();
200 // If Model List is empty, do nothing !
201 if(ModelList.size()==0) return false;
202 for (iModel=0; iModel<ModelList.size(); ++iModel)
203 if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
204 fApplicableModelList.push_back (ModelList[iModel]);
205 }
206
207 // If Applicable Model List is empty, do nothing !
208 if(fApplicableModelList.size()==0) return false;
209
210 // -- Register current track
211 fFastTrack.SetCurrentTrack(track,theNavigator);
212
213 // tests if particle are on the boundary and leaving,
214 // in this case do nothing !
215 if(fFastTrack.OnTheBoundaryButExiting()) return false;
216
217 // Loops on the ModelTrigger() methods
218 for (iModel=0; iModel<fApplicableModelList.size(); ++iModel)
219
220 //---------------------------------------------------
221 // Asks the ModelTrigger method if it must be trigged now.
222 //---------------------------------------------------
223
224 if(fApplicableModelList[iModel]->ModelTrigger(fFastTrack)) {
225 //--------------------------------------------------
226 // The model will be applied. Initializes the G4FastStep
227 // with the current state of the G4Track and
228 // same usefull parameters.
229 // In particular it does SetLocalEnergyDeposit(0.0).
230 //--------------------------------------------------
231 fFastStep.Initialize(fFastTrack);
232
233 // Keeps the FastSimulationModel pointer to call the
234 // DoIt() method.
235 fTriggedFastSimulationModel=fApplicableModelList[iModel];
236 return true;
237 }
238
239 //--------------------------------------------
240 // Nobody asks to gain control, returns false
241 //--------------------------------------------
242 return false;
243}
G4bool OnTheBoundaryButExiting() const
Definition: G4FastTrack.hh:241

Referenced by G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength().

◆ RemoveFastSimulationModel()

void G4FastSimulationManager::RemoveFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 187 of file G4FastSimulationManager.hh.

188{
189 if(!ModelList.remove(fsm)) fInactivatedModels.remove(fsm);
190 // forces the fApplicableModelList to be rebuild
191 fLastCrossedParticle = 0;
192}
T * remove(const T *)

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