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