source: trunk/source/track/src/G4ParticleChangeForLoss.cc@ 1108

Last change on this file since 1108 was 1058, checked in by garnier, 17 years ago

file release beta

File size: 6.1 KB
RevLine 
[826]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: G4ParticleChangeForLoss.cc,v 1.16 2006/08/28 16:10:29 vnivanch Exp $
[1058]28// GEANT4 tag $Name: geant4-09-02-ref-02 $
[826]29//
30//
31// --------------------------------------------------------------
32// GEANT 4 class implementation file
33//
34// ------------------------------------------------------------
35// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
36// --------------------------------------------------------------
37//
38// Modified:
39// 16.01.04 V.Ivanchenko update for model variant of energy loss
40// 15.04.05 V.Ivanchenko inline update methods
41// 28.08.06 V.Ivanchenko Add access to current track and polarizaion
42//
43// ------------------------------------------------------------
44//
45#include "G4ParticleChangeForLoss.hh"
46#include "G4Track.hh"
47#include "G4Step.hh"
48#include "G4DynamicParticle.hh"
49#include "G4ExceptionSeverity.hh"
50
51G4ParticleChangeForLoss::G4ParticleChangeForLoss():G4VParticleChange()
52{
53 theSteppingControlFlag = NormalCondition;
54 debugFlag = false;
55#ifdef G4VERBOSE
56 if (verboseLevel>2) {
57 G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl;
58 }
59#endif
60}
61
62G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
63{
64#ifdef G4VERBOSE
65 if (verboseLevel>2) {
66 G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl;
67 }
68#endif
69}
70
71G4ParticleChangeForLoss::G4ParticleChangeForLoss(
72 const G4ParticleChangeForLoss &right): G4VParticleChange(right)
73{
74 if (verboseLevel>1) {
75 G4cout << "G4ParticleChangeForLoss:: copy constructor is called " << G4endl;
76 }
77 currentTrack = right.currentTrack;
78 proposedKinEnergy = right.proposedKinEnergy;
79 currentCharge = right.currentCharge;
80 proposedMomentumDirection = right.proposedMomentumDirection;
81}
82
83// assignment operator
84G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=(
85 const G4ParticleChangeForLoss &right)
86{
87 if (verboseLevel>1) {
88 G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl;
89 }
90 if (this != &right) {
91 theListOfSecondaries = right.theListOfSecondaries;
92 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
93 theNumberOfSecondaries = right.theNumberOfSecondaries;
94 theStatusChange = right.theStatusChange;
95 theLocalEnergyDeposit = right.theLocalEnergyDeposit;
96 theSteppingControlFlag = right.theSteppingControlFlag;
97 theParentWeight = right.theParentWeight;
98
99 currentTrack = right.currentTrack;
100 proposedKinEnergy = right.proposedKinEnergy;
101 currentCharge = right.currentCharge;
102 proposedMomentumDirection = right.proposedMomentumDirection;
103 }
104 return *this;
105}
106
107//----------------------------------------------------------------
108// methods for printing messages
109//
110
111void G4ParticleChangeForLoss::DumpInfo() const
112{
113// use base-class DumpInfo
114 G4VParticleChange::DumpInfo();
115
116 G4cout.precision(3);
117 G4cout << " Charge (eplus) : "
118 << std::setw(20) << currentCharge/eplus
119 << G4endl;
120 G4cout << " Kinetic Energy (MeV): "
121 << std::setw(20) << proposedKinEnergy/MeV
122 << G4endl;
123 G4cout << " Momentum Direct - x : "
124 << std::setw(20) << proposedMomentumDirection.x()
125 << G4endl;
126 G4cout << " Momentum Direct - y : "
127 << std::setw(20) << proposedMomentumDirection.y()
128 << G4endl;
129 G4cout << " Momentum Direct - z : "
130 << std::setw(20) << proposedMomentumDirection.z()
131 << G4endl;
132}
133
134G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
135{
136 G4bool itsOK = true;
137 G4bool exitWithError = false;
138
139 G4double accuracy;
140
141 // Energy should not be lager than initial value
142 accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
143 if (accuracy > accuracyForWarning) {
144#ifdef G4VERBOSE
145 G4cout << "G4ParticleChangeForLoss::CheckIt: ";
146 G4cout << "KinEnergy become larger than the initial value!" << G4endl;
147 G4cout << " Difference: " << accuracy << "[MeV] " <<G4endl;
148#endif
149 itsOK = false;
150 if (accuracy > accuracyForException) exitWithError = true;
151 }
152
153 // dump out information of this particle change
154#ifdef G4VERBOSE
155 if (!itsOK) {
156 G4cout << "G4ParticleChangeForLoss::CheckIt " << G4endl;
157 DumpInfo();
158 }
159#endif
160
161 // Exit with error
162 if (exitWithError) {
163 G4Exception("G4ParticleChangeForLoss::CheckIt",
164 "400",
165 EventMustBeAborted,
166 "energy was illegal");
167 }
168
169 //correction
170 if (!itsOK) {
171 proposedKinEnergy = aTrack.GetKineticEnergy();
172 }
173
174 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
175 return itsOK;
176}
Note: See TracBrowser for help on using the repository browser.