Geant4 9.6.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 83 of file G4FastSimulationManager.hh.

Constructor & Destructor Documentation

◆ G4FastSimulationManager()

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

Definition at line 52 of file G4FastSimulationManager.cc.

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

◆ ~G4FastSimulationManager()

G4FastSimulationManager::~G4FastSimulationManager ( )

Definition at line 70 of file G4FastSimulationManager.cc.

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

Member Function Documentation

◆ ActivateFastSimulationModel()

G4bool G4FastSimulationManager::ActivateFastSimulationModel ( const G4String aName)

Definition at line 88 of file G4FastSimulationManager.cc.

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

◆ AddFastSimulationModel()

void G4FastSimulationManager::AddFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 184 of file G4FastSimulationManager.hh.

185{
186 ModelList.push_back(fsm);
187 // forces the fApplicableModelList to be rebuild
188 fLastCrossedParticle = 0;
189}

Referenced by G4VFastSimulationModel::G4VFastSimulationModel().

◆ AtRestGetFastSimulationManagerTrigger()

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

Definition at line 249 of file G4FastSimulationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength().

◆ GetEnvelope()

const G4Envelope * G4FastSimulationManager::GetEnvelope ( ) const
inline

Definition at line 206 of file G4FastSimulationManager.hh.

207{
208 return fFastTrack.GetEnvelope();
209}

◆ GetFastSimulationModel()

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

Definition at line 127 of file G4FastSimulationManager.cc.

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

◆ GetFastSimulationModelList()

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

Definition at line 146 of file G4FastSimulationManager.hh.

147 {return ModelList;}

◆ InActivateFastSimulationModel()

G4bool G4FastSimulationManager::InActivateFastSimulationModel ( const G4String aName)

Definition at line 111 of file G4FastSimulationManager.cc.

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

◆ InvokeAtRestDoIt()

G4VParticleChange * G4FastSimulationManager::InvokeAtRestDoIt ( )

Definition at line 290 of file G4FastSimulationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::AtRestDoIt().

◆ InvokePostStepDoIt()

G4VParticleChange * G4FastSimulationManager::InvokePostStepDoIt ( )

Definition at line 238 of file G4FastSimulationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::PostStepDoIt().

◆ ListModels() [1/3]

void G4FastSimulationManager::ListModels ( ) const

Definition at line 307 of file G4FastSimulationManager.cc.

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

◆ ListModels() [2/3]

void G4FastSimulationManager::ListModels ( const G4ParticleDefinition aPD) const

Definition at line 383 of file G4FastSimulationManager.cc.

384{
385 size_t iModel;
386 G4bool unique=true;
387
388 // Active Models
389 for (iModel=0; iModel<ModelList.size(); iModel++)
390 if(ModelList[iModel]->IsApplicable(*aPD)) {
391 G4cout << "Envelope ";
392 ListTitle();
393 G4cout << ", Model "
394 << ModelList[iModel]->GetName()
395 << "." << G4endl;
396 }
397 // inactive Models
398 for (iModel=0; iModel<fInactivatedModels.size(); iModel++)
399 if(fInactivatedModels[iModel]->IsApplicable(*aPD)) {
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 Models are available for the same particle type, in the same envelope/region." << G4endl;
411 G4Exception("G4FastSimulationManager::ListModels(const G4ParticleDefinition* aPD) const",
412 "FastSim001",
413 JustWarning, ed,
414 "Models risk to exclude each other.");
415 }
416 unique=false;
417}
@ JustWarning
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

◆ ListModels() [3/3]

void G4FastSimulationManager::ListModels ( const G4String aName) const

Definition at line 324 of file G4FastSimulationManager.cc.

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

◆ ListTitle()

void G4FastSimulationManager::ListTitle ( ) const

Definition at line 297 of file G4FastSimulationManager.cc.

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

201{
202 return (this==&fsm) ? true : false;
203}

◆ PostStepGetFastSimulationManagerTrigger()

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

Definition at line 183 of file G4FastSimulationManager.cc.

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

Referenced by G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength().

◆ RemoveFastSimulationModel()

void G4FastSimulationManager::RemoveFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 192 of file G4FastSimulationManager.hh.

193{
194 if(!ModelList.remove(fsm)) fInactivatedModels.remove(fsm);
195 // forces the fApplicableModelList to be rebuild
196 fLastCrossedParticle = 0;
197}
T * remove(const T *)

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