[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: G4ParticleChangeForMSC.cc,v 1.13 2006/06/29 21:15:09 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 | // Update for model variant of msc 16 Jan 2004 V.Ivanchenko |
---|
| 39 | // -------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | #include "G4ParticleChangeForMSC.hh" |
---|
| 42 | #include "G4Track.hh" |
---|
| 43 | #include "G4Step.hh" |
---|
| 44 | #include "G4DynamicParticle.hh" |
---|
| 45 | #include "G4ExceptionSeverity.hh" |
---|
| 46 | |
---|
| 47 | G4ParticleChangeForMSC::G4ParticleChangeForMSC():G4VParticleChange() |
---|
| 48 | { |
---|
| 49 | #ifdef G4VERBOSE |
---|
| 50 | if (verboseLevel>2) { |
---|
| 51 | G4cout << "G4ParticleChangeForMSC::G4ParticleChangeForMSC() " << G4endl; |
---|
| 52 | } |
---|
| 53 | #endif |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | G4ParticleChangeForMSC::~G4ParticleChangeForMSC() |
---|
| 57 | { |
---|
| 58 | #ifdef G4VERBOSE |
---|
| 59 | if (verboseLevel>2) { |
---|
| 60 | G4cout << "G4ParticleChangeForMSC::~G4ParticleChangeForMSC() " << G4endl; |
---|
| 61 | } |
---|
| 62 | #endif |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | G4ParticleChangeForMSC::G4ParticleChangeForMSC( |
---|
| 66 | const G4ParticleChangeForMSC &right): G4VParticleChange(right) |
---|
| 67 | { |
---|
| 68 | if (verboseLevel>1) { |
---|
| 69 | G4cout << "G4ParticleChangeForMSC:: copy constructor is called " << G4endl; |
---|
| 70 | } |
---|
| 71 | theMomentumDirection = right.theMomentumDirection; |
---|
| 72 | thePosition = right.thePosition; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // assignment operator |
---|
| 76 | G4ParticleChangeForMSC & G4ParticleChangeForMSC::operator=( |
---|
| 77 | const G4ParticleChangeForMSC &right) |
---|
| 78 | { |
---|
| 79 | if (verboseLevel>1) { |
---|
| 80 | G4cout << "G4ParticleChangeForMSC:: assignment operator is called " << G4endl; |
---|
| 81 | } |
---|
| 82 | if (this != &right) |
---|
| 83 | { |
---|
| 84 | theListOfSecondaries = right.theListOfSecondaries; |
---|
| 85 | theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; |
---|
| 86 | theNumberOfSecondaries = right.theNumberOfSecondaries; |
---|
| 87 | theStatusChange = right.theStatusChange; |
---|
| 88 | theLocalEnergyDeposit = right.theLocalEnergyDeposit; |
---|
| 89 | theSteppingControlFlag = right.theSteppingControlFlag; |
---|
| 90 | theTrueStepLength = right.theTrueStepLength; |
---|
| 91 | |
---|
| 92 | theMomentumDirection = right.theMomentumDirection; |
---|
| 93 | thePosition = right.thePosition; |
---|
| 94 | } |
---|
| 95 | return *this; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | //---------------------------------------------------------------- |
---|
| 99 | // methods for updating G4Step |
---|
| 100 | // |
---|
| 101 | |
---|
| 102 | G4Step* G4ParticleChangeForMSC::UpdateStepForAlongStep(G4Step* pStep) |
---|
| 103 | { |
---|
| 104 | // Update the G4Step specific attributes |
---|
| 105 | pStep->SetStepLength(theTrueStepLength); |
---|
| 106 | theStatusChange = pStep->GetTrack()->GetTrackStatus(); |
---|
| 107 | return pStep; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | G4Step* G4ParticleChangeForMSC::UpdateStepForPostStep(G4Step* pStep) |
---|
| 111 | { |
---|
| 112 | // A physics process always calculates the final state of the particle |
---|
| 113 | G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); |
---|
| 114 | |
---|
| 115 | // update momentum direction |
---|
| 116 | pPostStepPoint->SetMomentumDirection(theMomentumDirection); |
---|
| 117 | |
---|
| 118 | // update position |
---|
| 119 | pPostStepPoint->SetPosition( thePosition ); |
---|
| 120 | |
---|
| 121 | // Update the G4Step specific attributes |
---|
| 122 | return pStep; |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | //---------------------------------------------------------------- |
---|
| 127 | // methods for printing messages |
---|
| 128 | // |
---|
| 129 | |
---|
| 130 | void G4ParticleChangeForMSC::DumpInfo() const |
---|
| 131 | { |
---|
| 132 | // use base-class DumpInfo |
---|
| 133 | G4VParticleChange::DumpInfo(); |
---|
| 134 | |
---|
| 135 | G4cout.precision(3); |
---|
| 136 | G4cout << " Position - x (mm) : " |
---|
| 137 | << std::setw(20) << thePosition.x()/mm |
---|
| 138 | << G4endl; |
---|
| 139 | G4cout << " Position - y (mm) : " |
---|
| 140 | << std::setw(20) << thePosition.y()/mm |
---|
| 141 | << G4endl; |
---|
| 142 | G4cout << " Position - z (mm) : " |
---|
| 143 | << std::setw(20) << thePosition.z()/mm |
---|
| 144 | << G4endl; |
---|
| 145 | G4cout << " Momentum Direct - x : " |
---|
| 146 | << std::setw(20) << theMomentumDirection.x() |
---|
| 147 | << G4endl; |
---|
| 148 | G4cout << " Momentum Direct - y : " |
---|
| 149 | << std::setw(20) << theMomentumDirection.y() |
---|
| 150 | << G4endl; |
---|
| 151 | G4cout << " Momentum Direct - z : " |
---|
| 152 | << std::setw(20) << theMomentumDirection.z() |
---|
| 153 | << G4endl; |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | G4bool G4ParticleChangeForMSC::CheckIt(const G4Track& aTrack) |
---|
| 158 | { |
---|
| 159 | G4bool itsOK = true; |
---|
| 160 | G4bool exitWithError = false; |
---|
| 161 | |
---|
| 162 | G4double accuracy; |
---|
| 163 | |
---|
| 164 | // check |
---|
| 165 | |
---|
| 166 | // MomentumDirection should be unit vector |
---|
| 167 | accuracy = std::abs(theMomentumDirection.mag2()-1.0); |
---|
| 168 | if (accuracy > accuracyForWarning) { |
---|
| 169 | #ifdef G4VERBOSE |
---|
| 170 | G4cout << " G4ParticleChangeForMSC::CheckIt : "; |
---|
| 171 | G4cout << "the Momentum Change is not unit vector !!" << G4endl; |
---|
| 172 | G4cout << " Difference: " << accuracy << G4endl; |
---|
| 173 | #endif |
---|
| 174 | itsOK = false; |
---|
| 175 | if (accuracy > accuracyForException) exitWithError = true; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | // dump out information of this particle change |
---|
| 179 | #ifdef G4VERBOSE |
---|
| 180 | if (!itsOK) { |
---|
| 181 | G4cout << " G4ParticleChangeForMSC::CheckIt " <<G4endl; |
---|
| 182 | DumpInfo(); |
---|
| 183 | } |
---|
| 184 | #endif |
---|
| 185 | |
---|
| 186 | // Exit with error |
---|
| 187 | if (exitWithError) { |
---|
| 188 | G4Exception("G4ParticleChangeForMSC::CheckIt", |
---|
| 189 | "300", |
---|
| 190 | EventMustBeAborted, |
---|
| 191 | "momentum direction was illegal"); |
---|
| 192 | } |
---|
| 193 | //correction |
---|
| 194 | if (!itsOK) { |
---|
| 195 | G4double vmag = theMomentumDirection.mag(); |
---|
| 196 | theMomentumDirection = (1./vmag)*theMomentumDirection; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); |
---|
| 200 | return itsOK; |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | |
---|