Belle II Software  release-05-01-25
ExtMessenger.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Leo Piilonen *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <simulation/kernel/ExtMessenger.h>
12 #include <simulation/kernel/ExtStepLengthLimitProcess.h>
13 #include <simulation/kernel/ExtMagFieldLimitProcess.h>
14 #include <simulation/kernel/ExtEnergyLoss.h>
15 #include <globals.hh>
16 #include <G4UIdirectory.hh>
17 #include <G4UIcmdWithADoubleAndUnit.hh>
18 #include <G4UIcmdWithADouble.hh>
19 
20 #include <framework/logging/Logger.h>
21 
22 using namespace std;
23 using namespace Belle2;
24 using namespace Belle2::Simulation;
25 
26 ExtMessenger::ExtMessenger(ExtStepLengthLimitProcess* lAct, ExtMagFieldLimitProcess* mAct, ExtEnergyLoss* eAct) :
27  m_stepLengthAction(lAct),
28  m_magFieldAction(mAct),
29  m_energyLossAction(eAct)
30 {
31 
32  m_dir = new G4UIdirectory("/geant4e/");
33  m_dir->SetGuidance("GEANT4e control commands");
34  m_dirLimits = new G4UIdirectory("/geant4e/limits/");
35  m_dirLimits->SetGuidance("GEANT4e commands to limit the step");
36 
37  m_stepLengthLimitCmd = new G4UIcmdWithADoubleAndUnit("/geant4e/limits/stepLength", this);
38  m_stepLengthLimitCmd->SetGuidance("Limit the length of a step (distance)");
39  m_stepLengthLimitCmd->SetDefaultUnit("mm");
40  m_stepLengthLimitCmd->AvailableForStates(G4State_PreInit, G4State_Idle, G4State_GeomClosed, G4State_EventProc);
41 
42  m_magFieldLimitCmd = new G4UIcmdWithADouble("/geant4e/limits/magField", this);
43  m_magFieldLimitCmd->SetGuidance("Limit the length of a step (field/momentum)");
44  m_magFieldLimitCmd->AvailableForStates(G4State_PreInit, G4State_Idle, G4State_GeomClosed, G4State_EventProc);
45 
46  m_energyLossCmd = new G4UIcmdWithADouble("/geant4e/limits/energyLoss", this);
47  m_energyLossCmd->SetGuidance("Limit the length of a step (fractional KE loss)");
48  m_energyLossCmd->AvailableForStates(G4State_PreInit, G4State_Idle, G4State_GeomClosed, G4State_EventProc);
49 
50  if (false) {
51  G4UIcommand* command = nullptr;
52  SetNewValue(command, G4String(""));
53  }
54 
55 }
56 
58 {
59  delete m_stepLengthLimitCmd;
60  delete m_magFieldLimitCmd;
61  delete m_energyLossCmd;
62  delete m_dir;
63  delete m_dirLimits;
64 }
65 
66 void ExtMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
67 {
68  if (command == m_stepLengthLimitCmd) {
69  B2DEBUG(200, "ExtMessenger::SetNewValue() StepLengthAction SetStepLimit "
70  << m_stepLengthLimitCmd->GetNewDoubleValue(newValue));
71  m_stepLengthAction->SetStepLimit(m_stepLengthLimitCmd->GetNewDoubleValue(newValue));
72  } else if (command == m_magFieldLimitCmd) {
73  B2DEBUG(200, "ExtMessenger::SetNewValue() MagFieldAction SetStepLimit "
74  << m_magFieldLimitCmd->GetNewDoubleValue(newValue));
75  m_magFieldAction->SetStepLimit(m_magFieldLimitCmd->GetNewDoubleValue(newValue));
76  } else if (command == m_energyLossCmd) {
77  B2DEBUG(200, "ExtMessenger::SetNewValue() EnergyLossAction SetStepLimit "
78  << m_energyLossCmd->GetNewDoubleValue(newValue));
79  m_energyLossAction->SetStepLimit(m_energyLossCmd->GetNewDoubleValue(newValue));
80  }
81 }
Belle2::Simulation::ExtMessenger::SetNewValue
void SetNewValue(G4UIcommand *, G4String)
Process a geant4 UI command.
Definition: ExtMessenger.cc:66
Belle2::Simulation::ExtMessenger::m_energyLossCmd
G4UIcmdWithADouble * m_energyLossCmd
defines UI command "/geant4e/limits/energyLoss" to limit step length
Definition: ExtMessenger.h:77
Belle2::Simulation::ExtEnergyLoss
Define physics process to calculate energy loss without fluctuations.
Definition: ExtEnergyLoss.h:34
Belle2::Simulation::ExtMessenger::~ExtMessenger
~ExtMessenger()
destructor
Definition: ExtMessenger.cc:57
Belle2::Simulation::ExtMessenger::m_stepLengthLimitCmd
G4UIcmdWithADoubleAndUnit * m_stepLengthLimitCmd
Defines UI command "/geant4e/limits/stepLength" to limit step length.
Definition: ExtMessenger.h:71
Belle2::Simulation::ExtStepLengthLimitProcess::SetStepLimit
void SetStepLimit(G4double val)
Sets the step limit.
Definition: ExtStepLengthLimitProcess.h:51
Belle2::Simulation::ExtStepLengthLimitProcess
Defines the physics process that avoids hit invocation in sensitive volumes.
Definition: ExtStepLengthLimitProcess.h:28
Belle2::Simulation::ExtMagFieldLimitProcess
Defines the physics process that avoids hit invocation in sensitive volumes.
Definition: ExtMagFieldLimitProcess.h:29
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Simulation::ExtMagFieldLimitProcess::SetStepLimit
void SetStepLimit(G4double val)
Sets the step limit.
Definition: ExtMagFieldLimitProcess.h:52
Belle2::Simulation::ExtMessenger::m_magFieldLimitCmd
G4UIcmdWithADouble * m_magFieldLimitCmd
Defines UI command "/geant4e/limits/magField" to limit step length.
Definition: ExtMessenger.h:74
Belle2::Simulation::ExtMessenger::m_dirLimits
G4UIdirectory * m_dirLimits
Defines UI directory for "/geant4e/limits/" commands.
Definition: ExtMessenger.h:68
Belle2::Simulation::ExtEnergyLoss::SetStepLimit
void SetStepLimit(G4double)
Sets the step limit for this process.
Definition: ExtEnergyLoss.h:81
Belle2::Simulation::ExtMessenger::m_magFieldAction
ExtMagFieldLimitProcess * m_magFieldAction
Process that limits the geant4e step length in magnetic field.
Definition: ExtMessenger.h:59
Belle2::Simulation::ExtMessenger::m_stepLengthAction
ExtStepLengthLimitProcess * m_stepLengthAction
Process that limits the geant4e step length.
Definition: ExtMessenger.h:56
Belle2::Simulation::ExtMessenger::m_dir
G4UIdirectory * m_dir
Defines UI directory for "/geant4e/" commands.
Definition: ExtMessenger.h:65
Belle2::Simulation::ExtMessenger::m_energyLossAction
ExtEnergyLoss * m_energyLossAction
Process that limits the geant4e step length due to energy loss.
Definition: ExtMessenger.h:62