Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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 ( G4Envelope anEnvelope,
G4bool  IsUnique = FALSE 
)

Definition at line 53 of file G4FastSimulationManager.cc.

References G4GlobalFastSimulationManager::GetGlobalFastSimulationManager(), and G4Region::SetFastSimulationManager().

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 ( )

Definition at line 70 of file G4FastSimulationManager.cc.

References G4Region::ClearFastSimulationManager(), G4FastTrack::GetEnvelope(), G4Region::GetFastSimulationManager(), and G4GlobalFastSimulationManager::GetGlobalFastSimulationManager().

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 }
static G4GlobalFastSimulationManager * GetGlobalFastSimulationManager()
void ClearFastSimulationManager()
Definition: G4Region.cc:382
G4FastSimulationManager * GetFastSimulationManager() const
G4Envelope * GetEnvelope() const
Definition: G4FastTrack.hh:188

Member Function Documentation

G4bool G4FastSimulationManager::ActivateFastSimulationModel ( const G4String aName)

Definition at line 88 of file G4FastSimulationManager.cc.

References G4FastSimulationVector< T >::removeAt().

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 }
void G4FastSimulationManager::AddFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 184 of file G4FastSimulationManager.hh.

Referenced by G4VFastSimulationModel::G4VFastSimulationModel().

185 {
186  ModelList.push_back(fsm);
187  // forces the fApplicableModelList to be rebuild
188  fLastCrossedParticle = 0;
189 }
G4bool G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger ( const G4Track track,
const G4Navigator a = 0 
)

Definition at line 249 of file G4FastSimulationManager.cc.

References G4Track::GetDefinition(), G4FastStep::Initialize(), and G4FastTrack::SetCurrentTrack().

Referenced by G4FastSimulationManagerProcess::AtRestGetPhysicalInteractionLength().

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 }
G4ParticleDefinition * GetDefinition() const
void Initialize(const G4FastTrack &)
Definition: G4FastStep.cc:53
void SetCurrentTrack(const G4Track &, const G4Navigator *a=0)
Definition: G4FastTrack.cc:68
const G4Envelope * G4FastSimulationManager::GetEnvelope ( ) const
inline

Definition at line 206 of file G4FastSimulationManager.hh.

References G4FastTrack::GetEnvelope().

207 {
208  return fFastTrack.GetEnvelope();
209 }
G4Envelope * GetEnvelope() const
Definition: G4FastTrack.hh:188
G4VFastSimulationModel * G4FastSimulationManager::GetFastSimulationModel ( const G4String modelName,
const G4VFastSimulationModel previousFound,
bool &  foundPrevious 
) const

Definition at line 127 of file G4FastSimulationManager.cc.

130 {
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 }
const XML_Char XML_Content * model
const std::vector<G4VFastSimulationModel*>& G4FastSimulationManager::GetFastSimulationModelList ( ) const
inline

Definition at line 146 of file G4FastSimulationManager.hh.

147  {return ModelList;}
G4bool G4FastSimulationManager::InActivateFastSimulationModel ( const G4String aName)

Definition at line 111 of file G4FastSimulationManager.cc.

References G4FastSimulationVector< T >::removeAt().

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 }
G4VParticleChange * G4FastSimulationManager::InvokeAtRestDoIt ( )

Definition at line 290 of file G4FastSimulationManager.cc.

References G4VFastSimulationModel::AtRestDoIt().

Referenced by G4FastSimulationManagerProcess::AtRestDoIt().

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

Definition at line 238 of file G4FastSimulationManager.cc.

References G4VFastSimulationModel::DoIt().

Referenced by G4FastSimulationManagerProcess::PostStepDoIt().

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

Definition at line 307 of file G4FastSimulationManager.cc.

References G4cout, and ListTitle().

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 }
G4GLOB_DLL std::ostream G4cout
void G4FastSimulationManager::ListModels ( const G4ParticleDefinition aPD) const

Definition at line 383 of file G4FastSimulationManager.cc.

References G4cout, G4endl, G4Exception(), JustWarning, and ListTitle().

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 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void G4FastSimulationManager::ListModels ( const G4String aName) const

Definition at line 324 of file G4FastSimulationManager.cc.

References G4ParticleTable::entries(), G4cout, G4endl, G4ParticleTable::GetParticleName(), G4ParticleTable::GetParticleTable(), and ListTitle().

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 }
const G4String & GetParticleName(G4int index) const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static G4ParticleTable * GetParticleTable()
#define G4endl
Definition: G4ios.hh:61
G4int entries() const
void G4FastSimulationManager::ListTitle ( ) const

Definition at line 297 of file G4FastSimulationManager.cc.

References G4cout, G4FastTrack::GetEnvelope(), G4Region::GetName(), G4TransportationManager::GetNavigatorForTracking(), G4TransportationManager::GetTransportationManager(), G4Region::GetWorldPhysical(), and G4Navigator::GetWorldVolume().

Referenced by ListModels().

298 {
299  G4cout << fFastTrack.GetEnvelope()->GetName();
300  // if(GhostPlacements.size()!=0) G4cout << " (ghost)";
302  else G4cout << " (// geom.)";
303 
304 }
const G4String & GetName() const
G4Navigator * GetNavigatorForTracking() const
G4VPhysicalVolume * GetWorldPhysical() const
G4GLOB_DLL std::ostream G4cout
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * GetWorldVolume() const
G4Envelope * GetEnvelope() const
Definition: G4FastTrack.hh:188
G4bool G4FastSimulationManager::operator== ( const G4FastSimulationManager fsm) const
inline

Definition at line 200 of file G4FastSimulationManager.hh.

201 {
202  return (this==&fsm) ? true : false;
203 }
G4bool G4FastSimulationManager::PostStepGetFastSimulationManagerTrigger ( const G4Track track,
const G4Navigator a = 0 
)

Definition at line 184 of file G4FastSimulationManager.cc.

References G4Track::GetDefinition(), G4FastStep::Initialize(), G4FastTrack::OnTheBoundaryButExiting(), and G4FastTrack::SetCurrentTrack().

Referenced by G4FastSimulationManagerProcess::PostStepGetPhysicalInteractionLength().

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 }
G4ParticleDefinition * GetDefinition() const
G4bool OnTheBoundaryButExiting() const
Definition: G4FastTrack.hh:243
void Initialize(const G4FastTrack &)
Definition: G4FastStep.cc:53
void SetCurrentTrack(const G4Track &, const G4Navigator *a=0)
Definition: G4FastTrack.cc:68
void G4FastSimulationManager::RemoveFastSimulationModel ( G4VFastSimulationModel fsm)
inline

Definition at line 192 of file G4FastSimulationManager.hh.

References G4FastSimulationVector< T >::remove().

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: