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