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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /track/src/G4ParticleChangeForMSC.cc (Version 11.3.0) and /track/src/G4ParticleChangeForMSC.cc (Version 1.0)


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