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