ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4SteppingManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4SteppingManager.cc
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 //
28 //---------------------------------------------------------------
29 //
30 // G4SteppingManager.cc
31 //
32 // Description:
33 // This class represents the manager who steers to move the give
34 // particle from the TrackingManger by one Step.
35 //
36 // Contact:
37 // Questions and comments to this code should be sent to
38 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
39 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
40 //
41 //---------------------------------------------------------------
42 
43 #include "G4SteppingManager.hh"
44 #include "G4SteppingVerbose.hh"
45 #include "G4UImanager.hh"
46 #include "G4ForceCondition.hh"
47 #include "G4GPILSelection.hh"
48 #include "G4SteppingControl.hh"
50 #include "G4UserLimits.hh"
51 #include "G4VSensitiveDetector.hh" // Include from 'hits/digi'
52 #include "G4GeometryTolerance.hh"
53 
57  : fUserSteppingAction(0), verboseLevel(0)
58 {
59 
60 // Construct simple 'has-a' related objects
61  fStep = new G4Step();
65 #ifdef G4VERBOSE
69  fVerbose -> SetManager(this);
70  KillVerbose = true;
71  }
72  else {
74  fVerbose -> SetManager(this);
75  KillVerbose = false;
76  }
77 #endif
79  ->GetNavigatorForTracking());
80 
87 
89  ->GetNavigatorForTracking());
90 
93 }
94 
98 {
99  fTouchableHandle = 0;
100 // Destruct simple 'has-a' objects
103  delete fStep;
108 #ifdef G4VERBOSE
109  if(KillVerbose) delete fVerbose;
110 #endif
111 }
112 
113 
117 {
118 
119 //--------
120 // Prelude
121 //--------
122 #ifdef G4VERBOSE
123  // !!!!! Verbose
124  if(verboseLevel>0) fVerbose->NewStep();
125  else
126  if(verboseLevel==-1) {
128  }
129  else
131 #endif
132 
133 // Store last PostStepPoint to PreStepPoint, and swap current and nex
134 // volume information of G4Track. Reset total energy deposit in one Step.
137 
138 // Switch next touchable in track to current one
140 
141 // Reset the secondary particles
145 
146 //JA Set the volume before it is used (in DefineStepLength() for User Limit)
148 
149 // Reset the step's auxiliary points vector pointer
151 
152 //-----------------
153 // AtRest Processes
154 //-----------------
155 
156  if( fTrack->GetTrackStatus() == fStopButAlive ){
157  if( MAXofAtRestLoops>0 ){
161 
162 #ifdef G4VERBOSE
163  // !!!!! Verbose
165 #endif
166 
167  }
168  // Make sure the track is killed
170  }
171 
172 //---------------------------------
173 // AlongStep and PostStep Processes
174 //---------------------------------
175 
176 
177  else{
178  // Find minimum Step length demanded by active disc./cont. processes
180 
181  // Store the Step length (geometrical length) to G4Step and G4Track
184  G4double GeomStepLength = PhysicalStep;
185 
186  // Store StepStatus to PostStepPoint
188 
189  // Invoke AlongStepDoIt
191 
192  // Update track by taking into account all changes by AlongStepDoIt
193  fStep->UpdateTrack();
194 
195  // Update safety after invocation of all AlongStepDoIts
197 // endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
199 
201 
202 #ifdef G4VERBOSE
203  // !!!!! Verbose
205 #endif
206 
207  // Invoke PostStepDoIt
209 
210 #ifdef G4VERBOSE
211  // !!!!! Verbose
213 #endif
214  }
215 
216 //-------
217 // Finale
218 //-------
219 
220 // Update 'TrackLength' and remeber the Step length of the current Step
224 #ifdef G4VERBOSE
225  // !!!!! Verbose
226 
227  if(verboseLevel>0) fVerbose->StepInfo();
228 #endif
229 // Send G4Step information to Hit/Dig if the volume is sensitive
234  GetSensitiveDetector();
235  if( fSensitive != 0 ) {
236  fSensitive->Hit(fStep);
237  }
238  }
239 
240 // User intervention process.
241  if( fUserSteppingAction != 0 ) {
243  }
244  G4UserSteppingAction* regionalAction
247  if( regionalAction ) regionalAction->UserSteppingAction(fStep);
248 
249 // Stepping process finish. Return the value of the StepStatus.
250  return fStepStatus;
251 
252 }
253 
257 {
258 
259 // Set up several local variables.
260  PreStepPointIsGeom = false;
261  FirstStep = true;
262  fParticleChange = 0;
263  fPreviousStepSize = 0.;
265 
266  fTrack = valueTrack;
268 
269  PhysicalStep = 0.;
270  GeometricalStep = 0.;
271  CorrectedStep = 0.;
272  PreStepPointIsGeom = false;
273  FirstStep = false;
275 
276  TempInitVelocity = 0.;
277  TempVelocity = 0.;
278  sumEnergyChange = 0.;
279 
280 
281 // If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
282 // set the track state to 'Alive'.
283  if( (fTrack->GetTrackStatus()==fSuspend) ||
286  }
287 
288 // If the primary track has 'zero' kinetic energy, set the track
289 // state to 'StopButAlive'.
290  if(fTrack->GetKineticEnergy() <= 0.0){
292  }
293 
294 
295 // Set Touchable to track and a private attribute of G4SteppingManager
296 
297 
298  if ( ! fTrack->GetTouchableHandle() ) {
301  &direction, false, false );
303 
306  }else{
309  G4VPhysicalVolume* newTopVolume=
313 // if(newTopVolume != oldTopVolume ){
314  if(newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() == 1 ) {
318  }
319  }
320 // Set OriginTouchableHandle for primary track
321  if(fTrack->GetParentID()==0){
323  }
324 
325 // Set vertex information of G4Track at here
326  if ( fTrack->GetCurrentStepNumber() == 0 ) {
331  }
332 // Initial set up for attributes of 'G4SteppingManager'
334 
335 // If track is already outside the world boundary, kill it
336  if( fCurrentVolume==0 ){
337  // If the track is a primary, stop processing
338  if(fTrack->GetParentID()==0)
339  {
340  G4cerr << "ERROR - G4SteppingManager::SetInitialStep()" << G4endl
341  << " Primary particle starting at - "
342  << fTrack->GetPosition()
343  << " - is outside of the world volume." << G4endl;
344  G4Exception("G4SteppingManager::SetInitialStep()", "Tracking0010",
345  FatalException, "Primary vertex outside of the world!");
346  }
347 
349  G4cout << "WARNING - G4SteppingManager::SetInitialStep()" << G4endl
350  << " Initial track position is outside world! - "
351  << fTrack->GetPosition() << G4endl;
352  }
353  else {
354 // Initial set up for attribues of 'Step'
356  }
357 #ifdef G4VERBOSE
358  // !!!!! Verbose
360 #endif
361 }
362