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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 3.0)


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