Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/error_propagation/src/G4ErrorPropagatorManager.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 /error_propagation/src/G4ErrorPropagatorManager.cc (Version 11.3.0) and /error_propagation/src/G4ErrorPropagatorManager.cc (Version 9.5.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4ErrorPropagatorManager.cc,v 1.3 2007-05-31 15:28:51 gcosmo Exp $
                                                   >>  27 // GEANT4 tag $Name: not supported by cvs2svn $
 26 //                                                 28 //
 27 // -------------------------------------------     29 // ------------------------------------------------------------
 28 //      GEANT 4 class implementation file      <<  30 //      GEANT 4 class implementation file 
 29 // -------------------------------------------     31 // ------------------------------------------------------------
 30 //                                                 32 //
 31                                                    33 
 32 #include "G4ErrorPropagatorManager.hh"             34 #include "G4ErrorPropagatorManager.hh"
 33                                                    35 
 34 #include "G4SystemOfUnits.hh"                      36 #include "G4SystemOfUnits.hh"
 35 #include "G4MagIntegratorStepper.hh"               37 #include "G4MagIntegratorStepper.hh"
 36 #include "G4Mag_UsualEqRhs.hh"                     38 #include "G4Mag_UsualEqRhs.hh"
 37 #include "G4Mag_EqRhs.hh"                          39 #include "G4Mag_EqRhs.hh"
 38 #include "G4MagIntegratorDriver.hh"                40 #include "G4MagIntegratorDriver.hh"
 39                                                    41 
 40 #include "G4ClassicalRK4.hh"                       42 #include "G4ClassicalRK4.hh"
 41 #include "G4ExactHelixStepper.hh"                  43 #include "G4ExactHelixStepper.hh"
 42 #include "G4HelixExplicitEuler.hh"                 44 #include "G4HelixExplicitEuler.hh"
 43                                                    45 
 44 #include "G4EventManager.hh"                       46 #include "G4EventManager.hh"
 45 #include "G4ErrorRunManagerHelper.hh"              47 #include "G4ErrorRunManagerHelper.hh"
 46 #include "G4ErrorPropagator.hh"                    48 #include "G4ErrorPropagator.hh"
 47 #include "G4ErrorMag_UsualEqRhs.hh"                49 #include "G4ErrorMag_UsualEqRhs.hh"
 48                                                    50 
 49 #include "G4VParticleChange.hh"                    51 #include "G4VParticleChange.hh"
 50 #include "G4ParticleChangeForMSC.hh"               52 #include "G4ParticleChangeForMSC.hh"
 51 #include "G4ParticleChange.hh"                     53 #include "G4ParticleChange.hh"
 52 #include "G4Track.hh"                              54 #include "G4Track.hh"
 53 #include "G4TransportationManager.hh"              55 #include "G4TransportationManager.hh"
 54 #include "G4ErrorPropagationNavigator.hh"          56 #include "G4ErrorPropagationNavigator.hh"
 55 #include "G4GeometryManager.hh"                    57 #include "G4GeometryManager.hh"
 56 #include "G4StateManager.hh"                       58 #include "G4StateManager.hh"
 57 #include "G4ChordFinder.hh"                        59 #include "G4ChordFinder.hh"
 58 #include "G4EquationOfMotion.hh"                   60 #include "G4EquationOfMotion.hh"
 59 #include "G4FieldManager.hh"                       61 #include "G4FieldManager.hh"
 60 #include "G4PropagatorInField.hh"                  62 #include "G4PropagatorInField.hh"
 61 #include "G4RunManager.hh"                         63 #include "G4RunManager.hh"
 62 #include "G4VParticleChange.hh"                    64 #include "G4VParticleChange.hh"
 63                                                    65 
 64 G4ThreadLocal G4ErrorPropagatorManager*        <<  66 G4ErrorPropagatorManager*
 65   G4ErrorPropagatorManager::theG4ErrorPropagat <<  67 G4ErrorPropagatorManager::theG4ErrorPropagatorManager = 0;
 66                                                    68 
 67 //--------------------------------------------     69 //-----------------------------------------------------------------------
 68 G4ErrorPropagatorManager* G4ErrorPropagatorMan     70 G4ErrorPropagatorManager* G4ErrorPropagatorManager::GetErrorPropagatorManager()
 69 {                                                  71 {
 70   if(theG4ErrorPropagatorManager == NULL)      <<  72   if( theG4ErrorPropagatorManager == NULL ) {
 71   {                                            << 
 72     theG4ErrorPropagatorManager = new G4ErrorP     73     theG4ErrorPropagatorManager = new G4ErrorPropagatorManager;
 73   }                                                74   }
 74                                                    75 
 75   return theG4ErrorPropagatorManager;              76   return theG4ErrorPropagatorManager;
 76 }                                                  77 }
 77                                                    78 
                                                   >>  79 
 78 //--------------------------------------------     80 //-----------------------------------------------------------------------
 79 G4ErrorPropagatorManager::G4ErrorPropagatorMan     81 G4ErrorPropagatorManager::G4ErrorPropagatorManager()
 80 {                                                  82 {
 81   //----- Initialize a few things                  83   //----- Initialize a few things
 82   // o  theG4ErrorPropagatorManager = this;    <<  84   //o  theG4ErrorPropagatorManager = this;
 83                                                    85 
 84   char* g4emverb = std::getenv("G4EVERBOSE");  <<  86   char* g4emverb = getenv("G4EVERBOSE");
 85   if(!g4emverb)                                <<  87   if( !g4emverb ) {
 86   {                                            <<  88     G4ErrorPropagatorData::GetErrorPropagatorData()->SetVerbose( 0 );
 87     G4ErrorPropagatorData::GetErrorPropagatorD <<  89   } else {
 88   }                                            <<  90     G4ErrorPropagatorData::GetErrorPropagatorData()->SetVerbose( atoi( g4emverb ) );
 89   else                                         << 
 90   {                                            << 
 91     G4ErrorPropagatorData::GetErrorPropagatorD << 
 92   }                                                91   }
 93                                                    92 
 94   thePropagator = 0;                               93   thePropagator = 0;
 95                                                    94 
 96   theEquationOfMotion = 0;                         95   theEquationOfMotion = 0;
 97                                                    96 
 98   StartG4ErrorRunManagerHelper();              <<  97   StartG4ErrorRunManagerHelper(); 
 99                                                <<  98   
100   G4ErrorPropagatorData::GetErrorPropagatorDat <<  99   G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_PreInit );
101     G4ErrorState_PreInit);                     << 
102                                                   100 
103   theG4ErrorPropagationNavigator = 0;             101   theG4ErrorPropagationNavigator = 0;
104                                                   102 
105   StartNavigator();  // navigator has to be in << 103   StartNavigator(); //navigator has to be initialized at the beggining !?!?!
                                                   >> 104 
                                                   >> 105 
106 }                                                 106 }
107                                                   107 
                                                   >> 108 
