Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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//
27// $Id$
28//
29//
30// --------------------------------------------------------------
31// GEANT 4 class implementation file
32//
33// ------------------------------------------------------------
34// 15 April 2005 V.Ivanchenko for gamma EM processes
35// --------------------------------------------------------------
36//
37// Modified::
38// 28.08.06 V.Ivanchenko Add access to current track and polarizaion
39//
40// ------------------------------------------------------------
41//
43#include "G4SystemOfUnits.hh"
44#include "G4Track.hh"
45#include "G4Step.hh"
46#include "G4DynamicParticle.hh"
48
50 : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.)
51{
53 debugFlag = false;
54#ifdef G4VERBOSE
55 if (verboseLevel>2) {
56 G4cout << "G4ParticleChangeForGamma::G4ParticleChangeForGamma() " << G4endl;
57 }
58#endif
59}
60
62{
63#ifdef G4VERBOSE
64 if (verboseLevel>2) {
65 G4cout << "G4ParticleChangeForGamma::~G4ParticleChangeForGamma() " << G4endl;
66 }
67#endif
68}
69
72{
73 if (verboseLevel>1)
74 G4cout << "G4ParticleChangeForGamma:: copy constructor is called " << G4endl;
75
76 currentTrack = right.currentTrack;
77 proposedKinEnergy = right.proposedKinEnergy;
78 proposedMomentumDirection = right.proposedMomentumDirection;
79 proposedPolarization = right.proposedPolarization;
80}
81
82// assignment operator
84 const G4ParticleChangeForGamma &right)
85{
86#ifdef G4VERBOSE
87 if (verboseLevel>1)
88 G4cout << "G4ParticleChangeForGamma:: assignment operator is called " << G4endl;
89#endif
90
91 if (this != &right) {
93#ifdef G4VERBOSE
94 if (verboseLevel>0) {
95 G4cout << "G4ParticleChangeForGamma: assignment operator Warning ";
96 G4cout << "theListOfSecondaries is not empty ";
97 }
98#endif
99 for (G4int index= 0; index<theNumberOfSecondaries; index++){
100 if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
101 }
102 }
103 delete theListOfSecondaries;
106 for (G4int index = 0; index<theNumberOfSecondaries; index++){
107 G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
108 theListOfSecondaries->SetElement(index, newTrack); }
109
114
115 currentTrack = right.currentTrack;
116 proposedKinEnergy = right.proposedKinEnergy;
117 proposedMomentumDirection = right.proposedMomentumDirection;
118 proposedPolarization = right.proposedPolarization;
119 }
120 return *this;
121}
122
123//----------------------------------------------------------------
124// method for updating G4Step
125//
126
128{
130 pStep->SetStepLength( 0.0 );
131
134 }
135
136 return pStep;
137}
138
140{
141 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
142 pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
143 pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
144 pPostStepPoint->SetPolarization( proposedPolarization );
145
147 pPostStepPoint->SetWeight( theParentWeight );
148 }
149
152 return pStep;
153}
154
156{
157 // create track
158 G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(),
159 currentTrack->GetPosition());
160
161 // Touchable handle is copied to keep the pointer
162 aTrack->SetTouchableHandle(currentTrack->GetTouchableHandle());
163
164 // add a secondary
166}
167
168//----------------------------------------------------------------
169// methods for printing messages
170//
171
173{
174// use base-class DumpInfo
176
177 G4int oldprc = G4cout.precision(3);
178 G4cout << " Kinetic Energy (MeV): "
179 << std::setw(20) << proposedKinEnergy/MeV
180 << G4endl;
181 G4cout << " Momentum Direction: "
182 << std::setw(20) << proposedMomentumDirection
183 << G4endl;
184 G4cout << " Polarization: "
185 << std::setw(20) << proposedPolarization
186 << G4endl;
187 G4cout.precision(oldprc);
188}
189
191{
192 G4bool itsOK = true;
193 G4bool exitWithError = false;
194
195 G4double accuracy;
196
197 // Energy should not be lager than initial value
198 accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
199 if (accuracy > accuracyForWarning) {
200 itsOK = false;
201 exitWithError = (accuracy > accuracyForException);
202#ifdef G4VERBOSE
203 G4cout << "G4ParticleChangeForGamma::CheckIt: ";
204 G4cout << "KinEnergy become larger than the initial value!"
205 << " Difference: " << accuracy << "[MeV] " <<G4endl;
207 << " E=" << aTrack.GetKineticEnergy()/MeV
208 << " pos=" << aTrack.GetPosition().x()/m
209 << ", " << aTrack.GetPosition().y()/m
210 << ", " << aTrack.GetPosition().z()/m
211 << G4endl;
212#endif
213 }
214
215 // dump out information of this particle change
216#ifdef G4VERBOSE
217 if (!itsOK) DumpInfo();
218#endif
219
220 // Exit with error
221 if (exitWithError) {
222 G4Exception("G4ParticleChangeForGamma::CheckIt",
223 "TRACK004",EventMustBeAborted,
224 "energy was illegal");
225 }
226
227 //correction
228 if (!itsOK) {
229 proposedKinEnergy = aTrack.GetKineticEnergy();
230 }
231
232 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
233 return itsOK;
234}
@ EventMustBeAborted
@ NormalCondition
G4FastVector< G4Track, G4TrackFastVectorSize > G4TrackFastVector
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
double z() const
double x() const
double y() const
void SetElement(G4int anIndex, Type *anElement)
Definition: G4FastVector.hh:76
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 SetMomentumDirection(const G4ThreeVector &aValue)
void SetPolarization(const G4ThreeVector &aValue)
Definition: G4Step.hh:78
void SetStepLength(G4double value)
void AddNonIonizingEnergyDeposit(G4double value)
void AddTotalEnergyDeposit(G4double value)
G4StepPoint * GetPostStepPoint() const
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4double GetGlobalTime() const
G4ParticleDefinition * GetDefinition() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetKineticEnergy() 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
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41