Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/exoticphysics/monopole/src/G4MonopoleTransportation.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 /examples/extended/exoticphysics/monopole/src/G4MonopoleTransportation.cc (Version 11.3.0) and /examples/extended/exoticphysics/monopole/src/G4MonopoleTransportation.cc (Version 10.4.p3)


  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 /// \file exoticphysics/monopole/src/G4Monopol     26 /// \file exoticphysics/monopole/src/G4MonopoleTransportation.cc
 27 /// \brief Implementation of the G4MonopoleTra     27 /// \brief Implementation of the G4MonopoleTransportation class
 28 //                                                 28 //
                                                   >>  29 // $Id$
 29 //                                                 30 //
 30 //....oooOO0OOooo........oooOO0OOooo........oo     31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 31 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //                                                 33 //
 33 // This class is a process responsible for the <<  34 // This class is a process responsible for the transportation of 
 34 // magnetic monopoles, ie the geometrical prop <<  35 // magnetic monopoles, ie the geometrical propagation that encounters the 
 35 // geometrical sub-volumes of the detectors.       36 // geometrical sub-volumes of the detectors.
 36 //                                                 37 //
 37 // For monopoles, uses a different equation of     38 // For monopoles, uses a different equation of motion and ignores energy
 38 // conservation.                               <<  39 // conservation. 
 39 //                                                 40 //
 40                                                    41 
 41 // ===========================================     42 // =======================================================================
 42 // Created:  3 May 2010, J. Apostolakis, B. Bo     43 // Created:  3 May 2010, J. Apostolakis, B. Bozsogi
 43 // ===========================================     44 // =======================================================================
 44                                                    45 
 45 #include "G4MonopoleTransportation.hh"             46 #include "G4MonopoleTransportation.hh"
 46                                                <<  47 #include "G4ProductionCutsTable.hh"
 47 #include "DetectorConstruction.hh"             <<  48 #include "G4ParticleTable.hh"
 48                                                << 
 49 #include "G4ChordFinder.hh"                        49 #include "G4ChordFinder.hh"
                                                   >>  50 #include "G4SafetyHelper.hh"
 50 #include "G4FieldManagerStore.hh"                  51 #include "G4FieldManagerStore.hh"
 51 #include "G4Monopole.hh"                           52 #include "G4Monopole.hh"
 52 #include "G4ParticleTable.hh"                  << 
 53 #include "G4ProductionCutsTable.hh"            << 
 54 #include "G4RunManager.hh"                     << 
 55 #include "G4SafetyHelper.hh"                   << 
 56 #include "G4SystemOfUnits.hh"                  << 
 57 #include "G4TransportationProcessType.hh"          53 #include "G4TransportationProcessType.hh"
                                                   >>  54 #include "G4SystemOfUnits.hh"
                                                   >>  55 
                                                   >>  56 #include "G4RunManager.hh"
                                                   >>  57 #include "DetectorConstruction.hh"
 58                                                    58 
 59 class G4VSensitiveDetector;                        59 class G4VSensitiveDetector;
 60                                                    60 
 61 //....oooOO0OOooo........oooOO0OOooo........oo     61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 62                                                    62 
 63 G4MonopoleTransportation::G4MonopoleTransporta <<  63 G4MonopoleTransportation::G4MonopoleTransportation( const G4Monopole* mpl,
 64   : G4VProcess(G4String("MonopoleTransportatio <<  64                                                     G4int verb)
                                                   >>  65   : G4VProcess( G4String("MonopoleTransportation"), fTransportation ),
 65     fParticleDef(mpl),                             66     fParticleDef(mpl),
 66     fMagSetup(0),                                  67     fMagSetup(0),
 67     fLinearNavigator(0),                           68     fLinearNavigator(0),
 68     fFieldPropagator(0),                           69     fFieldPropagator(0),
 69     fParticleIsLooping(false),                 <<  70     fParticleIsLooping( false ),
 70     fPreviousSftOrigin(0., 0., 0.),            <<  71     fPreviousSftOrigin (0.,0.,0.),
 71     fPreviousSafety(0.0),                      <<  72     fPreviousSafety    ( 0.0 ),
 72     fThreshold_Warning_Energy(100 * MeV),      <<  73     fThreshold_Warning_Energy( 100 * MeV ),  
 73     fThreshold_Important_Energy(250 * MeV),    <<  74     fThreshold_Important_Energy( 250 * MeV ), 
 74     fThresholdTrials(10),                      <<  75     fThresholdTrials( 10 ), 
 75     // fUnimportant_Energy( 1 * MeV ),         <<  76     // fUnimportant_Energy( 1 * MeV ), 
 76     fNoLooperTrials(0),                            77     fNoLooperTrials(0),
 77     fSumEnergyKilled(0.0),                     <<  78     fSumEnergyKilled( 0.0 ), fMaxEnergyKilled( 0.0 ), 
 78     fMaxEnergyKilled(0.0),                     <<  79     fShortStepOptimisation(false),    // Old default: true (=fast short steps)
 79     fShortStepOptimisation(false),  // Old def <<  80     fpSafetyHelper(0)
 80     fpSafetyHelper(0),                         << 
 81     noCalls(0)                                 << 
 82 {                                                  81 {
 83   verboseLevel = verb;                             82   verboseLevel = verb;
 84                                                    83 
 85   // set Process Sub Type                          84   // set Process Sub Type
 86   SetProcessSubType(TRANSPORTATION);           <<  85   SetProcessSubType(TRANSPORTATION);  
 87                                                    86 
 88   // Do not finalize the G4MonopoleTransportat << 
 89   if (G4Threading::IsMasterThread() && G4Threa << 
 90     return;                                    << 
 91   }                                            << 
 92                                                    87 
 93   const DetectorConstruction* detector = stati <<  88 #ifdef G4MULTITHREADED
 94     G4RunManager::GetRunManager()->GetUserDete <<  89   // Do not finalize the G4MonopoleTransportation class 
                                                   >>  90   if (G4Threading::IsMasterThread())
                                                   >>  91     {
                                                   >>  92       return;
                                                   >>  93     }
                                                   >>  94 #endif
                                                   >>  95 
                                                   >>  96   const DetectorConstruction* detector = static_cast<const DetectorConstruction*>
                                                   >>  97                                  (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
 95                                                    98 
 96   fMagSetup = detector->GetMonopoleFieldSetup(     99   fMagSetup = detector->GetMonopoleFieldSetup();
                                                   >> 100   
                                                   >> 101   G4TransportationManager* transportMgr = G4TransportationManager::GetTransportationManager(); 
 97                                                   102 
 98   G4TransportationManager* transportMgr = G4Tr << 103   fLinearNavigator = transportMgr->GetNavigatorForTracking() ; 
 99                                                   104 
100   fLinearNavigator = transportMgr->GetNavigato << 105   // fGlobalFieldMgr = transportMgr->GetFieldManager() ;
101                                                   106 
102   fFieldPropagator = transportMgr->GetPropagat << 107   fFieldPropagator = transportMgr->GetPropagatorInField() ;
103   fpSafetyHelper = transportMgr->GetSafetyHelp << 108   fpSafetyHelper =   transportMgr->GetSafetyHelper();  
104                                                   109 
105   // New                                       << 110 // New 
106                                                   111 
107   // Cannot determine whether a field exists h    112   // Cannot determine whether a field exists here,
108   //  because it would only work if the field  << 113   //  because it would only work if the field manager has informed 
109   //  about the detector's field before this t << 114   //  about the detector's field before this transportation process 
110   //  is constructed.                             115   //  is constructed.
111   // Instead later the method DoesGlobalFieldE    116   // Instead later the method DoesGlobalFieldExist() is called
112   fCurrentTouchableHandle = nullptr;           << 
113                                                   117 
114   fEndGlobalTimeComputed = false;              << 118   static G4TouchableHandle nullTouchableHandle;  // Points to (G4VTouchable*) 0
                                                   >> 119   fCurrentTouchableHandle = nullTouchableHandle; 
                                                   >> 120 
                                                   >> 121   fEndGlobalTimeComputed  = false;
115   fCandidateEndGlobalTime = 0;                    122   fCandidateEndGlobalTime = 0;
116 }                                                 123 }
117                                                   124 
118 //....oooOO0OOooo........oooOO0OOooo........oo    125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119                                                   126 
120 G4MonopoleTransportation::~G4MonopoleTransport    127 G4MonopoleTransportation::~G4MonopoleTransportation()
121 {                                                 128 {
122   if ((verboseLevel > 0) && (fSumEnergyKilled  << 129   if( (verboseLevel > 0) && (fSumEnergyKilled > 0.0 ) ){ 
123     G4cout << " G4MonopoleTransportation: Stat << 130     G4cout << " G4MonopoleTransportation: Statistics for looping particles " 
124     G4cout << "   Sum of energy of loopers kil << 131            << G4endl;
125     G4cout << "   Max energy of loopers killed << 132     G4cout << "   Sum of energy of loopers killed: " <<  fSumEnergyKilled << G4endl;
126   }                                            << 133     G4cout << "   Max energy of loopers killed: " <<  fMaxEnergyKilled << G4endl;
                                                   >> 134   } 
127 }                                                 135 }
128                                                   136 
129 //....oooOO0OOooo........oooOO0OOooo........oo    137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 //                                                138 //
131 // Responsibilities:                              139 // Responsibilities:
132 //    Find whether the geometry limits the Ste    140 //    Find whether the geometry limits the Step, and to what length
133 //    Calculate the new value of the safety an    141 //    Calculate the new value of the safety and return it.
134 //    Store the final time, position and momen    142 //    Store the final time, position and momentum.
135                                                   143 
136 G4double G4MonopoleTransportation::AlongStepGe << 144 G4double G4MonopoleTransportation::
137   const G4Track& track,                        << 145 AlongStepGetPhysicalInteractionLength( const G4Track&  track,
138   G4double,  //  previousStepSize              << 146                                              G4double, //  previousStepSize
139   G4double currentMinimumStep, G4double& curre << 147                                              G4double  currentMinimumStep,
140 {                                              << 148                                              G4double& currentSafety,
141   fMagSetup->SetStepperAndChordFinder(1);      << 149                                              G4GPILSelection* selection )
                                                   >> 150 {  
                                                   >> 151   fMagSetup->SetStepperAndChordFinder(1); 
142   // change to monopole equation                  152   // change to monopole equation
143                                                   153 
144   G4double geometryStepLength, newSafety;      << 154   G4double geometryStepLength, newSafety ; 
145   fParticleIsLooping = false;                  << 155   fParticleIsLooping = false ;
146                                                   156 
147   // Initial actions moved to  StartTrack()    << 157   // Initial actions moved to  StartTrack()   
148   // --------------------------------------       158   // --------------------------------------
149   // Note: in case another process changes tou    159   // Note: in case another process changes touchable handle
150   //    it will be necessary to add here (for  << 160   //    it will be necessary to add here (for all steps)   
151   // fCurrentTouchableHandle = aTrack->GetTouc    161   // fCurrentTouchableHandle = aTrack->GetTouchableHandle();
152                                                   162 
153   // GPILSelection is set to defaule value of     163   // GPILSelection is set to defaule value of CandidateForSelection
154   // It is a return value                         164   // It is a return value
155   //                                              165   //
156   *selection = CandidateForSelection;          << 166   *selection = CandidateForSelection ;
157                                                   167 
158   // Get initial Energy/Momentum of the track     168   // Get initial Energy/Momentum of the track
159   //                                              169   //
160   const G4DynamicParticle* pParticle = track.G << 170   const G4DynamicParticle* pParticle      = track.GetDynamicParticle() ;
161   G4ThreeVector startMomentumDir = pParticle-> << 171   G4ThreeVector startMomentumDir          = pParticle->GetMomentumDirection() ;
162   G4ThreeVector startPosition = track.GetPosit << 172   G4ThreeVector startPosition             = track.GetPosition() ;
163                                                   173 
164   // G4double   theTime        = track.GetGlob    174   // G4double   theTime        = track.GetGlobalTime() ;
165                                                   175 
166   // The Step Point safety can be limited by o << 176   // The Step Point safety can be limited by other geometries and/or the 
167   // assumptions of any process - it's not alw    177   // assumptions of any process - it's not always the geometrical safety.
168   // We calculate the starting point's isotrop    178   // We calculate the starting point's isotropic safety here.
169   //                                              179   //
170   G4ThreeVector OriginShift = startPosition -  << 180   G4ThreeVector OriginShift = startPosition - fPreviousSftOrigin ;
171   G4double MagSqShift = OriginShift.mag2();    << 181   G4double      MagSqShift  = OriginShift.mag2() ;
172   if (MagSqShift >= sqr(fPreviousSafety)) {    << 182   if( MagSqShift >= sqr(fPreviousSafety) )
173     currentSafety = 0.0;                       << 183   {
                                                   >> 184      currentSafety = 0.0 ;
174   }                                               185   }
175   else {                                       << 186   else
176     currentSafety = fPreviousSafety - std::sqr << 187   {
                                                   >> 188      currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ;
177   }                                               189   }
178                                                   190 
179   // Is the monopole charged ?                    191   // Is the monopole charged ?
180   //                                              192   //
181   G4double particleMagneticCharge = fParticleD << 193   G4double particleMagneticCharge = fParticleDef->MagneticCharge() ; 
182   G4double particleElectricCharge = pParticle-    194   G4double particleElectricCharge = pParticle->GetCharge();
183                                                   195 
184   fGeometryLimitedStep = false;                << 196   fGeometryLimitedStep = false ;
185   // fEndGlobalTimeComputed = false ;             197   // fEndGlobalTimeComputed = false ;
186                                                   198 
187   // There is no need to locate the current vo    199   // There is no need to locate the current volume. It is Done elsewhere:
188   //   On track construction                   << 200   //   On track construction 
189   //   By the tracking, after all AlongStepDoI    201   //   By the tracking, after all AlongStepDoIts, in "Relocation"
190                                                   202 
191   // Check whether the particle have an (EM) f    203   // Check whether the particle have an (EM) field force exerting upon it
192   //                                              204   //
193   G4FieldManager* fieldMgr = 0;                << 205   G4FieldManager* fieldMgr=0;
194   G4bool fieldExertsForce = false;             << 206   G4bool          fieldExertsForce = false ;
195                                                << 207     
196   if ((particleMagneticCharge != 0.0)) {       << 208   if( (particleMagneticCharge != 0.0) )
197     fieldMgr = fFieldPropagator->FindAndSetFie << 209   {      
198     if (fieldMgr != 0) {                       << 210      fieldMgr= fFieldPropagator->FindAndSetFieldManager( track.GetVolume() ); 
199       // Message the field Manager, to configu << 211      if (fieldMgr != 0) {
200       fieldMgr->ConfigureForTrack(&track);     << 212        // Message the field Manager, to configure it for this track
201       // Moved here, in order to allow a trans << 213        fieldMgr->ConfigureForTrack( &track );
202       //   from a zero-field  status (with fie << 214        // Moved here, in order to allow a transition
203       //   to a finite field  status           << 215        //   from a zero-field  status (with fieldMgr->(field)0
204                                                << 216        //   to a finite field  status
205       // If the field manager has no field, th << 217 
206       fieldExertsForce = (fieldMgr->GetDetecto << 218        // If the field manager has no field, there is no field !
207     }                                          << 219        fieldExertsForce = (fieldMgr->GetDetectorField() != 0);
                                                   >> 220      }      
208   }                                               221   }
209                                                   222 
210   // G4cout << " G4Transport:  field exerts fo    223   // G4cout << " G4Transport:  field exerts force= " << fieldExertsForce
211   //          << "  fieldMgr= " << fieldMgr <<    224   //          << "  fieldMgr= " << fieldMgr << G4endl;
212                                                   225 
213   // Choose the calculation of the transportat << 226   // Choose the calculation of the transportation: Field or not 
214   //                                              227   //
215   if (!fieldExertsForce) {                     << 228   if( !fieldExertsForce ) 
216     G4double linearStepLength;                 << 229   {
217     if (fShortStepOptimisation && (currentMini << 230      G4double linearStepLength ;
218       // The Step is guaranteed to be taken    << 231      if( fShortStepOptimisation && (currentMinimumStep <= currentSafety) )
219       //                                       << 232      {
220       geometryStepLength = currentMinimumStep; << 233        // The Step is guaranteed to be taken
221       fGeometryLimitedStep = false;            << 234        //
222     }                                          << 235        geometryStepLength   = currentMinimumStep ;
223     else {                                     << 236        fGeometryLimitedStep = false ;
224       //  Find whether the straight path inter << 237      }
225       //                                       << 238      else
226       linearStepLength = fLinearNavigator->Com << 239      {
227                                                << 240        //  Find whether the straight path intersects a volume
228       // Remember last safety origin & value.  << 241        //
229       //                                       << 242        linearStepLength = fLinearNavigator->ComputeStep( startPosition, 
230       fPreviousSftOrigin = startPosition;      << 243                                                          startMomentumDir,
231       fPreviousSafety = newSafety;             << 244                                                          currentMinimumStep, 
232       // fpSafetyHelper->SetCurrentSafety( new << 245                                                          newSafety) ;
233                                                << 246        // Remember last safety origin & value.
234       // The safety at the initial point has b << 247        //
235       //                                       << 248        fPreviousSftOrigin = startPosition ;
236       currentSafety = newSafety;               << 249        fPreviousSafety    = newSafety ; 
237                                                << 250        // fpSafetyHelper->SetCurrentSafety( newSafety, startPosition);
238       fGeometryLimitedStep = (linearStepLength << 251 
239       if (fGeometryLimitedStep) {              << 252        // The safety at the initial point has been re-calculated:
240         // The geometry limits the Step size ( << 253        //
241         geometryStepLength = linearStepLength; << 254        currentSafety = newSafety ;
242       }                                        << 255           
243       else {                                   << 256        fGeometryLimitedStep= (linearStepLength <= currentMinimumStep); 
244         // The full Step is taken.             << 257        if( fGeometryLimitedStep )
245         geometryStepLength = currentMinimumSte << 258        {
246       }                                        << 259          // The geometry limits the Step size (an intersection was found.)
247     }                                          << 260          geometryStepLength   = linearStepLength ;
248     endpointDistance = geometryStepLength;     << 261        } 
249                                                << 262        else
250     // Calculate final position                << 263        {
251     //                                         << 264          // The full Step is taken.
252     fTransportEndPosition = startPosition + ge << 265          geometryStepLength   = currentMinimumStep ;
253                                                << 266        }
254     // Momentum direction, energy and polarisa << 267      }
255     //                                         << 268      endpointDistance = geometryStepLength ;
256     fTransportEndMomentumDir = startMomentumDi << 269 
257     fTransportEndKineticEnergy = track.GetKine << 270      // Calculate final position
258     fTransportEndSpin = track.GetPolarization( << 271      //
259     fParticleIsLooping = false;                << 272      fTransportEndPosition = startPosition+geometryStepLength*startMomentumDir ;
260     fMomentumChanged = false;                  << 273 
261     fEndGlobalTimeComputed = false;            << 274      // Momentum direction, energy and polarisation are unchanged by transport
262   }                                            << 275      //
263   else  //  A field exerts force               << 276      fTransportEndMomentumDir   = startMomentumDir ; 
264   {                                            << 277      fTransportEndKineticEnergy = track.GetKineticEnergy() ;
265     G4double momentumMagnitude = pParticle->Ge << 278      fTransportEndSpin          = track.GetPolarization();
266     G4ThreeVector EndUnitMomentum;             << 279      fParticleIsLooping         = false ;
267     G4double lengthAlongCurve;                 << 280      fMomentumChanged           = false ; 
268     G4double restMass = fParticleDef->GetPDGMa << 281      fEndGlobalTimeComputed     = false ;
269                                                << 282   }
270     G4ChargeState chargeState(particleElectric << 283   else   //  A field exerts force
271                               fParticleDef->Ge << 284   {
272                               0,  //  Magnetic << 285      G4double       momentumMagnitude = pParticle->GetTotalMomentum() ;
273                               0,  //  Electric << 286      G4ThreeVector  EndUnitMomentum ;
274                               particleMagnetic << 287      G4double       lengthAlongCurve ;
275                                                << 288      G4double       restMass = fParticleDef->GetPDGMass() ;
276     G4EquationOfMotion* equationOfMotion =     << 289 
277       fFieldPropagator->GetChordFinder()->GetI << 290      G4ChargeState chargeState(particleElectricCharge,  // The charge can change (dynamic)
278                                                << 291                                fParticleDef->GetPDGSpin(),
279     equationOfMotion->SetChargeMomentumMass(ch << 292                                0,   //  Magnetic moment:  pParticleDef->GetMagneticMoment(),
280     // SetChargeMomentumMass now passes both t << 293                                0,   //  Electric Dipole moment - not in Particle Definition 
281     // charge in chargeState                   << 294                                particleMagneticCharge );   // in Mev/c 
282                                                << 295 
283     G4ThreeVector spin = track.GetPolarization << 296      G4EquationOfMotion* equationOfMotion = 
284     G4FieldTrack aFieldTrack = G4FieldTrack(st << 297        fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetEquationOfMotion();
285                                             tr << 298 
286                                             tr << 299      equationOfMotion
287                                             tr << 300        ->SetChargeMomentumMass( chargeState,       //  Was particleMagneticCharge - in Mev/c
288                                             &s << 301                                 momentumMagnitude, //  Was particleElectricCharge 
289     if (currentMinimumStep > 0) {              << 302                                 restMass ) ;  
290       // Do the Transport in the field (non re << 303      // SetChargeMomentumMass now passes both the electric and magnetic charge - in chargeState
291       //                                       << 304 
292       lengthAlongCurve = fFieldPropagator->Com << 305      G4ThreeVector spin        = track.GetPolarization() ;
293                                                << 306      G4FieldTrack  aFieldTrack = G4FieldTrack( startPosition, 
294       fGeometryLimitedStep = lengthAlongCurve  << 307                                                track.GetMomentumDirection(),
295       if (fGeometryLimitedStep) {              << 308                                                0.0, 
296         geometryStepLength = lengthAlongCurve; << 309                                                track.GetKineticEnergy(),
297       }                                        << 310                                                restMass,
298       else {                                   << 311                                                track.GetVelocity(),
299         geometryStepLength = currentMinimumSte << 312                                                track.GetGlobalTime(), // Lab.
300       }                                        << 313                                                track.GetProperTime(), // Part.
301     }                                          << 314                                                &spin                  ) ;
302     else {                                     << 315      if( currentMinimumStep > 0 ) 
303       geometryStepLength = lengthAlongCurve =  << 316      {
304       fGeometryLimitedStep = false;            << 317         // Do the Transport in the field (non recti-linear)
305     }                                          << 318         //
306                                                << 319         lengthAlongCurve = fFieldPropagator->ComputeStep( aFieldTrack,
307     // Remember last safety origin & value.    << 320                                                           currentMinimumStep, 
308     //                                         << 321                                                           currentSafety,
309     fPreviousSftOrigin = startPosition;        << 322                                                           track.GetVolume() ) ;
310     fPreviousSafety = currentSafety;           << 323         fGeometryLimitedStep= lengthAlongCurve < currentMinimumStep; 
311     // fpSafetyHelper->SetCurrentSafety( newSa << 324         if( fGeometryLimitedStep ) {
312                                                << 325            geometryStepLength   = lengthAlongCurve ;
313     // Get the End-Position and End-Momentum ( << 326         } else {
314     //                                         << 327            geometryStepLength   = currentMinimumStep ;
315     fTransportEndPosition = aFieldTrack.GetPos << 328         }
316                                                << 329      }
317     // Momentum:  Magnitude and direction can  << 330      else
318     //                                         << 331      {
319     fMomentumChanged = true;                   << 332         geometryStepLength   = lengthAlongCurve= 0.0 ;
320     fTransportEndMomentumDir = aFieldTrack.Get << 333         fGeometryLimitedStep = false ;
321                                                << 334      }
322     fTransportEndKineticEnergy = aFieldTrack.G << 335 
323                                                << 336      // Remember last safety origin & value.
324     fCandidateEndGlobalTime = aFieldTrack.GetL << 337      //
325     fEndGlobalTimeComputed = true;             << 338      fPreviousSftOrigin = startPosition ;
326                                                << 339      fPreviousSafety    = currentSafety ;         
327     fTransportEndSpin = aFieldTrack.GetSpin(); << 340      // fpSafetyHelper->SetCurrentSafety( newSafety, startPosition);
328     fParticleIsLooping = fFieldPropagator->IsP << 341        
329     endpointDistance = (fTransportEndPosition  << 342      // Get the End-Position and End-Momentum (Dir-ection)
                                                   >> 343      //
                                                   >> 344      fTransportEndPosition = aFieldTrack.GetPosition() ;
                                                   >> 345 
                                                   >> 346      // Momentum:  Magnitude and direction can be changed too now ...
                                                   >> 347      //
                                                   >> 348      fMomentumChanged         = true ; 
                                                   >> 349      fTransportEndMomentumDir = aFieldTrack.GetMomentumDir() ;
                                                   >> 350 
                                                   >> 351      fTransportEndKineticEnergy  = aFieldTrack.GetKineticEnergy() ; 
                                                   >> 352 
                                                   >> 353      fCandidateEndGlobalTime   = aFieldTrack.GetLabTimeOfFlight();
                                                   >> 354      fEndGlobalTimeComputed    = true;
                                                   >> 355 
                                                   >> 356      fTransportEndSpin = aFieldTrack.GetSpin();
                                                   >> 357      fParticleIsLooping = fFieldPropagator->IsParticleLooping() ;
                                                   >> 358      endpointDistance   = (fTransportEndPosition - startPosition).mag() ;
330   }                                               359   }
331                                                   360 
332   // If we are asked to go a step length of 0,    361   // If we are asked to go a step length of 0, and we are on a boundary
333   // then a boundary will also limit the step     362   // then a boundary will also limit the step -> we must flag this.
334   //                                              363   //
335   if (currentMinimumStep == 0.0) {             << 364   if( currentMinimumStep == 0.0 ) 
336     if (currentSafety == 0.0) fGeometryLimited << 365   {
                                                   >> 366       if( currentSafety == 0.0 )  fGeometryLimitedStep = true ;
337   }                                               367   }
338                                                   368 
339   // Update the safety starting from the end-p    369   // Update the safety starting from the end-point,
340   // if it will become negative at the end-poi    370   // if it will become negative at the end-point.
341   //                                              371   //
342   if (currentSafety < endpointDistance) {      << 372   if( currentSafety < endpointDistance ) 
343     // if( particleMagneticCharge == 0.0 )     << 373   {
344     // G4cout  << "  Avoiding call to ComputeS << 374       // if( particleMagneticCharge == 0.0 ) 
345                                                << 375       //    G4cout  << "  Avoiding call to ComputeSafety : charge = 0.0 " << G4endl;
346     if (particleMagneticCharge != 0.0) {       << 376  
347       G4double endSafety = fLinearNavigator->C << 377       if( particleMagneticCharge != 0.0 ) {
348       currentSafety = endSafety;               << 378 
349       fPreviousSftOrigin = fTransportEndPositi << 379          G4double endSafety =
350       fPreviousSafety = currentSafety;         << 380                fLinearNavigator->ComputeSafety( fTransportEndPosition) ;
351       fpSafetyHelper->SetCurrentSafety(current << 381          currentSafety      = endSafety ;
352                                                << 382          fPreviousSftOrigin = fTransportEndPosition ;
353       // Because the Stepping Manager assumes  << 383          fPreviousSafety    = currentSafety ; 
354       //  add the StepLength                   << 384          fpSafetyHelper->SetCurrentSafety( currentSafety, fTransportEndPosition);
355       //                                       << 385 
356       currentSafety += endpointDistance;       << 386          // Because the Stepping Manager assumes it is from the start point, 
357                                                << 387          //  add the StepLength
358 #ifdef G4DEBUG_TRANSPORT                       << 388          //
359       G4cout.precision(12);                    << 389          currentSafety     += endpointDistance ;
360       G4cout << "***G4MonopoleTransportation:: << 390 
361       G4cout << "  Called Navigator->ComputeSa << 391 #ifdef G4DEBUG_TRANSPORT 
362              << "    and it returned safety= " << 392          G4cout.precision(12) ;
363       G4cout << "  Adding endpoint distance "  << 393          G4cout << "***G4MonopoleTransportation::AlongStepGPIL ** " << G4endl  ;
364              << "   to obtain pseudo-safety= " << 394          G4cout << "  Called Navigator->ComputeSafety at " << fTransportEndPosition
                                                   >> 395                 << "    and it returned safety= " << endSafety << G4endl ; 
                                                   >> 396          G4cout << "  Adding endpoint distance " << endpointDistance 
                                                   >> 397                 << "   to obtain pseudo-safety= " << currentSafety << G4endl ; 
365 #endif                                            398 #endif
366     }                                          << 399       }
367   }                                            << 400   }            
368                                                   401 
369   fParticleChange.ProposeTrueStepLength(geomet << 402   fParticleChange.ProposeTrueStepLength(geometryStepLength) ;
370                                                   403 
371   fMagSetup->SetStepperAndChordFinder(0);         404   fMagSetup->SetStepperAndChordFinder(0);
372   // change back to usual equation                405   // change back to usual equation
373                                                   406 
374   return geometryStepLength;                   << 407   return geometryStepLength ;
375 }                                                 408 }
376                                                   409 
377 //....oooOO0OOooo........oooOO0OOooo........oo    410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
378 //                                                411 //
379 //   Initialize ParticleChange  (by setting al    412 //   Initialize ParticleChange  (by setting all its members equal
380 //                               to correspond    413 //                               to corresponding members in G4Track)
381                                                   414 
382 G4VParticleChange* G4MonopoleTransportation::A << 415 G4VParticleChange* G4MonopoleTransportation::AlongStepDoIt( const G4Track& track,
383                                                << 416                                                     const G4Step&  stepData )
384 {                                                 417 {
385   ++noCalls;                                   << 418   static G4int noCalls=0;
                                                   >> 419   static const G4ParticleDefinition* fOpticalPhoton =
                                                   >> 420            G4ParticleTable::GetParticleTable()->FindParticle("opticalphoton");
386                                                   421 
387   if (fGeometryLimitedStep) {                  << 422   noCalls++;
388     stepData.GetPostStepPoint()->SetStepStatus << 
389   }                                            << 
390                                                   423 
391   fParticleChange.Initialize(track);           << 424   fParticleChange.Initialize(track) ;
392                                                   425 
393   //  Code for specific process                << 426   //  Code for specific process 
394   //                                              427   //
395   fParticleChange.ProposePosition(fTransportEn << 428   fParticleChange.ProposePosition(fTransportEndPosition) ;
396   fParticleChange.ProposeMomentumDirection(fTr << 429   fParticleChange.ProposeMomentumDirection(fTransportEndMomentumDir) ;
397   fParticleChange.ProposeEnergy(fTransportEndK << 430   fParticleChange.ProposeEnergy(fTransportEndKineticEnergy) ;
398   fParticleChange.SetMomentumChanged(fMomentum << 431   fParticleChange.SetMomentumChanged(fMomentumChanged) ;
399                                                   432 
400   fParticleChange.ProposePolarization(fTranspo    433   fParticleChange.ProposePolarization(fTransportEndSpin);
401                                                << 434   
402   G4double deltaTime = 0.0;                    << 435   G4double deltaTime = 0.0 ;
403                                                   436 
404   // Calculate  Lab Time of Flight (ONLY if fi    437   // Calculate  Lab Time of Flight (ONLY if field Equations used it!)
                                                   >> 438      // G4double endTime   = fCandidateEndGlobalTime;
                                                   >> 439      // G4double delta_time = endTime - startTime;
405                                                   440 
406   G4double startTime = track.GetGlobalTime();  << 441   G4double startTime = track.GetGlobalTime() ;
407                                                << 442   
408   if (!fEndGlobalTimeComputed) {               << 443   if (!fEndGlobalTimeComputed)
409     // The time was not integrated .. make the << 444   {
410     //                                         << 445      // The time was not integrated .. make the best estimate possible
411     G4double finalVelocity = track.GetVelocity << 446      //
412     G4double initialVelocity = stepData.GetPre << 447      G4double finalVelocity   = track.GetVelocity() ;
413     G4double stepLength = track.GetStepLength( << 448      G4double initialVelocity = stepData.GetPreStepPoint()->GetVelocity() ;
414                                                << 449      G4double stepLength      = track.GetStepLength() ;
415     deltaTime = 0.0;  // in case initialVeloci << 450 
416     if (finalVelocity > 0.0) {                 << 451      deltaTime= 0.0;  // in case initialVelocity = 0 
417       G4double meanInverseVelocity;            << 452      const G4DynamicParticle* fpDynamicParticle = track.GetDynamicParticle();
418       // deltaTime = stepLength/finalVelocity  << 453      if (fpDynamicParticle->GetDefinition()== fOpticalPhoton)
419       meanInverseVelocity = 0.5 * (1.0 / initi << 454      {
420       deltaTime = stepLength * meanInverseVelo << 455         //  A photon is in the medium of the final point
421     }                                          << 456         //  during the step, so it has the final velocity.
422     else if (initialVelocity > 0.0) {          << 457         deltaTime = stepLength/finalVelocity ;
423       deltaTime = stepLength / initialVelocity << 458      }
424     }                                          << 459      else if (finalVelocity > 0.0)
425     fCandidateEndGlobalTime = startTime + delt << 460      {
                                                   >> 461         G4double meanInverseVelocity ;
                                                   >> 462         // deltaTime = stepLength/finalVelocity ;
                                                   >> 463         meanInverseVelocity = 0.5
                                                   >> 464                             * ( 1.0 / initialVelocity + 1.0 / finalVelocity ) ;
                                                   >> 465         deltaTime = stepLength * meanInverseVelocity ;
                                                   >> 466      }
                                                   >> 467      else if( initialVelocity > 0.0 )
                                                   >> 468      {
                                                   >> 469         deltaTime = stepLength/initialVelocity ;
                                                   >> 470      }
                                                   >> 471      fCandidateEndGlobalTime   = startTime + deltaTime ;
426   }                                               472   }
427   else {                                       << 473   else
428     deltaTime = fCandidateEndGlobalTime - star << 474   {
                                                   >> 475      deltaTime = fCandidateEndGlobalTime - startTime ;
429   }                                               476   }
430                                                   477 
431   fParticleChange.ProposeGlobalTime(fCandidate << 478   fParticleChange.ProposeGlobalTime( fCandidateEndGlobalTime ) ;
432                                                   479 
433   // Now Correct by Lorentz factor to get "pro    480   // Now Correct by Lorentz factor to get "proper" deltaTime
                                                   >> 481   
                                                   >> 482   G4double  restMass       = track.GetDynamicParticle()->GetMass() ;
                                                   >> 483   G4double deltaProperTime = deltaTime*( restMass/track.GetTotalEnergy() ) ;
434                                                   484 
435   G4double restMass = track.GetDynamicParticle << 485   fParticleChange.ProposeProperTime(track.GetProperTime() + deltaProperTime) ;
436   G4double deltaProperTime = deltaTime * (rest << 486   //fParticleChange. ProposeTrueStepLength( track.GetStepLength() ) ;
437                                                << 
438   fParticleChange.ProposeProperTime(track.GetP << 
439                                                   487 
440   // If the particle is caught looping or is s    488   // If the particle is caught looping or is stuck (in very difficult
441   // boundaries) in a magnetic field (doing ma << 489   // boundaries) in a magnetic field (doing many steps) 
442   //   THEN this kills it ...                     490   //   THEN this kills it ...
443   //                                              491   //
444   if (fParticleIsLooping) {                    << 492   if ( fParticleIsLooping )
445     G4double endEnergy = fTransportEndKineticE << 493   {
                                                   >> 494       G4double endEnergy= fTransportEndKineticEnergy;
446                                                   495 
447     if ((endEnergy < fThreshold_Important_Ener << 496       if( (endEnergy < fThreshold_Important_Energy) 
448       // Kill the looping particle             << 497           || (fNoLooperTrials >= fThresholdTrials ) ){
449       //                                       << 498         // Kill the looping particle 
450       fParticleChange.ProposeTrackStatus(fStop << 499         //
451                                                << 500         fParticleChange.ProposeTrackStatus( fStopAndKill )  ;
452       // 'Bare' statistics                     << 501 
453       fSumEnergyKilled += endEnergy;           << 502         // 'Bare' statistics
454       if (endEnergy > fMaxEnergyKilled) {      << 503         fSumEnergyKilled += endEnergy; 
455         fMaxEnergyKilled = endEnergy;          << 504         if( endEnergy > fMaxEnergyKilled) { fMaxEnergyKilled= endEnergy; }
456       }                                        << 
457                                                   505 
458 #ifdef G4VERBOSE                                  506 #ifdef G4VERBOSE
459       if ((verboseLevel > 1) || (endEnergy > f << 507         if( (verboseLevel > 1) || 
460         G4cout << " G4MonopoleTransportation i << 508             ( endEnergy > fThreshold_Warning_Energy )  ) { 
461                << "that is looping or stuck "  << 509           G4cout << " G4MonopoleTransportation is killing track that is looping or stuck "
462                << track.GetKineticEnergy() / M << 510                  << G4endl
463         G4cout << "   Number of trials = " <<  << 511                  << "   This track has " << track.GetKineticEnergy() / MeV
464                << "   No of calls to AlongStep << 512                  << " MeV energy." << G4endl;
465       }                                        << 513           G4cout << "   Number of trials = " << fNoLooperTrials 
                                                   >> 514                  << "   No of calls to AlongStepDoIt = " << noCalls 
                                                   >> 515                  << G4endl;
                                                   >> 516         }
466 #endif                                            517 #endif
467       fNoLooperTrials = 0;                     << 518         fNoLooperTrials=0; 
468     }                                          << 
469     else {                                     << 
470       fNoLooperTrials++;                       << 
471 #ifdef G4VERBOSE                               << 
472       if ((verboseLevel > 2)) {                << 
473         G4cout << "   G4MonopoleTransportation << 
474                << "Particle looping - "        << 
475                << "   Number of trials = " <<  << 
476                << G4endl;                      << 
477       }                                           519       }
                                                   >> 520       else{
                                                   >> 521         fNoLooperTrials ++; 
                                                   >> 522 #ifdef G4VERBOSE
                                                   >> 523         if( (verboseLevel > 2) ){
                                                   >> 524           G4cout << "   G4MonopoleTransportation::AlongStepDoIt(): Particle looping -  "
                                                   >> 525                  << "   Number of trials = " << fNoLooperTrials 
                                                   >> 526                  << "   No of calls to  = " << noCalls 
                                                   >> 527                  << G4endl;
                                                   >> 528         }
478 #endif                                            529 #endif
479     }                                          << 530       }
480   }                                            << 531   }else{
481   else {                                       << 532       fNoLooperTrials=0; 
482     fNoLooperTrials = 0;                       << 
483   }                                               533   }
484                                                   534 
485   // Another (sometimes better way) is to use     535   // Another (sometimes better way) is to use a user-limit maximum Step size
486   // to alleviate this problem ..              << 536   // to alleviate this problem .. 
487                                                   537 
488   // Introduce smooth curved trajectories to p    538   // Introduce smooth curved trajectories to particle-change
489   //                                              539   //
490   fParticleChange.SetPointerToVectorOfAuxiliar << 540   fParticleChange.SetPointerToVectorOfAuxiliaryPoints
491     fFieldPropagator->GimmeTrajectoryVectorAnd << 541     (fFieldPropagator->GimmeTrajectoryVectorAndForgetIt() );
492                                                   542 
493   return &fParticleChange;                     << 543   return &fParticleChange ;
494 }                                                 544 }
495                                                   545 
496 //....oooOO0OOooo........oooOO0OOooo........oo    546 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
497 //                                                547 //
498 //  This ensures that the PostStep action is a    548 //  This ensures that the PostStep action is always called,
499 //  so that it can do the relocation if it is     549 //  so that it can do the relocation if it is needed.
500 //                                             << 550 // 
501                                                   551 
502 G4double                                       << 552 G4double G4MonopoleTransportation::
503 G4MonopoleTransportation::PostStepGetPhysicalI << 553 PostStepGetPhysicalInteractionLength( const G4Track&,
504                                                << 554                                             G4double, // previousStepSize
505                                                << 555                                             G4ForceCondition* pForceCond )
506 {                                              << 556 {  
507   *pForceCond = Forced;                        << 557   *pForceCond = Forced ; 
508   return DBL_MAX;  // was kInfinity ; but conv << 558   return DBL_MAX ;  // was kInfinity ; but convention now is DBL_MAX
509 }                                                 559 }
510                                                   560 
511 //....oooOO0OOooo........oooOO0OOooo........oo    561 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
512                                                   562 
513 G4VParticleChange* G4MonopoleTransportation::P << 563 G4VParticleChange* G4MonopoleTransportation::PostStepDoIt( const G4Track& track,
                                                   >> 564                                                    const G4Step& )
514 {                                                 565 {
515   G4TouchableHandle retCurrentTouchable;  // T << 566   G4TouchableHandle retCurrentTouchable ;   // The one to return
516                                                   567 
517   // Initialize ParticleChange  (by setting al    568   // Initialize ParticleChange  (by setting all its members equal
518   //                             to correspond    569   //                             to corresponding members in G4Track)
519   // fParticleChange.Initialize(track) ;  // T    570   // fParticleChange.Initialize(track) ;  // To initialise TouchableChange
520                                                   571 
521   fParticleChange.ProposeTrackStatus(track.Get << 572   fParticleChange.ProposeTrackStatus(track.GetTrackStatus()) ;
522                                                   573 
523   // If the Step was determined by the volume     574   // If the Step was determined by the volume boundary,
524   // logically relocate the particle              575   // logically relocate the particle
525                                                << 576   
526   if (fGeometryLimitedStep) {                  << 577   if(fGeometryLimitedStep)
527     // fCurrentTouchable will now become the p << 578   {  
                                                   >> 579     // fCurrentTouchable will now become the previous touchable, 
528     // and what was the previous will be freed    580     // and what was the previous will be freed.
529     // (Needed because the preStepPoint can po    581     // (Needed because the preStepPoint can point to the previous touchable)
530                                                   582 
531     fLinearNavigator->SetGeometricallyLimitedS << 583     fLinearNavigator->SetGeometricallyLimitedStep() ;
532     fLinearNavigator->LocateGlobalPointAndUpda << 584     fLinearNavigator->
533       track.GetPosition(), track.GetMomentumDi << 585     LocateGlobalPointAndUpdateTouchableHandle( track.GetPosition(),
534     // Check whether the particle is out of th << 586                                                track.GetMomentumDirection(),
                                                   >> 587                                                fCurrentTouchableHandle,
                                                   >> 588                                                true                      ) ;
                                                   >> 589     // Check whether the particle is out of the world volume 
535     // If so it has exited and must be killed.    590     // If so it has exited and must be killed.
536     //                                            591     //
537     if (fCurrentTouchableHandle->GetVolume() = << 592     if( fCurrentTouchableHandle->GetVolume() == 0 )
538       fParticleChange.ProposeTrackStatus(fStop << 593     {
                                                   >> 594        fParticleChange.ProposeTrackStatus( fStopAndKill ) ;
539     }                                             595     }
540     retCurrentTouchable = fCurrentTouchableHan << 596     retCurrentTouchable = fCurrentTouchableHandle ;
541     fParticleChange.SetTouchableHandle(fCurren << 597     fParticleChange.SetTouchableHandle( fCurrentTouchableHandle ) ;
542   }                                               598   }
543   else  // fGeometryLimitedStep  is false      << 599   else                 // fGeometryLimitedStep  is false
544   {                                            << 600   {                    
545     // This serves only to move the Navigator'    601     // This serves only to move the Navigator's location
546     //                                            602     //
547     fLinearNavigator->LocateGlobalPointWithinV << 603     fLinearNavigator->LocateGlobalPointWithinVolume( track.GetPosition() ) ;
548                                                   604 
549     // The value of the track's current Toucha << 605     // The value of the track's current Touchable is retained. 
550     // (and it must be correct because we must    606     // (and it must be correct because we must use it below to
551     // overwrite the (unset) one in particle c    607     // overwrite the (unset) one in particle change)
552     //  It must be fCurrentTouchable too ??       608     //  It must be fCurrentTouchable too ??
553     //                                            609     //
554     fParticleChange.SetTouchableHandle(track.G << 610     fParticleChange.SetTouchableHandle( track.GetTouchableHandle() ) ;
555     retCurrentTouchable = track.GetTouchableHa << 611     retCurrentTouchable = track.GetTouchableHandle() ;
556   }  // endif ( fGeometryLimitedStep )         << 612   }         // endif ( fGeometryLimitedStep ) 
557                                                << 613 
558   const G4VPhysicalVolume* pNewVol = retCurren << 614   const G4VPhysicalVolume* pNewVol = retCurrentTouchable->GetVolume() ;
559   const G4Material* pNewMaterial = 0;          << 615   const G4Material* pNewMaterial   = 0 ;
560   G4VSensitiveDetector* pNewSensitiveDetector  << 616   const G4VSensitiveDetector* pNewSensitiveDetector   = 0 ;
561   if (pNewVol != 0) {                          << 617                                                                                        
562     pNewMaterial = pNewVol->GetLogicalVolume() << 618   if( pNewVol != 0 )
563     pNewSensitiveDetector = pNewVol->GetLogica << 619   {
                                                   >> 620     pNewMaterial= pNewVol->GetLogicalVolume()->GetMaterial();
                                                   >> 621     pNewSensitiveDetector= pNewVol->GetLogicalVolume()->GetSensitiveDetector();
564   }                                               622   }
565                                                   623 
566   // ( <const_cast> pNewMaterial ) ;              624   // ( <const_cast> pNewMaterial ) ;
                                                   >> 625   // ( <const_cast> pNewSensitiveDetector) ;
567                                                   626 
568   fParticleChange.SetMaterialInTouchable((G4Ma << 627   fParticleChange.SetMaterialInTouchable( 
569   fParticleChange.SetSensitiveDetectorInToucha << 628                      (G4Material *) pNewMaterial ) ;
                                                   >> 629   fParticleChange.SetSensitiveDetectorInTouchable( 
                                                   >> 630                      (G4VSensitiveDetector *) pNewSensitiveDetector ) ;
570                                                   631 
571   const G4MaterialCutsCouple* pNewMaterialCuts    632   const G4MaterialCutsCouple* pNewMaterialCutsCouple = 0;
572   if (pNewVol != 0) {                          << 633   if( pNewVol != 0 )
573     pNewMaterialCutsCouple = pNewVol->GetLogic << 634   {
                                                   >> 635     pNewMaterialCutsCouple=pNewVol->GetLogicalVolume()->GetMaterialCutsCouple();
574   }                                               636   }
575                                                   637 
576   if (pNewVol != 0 && pNewMaterialCutsCouple ! << 638   if( pNewVol!=0 && pNewMaterialCutsCouple!=0 && 
577       && pNewMaterialCutsCouple->GetMaterial() << 639       pNewMaterialCutsCouple->GetMaterial()!=pNewMaterial )
578   {                                               640   {
579     // for parametrized volume                    641     // for parametrized volume
580     //                                            642     //
581     pNewMaterialCutsCouple = G4ProductionCutsT << 643     pNewMaterialCutsCouple =
582       pNewMaterial, pNewMaterialCutsCouple->Ge << 644       G4ProductionCutsTable::GetProductionCutsTable()
                                                   >> 645                              ->GetMaterialCutsCouple(pNewMaterial,
                                                   >> 646                                pNewMaterialCutsCouple->GetProductionCuts());
583   }                                               647   }
584   fParticleChange.SetMaterialCutsCoupleInTouch << 648   fParticleChange.SetMaterialCutsCoupleInTouchable( pNewMaterialCutsCouple );
585                                                   649 
586   // temporarily until Get/Set Material of Par << 650   // temporarily until Get/Set Material of ParticleChange, 
587   // and StepPoint can be made const.          << 651   // and StepPoint can be made const. 
588   // Set the touchable in ParticleChange          652   // Set the touchable in ParticleChange
589   // this must always be done because the part    653   // this must always be done because the particle change always
590   // uses this value to overwrite the current     654   // uses this value to overwrite the current touchable pointer.
591   //                                              655   //
592   fParticleChange.SetTouchableHandle(retCurren << 656   fParticleChange.SetTouchableHandle(retCurrentTouchable) ;
593                                                << 657   
594   return &fParticleChange;                     << 658   return &fParticleChange ;
595 }                                                 659 }
596                                                   660 
597 //....oooOO0OOooo........oooOO0OOooo........oo    661 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
598                                                   662 
599 // New method takes over the responsibility to << 663 // New method takes over the responsibility to reset the state 
600 // of G4MonopoleTransportation object at the s << 664 // of G4MonopoleTransportation object at the start of a new track 
601 // or the resumption of a suspended track.     << 665 // or the resumption of a suspended track. 
602                                                   666 
603 void G4MonopoleTransportation::StartTracking(G << 667 void 
                                                   >> 668 G4MonopoleTransportation::StartTracking(G4Track* aTrack)
604 {                                                 669 {
605   G4VProcess::StartTracking(aTrack);              670   G4VProcess::StartTracking(aTrack);
606                                                   671 
607   // The actions here are those that were take << 672 // The actions here are those that were taken in AlongStepGPIL
608   //   when track.GetCurrentStepNumber()==1    << 673 //   when track.GetCurrentStepNumber()==1
609                                                   674 
610   // reset safety value and center                675   // reset safety value and center
611   //                                              676   //
612   fPreviousSafety = 0.0;                       << 677   fPreviousSafety    = 0.0 ; 
613   fPreviousSftOrigin = G4ThreeVector(0., 0., 0 << 678   fPreviousSftOrigin = G4ThreeVector(0.,0.,0.) ;
614                                                << 679   
615   // reset looping counter -- for motion in fi    680   // reset looping counter -- for motion in field
616   fNoLooperTrials = 0;                         << 681   fNoLooperTrials= 0; 
617   // Must clear this state .. else it depends     682   // Must clear this state .. else it depends on last track's value
618   //  --> a better solution would set this fro << 683   //  --> a better solution would set this from state of suspended track TODO ? 
619   // Was if( aTrack->GetCurrentStepNumber()==1    684   // Was if( aTrack->GetCurrentStepNumber()==1 ) { .. }
620                                                   685 
621   // ChordFinder reset internal state             686   // ChordFinder reset internal state
622   //                                              687   //
623   if (DoesGlobalFieldExist()) {                << 688   if( DoesGlobalFieldExist() ) {
624     fFieldPropagator->ClearPropagatorState();  << 689      fFieldPropagator->ClearPropagatorState();   
625     // Resets all state of field propagator cl << 690        // Resets all state of field propagator class (ONLY)
626     // including safety values                 << 691        //  including safety values (in case of overlaps and to wipe for first track).
627     // in case of overlaps and to wipe for fir << 
628                                                   692 
629     // G4ChordFinder* chordF= fFieldPropagator << 693      // G4ChordFinder* chordF= fFieldPropagator->GetChordFinder();
630     // if( chordF ) chordF->ResetStepEstimate( << 694      // if( chordF ) chordF->ResetStepEstimate();
631   }                                               695   }
632                                                   696 
633   // Make sure to clear the chord finders of a    697   // Make sure to clear the chord finders of all fields (ie managers)
634   G4FieldManagerStore* fieldMgrStore = G4Field << 698   static G4FieldManagerStore* fieldMgrStore= G4FieldManagerStore::GetInstance();
635   fieldMgrStore->ClearAllChordFindersState();  << 699   fieldMgrStore->ClearAllChordFindersState(); 
636                                                   700 
637   // Update the current touchable handle  (fro    701   // Update the current touchable handle  (from the track's)
638   //                                              702   //
639   fCurrentTouchableHandle = aTrack->GetTouchab    703   fCurrentTouchableHandle = aTrack->GetTouchableHandle();
640 }                                                 704 }
641                                                   705 
642 //....oooOO0OOooo........oooOO0OOooo........oo    706 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 707 
643                                                   708