108 //--------------------------------------------    109 //-----------------------------------------------------------------------
109 G4ErrorPropagatorManager::~G4ErrorPropagatorMa    110 G4ErrorPropagatorManager::~G4ErrorPropagatorManager()
110 {                                                 111 {
111   delete theEquationOfMotion;                     112   delete theEquationOfMotion;
112   delete theG4ErrorPropagationNavigator;          113   delete theG4ErrorPropagationNavigator;
113   delete thePropagator;                           114   delete thePropagator;
114   delete theG4ErrorRunManagerHelper;              115   delete theG4ErrorRunManagerHelper;
115   delete theG4ErrorPropagatorManager;             116   delete theG4ErrorPropagatorManager;
116 }                                                 117 }
117                                                   118 
                                                   >> 119 
118 //--------------------------------------------    120 //-----------------------------------------------------------------------
119 void G4ErrorPropagatorManager::StartG4ErrorRun    121 void G4ErrorPropagatorManager::StartG4ErrorRunManagerHelper()
120 {                                                 122 {
121   //----- Initialize G4ErrorRunManagerHelper      123   //----- Initialize G4ErrorRunManagerHelper
122   theG4ErrorRunManagerHelper = G4ErrorRunManag    124   theG4ErrorRunManagerHelper = G4ErrorRunManagerHelper::GetRunManagerKernel();
123                                                   125 
124   if(theG4ErrorRunManagerHelper == 0)          << 126   if( theG4ErrorRunManagerHelper == 0 ) {
125   {                                            << 
126     theG4ErrorRunManagerHelper = new G4ErrorRu    127     theG4ErrorRunManagerHelper = new G4ErrorRunManagerHelper();
127   }                                               128   }
128                                                   129 
129   //----- User Initialization classes          << 130   //----- User Initialization classes 
130   //--- GEANT4e PhysicsList                       131   //--- GEANT4e PhysicsList
131   if(G4ErrorPropagatorData::verbose() >= 4)    << 132   if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::StartG4eRunManager() done " << theG4ErrorRunManagerHelper << G4endl;
132     G4cout << " G4ErrorPropagatorManager::Star << 
133            << theG4ErrorRunManagerHelper << G4 << 
134   //-  theG4eRunManager->SetUserInitialization    133   //-  theG4eRunManager->SetUserInitialization(new G4ErrorPhysicsList);
                                                   >> 134 
135 }                                                 135 }
136                                                   136 
                                                   >> 137 
