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


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4ParticleChangeForTransport class implemen << 
 27 //                                                 23 //
 28 // Author: Hisaya Kurashige, 10 May 1998       <<  24 // $Id: G4ParticleChangeForTransport.cc,v 1.16 2004/01/20 15:29:41 vnivanch Exp $
 29 // ------------------------------------------- <<  25 // GEANT4 tag $Name: geant4-06-01 $
                                                   >>  26 //
                                                   >>  27 // 
                                                   >>  28 // --------------------------------------------------------------
                                                   >>  29 //  GEANT 4 class implementation file 
                                                   >>  30 //
                                                   >>  31 //  
                                                   >>  32 //
                                                   >>  33 // ------------------------------------------------------------
                                                   >>  34 //   Implemented for the new scheme                 10 May. 1998  H.Kurahige
                                                   >>  35 //   Correct tratment of fpNextTouchable            12 May. 1998  H.Kurashige
                                                   >>  36 //   Change to the next volume only if energy>0     19 Jan. 2004  V.Ivanchenko
                                                   >>  37 // --------------------------------------------------------------
 30                                                    38 
 31 #include "G4ParticleChangeForTransport.hh"         39 #include "G4ParticleChangeForTransport.hh"
 32 #include "G4TouchableHandle.hh"                    40 #include "G4TouchableHandle.hh"
 33 #include "G4Track.hh"                              41 #include "G4Track.hh"
 34 #include "G4Step.hh"                               42 #include "G4Step.hh"
 35 #include "G4TrackFastVector.hh"                    43 #include "G4TrackFastVector.hh"
 36 #include "G4DynamicParticle.hh"                    44 #include "G4DynamicParticle.hh"
 37                                                    45 
 38 // ------------------------------------------- <<  46 G4ParticleChangeForTransport::G4ParticleChangeForTransport():G4ParticleChange()
 39 G4ParticleChangeForTransport::G4ParticleChange <<  47 {
                                                   >>  48   if (verboseLevel>2) {
                                                   >>  49     G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() " << G4endl;
                                                   >>  50   }
                                                   >>  51 }
                                                   >>  52 
                                                   >>  53 G4ParticleChangeForTransport::~G4ParticleChangeForTransport() 
                                                   >>  54 {
                                                   >>  55   if (verboseLevel>2) {
                                                   >>  56     G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() " << G4endl;
                                                   >>  57   }
                                                   >>  58 }
                                                   >>  59 
                                                   >>  60 
                                                   >>  61 G4ParticleChangeForTransport::G4ParticleChangeForTransport(const G4ParticleChangeForTransport &right):G4ParticleChange(right)
                                                   >>  62 {
                                                   >>  63   if (verboseLevel>0) {
                                                   >>  64     G4cout << "G4ParticleChangeForTransport::  copy constructor is called " << G4endl;
                                                   >>  65   }
                                                   >>  66   theTouchableHandle = right.theTouchableHandle;
                                                   >>  67 }
                                                   >>  68 
                                                   >>  69 // assignemnt operator
                                                   >>  70 G4ParticleChangeForTransport & G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport &right)
 40 {                                                  71 {
 41   // Disable flag that is enabled in G4VPartic <<  72    if (verboseLevel>1) {
 42   debugFlag = false;                           <<  73     G4cout << "G4ParticleChangeForTransport:: assignment operator is called " << G4endl;
                                                   >>  74    }
                                                   >>  75    if (this != &right)
                                                   >>  76    {
                                                   >>  77       theListOfSecondaries = right.theListOfSecondaries;
                                                   >>  78       theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
                                                   >>  79       theNumberOfSecondaries = right.theNumberOfSecondaries;
                                                   >>  80       theStatusChange = right.theStatusChange;
                                                   >>  81       theTouchableHandle = right.theTouchableHandle;
                                                   >>  82       theMaterialChange = right.theMaterialChange;
                                                   >>  83       theMaterialCutsCoupleChange = right.theMaterialCutsCoupleChange;
                                                   >>  84       theMomentumDirectionChange = right.theMomentumDirectionChange;
                                                   >>  85       thePolarizationChange = right.thePolarizationChange;
                                                   >>  86       thePositionChange = right.thePositionChange;
                                                   >>  87       theTimeChange = right.theTimeChange;
                                                   >>  88       theEnergyChange = right.theEnergyChange;
                                                   >>  89       theTrueStepLength = right.theTrueStepLength;
                                                   >>  90       theLocalEnergyDeposit = right.theLocalEnergyDeposit;
                                                   >>  91       theSteppingControlFlag = right.theSteppingControlFlag;
                                                   >>  92    }
                                                   >>  93    return *this;
 43 }                                                  94 }
 44                                                    95 
 45 // ------------------------------------------- <<  96 //----------------------------------------------------------------
                                                   >>  97 // methods for updating G4Step
                                                   >>  98 //
                                                   >>  99 
 46 G4Step* G4ParticleChangeForTransport::UpdateSt    100 G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
 47 {                                                 101 {
 48   // Update the G4Step specific attributes     << 102   // Nothing happens for AtRestDoIt
                                                   >> 103   if (verboseLevel>0) {
                                                   >> 104     G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called" << G4endl;
                                                   >> 105     G4cout << " Nothing happens for this method " << G4endl;
                                                   >> 106   }
                                                   >> 107   //  Update the G4Step specific attributes
 49   return UpdateStepInfo(pStep);                   108   return UpdateStepInfo(pStep);
 50 }                                                 109 }
 51                                                   110 
 52 // ------------------------------------------- << 111 
 53 G4Step* G4ParticleChangeForTransport::UpdateSt    112 G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
 54 {                                                 113 {
 55   // Smooth curved tajectory representation: l    114   // Smooth curved tajectory representation: let the Step know about
 56   // the auxiliary trajectory points (jacek 30    115   // the auxiliary trajectory points (jacek 30/10/2002)
 57   pStep->SetPointerToVectorOfAuxiliaryPoints(f    116   pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
 58                                                   117 
 59   // Most of the code assumes that transportat << 118   // copy of G4ParticleChange::UpdateStepForAlongStep
 60   // so the pre- and post-step point are still << 119   //  i.e. no effect for touchable
                                                   >> 120 
                                                   >> 121   // A physics process always calculates the final state of the
                                                   >> 122   // particle relative to the initial state at the beginning
                                                   >> 123   // of the Step, i.e., based on information of G4Track (or
                                                   >> 124   // equivalently the PreStepPoint).
                                                   >> 125   // So, the differences (delta) between these two states have to be
                                                   >> 126   // calculated and be accumulated in PostStepPoint.
                                                   >> 127 
                                                   >> 128   // Take note that the return type of GetMomentumChange is a
                                                   >> 129   // pointer to G4ThreeVector. Also it is a normalized
                                                   >> 130   // momentum vector.
                                                   >> 131 
 61   G4StepPoint* pPreStepPoint  = pStep->GetPreS    132   G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint();
 62   G4StepPoint* pPostStepPoint = pStep->GetPost    133   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 134   G4Track*     aTrack  = pStep->GetTrack();
                                                   >> 135   G4double     mass = aTrack->GetDynamicParticle()->GetMass();
                                                   >> 136 
                                                   >> 137   // uodate kinetic energy
                                                   >> 138   //  now assume that no energy change in transportation
                                                   >> 139   //  However it is not true in electric fields
                                                   >> 140   //  Case for changing energy will be implemented in future
                                                   >> 141 
 63                                                   142 
 64   // update momentum direction and energy         143   // update momentum direction and energy
 65   if(isMomentumChanged)                        << 144   if (isMomentumChanged) {
 66   {                                            << 145     G4double energy;
 67     pPostStepPoint->SetMomentumDirection(theMo << 146     energy= pPostStepPoint->GetKineticEnergy()
 68     pPostStepPoint->SetKineticEnergy(theEnergy << 147                  + (theEnergyChange - pPreStepPoint->GetKineticEnergy());
                                                   >> 148 
                                                   >> 149     // calculate new momentum
                                                   >> 150     G4ThreeVector pMomentum =  pPostStepPoint->GetMomentum()
                                                   >> 151                      + ( CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass)
                                                   >> 152                     - pPreStepPoint->GetMomentum());
                                                   >> 153     G4double      tMomentum = pMomentum.mag();
                                                   >> 154     G4ThreeVector direction(1.0,0.0,0.0);
                                                   >> 155     if( tMomentum > 0. ){
                                                   >> 156       G4double  inv_Momentum= 1.0 / tMomentum;
                                                   >> 157       direction= pMomentum * inv_Momentum;
                                                   >> 158     }
                                                   >> 159     pPostStepPoint->SetMomentumDirection(direction);
                                                   >> 160     pPostStepPoint->SetKineticEnergy( energy );
 69   }                                               161   }
 70   if(isVelocityChanged)                        << 162 
 71     pPostStepPoint->SetVelocity(theVelocityCha << 163   // stop case should not occur
                                                   >> 164   //pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
                                                   >> 165 
 72                                                   166 
 73   // update polarization                          167   // update polarization
 74   pPostStepPoint->SetPolarization(thePolarizat << 168   pPostStepPoint->AddPolarization( thePolarizationChange
                                                   >> 169              - pPreStepPoint->GetPolarization());
 75                                                   170 
 76   // update position and time                     171   // update position and time
 77   pPostStepPoint->SetPosition(thePositionChang << 172   pPostStepPoint->AddPosition( thePositionChange
 78   pPostStepPoint->AddGlobalTime(theTimeChange  << 173              - pPreStepPoint->GetPosition() );
 79   pPostStepPoint->AddLocalTime(theTimeChange - << 174   pPostStepPoint->AddGlobalTime( theTimeChange
 80   pPostStepPoint->SetProperTime(theProperTimeC << 175          - pPreStepPoint->GetGlobalTime());
                                                   >> 176   pPostStepPoint->AddLocalTime( theTimeChange
                                                   >> 177          - pPreStepPoint->GetGlobalTime());
                                                   >> 178   pPostStepPoint->AddProperTime( theProperTimeChange
                                                   >> 179          - pPreStepPoint->GetProperTime());
 81                                                   180 
 82 #ifdef G4VERBOSE                                  181 #ifdef G4VERBOSE
 83   if(debugFlag) { CheckIt(*theCurrentTrack); } << 182   if (debugFlag) CheckIt(*aTrack);
 84 #endif                                            183 #endif
 85                                                   184 
 86   // Update the G4Step specific attributes     << 185   //  Update the G4Step specific attributes
 87   pStep->SetStepLength( theTrueStepLength );   << 186   //pStep->SetStepLength( theTrueStepLength );
 88   pStep->SetControlFlag(theSteppingControlFlag << 187   //  pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
 89                                                << 188   pStep->SetControlFlag( theSteppingControlFlag );
 90   return pStep;                                   189   return pStep;
                                                   >> 190   //  return UpdateStepInfo(pStep);
 91 }                                                 191 }
 92                                                   192 
 93 // ------------------------------------------- << 
 94 G4Step* G4ParticleChangeForTransport::UpdateSt    193 G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
 95 {                                                 194 {
 96   // A physics process always calculates the f    195   // A physics process always calculates the final state of the particle
 97                                                   196 
 98   // Change volume only if some kinetic energy << 197   // Change volume if any kinetic energy remanes
 99   G4StepPoint* pPostStepPoint = pStep->GetPost    198   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
100   if(pPostStepPoint->GetKineticEnergy() > 0.0) << 199   if(pPostStepPoint->GetKineticEnergy() > 0.0) {
101   {                                            << 200 
102     // update next touchable                      201     // update next touchable
103     // (touchable can be changed only at PostS    202     // (touchable can be changed only at PostStepDoIt)
104     pPostStepPoint->SetTouchableHandle(theTouc << 203     pPostStepPoint->SetTouchableHandle( theTouchableHandle );
105                                                   204 
106     pPostStepPoint->SetMaterial(theMaterialCha << 205     pPostStepPoint->SetMaterial( theMaterialChange );
107     pPostStepPoint->SetMaterialCutsCouple(theM << 206     pPostStepPoint->SetMaterialCutsCouple( theMaterialCutsCoupleChange );
108     pPostStepPoint->SetSensitiveDetector(theSe << 
109   }                                            << 
110   if(this->GetFirstStepInVolume())             << 
111   {                                            << 
112     pStep->SetFirstStepFlag();                 << 
113   }                                            << 
114   else                                         << 
115   {                                            << 
116     pStep->ClearFirstStepFlag();               << 
117   }                                            << 
118   if(this->GetLastStepInVolume())              << 
119   {                                            << 
120     pStep->SetLastStepFlag();                  << 
121   }                                            << 
122   else                                         << 
123   {                                            << 
124     pStep->ClearLastStepFlag();                << 
125   }                                               207   }
126   // It used to call base class's method          208   // It used to call base class's method
127   //   - but this would copy uninitialised dat    209   //   - but this would copy uninitialised data members
128   // return G4ParticleChange::UpdateStepForPos    210   // return G4ParticleChange::UpdateStepForPostStep(pStep);
129                                                   211 
130   // Copying what the base class does would in    212   // Copying what the base class does would instead
131   //   - also not useful                          213   //   - also not useful
132   // return G4VParticleChange::UpdateStepInfo(    214   // return G4VParticleChange::UpdateStepInfo(pStep);
133                                                   215 
134   return pStep;                                   216   return pStep;
135 }                                                 217 }
136                                                   218 
137 // ------------------------------------------- << 219 //----------------------------------------------------------------
                                                   >> 220 // methods for printing messages
                                                   >> 221 //
                                                   >> 222 
138 void G4ParticleChangeForTransport::DumpInfo()     223 void G4ParticleChangeForTransport::DumpInfo() const
139 {                                                 224 {
140   // use base-class DumpInfo                   << 225 // use base-class DumpInfo
141   G4ParticleChange::DumpInfo();                   226   G4ParticleChange::DumpInfo();
142   G4cout << "        Touchable (pointer) : " < << 227 
143          << theTouchableHandle() << G4endl;    << 228   G4cout.precision(3);
                                                   >> 229   G4cout << "        Touchable (pointer) : " 
                                                   >> 230        << std::setw(20) << theTouchableHandle()
                                                   >> 231        << G4endl; 
144 }                                                 232 }
                                                   >> 233 
                                                   >> 234 
                                                   >> 235 
                                                   >> 236 
                                                   >> 237 
                                                   >> 238 
                                                   >> 239 
                                                   >> 240 
145                                                   241