File indexing completed on 2025-11-03 09:05:07
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
0031
0032
0033
0034
0035
0036
0037
0038 #include "DetectorMessenger.hh"
0039
0040 #include "DetectorConstruction.hh"
0041
0042 #include "G4UIcmdWithADoubleAndUnit.hh"
0043
0044
0045
0046 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det)
0047 :G4UImessenger(), fpDetector(Det)
0048 {
0049 fpTestDir = std::make_unique<G4UIdirectory>("/microyz/");
0050 fpTestDir->SetGuidance(" detector control.");
0051
0052 fpDetDir = std::make_unique<G4UIdirectory>("/microyz/det/");
0053 fpDetDir->SetGuidance("detector construction commands");
0054
0055 fpTrackingCutCmd =
0056 std::make_unique<G4UIcmdWithADoubleAndUnit>("/microyz/det/setTrackingCut", this);
0057 fpTrackingCutCmd->SetGuidance("Set tracking cut");
0058 fpTrackingCutCmd->SetParameterName("Cut", false);
0059 fpTrackingCutCmd->SetRange("Cut>0.");
0060 fpTrackingCutCmd->SetUnitCategory("Energy");
0061 fpTrackingCutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0062 fpTrackingCutCmd->SetToBeBroadcasted(false);
0063
0064 fpMaxStepSizeCmd =
0065 std::make_unique<G4UIcmdWithADoubleAndUnit>("/microyz/det/setMaxStepSize", this);
0066 fpMaxStepSizeCmd->SetGuidance("Set maximum step size");
0067 fpMaxStepSizeCmd->SetParameterName("Size", false);
0068 fpMaxStepSizeCmd->SetRange("Size>0.");
0069 fpMaxStepSizeCmd->SetUnitCategory("Length");
0070 fpMaxStepSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0071 fpMaxStepSizeCmd->SetToBeBroadcasted(false);
0072
0073 fAddRadius = std::make_unique<G4UIcmdWithADoubleAndUnit>("/microyz/det/Radius", this);
0074 fpMaxStepSizeCmd->SetGuidance("Set TrackSD radius");
0075 fAddRadius->SetToBeBroadcasted(false);
0076 fAddRadius->SetParameterName("Radius", false);
0077 fAddRadius->SetRange("Radius>0.");
0078 fAddRadius->SetUnitCategory("Length");
0079 fAddRadius->AvailableForStates(G4State_PreInit, G4State_Idle);
0080 }
0081
0082
0083
0084 DetectorMessenger::~DetectorMessenger() = default;
0085
0086
0087
0088 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0089 {
0090 if (command == fpTrackingCutCmd.get()) {
0091 fpDetector->SetTrackingCut(fpTrackingCutCmd->GetNewDoubleValue(newValue));
0092 }
0093
0094 if (command == fpMaxStepSizeCmd.get()) {
0095 fpDetector->SetMaxStepSize(fpMaxStepSizeCmd->GetNewDoubleValue(newValue));
0096 }
0097
0098 if (command == fAddRadius.get()) {
0099 fpDetector->SetTrackerSDRadius(fAddRadius->GetNewDoubleValue(newValue));
0100 }
0101 }
0102
0103