File indexing completed on 2025-01-31 09:22:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "DetectorMessenger.hh"
0031
0032 #include "DetectorConstruction.hh"
0033
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIdirectory.hh"
0037
0038 namespace B2b
0039 {
0040
0041
0042
0043 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetectorConstruction(Det)
0044 {
0045 fDirectory = new G4UIdirectory("/B2/");
0046 fDirectory->SetGuidance("UI commands specific to this example.");
0047
0048 fDetDirectory = new G4UIdirectory("/B2/det/");
0049 fDetDirectory->SetGuidance("Detector construction control");
0050
0051 fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial", this);
0052 fTargMatCmd->SetGuidance("Select Material of the Target.");
0053 fTargMatCmd->SetParameterName("choice", false);
0054 fTargMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0055
0056 fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial", this);
0057 fChamMatCmd->SetGuidance("Select Material of the Chamber.");
0058 fChamMatCmd->SetParameterName("choice", false);
0059 fChamMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0060
0061 fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax", this);
0062 fStepMaxCmd->SetGuidance("Define a step max");
0063 fStepMaxCmd->SetParameterName("stepMax", false);
0064 fStepMaxCmd->SetUnitCategory("Length");
0065 fStepMaxCmd->AvailableForStates(G4State_Idle);
0066 }
0067
0068
0069
0070 DetectorMessenger::~DetectorMessenger()
0071 {
0072 delete fTargMatCmd;
0073 delete fChamMatCmd;
0074 delete fStepMaxCmd;
0075 delete fDirectory;
0076 delete fDetDirectory;
0077 }
0078
0079
0080
0081 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0082 {
0083 if (command == fTargMatCmd) {
0084 fDetectorConstruction->SetTargetMaterial(newValue);
0085 }
0086
0087 if (command == fChamMatCmd) {
0088 fDetectorConstruction->SetChamberMaterial(newValue);
0089 }
0090
0091 if (command == fStepMaxCmd) {
0092 fDetectorConstruction->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
0093 }
0094 }
0095
0096
0097
0098 }