Geant4-11
G4ParticleChangeForGamma.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// G4ParticleChangeForGamma class implementation
27//
28// Author: Hisaya Kurashige, 23 March 1998
29// Revision: Vladimir Ivantchenko, 15 April 2005
30// --------------------------------------------------------------------
31
33#include "G4SystemOfUnits.hh"
34#include "G4Track.hh"
35#include "G4Step.hh"
36#include "G4DynamicParticle.hh"
38
39// --------------------------------------------------------------------
42{
44 // Disable flag that is enabled in G4VParticleChange if G4VERBOSE.
45 debugFlag = false;
46}
47
48// --------------------------------------------------------------------
50{
51}
52
53// --------------------------------------------------------------------
56 : G4VParticleChange(right)
57{
62}
63
64// --------------------------------------------------------------------
67{
68 if(this != &right)
69 {
71 {
72 for(G4int index = 0; index < theNumberOfSecondaries; ++index)
73 {
74 if((*theListOfSecondaries)[index])
75 delete(*theListOfSecondaries)[index];
76 }
77 }
81 for(G4int index = 0; index < theNumberOfSecondaries; ++index)
82 {
83 G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
84 theListOfSecondaries->SetElement(index, newTrack);
85 }
86
91
96 }
97 return *this;
98}
99
100// --------------------------------------------------------------------
102{
103 // create track
104 G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(),
106
107 // touchable handle is copied to keep the pointer
109
110 // add a secondary
112}
113
114// --------------------------------------------------------------------
116{
118 pStep->SetStepLength(0.0);
119
121 {
123 }
124
125 return pStep;
126}
127
128// --------------------------------------------------------------------
130{
131 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
132 G4Track* pTrack = pStep->GetTrack();
133
134 pPostStepPoint->SetKineticEnergy(proposedKinEnergy);
136 pPostStepPoint->SetPolarization(proposedPolarization);
137
138 // update velocity for scattering process and particles with mass
139 if(proposedKinEnergy > 0.0)
140 {
141 if(pTrack->GetParticleDefinition()->GetPDGMass() > 0.0)
142 {
143 pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
144 }
145 }
146
148 {
149 pPostStepPoint->SetWeight(theParentWeight);
150 }
151
154 return pStep;
155}
156
157// --------------------------------------------------------------------
159{
160 // use base-class DumpInfo
162
163 G4int oldprc = G4cout.precision(3);
164 G4cout << " Kinetic Energy (MeV): " << std::setw(20)
166 G4cout << " Momentum Direction: " << std::setw(20)
168 G4cout << " Polarization: " << std::setw(20) << proposedPolarization
169 << G4endl;
170 G4cout.precision(oldprc);
171}
172
173// --------------------------------------------------------------------
175{
176 G4bool itsOK = true;
177 G4bool exitWithError = false;
178
179 G4double accuracy;
180
181 // Energy should not be lager than initial value
182 accuracy = (proposedKinEnergy - aTrack.GetKineticEnergy()) / MeV;
183 if(accuracy > accuracyForWarning)
184 {
185 itsOK = false;
186 exitWithError = (accuracy > accuracyForException);
187#ifdef G4VERBOSE
188 G4cout << "G4ParticleChangeForGamma::CheckIt: ";
189 G4cout << "KinEnergy become larger than the initial value!"
190 << " Difference: " << accuracy << "[MeV] " << G4endl;
192 << " E=" << aTrack.GetKineticEnergy() / MeV
193 << " pos=" << aTrack.GetPosition().x() / m << ", "
194 << aTrack.GetPosition().y() / m << ", "
195 << aTrack.GetPosition().z() / m << G4endl;
196#endif
197 }
198
199 // dump out information of this particle change
200#ifdef G4VERBOSE
201 if(!itsOK) { DumpInfo(); }
202#endif
203
204 // Exit with error
205 if(exitWithError)
206 {
207 G4Exception("G4ParticleChangeForGamma::CheckIt()", "TRACK004",
208 EventMustBeAborted, "energy was illegal");
209 }
210
211 // correction
212 if(!itsOK)
213 {
215 }
216
217 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
218 return itsOK;
219}
@ EventMustBeAborted
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static constexpr double m
Definition: G4SIunits.hh:109
static constexpr double MeV
Definition: G4SIunits.hh:200
@ NormalCondition
G4FastVector< G4Track, G4TrackFastVectorSize > G4TrackFastVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
double z() const
double x() const
double y() const
void SetElement(G4int anIndex, Type *anElement)
Definition: G4FastVector.hh:72
G4Step * UpdateStepForAtRest(G4Step *pStep)
G4ParticleChangeForGamma & operator=(const G4ParticleChangeForGamma &right)
virtual G4bool CheckIt(const G4Track &)
void AddSecondary(G4DynamicParticle *aParticle)
G4Step * UpdateStepForPostStep(G4Step *Step)
const G4String & GetParticleName() const
void SetKineticEnergy(const G4double aValue)
void SetWeight(G4double aValue)
void SetVelocity(G4double v)
void SetMomentumDirection(const G4ThreeVector &aValue)
void SetPolarization(const G4ThreeVector &aValue)
Definition: G4Step.hh:62
G4Track * GetTrack() const
void SetStepLength(G4double value)
void AddNonIonizingEnergyDeposit(G4double value)
void AddTotalEnergyDeposit(G4double value)
G4StepPoint * GetPostStepPoint() const
const G4ParticleDefinition * GetParticleDefinition() const
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4double GetGlobalTime() const
G4ParticleDefinition * GetDefinition() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetKineticEnergy() const
G4double CalculateVelocity() const
virtual G4bool CheckIt(const G4Track &)
static const G4double accuracyForException
G4TrackStatus theStatusChange
G4TrackFastVector * theListOfSecondaries
G4SteppingControl theSteppingControlFlag
static const G4double accuracyForWarning
G4double theNonIonizingEnergyDeposit
void AddSecondary(G4Track *aSecondary)
virtual void DumpInfo() const