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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 10.7.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 // G4ParticleChangeForTransport class implemen     26 // G4ParticleChangeForTransport class implementation
 27 //                                                 27 //
 28 // Author: Hisaya Kurashige, 10 May 1998           28 // Author: Hisaya Kurashige, 10 May 1998
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4ParticleChangeForTransport.hh"         31 #include "G4ParticleChangeForTransport.hh"
 32 #include "G4TouchableHandle.hh"                    32 #include "G4TouchableHandle.hh"
 33 #include "G4Track.hh"                              33 #include "G4Track.hh"
 34 #include "G4Step.hh"                               34 #include "G4Step.hh"
 35 #include "G4TrackFastVector.hh"                    35 #include "G4TrackFastVector.hh"
 36 #include "G4DynamicParticle.hh"                    36 #include "G4DynamicParticle.hh"
 37                                                    37 
 38 // -------------------------------------------     38 // --------------------------------------------------------------------
 39 G4ParticleChangeForTransport::G4ParticleChange <<  39 G4ParticleChangeForTransport::G4ParticleChangeForTransport()
                                                   >>  40   : G4ParticleChange()
 40 {                                                  41 {
 41   // Disable flag that is enabled in G4VPartic <<  42 }
 42   debugFlag = false;                           <<  43 
                                                   >>  44 // --------------------------------------------------------------------
                                                   >>  45 G4ParticleChangeForTransport::~G4ParticleChangeForTransport()
                                                   >>  46 {
                                                   >>  47 }
                                                   >>  48 
                                                   >>  49 // --------------------------------------------------------------------
                                                   >>  50 G4ParticleChangeForTransport::
                                                   >>  51 G4ParticleChangeForTransport(const G4ParticleChangeForTransport& r)
                                                   >>  52   : G4ParticleChange(r)
                                                   >>  53 {
                                                   >>  54   theTouchableHandle          = r.theTouchableHandle;
                                                   >>  55   isMomentumChanged           = r.isMomentumChanged;
                                                   >>  56   theMaterialChange           = r.theMaterialChange;
                                                   >>  57   theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
                                                   >>  58   theSensitiveDetectorChange  = r.theSensitiveDetectorChange;
                                                   >>  59 }
                                                   >>  60 
                                                   >>  61 // --------------------------------------------------------------------
                                                   >>  62 G4ParticleChangeForTransport&
                                                   >>  63 G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport& r)
                                                   >>  64 {
                                                   >>  65   if(this != &r)
                                                   >>  66   {
                                                   >>  67     theListOfSecondaries          = r.theListOfSecondaries;
                                                   >>  68     theSizeOftheListOfSecondaries = r.theSizeOftheListOfSecondaries;
                                                   >>  69     theNumberOfSecondaries        = r.theNumberOfSecondaries;
                                                   >>  70     theStatusChange               = r.theStatusChange;
                                                   >>  71     theTouchableHandle            = r.theTouchableHandle;
                                                   >>  72     theMaterialChange             = r.theMaterialChange;
                                                   >>  73     theMaterialCutsCoupleChange   = r.theMaterialCutsCoupleChange;
                                                   >>  74     theSensitiveDetectorChange    = r.theSensitiveDetectorChange;
                                                   >>  75     theMomentumDirectionChange    = r.theMomentumDirectionChange;
                                                   >>  76     thePolarizationChange         = r.thePolarizationChange;
                                                   >>  77     thePositionChange             = r.thePositionChange;
                                                   >>  78     theTimeChange                 = r.theTimeChange;
                                                   >>  79     theEnergyChange               = r.theEnergyChange;
                                                   >>  80     theVelocityChange             = r.theVelocityChange;
                                                   >>  81     theTrueStepLength             = r.theTrueStepLength;
                                                   >>  82     theLocalEnergyDeposit         = r.theLocalEnergyDeposit;
                                                   >>  83     theSteppingControlFlag        = r.theSteppingControlFlag;
                                                   >>  84   }
                                                   >>  85   return *this;
 43 }                                                  86 }
 44                                                    87 
 45 // -------------------------------------------     88 // --------------------------------------------------------------------
 46 G4Step* G4ParticleChangeForTransport::UpdateSt     89 G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
 47 {                                                  90 {
 48   // Update the G4Step specific attributes         91   // Update the G4Step specific attributes
 49   return UpdateStepInfo(pStep);                    92   return UpdateStepInfo(pStep);
 50 }                                                  93 }
 51                                                    94 
 52 // -------------------------------------------     95 // --------------------------------------------------------------------
 53 G4Step* G4ParticleChangeForTransport::UpdateSt     96 G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
 54 {                                                  97 {
 55   // Smooth curved tajectory representation: l     98   // Smooth curved tajectory representation: let the Step know about
 56   // the auxiliary trajectory points (jacek 30     99   // the auxiliary trajectory points (jacek 30/10/2002)
 57   pStep->SetPointerToVectorOfAuxiliaryPoints(f    100   pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
 58                                                   101 
 59   // Most of the code assumes that transportat << 102   // copy of G4ParticleChange::UpdateStepForAlongStep
 60   // so the pre- and post-step point are still << 103   // i.e. no effect for touchable
                                                   >> 104 
                                                   >> 105   // A physics process always calculates the final state of the
                                                   >> 106   // particle relative to the initial state at the beginning
                                                   >> 107   // of the Step, i.e., based on information of G4Track (or
                                                   >> 108   // equivalently the PreStepPoint).
                                                   >> 109   // So, the differences (delta) between these two states have to be
                                                   >> 110   // calculated and be accumulated in PostStepPoint.
                                                   >> 111 
                                                   >> 112   // Take note that the return type of GetMomentumChange is a
                                                   >> 113   // pointer to G4ThreeVector. Also it is a normalized
                                                   >> 114   // momentum vector.
                                                   >> 115 
 61   G4StepPoint* pPreStepPoint  = pStep->GetPreS    116   G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint();
 62   G4StepPoint* pPostStepPoint = pStep->GetPost    117   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
                                                   >> 118   G4Track* aTrack             = pStep->GetTrack();
                                                   >> 119   G4double mass               = aTrack->GetDynamicParticle()->GetMass();
                                                   >> 120 
                                                   >> 121   // update kinetic energy
                                                   >> 122   // now assume that no energy change in transportation
                                                   >> 123   // However it is not true in electric fields
                                                   >> 124   // Case for changing energy will be implemented in future
 63                                                   125 
 64   // update momentum direction and energy         126   // update momentum direction and energy
 65   if(isMomentumChanged)                           127   if(isMomentumChanged)
 66   {                                               128   {
 67     pPostStepPoint->SetMomentumDirection(theMo << 129     G4double energy;
 68     pPostStepPoint->SetKineticEnergy(theEnergy << 130     energy = pPostStepPoint->GetKineticEnergy() +
                                                   >> 131              (theEnergyChange - pPreStepPoint->GetKineticEnergy());
                                                   >> 132 
                                                   >> 133     // calculate new momentum
                                                   >> 134     G4ThreeVector pMomentum =
                                                   >> 135       pPostStepPoint->GetMomentum() +
                                                   >> 136       (CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass) -
                                                   >> 137        pPreStepPoint->GetMomentum());
                                                   >> 138     G4double tMomentum = pMomentum.mag();
                                                   >> 139     G4ThreeVector direction(1.0, 0.0, 0.0);
                                                   >> 140     if(tMomentum > 0.)
                                                   >> 141     {
                                                   >> 142       G4double inv_Momentum = 1.0 / tMomentum;
                                                   >> 143       direction             = pMomentum * inv_Momentum;
                                                   >> 144     }
                                                   >> 145     pPostStepPoint->SetMomentumDirection(direction);
                                                   >> 146     pPostStepPoint->SetKineticEnergy(energy);
 69   }                                               147   }
 70   if(isVelocityChanged)                           148   if(isVelocityChanged)
 71     pPostStepPoint->SetVelocity(theVelocityCha    149     pPostStepPoint->SetVelocity(theVelocityChange);
 72                                                   150 
                                                   >> 151   // stop case should not occur
                                                   >> 152   // pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
                                                   >> 153 
 73   // update polarization                          154   // update polarization
 74   pPostStepPoint->SetPolarization(thePolarizat << 155   pPostStepPoint->AddPolarization(thePolarizationChange -
                                                   >> 156                                   pPreStepPoint->GetPolarization());
 75                                                   157 
 76   // update position and time                     158   // update position and time
 77   pPostStepPoint->SetPosition(thePositionChang << 159   pPostStepPoint->AddPosition(thePositionChange - pPreStepPoint->GetPosition());
 78   pPostStepPoint->AddGlobalTime(theTimeChange     160   pPostStepPoint->AddGlobalTime(theTimeChange - pPreStepPoint->GetLocalTime());
 79   pPostStepPoint->AddLocalTime(theTimeChange -    161   pPostStepPoint->AddLocalTime(theTimeChange - pPreStepPoint->GetLocalTime());
 80   pPostStepPoint->SetProperTime(theProperTimeC << 162   pPostStepPoint->AddProperTime(theProperTimeChange -
                                                   >> 163                                 pPreStepPoint->GetProperTime());
 81                                                   164 
 82 #ifdef G4VERBOSE                                  165 #ifdef G4VERBOSE
 83   if(debugFlag) { CheckIt(*theCurrentTrack); } << 166   if(debugFlag) { CheckIt(*aTrack); }
 84 #endif                                            167 #endif
 85                                                   168 
 86   // Update the G4Step specific attributes        169   // Update the G4Step specific attributes
 87   pStep->SetStepLength( theTrueStepLength );   << 170   // pStep->SetStepLength( theTrueStepLength );
                                                   >> 171   // pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
 88   pStep->SetControlFlag(theSteppingControlFlag    172   pStep->SetControlFlag(theSteppingControlFlag);
 89                                                   173 
 90   return pStep;                                   174   return pStep;
 91 }                                                 175 }
 92                                                   176 
 93 // -------------------------------------------    177 // --------------------------------------------------------------------
 94 G4Step* G4ParticleChangeForTransport::UpdateSt    178 G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
 95 {                                                 179 {
 96   // A physics process always calculates the f    180   // A physics process always calculates the final state of the particle
 97                                                   181 
 98   // Change volume only if some kinetic energy    182   // Change volume only if some kinetic energy remains
 99   G4StepPoint* pPostStepPoint = pStep->GetPost    183   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
100   if(pPostStepPoint->GetKineticEnergy() > 0.0)    184   if(pPostStepPoint->GetKineticEnergy() > 0.0)
101   {                                               185   {
102     // update next touchable                      186     // update next touchable
103     // (touchable can be changed only at PostS    187     // (touchable can be changed only at PostStepDoIt)
104     pPostStepPoint->SetTouchableHandle(theTouc    188     pPostStepPoint->SetTouchableHandle(theTouchableHandle);
105                                                   189 
106     pPostStepPoint->SetMaterial(theMaterialCha    190     pPostStepPoint->SetMaterial(theMaterialChange);
107     pPostStepPoint->SetMaterialCutsCouple(theM    191     pPostStepPoint->SetMaterialCutsCouple(theMaterialCutsCoupleChange);
108     pPostStepPoint->SetSensitiveDetector(theSe    192     pPostStepPoint->SetSensitiveDetector(theSensitiveDetectorChange);
109   }                                               193   }
110   if(this->GetFirstStepInVolume())                194   if(this->GetFirstStepInVolume())
111   {                                               195   {
112     pStep->SetFirstStepFlag();                    196     pStep->SetFirstStepFlag();
113   }                                               197   }
114   else                                            198   else
115   {                                               199   {
116     pStep->ClearFirstStepFlag();                  200     pStep->ClearFirstStepFlag();
117   }                                               201   }
118   if(this->GetLastStepInVolume())                 202   if(this->GetLastStepInVolume())
119   {                                               203   {
120     pStep->SetLastStepFlag();                     204     pStep->SetLastStepFlag();
121   }                                               205   }
122   else                                            206   else
123   {                                               207   {
124     pStep->ClearLastStepFlag();                   208     pStep->ClearLastStepFlag();
125   }                                               209   }
126   // It used to call base class's method          210   // It used to call base class's method
127   //   - but this would copy uninitialised dat    211   //   - but this would copy uninitialised data members
128   // return G4ParticleChange::UpdateStepForPos    212   // return G4ParticleChange::UpdateStepForPostStep(pStep);
129                                                   213 
130   // Copying what the base class does would in    214   // Copying what the base class does would instead
131   //   - also not useful                          215   //   - also not useful
132   // return G4VParticleChange::UpdateStepInfo(    216   // return G4VParticleChange::UpdateStepInfo(pStep);
133                                                   217 
134   return pStep;                                   218   return pStep;
135 }                                                 219 }
136                                                   220 
137 // -------------------------------------------    221 // --------------------------------------------------------------------
138 void G4ParticleChangeForTransport::DumpInfo()     222 void G4ParticleChangeForTransport::DumpInfo() const
139 {                                                 223 {
140   // use base-class DumpInfo                      224   // use base-class DumpInfo
141   G4ParticleChange::DumpInfo();                   225   G4ParticleChange::DumpInfo();
                                                   >> 226 
                                                   >> 227   G4int oldprc = G4cout.precision(3);
142   G4cout << "        Touchable (pointer) : " <    228   G4cout << "        Touchable (pointer) : " << std::setw(20)
143          << theTouchableHandle() << G4endl;       229          << theTouchableHandle() << G4endl;
                                                   >> 230   G4cout.precision(oldprc);
144 }                                                 231 }
145                                                   232