Geant4-11
G4ParticleChangeForMSC.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// G4ParticleChangeForMSC class implementation
27//
28// Author: Hisaya Kurashige, 23 March 1998
29// Revision: Vladimir Ivantchenko, 16 January 2004
30// --------------------------------------------------------------------
31
33#include "G4SystemOfUnits.hh"
34#include "G4Track.hh"
35#include "G4Step.hh"
36#include "G4DynamicParticle.hh"
38
39// --------------------------------------------------------------------
42{
43 // Disable flag that is enabled in G4VParticleChange if G4VERBOSE.
44 debugFlag = false;
45}
46
47// --------------------------------------------------------------------
49{
50}
51
52// --------------------------------------------------------------------
55 : G4VParticleChange(right)
56{
59}
60
61// --------------------------------------------------------------------
64{
65 if(this != &right)
66 {
74
77 }
78 return *this;
79}
80
81// --------------------------------------------------------------------
83{
84 // update the G4Step specific attributes
87
88 // multiple scattering calculates the final state of the particle
89 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
90
91 // update momentum direction
93
94 // update position
95 pPostStepPoint->SetPosition(thePosition);
96 return pStep;
97}
98
99// --------------------------------------------------------------------
101{
102 // multiple scattering calculates the final state of the particle
103 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
104
105 // update momentum direction
107
108 // update position
109 pPostStepPoint->SetPosition(thePosition);
110
111 // update the G4Step specific attributes
112 return pStep;
113}
114
115// --------------------------------------------------------------------
117{
118 // use base-class DumpInfo
120
121 G4int oldprc = G4cout.precision(3);
122 G4cout << " Position - x (mm) : " << std::setw(20)
123 << thePosition.x() / mm << G4endl;
124 G4cout << " Position - y (mm) : " << std::setw(20)
125 << thePosition.y() / mm << G4endl;
126 G4cout << " Position - z (mm) : " << std::setw(20)
127 << thePosition.z() / mm << G4endl;
128 G4cout << " Momentum Direct - x : " << std::setw(20)
130 G4cout << " Momentum Direct - y : " << std::setw(20)
132 G4cout << " Momentum Direct - z : " << std::setw(20)
134 G4cout.precision(oldprc);
135}
136
137// --------------------------------------------------------------------
139{
140 G4bool itsOK = true;
141 G4bool exitWithError = false;
142
143 G4double accuracy;
144
145 // check
146
147 // MomentumDirection should be unit vector
148 accuracy = std::fabs(theMomentumDirection.mag2() - 1.0);
149 if(accuracy > accuracyForWarning)
150 {
151 itsOK = false;
152 exitWithError = (accuracy > accuracyForException);
153#ifdef G4VERBOSE
154 G4cout << " G4ParticleChangeForMSC::CheckIt : ";
155 G4cout << "the Momentum Change is not unit vector !!"
156 << " Difference: " << accuracy << G4endl;
158 << " E=" << aTrack.GetKineticEnergy() / MeV
159 << " pos=" << aTrack.GetPosition().x() / m << ", "
160 << aTrack.GetPosition().y() / m << ", "
161 << aTrack.GetPosition().z() / m << G4endl;
162#endif
163 }
164
165 // dump out information of this particle change
166#ifdef G4VERBOSE
167 if(!itsOK) { DumpInfo(); }
168#endif
169
170 // exit with error
171 if(exitWithError)
172 {
173 G4Exception("G4ParticleChangeForMSC::CheckIt()", "300", EventMustBeAborted,
174 "momentum direction was illegal");
175 }
176 // correction
177 if(!itsOK)
178 {
181 }
182
183 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
184 return itsOK;
185}
@ 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 mm
Definition: G4SIunits.hh:95
static constexpr double MeV
Definition: G4SIunits.hh:200
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 mag2() const
double y() const
double mag() const
virtual G4Step * UpdateStepForPostStep(G4Step *Step)
virtual G4Step * UpdateStepForAlongStep(G4Step *Step)
G4ParticleChangeForMSC & operator=(const G4ParticleChangeForMSC &right)
virtual void DumpInfo() const
virtual G4bool CheckIt(const G4Track &)
const G4String & GetParticleName() const
void SetPosition(const G4ThreeVector &aValue)
void SetMomentumDirection(const G4ThreeVector &aValue)
Definition: G4Step.hh:62
G4Track * GetTrack() const
void SetStepLength(G4double value)
G4StepPoint * GetPostStepPoint() const
G4TrackStatus GetTrackStatus() const
const G4ThreeVector & GetPosition() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
virtual G4bool CheckIt(const G4Track &)
static const G4double accuracyForException
G4TrackStatus theStatusChange
G4TrackFastVector * theListOfSecondaries
G4SteppingControl theSteppingControlFlag
static const G4double accuracyForWarning
virtual void DumpInfo() const