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
G4ParticleChangeForGamma.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ParticleChangeForGamma.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
// 15 April 2005 V.Ivanchenko for gamma EM processes
34
// --------------------------------------------------------------
35
//
36
// Modified::
37
// 28.08.06 V.Ivanchenko Add access to current track and polarizaion
38
//
39
// ------------------------------------------------------------
40
//
41
#include "
G4ParticleChangeForGamma.hh
"
42
#include "
G4SystemOfUnits.hh
"
43
#include "
G4Track.hh
"
44
#include "
G4Step.hh
"
45
#include "
G4DynamicParticle.hh
"
46
#include "
G4ExceptionSeverity.hh
"
47
48
G4ParticleChangeForGamma::G4ParticleChangeForGamma
()
49
:
G4VParticleChange
(), currentTrack(0), proposedKinEnergy(0.)
50
{
51
theSteppingControlFlag
=
NormalCondition
;
52
debugFlag
=
false
;
53
#ifdef G4VERBOSE
54
if
(
verboseLevel
>2) {
55
G4cout
<<
"G4ParticleChangeForGamma::G4ParticleChangeForGamma() "
<<
G4endl
;
56
}
57
#endif
58
}
59
60
G4ParticleChangeForGamma::~G4ParticleChangeForGamma
()
61
{
62
#ifdef G4VERBOSE
63
if
(
verboseLevel
>2) {
64
G4cout
<<
"G4ParticleChangeForGamma::~G4ParticleChangeForGamma() "
<<
G4endl
;
65
}
66
#endif
67
}
68
69
G4ParticleChangeForGamma::G4ParticleChangeForGamma
(
70
const
G4ParticleChangeForGamma
&
right
):
G4VParticleChange
(right)
71
{
72
if
(
verboseLevel
>1)
73
G4cout
<<
"G4ParticleChangeForGamma:: copy constructor is called "
<<
G4endl
;
74
75
currentTrack
= right.
currentTrack
;
76
proposedKinEnergy
= right.
proposedKinEnergy
;
77
proposedMomentumDirection
= right.
proposedMomentumDirection
;
78
proposedPolarization
= right.
proposedPolarization
;
79
}
80
81
// assignment operator
82
G4ParticleChangeForGamma
&
G4ParticleChangeForGamma::operator=
(
83
const
G4ParticleChangeForGamma
&
right
)
84
{
85
#ifdef G4VERBOSE
86
if
(
verboseLevel
>1)
87
G4cout
<<
"G4ParticleChangeForGamma:: assignment operator is called "
<<
G4endl
;
88
#endif
89
90
if
(
this
!= &right) {
91
if
(
theNumberOfSecondaries
>0) {
92
#ifdef G4VERBOSE
93
if
(
verboseLevel
>0) {
94
G4cout
<<
"G4ParticleChangeForGamma: assignment operator Warning "
;
95
G4cout
<<
"theListOfSecondaries is not empty "
;
96
}
97
#endif
98
for
(
G4int
index= 0; index<
theNumberOfSecondaries
; index++){
99
if
( (*
theListOfSecondaries
)[index] )
delete
(*theListOfSecondaries)[index] ;
100
}
101
}
102
delete
theListOfSecondaries
;
103
theListOfSecondaries
=
new
G4TrackFastVector
();
104
theNumberOfSecondaries
= right.
theNumberOfSecondaries
;
105
for
(
G4int
index = 0; index<
theNumberOfSecondaries
; index++){
106
G4Track
* newTrack =
new
G4Track
(*((*right.
theListOfSecondaries
)[index] ));
107
theListOfSecondaries
->
SetElement
(index, newTrack); }
108
109
theStatusChange
= right.
theStatusChange
;
110
theLocalEnergyDeposit
= right.
theLocalEnergyDeposit
;
111
theSteppingControlFlag
= right.
theSteppingControlFlag
;
112
theParentWeight
= right.
theParentWeight
;
113
114
currentTrack
= right.
currentTrack
;
115
proposedKinEnergy
= right.
proposedKinEnergy
;
116
proposedMomentumDirection
= right.
proposedMomentumDirection
;
117
proposedPolarization
= right.
proposedPolarization
;
118
}
119
return
*
this
;
120
}
121
122
void
G4ParticleChangeForGamma::AddSecondary
(
G4DynamicParticle
* aParticle)
123
{
124
// create track
125
G4Track
* aTrack =
new
G4Track
(aParticle,
currentTrack
->
GetGlobalTime
(),
126
currentTrack
->
GetPosition
());
127
128
// Touchable handle is copied to keep the pointer
129
aTrack->
SetTouchableHandle
(
currentTrack
->
GetTouchableHandle
());
130
131
// add a secondary
132
G4VParticleChange::AddSecondary
(aTrack);
133
}
134
135
//----------------------------------------------------------------
136
// method for updating G4Step
137
//
138
139
G4Step
*
G4ParticleChangeForGamma::UpdateStepForAtRest
(
G4Step
* pStep)
140
{
141
pStep->
AddTotalEnergyDeposit
(
theLocalEnergyDeposit
);
142
pStep->
SetStepLength
( 0.0 );
143
144
if
(
isParentWeightProposed
){
145
pStep->
GetPostStepPoint
()->
SetWeight
(
theParentWeight
);
146
}
147
148
return
pStep;
149
}
150
151
G4Step
*
G4ParticleChangeForGamma::UpdateStepForPostStep
(
G4Step
* pStep)
152
{
153
G4StepPoint
* pPostStepPoint = pStep->
GetPostStepPoint
();
154
G4Track
* pTrack = pStep->
GetTrack
();
155
156
pPostStepPoint->
SetKineticEnergy
(
proposedKinEnergy
);
157
pPostStepPoint->
SetMomentumDirection
(
proposedMomentumDirection
);
158
pPostStepPoint->
SetPolarization
(
proposedPolarization
);
159
160
// update velocity for scattering process and particles with mass
161
if
(
proposedKinEnergy
> 0.0) {
162
if
(pTrack->
GetParticleDefinition
()->
GetPDGMass
() > 0.0) {
163
pPostStepPoint->
SetVelocity
(pTrack->
CalculateVelocity
());
164
}
165
}
166
167
if
(
isParentWeightProposed
){
168
pPostStepPoint->
SetWeight
(
theParentWeight
);
169
}
170
171
pStep->
AddTotalEnergyDeposit
(
theLocalEnergyDeposit
);
172
pStep->
AddNonIonizingEnergyDeposit
(
theNonIonizingEnergyDeposit
);
173
return
pStep;
174
}
175
176
//----------------------------------------------------------------
177
// methods for printing messages
178
//
179
180
void
G4ParticleChangeForGamma::DumpInfo
()
const
181
{
182
// use base-class DumpInfo
183
G4VParticleChange::DumpInfo
();
184
185
G4int
oldprc =
G4cout
.precision(3);
186
G4cout
<<
" Kinetic Energy (MeV): "
187
<< std::setw(20) <<
proposedKinEnergy
/
MeV
188
<<
G4endl
;
189
G4cout
<<
" Momentum Direction: "
190
<< std::setw(20) <<
proposedMomentumDirection
191
<<
G4endl
;
192
G4cout
<<
" Polarization: "
193
<< std::setw(20) <<
proposedPolarization
194
<<
G4endl
;
195
G4cout
.precision(oldprc);
196
}
197
198
G4bool
G4ParticleChangeForGamma::CheckIt
(
const
G4Track
& aTrack)
199
{
200
G4bool
itsOK =
true
;
201
G4bool
exitWithError =
false
;
202
203
G4double
accuracy;
204
205
// Energy should not be lager than initial value
206
accuracy = (
proposedKinEnergy
- aTrack.
GetKineticEnergy
())/
MeV
;
207
if
(accuracy >
accuracyForWarning
) {
208
itsOK =
false
;
209
exitWithError = (accuracy >
accuracyForException
);
210
#ifdef G4VERBOSE
211
G4cout
<<
"G4ParticleChangeForGamma::CheckIt: "
;
212
G4cout
<<
"KinEnergy become larger than the initial value!"
213
<<
" Difference: "
<< accuracy <<
"[MeV] "
<<
G4endl
;
214
G4cout
<< aTrack.
GetDefinition
()->
GetParticleName
()
215
<<
" E="
<< aTrack.
GetKineticEnergy
()/
MeV
216
<<
" pos="
<< aTrack.
GetPosition
().
x
()/
m
217
<<
", "
<< aTrack.
GetPosition
().
y
()/
m
218
<<
", "
<< aTrack.
GetPosition
().
z
()/
m
219
<<
G4endl
;
220
#endif
221
}
222
223
// dump out information of this particle change
224
#ifdef G4VERBOSE
225
if
(!itsOK)
DumpInfo
();
226
#endif
227
228
// Exit with error
229
if
(exitWithError) {
230
G4Exception
(
"G4ParticleChangeForGamma::CheckIt"
,
231
"TRACK004"
,
EventMustBeAborted
,
232
"energy was illegal"
);
233
}
234
235
//correction
236
if
(!itsOK) {
237
proposedKinEnergy
= aTrack.
GetKineticEnergy
();
238
}
239
240
itsOK = (itsOK) &&
G4VParticleChange::CheckIt
(aTrack);
241
return
itsOK;
242
}
geant4
tree
geant4-10.6-release
source
track
src
G4ParticleChangeForGamma.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:53
using
1.8.2 with
ECCE GitHub integration