File indexing completed on 2025-02-23 09:21:11
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 #include "DetectorConstructionMessenger.hh"
0028
0029 #include "DetectorConstruction.hh"
0030
0031 #include "G4RunManager.hh"
0032 #include "G4UIcmdWith3Vector.hh"
0033 #include "G4UIcmdWith3VectorAndUnit.hh"
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithADouble.hh"
0036 #include "G4UIcmdWithADoubleAndUnit.hh"
0037 #include "G4UIcmdWithAString.hh"
0038 #include "G4UIdirectory.hh"
0039 #include "G4ios.hh"
0040
0041 DetectorConstructionMessenger::DetectorConstructionMessenger(DetectorConstruction* mpga)
0042 : fTarget(mpga)
0043 {
0044 fMyXtalDirectory = new G4UIdirectory("/xtal/");
0045 fMyXtalDirectory->SetGuidance("Crystal setup control commands.");
0046
0047 fXtalMaterialCmd = new G4UIcmdWithAString("/xtal/setMaterial", this);
0048 fXtalMaterialCmd->SetGuidance("Set crystal material.");
0049 fXtalMaterialCmd->SetParameterName("xMat", true);
0050 fXtalMaterialCmd->SetDefaultValue("G4_Si");
0051
0052 fXtalSizeCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setSize", this);
0053 fXtalSizeCmd->SetGuidance("Set crystal size.");
0054 fXtalSizeCmd->SetParameterName("xtalSizeX", "xtalSizeY", "xtalSizeZ", true);
0055 fXtalSizeCmd->SetDefaultValue(G4ThreeVector(6., 2., 6.));
0056 fXtalSizeCmd->SetDefaultUnit("mm");
0057
0058 fXtalBRCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setBR", this);
0059 fXtalBRCmd->SetGuidance("Set crystal bending radius.");
0060 fXtalBRCmd->SetParameterName("xtalBRX", "xtalBRY", "xtalBRZ", true);
0061 fXtalBRCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
0062 fXtalBRCmd->SetDefaultUnit("m");
0063
0064 fXtalAngleCmd = new G4UIcmdWith3VectorAndUnit("/xtal/setAngle", this);
0065 fXtalAngleCmd->SetGuidance("Set crystal angles.");
0066 fXtalAngleCmd->SetParameterName("xtalAngleX", "xtalAngleY", "xtalAngleZ", true);
0067 fXtalAngleCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
0068 fXtalAngleCmd->SetDefaultUnit("rad");
0069
0070 fXtalECCmd = new G4UIcmdWithAString("/xtal/setEC", this);
0071 fXtalECCmd->SetGuidance("Set crystal EC.");
0072 fXtalECCmd->SetParameterName("xEC", true);
0073 fXtalECCmd->SetDefaultValue("data/Si220pl");
0074 }
0075
0076
0077
0078 DetectorConstructionMessenger::~DetectorConstructionMessenger()
0079 {
0080 delete fXtalMaterialCmd;
0081 delete fXtalSizeCmd;
0082 delete fXtalAngleCmd;
0083 delete fXtalECCmd;
0084 delete fXtalBRCmd;
0085 }
0086
0087
0088
0089 void DetectorConstructionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0090 {
0091 if (command == fXtalMaterialCmd) {
0092 fTarget->SetMaterial(newValue);
0093 }
0094 if (command == fXtalSizeCmd) {
0095 fTarget->SetSizes(fXtalSizeCmd->GetNew3VectorValue(newValue));
0096 }
0097 if (command == fXtalBRCmd) {
0098 fTarget->SetBR(fXtalBRCmd->GetNew3VectorValue(newValue));
0099 }
0100 if (command == fXtalAngleCmd) {
0101 fTarget->SetAngles(fXtalAngleCmd->GetNew3VectorValue(newValue));
0102 }
0103 if (command == fXtalECCmd) {
0104 fTarget->SetEC(newValue);
0105 }
0106 }
0107
0108
0109
0110 G4String DetectorConstructionMessenger::GetCurrentValue(G4UIcommand* command)
0111 {
0112 G4String cv;
0113
0114 if (command == fXtalMaterialCmd) {
0115 cv = fTarget->GetMaterial();
0116 }
0117 if (command == fXtalSizeCmd) {
0118 cv = fXtalSizeCmd->ConvertToString(fTarget->GetSizes(), "mm");
0119 }
0120 if (command == fXtalBRCmd) {
0121 cv = fXtalBRCmd->ConvertToString(fTarget->GetBR(), "m");
0122 }
0123 if (command == fXtalAngleCmd) {
0124 cv = fXtalAngleCmd->ConvertToString(fTarget->GetAngles(), "rad");
0125 }
0126 if (command == fXtalECCmd) {
0127 cv = fTarget->GetEC();
0128 }
0129 return cv;
0130 }
0131
0132