137 //--------------------------------------------    138 //-----------------------------------------------------------------------
138 void G4ErrorPropagatorManager::StartNavigator(    139 void G4ErrorPropagatorManager::StartNavigator()
139 {                                                 140 {
140   if(theG4ErrorPropagationNavigator == 0)      << 141   if( theG4ErrorPropagationNavigator == 0 ) {
141   {                                            << 142     G4TransportationManager*transportationManager = G4TransportationManager::GetTransportationManager();
142     G4TransportationManager* transportationMan << 143     
143       G4TransportationManager::GetTransportati << 
144                                                << 
145     G4Navigator* g4navi = transportationManage    144     G4Navigator* g4navi = transportationManager->GetNavigatorForTracking();
146                                                << 145    
147     G4VPhysicalVolume* world = g4navi->GetWorl    146     G4VPhysicalVolume* world = g4navi->GetWorldVolume();
148     G4int verb               = g4navi->GetVerb << 147     G4int verb = g4navi->GetVerboseLevel();
149     delete g4navi;                                148     delete g4navi;
150                                                   149 
151     theG4ErrorPropagationNavigator = new G4Err    150     theG4ErrorPropagationNavigator = new G4ErrorPropagationNavigator();
152                                                   151 
153     if(world != 0)                             << 152     if( world != 0 ) {
154     {                                          << 153       theG4ErrorPropagationNavigator->SetWorldVolume( world );
155       theG4ErrorPropagationNavigator->SetWorld << 
156     }                                             154     }
157     theG4ErrorPropagationNavigator->SetVerbose << 155     theG4ErrorPropagationNavigator->SetVerboseLevel( verb );   
158                                                << 156     
159     transportationManager->SetNavigatorForTrac << 157     transportationManager->SetNavigatorForTracking(theG4ErrorPropagationNavigator);
160       theG4ErrorPropagationNavigator);         << 158     transportationManager->GetPropagatorInField()->GetIntersectionLocator()
161     transportationManager->GetPropagatorInFiel << 159                          ->SetNavigatorFor(theG4ErrorPropagationNavigator);
162       ->GetIntersectionLocator()               << 160     G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager()
163       ->SetNavigatorFor(theG4ErrorPropagationN << 161                          ->SetNavigator(theG4ErrorPropagationNavigator);
164     G4EventManager::GetEventManager()          << 
165       ->GetTrackingManager()                   << 
166       ->GetSteppingManager()                   << 
167       ->SetNavigator(theG4ErrorPropagationNavi << 
168     //  G4ThreeVector center(0,0,0);              162     //  G4ThreeVector center(0,0,0);
169     //  theG4ErrorPropagationNavigator->Locate    163     //  theG4ErrorPropagationNavigator->LocateGlobalPointAndSetup(center,0,false);
                                                   >> 164     
170   }                                               165   }
171                                                   166 
172   if(G4ErrorPropagatorData::verbose() >= 2)    << 167   if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << " theState at StartNavigator " << PrintG4ErrorState() << G4endl;
173     G4cout << " theState at StartNavigator " < << 168 
174 }                                                 169 }
                                                   >> 170   
175                                                   171 
176 //--------------------------------------------    172 //-----------------------------------------------------------------------
177 void G4ErrorPropagatorManager::InitGeant4e()      173 void G4ErrorPropagatorManager::InitGeant4e()
178 {                                                 174 {
179   if(G4ErrorPropagatorData::verbose() >= 1)    << 175   if( G4ErrorPropagatorData::verbose() >= 1 ) G4cout << "InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
180     G4cout << "InitGeant4e GEANT4e State= " << << 176   G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
181            << " GEANT4 State= " << PrintG4Stat << 
182   G4ApplicationState currentState =            << 
183     G4StateManager::GetStateManager()->GetCurr << 
184   //----- Initialize run                          177   //----- Initialize run
185   //  if( G4StateManager::GetStateManager()->G << 178   //  if( G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit) {
186   //  G4State_PreInit) {                       << 179   
187                                                << 180   if( G4ErrorPropagatorData::GetErrorPropagatorData()->GetState() == G4ErrorState_PreInit ) {
188   if(G4ErrorPropagatorData::GetErrorPropagator << 181     if ( currentState == G4State_PreInit || currentState == G4State_Idle) {
189      G4ErrorState_PreInit)                     << 
190   {                                            << 
191     if(currentState == G4State_PreInit || curr << 
192     {                                          << 
193       //    G4eRunManager::GetRunManager()->In    182       //    G4eRunManager::GetRunManager()->Initialize();
194       theG4ErrorRunManagerHelper->InitializeGe    183       theG4ErrorRunManagerHelper->InitializeGeometry();
195       theG4ErrorRunManagerHelper->InitializePh    184       theG4ErrorRunManagerHelper->InitializePhysics();
196     }                                             185     }
197                                                << 186     
198     InitFieldForBackwards();                      187     InitFieldForBackwards();
199                                                << 188     
200     //-    G4StateManager::GetStateManager()->    189     //-    G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
201                                                << 190     
202     if(G4ErrorPropagatorData::verbose() >= 4)  << 191     if( G4ErrorPropagatorData::verbose() >= 4 )   G4cout << " bef  theG4ErrorPropagatorManager->RunInitialization() " <<  G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
203       G4cout << " bef  theG4ErrorPropagatorMan << 
204              << G4StateManager::GetStateManage << 
205     theG4ErrorRunManagerHelper->RunInitializat    192     theG4ErrorRunManagerHelper->RunInitialization();
206     if(G4ErrorPropagatorData::verbose() >= 4)  << 193     if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " aft  theG4ErrorPropagatorManager->RunInitialization() " <<  G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
207       G4cout << " aft  theG4ErrorPropagatorMan << 194     
208              << G4StateManager::GetStateManage << 195     if( !thePropagator ) thePropagator = new G4ErrorPropagator();  // currently the only propagator possible
209                                                << 196     
210     if(!thePropagator)                         << 
211       thePropagator =                          << 
212         new G4ErrorPropagator();  // currently << 
213                                                << 
214     InitTrackPropagation();                       197     InitTrackPropagation();
                                                   >> 198   } else {
                                                   >> 199     G4cerr << "G4ErrorPropagatorManager::InitGeant4e: Illegal application state - "
                                                   >> 200            << "G4ErrorPropagatorManager::InitGeant4e() ignored." << G4endl;
                                                   >> 201     G4cerr << " GEANT4e State= " << PrintG4ErrorState() 
                                                   >> 202       //<< " GEANT4 State= " <<  PrintG4State() 
                                                   >> 203            << G4endl;
215   }                                               204   }
216   else                                         << 205   
217   {                                            << 
218     std::ostringstream message;                << 
219     message << "Illegal GEANT4e State= " << Pr << 
220     G4Exception("G4ErrorPropagatorManager::Ini << 
221                 JustWarning, message);         << 
222   }                                            << 
223                                                << 
224   //----- Set the tracking geometry for this p    206   //----- Set the tracking geometry for this propagation
225   // t  SetTrackingGeometry();                 << 207   //t  SetTrackingGeometry();
226   //----- Set the physics list for this propag    208   //----- Set the physics list for this propagation
227   // t  SetPhysicsList();                      << 209   //t  SetPhysicsList();
228   //----- Set the field propagation parameters    210   //----- Set the field propagation parameters for this propagation
229   // t  SetFieldPropagationParameters();       << 211   //t  SetFieldPropagationParameters();
230   G4ErrorPropagatorData::GetErrorPropagatorDat << 212   G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Init );
                                                   >> 213 
                                                   >> 214   if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << "End InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
                                                   >> 215 
231                                                   216 
232   if(G4ErrorPropagatorData::verbose() >= 2)    << 
233     G4cout << "End InitGeant4e GEANT4e State=  << 
234            << " GEANT4 State= " << PrintG4Stat << 
235 }                                                 217 }
236                                                   218 
                                                   >> 219 
237 //--------------------------------------------    220 //-----------------------------------------------------------------------
238 void G4ErrorPropagatorManager::InitTrackPropag    221 void G4ErrorPropagatorManager::InitTrackPropagation()
239 {                                                 222 {
240   thePropagator->SetStepN(0);                  << 223   thePropagator->SetStepN( 0 );
                                                   >> 224 
                                                   >> 225   G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Propagating );
241                                                   226 
242   G4ErrorPropagatorData::GetErrorPropagatorDat << 
243     G4ErrorState_Propagating);                 << 
244 }                                                 227 }
245                                                   228 
                                                   >> 229 
