source: trunk/source/track/src/G4ParticleChangeForDecay.cc@ 1348

Last change on this file since 1348 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 6.9 KB
Line 
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: G4ParticleChangeForDecay.cc,v 1.12 2010/07/21 09:30:15 gcosmo Exp $
28// GEANT4 tag $Name: track-V09-03-09 $
29//
30//
31// --------------------------------------------------------------
32// GEANT 4 class implementation file
33//
34//
35//
36// ------------------------------------------------------------
37// Implemented for the new scheme 23 Mar. 1998 H.Kurahige
38// Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige
39// --------------------------------------------------------------
40
41#include "G4ParticleChangeForDecay.hh"
42#include "G4Track.hh"
43#include "G4Step.hh"
44#include "G4TrackFastVector.hh"
45#include "G4DynamicParticle.hh"
46#include "G4ExceptionSeverity.hh"
47
48G4ParticleChangeForDecay::G4ParticleChangeForDecay()
49 : G4VParticleChange(), theTimeChange(0.)
50{
51#ifdef G4VERBOSE
52 if (verboseLevel>2) {
53 G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl;
54 }
55#endif
56}
57
58G4ParticleChangeForDecay::~G4ParticleChangeForDecay()
59{
60#ifdef G4VERBOSE
61 if (verboseLevel>2) {
62 G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl;
63 }
64#endif
65}
66
67// copy and assignment operators are implemented as "shallow copy"
68G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right)
69{
70 theTimeChange = right.theTimeChange;
71 thePolarizationChange = right.thePolarizationChange;
72}
73
74
75G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right)
76{
77 if (this != &right){
78 theListOfSecondaries = right.theListOfSecondaries;
79 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
80 theNumberOfSecondaries = right.theNumberOfSecondaries;
81 theStatusChange = right.theStatusChange;
82 theTrueStepLength = right.theTrueStepLength;
83 theLocalEnergyDeposit = right.theLocalEnergyDeposit;
84 theSteppingControlFlag = right.theSteppingControlFlag;
85
86 theTimeChange = right.theTimeChange;
87 thePolarizationChange = right.thePolarizationChange;
88 }
89 return *this;
90}
91
92G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const
93{
94 return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
95}
96
97G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const
98{
99 return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
100}
101
102//----------------------------------------------------------------
103// methods for Initialization
104//
105void G4ParticleChangeForDecay::Initialize(const G4Track& track)
106{
107 // use base class's method at first
108 G4VParticleChange::Initialize(track);
109
110 const G4DynamicParticle* pParticle = track.GetDynamicParticle();
111
112 // set Time e equal to those of the parent track
113 theTimeChange = track.GetGlobalTime();
114
115 // set the Polarization equal to those of the parent track
116 thePolarizationChange = pParticle->GetPolarization();
117}
118
119//----------------------------------------------------------------
120// methods for updating G4Step
121//
122
123G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep)
124{
125 // Update the G4Step specific attributes
126 return UpdateStepInfo(pStep);
127}
128
129
130G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep)
131{
132 // A physics process always calculates the final state of the particle
133
134 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
135 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
136
137 // update polarization
138 pPostStepPoint->SetPolarization( thePolarizationChange );
139
140 // update time
141 pPostStepPoint->SetGlobalTime( theTimeChange );
142 pPostStepPoint->AddLocalTime( theTimeChange
143 - pPreStepPoint->GetGlobalTime());
144 pPostStepPoint->AddProperTime( theTimeChange
145 - pPreStepPoint->GetGlobalTime());
146
147
148#ifdef G4VERBOSE
149 G4Track* aTrack = pStep->GetTrack();
150 if (debugFlag) CheckIt(*aTrack);
151#endif
152
153 // Update the G4Step specific attributes
154 return UpdateStepInfo(pStep);
155}
156
157void G4ParticleChangeForDecay::DumpInfo() const
158{
159// Show header
160 G4VParticleChange::DumpInfo();
161
162 G4int oldprc = G4cout.precision(3);
163 G4cout << " Time (ns) : "
164 << std::setw(20) << theTimeChange/ns << G4endl;
165 G4cout.precision(oldprc);
166}
167
168G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack)
169{
170 G4bool exitWithError = false;
171
172 G4double accuracy;
173
174 // global time should not go back
175 G4bool itsOK =true;
176 accuracy = -1.0*(theTimeChange - aTrack.GetGlobalTime())/ns;
177 if (accuracy > accuracyForWarning) {
178#ifdef G4VERBOSE
179 G4cout << " G4ParticleChangeForDecay::CheckIt : ";
180 G4cout << "the global time goes back !!" << G4endl;
181 G4cout << " Difference: " << accuracy << "[ns] " <<G4endl;
182#endif
183 itsOK = false;
184 if (accuracy > accuracyForException) exitWithError = true;
185 }
186
187 // dump out information of this particle change
188#ifdef G4VERBOSE
189 if (!itsOK) {
190 G4cout << " G4ParticleChangeForDecay::CheckIt " <<G4endl;
191 DumpInfo();
192 }
193#endif
194
195 // Exit with error
196 if (exitWithError) {
197 G4Exception("G4ParticleChangeForDecay::CheckIt",
198 "500",
199 EventMustBeAborted,
200 "time was illegal");
201 }
202
203 // correction
204 if (!itsOK) {
205 theTimeChange = aTrack.GetGlobalTime();
206 }
207
208 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
209 return itsOK;
210}
211
212
213
214
215
Note: See TracBrowser for help on using the repository browser.