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