246 //--------------------------------------------    230 //-----------------------------------------------------------------------
247 G4bool G4ErrorPropagatorManager::InitFieldForB    231 G4bool G4ErrorPropagatorManager::InitFieldForBackwards()
248 {                                                 232 {
249   if(G4ErrorPropagatorData::verbose() >= 4)    << 233 
250     G4cout << " G4ErrorPropagatorManager::Init << 234   if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::InitFieldForBackwards() " << G4endl;
251   //----- Gets the current equation of motion     235   //----- Gets the current equation of motion
252   G4FieldManager* fieldMgr =                   << 236   G4FieldManager* fieldMgr= G4TransportationManager::GetTransportationManager()->GetFieldManager();
253     G4TransportationManager::GetTransportation << 
254   //  G4cout << " fieldMgr " << fieldMgr << G4    237   //  G4cout << " fieldMgr " << fieldMgr << G4endl;
255   if(!fieldMgr)                                << 238   if( !fieldMgr ) return 0;
256     return 0;                                  << 
257                                                   239 
258   //  G4Field* myfield = fieldMgr->GetDetector    240   //  G4Field* myfield = fieldMgr->GetDetectorField();
259   G4ChordFinder* cf = fieldMgr->GetChordFinder << 241   G4ChordFinder* cf = fieldMgr ->GetChordFinder();
260   if(!cf)                                      << 242   if( !cf ) return 0;
261     return 0;                                  << 243   G4MagInt_Driver* mid = cf->GetIntegrationDriver();
262   auto driver = cf->GetIntegrationDriver();    << 244   if( !mid ) return 0;
263   if(!driver)                                  << 245   G4MagIntegratorStepper* stepper = const_cast<G4MagIntegratorStepper*>(mid->GetStepper());
264     return 0;                                  << 246   if( !stepper ) return 0;
265   auto equation = driver->GetEquationOfMotion( << 247   G4EquationOfMotion* equation = stepper->GetEquationOfMotion();
266                                                << 248 
267   //----- Replaces the equation by a G4ErrorMa << 249   //----- Replaces the equation by a G4ErrorMag_UsualEqRhs to handle backwards tracking
268   //tracking                                   << 250   if ( !dynamic_cast<G4ErrorMag_UsualEqRhs*>(equation) ) {
269   if(!dynamic_cast<G4ErrorMag_UsualEqRhs*>(equ << 251 
270   {                                            << 252     G4MagneticField* myfield = (G4MagneticField*)fieldMgr->GetDetectorField();
271     G4MagneticField* myfield = (G4MagneticFiel << 253     
272                                                << 254     //    G4Mag_UsualEqRhs* fEquation_usual = dynamic_cast<G4Mag_UsualEqRhs*>(equation);
273     //    G4Mag_UsualEqRhs* fEquation_usual =  << 255     if( theEquationOfMotion == 0 ) theEquationOfMotion = new G4ErrorMag_UsualEqRhs(myfield);
274     //    dynamic_cast<G4Mag_UsualEqRhs*>(equa << 256  
275     if(theEquationOfMotion == 0)               << 
276       theEquationOfMotion = new G4ErrorMag_Usu << 
277                                                << 
278     //---- Pass the equation of motion to the     257     //---- Pass the equation of motion to the G4MagIntegratorStepper
279     driver->SetEquationOfMotion(theEquationOfM << 258     stepper->SetEquationOfMotion( theEquationOfMotion );
280                                                   259 
281     //--- change stepper for speed tests          260     //--- change stepper for speed tests
282     G4MagIntegratorStepper* g4eStepper =       << 261    G4MagIntegratorStepper* g4eStepper = new G4ClassicalRK4(theEquationOfMotion);
283       new G4ClassicalRK4(theEquationOfMotion); << 262    // G4MagIntegratorStepper* g4eStepper = new G4ExactHelixStepper(theEquationOfMotion);
284     // G4MagIntegratorStepper* g4eStepper = ne << 263     
285     // G4ExactHelixStepper(theEquationOfMotion << 264     //---- 
286                                                << 265     G4MagneticField* field = static_cast<G4MagneticField*>(const_cast<G4Field*>(fieldMgr->GetDetectorField()));
287     //----                                     << 266     G4ChordFinder* pChordFinder = new G4ChordFinder(field, 1.0e-2*mm, g4eStepper);
288     G4MagneticField* field = static_cast<G4Mag << 
289       const_cast<G4Field*>(fieldMgr->GetDetect << 
290     G4ChordFinder* pChordFinder =              << 
291       new G4ChordFinder(field, 1.0e-2 * mm, g4 << 
292                                                   267 
293     fieldMgr->SetChordFinder(pChordFinder);       268     fieldMgr->SetChordFinder(pChordFinder);
                                                   >> 269 
294   }                                               270   }
295                                                   271 
296   return 1;                                       272   return 1;
297 }                                                 273 }
298                                                   274 
                                                   >> 275 
299 //--------------------------------------------    276 //-----------------------------------------------------------------------
300 G4int G4ErrorPropagatorManager::Propagate(G4Er << 277 G4int G4ErrorPropagatorManager::Propagate( G4ErrorTrajState* currentTS, const G4ErrorTarget* target, G4ErrorMode mode )
301                                           cons << 278 {
302                                           G4Er << 279   G4ErrorPropagatorData::GetErrorPropagatorData()->SetMode( mode );
303 {                                              << 280   if( !thePropagator ) thePropagator = new G4ErrorPropagator();  // currently the only propagator possible
304   G4ErrorPropagatorData::GetErrorPropagatorDat << 
305   if(!thePropagator)                           << 
306     thePropagator =                            << 
307       new G4ErrorPropagator();  // currently t << 
308                                                   281 
309   SetSteppingManagerVerboseLevel();               282   SetSteppingManagerVerboseLevel();
310   InitTrackPropagation();                         283   InitTrackPropagation();
311                                                   284 
312   G4int ierr = thePropagator->Propagate(curren << 285   G4int ierr = thePropagator->Propagate( currentTS, target, mode );
313                                                   286 
314   EventTermination();                             287   EventTermination();
315                                                   288 
316   return ierr;                                    289   return ierr;
317 }                                                 290 }
318                                                   291 
                                                   >> 292 
319 //--------------------------------------------    293 //-----------------------------------------------------------------------
320 G4int G4ErrorPropagatorManager::PropagateOneSt << 294 G4int G4ErrorPropagatorManager::PropagateOneStep( G4ErrorTrajState* currentTS, G4ErrorMode mode )
321                                                << 
322 {                                                 295 {
323   G4ErrorPropagatorData::GetErrorPropagatorDat << 296   G4ErrorPropagatorData::GetErrorPropagatorData()->SetMode( mode );
324                                                   297 
325   if(!thePropagator)                           << 298   if( !thePropagator ) thePropagator = new G4ErrorPropagator();  // currently the only propagator possible
326     thePropagator =                            << 
327       new G4ErrorPropagator();  // currently t << 
328                                                   299 
329   SetSteppingManagerVerboseLevel();               300   SetSteppingManagerVerboseLevel();
330                                                   301 
331   return thePropagator->PropagateOneStep(curre << 302   return thePropagator->PropagateOneStep( currentTS );
332 }                                                 303 }
333                                                   304 
                                                   >> 305 
334 //--------------------------------------------    306 //-----------------------------------------------------------------------
335 G4bool G4ErrorPropagatorManager::CloseGeometry    307 G4bool G4ErrorPropagatorManager::CloseGeometry()
336 {                                                 308 {
337   G4GeometryManager* geomManager = G4GeometryM    309   G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
338   geomManager->OpenGeometry();                    310   geomManager->OpenGeometry();
339   if(G4StateManager::GetStateManager()->GetCur << 311   if(  G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
340   {                                            << 
341     G4StateManager::GetStateManager()->SetNewS    312     G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
342   }                                               313   }
343                                                   314 
344   return TRUE;                                    315   return TRUE;
345 }                                                 316 }
346                                                   317 
                                                   >> 318 
347 //--------------------------------------------    319 //---------------------------------------------------------------------------
348 void G4ErrorPropagatorManager::SetUserInitiali << 320 void G4ErrorPropagatorManager::SetUserInitialization(G4VUserDetectorConstruction* userInit)
349   G4VUserDetectorConstruction* userInit)       << 
350 {                                                 321 {
351   theG4ErrorRunManagerHelper->SetUserInitializ << 322   theG4ErrorRunManagerHelper->SetUserInitialization( userInit); 
352 }                                                 323 }
353                                                   324 
                                                   >> 325 
354 //--------------------------------------------    326 //---------------------------------------------------------------------------
355 void G4ErrorPropagatorManager::SetUserInitiali << 327 void G4ErrorPropagatorManager::SetUserInitialization(G4VPhysicalVolume* userInit)
356   G4VPhysicalVolume* userInit)                 << 328 { 
357 {                                              << 329   theG4ErrorRunManagerHelper->SetUserInitialization( userInit); 
358   theG4ErrorRunManagerHelper->SetUserInitializ << 
359 }                                                 330 }
                                                   >> 331  
360                                                   332 
361 //--------------------------------------------    333 //---------------------------------------------------------------------------
362 void G4ErrorPropagatorManager::SetUserInitiali << 334 void G4ErrorPropagatorManager::SetUserInitialization(G4VUserPhysicsList* userInit)
363   G4VUserPhysicsList* userInit)                << 335 { 
364 {                                              << 336   theG4ErrorRunManagerHelper->SetUserInitialization( userInit); 
365   theG4ErrorRunManagerHelper->SetUserInitializ << 
366 }                                                 337 }
367                                                   338 
                                                   >> 339 
368 //--------------------------------------------    340 //---------------------------------------------------------------------------
369 void G4ErrorPropagatorManager::SetUserAction(G    341 void G4ErrorPropagatorManager::SetUserAction(G4UserTrackingAction* userAction)
370 {                                                 342 {
371   G4EventManager::GetEventManager()->SetUserAc << 343   G4EventManager::GetEventManager()->SetUserAction( userAction ); 
372 }                                                 344 }
373                                                   345 
                                                   >> 346 
374 //--------------------------------------------    347 //---------------------------------------------------------------------------
375 void G4ErrorPropagatorManager::SetUserAction(G    348 void G4ErrorPropagatorManager::SetUserAction(G4UserSteppingAction* userAction)
376 {                                                 349 {
377   G4EventManager::GetEventManager()->SetUserAc << 350   G4EventManager::GetEventManager()->SetUserAction( userAction ); 
378 }                                                 351 }
379                                                   352 
                                                   >> 353 
380 //--------------------------------------------    354 //---------------------------------------------------------------------------
381 void G4ErrorPropagatorManager::SetSteppingMana    355 void G4ErrorPropagatorManager::SetSteppingManagerVerboseLevel()
382 {                                                 356 {
383   G4TrackingManager* trkmgr =                  << 357   G4TrackingManager* trkmgr = G4EventManager::GetEventManager()->GetTrackingManager();
384     G4EventManager::GetEventManager()->GetTrac << 358   trkmgr->GetSteppingManager()->SetVerboseLevel( trkmgr->GetVerboseLevel() );
385   trkmgr->GetSteppingManager()->SetVerboseLeve << 
386 }                                                 359 }
387                                                   360 
                                                   >> 361 
388 //--------------------------------------------    362 //---------------------------------------------------------------------------
389 void G4ErrorPropagatorManager::EventTerminatio    363 void G4ErrorPropagatorManager::EventTermination()
390 {                                                 364 {
391   G4ErrorPropagatorData::GetErrorPropagatorDat << 365   G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Init );
392 }                                                 366 }
393                                                   367 
                                                   >> 368 
394 //--------------------------------------------    369 //---------------------------------------------------------------------------
395 void G4ErrorPropagatorManager::RunTermination(    370 void G4ErrorPropagatorManager::RunTermination()
396 {                                                 371 {
397   G4ErrorPropagatorData::GetErrorPropagatorDat << 372 G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_PreInit );
398     G4ErrorState_PreInit);                     << 373   theG4ErrorRunManagerHelper->RunTermination(); 
399   theG4ErrorRunManagerHelper->RunTermination() << 
400 }                                                 374 }
401                                                   375 
                                                   >> 376 
402 //--------------------------------------------    377 //---------------------------------------------------------------------------
403 G4String G4ErrorPropagatorManager::PrintG4Erro << 378 G4String G4ErrorPropagatorManager::PrintG4ErrorState() 
404 {                                                 379 {
405   return PrintG4ErrorState(                    << 380   return PrintG4ErrorState( G4ErrorPropagatorData::GetErrorPropagatorData()->GetState() );
406     G4ErrorPropagatorData::GetErrorPropagatorD << 
407 }                                                 381 }
408                                                   382 
                                                   >> 383 
409 //--------------------------------------------    384 //---------------------------------------------------------------------------
410 G4String G4ErrorPropagatorManager::PrintG4Erro << 385 G4String G4ErrorPropagatorManager::PrintG4ErrorState( G4ErrorState state ) 
411 {                                                 386 {
412   G4String nam = "";                              387   G4String nam = "";
413   switch(state)                                << 388   switch (state){
414   {                                            << 389   case G4ErrorState_PreInit: 
415     case G4ErrorState_PreInit:                 << 390     nam = "G4ErrorState_PreInit"; 
416       nam = "G4ErrorState_PreInit";            << 391     break;
417       break;                                   << 392   case G4ErrorState_Init: 
418     case G4ErrorState_Init:                    << 393     nam = "G4ErrorState_Init"; 
419       nam = "G4ErrorState_Init";               << 394     break;
420       break;                                   << 395   case G4ErrorState_Propagating:
421     case G4ErrorState_Propagating:             << 396     nam = "G4ErrorState_Propagating";
422       nam = "G4ErrorState_Propagating";        << 397     break;
423       break;                                   << 398   case G4ErrorState_TargetCloserThanBoundary:
424     case G4ErrorState_TargetCloserThanBoundary << 399     nam = "G4ErrorState_TargetCloserThanBoundary";
425       nam = "G4ErrorState_TargetCloserThanBoun << 400     break;
426       break;                                   << 401   case G4ErrorState_StoppedAtTarget:
427     case G4ErrorState_StoppedAtTarget:         << 402     nam = "G4ErrorState_StoppedAtTarget";
428       nam = "G4ErrorState_StoppedAtTarget";    << 403     break;
429       break;                                   << 
430   }                                               404   }
431                                                   405 
432   return nam;                                     406   return nam;
433 }                                                 407 }
434                                                   408 
                                                   >> 409 
435 //--------------------------------------------    410 //---------------------------------------------------------------------------
436 G4String G4ErrorPropagatorManager::PrintG4Stat    411 G4String G4ErrorPropagatorManager::PrintG4State()
437 {                                                 412 {
438   return PrintG4State(G4StateManager::GetState    413   return PrintG4State(G4StateManager::GetStateManager()->GetCurrentState());
439 }                                                 414 }
440                                                   415 
                                                   >> 416 
441 //--------------------------------------------    417 //---------------------------------------------------------------------------
442 G4String G4ErrorPropagatorManager::PrintG4Stat << 418 G4String G4ErrorPropagatorManager::PrintG4State( G4ApplicationState state )
443 {                                                 419 {
444   G4String nam = "";                              420   G4String nam = "";
445   switch(state)                                << 421   switch ( state ){
446   {                                            << 422   case G4State_PreInit:
447     case G4State_PreInit:                      << 423     nam = "G4State_PreInit";
448       nam = "G4State_PreInit";                 << 424     break;
449       break;                                   << 425   case G4State_Init:
450     case G4State_Init:                         << 426     nam = "G4State_Init";
451       nam = "G4State_Init";                    << 427     break;
452       break;                                   << 428   case G4State_Idle:
453     case G4State_Idle:                         << 429     nam = "G4State_Idle";
454       nam = "G4State_Idle";                    << 430     break;
455       break;                                   << 431   case G4State_GeomClosed:
456     case G4State_GeomClosed:                   << 432     nam = "G4State_GeomClosed";
457       nam = "G4State_GeomClosed";              << 433     break;
458       break;                                   << 434   case G4State_EventProc:
459     case G4State_EventProc:                    << 435     nam = "G4State_EventProc"; 
460       nam = "G4State_EventProc";               << 436     break;
461       break;                                   << 437   case G4State_Quit:
462     case G4State_Quit:                         << 438     nam = "G4State_Quit";
463       nam = "G4State_Quit";                    << 439     break;
464       break;                                   << 440   case G4State_Abort:
465     case G4State_Abort:                        << 441     nam = "G4State_Abort";
466       nam = "G4State_Abort";                   << 442     break;
467       break;                                   << 
468   }                                               443   }
469                                                << 444   
470   return nam;                                     445   return nam;
                                                   >> 446 
471 }                                                 447 }
472                                                   448