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