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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/G4ParticleChangeForGamma.cc (Version 11.3.0) and /track/src/G4ParticleChangeForGamma.cc (Version 10.2.p1)


  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 // G4ParticleChangeForGamma class implementati << 
 27 //                                                 26 //
 28 // Author: Hisaya Kurashige, 23 March 1998     <<  27 // $Id: G4ParticleChangeForGamma.cc 68795 2013-04-05 13:24:46Z gcosmo $
 29 // Revision: Vladimir Ivantchenko, 15 April 20 <<  28 //
 30 // ------------------------------------------- <<  29 //
 31                                                <<  30 // --------------------------------------------------------------
                                                   >>  31 //  GEANT 4 class implementation file
                                                   >>  32 //
                                                   >>  33 // ------------------------------------------------------------
                                                   >>  34 //   15 April 2005 V.Ivanchenko for gamma EM processes
                                                   >>  35 // --------------------------------------------------------------
                                                   >>  36 //
                                                   >>  37 //   Modified::
                                                   >>  38 //   28.08.06 V.Ivanchenko Add access to current track and polarizaion
                                                   >>  39 //
                                                   >>  40 // ------------------------------------------------------------
                                                   >>  41 //
 32 #include "G4ParticleChangeForGamma.hh"             42 #include "G4ParticleChangeForGamma.hh"
 33 #include "G4SystemOfUnits.hh"                      43 #include "G4SystemOfUnits.hh"
 34 #include "G4Track.hh"                              44 #include "G4Track.hh"
 35 #include "G4Step.hh"                               45 #include "G4Step.hh"
 36 #include "G4DynamicParticle.hh"                    46 #include "G4DynamicParticle.hh"
 37 #include "G4ExceptionSeverity.hh"                  47 #include "G4ExceptionSeverity.hh"
 38                                                    48 
 39 // ------------------------------------------- <<  49 G4ParticleChangeForGamma::G4ParticleChangeForGamma()
 40 G4ParticleChangeForGamma::G4ParticleChangeForG <<  50  : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.)
 41 {                                                  51 {
 42   // Disable flag to avoid check of each secon <<  52   theSteppingControlFlag = NormalCondition;
 43   debugFlag = false;                               53   debugFlag = false;
 44   SetNumberOfSecondaries(2);                   <<  54 #ifdef G4VERBOSE
                                                   >>  55   if (verboseLevel>2) {
                                                   >>  56     G4cout << "G4ParticleChangeForGamma::G4ParticleChangeForGamma() " << G4endl;
                                                   >>  57   }
                                                   >>  58 #endif
                                                   >>  59 }
                                                   >>  60 
                                                   >>  61 G4ParticleChangeForGamma::~G4ParticleChangeForGamma()
                                                   >>  62 {
                                                   >>  63 #ifdef G4VERBOSE
                                                   >>  64   if (verboseLevel>2) {
                                                   >>  65     G4cout << "G4ParticleChangeForGamma::~G4ParticleChangeForGamma() " << G4endl;
                                                   >>  66   }
                                                   >>  67 #endif
                                                   >>  68 }
                                                   >>  69 
                                                   >>  70 G4ParticleChangeForGamma::G4ParticleChangeForGamma(
                                                   >>  71              const G4ParticleChangeForGamma &right): G4VParticleChange(right)
                                                   >>  72 {
                                                   >>  73   if (verboseLevel>1) 
                                                   >>  74     G4cout << "G4ParticleChangeForGamma::  copy constructor is called " << G4endl;
                                                   >>  75   
                                                   >>  76   currentTrack = right.currentTrack;
                                                   >>  77   proposedKinEnergy = right.proposedKinEnergy;
                                                   >>  78   proposedMomentumDirection = right.proposedMomentumDirection;
                                                   >>  79   proposedPolarization = right.proposedPolarization;
                                                   >>  80 }
                                                   >>  81 
                                                   >>  82 // assignment operator
                                                   >>  83 G4ParticleChangeForGamma & G4ParticleChangeForGamma::operator=(
                                                   >>  84          const G4ParticleChangeForGamma &right)
                                                   >>  85 {
                                                   >>  86 #ifdef G4VERBOSE
                                                   >>  87   if (verboseLevel>1) 
                                                   >>  88     G4cout << "G4ParticleChangeForGamma:: assignment operator is called " << G4endl;
                                                   >>  89 #endif
                                                   >>  90   
                                                   >>  91   if (this != &right) {
                                                   >>  92      if (theNumberOfSecondaries>0) {
                                                   >>  93 #ifdef G4VERBOSE
                                                   >>  94        if (verboseLevel>0) {
                                                   >>  95    G4cout << "G4ParticleChangeForGamma: assignment operator Warning  ";
                                                   >>  96    G4cout << "theListOfSecondaries is not empty ";
                                                   >>  97        }
                                                   >>  98 #endif
                                                   >>  99        for (G4int index= 0; index<theNumberOfSecondaries; index++){
                                                   >> 100    if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
                                                   >> 101        }
                                                   >> 102      }
                                                   >> 103      delete theListOfSecondaries; 
                                                   >> 104     theListOfSecondaries =  new G4TrackFastVector();
                                                   >> 105     theNumberOfSecondaries = right.theNumberOfSecondaries;
                                                   >> 106     for (G4int index = 0; index<theNumberOfSecondaries; index++){
                                                   >> 107       G4Track* newTrack =  new G4Track(*((*right.theListOfSecondaries)[index] ));
                                                   >> 108       theListOfSecondaries->SetElement(index, newTrack);          }
                                                   >> 109  
                                                   >> 110     theStatusChange = right.theStatusChange;
                                                   >> 111     theLocalEnergyDeposit = right.theLocalEnergyDeposit;
                                                   >> 112     theSteppingControlFlag = right.theSteppingControlFlag;
                                                   >> 113     theParentWeight = right.theParentWeight;
                                                   >> 114 
                                                   >> 115     currentTrack = right.currentTrack;
                                                   >> 116     proposedKinEnergy = right.proposedKinEnergy;
                                                   >> 117     proposedMomentumDirection = right.proposedMomentumDirection;
                                                   >> 118     proposedPolarization = right.proposedPolarization;
                                                   >> 119   }
                                                   >> 120   return *this;
 45 }                                                 121 }
 46                                                   122 
 47 // ------------------------------------------- << 
 48 void G4ParticleChangeForGamma::AddSecondary(G4    123 void G4ParticleChangeForGamma::AddSecondary(G4DynamicParticle* aParticle)
 49 {                                                 124 {
 50   // create track                              << 125   //  create track
 51   G4Track* aTrack = new G4Track(aParticle, the << 126   G4Track* aTrack = new G4Track(aParticle, currentTrack->GetGlobalTime(),
 52                                 theCurrentTrac << 127                                            currentTrack->GetPosition());
 53                                                   128 
 54   // touchable handle is copied to keep the po << 129   //   Touchable handle is copied to keep the pointer
 55   aTrack->SetTouchableHandle(theCurrentTrack-> << 130   aTrack->SetTouchableHandle(currentTrack->GetTouchableHandle());
 56                                                   131 
 57   // add a secondary                           << 132   //  add a secondary
 58   G4VParticleChange::AddSecondary(aTrack);        133   G4VParticleChange::AddSecondary(aTrack);
 59 }                                                 134 }
 60                                                   135 
 61 // ------------------------------------------- << 136 //----------------------------------------------------------------
                                                   >> 137 // method for updating G4Step
                                                   >> 138 //
                                                   >> 139 
 62 G4Step* G4ParticleChangeForGamma::UpdateStepFo    140 G4Step* G4ParticleChangeForGamma::UpdateStepForAtRest(G4Step* pStep)
 63 {                                                 141 {
 64   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 142   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
 65   pStep->SetStepLength(0.0);                   << 143   pStep->SetStepLength( 0.0 );
 66                                                   144 
 67   if(isParentWeightProposed)                   << 145   if (isParentWeightProposed ){
 68   {                                            << 146     pStep->GetPostStepPoint()->SetWeight( theParentWeight );
 69     pStep->GetPostStepPoint()->SetWeight(thePa << 
 70   }                                               147   }
 71                                                   148 
 72   return pStep;                                   149   return pStep;
 73 }                                                 150 }
 74                                                   151 
 75 // ------------------------------------------- << 
 76 G4Step* G4ParticleChangeForGamma::UpdateStepFo    152 G4Step* G4ParticleChangeForGamma::UpdateStepForPostStep(G4Step* pStep)
 77 {                                                 153 {
 78   G4StepPoint* pPostStepPoint = pStep->GetPost    154   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 155   G4Track* pTrack = pStep->GetTrack();
 79                                                   156 
 80   pPostStepPoint->SetMomentumDirection(propose << 157   pPostStepPoint->SetKineticEnergy( proposedKinEnergy );
 81   pPostStepPoint->SetPolarization(proposedPola << 158   pPostStepPoint->SetMomentumDirection( proposedMomentumDirection );
                                                   >> 159   pPostStepPoint->SetPolarization( proposedPolarization );
 82                                                   160 
 83   // update velocity for scattering process an    161   // update velocity for scattering process and particles with mass
 84   if(proposedKinEnergy > 0.0)                  << 162   if(proposedKinEnergy > 0.0) { 
 85   {                                            << 163     if(pTrack->GetParticleDefinition()->GetPDGMass() > 0.0) {
 86     pPostStepPoint->SetKineticEnergy(proposedK << 164       pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
 87     G4double mass = theCurrentTrack->GetDefini << 
 88     G4double v = CLHEP::c_light;               << 
 89     if(mass > 0.0) {                           << 
 90       v *= std::sqrt(proposedKinEnergy*(propos << 
 91   (proposedKinEnergy + mass);                  << 
 92     }                                             165     }
 93     pPostStepPoint->SetVelocity(v);            << 166   } 
 94   }                                            << 
 95   else                                         << 
 96   {                                            << 
 97     pPostStepPoint->SetKineticEnergy(0.0);     << 
 98     pPostStepPoint->SetVelocity(0.0);          << 
 99   }                                            << 
100                                                   167 
101   if(isParentWeightProposed)                   << 168   if (isParentWeightProposed ){
102   {                                            << 169     pPostStepPoint->SetWeight( theParentWeight );
103     pPostStepPoint->SetWeight(theParentWeight) << 
104   }                                               170   }
105                                                << 171    
106   pStep->AddTotalEnergyDeposit(theLocalEnergyD << 172   pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
107   pStep->AddNonIonizingEnergyDeposit(theNonIon << 173   pStep->AddNonIonizingEnergyDeposit( theNonIonizingEnergyDeposit );
108   return pStep;                                   174   return pStep;
109 }                                                 175 }
110                                                   176 
111 // ------------------------------------------- << 177 //----------------------------------------------------------------
                                                   >> 178 // methods for printing messages
                                                   >> 179 //
                                                   >> 180 
112 void G4ParticleChangeForGamma::DumpInfo() cons    181 void G4ParticleChangeForGamma::DumpInfo() const
113 {                                                 182 {
114   // use base-class DumpInfo                   << 183 // use base-class DumpInfo
115   G4VParticleChange::DumpInfo();                  184   G4VParticleChange::DumpInfo();
116                                                   185 
117   G4long oldprc = G4cout.precision(8);         << 186   G4int oldprc = G4cout.precision(3);
118   G4cout << "      --------------------------- << 187   G4cout << "        Kinetic Energy (MeV): "
119   G4cout << "        G4ParticleChangeForGamma  << 188        << std::setw(20) << proposedKinEnergy/MeV
120   G4cout << "        Kinetic Energy (MeV): " < << 189        << G4endl;
121          << proposedKinEnergy / MeV << G4endl; << 190   G4cout << "        Momentum Direction: "
122   G4cout << "        Momentum Direction: " <<  << 191        << std::setw(20) << proposedMomentumDirection
123          << proposedMomentumDirection << G4end << 192        << G4endl;
124   G4cout << "        Polarization: " << std::s << 193   G4cout << "        Polarization: "
125          << G4endl;                            << 194        << std::setw(20) << proposedPolarization
                                                   >> 195        << G4endl;
126   G4cout.precision(oldprc);                       196   G4cout.precision(oldprc);
127 }                                                 197 }
128                                                   198 
                                                   >> 199 G4bool G4ParticleChangeForGamma::CheckIt(const G4Track& aTrack)
                                                   >> 200 {
                                                   >> 201   G4bool    itsOK = true;
                                                   >> 202   G4bool    exitWithError = false;
                                                   >> 203 
                                                   >> 204   G4double  accuracy;
                                                   >> 205 
                                                   >> 206   // Energy should not be lager than initial value
                                                   >> 207   accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
                                                   >> 208   if (accuracy > accuracyForWarning) {
                                                   >> 209     itsOK = false;
                                                   >> 210     exitWithError = (accuracy > accuracyForException);
                                                   >> 211 #ifdef G4VERBOSE
                                                   >> 212     G4cout << "G4ParticleChangeForGamma::CheckIt: ";
                                                   >> 213     G4cout << "KinEnergy become larger than the initial value!" 
                                                   >> 214      << "  Difference:  " << accuracy  << "[MeV] " <<G4endl;
                                                   >> 215     G4cout << aTrack.GetDefinition()->GetParticleName()
                                                   >> 216      << " E=" << aTrack.GetKineticEnergy()/MeV
                                                   >> 217      << " pos=" << aTrack.GetPosition().x()/m
                                                   >> 218      << ", " << aTrack.GetPosition().y()/m
                                                   >> 219      << ", " << aTrack.GetPosition().z()/m
                                                   >> 220      << G4endl;
                                                   >> 221 #endif
                                                   >> 222   }
                                                   >> 223 
                                                   >> 224   // dump out information of this particle change
                                                   >> 225 #ifdef G4VERBOSE
                                                   >> 226   if (!itsOK) DumpInfo();
                                                   >> 227 #endif
                                                   >> 228 
                                                   >> 229   // Exit with error
                                                   >> 230   if (exitWithError) {
                                                   >> 231     G4Exception("G4ParticleChangeForGamma::CheckIt",
                                                   >> 232     "TRACK004",EventMustBeAborted,
                                                   >> 233     "energy was  illegal");
                                                   >> 234   }
                                                   >> 235 
                                                   >> 236   //correction
                                                   >> 237   if (!itsOK) {
                                                   >> 238     proposedKinEnergy = aTrack.GetKineticEnergy();
                                                   >> 239   }
                                                   >> 240 
                                                   >> 241   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
                                                   >> 242   return itsOK;
                                                   >> 243 }
129                                                   244