File indexing completed on 2026-06-03 07:56:46
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 #include "Par03DetectorMessenger.hh"
0030
0031 #include "Par03DetectorConstruction.hh"
0032
0033 #include "G4UIcmdWithADoubleAndUnit.hh"
0034 #include "G4UIcmdWithAString.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIcmdWithoutParameter.hh"
0037 #include "G4UIdirectory.hh"
0038
0039
0040
0041 Par03DetectorMessenger::Par03DetectorMessenger(Par03DetectorConstruction* aDetector)
0042 : G4UImessenger(), fDetector(aDetector)
0043 {
0044 fExampleDir = new G4UIdirectory("/Par03/");
0045 fExampleDir->SetGuidance("UI commands specific to this example");
0046
0047 fDetectorDir = new G4UIdirectory("/Par03/detector/");
0048 fDetectorDir->SetGuidance("Detector construction UI commands");
0049
0050 fPrintCmd = new G4UIcmdWithoutParameter("/Par03/detector/print", this);
0051 fPrintCmd->SetGuidance("Print current settings.");
0052
0053 fDetectorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorRadius", this);
0054 fDetectorRadiusCmd->SetGuidance("Set tranverse size of the detector (cylinder radius)");
0055 fDetectorRadiusCmd->SetParameterName("Size", false);
0056 fDetectorRadiusCmd->SetRange("Size>0.");
0057 fDetectorRadiusCmd->SetUnitCategory("Length");
0058 fDetectorRadiusCmd->AvailableForStates(G4State_PreInit);
0059 fDetectorRadiusCmd->SetToBeBroadcasted(false);
0060
0061 fDetectorLengthCmd = new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorLength", this);
0062 fDetectorLengthCmd->SetGuidance("Set length of the detector (cylinder length)");
0063 fDetectorLengthCmd->SetParameterName("Size", false);
0064 fDetectorLengthCmd->SetRange("Size>0.");
0065 fDetectorLengthCmd->SetUnitCategory("Length");
0066 fDetectorLengthCmd->AvailableForStates(G4State_PreInit);
0067 fDetectorLengthCmd->SetToBeBroadcasted(false);
0068
0069 fDetectorMaterialCmd = new G4UIcmdWithAString("/Par03/detector/setDetectorMaterial", this);
0070 fDetectorMaterialCmd->SetGuidance("Material of the detector.");
0071 fDetectorMaterialCmd->SetParameterName("Name", false);
0072 fDetectorMaterialCmd->AvailableForStates(G4State_PreInit);
0073 fDetectorMaterialCmd->SetToBeBroadcasted(false);
0074
0075 fNbLayersCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfLayers", this);
0076 fNbLayersCmd->SetGuidance("Set number of layers.");
0077 fNbLayersCmd->SetParameterName("NbLayers", false);
0078 fNbLayersCmd->SetRange("NbLayers>0");
0079 fNbLayersCmd->AvailableForStates(G4State_PreInit);
0080 fNbLayersCmd->SetToBeBroadcasted(false);
0081
0082 fNbRhoCellsCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfRhoCells", this);
0083 fNbRhoCellsCmd->SetGuidance("Set number of cells along radius.");
0084 fNbRhoCellsCmd->SetParameterName("NbRhoCells", false);
0085 fNbRhoCellsCmd->SetRange("NbRhoCells>0");
0086 fNbRhoCellsCmd->AvailableForStates(G4State_PreInit);
0087 fNbRhoCellsCmd->SetToBeBroadcasted(false);
0088
0089 fNbPhiCellsCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfPhiCells", this);
0090 fNbPhiCellsCmd->SetGuidance("Set number of cells in azimuthal angle.");
0091 fNbPhiCellsCmd->SetParameterName("NbPhiCells", false);
0092 fNbPhiCellsCmd->SetRange("NbPhiCells>0");
0093 fNbPhiCellsCmd->AvailableForStates(G4State_PreInit);
0094 fNbPhiCellsCmd->SetToBeBroadcasted(false);
0095 }
0096
0097
0098
0099 Par03DetectorMessenger::~Par03DetectorMessenger()
0100 {
0101 delete fPrintCmd;
0102 delete fDetectorRadiusCmd;
0103 delete fDetectorLengthCmd;
0104 delete fDetectorMaterialCmd;
0105 delete fNbLayersCmd;
0106 delete fNbRhoCellsCmd;
0107 delete fNbPhiCellsCmd;
0108 delete fDetectorDir;
0109 delete fExampleDir;
0110 }
0111
0112
0113
0114 void Par03DetectorMessenger::SetNewValue(G4UIcommand* aCommand, G4String aNewValue)
0115 {
0116 if (aCommand == fPrintCmd) {
0117 fDetector->Print();
0118 }
0119 else if (aCommand == fDetectorRadiusCmd) {
0120 fDetector->SetRadius(fDetectorRadiusCmd->GetNewDoubleValue(aNewValue));
0121 }
0122 else if (aCommand == fDetectorLengthCmd) {
0123 fDetector->SetLength(fDetectorRadiusCmd->GetNewDoubleValue(aNewValue));
0124 }
0125 else if (aCommand == fDetectorMaterialCmd) {
0126 fDetector->SetMaterial(aNewValue);
0127 }
0128 else if (aCommand == fNbLayersCmd) {
0129 fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(aNewValue));
0130 }
0131 else if (aCommand == fNbRhoCellsCmd) {
0132 fDetector->SetNbOfRhoCells(fNbRhoCellsCmd->GetNewIntValue(aNewValue));
0133 }
0134 else if (aCommand == fNbPhiCellsCmd) {
0135 fDetector->SetNbOfPhiCells(fNbPhiCellsCmd->GetNewIntValue(aNewValue));
0136 }
0137 }
0138
0139
0140
0141 G4String Par03DetectorMessenger::GetCurrentValue(G4UIcommand* aCommand)
0142 {
0143 G4String cv;
0144
0145 if (aCommand == fDetectorRadiusCmd) {
0146 cv = fDetectorRadiusCmd->ConvertToString(fDetector->GetRadius(), "mm");
0147 }
0148 else if (aCommand == fDetectorLengthCmd) {
0149 cv = fDetectorLengthCmd->ConvertToString(fDetector->GetLength(), "mm");
0150 }
0151 else if (aCommand == fDetectorMaterialCmd) {
0152 cv = fDetector->GetMaterial();
0153 }
0154 else if (aCommand == fNbLayersCmd) {
0155 cv = fNbLayersCmd->ConvertToString(fDetector->GetNbOfLayers());
0156 }
0157 else if (aCommand == fNbPhiCellsCmd) {
0158 cv = fNbPhiCellsCmd->ConvertToString(fDetector->GetNbOfPhiCells());
0159 }
0160 else if (aCommand == fNbRhoCellsCmd) {
0161 cv = fNbRhoCellsCmd->ConvertToString(fDetector->GetNbOfRhoCells());
0162 }
0163 return cv;
0164 }