File indexing completed on 2026-09-09 08:28:41
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
0040
0041
0042 #include "DetectorMessenger.hh"
0043
0044 #include "DetectorConstruction.hh"
0045 #include "HistoManager.hh"
0046
0047 #include "G4PhysicalConstants.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4UIcmdWith3Vector.hh"
0050 #include "G4UIcmdWithABool.hh"
0051 #include "G4UIcmdWithADoubleAndUnit.hh"
0052 #include "G4UIcmdWithAString.hh"
0053 #include "G4UIcmdWithAnInteger.hh"
0054 #include "G4UIcmdWithoutParameter.hh"
0055 #include "G4UIdirectory.hh"
0056
0057
0058
0059 DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
0060 : G4UImessenger(),
0061 fDetector(det),
0062 fTestDir(0),
0063 fMatCmd(0),
0064 fMat1Cmd(0),
0065 fIonCmd(0),
0066 fRCmd(0),
0067 fLCmd(0),
0068 fEdepCmd(0),
0069 fBinCmd(0),
0070 fNOfAbsCmd(0),
0071 fVerbCmd(0),
0072 fBeamCmd(0)
0073 {
0074 fTestDir = new G4UIdirectory("/testhadr/");
0075 fTestDir->SetGuidance(" Hadronic Extended Example.");
0076
0077 fMatCmd = new G4UIcmdWithAString("/testhadr/TargetMat", this);
0078 fMatCmd->SetGuidance("Select Material for the target");
0079 fMatCmd->SetParameterName("tMaterial", false);
0080 fMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0081
0082 fMat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat", this);
0083 fMat1Cmd->SetGuidance("Select Material for world");
0084 fMat1Cmd->SetParameterName("wMaterial", false);
0085 fMat1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0086
0087 fIonCmd = new G4UIcmdWithAString("/testhadr/ionPhysics", this);
0088 fIonCmd->SetGuidance("Select ion Physics");
0089 fIonCmd->SetParameterName("DPMJET", false);
0090 fIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0091
0092 fRCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius", this);
0093 fRCmd->SetGuidance("Set radius of the target");
0094 fRCmd->SetParameterName("radius", false);
0095 fRCmd->SetUnitCategory("Length");
0096 fRCmd->SetRange("radius>0");
0097 fRCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0098
0099 fLCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength", this);
0100 fLCmd->SetGuidance("Set length of the target");
0101 fLCmd->SetParameterName("length", false);
0102 fLCmd->SetUnitCategory("Length");
0103 fLCmd->SetRange("length>0");
0104 fLCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0105
0106 fBinCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE", this);
0107 fBinCmd->SetGuidance("Set number of bins for Energy");
0108 fBinCmd->SetParameterName("NEbins", false);
0109 fBinCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0110
0111 fNOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ", this);
0112 fNOfAbsCmd->SetGuidance("Set number of slices");
0113 fNOfAbsCmd->SetParameterName("NZ", false);
0114 fNOfAbsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0115
0116 fEdepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep", this);
0117 fEdepCmd->SetGuidance("Set max energy in histogram");
0118 fEdepCmd->SetParameterName("edep", false);
0119 fEdepCmd->SetUnitCategory("Energy");
0120 fEdepCmd->SetRange("edep>0");
0121 fEdepCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0122
0123 fBeamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition", this);
0124 fBeamCmd->SetGuidance("show inelastic and elastic cross sections");
0125
0126 fVerbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose", this);
0127 fVerbCmd->SetGuidance("Set verbose for ");
0128 fVerbCmd->SetParameterName("verb", false);
0129 fVerbCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0130 }
0131
0132
0133
0134 DetectorMessenger::~DetectorMessenger()
0135 {
0136 delete fMatCmd;
0137 delete fMat1Cmd;
0138 delete fIonCmd;
0139 delete fRCmd;
0140 delete fLCmd;
0141 delete fNOfAbsCmd;
0142 delete fTestDir;
0143 delete fBeamCmd;
0144 delete fVerbCmd;
0145 delete fEdepCmd;
0146 }
0147
0148
0149
0150 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0151 {
0152 HistoManager* h = HistoManager::GetPointer();
0153 if (command == fMatCmd) {
0154 fDetector->SetTargetMaterial(newValue);
0155 }
0156 else if (command == fMat1Cmd) {
0157 fDetector->SetWorldMaterial(newValue);
0158 }
0159 else if (command == fIonCmd) {
0160 h->SetIonPhysics(newValue);
0161 }
0162 else if (command == fRCmd) {
0163 fDetector->SetTargetRadius(fRCmd->GetNewDoubleValue(newValue));
0164 }
0165 else if (command == fLCmd) {
0166 h->SetTargetLength(fLCmd->GetNewDoubleValue(newValue));
0167 }
0168 else if (command == fNOfAbsCmd) {
0169 h->SetNumberOfSlices(fNOfAbsCmd->GetNewIntValue(newValue));
0170 }
0171 else if (command == fBinCmd) {
0172 h->SetNumberOfBinsE(fBinCmd->GetNewIntValue(newValue));
0173 }
0174 else if (command == fVerbCmd) {
0175 h->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
0176 }
0177 else if (command == fBeamCmd) {
0178 h->SetDefaultBeamPositionFlag(fBeamCmd->GetNewBoolValue(newValue));
0179 }
0180 else if (command == fEdepCmd) {
0181 h->SetMaxEnergyDeposit(fEdepCmd->GetNewDoubleValue(newValue));
0182 }
0183 }
0184
0185