SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
FieldMessenger.cc
Go to the documentation of this file.
1 #include "FieldMessenger.hh"
2 
3 // SLIC
4 #include "FieldManager.hh"
6 
7 // Geant4
8 #include "G4UIcmdWithADoubleAndUnit.hh"
9 #include "G4FieldManager.hh"
10 #include "G4UIcommand.hh"
11 #include "G4UIdirectory.hh"
12 #include "G4TransportationManager.hh"
13 #include "G4ApplicationState.hh"
14 
15 namespace slic {
16 
18  m_mgr(mgr) {
20 }
21 
23  delete m_fieldDir;
24  delete m_selectStepperCmd;
25  delete m_setDeltaOneStepCmd;
27 }
28 
29 void FieldMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) {
30  G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
31 
32  if (cmd == m_selectStepperCmd) {
33  G4MagIntegratorStepperFactory::instance()->setupG4MagIntegratorStepper(newVals);
34 #ifdef SLIC_LOG
35  m_mgr->log() << LOG::okay << "mag field integrator <" << newVals << ">" << LOG::done;
36 #endif
37  } else if (cmd == m_setDeltaOneStepCmd) {
38  double deltaOneStep = m_setDeltaOneStepCmd->GetNewDoubleValue(newVals);
39  fieldMgr->SetDeltaOneStep(deltaOneStep);
40  m_mgr->log() << LOG::okay << "delta one step <" << deltaOneStep << ">" << LOG::done;
41  } else if (cmd == m_setDeltaIntersectionCmd) {
42  double deltaIntersection = m_setDeltaIntersectionCmd->GetNewDoubleValue(newVals);
43  fieldMgr->SetDeltaIntersection(deltaIntersection);
44  m_mgr->log() << LOG::okay << "delta intersection <" << deltaIntersection << ">" << LOG::done;
45  } else {
46  G4Exception("", "", JustWarning, "Unknown command.");
47  }
48 }
49 
51  G4UIparameter *p;
52 
53  m_fieldDir = new G4UIdirectory("/field/");
54  m_fieldDir->SetGuidance("Magnetic field customization commands. [SLIC]");
55 
56  m_selectStepperCmd = new G4UIcommand("/field/selectStepper", this);
57 
58  m_selectStepperCmd->SetGuidance("Select the G4MagIntegratorStepper:\nG4ClassicalRK4 G4ExplicitEuler G4HelixExplicitEuler G4HelixHeum G4HelixImplicitEuler G4HelixSimpleRunge G4ImplicitEuler G4CashKarpRKF45 G4SimpleHeum G4SimpleRunge");
59 
60  p = new G4UIparameter("stepper", 's', false);
61  m_selectStepperCmd->SetParameter(p);
62  m_selectStepperCmd->AvailableForStates(G4State_Init, G4State_Idle);
63 
64  m_setDeltaOneStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaOneStep", this);
65  m_setDeltaOneStepCmd->SetGuidance("Set the delta of one step.");
66  m_setDeltaOneStepCmd->SetDefaultUnit("mm");
67  m_setDeltaOneStepCmd->AvailableForStates(G4State_Init, G4State_Idle);
68 
69  m_setDeltaIntersectionCmd = new G4UIcmdWithADoubleAndUnit("/field/setDeltaIntersection", this);
70  m_setDeltaIntersectionCmd->SetGuidance("Set the delta of intersection.");
71  m_setDeltaIntersectionCmd->SetDefaultUnit("mm");
72  m_setDeltaIntersectionCmd->AvailableForStates(G4State_Init, G4State_Idle);
73 }
74 }
static G4MagIntegratorStepperFactory * instance()
A manager of B-fields that currently just holds the pointer to its associated FieldMessenger.
Definition: FieldManager.hh:15
G4UIcommand * m_selectStepperCmd
G4UIcmdWithADoubleAndUnit * m_setDeltaIntersectionCmd
G4UIcmdWithADoubleAndUnit * m_setDeltaOneStepCmd
FieldManager * m_mgr
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
FieldMessenger(FieldManager *mgr)
G4UIdirectory * m_fieldDir
LogStream & log()
Definition: Module.hh:99
@ okay
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26