Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4ParticleChangeForMSC class implementation << 27 // 23 // 28 // Author: Hisaya Kurashige, 23 March 1998 << 24 // $Id: G4ParticleChangeForMSC.cc,v 1.8 2001/08/16 08:17:59 kurasige Exp $ 29 // Revision: Vladimir Ivantchenko, 16 January << 25 // GEANT4 tag $Name: geant4-05-01 $ 30 // 23 August 2 << 26 // 31 // ------------------------------------------- << 27 // >> 28 // -------------------------------------------------------------- >> 29 // GEANT 4 class implementation file >> 30 // >> 31 // >> 32 // >> 33 // ------------------------------------------------------------ >> 34 // Implemented for the new scheme 23 Mar. 1998 H.Kurahige >> 35 // -------------------------------------------------------------- 32 36 33 #include "G4ParticleChangeForMSC.hh" 37 #include "G4ParticleChangeForMSC.hh" 34 #include "G4SystemOfUnits.hh" << 35 #include "G4Track.hh" 38 #include "G4Track.hh" 36 #include "G4Step.hh" 39 #include "G4Step.hh" 37 #include "G4ExceptionSeverity.hh" << 40 #include "G4TrackFastVector.hh" >> 41 #include "G4DynamicParticle.hh" >> 42 >> 43 G4ParticleChangeForMSC::G4ParticleChangeForMSC():G4VParticleChange() >> 44 { >> 45 #ifdef G4VERBOSE >> 46 if (verboseLevel>2) { >> 47 G4cout << "G4ParticleChangeForMSC::G4ParticleChangeForMSC() " << G4endl; >> 48 } >> 49 #endif >> 50 } >> 51 >> 52 G4ParticleChangeForMSC::~G4ParticleChangeForMSC() >> 53 { >> 54 #ifdef G4VERBOSE >> 55 if (verboseLevel>2) { >> 56 G4cout << "G4ParticleChangeForMSC::~G4ParticleChangeForMSC() " << G4endl; >> 57 } >> 58 #endif >> 59 } >> 60 >> 61 G4ParticleChangeForMSC::G4ParticleChangeForMSC( >> 62 const G4ParticleChangeForMSC &right): G4VParticleChange(right) >> 63 { >> 64 if (verboseLevel>1) { >> 65 G4cout << "G4ParticleChangeForMSC:: copy constructor is called " << G4endl; >> 66 } >> 67 theMomentumDirectionChange = right.theMomentumDirectionChange; >> 68 thePositionChange = right.thePositionChange; >> 69 theTrueStepLength = right.theTrueStepLength; >> 70 } 38 71 39 // ------------------------------------------- << 72 // assignment operator 40 G4ParticleChangeForMSC::G4ParticleChangeForMSC << 73 G4ParticleChangeForMSC & G4ParticleChangeForMSC::operator=( >> 74 const G4ParticleChangeForMSC &right) 41 { 75 { 42 // Disable flag that is enabled in G4VPartic << 76 if (verboseLevel>1) { 43 debugFlag = false; << 77 G4cout << "G4ParticleChangeForMSC:: assignment operator is called " << G4endl; >> 78 } >> 79 if (this != &right) >> 80 { >> 81 theListOfSecondaries = right.theListOfSecondaries; >> 82 theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; >> 83 theNumberOfSecondaries = right.theNumberOfSecondaries; >> 84 theStatusChange = right.theStatusChange; >> 85 theLocalEnergyDeposit = right.theLocalEnergyDeposit; >> 86 theSteppingControlFlag = right.theSteppingControlFlag; >> 87 >> 88 >> 89 theMomentumDirectionChange = right.theMomentumDirectionChange; >> 90 thePositionChange = right.thePositionChange; >> 91 theTrueStepLength = right.theTrueStepLength; >> 92 } >> 93 return *this; 44 } 94 } 45 95 46 // ------------------------------------------- << 96 //---------------------------------------------------------------- >> 97 // functions for Initialization >> 98 // >> 99 >> 100 void G4ParticleChangeForMSC::Initialize(const G4Track& track) >> 101 { >> 102 // use base class's method at first >> 103 G4VParticleChange::Initialize(track); >> 104 >> 105 // set Energy/Momentum etc. equal to those of the parent particle >> 106 const G4DynamicParticle* pParticle = track.GetDynamicParticle(); >> 107 theMomentumDirectionChange = pParticle->GetMomentumDirection(); >> 108 >> 109 // set Position equal to those of the parent track >> 110 thePositionChange = track.GetPosition(); >> 111 } >> 112 >> 113 //---------------------------------------------------------------- >> 114 // methods for updating G4Step >> 115 // >> 116 47 G4Step* G4ParticleChangeForMSC::UpdateStepForA 117 G4Step* G4ParticleChangeForMSC::UpdateStepForAlongStep(G4Step* pStep) 48 { 118 { 49 // update the G4Step specific attributes << 119 50 pStep->SetStepLength(theTrueStepLength); << 120 // Update the G4Step specific attributes >> 121 pStep->SetStepLength(theTrueStepLength) ; 51 122 52 // multiple scattering calculates the final << 123 return pStep; 53 G4StepPoint* pPostStepPoint = pStep->GetPost << 124 } 54 125 >> 126 G4Step* G4ParticleChangeForMSC::UpdateStepForPostStep(G4Step* pStep) >> 127 { >> 128 // A physics process always calculates the final state of the particle >> 129 >> 130 // Take note that the return type of GetMomentumChange is a >> 131 // pointer to G4ParticleMometum. Also it is a normalized >> 132 // momentum vector. >> 133 >> 134 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); >> 135 G4Track* aTrack = pStep->GetTrack(); >> 136 55 // update momentum direction 137 // update momentum direction 56 pPostStepPoint->SetMomentumDirection(theMome << 138 pPostStepPoint->SetMomentumDirection(theMomentumDirectionChange); 57 139 58 // update position << 140 // update position 59 pPostStepPoint->SetPosition(thePosition); << 141 pPostStepPoint->SetPosition( thePositionChange ); 60 return pStep; << 142 >> 143 #ifdef G4VERBOSE >> 144 if (debugFlag) CheckIt(*aTrack); >> 145 #endif >> 146 >> 147 // Update the G4Step specific attributes >> 148 return UpdateStepInfo(pStep); >> 149 } >> 150 >> 151 G4Step* G4ParticleChangeForMSC::UpdateStepForAtRest(G4Step* pStep) >> 152 { >> 153 >> 154 // Update the G4Step specific attributes >> 155 return UpdateStepInfo(pStep); >> 156 } >> 157 >> 158 //---------------------------------------------------------------- >> 159 // methods for printing messages >> 160 // >> 161 >> 162 void G4ParticleChangeForMSC::DumpInfo() const >> 163 { >> 164 // use base-class DumpInfo >> 165 G4VParticleChange::DumpInfo(); >> 166 >> 167 G4cout.precision(3); >> 168 G4cout << " Position - x (mm) : " >> 169 << G4std::setw(20) << thePositionChange.x()/mm >> 170 << G4endl; >> 171 G4cout << " Position - y (mm) : " >> 172 << G4std::setw(20) << thePositionChange.y()/mm >> 173 << G4endl; >> 174 G4cout << " Position - z (mm) : " >> 175 << G4std::setw(20) << thePositionChange.z()/mm >> 176 << G4endl; >> 177 G4cout << " Momentum Direction - x : " >> 178 << G4std::setw(20) << theMomentumDirectionChange.x() >> 179 << G4endl; >> 180 G4cout << " Momentum Direction - y : " >> 181 << G4std::setw(20) << theMomentumDirectionChange.y() >> 182 << G4endl; >> 183 G4cout << " Momentum Direction - z : " >> 184 << G4std::setw(20) << theMomentumDirectionChange.z() >> 185 << G4endl; 61 } 186 } >> 187 >> 188 >> 189 G4bool G4ParticleChangeForMSC::CheckIt(const G4Track& aTrack) >> 190 { >> 191 G4bool itsOK = true; >> 192 G4bool exitWithError = false; >> 193 >> 194 G4double accuracy; >> 195 >> 196 // check >> 197 >> 198 // MomentumDirection should be unit vector >> 199 accuracy = abs(theMomentumDirectionChange.mag2()-1.0); >> 200 if (accuracy > accuracyForWarning) { >> 201 G4cout << " G4ParticleChangeForMSC::CheckIt : "; >> 202 G4cout << "the Momentum Change is not unit vector !!" << G4endl; >> 203 G4cout << " Difference: " << accuracy << G4endl; >> 204 itsOK = false; >> 205 if (accuracy > accuracyForException) exitWithError = true; >> 206 } >> 207 >> 208 // dump out information of this particle change >> 209 if (!itsOK) { >> 210 G4cout << " G4ParticleChangeForMSC::CheckIt " <<G4endl; >> 211 DumpInfo(); >> 212 } >> 213 >> 214 // Exit with error >> 215 if (exitWithError) G4Exception("G4ParticleChangeForMSC::CheckIt"); >> 216 >> 217 //correction >> 218 if (!itsOK) { >> 219 G4double vmag = theMomentumDirectionChange.mag(); >> 220 theMomentumDirectionChange = (1./vmag)*theMomentumDirectionChange; >> 221 } >> 222 >> 223 >> 224 itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); >> 225 return itsOK; >> 226 } >> 227 >> 228 >> 229 62 230 63 231