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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.0.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 // $Id: G4ParticleChangeForLoss.cc 68795 2013-04-05 13:24:46Z gcosmo $
 29 // Revision: Vladimir Ivantchenko, 16 January  <<  28 //
 30 // ------------------------------------------- <<  29 //
 31                                                <<  30 // --------------------------------------------------------------
                                                   >>  31 //  GEANT 4 class implementation file
                                                   >>  32 //
                                                   >>  33 // ------------------------------------------------------------
                                                   >>  34 //   Implemented for the new scheme                 23 Mar. 1998  H.Kurahige
                                                   >>  35 // --------------------------------------------------------------
                                                   >>  36 //
                                                   >>  37 //   Modified:
                                                   >>  38 //   16.01.04 V.Ivanchenko update for model variant of energy loss
                                                   >>  39 //   15.04.05 V.Ivanchenko inline update methods
                                                   >>  40 //   28.08.06 V.Ivanchenko Add access to current track and polarizaion
                                                   >>  41 //
                                                   >>  42 // ------------------------------------------------------------
                                                   >>  43 //
 32 #include "G4ParticleChangeForLoss.hh"              44 #include "G4ParticleChangeForLoss.hh"
 33 #include "G4SystemOfUnits.hh"                      45 #include "G4SystemOfUnits.hh"
                                                   >>  46 #include "G4Track.hh"
                                                   >>  47 #include "G4Step.hh"
                                                   >>  48 #include "G4DynamicParticle.hh"
 34 #include "G4ExceptionSeverity.hh"                  49 #include "G4ExceptionSeverity.hh"
                                                   >>  50 //#include "G4VelocityTable.hh"
 35                                                    51 
 36 // ------------------------------------------- << 
 37 G4ParticleChangeForLoss::G4ParticleChangeForLo     52 G4ParticleChangeForLoss::G4ParticleChangeForLoss()
                                                   >>  53   : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.),
                                                   >>  54     lowEnergyLimit(1.0*eV), currentCharge(0.)
 38 {                                                  55 {
 39   // Disable flag that is enabled in G4VPartic <<  56   theSteppingControlFlag = NormalCondition;
 40   debugFlag = false;                               57   debugFlag = false;
 41   SetNumberOfSecondaries(1);                   <<  58 #ifdef G4VERBOSE
                                                   >>  59   if (verboseLevel>2) {
                                                   >>  60     G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl;
                                                   >>  61   }
                                                   >>  62 #endif
                                                   >>  63 }
                                                   >>  64 
                                                   >>  65 G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
                                                   >>  66 {
                                                   >>  67 #ifdef G4VERBOSE
                                                   >>  68   if (verboseLevel>2) {
                                                   >>  69     G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl;
                                                   >>  70   }
                                                   >>  71 #endif
                                                   >>  72 }
                                                   >>  73 
                                                   >>  74 G4ParticleChangeForLoss::
                                                   >>  75 G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right)
                                                   >>  76   : G4VParticleChange(right)
                                                   >>  77 {
                                                   >>  78   if (verboseLevel>1) {
                                                   >>  79     G4cout << "G4ParticleChangeForLoss::  copy constructor is called " << G4endl;
                                                   >>  80   }
                                                   >>  81   currentTrack = right.currentTrack;
                                                   >>  82   proposedKinEnergy = right.proposedKinEnergy;
                                                   >>  83   lowEnergyLimit = right.lowEnergyLimit;
                                                   >>  84   currentCharge = right.currentCharge;
                                                   >>  85   proposedMomentumDirection = right.proposedMomentumDirection;
 42 }                                                  86 }
 43                                                    87 
 44 // ------------------------------------------- <<  88 // assignment operator
                                                   >>  89 G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=(
                                                   >>  90                                    const G4ParticleChangeForLoss &right)
                                                   >>  91 {
                                                   >>  92 #ifdef G4VERBOSE
                                                   >>  93   if (verboseLevel>1) {
                                                   >>  94     G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl;
                                                   >>  95   }
                                                   >>  96 #endif
                                                   >>  97 
                                                   >>  98   if (this != &right) {
                                                   >>  99     if (theNumberOfSecondaries>0) {
                                                   >> 100 #ifdef G4VERBOSE
                                                   >> 101       if (verboseLevel>0) {
                                                   >> 102   G4cout << "G4ParticleChangeForLoss: assignment operator Warning  ";
                                                   >> 103   G4cout << "theListOfSecondaries is not empty ";
                                                   >> 104       }
                                                   >> 105 #endif
                                                   >> 106        for (G4int index= 0; index<theNumberOfSecondaries; index++){
                                                   >> 107    if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
                                                   >> 108        }
                                                   >> 109     }
                                                   >> 110     delete theListOfSecondaries; 
                                                   >> 111     theListOfSecondaries =  new G4TrackFastVector();
                                                   >> 112     theNumberOfSecondaries = right.theNumberOfSecondaries;
                                                   >> 113     for (G4int index = 0; index<theNumberOfSecondaries; index++){
                                                   >> 114       G4Track* newTrack =  new G4Track(*((*right.theListOfSecondaries)[index] ));
                                                   >> 115       theListOfSecondaries->SetElement(index, newTrack);          }
                                                   >> 116 
                                                   >> 117     theStatusChange = right.theStatusChange;
                                                   >> 118     theLocalEnergyDeposit = right.theLocalEnergyDeposit;
                                                   >> 119     theSteppingControlFlag = right.theSteppingControlFlag;
                                                   >> 120     theParentWeight = right.theParentWeight;
                                                   >> 121     isParentWeightProposed = right.isParentWeightProposed;
                                                   >> 122     fSetSecondaryWeightByProcess = right.fSetSecondaryWeightByProcess;
                                                   >> 123 
                                                   >> 124     currentTrack = right.currentTrack;
                                                   >> 125     proposedKinEnergy = right.proposedKinEnergy;
                                                   >> 126     currentCharge = right.currentCharge;
                                                   >> 127     proposedMomentumDirection = right.proposedMomentumDirection;
                                                   >> 128   }
                                                   >> 129   return *this;
                                                   >> 130 }
                                                   >> 131 
                                                   >> 132 //----------------------------------------------------------------
                                                   >> 133 // methods for printing messages
                                                   >> 134 //
                                                   >> 135 
 45 void G4ParticleChangeForLoss::DumpInfo() const    136 void G4ParticleChangeForLoss::DumpInfo() const
 46 {                                                 137 {
 47   // use base-class DumpInfo                   << 138 // use base-class DumpInfo
 48   G4VParticleChange::DumpInfo();                  139   G4VParticleChange::DumpInfo();
 49                                                   140 
 50   G4long oldprc = G4cout.precision(8);         << 141   G4int oldprc = G4cout.precision(3);
 51   G4cout << "      --------------------------- << 142   G4cout << "        Charge (eplus)   : "
 52   G4cout << "        G4ParticleChangeForLoss p << 143        << std::setw(20) << currentCharge/eplus
 53   G4cout << "        Charge (eplus)   : " << s << 144        << G4endl;
 54          << currentCharge / eplus << G4endl;   << 145   G4cout << "        Kinetic Energy (MeV): "
 55   G4cout << "        Kinetic Energy (MeV): " < << 146        << std::setw(20) << proposedKinEnergy/MeV
 56          << proposedKinEnergy / MeV << G4endl; << 147        << G4endl;
 57   G4cout << "        Momentum Direct - x : " < << 148   G4cout << "        Momentum Direct - x : "
 58          << proposedMomentumDirection.x() << G << 149        << std::setw(20) << proposedMomentumDirection.x()
 59   G4cout << "        Momentum Direct - y : " < << 150        << G4endl;
 60          << proposedMomentumDirection.y() << G << 151   G4cout << "        Momentum Direct - y : "
 61   G4cout << "        Momentum Direct - z : " < << 152        << std::setw(20) << proposedMomentumDirection.y()
 62          << proposedMomentumDirection.z() << G << 153        << G4endl;
                                                   >> 154   G4cout << "        Momentum Direct - z : "
                                                   >> 155        << std::setw(20) << proposedMomentumDirection.z()
                                                   >> 156        << G4endl;
 63   G4cout.precision(oldprc);                       157   G4cout.precision(oldprc);
 64 }                                                 158 }
 65                                                   159 
 66 // ------------------------------------------- << 160 G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
                                                   >> 161 {
                                                   >> 162   G4bool    itsOK = true;
                                                   >> 163   G4bool    exitWithError = false;
                                                   >> 164 
                                                   >> 165   G4double  accuracy;
                                                   >> 166 
                                                   >> 167   // Energy should not be lager than initial value
                                                   >> 168   accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
                                                   >> 169   if (accuracy > accuracyForWarning) {
                                                   >> 170     itsOK = false;
                                                   >> 171     exitWithError = (accuracy > accuracyForException);
                                                   >> 172 #ifdef G4VERBOSE
                                                   >> 173     G4cout << "G4ParticleChangeForLoss::CheckIt: ";
                                                   >> 174     G4cout << "KinEnergy become larger than the initial value!" 
                                                   >> 175      << "  Difference:  " << accuracy  << "[MeV] " <<G4endl;
                                                   >> 176     G4cout << aTrack.GetDefinition()->GetParticleName()
                                                   >> 177      << " E=" << aTrack.GetKineticEnergy()/MeV
                                                   >> 178      << " pos=" << aTrack.GetPosition().x()/m
                                                   >> 179      << ", " << aTrack.GetPosition().y()/m
                                                   >> 180      << ", " << aTrack.GetPosition().z()/m
                                                   >> 181      <<G4endl;
                                                   >> 182 #endif
                                                   >> 183   }
                                                   >> 184 
                                                   >> 185   // dump out information of this particle change
                                                   >> 186 #ifdef G4VERBOSE
                                                   >> 187   if (!itsOK) DumpInfo();
                                                   >> 188 #endif
                                                   >> 189 
                                                   >> 190   // Exit with error
                                                   >> 191   if (exitWithError) {
                                                   >> 192     G4Exception("G4ParticleChangeForLoss::CheckIt",
                                                   >> 193     "TRACK004", EventMustBeAborted,
                                                   >> 194     "energy was  illegal");
                                                   >> 195   }
                                                   >> 196 
                                                   >> 197   //correction
                                                   >> 198   if (!itsOK) {
                                                   >> 199     proposedKinEnergy = aTrack.GetKineticEnergy();
                                                   >> 200   }
                                                   >> 201 
                                                   >> 202   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
                                                   >> 203   return itsOK;
                                                   >> 204 }
                                                   >> 205 
                                                   >> 206 //----------------------------------------------------------------
                                                   >> 207 // methods for updating G4Step
                                                   >> 208 //
                                                   >> 209 
 67 G4Step* G4ParticleChangeForLoss::UpdateStepFor    210 G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep)
 68 {                                                 211 {
 69   const G4StepPoint* pPreStepPoint = pStep->Ge << 
 70   G4StepPoint* pPostStepPoint = pStep->GetPost    212   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 213   G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint();
                                                   >> 214   G4Track* pTrack = pStep->GetTrack();
 71                                                   215 
 72   // accumulate change of the kinetic energy      216   // accumulate change of the kinetic energy
 73   G4double preKinEnergy = pPreStepPoint->GetKi    217   G4double preKinEnergy = pPreStepPoint->GetKineticEnergy();
 74   G4double kinEnergy =                         << 218   G4double kinEnergy = pPostStepPoint->GetKineticEnergy() +
 75     pPostStepPoint->GetKineticEnergy() + (prop << 219     (proposedKinEnergy - preKinEnergy);
 76                                                   220 
 77   pPostStepPoint->SetCharge(currentCharge);    << 221   // update kinetic energy and charge
 78                                                << 222   if (kinEnergy < lowEnergyLimit) {
 79   // calculate velocity                        << 223     theLocalEnergyDeposit += kinEnergy;
 80   if(kinEnergy > 0.0)                          << 224     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);             225     pPostStepPoint->SetVelocity(0.0);
                                                   >> 226   } else {
                                                   >> 227     pPostStepPoint->SetCharge( currentCharge );
                                                   >> 228     // calculate velocity
                                                   >> 229     pTrack->SetKineticEnergy(kinEnergy); 
                                                   >> 230     pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
                                                   >> 231     pTrack->SetKineticEnergy(preKinEnergy); 
 91   }                                               232   }
                                                   >> 233   pPostStepPoint->SetKineticEnergy( kinEnergy );
 92                                                   234 
 93   if(isParentWeightProposed)                   << 235   if (isParentWeightProposed ){
 94   {                                            << 236     pPostStepPoint->SetWeight( theParentWeight );
 95     pPostStepPoint->SetWeight(theParentWeight) << 
 96   }                                               237   }
 97                                                   238 
 98   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 239   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
 99   pStep->AddNonIonizingEnergyDeposit(theNonIon << 240   pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
100   return pStep;                                   241   return pStep;
101 }                                                 242 }
102                                                   243 
103 // ------------------------------------------- << 
104 G4Step* G4ParticleChangeForLoss::UpdateStepFor    244 G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep)
105 {                                                 245 {
106   G4StepPoint* pPostStepPoint = pStep->GetPost    246   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 247   G4Track* pTrack = pStep->GetTrack();
107                                                   248 
108   pPostStepPoint->SetCharge(currentCharge);    << 249   pPostStepPoint->SetCharge( currentCharge );
109   pPostStepPoint->SetMomentumDirection(propose << 250   pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
110   if(proposedKinEnergy > 0.0)                  << 251   pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
111   {                                            << 252   pTrack->SetKineticEnergy( proposedKinEnergy );
112     pPostStepPoint->SetKineticEnergy(proposedK << 253   if(proposedKinEnergy > 0.0) {
113                                                << 254     pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
114     // assuming that mass>0, zero mass particl << 255   } else {
115     pPostStepPoint->SetVelocity(CLHEP::c_light << 
116   }                                            << 
117   else                                         << 
118   {                                            << 
119     pPostStepPoint->SetKineticEnergy(0.0);     << 
120     pPostStepPoint->SetVelocity(0.0);             256     pPostStepPoint->SetVelocity(0.0);
121   }                                               257   }
122   pPostStepPoint->SetPolarization(proposedPola << 258   pPostStepPoint->SetPolarization( proposedPolarization );
123                                                   259 
124   if(isParentWeightProposed)                   << 260   if (isParentWeightProposed ){
125   {                                            << 261     pPostStepPoint->SetWeight( theParentWeight );
126     pPostStepPoint->SetWeight(theParentWeight) << 
127   }                                               262   }
128                                                   263 
129   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 264   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
130   pStep->AddNonIonizingEnergyDeposit(theNonIon << 265   pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
131   return pStep;                                   266   return pStep;
132 }                                                 267 }
                                                   >> 268 
133                                                   269