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
G4ParticleChangeForDecay.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ParticleChangeForDecay.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
// GEANT 4 class implementation file
31
//
32
//
33
//
34
// ------------------------------------------------------------
35
// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
36
// Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige
37
// --------------------------------------------------------------
38
39
#include "
G4ParticleChangeForDecay.hh
"
40
#include "
G4SystemOfUnits.hh
"
41
#include "
G4Track.hh
"
42
#include "
G4Step.hh
"
43
#include "
G4TrackFastVector.hh
"
44
#include "
G4DynamicParticle.hh
"
45
#include "
G4ExceptionSeverity.hh
"
46
47
G4ParticleChangeForDecay::G4ParticleChangeForDecay
()
48
:
G4VParticleChange
(),
49
theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.)
50
{
51
#ifdef G4VERBOSE
52
if
(
verboseLevel
>2) {
53
G4cout
<<
"G4ParticleChangeForDecay::G4ParticleChangeForDecay() "
<<
G4endl
;
54
}
55
#endif
56
}
57
58
G4ParticleChangeForDecay::~G4ParticleChangeForDecay
()
59
{
60
#ifdef G4VERBOSE
61
if
(
verboseLevel
>2) {
62
G4cout
<<
"G4ParticleChangeForDecay::~G4ParticleChangeForDecay() "
<<
G4endl
;
63
}
64
#endif
65
}
66
67
G4ParticleChangeForDecay::G4ParticleChangeForDecay
(
const
G4ParticleChangeForDecay
&
right
):
G4VParticleChange
(right)
68
{
69
theGlobalTime0
= right.
theGlobalTime0
;
70
theLocalTime0
= right.
theLocalTime0
;
71
theTimeChange
= right.
theTimeChange
;
72
thePolarizationChange
= right.
thePolarizationChange
;
73
}
74
75
76
G4ParticleChangeForDecay
&
G4ParticleChangeForDecay::operator=
(
const
G4ParticleChangeForDecay
&
right
)
77
{
78
if
(
this
!= &right){
79
if
(
theNumberOfSecondaries
>0) {
80
#ifdef G4VERBOSE
81
if
(
verboseLevel
>0) {
82
G4cout
<<
"G4ParticleChangeForDecay: assignment operator Warning "
;
83
G4cout
<<
"theListOfSecondaries is not empty "
;
84
}
85
#endif
86
for
(
G4int
index= 0; index<
theNumberOfSecondaries
; index++){
87
if
( (*
theListOfSecondaries
)[index] )
delete
(*theListOfSecondaries)[index] ;
88
}
89
}
90
delete
theListOfSecondaries
;
91
theListOfSecondaries
=
new
G4TrackFastVector
();
92
theNumberOfSecondaries
= right.
theNumberOfSecondaries
;
93
for
(
G4int
index = 0; index<
theNumberOfSecondaries
; index++){
94
G4Track
* newTrack =
new
G4Track
(*((*right.
theListOfSecondaries
)[index] ));
95
theListOfSecondaries
->
SetElement
(index, newTrack); }
96
97
theStatusChange
= right.
theStatusChange
;
98
theTrueStepLength
= right.
theTrueStepLength
;
99
theLocalEnergyDeposit
= right.
theLocalEnergyDeposit
;
100
theSteppingControlFlag
= right.
theSteppingControlFlag
;
101
102
theGlobalTime0
= right.
theGlobalTime0
;
103
theLocalTime0
= right.
theLocalTime0
;
104
theTimeChange
= right.
theTimeChange
;
105
thePolarizationChange
= right.
thePolarizationChange
;
106
}
107
return
*
this
;
108
}
109
110
G4bool
G4ParticleChangeForDecay::operator==
(
const
G4ParticleChangeForDecay
&
right
)
const
111
{
112
return
((
G4VParticleChange
*)
this
== (
G4VParticleChange
*) &right);
113
}
114
115
G4bool
G4ParticleChangeForDecay::operator!=
(
const
G4ParticleChangeForDecay
&
right
)
const
116
{
117
return
((
G4VParticleChange
*)
this
!= (
G4VParticleChange
*) &right);
118
}
119
120
//----------------------------------------------------------------
121
// methods for Initialization
122
//
123
void
G4ParticleChangeForDecay::Initialize
(
const
G4Track
&
track
)
124
{
125
// use base class's method at first
126
G4VParticleChange::Initialize
(track);
127
128
const
G4DynamicParticle
* pParticle = track.
GetDynamicParticle
();
129
130
// set TimeChange equal to local time of the parent track
131
theTimeChange
= track.
GetLocalTime
();
132
133
// set initial Local/Global time of the parent track
134
theLocalTime0
= track.
GetLocalTime
();
135
theGlobalTime0
= track.
GetGlobalTime
();
136
137
// set the Polarization equal to those of the parent track
138
thePolarizationChange
= pParticle->
GetPolarization
();
139
}
140
141
//----------------------------------------------------------------
142
// methods for updating G4Step
143
//
144
145
G4Step
*
G4ParticleChangeForDecay::UpdateStepForPostStep
(
G4Step
* pStep)
146
{
147
G4StepPoint
* pPostStepPoint = pStep->
GetPostStepPoint
();
148
149
if
(
isParentWeightProposed
){
150
pPostStepPoint->
SetWeight
(
theParentWeight
);
151
}
152
// update polarization
153
pPostStepPoint->
SetPolarization
(
thePolarizationChange
);
154
155
// Update the G4Step specific attributes
156
return
UpdateStepInfo
(pStep);
157
}
158
159
160
G4Step
*
G4ParticleChangeForDecay::UpdateStepForAtRest
(
G4Step
* pStep)
161
{
162
// A physics process always calculates the final state of the particle
163
164
G4StepPoint
* pPostStepPoint = pStep->
GetPostStepPoint
();
165
166
// update polarization
167
pPostStepPoint->
SetPolarization
(
thePolarizationChange
);
168
169
// update time
170
pPostStepPoint->
SetGlobalTime
(
GetGlobalTime
() );
171
pPostStepPoint->
SetLocalTime
(
theTimeChange
);
172
pPostStepPoint->
AddProperTime
(
theTimeChange
-
theLocalTime0
);
173
174
#ifdef G4VERBOSE
175
G4Track
* aTrack = pStep->
GetTrack
();
176
if
(
debugFlag
)
CheckIt
(*aTrack);
177
#endif
178
179
if
(
isParentWeightProposed
)pPostStepPoint->
SetWeight
(
theParentWeight
);
180
181
// Update the G4Step specific attributes
182
return
UpdateStepInfo
(pStep);
183
}
184
185
void
G4ParticleChangeForDecay::DumpInfo
()
const
186
{
187
// Show header
188
G4VParticleChange::DumpInfo
();
189
190
G4int
oldprc =
G4cout
.precision(3);
191
G4cout
<<
" proposed local Time (ns) : "
192
<< std::setw(20) <<
theTimeChange
/
ns
<<
G4endl
;
193
G4cout
<<
" initial local Time (ns) : "
194
<< std::setw(20) <<
theLocalTime0
/
ns
<<
G4endl
;
195
G4cout
<<
" initial global Time (ns) : "
196
<< std::setw(20) <<
theGlobalTime0
/
ns
<<
G4endl
;
197
G4cout
.precision(oldprc);
198
}
199
200
G4bool
G4ParticleChangeForDecay::CheckIt
(
const
G4Track
& aTrack)
201
{
202
G4bool
exitWithError =
false
;
203
204
G4double
accuracy;
205
206
// local time should not go back
207
G4bool
itsOK =
true
;
208
accuracy = -1.0*(
theTimeChange
-
theLocalTime0
)/
ns
;
209
if
(accuracy >
accuracyForWarning
) {
210
itsOK =
false
;
211
exitWithError = (accuracy >
accuracyForException
);
212
#ifdef G4VERBOSE
213
G4cout
<<
" G4ParticleChangeForDecay::CheckIt : "
;
214
G4cout
<<
"the local time goes back !!"
215
<<
" Difference: "
<< accuracy <<
"[ns] "
<<
G4endl
;
216
G4cout
<<
"initial local time "
<<
theLocalTime0
/
ns
<<
"[ns] "
217
<<
"initial global time "
<<
theGlobalTime0
/
ns
<<
"[ns] "
<<
G4endl
;
218
G4cout
<< aTrack.
GetDefinition
()->
GetParticleName
()
219
<<
" E="
<< aTrack.
GetKineticEnergy
()/
MeV
220
<<
" pos="
<< aTrack.
GetPosition
().
x
()/
m
221
<<
", "
<< aTrack.
GetPosition
().
y
()/
m
222
<<
", "
<< aTrack.
GetPosition
().
z
()/
m
223
<<
G4endl
;
224
#endif
225
}
226
227
// dump out information of this particle change
228
#ifdef G4VERBOSE
229
if
(!itsOK)
DumpInfo
();
230
#endif
231
232
// Exit with error
233
if
(exitWithError) {
234
G4Exception
(
"G4ParticleChangeForDecay::CheckIt"
,
235
"TRACK005"
,
EventMustBeAborted
,
236
"time was illegal"
);
237
}
238
239
// correction
240
if
(!itsOK) {
241
theTimeChange
= aTrack.
GetLocalTime
();
242
}
243
244
itsOK = (itsOK) &&
G4VParticleChange::CheckIt
(aTrack);
245
return
itsOK;
246
}
247
248
249
250
251
geant4
tree
geant4-10.6-release
source
track
src
G4ParticleChangeForDecay.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:53
using
1.8.2 with
ECCE GitHub integration