SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
G4MagIntegratorStepperFactory.cc
Go to the documentation of this file.
2 
3 // Geant4
4 #include "G4SystemOfUnits.hh"
5 #include "G4Mag_UsualEqRhs.hh"
6 #include "G4ChordFinder.hh"
7 #include "G4MagIntegratorStepper.hh"
8 #include "G4ClassicalRK4.hh"
9 #include "G4ExplicitEuler.hh"
10 #include "G4HelixExplicitEuler.hh"
11 #include "G4HelixHeum.hh"
12 #include "G4HelixImplicitEuler.hh"
13 #include "G4HelixSimpleRunge.hh"
14 #include "G4ImplicitEuler.hh"
15 #include "G4SimpleHeum.hh"
16 #include "G4SimpleRunge.hh"
17 #include "G4CashKarpRKF45.hh"
18 #include "G4MagneticField.hh"
19 #include "G4FieldManager.hh"
20 #include "G4TransportationManager.hh"
21 #include "G4SystemOfUnits.hh"
22 
23 using std::string;
24 
25 namespace slic {
27  Module("G4MagIntegratorStepperFactory") {
28  m_fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
29  m_field = static_cast<G4MagneticField*>(const_cast<G4Field*>(m_fieldMgr->GetDetectorField()));
30  if (m_field == 0) {
31  log() << LOG::error << "Command refused. Detector has no G4MagneticField." << LOG::done;
32  } else {
33  m_fieldEquations = new G4Mag_UsualEqRhs(m_field);
34  }
35 }
36 
38  delete m_fieldEquations;
39 }
40 
42  G4MagIntegratorStepper* stepper = createG4MagIntegratorStepper(name);
43 
44  if (stepper != 0) {
45 
46  G4ChordFinder* oldChordFinder = m_fieldMgr->GetChordFinder();
47  if (oldChordFinder != 0) {
48  delete oldChordFinder;
49  }
50 
51  /* Create new chord finder with default step minimum. */
52  m_fieldMgr->SetChordFinder(new G4ChordFinder(m_field, 1E-2 * mm, stepper));
53  }
54 }
55 
57  if (name == "G4ClassicalRK4") {
58  return new G4ClassicalRK4(m_fieldEquations);
59  } else if (name == "G4ExplicitEuler") {
60  return new G4ExplicitEuler(m_fieldEquations);
61  } else if (name == "G4HelixExplicitEuler") {
62  return new G4HelixExplicitEuler(m_fieldEquations);
63  } else if (name == "G4HelixHeum") {
64  return new G4HelixHeum(m_fieldEquations);
65  } else if (name == "G4HelixImplicitEuler") {
66  return new G4HelixImplicitEuler(m_fieldEquations);
67  } else if (name == "G4HelixSimpleRunge") {
68  return new G4HelixSimpleRunge(m_fieldEquations);
69  } else if (name == "G4ImplicitEuler") {
70  return new G4ImplicitEuler(m_fieldEquations);
71  } else if (name == "G4CashKarpRKF45") {
72  return new G4CashKarpRKF45(m_fieldEquations);
73  } else if (name == "G4SimpleHeum") {
74  return new G4SimpleHeum(m_fieldEquations);
75  } else if (name == "G4SimpleRunge") {
76  return new G4SimpleRunge(m_fieldEquations);
77  } else {
78  log() << LOG::error << "Unknown G4MagIntegratorStepper <" + name << ">" << LOG::done;
79  }
80 
81  return 0;
82 }
83 }
G4MagIntegratorStepper * createG4MagIntegratorStepper(std::string name)
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
@ error
Definition: LogStream.hh:33
@ name
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26