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.hh,v 1.20 2008/01/11 19:57:12 vnivanch Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // ------------------------------------------------------------ |
---|
32 | // GEANT 4 class header file |
---|
33 | // |
---|
34 | // |
---|
35 | // ------------------------------------------------------------ |
---|
36 | // Implemented for the new scheme 23 Mar. 1998 H.Kurahige |
---|
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 | // 30.01.06 V.Ivanchenko add ProposedMomentumDirection for AlongStep |
---|
42 | // and ProposeWeight for PostStep |
---|
43 | // 07.06.06 V.Ivanchenko RemoveProposedMomentumDirection from AlongStep |
---|
44 | // 28.08.06 V.Ivanchenko Add access to current track and polarizaion |
---|
45 | // |
---|
46 | // ------------------------------------------------------------ |
---|
47 | // |
---|
48 | // Class Description |
---|
49 | // This class is a concrete class for ParticleChange for EnergyLoss |
---|
50 | // |
---|
51 | #ifndef G4ParticleChangeForLoss_h |
---|
52 | #define G4ParticleChangeForLoss_h 1 |
---|
53 | |
---|
54 | #include "globals.hh" |
---|
55 | #include "G4ios.hh" |
---|
56 | #include "G4VParticleChange.hh" |
---|
57 | |
---|
58 | class G4DynamicParticle; |
---|
59 | |
---|
60 | class G4ParticleChangeForLoss: public G4VParticleChange |
---|
61 | { |
---|
62 | public: |
---|
63 | // default constructor |
---|
64 | G4ParticleChangeForLoss(); |
---|
65 | |
---|
66 | // destructor |
---|
67 | virtual ~G4ParticleChangeForLoss(); |
---|
68 | |
---|
69 | // with description |
---|
70 | // ---------------------------------------------------- |
---|
71 | // --- the following methods are for updating G4Step ----- |
---|
72 | |
---|
73 | G4Step* UpdateStepForAlongStep(G4Step* Step); |
---|
74 | G4Step* UpdateStepForPostStep(G4Step* Step); |
---|
75 | // A physics process gives the final state of the particle |
---|
76 | // based on information of G4Track |
---|
77 | |
---|
78 | void InitializeForAlongStep(const G4Track&); |
---|
79 | void InitializeForPostStep(const G4Track&); |
---|
80 | //Initialize all propoerties by using G4Track information |
---|
81 | |
---|
82 | void AddSecondary(G4DynamicParticle* aParticle); |
---|
83 | // Add next secondary |
---|
84 | |
---|
85 | G4double GetProposedCharge() const; |
---|
86 | void SetProposedCharge(G4double theCharge); |
---|
87 | // Get/Set theCharge |
---|
88 | |
---|
89 | G4double GetCharge() const; |
---|
90 | void ProposeCharge(G4double finalCharge); |
---|
91 | // Get/Propose the final dynamical Charge in G4DynamicParticle |
---|
92 | |
---|
93 | G4double GetProposedKineticEnergy() const; |
---|
94 | void SetProposedKineticEnergy(G4double proposedKinEnergy); |
---|
95 | // Get/Set the final kinetic energy of the current particle. |
---|
96 | |
---|
97 | const G4ThreeVector& GetProposedMomentumDirection() const; |
---|
98 | void SetProposedMomentumDirection(const G4ThreeVector& dir); |
---|
99 | const G4ThreeVector& GetMomentumDirection() const; |
---|
100 | void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz); |
---|
101 | void ProposeMomentumDirection(const G4ThreeVector& Pfinal); |
---|
102 | // Get/Propose the MomentumDirection vector: it is the final momentum direction. |
---|
103 | |
---|
104 | const G4ThreeVector& GetProposedPolarization() const; |
---|
105 | void ProposePolarization(const G4ThreeVector& dir); |
---|
106 | void ProposePolarization(G4double Px, G4double Py, G4double Pz); |
---|
107 | |
---|
108 | const G4Track* GetCurrentTrack() const; |
---|
109 | |
---|
110 | virtual void DumpInfo() const; |
---|
111 | |
---|
112 | // for Debug |
---|
113 | virtual G4bool CheckIt(const G4Track&); |
---|
114 | |
---|
115 | protected: |
---|
116 | // hide copy constructor and assignment operaor as protected |
---|
117 | G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right); |
---|
118 | G4ParticleChangeForLoss & operator=(const G4ParticleChangeForLoss &right); |
---|
119 | |
---|
120 | private: |
---|
121 | |
---|
122 | const G4Track* currentTrack; |
---|
123 | // The pointer to G4Track |
---|
124 | |
---|
125 | G4double proposedKinEnergy; |
---|
126 | // The final kinetic energy of the current particle. |
---|
127 | |
---|
128 | G4double currentCharge; |
---|
129 | // The final charge of the current particle. |
---|
130 | |
---|
131 | G4ThreeVector proposedMomentumDirection; |
---|
132 | // The final momentum direction of the current particle. |
---|
133 | |
---|
134 | G4ThreeVector proposedPolarization; |
---|
135 | // The final polarization of the current particle. |
---|
136 | }; |
---|
137 | |
---|
138 | // ------------------------------------------------------------ |
---|
139 | |
---|
140 | inline G4double G4ParticleChangeForLoss::GetProposedKineticEnergy() const |
---|
141 | { |
---|
142 | return proposedKinEnergy; |
---|
143 | } |
---|
144 | |
---|
145 | inline void G4ParticleChangeForLoss::SetProposedKineticEnergy(G4double energy) |
---|
146 | { |
---|
147 | proposedKinEnergy = energy; |
---|
148 | } |
---|
149 | |
---|
150 | inline G4double G4ParticleChangeForLoss::GetProposedCharge() const |
---|
151 | { |
---|
152 | return currentCharge; |
---|
153 | } |
---|
154 | |
---|
155 | inline G4double G4ParticleChangeForLoss::GetCharge() const |
---|
156 | { |
---|
157 | return currentCharge; |
---|
158 | } |
---|
159 | |
---|
160 | inline void G4ParticleChangeForLoss::SetProposedCharge(G4double theCharge) |
---|
161 | { |
---|
162 | currentCharge = theCharge; |
---|
163 | } |
---|
164 | |
---|
165 | inline void G4ParticleChangeForLoss::ProposeCharge(G4double theCharge) |
---|
166 | { |
---|
167 | currentCharge = theCharge; |
---|
168 | } |
---|
169 | |
---|
170 | inline |
---|
171 | const G4ThreeVector& G4ParticleChangeForLoss::GetProposedMomentumDirection() const |
---|
172 | { |
---|
173 | return proposedMomentumDirection; |
---|
174 | } |
---|
175 | |
---|
176 | inline |
---|
177 | const G4ThreeVector& G4ParticleChangeForLoss::GetMomentumDirection() const |
---|
178 | { |
---|
179 | return proposedMomentumDirection; |
---|
180 | } |
---|
181 | |
---|
182 | inline |
---|
183 | void G4ParticleChangeForLoss::ProposeMomentumDirection(const G4ThreeVector& dir) |
---|
184 | { |
---|
185 | proposedMomentumDirection = dir; |
---|
186 | } |
---|
187 | |
---|
188 | inline |
---|
189 | void G4ParticleChangeForLoss::SetProposedMomentumDirection(const G4ThreeVector& dir) |
---|
190 | { |
---|
191 | proposedMomentumDirection = dir; |
---|
192 | } |
---|
193 | |
---|
194 | inline |
---|
195 | void G4ParticleChangeForLoss::ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz) |
---|
196 | { |
---|
197 | proposedMomentumDirection.setX(Px); |
---|
198 | proposedMomentumDirection.setY(Py); |
---|
199 | proposedMomentumDirection.setZ(Pz); |
---|
200 | } |
---|
201 | |
---|
202 | inline const G4Track* G4ParticleChangeForLoss::GetCurrentTrack() const |
---|
203 | { |
---|
204 | return currentTrack; |
---|
205 | } |
---|
206 | |
---|
207 | inline |
---|
208 | const G4ThreeVector& G4ParticleChangeForLoss::GetProposedPolarization() const |
---|
209 | { |
---|
210 | return proposedPolarization; |
---|
211 | } |
---|
212 | |
---|
213 | inline |
---|
214 | void G4ParticleChangeForLoss::ProposePolarization(const G4ThreeVector& dir) |
---|
215 | { |
---|
216 | proposedPolarization = dir; |
---|
217 | } |
---|
218 | |
---|
219 | inline |
---|
220 | void G4ParticleChangeForLoss::ProposePolarization(G4double Px, G4double Py, G4double Pz) |
---|
221 | { |
---|
222 | proposedPolarization.setX(Px); |
---|
223 | proposedPolarization.setY(Py); |
---|
224 | proposedPolarization.setZ(Pz); |
---|
225 | } |
---|
226 | |
---|
227 | inline void G4ParticleChangeForLoss::InitializeForAlongStep(const G4Track& track) |
---|
228 | { |
---|
229 | theStatusChange = track.GetTrackStatus(); |
---|
230 | theLocalEnergyDeposit = 0.0; |
---|
231 | theNonIonizingEnergyDeposit = 0.0; |
---|
232 | InitializeSecondaries(track); |
---|
233 | theParentWeight = track.GetWeight(); |
---|
234 | proposedKinEnergy = track.GetKineticEnergy(); |
---|
235 | currentCharge = track.GetDynamicParticle()->GetCharge(); |
---|
236 | } |
---|
237 | |
---|
238 | inline void G4ParticleChangeForLoss::InitializeForPostStep(const G4Track& track) |
---|
239 | { |
---|
240 | theStatusChange = track.GetTrackStatus(); |
---|
241 | theLocalEnergyDeposit = 0.0; |
---|
242 | theNonIonizingEnergyDeposit = 0.0; |
---|
243 | InitializeSecondaries(track); |
---|
244 | theParentWeight = track.GetWeight(); |
---|
245 | proposedKinEnergy = track.GetKineticEnergy(); |
---|
246 | currentCharge = track.GetDynamicParticle()->GetCharge(); |
---|
247 | proposedMomentumDirection = track.GetMomentumDirection(); |
---|
248 | proposedPolarization = track.GetPolarization(); |
---|
249 | currentTrack = &track; |
---|
250 | } |
---|
251 | |
---|
252 | //---------------------------------------------------------------- |
---|
253 | // methods for updating G4Step |
---|
254 | // |
---|
255 | |
---|
256 | inline G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep) |
---|
257 | { |
---|
258 | G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); |
---|
259 | |
---|
260 | // accumulate change of the kinetic energy |
---|
261 | G4double kinEnergy = pPostStepPoint->GetKineticEnergy() + |
---|
262 | (proposedKinEnergy - pStep->GetPreStepPoint()->GetKineticEnergy()); |
---|
263 | |
---|
264 | // update kinetic energy and charge |
---|
265 | if (kinEnergy < DBL_MIN) { |
---|
266 | theLocalEnergyDeposit += kinEnergy; |
---|
267 | kinEnergy = 0.0; |
---|
268 | } else { |
---|
269 | pPostStepPoint->SetCharge( currentCharge ); |
---|
270 | } |
---|
271 | pPostStepPoint->SetKineticEnergy( kinEnergy ); |
---|
272 | |
---|
273 | // update weight |
---|
274 | // this feature is commented out, it should be overwritten in case |
---|
275 | // if energy loss processes will use biasing |
---|
276 | // G4double newWeight = theParentWeight*(pPostStepPoint->GetWeight()) |
---|
277 | // /(pPreStepPoint->GetWeight()); |
---|
278 | // pPostStepPoint->SetWeight( newWeight ); |
---|
279 | pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit ); |
---|
280 | pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit ); |
---|
281 | return pStep; |
---|
282 | } |
---|
283 | |
---|
284 | inline G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep) |
---|
285 | { |
---|
286 | G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); |
---|
287 | pPostStepPoint->SetCharge( currentCharge ); |
---|
288 | pPostStepPoint->SetMomentumDirection( proposedMomentumDirection ); |
---|
289 | pPostStepPoint->SetKineticEnergy( proposedKinEnergy ); |
---|
290 | pPostStepPoint->SetPolarization( proposedPolarization ); |
---|
291 | // update weight if process cannot do that |
---|
292 | if (!fSetParentWeightByProcess) |
---|
293 | pPostStepPoint->SetWeight( theParentWeight ); |
---|
294 | |
---|
295 | pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit ); |
---|
296 | pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit ); |
---|
297 | return pStep; |
---|
298 | } |
---|
299 | |
---|
300 | inline void G4ParticleChangeForLoss::AddSecondary(G4DynamicParticle* aParticle) |
---|
301 | { |
---|
302 | // create track |
---|
303 | G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(), |
---|
304 | currentTrack->GetPosition()); |
---|
305 | |
---|
306 | // Touchable handle is copied to keep the pointer |
---|
307 | aTrack->SetTouchableHandle(currentTrack->GetTouchableHandle()); |
---|
308 | |
---|
309 | // add a secondary |
---|
310 | G4VParticleChange::AddSecondary(aTrack); |
---|
311 | } |
---|
312 | |
---|
313 | #endif |
---|
314 | |
---|