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.17 2009/05/26 13:19:41 vnivanch Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
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 | |
---|
51 | G4ParticleChangeForLoss::G4ParticleChangeForLoss() |
---|
52 | :G4VParticleChange(), lowEnergyLimit(1.0*eV) |
---|
53 | { |
---|
54 | theSteppingControlFlag = NormalCondition; |
---|
55 | debugFlag = false; |
---|
56 | #ifdef G4VERBOSE |
---|
57 | if (verboseLevel>2) { |
---|
58 | G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl; |
---|
59 | } |
---|
60 | #endif |
---|
61 | } |
---|
62 | |
---|
63 | G4ParticleChangeForLoss::~G4ParticleChangeForLoss() |
---|
64 | { |
---|
65 | #ifdef G4VERBOSE |
---|
66 | if (verboseLevel>2) { |
---|
67 | G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl; |
---|
68 | } |
---|
69 | #endif |
---|
70 | } |
---|
71 | |
---|
72 | G4ParticleChangeForLoss::G4ParticleChangeForLoss( |
---|
73 | const G4ParticleChangeForLoss &right): G4VParticleChange(right) |
---|
74 | { |
---|
75 | if (verboseLevel>1) { |
---|
76 | G4cout << "G4ParticleChangeForLoss:: copy constructor is called " << G4endl; |
---|
77 | } |
---|
78 | currentTrack = right.currentTrack; |
---|
79 | proposedKinEnergy = right.proposedKinEnergy; |
---|
80 | currentCharge = right.currentCharge; |
---|
81 | proposedMomentumDirection = right.proposedMomentumDirection; |
---|
82 | } |
---|
83 | |
---|
84 | // assignment operator |
---|
85 | G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=( |
---|
86 | const G4ParticleChangeForLoss &right) |
---|
87 | { |
---|
88 | if (verboseLevel>1) { |
---|
89 | G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl; |
---|
90 | } |
---|
91 | if (this != &right) { |
---|
92 | theListOfSecondaries = right.theListOfSecondaries; |
---|
93 | theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; |
---|
94 | theNumberOfSecondaries = right.theNumberOfSecondaries; |
---|
95 | theStatusChange = right.theStatusChange; |
---|
96 | theLocalEnergyDeposit = right.theLocalEnergyDeposit; |
---|
97 | theSteppingControlFlag = right.theSteppingControlFlag; |
---|
98 | theParentWeight = right.theParentWeight; |
---|
99 | |
---|
100 | currentTrack = right.currentTrack; |
---|
101 | proposedKinEnergy = right.proposedKinEnergy; |
---|
102 | currentCharge = right.currentCharge; |
---|
103 | proposedMomentumDirection = right.proposedMomentumDirection; |
---|
104 | } |
---|
105 | return *this; |
---|
106 | } |
---|
107 | |
---|
108 | //---------------------------------------------------------------- |
---|
109 | // methods for printing messages |
---|
110 | // |
---|
111 | |
---|
112 | void G4ParticleChangeForLoss::DumpInfo() const |
---|
113 | { |
---|
114 | // use base-class DumpInfo |
---|
115 | G4VParticleChange::DumpInfo(); |
---|
116 | |
---|
117 | G4cout.precision(3); |
---|
118 | G4cout << " Charge (eplus) : " |
---|
119 | << std::setw(20) << currentCharge/eplus |
---|
120 | << G4endl; |
---|
121 | G4cout << " Kinetic Energy (MeV): " |
---|
122 | << std::setw(20) << proposedKinEnergy/MeV |
---|
123 | << G4endl; |
---|
124 | G4cout << " Momentum Direct - x : " |
---|
125 | << std::setw(20) << proposedMomentumDirection.x() |
---|
126 | << G4endl; |
---|
127 | G4cout << " Momentum Direct - y : " |
---|
128 | << std::setw(20) << proposedMomentumDirection.y() |
---|
129 | << G4endl; |
---|
130 | G4cout << " Momentum Direct - z : " |
---|
131 | << std::setw(20) << proposedMomentumDirection.z() |
---|
132 | << G4endl; |
---|
133 | } |
---|
134 | |
---|
135 | G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack) |
---|
136 | { |
---|
137 | G4bool itsOK = true; |
---|
138 | G4bool exitWithError = false; |
---|
139 | |
---|
140 | G4double accuracy; |
---|
141 | |
---|
142 | // Energy should not be lager than initial value |
---|
143 | accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV; |
---|
144 | if (accuracy > accuracyForWarning) { |
---|
145 | #ifdef G4VERBOSE |
---|
146 | G4cout << "G4ParticleChangeForLoss::CheckIt: "; |
---|
147 | G4cout << "KinEnergy become larger than the initial value!" << G4endl; |
---|
148 | G4cout << " Difference: " << accuracy << "[MeV] " <<G4endl; |
---|
149 | #endif |
---|
150 | itsOK = false; |
---|
151 | if (accuracy > accuracyForException) exitWithError = true; |
---|
152 | } |
---|
153 | |
---|
154 | // dump out information of this particle change |
---|
155 | #ifdef G4VERBOSE |
---|
156 | if (!itsOK) { |
---|
157 | G4cout << "G4ParticleChangeForLoss::CheckIt " << G4endl; |
---|
158 | DumpInfo(); |
---|
159 | } |
---|
160 | #endif |
---|
161 | |
---|
162 | // Exit with error |
---|
163 | if (exitWithError) { |
---|
164 | G4Exception("G4ParticleChangeForLoss::CheckIt", |
---|
165 | "400", |
---|
166 | EventMustBeAborted, |
---|
167 | "energy was illegal"); |
---|
168 | } |
---|
169 | |
---|
170 | //correction |
---|
171 | if (!itsOK) { |
---|
172 | proposedKinEnergy = aTrack.GetKineticEnergy(); |
---|
173 | } |
---|
174 | |
---|
175 | itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); |
---|
176 | return itsOK; |
---|
177 | } |
---|