Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ParticleChangeForDecay.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 //
27 // $Id: G4ParticleChangeForDecay.cc 93028 2015-09-30 16:09:00Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 //
34 //
35 // ------------------------------------------------------------
36 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige
37 // Remove modification of energy/momentum 20 Jul, 1998 H.Kurashige
38 // --------------------------------------------------------------
39 
41 #include "G4SystemOfUnits.hh"
42 #include "G4Track.hh"
43 #include "G4Step.hh"
44 #include "G4TrackFastVector.hh"
45 #include "G4DynamicParticle.hh"
46 #include "G4ExceptionSeverity.hh"
47 
49  : G4VParticleChange(),
50  theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.)
51 {
52 #ifdef G4VERBOSE
53  if (verboseLevel>2) {
54  G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl;
55  }
56 #endif
57 }
58 
60 {
61 #ifdef G4VERBOSE
62  if (verboseLevel>2) {
63  G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl;
64  }
65 #endif
66 }
67 
69 {
74 }
75 
76 
78 {
79  if (this != &right){
80  if (theNumberOfSecondaries>0) {
81 #ifdef G4VERBOSE
82  if (verboseLevel>0) {
83  G4cout << "G4ParticleChangeForDecay: assignment operator Warning ";
84  G4cout << "theListOfSecondaries is not empty ";
85  }
86 #endif
87  for (G4int index= 0; index<theNumberOfSecondaries; index++){
88  if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
89  }
90  }
91  delete theListOfSecondaries;
94  for (G4int index = 0; index<theNumberOfSecondaries; index++){
95  G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index] ));
96  theListOfSecondaries->SetElement(index, newTrack); }
97 
102 
107  }
108  return *this;
109 }
110 
112 {
113  return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
114 }
115 
117 {
118  return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
119 }
120 
121 //----------------------------------------------------------------
122 // methods for Initialization
123 //
125 {
126  // use base class's method at first
128 
129  const G4DynamicParticle* pParticle = track.GetDynamicParticle();
130 
131  // set TimeChange equal to local time of the parent track
132  theTimeChange = track.GetLocalTime();
133 
134  // set initial Local/Global time of the parent track
135  theLocalTime0 = track.GetLocalTime();
136  theGlobalTime0 = track.GetGlobalTime();
137 
138  // set the Polarization equal to those of the parent track
139  thePolarizationChange = pParticle->GetPolarization();
140 }
141 
142 //----------------------------------------------------------------
143 // methods for updating G4Step
144 //
145 
147 {
148  G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
149 
151  pPostStepPoint->SetWeight( theParentWeight );
152  }
153  // update polarization
154  pPostStepPoint->SetPolarization( thePolarizationChange );
155 
156  // Update the G4Step specific attributes
157  return UpdateStepInfo(pStep);
158 }
159 
160 
162 {
163  // A physics process always calculates the final state of the particle
164 
165  G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
166 
167  // update polarization
168  pPostStepPoint->SetPolarization( thePolarizationChange );
169 
170  // update time
171  pPostStepPoint->SetGlobalTime( GetGlobalTime() );
172  pPostStepPoint->SetLocalTime( theTimeChange );
173  pPostStepPoint->AddProperTime (theTimeChange-theLocalTime0);
174 
175 #ifdef G4VERBOSE
176  G4Track* aTrack = pStep->GetTrack();
177  if (debugFlag) CheckIt(*aTrack);
178 #endif
179 
180  if (isParentWeightProposed )pPostStepPoint->SetWeight( theParentWeight );
181 
182  // Update the G4Step specific attributes
183  return UpdateStepInfo(pStep);
184 }
185 
187 {
188 // Show header
190 
191  G4int oldprc = G4cout.precision(3);
192  G4cout << " proposed local Time (ns) : "
193  << std::setw(20) << theTimeChange/ns << G4endl;
194  G4cout << " initial local Time (ns) : "
195  << std::setw(20) << theLocalTime0/ns << G4endl;
196  G4cout << " initial global Time (ns) : "
197  << std::setw(20) << theGlobalTime0/ns << G4endl;
198  G4cout.precision(oldprc);
199 }
200 
202 {
203  G4bool exitWithError = false;
204 
205  G4double accuracy;
206 
207  // local time should not go back
208  G4bool itsOK =true;
209  accuracy = -1.0*(theTimeChange - theLocalTime0)/ns;
210  if (accuracy > accuracyForWarning) {
211  itsOK = false;
212  exitWithError = (accuracy > accuracyForException);
213 #ifdef G4VERBOSE
214  G4cout << " G4ParticleChangeForDecay::CheckIt : ";
215  G4cout << "the local time goes back !!"
216  << " Difference: " << accuracy << "[ns] " <<G4endl;
217  G4cout << "initial local time "<< theLocalTime0/ns << "[ns] "
218  << "initial global time "<< theGlobalTime0/ns << "[ns] " <<G4endl;
219  G4cout << aTrack.GetDefinition()->GetParticleName()
220  << " E=" << aTrack.GetKineticEnergy()/MeV
221  << " pos=" << aTrack.GetPosition().x()/m
222  << ", " << aTrack.GetPosition().y()/m
223  << ", " << aTrack.GetPosition().z()/m
224  <<G4endl;
225 #endif
226  }
227 
228  // dump out information of this particle change
229 #ifdef G4VERBOSE
230  if (!itsOK) DumpInfo();
231 #endif
232 
233  // Exit with error
234  if (exitWithError) {
235  G4Exception("G4ParticleChangeForDecay::CheckIt",
236  "TRACK005",EventMustBeAborted,
237  "time was illegal");
238  }
239 
240  // correction
241  if (!itsOK) {
242  theTimeChange = aTrack.GetLocalTime();
243  }
244 
245  itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
246  return itsOK;
247 }
248 
249 
250 
251 
252 
G4ParticleDefinition * GetDefinition() const
virtual void Initialize(const G4Track &)
void SetElement(G4int anIndex, Type *anElement)
Definition: G4FastVector.hh:76
G4bool operator==(const G4ParticleChangeForDecay &right) const
G4double GetLocalTime() const
double x() const
const G4DynamicParticle * GetDynamicParticle() const
G4double GetGlobalTime(G4double timeDelay=0.0) const
virtual G4bool CheckIt(const G4Track &)
const G4ThreeVector & GetPosition() const
G4TrackFastVector * theListOfSecondaries
void SetWeight(G4double aValue)
virtual G4Step * UpdateStepForPostStep(G4Step *Step)
virtual void DumpInfo() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
double z() const
static const G4double accuracyForException
void SetGlobalTime(const G4double aValue)
virtual G4Step * UpdateStepForAtRest(G4Step *Step)
void SetLocalTime(const G4double aValue)
virtual G4bool CheckIt(const G4Track &)
virtual void Initialize(const G4Track &)
G4double GetKineticEnergy() const
void SetPolarization(const G4ThreeVector &aValue)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
bool G4bool
Definition: G4Types.hh:79
G4SteppingControl theSteppingControlFlag
Definition: G4Step.hh:76
G4double GetGlobalTime() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Step * UpdateStepInfo(G4Step *Step)
G4FastVector< G4Track, G4TrackFastVectorSize > G4TrackFastVector
G4StepPoint * GetPostStepPoint() const
G4ParticleChangeForDecay & operator=(const G4ParticleChangeForDecay &right)
double y() const
const G4ThreeVector & GetPolarization() const
G4bool operator!=(const G4ParticleChangeForDecay &right) const
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
G4TrackStatus theStatusChange
double G4double
Definition: G4Types.hh:76
static const G4double accuracyForWarning
G4Track * GetTrack() const
#define ns
Definition: xmlparse.cc:614
void AddProperTime(const G4double aValue)