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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.6)


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