Geant4 10.7.0
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
 
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:121

◆ ~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:130
void ClearFastSimulationManager()
Definition: G4Region.cc:424

Member Function Documentation

◆ ActivateFastSimulationModel()

G4bool G4FastSimulationManager::ActivateFastSimulationModel ( const G4String aName)

Definition at line 87 of file G4FastSimulationManager.cc.

88{
89 size_t iModel;
90
91 // If the model is already active, do nothing.
92 for (iModel=0; iModel<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<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}

◆ AddFastSimulationModel()

void G4FastSimulationManager::AddFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 178 of file G4FastSimulationManager.hh.

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

Referenced by G4VFastSimulationModel::G4VFastSimulationModel().

◆ AtRestGetFastSimulationManagerTrigger()

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

Definition at line 248 of file G4FastSimulationManager.cc.

250{
251 size_t iModel;
252
253 // If particle type changed re-build the fApplicableModelList.
254 if(fLastCrossedParticle!=track.GetDefinition()) {
255 fLastCrossedParticle=track.GetDefinition();
256 fApplicableModelList.clear();
257 // If Model List is empty, do nothing !
258 if(ModelList.size()==0) return false;
259 for (iModel=0; iModel<ModelList.size(); iModel++)
260 if(ModelList[iModel]->IsApplicable(*(track.GetDefinition())))
261 fApplicableModelList.push_back (ModelList[iModel]);
262 }
263
264 // If Applicable Model List is empty, do nothing !
265 if(fApplicableModelList.size()==0) return false;
266
267 // -- Register current track
268 fFastTrack.SetCurrentTrack(track,theNavigator);
269
270 // -- (note: compared to the PostStepGetFastSimulationManagerTrigger,
271 // -- the test to see if the particle is on the boundary but leaving
272 // -- is irrelevant here)
273
274 // Loops on the models to see if one of them wants to trigger:
275 for (iModel=0; iModel < fApplicableModelList.size(); iModel++)
276 if(fApplicableModelList[iModel]->AtRestModelTrigger(fFastTrack))
277 {
278 fFastStep.Initialize(fFastTrack);
279 fTriggedFastSimulationModel=fApplicableModelList[iModel];
280 return true;
281 }
282
283 //--------------------------------------------
284 // Nobody asks to gain control, returns false
285 //--------------------------------------------
286 return false;
287}
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().

◆ GetEnvelope()

const G4Envelope * G4FastSimulationManager::GetEnvelope ( ) const
inline

Definition at line 200 of file G4FastSimulationManager.hh.

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

◆ GetFastSimulationModel()

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

Definition at line 126 of file G4FastSimulationManager.cc.

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

◆ 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 (size_t iModel=0; iModel<ModelList.size(); iModel++)
115 if(ModelList[iModel]->GetName() == aName) {
116 fInactivatedModels.
117 push_back (ModelList.removeAt(iModel));
118 // forces the fApplicableModelList to be rebuild
119 fLastCrossedParticle=0;
120 return true;
121 }
122 return false;
123}

◆ InvokeAtRestDoIt()

G4VParticleChange * G4FastSimulationManager::InvokeAtRestDoIt ( )

Definition at line 289 of file G4FastSimulationManager.cc.

290{
291 fTriggedFastSimulationModel->AtRestDoIt(fFastTrack,fFastStep);
292 return &fFastStep;
293}
virtual void AtRestDoIt(const G4FastTrack &, G4FastStep &)

Referenced by G4FastSimulationManagerProcess::AtRestDoIt().

◆ InvokePostStepDoIt()

G4VParticleChange * G4FastSimulationManager::InvokePostStepDoIt ( )

Definition at line 237 of file G4FastSimulationManager.cc.

238{
239 // const G4FastTrack& parFastTrack=fFastTrack;
240 fTriggedFastSimulationModel->DoIt(fFastTrack,fFastStep);
241 return &fFastStep;
242}
virtual void DoIt(const G4FastTrack &, G4FastStep &)=0

Referenced by G4FastSimulationManagerProcess::PostStepDoIt().

◆ ListModels() [1/3]

void G4FastSimulationManager::ListModels ( ) const

Definition at line 306 of file G4FastSimulationManager.cc.

