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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/G4ParticleChangeForLoss.cc (Version 11.3.0) and /track/src/G4ParticleChangeForLoss.cc (Version 10.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ParticleChangeForLoss class implementatio << 
 27 //                                                 26 //
 28 // Author: Hisaya Kurashige, 23 March 1998     <<  27 //
 29 // Revision: Vladimir Ivantchenko, 16 January  <<  28 //
 30 // ------------------------------------------- <<  29 // --------------------------------------------------------------
 31                                                <<  30 //  GEANT 4 class implementation file
                                                   >>  31 //
                                                   >>  32 // ------------------------------------------------------------
                                                   >>  33 //   Implemented for the new scheme                 23 Mar. 1998  H.Kurahige
                                                   >>  34 // --------------------------------------------------------------
                                                   >>  35 //
                                                   >>  36 //   Modified:
                                                   >>  37 //   16.01.04 V.Ivanchenko update for model variant of energy loss
                                                   >>  38 //   15.04.05 V.Ivanchenko inline update methods
                                                   >>  39 //   28.08.06 V.Ivanchenko Add access to current track and polarizaion
                                                   >>  40 //
                                                   >>  41 // ------------------------------------------------------------
                                                   >>  42 //
 32 #include "G4ParticleChangeForLoss.hh"              43 #include "G4ParticleChangeForLoss.hh"
 33 #include "G4SystemOfUnits.hh"                      44 #include "G4SystemOfUnits.hh"
                                                   >>  45 #include "G4Track.hh"
                                                   >>  46 #include "G4Step.hh"
                                                   >>  47 #include "G4DynamicParticle.hh"
 34 #include "G4ExceptionSeverity.hh"                  48 #include "G4ExceptionSeverity.hh"
                                                   >>  49 //#include "G4VelocityTable.hh"
 35                                                    50 
 36 // ------------------------------------------- << 
 37 G4ParticleChangeForLoss::G4ParticleChangeForLo     51 G4ParticleChangeForLoss::G4ParticleChangeForLoss()
                                                   >>  52   : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.),
                                                   >>  53     lowEnergyLimit(1.0*eV), currentCharge(0.)
 38 {                                                  54 {
 39   // Disable flag that is enabled in G4VPartic <<  55   theSteppingControlFlag = NormalCondition;
 40   debugFlag = false;                               56   debugFlag = false;
 41   SetNumberOfSecondaries(1);                   <<  57 #ifdef G4VERBOSE
                                                   >>  58   if (verboseLevel>2) {
                                                   >>  59     G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl;
                                                   >>  60   }
                                                   >>  61 #endif
                                                   >>  62 }
                                                   >>  63 
                                                   >>  64 G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
                                                   >>  65 {
                                                   >>  66 #ifdef G4VERBOSE
                                                   >>  67   if (verboseLevel>2) {
                                                   >>  68     G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl;
                                                   >>  69   }
                                                   >>  70 #endif
                                                   >>  71 }
                                                   >>  72 
                                                   >>  73 G4ParticleChangeForLoss::
                                                   >>  74 G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right)
                                                   >>  75   : G4VParticleChange(right)
                                                   >>  76 {
                                                   >>  77   if (verboseLevel>1) {
                                                   >>  78     G4cout << "G4ParticleChangeForLoss::  copy constructor is called " << G4endl;
                                                   >>  79   }
                                                   >>  80   currentTrack = right.currentTrack;
                                                   >>  81   proposedKinEnergy = right.proposedKinEnergy;
                                                   >>  82   lowEnergyLimit = right.lowEnergyLimit;
                                                   >>  83   currentCharge = right.currentCharge;
                                                   >>  84   proposedMomentumDirection = right.proposedMomentumDirection;
 42 }                                                  85 }
 43                                                    86 
 44 // ------------------------------------------- <<  87 // assignment operator
                                                   >>  88 G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=(
                                                   >>  89                                    const G4ParticleChangeForLoss &right)
                                                   >>  90 {
                                                   >>  91 #ifdef G4VERBOSE
                                                   >>  92   if (verboseLevel>1) {
                                                   >>  93     G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl;
                                                   >>  94   }
                                                   >>  95 #endif
                                                   >>  96 
                                                   >>  97   if (this != &right) {
                                                   >>  98     if (theNumberOfSecondaries>0) {
                                                   >>  99 #ifdef G4VERBOSE
                                                   >> 100       if (verboseLevel>0) {
                                                   >> 101   G4cout << "G4ParticleChangeForLoss: assignment operator Warning  ";
                                                   >> 102   G4cout << "theListOfSecondaries is not empty ";
                                                   >> 103       }
                                                   >> 104 #endif
                                                   >> 105        for (G4int index= 0; index<theNumberOfSecondaries; index++){
                                                   >> 106    if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
                                                   >> 107        }
                                                   >> 108     }
                                                   >> 109     delete theListOfSecondaries; 
                                                   >> 110     theListOfSecondaries =  new G4TrackFastVector();
                                                   >> 111     theNumberOfSecondaries = right.theNumberOfSecondaries;
                                                   >> 112     for (G4int index = 0; index<theNumberOfSecondaries; index++){
                                                   >> 113       G4Track* newTrack =  new G4Track(*((*right.theListOfSecondaries)[index] ));
                                                   >> 114       theListOfSecondaries->SetElement(index, newTrack);          }
                                                   >> 115 
                                                   >> 116     theStatusChange = right.theStatusChange;
                                                   >> 117     theLocalEnergyDeposit = right.theLocalEnergyDeposit;
                                                   >> 118     theSteppingControlFlag = right.theSteppingControlFlag;
                                                   >> 119     theParentWeight = right.theParentWeight;
                                                   >> 120     isParentWeightProposed = right.isParentWeightProposed;
                                                   >> 121     fSetSecondaryWeightByProcess = right.fSetSecondaryWeightByProcess;
                                                   >> 122 
                                                   >> 123     currentTrack = right.currentTrack;
                                                   >> 124     proposedKinEnergy = right.proposedKinEnergy;
                                                   >> 125     currentCharge = right.currentCharge;
                                                   >> 126     proposedMomentumDirection = right.proposedMomentumDirection;
                                                   >> 127   }
                                                   >> 128   return *this;
                                                   >> 129 }
                                                   >> 130 
                                                   >> 131 //----------------------------------------------------------------
                                                   >> 132 // methods for printing messages
                                                   >> 133 //
                                                   >> 134 
 45 void G4ParticleChangeForLoss::DumpInfo() const    135 void G4ParticleChangeForLoss::DumpInfo() const
 46 {                                                 136 {
 47   // use base-class DumpInfo                   << 137 // use base-class DumpInfo
 48   G4VParticleChange::DumpInfo();                  138   G4VParticleChange::DumpInfo();
 49                                                   139 
 50   G4long oldprc = G4cout.precision(8);         << 140   G4int oldprc = G4cout.precision(3);
 51   G4cout << "      --------------------------- << 141   G4cout << "        Charge (eplus)   : "
 52   G4cout << "        G4ParticleChangeForLoss p << 142        << std::setw(20) << currentCharge/eplus
 53   G4cout << "        Charge (eplus)   : " << s << 143        << G4endl;
 54          << currentCharge / eplus << G4endl;   << 144   G4cout << "        Kinetic Energy (MeV): "
 55   G4cout << "        Kinetic Energy (MeV): " < << 145        << std::setw(20) << proposedKinEnergy/MeV
 56          << proposedKinEnergy / MeV << G4endl; << 146        << G4endl;
 57   G4cout << "        Momentum Direct - x : " < << 147   G4cout << "        Momentum Direct - x : "
 58          << proposedMomentumDirection.x() << G << 148        << std::setw(20) << proposedMomentumDirection.x()
 59   G4cout << "        Momentum Direct - y : " < << 149        << G4endl;
 60          << proposedMomentumDirection.y() << G << 150   G4cout << "        Momentum Direct - y : "
 61   G4cout << "        Momentum Direct - z : " < << 151        << std::setw(20) << proposedMomentumDirection.y()
 62          << proposedMomentumDirection.z() << G << 152        << G4endl;
                                                   >> 153   G4cout << "        Momentum Direct - z : "
                                                   >> 154        << std::setw(20) << proposedMomentumDirection.z()
                                                   >> 155        << G4endl;
 63   G4cout.precision(oldprc);                       156   G4cout.precision(oldprc);
 64 }                                                 157 }
 65                                                   158 
 66 // ------------------------------------------- << 159 G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
                                                   >> 160 {
                                                   >> 161   G4bool    itsOK = true;
                                                   >> 162   G4bool    exitWithError = false;
                                                   >> 163 
                                                   >> 164   G4double  accuracy;
                                                   >> 165 
                                                   >> 166   // Energy should not be lager than initial value
                                                   >> 167   accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
                                                   >> 168   if (accuracy > accuracyForWarning) {
                                                   >> 169     itsOK = false;
                                                   >> 170     exitWithError = (accuracy > accuracyForException);
                                                   >> 171 #ifdef G4VERBOSE
                                                   >> 172     G4cout << "G4ParticleChangeForLoss::CheckIt: ";
                                                   >> 173     G4cout << "KinEnergy become larger than the initial value!" 
                                                   >> 174      << "  Difference:  " << accuracy  << "[MeV] " <<G4endl;
                                                   >> 175     G4cout << aTrack.GetDefinition()->GetParticleName()
                                                   >> 176      << " E=" << aTrack.GetKineticEnergy()/MeV
                                                   >> 177      << " pos=" << aTrack.GetPosition().x()/m
                                                   >> 178      << ", " << aTrack.GetPosition().y()/m
                                                   >> 179      << ", " << aTrack.GetPosition().z()/m
                                                   >> 180      <<G4endl;
                                                   >> 181 #endif
                                                   >> 182   }
                                                   >> 183 
                                                   >> 184   // dump out information of this particle change
                                                   >> 185 #ifdef G4VERBOSE
                                                   >> 186   if (!itsOK) DumpInfo();
                                                   >> 187 #endif
                                                   >> 188 
                                                   >> 189   // Exit with error
                                                   >> 190   if (exitWithError) {
                                                   >> 191     G4Exception("G4ParticleChangeForLoss::CheckIt",
                                                   >> 192     "TRACK004", EventMustBeAborted,
                                                   >> 193     "energy was  illegal");
                                                   >> 194   }
                                                   >> 195 
                                                   >> 196   //correction
                                                   >> 197   if (!itsOK) {
                                                   >> 198     proposedKinEnergy = aTrack.GetKineticEnergy();
                                                   >> 199   }
                                                   >> 200 
                                                   >> 201   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
                                                   >> 202   return itsOK;
                                                   >> 203 }
                                                   >> 204 
                                                   >> 205 //----------------------------------------------------------------
                                                   >> 206 // methods for updating G4Step
                                                   >> 207 //
                                                   >> 208 
 67 G4Step* G4ParticleChangeForLoss::UpdateStepFor    209 G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep)
 68 {                                                 210 {
 69   const G4StepPoint* pPreStepPoint = pStep->Ge << 
 70   G4StepPoint* pPostStepPoint = pStep->GetPost    211   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 212   G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint();
                                                   >> 213   G4Track* pTrack = pStep->GetTrack();
 71                                                   214 
 72   // accumulate change of the kinetic energy      215   // accumulate change of the kinetic energy
 73   G4double preKinEnergy = pPreStepPoint->GetKi    216   G4double preKinEnergy = pPreStepPoint->GetKineticEnergy();
 74   G4double kinEnergy =                         << 217   G4double kinEnergy = pPostStepPoint->GetKineticEnergy() +
 75     pPostStepPoint->GetKineticEnergy() + (prop << 218     (proposedKinEnergy - preKinEnergy);
 76                                                   219 
 77   pPostStepPoint->SetCharge(currentCharge);    << 220   // update kinetic energy and charge
 78                                                << 221   if (kinEnergy < lowEnergyLimit) {
 79   // calculate velocity                        << 222     theLocalEnergyDeposit += kinEnergy;
 80   if(kinEnergy > 0.0)                          << 223     kinEnergy = 0.0;
 81   {                                            << 
 82     pPostStepPoint->SetKineticEnergy(kinEnergy << 
 83                                                << 
 84     // assuming that mass>0, zero mass particl << 
 85     pPostStepPoint->SetVelocity(CLHEP::c_light << 
 86   }                                            << 
 87   else                                         << 
 88   {                                            << 
 89     pPostStepPoint->SetKineticEnergy(0.0);     << 
 90     pPostStepPoint->SetVelocity(0.0);             224     pPostStepPoint->SetVelocity(0.0);
                                                   >> 225   } else {
                                                   >> 226     pPostStepPoint->SetCharge( currentCharge );
                                                   >> 227     // calculate velocity
                                                   >> 228     pTrack->SetKineticEnergy(kinEnergy); 
                                                   >> 229     pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
                                                   >> 230     pTrack->SetKineticEnergy(preKinEnergy); 
 91   }                                               231   }
                                                   >> 232   pPostStepPoint->SetKineticEnergy( kinEnergy );
 92                                                   233 
 93   if(isParentWeightProposed)                   << 234   if (isParentWeightProposed ){
 94   {                                            << 235     pPostStepPoint->SetWeight( theParentWeight );
 95     pPostStepPoint->SetWeight(theParentWeight) << 
 96   }                                               236   }
 97                                                   237 
 98   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 238   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
 99   pStep->AddNonIonizingEnergyDeposit(theNonIon << 239   pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
100   return pStep;                                   240   return pStep;
101 }                                                 241 }
102                                                   242 
103 // ------------------------------------------- << 
104 G4Step* G4ParticleChangeForLoss::UpdateStepFor    243 G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep)
105 {                                                 244 {
106   G4StepPoint* pPostStepPoint = pStep->GetPost    245   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 246   G4Track* pTrack = pStep->GetTrack();
107                                                   247 
108   pPostStepPoint->SetCharge(currentCharge);    << 248   pPostStepPoint->SetCharge( currentCharge );
109   pPostStepPoint->SetMomentumDirection(propose << 249   pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
110   if(proposedKinEnergy > 0.0)                  << 250   pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
111   {                                            << 251   pTrack->SetKineticEnergy( proposedKinEnergy );
112     pPostStepPoint->SetKineticEnergy(proposedK << 252   if(proposedKinEnergy > 0.0) {
113                                                << 253     pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
114     // assuming that mass>0, zero mass particl << 254   } else {
115     pPostStepPoint->SetVelocity(CLHEP::c_light << 
116   }                                            << 
117   else                                         << 
118   {                                            << 
119     pPostStepPoint->SetKineticEnergy(0.0);     << 
120     pPostStepPoint->SetVelocity(0.0);             255     pPostStepPoint->SetVelocity(0.0);
121   }                                               256   }
122   pPostStepPoint->SetPolarization(proposedPola << 257   pPostStepPoint->SetPolarization( proposedPolarization );
123                                                   258 
124   if(isParentWeightProposed)                   << 259   if (isParentWeightProposed ){
125   {                                            << 260     pPostStepPoint->SetWeight( theParentWeight );
126     pPostStepPoint->SetWeight(theParentWeight) << 
127   }                                               261   }
128                                                   262 
129   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 263   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
130   pStep->AddNonIonizingEnergyDeposit(theNonIon << 264   pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
131   return pStep;                                   265   return pStep;
132 }                                                 266 }
                                                   >> 267 
133                                                   268