ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
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
"
49
#include "
G4TransportationManager.hh
"
50
#include "
G4UserLimits.hh
"
51
#include "
G4VSensitiveDetector.hh
"
// Include from 'hits/digi'
52
#include "
G4GeometryTolerance.hh
"
53
55
G4SteppingManager::G4SteppingManager
()
57
: fUserSteppingAction(0), verboseLevel(0)
58
{
59
60
// Construct simple 'has-a' related objects
61
fStep
=
new
G4Step
();
62
fSecondary
=
fStep
->
NewSecondaryVector
();
63
fPreStepPoint
=
fStep
->
GetPreStepPoint
();
64
fPostStepPoint
=
fStep
->
GetPostStepPoint
();
65
#ifdef G4VERBOSE
66
if
(
G4VSteppingVerbose::GetInstance
()==0) {
67
fVerbose
=
new
G4SteppingVerbose
();
68
G4VSteppingVerbose::SetInstance
(
fVerbose
);
69
fVerbose
-> SetManager(
this
);
70
KillVerbose
=
true
;
71
}
72
else
{
73
fVerbose
=
G4VSteppingVerbose::GetInstance
();
74
fVerbose
-> SetManager(
this
);
75
KillVerbose
=
false
;
76
}
77
#endif
78
SetNavigator
(
G4TransportationManager::GetTransportationManager
()
79
->GetNavigatorForTracking());
80
81
fSelectedAtRestDoItVector
82
=
new
G4SelectedAtRestDoItVector
(
SizeOfSelectedDoItVector
,0);
83
fSelectedAlongStepDoItVector
84
=
new
G4SelectedAlongStepDoItVector
(
SizeOfSelectedDoItVector
,0);
85
fSelectedPostStepDoItVector
86
=
new
G4SelectedPostStepDoItVector
(
SizeOfSelectedDoItVector
,0);
87
88
SetNavigator
(
G4TransportationManager::GetTransportationManager
()
89
->GetNavigatorForTracking());
90
91
physIntLength
=
DBL_MAX
;
92
kCarTolerance
= 0.5*
G4GeometryTolerance::GetInstance
()->
GetSurfaceTolerance
();
93
}
94
96
G4SteppingManager::~G4SteppingManager
()
98
{
99
fTouchableHandle
= 0;
100
// Destruct simple 'has-a' objects
101
fStep
->
DeleteSecondaryVector
();
103
delete
fStep
;
104
delete
fSelectedAtRestDoItVector
;
105
delete
fSelectedAlongStepDoItVector
;
106
delete
fSelectedPostStepDoItVector
;
107
if
(
fUserSteppingAction
)
delete
fUserSteppingAction
;
108
#ifdef G4VERBOSE
109
if
(
KillVerbose
)
delete
fVerbose
;
110
#endif
111
}
112
113
115
G4StepStatus
G4SteppingManager::Stepping
()
117
{
118
119
//--------
120
// Prelude
121
//--------
122
#ifdef G4VERBOSE
123
// !!!!! Verbose
124
if
(
verboseLevel
>0)
fVerbose
->
NewStep
();
125
else
126
if
(
verboseLevel
==-1) {
127
G4VSteppingVerbose::SetSilent
(1);
128
}
129
else
130
G4VSteppingVerbose::SetSilent
(0);
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.
135
fStep
->
CopyPostToPreStepPoint
();
136
fStep
->
ResetTotalEnergyDeposit
();
137
138
// Switch next touchable in track to current one
139
fTrack
->
SetTouchableHandle
(
fTrack
->
GetNextTouchableHandle
());
140
141
// Reset the secondary particles
142
fN2ndariesAtRestDoIt
= 0;
143
fN2ndariesAlongStepDoIt
= 0;
144
fN2ndariesPostStepDoIt
= 0;
145
146
//JA Set the volume before it is used (in DefineStepLength() for User Limit)
147
fCurrentVolume
=
fStep
->
GetPreStepPoint
()->
GetPhysicalVolume
();
148
149
// Reset the step's auxiliary points vector pointer
150
fStep
->
SetPointerToVectorOfAuxiliaryPoints
(0);
151
152
//-----------------
153
// AtRest Processes
154
//-----------------
155
156
if
(
fTrack
->
GetTrackStatus
() ==
fStopButAlive
){
157
if
(
MAXofAtRestLoops
>0 ){
158
InvokeAtRestDoItProcs
();
159
fStepStatus
=
fAtRestDoItProc
;
160
fStep
->
GetPostStepPoint
()->
SetStepStatus
(
fStepStatus
);
161
162
#ifdef G4VERBOSE
163
// !!!!! Verbose
164
if
(
verboseLevel
>0)
fVerbose
->
AtRestDoItInvoked
();
165
#endif
166
167
}
168
// Make sure the track is killed
169
fTrack
->
SetTrackStatus
(
fStopAndKill
);
170
}
171
172
//---------------------------------
173
// AlongStep and PostStep Processes
174
//---------------------------------
175
176
177
else
{
178
// Find minimum Step length demanded by active disc./cont. processes
179
DefinePhysicalStepLength
();
180
181
// Store the Step length (geometrical length) to G4Step and G4Track
182
fStep
->
SetStepLength
(
PhysicalStep
);
183
fTrack
->
SetStepLength
(
PhysicalStep
);
184
G4double
GeomStepLength =
PhysicalStep
;
185
186
// Store StepStatus to PostStepPoint
187
fStep
->
GetPostStepPoint
()->
SetStepStatus
(
fStepStatus
);
188
189
// Invoke AlongStepDoIt
190
InvokeAlongStepDoItProcs
();
191
192
// Update track by taking into account all changes by AlongStepDoIt
193
fStep
->
UpdateTrack
();
194
195
// Update safety after invocation of all AlongStepDoIts
196
endpointSafOrigin
=
fPostStepPoint
->
GetPosition
();
197
// endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
198
endpointSafety
=
std::max
(
proposedSafety
- GeomStepLength,
kCarTolerance
);
199
200
fStep
->
GetPostStepPoint
()->
SetSafety
(
endpointSafety
);
201
202
#ifdef G4VERBOSE
203
// !!!!! Verbose
204
if
(
verboseLevel
>0)
fVerbose
->
AlongStepDoItAllDone
();
205
#endif
206
207
// Invoke PostStepDoIt
208
InvokePostStepDoItProcs
();
209
210
#ifdef G4VERBOSE
211
// !!!!! Verbose
212
if
(
verboseLevel
>0)
fVerbose
->
PostStepDoItAllDone
();
213
#endif
214
}
215
216
//-------
217
// Finale
218
//-------
219
220
// Update 'TrackLength' and remeber the Step length of the current Step
221
fTrack
->
AddTrackLength
(
fStep
->
GetStepLength
());
222
fPreviousStepSize
=
fStep
->
GetStepLength
();
223
fStep
->
SetTrack
(
fTrack
);
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
230
fCurrentVolume
=
fStep
->
GetPreStepPoint
()->
GetPhysicalVolume
();
231
StepControlFlag
=
fStep
->
GetControlFlag
();
232
if
(
fCurrentVolume
!= 0 &&
StepControlFlag
!=
AvoidHitInvocation
) {
233
fSensitive
=
fStep
->
GetPreStepPoint
()->
234
GetSensitiveDetector();
235
if
(
fSensitive
!= 0 ) {
236
fSensitive
->
Hit
(
fStep
);
237
}
238
}
239
240
// User intervention process.
241
if
(
fUserSteppingAction
!= 0 ) {
242
fUserSteppingAction
->
UserSteppingAction
(
fStep
);
243
}
244
G4UserSteppingAction
* regionalAction
245
=
fStep
->
GetPreStepPoint
()->
GetPhysicalVolume
()->
GetLogicalVolume
()->
GetRegion
()
246
->
GetRegionalSteppingAction
();
247
if
( regionalAction ) regionalAction->
UserSteppingAction
(
fStep
);
248
249
// Stepping process finish. Return the value of the StepStatus.
250
return
fStepStatus
;
251
252
}
253
255
void
G4SteppingManager::SetInitialStep
(
G4Track
* valueTrack)
257
{
258
259
// Set up several local variables.
260
PreStepPointIsGeom
=
false
;
261
FirstStep
=
true
;
262
fParticleChange
= 0;
263
fPreviousStepSize
= 0.;
264
fStepStatus
=
fUndefined
;
265
266
fTrack
= valueTrack;
267
Mass
=
fTrack
->
GetDynamicParticle
()->
GetMass
();
268
269
PhysicalStep
= 0.;
270
GeometricalStep
= 0.;
271
CorrectedStep
= 0.;
272
PreStepPointIsGeom
=
false
;
273
FirstStep
=
false
;
274
fStepStatus
=
fUndefined
;
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
) ||
284
(
fTrack
->
GetTrackStatus
()==
fPostponeToNextEvent
) ){
285
fTrack
->
SetTrackStatus
(
fAlive
);
286
}
287
288
// If the primary track has 'zero' kinetic energy, set the track
289
// state to 'StopButAlive'.
290
if
(
fTrack
->
GetKineticEnergy
() <= 0.0){
291
fTrack
->
SetTrackStatus
(
fStopButAlive
);
292
}
293
294
295
// Set Touchable to track and a private attribute of G4SteppingManager
296
297
298
if
( !
fTrack
->
GetTouchableHandle
() ) {
299
G4ThreeVector
direction=
fTrack
->
GetMomentumDirection
();
300
fNavigator
->
LocateGlobalPointAndSetup
(
fTrack
->
GetPosition
(),
301
&direction,
false
,
false
);
302
fTouchableHandle
=
fNavigator
->
CreateTouchableHistory
();
303
304
fTrack
->
SetTouchableHandle
(
fTouchableHandle
);
305
fTrack
->
SetNextTouchableHandle
(
fTouchableHandle
);
306
}
else
{
307
fTrack
->
SetNextTouchableHandle
(
fTouchableHandle
=
fTrack
->
GetTouchableHandle
() );
308
G4VPhysicalVolume
* oldTopVolume=
fTrack
->
GetTouchableHandle
()->
GetVolume
();
309
G4VPhysicalVolume
* newTopVolume=
310
fNavigator
->
ResetHierarchyAndLocate
(
fTrack
->
GetPosition
(),
311
fTrack
->
GetMomentumDirection
(),
312
*((
G4TouchableHistory
*)
fTrack
->
GetTouchableHandle
()()) );
313
// if(newTopVolume != oldTopVolume ){
314
if
(newTopVolume != oldTopVolume || oldTopVolume->
GetRegularStructureId
() == 1 ) {
315
fTouchableHandle
=
fNavigator
->
CreateTouchableHistory
();
316
fTrack
->
SetTouchableHandle
(
fTouchableHandle
);
317
fTrack
->
SetNextTouchableHandle
(
fTouchableHandle
);
318
}
319
}
320
// Set OriginTouchableHandle for primary track
321
if
(
fTrack
->
GetParentID
()==0){
322
fTrack
->
SetOriginTouchableHandle
(
fTrack
->
GetTouchableHandle
());
323
}
324
325
// Set vertex information of G4Track at here
326
if
(
fTrack
->
GetCurrentStepNumber
() == 0 ) {
327
fTrack
->
SetVertexPosition
(
fTrack
->
GetPosition
() );
328
fTrack
->
SetVertexMomentumDirection
(
fTrack
->
GetMomentumDirection
() );
329
fTrack
->
SetVertexKineticEnergy
(
fTrack
->
GetKineticEnergy
() );
330
fTrack
->
SetLogicalVolumeAtVertex
(
fTrack
->
GetVolume
()->
GetLogicalVolume
() );
331
}
332
// Initial set up for attributes of 'G4SteppingManager'
333
fCurrentVolume
=
fTouchableHandle
->
GetVolume
();
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
348
fTrack
->
SetTrackStatus
(
fStopAndKill
);
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'
355
fStep
->
InitializeStep
(
fTrack
);
356
}
357
#ifdef G4VERBOSE
358
// !!!!! Verbose
359
if
(
verboseLevel
>0)
fVerbose
->
TrackingStarted
();
360
#endif
361
}
362
geant4
tree
geant4-10.6-release
source
tracking
src
G4SteppingManager.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:54
using
1.8.2 with
ECCE GitHub integration