Geant4  10.03
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 //
27 // $Id: G4SteppingManager.cc 95198 2016-01-29 08:28:27Z gcosmo $
28 //
29 //---------------------------------------------------------------
30 //
31 // G4SteppingManager.cc
32 //
33 // Description:
34 // This class represents the manager who steers to move the give
35 // particle from the TrackingManger by one Step.
36 //
37 // Contact:
38 // Questions and comments to this code should be sent to
39 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
40 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
41 //
42 //---------------------------------------------------------------
43 
44 #include "G4SteppingManager.hh"
45 #include "G4SteppingVerbose.hh"
46 #include "G4UImanager.hh"
47 #include "G4ForceCondition.hh"
48 #include "G4GPILSelection.hh"
49 #include "G4SteppingControl.hh"
51 #include "G4UserLimits.hh"
52 #include "G4VSensitiveDetector.hh" // Include from 'hits/digi'
53 #include "G4GeometryTolerance.hh"
54 
58  : fUserSteppingAction(0), verboseLevel(0)
59 {
60 
61 // Construct simple 'has-a' related objects
62  fStep = new G4Step();
66 #ifdef G4VERBOSE
70  fVerbose -> SetManager(this);
71  KillVerbose = true;
72  }
73  else {
75  fVerbose -> SetManager(this);
76  KillVerbose = false;
77  }
78 #endif
80  ->GetNavigatorForTracking());
81 
88 
90  ->GetNavigatorForTracking());
91 
94 }
95 
99 {
100  fTouchableHandle = 0;
101 // Destruct simple 'has-a' objects
104  delete fStep;
109 #ifdef G4VERBOSE
110  if(KillVerbose) delete fVerbose;
111 #endif
112 }
113 
114 
118 {
119 
120 //--------
121 // Prelude
122 //--------
123 #ifdef G4VERBOSE
124  // !!!!! Verbose
125  if(verboseLevel>0) fVerbose->NewStep();
126  else
127  if(verboseLevel==-1) {
129  }
130  else
132 #endif
133 
134 // Store last PostStepPoint to PreStepPoint, and swap current and nex
135 // volume information of G4Track. Reset total energy deposit in one Step.
138 
139 // Switch next touchable in track to current one
141 
142 // Reset the secondary particles
146 
147 //JA Set the volume before it is used (in DefineStepLength() for User Limit)
149 
150 // Reset the step's auxiliary points vector pointer
152 
153 //-----------------
154 // AtRest Processes
155 //-----------------
156 
157  if( fTrack->GetTrackStatus() == fStopButAlive ){
158  if( MAXofAtRestLoops>0 ){
162 
163 #ifdef G4VERBOSE
164  // !!!!! Verbose
166 #endif
167 
168  }
169  // Make sure the track is killed
171  }
172 
173 //---------------------------------
174 // AlongStep and PostStep Processes
175 //---------------------------------
176 
177 
178  else{
179  // Find minimum Step length demanded by active disc./cont. processes
181 
182  // Store the Step length (geometrical length) to G4Step and G4Track
185  G4double GeomStepLength = PhysicalStep;
186 
187  // Store StepStatus to PostStepPoint
189 
190  // Invoke AlongStepDoIt
192 
193  // Update track by taking into account all changes by AlongStepDoIt
194  fStep->UpdateTrack();
195 
196  // Update safety after invocation of all AlongStepDoIts
198 // endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
200 
202 
203 #ifdef G4VERBOSE
204  // !!!!! Verbose
206 #endif
207 
208  // Invoke PostStepDoIt
210 
211 #ifdef G4VERBOSE
212  // !!!!! Verbose
214 #endif
215  }
216 
217 //-------
218 // Finale
219 //-------
220 
221 // Update 'TrackLength' and remeber the Step length of the current Step
225 #ifdef G4VERBOSE
226  // !!!!! Verbose
227 
228  if(verboseLevel>0) fVerbose->StepInfo();
229 #endif
230 // Send G4Step information to Hit/Dig if the volume is sensitive
235  GetSensitiveDetector();
236  if( fSensitive != 0 ) {
237  fSensitive->Hit(fStep);
238  }
239  }
240 
241 // User intervention process.
242  if( fUserSteppingAction != 0 ) {
244  }
245  G4UserSteppingAction* regionalAction
248  if( regionalAction ) regionalAction->UserSteppingAction(fStep);
249 
250 // Stepping process finish. Return the value of the StepStatus.
251  return fStepStatus;
252 
253 }
254 
258 {
259 
260 // Set up several local variables.
261  PreStepPointIsGeom = false;
262  FirstStep = true;
263  fParticleChange = 0;
264  fPreviousStepSize = 0.;
266 
267  fTrack = valueTrack;
269 
270  PhysicalStep = 0.;
271  GeometricalStep = 0.;
272  CorrectedStep = 0.;
273  PreStepPointIsGeom = false;
274  FirstStep = false;
276 
277  TempInitVelocity = 0.;
278  TempVelocity = 0.;
279  sumEnergyChange = 0.;
280 
281 
282 // If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
283 // set the track state to 'Alive'.
284  if( (fTrack->GetTrackStatus()==fSuspend) ||
287  }
288 
289 // If the primary track has 'zero' kinetic energy, set the track
290 // state to 'StopButAlive'.
291  if(fTrack->GetKineticEnergy() <= 0.0){
293  }
294 
295 
296 // Set Touchable to track and a private attribute of G4SteppingManager
297 
298 
299  if ( ! fTrack->GetTouchableHandle() ) {
302  &direction, false, false );
304 
307  }else{
310  G4VPhysicalVolume* newTopVolume=
314 // if(newTopVolume != oldTopVolume ){
315  if(newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() == 1 ) {
319  }
320  }
321 // Set OriginTouchableHandle for primary track
322  if(fTrack->GetParentID()==0){
324  }
325 
326 // Set vertex information of G4Track at here
327  if ( fTrack->GetCurrentStepNumber() == 0 ) {
332  }
333 // Initial set up for attributes of 'G4SteppingManager'
335 
336 // If track is already outside the world boundary, kill it
337  if( fCurrentVolume==0 ){
338  // If the track is a primary, stop processing
339  if(fTrack->GetParentID()==0)
340  {
341  G4cerr << "ERROR - G4SteppingManager::SetInitialStep()" << G4endl
342  << " Primary particle starting at - "
343  << fTrack->GetPosition()
344  << " - is outside of the world volume." << G4endl;
345  G4Exception("G4SteppingManager::SetInitialStep()", "Tracking0010",
346  FatalException, "Primary vertex outside of the world!");
347  }
348 
350  G4cout << "WARNING - G4SteppingManager::SetInitialStep()" << G4endl
351  << " Initial track position is outside world! - "
352  << fTrack->GetPosition() << G4endl;
353  }
354  else {
355 // Initial set up for attribues of 'Step'
357  }
358 #ifdef G4VERBOSE
359  // !!!!! Verbose
361 #endif
362 }
363 
void SetTrackStatus(const G4TrackStatus aTrackStatus)
void SetStepLength(G4double value)
G4int GetParentID() const
void SetTrack(G4Track *value)
void SetVertexMomentumDirection(const G4ThreeVector &aValue)
static G4VSteppingVerbose * GetInstance()
void SetNavigator(G4Navigator *value)
void SetOriginTouchableHandle(const G4TouchableHandle &apValue)
G4UserSteppingAction * GetRegionalSteppingAction() const
Definition: G4Region.cc:155
CLHEP::Hep3Vector G4ThreeVector
G4double GetStepLength() const
static void SetSilent(G4int fSilent)
void DeleteSecondaryVector()
const G4DynamicParticle * GetDynamicParticle() const
virtual void StepInfo()=0
class std::vector< int, std::allocator< int > > G4SelectedAtRestDoItVector
G4SteppingControl StepControlFlag
class std::vector< int, std::allocator< int > > G4SelectedAlongStepDoItVector
G4Navigator * fNavigator
virtual void PostStepDoItAllDone()=0
G4VSteppingVerbose * fVerbose
const G4ThreeVector & GetPosition() const
G4double GetSurfaceTolerance() const
G4TrackStatus GetTrackStatus() const
void SetNextTouchableHandle(const G4TouchableHandle &apValue)
G4UserSteppingAction * fUserSteppingAction
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4SteppingControl GetControlFlag() const
G4SelectedPostStepDoItVector * fSelectedPostStepDoItVector
void SetPointerToVectorOfAuxiliaryPoints(std::vector< G4ThreeVector > *theNewVectorPointer)
Definition: G4Step.hh:239
G4Region * GetRegion() const
virtual void UserSteppingAction(const G4Step *)
void SetStepStatus(const G4StepStatus aValue)
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
Definition: G4Navigator.cc:95
G4StepStatus
Definition: G4StepStatus.hh:49
G4StepPoint * GetPreStepPoint() const
void UpdateTrack()
G4SelectedAlongStepDoItVector * fSelectedAlongStepDoItVector
G4double GetKineticEnergy() const
class std::vector< int, std::allocator< int > > G4SelectedPostStepDoItVector
G4GLOB_DLL std::ostream G4cout
G4int GetCurrentStepNumber() const
G4TrackVector * NewSecondaryVector()
G4VPhysicalVolume * GetPhysicalVolume() const
const G4ThreeVector & GetPosition() const
G4double GetMass() const
void SetStepLength(G4double value)
virtual G4int GetRegularStructureId() const =0
void ResetTotalEnergyDeposit()
void SetVertexKineticEnergy(const G4double aValue)
const G4TouchableHandle & GetNextTouchableHandle() const
G4bool Hit(G4Step *aStep)
Definition: G4Step.hh:76
G4StepStatus Stepping()
G4ThreeVector endpointSafOrigin
const G4TouchableHandle & GetTouchableHandle() const
void SetInitialStep(G4Track *valueTrack)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4TransportationManager * GetTransportationManager()
G4TouchableHistory * CreateTouchableHistory() const
const G4ThreeVector & GetMomentumDirection() const
static void SetInstance(G4VSteppingVerbose *Instance)
G4LogicalVolume * GetLogicalVolume() const
G4StepPoint * fPostStepPoint
G4TrackVector * fSecondary
T max(const T t1, const T t2)
brief Return the largest of the two arguments
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
void SetVertexPosition(const G4ThreeVector &aValue)
G4StepPoint * GetPostStepPoint() const
virtual void AtRestDoItInvoked()=0
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
Definition: G4Navigator.cc:125
G4VSensitiveDetector * fSensitive
G4VPhysicalVolume * GetVolume() const
G4VPhysicalVolume * fCurrentVolume
#define G4endl
Definition: G4ios.hh:61
void AddTrackLength(const G4double aValue)
void InitializeStep(G4Track *aValue)
virtual void NewStep()=0
virtual void AlongStepDoItAllDone()=0
double G4double
Definition: G4Types.hh:76
void SetSafety(const G4double aValue)
G4VParticleChange * fParticleChange
#define DBL_MAX
Definition: templates.hh:83
G4SelectedAtRestDoItVector * fSelectedAtRestDoItVector
static G4GeometryTolerance * GetInstance()
static const size_t SizeOfSelectedDoItVector
G4GLOB_DLL std::ostream G4cerr
G4StepStatus fStepStatus
G4TouchableHandle fTouchableHandle
void SetLogicalVolumeAtVertex(const G4LogicalVolume *)
void CopyPostToPreStepPoint()
virtual void TrackingStarted()=0
G4StepPoint * fPreStepPoint