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