Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ErrorPropagatorManager.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4ErrorPropagatorManager.cc 107054 2017-11-01 14:35:18Z gcosmo $
27 //
28 // ------------------------------------------------------------
29 // GEANT 4 class implementation file
30 // ------------------------------------------------------------
31 //
32 
34 
35 #include "G4SystemOfUnits.hh"
37 #include "G4Mag_UsualEqRhs.hh"
38 #include "G4Mag_EqRhs.hh"
39 #include "G4MagIntegratorDriver.hh"
40 
41 #include "G4ClassicalRK4.hh"
42 #include "G4ExactHelixStepper.hh"
43 #include "G4HelixExplicitEuler.hh"
44 
45 #include "G4EventManager.hh"
47 #include "G4ErrorPropagator.hh"
48 #include "G4ErrorMag_UsualEqRhs.hh"
49 
50 #include "G4VParticleChange.hh"
52 #include "G4ParticleChange.hh"
53 #include "G4Track.hh"
56 #include "G4GeometryManager.hh"
57 #include "G4StateManager.hh"
58 #include "G4ChordFinder.hh"
59 #include "G4EquationOfMotion.hh"
60 #include "G4FieldManager.hh"
61 #include "G4PropagatorInField.hh"
62 #include "G4RunManager.hh"
63 #include "G4VParticleChange.hh"
64 
67 
68 //-----------------------------------------------------------------------
70 {
71  if( theG4ErrorPropagatorManager == NULL ) {
73  }
74 
76 }
77 
78 
79 //-----------------------------------------------------------------------
81 {
82  //----- Initialize a few things
83  //o theG4ErrorPropagatorManager = this;
84 
85  char* g4emverb = getenv("G4EVERBOSE");
86  if( !g4emverb ) {
88  } else {
90  }
91 
92  thePropagator = 0;
93 
95 
97 
99 
101 
102  StartNavigator(); //navigator has to be initialized at the beggining !?!?!
103 
104 
105 }
106 
107 
108 //-----------------------------------------------------------------------
110 {
111  delete theEquationOfMotion;
113  delete thePropagator;
116 }
117 
118 
119 //-----------------------------------------------------------------------
121 {
122  //----- Initialize G4ErrorRunManagerHelper
124 
125  if( theG4ErrorRunManagerHelper == 0 ) {
127  }
128 
129  //----- User Initialization classes
130  //--- GEANT4e PhysicsList
131  if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::StartG4eRunManager() done " << theG4ErrorRunManagerHelper << G4endl;
132  //- theG4eRunManager->SetUserInitialization(new G4ErrorPhysicsList);
133 
134 }
135 
136 
137 //-----------------------------------------------------------------------
139 {
140  if( theG4ErrorPropagationNavigator == 0 ) {
142 
143  G4Navigator* g4navi = transportationManager->GetNavigatorForTracking();
144 
145  G4VPhysicalVolume* world = g4navi->GetWorldVolume();
146  G4int verb = g4navi->GetVerboseLevel();
147  delete g4navi;
148 
150 
151  if( world != 0 ) {
153  }
155 
157  transportationManager->GetPropagatorInField()->GetIntersectionLocator()
161  // G4ThreeVector center(0,0,0);
162  // theG4ErrorPropagationNavigator->LocateGlobalPointAndSetup(center,0,false);
163 
164  }
165 
166  if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << " theState at StartNavigator " << PrintG4ErrorState() << G4endl;
167 
168 }
169 
170 
171 //-----------------------------------------------------------------------
173 {
174  if( G4ErrorPropagatorData::verbose() >= 1 ) G4cout << "InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
176  //----- Initialize run
177  // if( G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit) {
178 
180  if ( currentState == G4State_PreInit || currentState == G4State_Idle) {
181  // G4eRunManager::GetRunManager()->Initialize();
184  }
185 
187 
188  //- G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
189 
190  if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " bef theG4ErrorPropagatorManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
192  if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " aft theG4ErrorPropagatorManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
193 
194  if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
195 
197  } else {
198  std::ostringstream message;
199  message << "Illegal GEANT4e State= " << PrintG4ErrorState();
200  G4Exception("G4ErrorPropagatorManager::InitGeant4e()",
201  "IllegalState", JustWarning, message);
202  }
203 
204  //----- Set the tracking geometry for this propagation
205  //t SetTrackingGeometry();
206  //----- Set the physics list for this propagation
207  //t SetPhysicsList();
208  //----- Set the field propagation parameters for this propagation
209  //t SetFieldPropagationParameters();
211 
212  if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << "End InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
213 
214 
215 }
216 
217 
218 //-----------------------------------------------------------------------
220 {
221  thePropagator->SetStepN( 0 );
222 
224 
225 }
226 
227 
228 //-----------------------------------------------------------------------
230 {
231 
232  if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::InitFieldForBackwards() " << G4endl;
233  //----- Gets the current equation of motion
235  // G4cout << " fieldMgr " << fieldMgr << G4endl;
236  if( !fieldMgr ) return 0;
237 
238  // G4Field* myfield = fieldMgr->GetDetectorField();
239  G4ChordFinder* cf = fieldMgr ->GetChordFinder();
240  if( !cf ) return 0;
241  auto driver = cf->GetIntegrationDriver();
242  if( !driver ) return 0;
243  auto equation = driver->GetEquationOfMotion();
244 
245  //----- Replaces the equation by a G4ErrorMag_UsualEqRhs to handle backwards tracking
246  if ( !dynamic_cast<G4ErrorMag_UsualEqRhs*>(equation) ) {
247 
248  G4MagneticField* myfield = (G4MagneticField*)fieldMgr->GetDetectorField();
249 
250  // G4Mag_UsualEqRhs* fEquation_usual = dynamic_cast<G4Mag_UsualEqRhs*>(equation);
252 
253  //---- Pass the equation of motion to the G4MagIntegratorStepper
254  driver->SetEquationOfMotion( theEquationOfMotion );
255 
256  //--- change stepper for speed tests
258  // G4MagIntegratorStepper* g4eStepper = new G4ExactHelixStepper(theEquationOfMotion);
259 
260  //----
261  G4MagneticField* field = static_cast<G4MagneticField*>(const_cast<G4Field*>(fieldMgr->GetDetectorField()));
262  G4ChordFinder* pChordFinder = new G4ChordFinder(field, 1.0e-2*mm, g4eStepper);
263 
264  fieldMgr->SetChordFinder(pChordFinder);
265 
266  }
267 
268  return 1;
269 }
270 
271 
272 //-----------------------------------------------------------------------
274 {
276  if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
277 
280 
281  G4int ierr = thePropagator->Propagate( currentTS, target, mode );
282 
284 
285  return ierr;
286 }
287 
288 
289 //-----------------------------------------------------------------------
291 {
293 
294  if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
295 
297 
298  return thePropagator->PropagateOneStep( currentTS );
299 }
300 
301 
302 //-----------------------------------------------------------------------
304 {
306  geomManager->OpenGeometry();
307  if( G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
309  }
310 
311  return TRUE;
312 }
313 
314 
315 //---------------------------------------------------------------------------
317 {
319 }
320 
321 
322 //---------------------------------------------------------------------------
324 {
326 }
327 
328 
329 //---------------------------------------------------------------------------
331 {
333 }
334 
335 
336 //---------------------------------------------------------------------------
338 {
340 }
341 
342 
343 //---------------------------------------------------------------------------
345 {
347 }
348 
349 
350 //---------------------------------------------------------------------------
352 {
354  trkmgr->GetSteppingManager()->SetVerboseLevel( trkmgr->GetVerboseLevel() );
355 }
356 
357 
358 //---------------------------------------------------------------------------
360 {
362 }
363 
364 
365 //---------------------------------------------------------------------------
367 {
370 }
371 
372 
373 //---------------------------------------------------------------------------
375 {
377 }
378 
379 
380 //---------------------------------------------------------------------------
382 {
383  G4String nam = "";
384  switch (state){
385  case G4ErrorState_PreInit:
386  nam = "G4ErrorState_PreInit";
387  break;
388  case G4ErrorState_Init:
389  nam = "G4ErrorState_Init";
390  break;
392  nam = "G4ErrorState_Propagating";
393  break;
395  nam = "G4ErrorState_TargetCloserThanBoundary";
396  break;
398  nam = "G4ErrorState_StoppedAtTarget";
399  break;
400  }
401 
402  return nam;
403 }
404 
405 
406 //---------------------------------------------------------------------------
408 {
409  return PrintG4State(G4StateManager::GetStateManager()->GetCurrentState());
410 }
411 
412 
413 //---------------------------------------------------------------------------
415 {
416  G4String nam = "";
417  switch ( state ){
418  case G4State_PreInit:
419  nam = "G4State_PreInit";
420  break;
421  case G4State_Init:
422  nam = "G4State_Init";
423  break;
424  case G4State_Idle:
425  nam = "G4State_Idle";
426  break;
427  case G4State_GeomClosed:
428  nam = "G4State_GeomClosed";
429  break;
430  case G4State_EventProc:
431  nam = "G4State_EventProc";
432  break;
433  case G4State_Quit:
434  nam = "G4State_Quit";
435  break;
436  case G4State_Abort:
437  nam = "G4State_Abort";
438  break;
439  }
440 
441  return nam;
442 
443 }
G4VIntegrationDriver * GetIntegrationDriver()
static G4ThreadLocal G4ErrorPropagatorManager * theG4ErrorPropagatorManager
G4bool SetNewState(G4ApplicationState requestedState)
const XML_Char * target
Definition: expat.h:268
static void SetVerbose(G4int ver)
void SetNavigator(G4Navigator *value)
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
virtual G4EquationOfMotion * GetEquationOfMotion()=0
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
G4ErrorRunManagerHelper * theG4ErrorRunManagerHelper
void SetUserAction(G4UserTrackingAction *userAction)
static G4ErrorPropagatorManager * GetErrorPropagatorManager()
void SetStepN(const G4int sn)
G4Navigator * GetNavigatorForTracking() const
#define G4ThreadLocal
Definition: tls.hh:69
void SetUserAction(G4UserEventAction *userAction)
void SetVerboseLevel(G4int vLevel)
void SetNavigatorFor(G4Navigator *fNavigator)
G4VIntersectionLocator * GetIntersectionLocator()
bool G4bool
Definition: G4Types.hh:79
G4int GetVerboseLevel() const
G4FieldManager * GetFieldManager() const
G4TrackingManager * GetTrackingManager() const
G4int Propagate(G4ErrorTrajState *currentTS, const G4ErrorTarget *target, G4ErrorMode mode=G4ErrorMode_PropForwards)
void SetMode(G4ErrorMode mode)
static G4GeometryManager * GetInstance()
G4int Propagate(G4ErrorTrajState *currentTS, const G4ErrorTarget *target, G4ErrorMode mode=G4ErrorMode_PropForwards)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
static G4EventManager * GetEventManager()
#define TRUE
Definition: globals.hh:55
const G4Field * GetDetectorField() const
static G4ErrorRunManagerHelper * GetRunManagerKernel()
void OpenGeometry(G4VPhysicalVolume *vol=0)
void SetVerboseLevel(G4int level)
static G4TransportationManager * GetTransportationManager()
G4int PropagateOneStep(G4ErrorTrajState *currentTS, G4ErrorMode mode=G4ErrorMode_PropForwards)
G4ErrorPropagationNavigator * theG4ErrorPropagationNavigator
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
void SetChordFinder(G4ChordFinder *aChordFinder)
int G4int
Definition: G4Types.hh:78
G4ApplicationState GetCurrentState() const
G4GLOB_DLL std::ostream G4cout
void SetState(G4ErrorState sta)
G4ApplicationState
G4PropagatorInField * GetPropagatorInField() const
void SetNavigatorForTracking(G4Navigator *newNavigator)
G4VPhysicalVolume * GetWorldVolume() const
G4SteppingManager * GetSteppingManager() const
void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4int PropagateOneStep(G4ErrorTrajState *currentTS)
void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4StateManager * GetStateManager()
G4ChordFinder * GetChordFinder()
G4int GetVerboseLevel() const
static G4ErrorPropagatorData * GetErrorPropagatorData()