Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/parameterisation/src/G4FastStep.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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 /processes/parameterisation/src/G4FastStep.cc (Version 11.3.0) and /processes/parameterisation/src/G4FastStep.cc (Version 11.1.2)


  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 //                                                 26 //
 27 //                                                 27 //
 28 //--------------------------------------------     28 //---------------------------------------------------------------
 29 //                                                 29 //
 30 //  G4FastStep.cc                                  30 //  G4FastStep.cc
 31 //                                                 31 //
 32 //  Description:                                   32 //  Description:
 33 //    Encapsulates a G4ParticleChange and insu     33 //    Encapsulates a G4ParticleChange and insure friendly interface
 34 //    methods to manage the primary/secondarie <<  34 //    methods to manage the primary/secondaries final state for 
 35 //    Fast Simulation Models.                      35 //    Fast Simulation Models.
 36 //                                                 36 //
 37 //  History:                                       37 //  History:
 38 //    Oct 97: Verderi && MoraDeFreitas - First     38 //    Oct 97: Verderi && MoraDeFreitas - First Implementation.
 39 //    Apr 98: MoraDeFreitas - G4FastStep becom     39 //    Apr 98: MoraDeFreitas - G4FastStep becomes the G4ParticleChange
 40 //                      for the Fast Simulatio     40 //                      for the Fast Simulation Process.
 41 //                                                 41 //
 42 //--------------------------------------------     42 //---------------------------------------------------------------
 43                                                    43 
 44 #include "G4FastStep.hh"                           44 #include "G4FastStep.hh"
 45                                                    45 
 46 #include "G4DynamicParticle.hh"                << 
 47 #include "G4Step.hh"                           << 
 48 #include "G4SystemOfUnits.hh"                      46 #include "G4SystemOfUnits.hh"
                                                   >>  47 #include "G4UnitsTable.hh"
 49 #include "G4Track.hh"                              48 #include "G4Track.hh"
                                                   >>  49 #include "G4Step.hh"
 50 #include "G4TrackFastVector.hh"                    50 #include "G4TrackFastVector.hh"
 51 #include "G4UnitsTable.hh"                     <<  51 #include "G4DynamicParticle.hh"
 52                                                    52 
 53 void G4FastStep::Initialize(const G4FastTrack&     53 void G4FastStep::Initialize(const G4FastTrack& fastTrack)
 54 {                                                  54 {
 55   // keeps the fastTrack reference                 55   // keeps the fastTrack reference
 56   fFastTrack = &fastTrack;                     <<  56   fFastTrack=&fastTrack;
 57                                                    57 
 58   // currentTrack will be used to Initialize t     58   // currentTrack will be used to Initialize the other data members
 59   const G4Track& currentTrack = *(fFastTrack->     59   const G4Track& currentTrack = *(fFastTrack->GetPrimaryTrack());
 60                                                    60 
 61   // use base class's method at first              61   // use base class's method at first
 62   G4VParticleChange::Initialize(currentTrack);     62   G4VParticleChange::Initialize(currentTrack);
 63                                                    63 
 64   // set Energy/Momentum etc. equal to those o     64   // set Energy/Momentum etc. equal to those of the parent particle
 65   const G4DynamicParticle* pParticle = current <<  65   const G4DynamicParticle*  pParticle = currentTrack.GetDynamicParticle();
 66   theEnergyChange = pParticle->GetKineticEnerg <<  66   theEnergyChange          = pParticle->GetKineticEnergy();
 67   theMomentumChange = pParticle->GetMomentumDi <<  67   theMomentumChange        = pParticle->GetMomentumDirection();
 68   thePolarizationChange = pParticle->GetPolari <<  68   thePolarizationChange    = pParticle->GetPolarization();
 69   theProperTimeChange = pParticle->GetProperTi <<  69   theProperTimeChange      = pParticle->GetProperTime();
 70                                                    70 
 71   // set Position/Time etc. equal to those of      71   // set Position/Time etc. equal to those of the parent track
 72   thePositionChange = currentTrack.GetPosition <<  72   thePositionChange      = currentTrack.GetPosition();
 73   theTimeChange = currentTrack.GetGlobalTime() <<  73   theTimeChange          = currentTrack.GetGlobalTime();
 74                                                    74 
 75   // switch off stepping hit invokation by def     75   // switch off stepping hit invokation by default:
 76   theSteppingControlFlag = AvoidHitInvocation;     76   theSteppingControlFlag = AvoidHitInvocation;
 77                                                    77 
 78   // event biasing weigth:                         78   // event biasing weigth:
 79   theWeightChange = currentTrack.GetWeight();  <<  79   theWeightChange        = currentTrack.GetWeight();
 80 }                                              <<  80 }  
 81                                                    81 
 82 //----------------------------------------         82 //----------------------------------------
 83 // -- Set the StopAndKilled signal                 83 // -- Set the StopAndKilled signal
 84 // -- and put kinetic energy to 0.0. in the        84 // -- and put kinetic energy to 0.0. in the
 85 // -- G4ParticleChange.                            85 // -- G4ParticleChange.
 86 //----------------------------------------         86 //----------------------------------------
 87 void G4FastStep::KillPrimaryTrack()                87 void G4FastStep::KillPrimaryTrack()
 88 {                                                  88 {
 89   ProposePrimaryTrackFinalKineticEnergy(0.);   <<  89   SetPrimaryTrackFinalKineticEnergy(0.) ;
 90   ProposeTrackStatus(fStopAndKill);            <<  90   ProposeTrackStatus(fStopAndKill) ;
 91 }                                                  91 }
 92                                                    92 
 93 //--------------------                             93 //--------------------
 94 //                                                 94 //
 95 //--------------------                             95 //--------------------
 96 void G4FastStep::ProposePrimaryTrackFinalPosit <<  96 void 
 97                                                <<  97 G4FastStep::
                                                   >>  98 ProposePrimaryTrackFinalPosition(const G4ThreeVector &position,
                                                   >>  99                                  G4bool localCoordinates)
 98 {                                                 100 {
 99   // Compute the position coordinate in global    101   // Compute the position coordinate in global
100   // reference system if needed ...               102   // reference system if needed ...
101   G4ThreeVector globalPosition = position;        103   G4ThreeVector globalPosition = position;
102   if (localCoordinates)                        << 104   if (localCoordinates) 
103     globalPosition = fFastTrack->GetInverseAff << 105     globalPosition = fFastTrack->GetInverseAffineTransformation()->
                                                   >> 106       TransformPoint(position);
104   // ...and feed the globalPosition:              107   // ...and feed the globalPosition:
105   thePositionChange = globalPosition;             108   thePositionChange = globalPosition;
106 }                                                 109 }
107                                                   110 
108 void G4FastStep::SetPrimaryTrackFinalPosition( << 111 void 
109                                                << 112 G4FastStep::
                                                   >> 113 SetPrimaryTrackFinalPosition(const G4ThreeVector &position,
                                                   >> 114                              G4bool localCoordinates)
110 {                                                 115 {
111   ProposePrimaryTrackFinalPosition(position, l    116   ProposePrimaryTrackFinalPosition(position, localCoordinates);
112 }                                                 117 }
113                                                   118 
114 //--------------------                            119 //--------------------
115 //                                                120 //
116 //--------------------                            121 //--------------------
117 void G4FastStep::ProposePrimaryTrackFinalMomen << 122 void 
118                                                << 123 G4FastStep::
                                                   >> 124 ProposePrimaryTrackFinalMomentumDirection(const G4ThreeVector &momentum,
                                                   >> 125                                           G4bool localCoordinates)
119 {                                                 126 {
120   // Compute the momentum in global reference     127   // Compute the momentum in global reference
121   // system if needed ...                         128   // system if needed ...
122   G4ThreeVector globalMomentum = momentum;        129   G4ThreeVector globalMomentum = momentum;
123   if (localCoordinates)                           130   if (localCoordinates)
124     globalMomentum = fFastTrack->GetInverseAff << 131     globalMomentum = fFastTrack->GetInverseAffineTransformation()->
                                                   >> 132       TransformAxis(momentum);
125   // ...and feed the globalMomentum (ensuring     133   // ...and feed the globalMomentum (ensuring unitarity)
126   SetMomentumChange(globalMomentum.unit());       134   SetMomentumChange(globalMomentum.unit());
127 }                                                 135 }
128                                                   136 
129 void G4FastStep::SetPrimaryTrackFinalMomentum( << 137 void 
130                                                << 138 G4FastStep::
                                                   >> 139 SetPrimaryTrackFinalMomentum(const G4ThreeVector &momentum,
                                                   >> 140                              G4bool localCoordinates)
131 {                                                 141 {
132   ProposePrimaryTrackFinalMomentumDirection(mo    142   ProposePrimaryTrackFinalMomentumDirection(momentum, localCoordinates);
133 }                                                 143 }
134                                                   144 
135 //--------------------                            145 //--------------------
136 //                                                146 //
137 //--------------------                            147 //--------------------
138 void G4FastStep::ProposePrimaryTrackFinalKinet << 148 void 
139                                                << 149 G4FastStep::
140                                                << 150 ProposePrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
                                                   >> 151                                                   const G4ThreeVector &direction,
                                                   >> 152                                                   G4bool localCoordinates)
141 {                                                 153 {
142   // Compute global direction if needed...        154   // Compute global direction if needed...
143   G4ThreeVector globalDirection = direction;      155   G4ThreeVector globalDirection = direction;
144   if (localCoordinates)                           156   if (localCoordinates)
145     globalDirection = fFastTrack->GetInverseAf << 157     globalDirection =fFastTrack->GetInverseAffineTransformation()-> 
                                                   >> 158       TransformAxis(direction);
146   // ...and feed the globalMomentum (ensuring     159   // ...and feed the globalMomentum (ensuring unitarity)
147   SetMomentumChange(globalDirection.unit());      160   SetMomentumChange(globalDirection.unit());
148   ProposePrimaryTrackFinalKineticEnergy(kineti << 161   SetPrimaryTrackFinalKineticEnergy(kineticEnergy);
149 }                                                 162 }
150                                                   163 
151 void G4FastStep::SetPrimaryTrackFinalKineticEn << 164 void 
152                                                << 165 G4FastStep::
153                                                << 166 SetPrimaryTrackFinalKineticEnergyAndDirection(G4double kineticEnergy,
                                                   >> 167                                               const G4ThreeVector &direction,
                                                   >> 168                                               G4bool localCoordinates)
154 {                                                 169 {
155   ProposePrimaryTrackFinalKineticEnergyAndDire    170   ProposePrimaryTrackFinalKineticEnergyAndDirection(kineticEnergy, direction, localCoordinates);
156 }                                                 171 }
157                                                   172 
158 //--------------------                            173 //--------------------
159 //                                                174 //
160 //--------------------                            175 //--------------------
161 void G4FastStep::ProposePrimaryTrackFinalPolar << 176 void 
162                                                << 177 G4FastStep::
                                                   >> 178 ProposePrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
                                                   >> 179                                      G4bool localCoordinates)
163 {                                                 180 {
164   // Compute polarization in global system if     181   // Compute polarization in global system if needed:
165   G4ThreeVector globalPolarization(polarizatio    182   G4ThreeVector globalPolarization(polarization);
166   if (localCoordinates)                           183   if (localCoordinates)
167     globalPolarization =                       << 184     globalPolarization = fFastTrack->GetInverseAffineTransformation()->
168       fFastTrack->GetInverseAffineTransformati << 185       TransformAxis(globalPolarization);  
169   // Feed the particle globalPolarization:        186   // Feed the particle globalPolarization:
170   thePolarizationChange = globalPolarization;     187   thePolarizationChange = globalPolarization;
171 }                                                 188 }
172                                                   189 
173 void G4FastStep::SetPrimaryTrackFinalPolarizat << 190 void 
174                                                << 191 G4FastStep::
                                                   >> 192 SetPrimaryTrackFinalPolarization(const G4ThreeVector &polarization,
                                                   >> 193                                  G4bool localCoordinates)
175 {                                                 194 {
176   ProposePrimaryTrackFinalPolarization(polariz    195   ProposePrimaryTrackFinalPolarization(polarization, localCoordinates);
177 }                                                 196 }
178                                                   197 
179 //--------------------                            198 //--------------------
180 //                                                199 //
181 //--------------------                            200 //--------------------
182 G4Track* G4FastStep::CreateSecondaryTrack(cons << 201 G4Track* G4FastStep::
183                                           G4Th << 202 CreateSecondaryTrack(const G4DynamicParticle& dynamics,
184                                           G4do << 203                      G4ThreeVector polarization,
                                                   >> 204                      G4ThreeVector position,
                                                   >> 205                      G4double time,
                                                   >> 206                      G4bool localCoordinates     )
185 {                                                 207 {
186   G4DynamicParticle dummyDynamics(dynamics);      208   G4DynamicParticle dummyDynamics(dynamics);
187                                                << 209   
188   // -----------------------------------------    210   // ------------------------------------------
189   // Add the polarization to the dummyDynamics    211   // Add the polarization to the dummyDynamics:
190   // -----------------------------------------    212   // ------------------------------------------
191   dummyDynamics.SetPolarization(polarization.x << 213   dummyDynamics.SetPolarization(polarization.x(),
192                                                << 214                                 polarization.y(),
                                                   >> 215                                 polarization.z());
                                                   >> 216   
193   return CreateSecondaryTrack(dummyDynamics, p    217   return CreateSecondaryTrack(dummyDynamics, position, time, localCoordinates);
194 }                                                 218 }
195                                                   219 
196 //--------------------                            220 //--------------------
197 //                                                221 //
198 //--------------------                            222 //--------------------
199 G4Track* G4FastStep::CreateSecondaryTrack(cons << 223 G4Track* G4FastStep::
200                                           G4do << 224 CreateSecondaryTrack(const G4DynamicParticle& dynamics,
                                                   >> 225                      G4ThreeVector position,
                                                   >> 226                      G4double time,
                                                   >> 227                      G4bool localCoordinates     )
201 {                                                 228 {
202   // ----------------------------------------     229   // ----------------------------------------
203   // Quantities in global coordinates system.     230   // Quantities in global coordinates system.
204   //                                           << 231   //  
205   // The allocated globalDynamics is deleted      232   // The allocated globalDynamics is deleted
206   // by the destructor of the G4Track.            233   // by the destructor of the G4Track.
207   // ----------------------------------------     234   // ----------------------------------------
208   auto globalDynamics = new G4DynamicParticle( << 235   G4DynamicParticle* globalDynamics =
                                                   >> 236     new G4DynamicParticle(dynamics);
209   G4ThreeVector globalPosition(position);         237   G4ThreeVector globalPosition(position);
210                                                << 238   
211   // -----------------------------------          239   // -----------------------------------
212   // Convert to global system if needed:          240   // Convert to global system if needed:
213   // -----------------------------------          241   // -----------------------------------
214   if (localCoordinates) {                      << 242   if (localCoordinates)
215     // -- Momentum Direction:                  << 243     {
216     globalDynamics->SetMomentumDirection(      << 244       // -- Momentum Direction:
217       fFastTrack->GetInverseAffineTransformati << 245       globalDynamics->SetMomentumDirection(fFastTrack->
218         globalDynamics->GetMomentumDirection() << 246                                            GetInverseAffineTransformation()->
219     // -- Polarization:                        << 247                                            TransformAxis(globalDynamics->
220     G4ThreeVector globalPolarization;          << 248                                                          GetMomentumDirection()));
221     globalPolarization = fFastTrack->GetInvers << 249       // -- Polarization:
222       globalDynamics->GetPolarization());      << 250       G4ThreeVector globalPolarization;
223     globalDynamics->SetPolarization(globalPola << 251       globalPolarization = fFastTrack->GetInverseAffineTransformation()->
224                                     globalPola << 252         TransformAxis(globalDynamics->GetPolarization());
225                                                << 253       globalDynamics->SetPolarization(
226     // -- Position:                            << 254                                       globalPolarization.x(),
227     globalPosition = fFastTrack->GetInverseAff << 255                                       globalPolarization.y(),
228   }                                            << 256                                       globalPolarization.z()
229                                                << 257                                       );
                                                   >> 258       
                                                   >> 259       // -- Position:
                                                   >> 260       globalPosition = fFastTrack->GetInverseAffineTransformation()->
                                                   >> 261         TransformPoint(globalPosition);
                                                   >> 262     }
                                                   >> 263   
230   //-------------------------------------         264   //-------------------------------------
231   // Create the G4Track of the secondary:         265   // Create the G4Track of the secondary:
232   //-------------------------------------         266   //-------------------------------------
233   auto secondary = new G4Track(globalDynamics, << 267   G4Track* secondary = new G4Track(
234                                                << 268                                    globalDynamics,
                                                   >> 269                                    time,
                                                   >> 270                                    globalPosition
                                                   >> 271                                    );
                                                   >> 272   
235   //-------------------------------               273   //-------------------------------
236   // and feed the changes:                        274   // and feed the changes:
237   //-------------------------------               275   //-------------------------------
238   AddSecondary(secondary);                        276   AddSecondary(secondary);
239                                                << 277   
240   //--------------------------------------        278   //--------------------------------------
241   // returns the pointer on the secondary:        279   // returns the pointer on the secondary:
242   //--------------------------------------        280   //--------------------------------------
243   return secondary;                               281   return secondary;
244 }                                                 282 }
245                                                   283 
246 // G4FastStep should never be Initialized in t    284 // G4FastStep should never be Initialized in this way
247 // but we must define it to avoid warnings.       285 // but we must define it to avoid warnings.
248 void G4FastStep::Initialize(const G4Track&)       286 void G4FastStep::Initialize(const G4Track&)
249 {                                                 287 {
250   G4ExceptionDescription tellWhatIsWrong;      << 288   G4ExceptionDescription  tellWhatIsWrong;
251   tellWhatIsWrong << "G4FastStep can be initia << 289   tellWhatIsWrong << "G4FastStep can be initialised only through G4FastTrack."
252   G4Exception("G4FastStep::Initialize(const G4 << 290       << G4endl;
253               tellWhatIsWrong);                << 291   G4Exception("G4FastStep::Initialize(const G4Track&)",
                                                   >> 292         "FastSim005",
                                                   >> 293         FatalException,
                                                   >> 294         tellWhatIsWrong);
                                                   >> 295 }
                                                   >> 296 
                                                   >> 297 G4FastStep::G4FastStep()
                                                   >> 298   : G4VParticleChange()
                                                   >> 299 {
                                                   >> 300   if (verboseLevel>2)
                                                   >> 301   {
                                                   >> 302     G4cerr << "G4FastStep::G4FastStep()" << G4endl;
                                                   >> 303   }
                                                   >> 304 }
                                                   >> 305 
                                                   >> 306 G4FastStep::~G4FastStep() 
                                                   >> 307 {
                                                   >> 308   if (verboseLevel>2)
                                                   >> 309   {
                                                   >> 310     G4cerr << "G4FastStep::~G4FastStep()" << G4endl;
                                                   >> 311   }
254 }                                                 312 }
255                                                   313 
256 //--------------------------------------------    314 //----------------------------------------------------------------
257 // methods for updating G4Step                 << 315 // methods for updating G4Step 
258 //                                                316 //
259                                                   317 
260 G4Step* G4FastStep::UpdateStepForPostStep(G4St    318 G4Step* G4FastStep::UpdateStepForPostStep(G4Step* pStep)
261 {                                              << 319 { 
262   // A physics process always calculates the f    320   // A physics process always calculates the final state of the particle
263                                                   321 
264   // Take note that the return type of GetMome    322   // Take note that the return type of GetMomentumChange is a
265   // pointer to G4ParticleMometum. Also it is  << 323   // pointer to G4ParticleMometum. Also it is a normalized 
266   // momentum vector.                             324   // momentum vector.
267                                                   325 
268   //  G4StepPoint* pPreStepPoint  = pStep->Get << 326   //  G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint(); 
269   G4StepPoint* pPostStepPoint = pStep->GetPost << 327   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 
270   G4Track* aTrack = pStep->GetTrack();         << 328   G4Track*     aTrack  = pStep->GetTrack();
271   //  G4double     mass = aTrack->GetDynamicPa    329   //  G4double     mass = aTrack->GetDynamicParticle()->GetMass();
272                                                << 330  
273   // update kinetic energy and momentum direct    331   // update kinetic energy and momentum direction
274   pPostStepPoint->SetMomentumDirection(theMome    332   pPostStepPoint->SetMomentumDirection(theMomentumChange);
275   pPostStepPoint->SetKineticEnergy(theEnergyCh << 333   pPostStepPoint->SetKineticEnergy( theEnergyChange );
276                                                << 
277   // update polarization                       << 
278   pPostStepPoint->SetPolarization(thePolarizat << 
279                                                   334 
                                                   >> 335    // update polarization
                                                   >> 336   pPostStepPoint->SetPolarization( thePolarizationChange );
                                                   >> 337       
280   // update position and time                     338   // update position and time
281   pPostStepPoint->SetPosition(thePositionChang << 339   pPostStepPoint->SetPosition( thePositionChange  );
282   pPostStepPoint->SetGlobalTime(theTimeChange) << 340   pPostStepPoint->SetGlobalTime( theTimeChange  );
283   pPostStepPoint->AddLocalTime(theTimeChange - << 341   pPostStepPoint->AddLocalTime( theTimeChange 
284   pPostStepPoint->SetProperTime(theProperTimeC << 342                                  - aTrack->GetGlobalTime());
                                                   >> 343   pPostStepPoint->SetProperTime( theProperTimeChange  );
285                                                   344 
286   // update weight                                345   // update weight
287   pPostStepPoint->SetWeight(theWeightChange);  << 346   pPostStepPoint->SetWeight( theWeightChange );
288                                                   347 
289   if (debugFlag) CheckIt(*aTrack);                348   if (debugFlag) CheckIt(*aTrack);
290                                                   349 
291   //  Update the G4Step specific attributes    << 350   
                                                   >> 351   //  Update the G4Step specific attributes 
292   return UpdateStepInfo(pStep);                   352   return UpdateStepInfo(pStep);
293 }                                                 353 }
294                                                   354 
295 G4Step* G4FastStep::UpdateStepForAtRest(G4Step    355 G4Step* G4FastStep::UpdateStepForAtRest(G4Step* pStep)
296 {                                              << 356 { 
297   // A physics process always calculates the f    357   // A physics process always calculates the final state of the particle
298                                                   358 
299   // G4StepPoint* pPreStepPoint  = pStep->GetP << 359   // G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint(); 
300   G4StepPoint* pPostStepPoint = pStep->GetPost << 360   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 
301   G4Track* aTrack = pStep->GetTrack();         << 361   G4Track*     aTrack  = pStep->GetTrack();
302   // G4double     mass = aTrack->GetDynamicPar    362   // G4double     mass = aTrack->GetDynamicParticle()->GetMass();
303                                                << 363  
304   // update kinetic energy and momentum direct    364   // update kinetic energy and momentum direction
305   pPostStepPoint->SetMomentumDirection(theMome    365   pPostStepPoint->SetMomentumDirection(theMomentumChange);
306   pPostStepPoint->SetKineticEnergy(theEnergyCh << 366   pPostStepPoint->SetKineticEnergy( theEnergyChange );
307                                                   367 
308   // update polarization                          368   // update polarization
309   pPostStepPoint->SetPolarization(thePolarizat << 369   pPostStepPoint->SetPolarization( thePolarizationChange );
310                                                << 370       
311   // update position and time                     371   // update position and time
312   pPostStepPoint->SetPosition(thePositionChang << 372   pPostStepPoint->SetPosition( thePositionChange  );
313   pPostStepPoint->SetGlobalTime(theTimeChange) << 373   pPostStepPoint->SetGlobalTime( theTimeChange  );
314   pPostStepPoint->AddLocalTime(theTimeChange - << 374   pPostStepPoint->AddLocalTime( theTimeChange 
315   pPostStepPoint->SetProperTime(theProperTimeC << 375                                  - aTrack->GetGlobalTime());
                                                   >> 376   pPostStepPoint->SetProperTime( theProperTimeChange  );
316                                                   377 
317   // update weight                                378   // update weight
318   pPostStepPoint->SetWeight(theWeightChange);  << 379   pPostStepPoint->SetWeight( theWeightChange );
319                                                   380 
320   if (debugFlag) CheckIt(*aTrack);                381   if (debugFlag) CheckIt(*aTrack);
321                                                   382 
322   //  Update the G4Step specific attributes    << 383   //  Update the G4Step specific attributes 
323   return UpdateStepInfo(pStep);                   384   return UpdateStepInfo(pStep);
324 }                                                 385 }
325                                                   386 
326 //--------------------------------------------    387 //----------------------------------------------------------------
327 // methods for printing messages               << 388 // methods for printing messages  
328 //                                                389 //
329                                                   390 
330 void G4FastStep::DumpInfo() const                 391 void G4FastStep::DumpInfo() const
331 {                                                 392 {
332   // use base-class DumpInfo                   << 393 // use base-class DumpInfo
333   G4VParticleChange::DumpInfo();                  394   G4VParticleChange::DumpInfo();
334                                                << 395   
335   G4cout << "        Position - x (mm)   : " < << 396   G4cout << "        Position - x (mm)   : " <<      G4BestUnit( thePositionChange.x(), "Length" ) << G4endl; 
336          << G4endl;                            << 397   G4cout << "        Position - y (mm)   : " <<      G4BestUnit( thePositionChange.y(), "Length" ) << G4endl;
337   G4cout << "        Position - y (mm)   : " < << 398   G4cout << "        Position - z (mm)   : " <<      G4BestUnit( thePositionChange.z(), "Length" ) << G4endl;   
338          << G4endl;                            << 399   G4cout << "        Time (ns)           : " <<      G4BestUnit( theTimeChange,         "Time"   ) << G4endl;
339   G4cout << "        Position - z (mm)   : " < << 400   G4cout << "        Proper Time (ns)    : " <<      G4BestUnit( theProperTimeChange,   "Time"   ) << G4endl;
340          << G4endl;                            << 
341   G4cout << "        Time (ns)           : " < << 
342   G4cout << "        Proper Time (ns)    : " < << 
343   G4long olprc = G4cout.precision(3);             401   G4long olprc = G4cout.precision(3);
344   G4cout << "        Momentum Direct - x : " <    402   G4cout << "        Momentum Direct - x : " << std::setw(20) << theMomentumChange.x() << G4endl;
345   G4cout << "        Momentum Direct - y : " <    403   G4cout << "        Momentum Direct - y : " << std::setw(20) << theMomentumChange.y() << G4endl;
346   G4cout << "        Momentum Direct - z : " <    404   G4cout << "        Momentum Direct - z : " << std::setw(20) << theMomentumChange.z() << G4endl;
347   G4cout.precision(olprc);                        405   G4cout.precision(olprc);
348   G4cout << "        Kinetic Energy (MeV): " < << 406   G4cout << "        Kinetic Energy (MeV): " <<      G4BestUnit( theEnergyChange,       "Energy" ) << G4endl;
349   G4cout.precision(3);                            407   G4cout.precision(3);
350   G4cout << "        Polarization - x    : " < << 408   G4cout << "        Polarization - x    : " << std::setw(20) << thePolarizationChange.x() << G4endl;
351          << G4endl;                            << 409   G4cout << "        Polarization - y    : " << std::setw(20) << thePolarizationChange.y() << G4endl;
352   G4cout << "        Polarization - y    : " < << 410   G4cout << "        Polarization - z    : " << std::setw(20) << thePolarizationChange.z() << G4endl;
353          << G4endl;                            << 
354   G4cout << "        Polarization - z    : " < << 
355          << G4endl;                            << 
356   G4cout.precision(olprc);                        411   G4cout.precision(olprc);
357 }                                                 412 }
358                                                   413 
359 G4bool G4FastStep::CheckIt(const G4Track& aTra    414 G4bool G4FastStep::CheckIt(const G4Track& aTrack)
360 {                                                 415 {
361   //                                              416   //
362   //      In the G4FastStep::CheckIt              417   //      In the G4FastStep::CheckIt
363   //      We only check a bit                     418   //      We only check a bit
364   //                                           << 419   //      
365   //      If the user violates the energy,        420   //      If the user violates the energy,
366   //      We don't care, we agree.                421   //      We don't care, we agree.
367   //                                              422   //
368   //      But for theMomentumDirectionChange,     423   //      But for theMomentumDirectionChange,
369   //      We do pay attention.                    424   //      We do pay attention.
370   //      And if too large is its range,          425   //      And if too large is its range,
371   //      We issue an Exception.                  426   //      We issue an Exception.
372   //                                              427   //
373   //                                              428   //
374   // It means, the G4FastStep::CheckIt issues     429   // It means, the G4FastStep::CheckIt issues an exception only for the
375   // theMomentumDirectionChange which should b    430   // theMomentumDirectionChange which should be an unit vector
376   // and it corrects it because it could cause    431   // and it corrects it because it could cause problems for the ulterior
377   // tracking.For the rest, only warning are i    432   // tracking.For the rest, only warning are issued.
378                                                   433 
379   G4bool itsOK = true;                         << 434   G4bool    itsOK = true;
380   G4bool exitWithError = false;                << 435   G4bool    exitWithError = false;
381   G4double accuracy;                           << 436   G4double  accuracy;
382                                                << 437   
383   // Energy should not be larger than the init    438   // Energy should not be larger than the initial value
384   accuracy = (theEnergyChange - aTrack.GetKine << 439   accuracy = ( theEnergyChange - aTrack.GetKineticEnergy())/MeV;
385   if (accuracy > GetAccuracyForWarning()) {    << 440   if (accuracy > GetAccuracyForWarning())
386     G4ExceptionDescription ed;                 << 441     {
387     ed << "The energy becomes larger than the  << 442       G4ExceptionDescription ed;
388        << G4endl;                              << 443       ed << "The energy becomes larger than the initial value, difference = " <<  accuracy << " MeV" << G4endl;
389     G4Exception("G4FastStep::CheckIt(const G4T << 444       G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
390     itsOK = false;                             << 445       "FastSim006",
391     if (accuracy > GetAccuracyForException())  << 446       JustWarning, ed);
392       exitWithError = true;                    << 447       itsOK = false;
                                                   >> 448       if (accuracy > GetAccuracyForException())  {exitWithError = true;}
393     }                                             449     }
394   }                                            << 450   
395                                                << 
396   G4bool itsOKforMomentum = true;                 451   G4bool itsOKforMomentum = true;
397   if (theEnergyChange > 0.) {                  << 452   if ( theEnergyChange >0.)
398     accuracy = std::abs(theMomentumChange.mag2 << 453     {
399     if (accuracy > GetAccuracyForWarning()) {  << 454       accuracy = std::abs(theMomentumChange.mag2()-1.0);
                                                   >> 455       if (accuracy > GetAccuracyForWarning())
                                                   >> 456   {
                                                   >> 457     G4ExceptionDescription ed;
                                                   >> 458     ed << "The Momentum Change is not a unit vector, difference = " <<  accuracy << G4endl;
                                                   >> 459     G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
                                                   >> 460           "FastSim007",
                                                   >> 461           JustWarning, ed);
                                                   >> 462     itsOK = itsOKforMomentum = false;
                                                   >> 463     if (accuracy > GetAccuracyForException())  {exitWithError = true;}
                                                   >> 464   }
                                                   >> 465     }
                                                   >> 466   
                                                   >> 467   accuracy = (aTrack.GetGlobalTime()- theTimeChange)/ns;  
                                                   >> 468   if (accuracy > GetAccuracyForWarning())
                                                   >> 469     {
400       G4ExceptionDescription ed;                  470       G4ExceptionDescription ed;
401       ed << "The Momentum Change is not a unit << 471       ed << "The global time is getting backward, difference = " <<  accuracy << " ns" << G4endl;
402       G4Exception("G4FastStep::CheckIt(const G << 472       G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
403       itsOK = itsOKforMomentum = false;        << 473       "FastSim008",
404       if (accuracy > GetAccuracyForException() << 474       JustWarning, ed);
405         exitWithError = true;                  << 475       itsOK = false;
406       }                                        << 
407     }                                             476     }
408   }                                            << 477   
409                                                << 478   accuracy = (aTrack.GetProperTime() - theProperTimeChange )/ns;
410   accuracy = (aTrack.GetGlobalTime() - theTime << 479   if (accuracy >  GetAccuracyForWarning())
411   if (accuracy > GetAccuracyForWarning()) {    << 480     {
412     G4ExceptionDescription ed;                 << 481       G4ExceptionDescription ed;
413     ed << "The global time is getting backward << 482       ed << "The proper time is getting backward, difference = " <<  accuracy << " ns" << G4endl;
414     G4Exception("G4FastStep::CheckIt(const G4T << 483       G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
415     itsOK = false;                             << 484       "FastSim009",
416   }                                            << 485       JustWarning, ed);
417                                                << 486       itsOK = false;
418   accuracy = (aTrack.GetProperTime() - theProp << 487     }
419   if (accuracy > GetAccuracyForWarning()) {    << 488   
420     G4ExceptionDescription ed;                 << 489   if (!itsOK)
421     ed << "The proper time is getting backward << 490     { 
422     G4Exception("G4FastStep::CheckIt(const G4T << 491       G4cout << "ERROR - G4FastStep::CheckIt() " << G4endl;
423     itsOK = false;                             << 492       G4cout << "        Pointer : " << this << G4endl ;
424   }                                            << 493       DumpInfo();
425                                                << 494     }
426   if (!itsOK) {                                << 495   
427     G4cout << "ERROR - G4FastStep::CheckIt() " << 
428     G4cout << "        Pointer : " << this <<  << 
429     DumpInfo();                                << 
430   }                                            << 
431                                                << 
432   // Exit with error                              496   // Exit with error
433   if (exitWithError) {                         << 497   if (exitWithError)
434     G4ExceptionDescription ed;                 << 498     {
435     ed << "An inaccuracy in G4FastStep is beyo << 499       G4ExceptionDescription ed;
436     G4Exception("G4FastStep::CheckIt(const G4T << 500       ed << "An inaccuracy in G4FastStep is beyond tolerance." << G4endl;
437   }                                            << 501       G4Exception("G4FastStep::CheckIt(const G4Track& aTrack)",
438                                                << 502       "FastSim010",
439   // correction for Momentum only.             << 503       FatalException, ed);
                                                   >> 504     }
                                                   >> 505   
                                                   >> 506   //correction for Momentum only.
440   if (!itsOKforMomentum) {                        507   if (!itsOKforMomentum) {
441     G4double vmag = theMomentumChange.mag();      508     G4double vmag = theMomentumChange.mag();
442     theMomentumChange = (1. / vmag) * theMomen << 509     theMomentumChange = (1./vmag)*theMomentumChange;
443   }                                               510   }
444                                                << 511   
445   itsOK = (itsOK) && G4VParticleChange::CheckI << 512   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack); 
446   return itsOK;                                   513   return itsOK;
447 }                                                 514 }
448                                                   515