307{
308 size_t iModel;
309
310 G4cout << "Current Models for the ";
311 ListTitle();
312 G4cout << " envelope:\n";
313
314 for (iModel=0; iModel<ModelList.size(); iModel++)
315 G4cout << " " << ModelList[iModel]->GetName() << "\n";
316
317 for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
318 G4cout << " " << fInactivatedModels[iModel]->GetName()
319 << "(inactivated)\n";
320}
G4GLOB_DLL std::ostream G4cout

◆ ListModels() [2/3]

void G4FastSimulationManager::ListModels ( const G4ParticleDefinition particleDefinition) const

Definition at line 377 of file G4FastSimulationManager.cc.

378{
379 size_t iModel;
380 G4bool unique = true;
381
382 // Active Models
383 for ( iModel=0; iModel<ModelList.size(); iModel++ )
384 if ( ModelList[iModel]->IsApplicable(*particleDefinition) )
385 {
386 G4cout << "Envelope ";
387 ListTitle();
388 G4cout << ", Model "
389 << ModelList[iModel]->GetName()
390 << "." << G4endl;
391 // -- Verify unicity of model attached to particleDefinition:
392 for ( auto jModel = iModel + 1; jModel < ModelList.size(); jModel++ )
393 if ( ModelList[jModel]->IsApplicable(*particleDefinition) ) unique = false;
394 }
395
396 // Inactive Models
397 for ( iModel=0; iModel<fInactivatedModels.size(); iModel++ )
398 if( fInactivatedModels[iModel]->IsApplicable(*particleDefinition) )
399 {
400 G4cout << "Envelope ";
401 ListTitle();
402 G4cout << ", Model "
403 << fInactivatedModels[iModel]->GetName()
404 << " (inactivated)." << G4endl;
405 }
406
407 if( !unique )
408 {
410 ed << "Two or more active Models are available for the same particle type, in the same envelope/region." << G4endl;
411 G4Exception("G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const",
412 "FastSim001",
413 JustWarning, ed,
414 "Models risk to exclude each other.");
415 }
416 unique=false;
417}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
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 322 of file G4FastSimulationManager.cc.

323{
324 size_t iModel;
325 G4int titled = 0;
327
328 // Active Models
329 for ( iModel=0; iModel<ModelList.size(); iModel++ )
330 if( ModelList[iModel]->GetName() == modelName || modelName == "all" )
331 {
332 if( !(titled++) )
333 {
334 G4cout << "In the envelope ";
335 ListTitle();
336 G4cout << ",\n";
337 }
338 G4cout << " the model " << ModelList[iModel]->GetName()
339 << " is applicable for :\n ";
340
341 G4int list_started=0;
342 for ( G4int iParticle = 0; iParticle<theParticleTable->entries(); iParticle++)
343 if( ModelList[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
344 {
345 if(list_started++) G4cout << ", ";
346 G4cout << theParticleTable->
347 GetParticle(iParticle)->GetParticleName();
348 }
349 G4cout <<G4endl;
350 }
351
352 // Inactive Models
353 for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
354 if(fInactivatedModels[iModel]->GetName() == modelName || modelName == "all" )
355 {
356 if( !(titled++) )
357 {
358 G4cout << "In the envelope ";
359 ListTitle();
360 G4cout << ",\n";
361 }
362 G4cout << " the model " << fInactivatedModels[iModel]->GetName()
363 << " (inactivated) is applicable for :\n ";
364
365 G4int list_started=0;
366 for ( G4int iParticle=0; iParticle<theParticleTable->entries(); iParticle++ )
367 if( fInactivatedModels[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) )
368 {
369 if(list_started++) G4cout << ", ";
370 G4cout << theParticleTable->
371 GetParticle(iParticle)->GetParticleName();
372 }
373 G4cout <<G4endl;
374 }
375}
int G4int
Definition: G4Types.hh:85
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 296 of file G4FastSimulationManager.cc.

297{
298 G4cout << fFastTrack.GetEnvelope()->GetName();
299 // if(GhostPlacements.size()!=0) G4cout << " (ghost)";
301 else G4cout << " (// geom.)";
302
303}
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 194 of file G4FastSimulationManager.hh.

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

◆ PostStepGetFastSimulationManagerTrigger()

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

Definition at line 182 of file G4FastSimulationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength().

◆ RemoveFastSimulationModel()

void G4FastSimulationManager::RemoveFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 186 of file G4FastSimulationManager.hh.

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

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