Geant4-11
G4SteppingManager.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4SteppingManager class implementation
27//
28// Contact:
29// Questions and comments to this code should be sent to
30// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
31// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
32// --------------------------------------------------------------------
33
34#include "G4SteppingManager.hh"
35#include "G4SteppingVerbose.hh"
37#include "G4UImanager.hh"
38#include "G4ForceCondition.hh"
39#include "G4GPILSelection.hh"
40#include "G4SteppingControl.hh"
42#include "G4UserLimits.hh"
43#include "G4VSensitiveDetector.hh" // Include from 'hits/digi'
45#include "G4Profiler.hh"
46#include "G4TiMemory.hh"
47
51{
52 // Construct simple 'has-a' related objects
53
54 fStep = new G4Step();
58
59#ifdef G4VERBOSE
61 if(fVerbose==nullptr)
62 {
64 {
66 if(prec > 0)
68 else
69 { fVerbose = new G4SteppingVerbose(); }
70 }
71 else
73 KillVerbose = true;
74 }
75 else
76 { KillVerbose = false; }
77 fVerbose -> SetManager(this);
78#endif
79
81 ->GetNavigatorForTracking());
82
89
91 ->GetNavigatorForTracking());
92
96
98}
99
103{
105
106 // Destruct simple 'has-a' objects
107 //
109
110 // delete fSecondary;
111 delete fStep;
115 delete fUserSteppingAction;
116 #ifdef G4VERBOSE
117 if(KillVerbose) delete fVerbose;
118 #endif
119}
120
124{
125#ifdef GEANT4_USE_TIMEMORY
126 ProfilerConfig profiler{ fStep };
127#endif
128
129 //--------
130 // Prelude
131 //--------
132 #ifdef G4VERBOSE
133 if(verboseLevel>0)
134 {
135 fVerbose->NewStep();
136 }
137 else if (verboseLevel==-1)
138 {
140 }
141 else
142 {
144 }
145 #endif
146
147 // Store last PostStepPoint to PreStepPoint, and swap current and nex
148 // volume information of G4Track. Reset total energy deposit in one Step.
149 //
152
153 // Switch next touchable in track to current one
154 //
156
157 // Reset the secondary particles
158 //
162
163 // Set the volume before it is used (in DefineStepLength() for User Limit)
164 //
166
167 // Reset the step's auxiliary points vector pointer
168 //
170
171 //-----------------
172 // AtRest Processes
173 //-----------------
174
176 {
177 if( MAXofAtRestLoops>0 )
178 {
182
183 #ifdef G4VERBOSE
185 #endif
186
187 }
188 // Make sure the track is killed
189 //
191 }
192
193 //---------------------------------
194 // AlongStep and PostStep Processes
195 //---------------------------------
196
197 else
198 {
199 // Find minimum Step length demanded by active disc./cont. processes
201
202 // Store the Step length (geometrical length) to G4Step and G4Track
205 G4double GeomStepLength = PhysicalStep;
206
207 // Store StepStatus to PostStepPoint
209
210 // Invoke AlongStepDoIt
212
213 // Update track by taking into account all changes by AlongStepDoIt
215
216 // Update safety after invocation of all AlongStepDoIts
218 // endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
220
222
223 #ifdef G4VERBOSE
225 #endif
226
227 // Invoke PostStepDoIt
229
230 #ifdef G4VERBOSE
232 #endif
233 }
234
235 //-------
236 // Finale
237 //-------
238
239 // Update 'TrackLength' and remeber the Step length of the current Step
240 //
244
245 #ifdef G4VERBOSE
247 #endif
248
249 // Send G4Step information to Hit/Dig if the volume is sensitive
250 //
254 {
256 if( fSensitive != 0 )
257 {
259 }
260 }
261
262 // User intervention process
263 //
264 if( fUserSteppingAction != nullptr )
265 {
267 }
268
269 G4UserSteppingAction* regionalAction =
271
272 if(regionalAction)
273 regionalAction->UserSteppingAction(fStep);
274
275 // Stepping process finish. Return the value of the StepStatus
276 //
277 return fStepStatus;
278}
279
283{
284 // Set up several local variables
285 //
286 PreStepPointIsGeom = false;
287 FirstStep = true;
288 fParticleChange = nullptr;
291
292 fTrack = valueTrack;
294
295 PhysicalStep = 0.;
296 GeometricalStep = 0.;
297 CorrectedStep = 0.;
298 PreStepPointIsGeom = false;
299 FirstStep = false;
300
301 TempInitVelocity = 0.;
302 TempVelocity = 0.;
303 sumEnergyChange = 0.;
304
305 // If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
306 // set the track state to 'Alive'
307 //
310 {
312 }
313
314 // If the primary track has 'zero' kinetic energy, set the track
315 // state to 'StopButAlive'
316 //
317 if(fTrack->GetKineticEnergy() <= 0.0)
318 {
320 }
321
322 // Set Touchable to track and a private attribute of G4SteppingManager
323
324 if ( ! fTrack->GetTouchableHandle() )
325 {
328 &direction, false, false );
332 }
333 else
334 {
337 G4VPhysicalVolume* newTopVolume =
341 if ( newTopVolume != oldTopVolume
342 || oldTopVolume->GetRegularStructureId() == 1 )
343 {
347 }
348 }
349
350 // Set OriginTouchableHandle for primary track
351 //
352 if(fTrack->GetParentID()==0)
353 {
355 }
356
357 // Set vertex information of G4Track at here
358 //
359 if ( fTrack->GetCurrentStepNumber() == 0 )
360 {
365 }
366
367 // Initial set up for attributes of 'G4SteppingManager'
369
370 // If track is already outside the world boundary, kill it
371 //
372 if( fCurrentVolume==nullptr )
373 {
374 // If the track is a primary, stop processing
375 if(fTrack->GetParentID()==0)
376 {
377 G4cerr << "ERROR - G4SteppingManager::SetInitialStep()" << G4endl
378 << " Primary particle starting at - "
379 << fTrack->GetPosition()
380 << " - is outside of the world volume." << G4endl;
381 G4Exception("G4SteppingManager::SetInitialStep()", "Tracking0010",
382 FatalException, "Primary vertex outside of the world!");
383 }
384
386 G4cout << "WARNING - G4SteppingManager::SetInitialStep()" << G4endl
387 << " Initial track position is outside world! - "
388 << fTrack->GetPosition() << G4endl;
389 }
390 else
391 {
392 // Initial set up for attributes of 'Step'
394 }
395
396 #ifdef G4VERBOSE
398 #endif
399}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
class std::vector< int, std::allocator< int > > G4SelectedPostStepDoItVector
class std::vector< int, std::allocator< int > > G4SelectedAtRestDoItVector
class std::vector< int, std::allocator< int > > G4SelectedAlongStepDoItVector
G4StepStatus
Definition: G4StepStatus.hh:40
@ fUndefined
Definition: G4StepStatus.hh:55
@ fAtRestDoItProc
Definition: G4StepStatus.hh:45
@ AvoidHitInvocation
Definition of the G4SteppingVerboseWithUnits class.
@ fSuspend
@ fAlive
@ fStopAndKill
@ fStopButAlive
@ fPostponeToNextEvent
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double GetMass() const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4Region * GetRegion() const
G4TouchableHistory * CreateTouchableHistory() const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Definition: G4Navigator.cc:132
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
Definition: G4Navigator.cc:102
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:158
void SetSafety(const G4double aValue)
void SetStepStatus(const G4StepStatus aValue)
const G4ThreeVector & GetPosition() const
G4VSensitiveDetector * GetSensitiveDetector() const
G4VPhysicalVolume * GetPhysicalVolume() const
Definition: G4Step.hh:62
void DeleteSecondaryVector()
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *vec)
void InitializeStep(G4Track *aValue)
G4SteppingControl GetControlFlag() const
void UpdateTrack()
void ResetTotalEnergyDeposit()
void SetStepLength(G4double value)
void CopyPostToPreStepPoint()
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4TrackVector * NewSecondaryVector()
G4StepPoint * GetPostStepPoint() const
void SetTrack(G4Track *value)
std::size_t MAXofAtRestLoops
G4VSensitiveDetector * fSensitive
G4ThreeVector endpointSafOrigin
G4StepStatus Stepping()
G4TouchableHandle fTouchableHandle
G4StepPoint * fPostStepPoint
void SetNavigator(G4Navigator *value)
G4NoProcess const * fNoProcess
static const size_t SizeOfSelectedDoItVector
G4UserSteppingAction * fUserSteppingAction
G4Navigator * fNavigator
G4StepPoint * fPreStepPoint
G4SelectedAlongStepDoItVector * fSelectedAlongStepDoItVector
void SetInitialStep(G4Track *valueTrack)
G4TrackVector * fSecondary
G4VSteppingVerbose * fVerbose
G4SelectedPostStepDoItVector * fSelectedPostStepDoItVector
G4VParticleChange * fParticleChange
G4SelectedAtRestDoItVector * fSelectedAtRestDoItVector
G4StepStatus fStepStatus
G4SteppingControl StepControlFlag
G4VPhysicalVolume * fCurrentVolume
static G4int BestUnitPrecision()
G4TrackStatus GetTrackStatus() const
void SetTrackStatus(const G4TrackStatus aTrackStatus)
void SetStepLength(G4double value)
G4VPhysicalVolume * GetVolume() const
void SetVertexPosition(const G4ThreeVector &aValue)
const G4TouchableHandle & GetNextTouchableHandle() const
void SetVertexMomentumDirection(const G4ThreeVector &aValue)
void SetNextTouchableHandle(const G4TouchableHandle &apValue)
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4int GetCurrentStepNumber() const
void SetOriginTouchableHandle(const G4TouchableHandle &apValue)
void AddTrackLength(const G4double aValue)
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
void SetVertexKineticEnergy(const G4double aValue)
G4int GetParentID() const
void SetLogicalVolumeAtVertex(const G4LogicalVolume *)
static G4TransportationManager * GetTransportationManager()
virtual void UserSteppingAction(const G4Step *)
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetRegularStructureId() const =0
G4bool Hit(G4Step *aStep)
static G4VSteppingVerbose * GetInstance()
virtual void AlongStepDoItAllDone()=0
virtual G4VSteppingVerbose * Clone()
virtual void PostStepDoItAllDone()=0
virtual void AtRestDoItInvoked()=0
virtual void StepInfo()=0
static void SetSilent(G4int fSilent)
virtual void TrackingStarted()=0
virtual void NewStep()=0
static G4VSteppingVerbose * GetMasterInstance()
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:34
static const double prec
Definition: RanecuEngine.cc:61
T max(const T t1, const T t2)
brief Return the largest of the two arguments
#define DBL_MAX
Definition: templates.hh:62