File indexing completed on 2025-02-23 09:22:22
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 "OpNoviceDetectorMessenger.hh"
0028
0029 #include "OpNoviceDetectorConstruction.hh"
0030 #include "OpNoviceGDMLDetectorConstruction.hh"
0031
0032 #include "G4UIcmdWithABool.hh"
0033 #include "G4UIcmdWithAString.hh"
0034 #include "G4UIdirectory.hh"
0035
0036
0037
0038 OpNoviceDetectorMessenger::OpNoviceDetectorMessenger(G4VUserDetectorConstruction* detcon)
0039 : G4UImessenger(), fOpNoviceDetCon(detcon)
0040 {
0041 fDetConDir = new G4UIdirectory("/OpNovice/DetectorConstruction/");
0042 fDetConDir->SetGuidance("Configuring Detector Construction");
0043
0044 fVerboseCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/enableVerbose", this);
0045 fVerboseCmd->SetGuidance("Set flag for enabling verbose diagnostic printout");
0046 fVerboseCmd->SetDefaultValue(false);
0047 fVerboseCmd->AvailableForStates(G4State_PreInit);
0048
0049 fDumpGdmlCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/dumpGdml", this);
0050 fDumpGdmlCmd->SetGuidance("Set flag for enabling dumping the detector to a gdml file");
0051 fDumpGdmlCmd->SetDefaultValue(false);
0052 fDumpGdmlCmd->AvailableForStates(G4State_PreInit);
0053
0054 fDumpGdmlFileNameCmd =
0055 new G4UIcmdWithAString("/OpNovice/DetectorConstruction/dumpGdmlFileName", this);
0056 fDumpGdmlFileNameCmd->SetGuidance("Enter file name to dump gdml file ");
0057 fDumpGdmlFileNameCmd->SetDefaultValue("OpNovice_dump.gdml");
0058 fDumpGdmlFileNameCmd->AvailableForStates(G4State_PreInit);
0059 }
0060
0061
0062
0063 OpNoviceDetectorMessenger::~OpNoviceDetectorMessenger()
0064 {
0065 delete fDetConDir;
0066 delete fVerboseCmd;
0067 delete fDumpGdmlCmd;
0068 delete fDumpGdmlFileNameCmd;
0069 }
0070
0071
0072
0073 void OpNoviceDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0074 {
0075 auto dc1 = dynamic_cast<OpNoviceDetectorConstruction*>(fOpNoviceDetCon);
0076 if (dc1 != nullptr) {
0077 if (command == fVerboseCmd) dc1->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0078 if (command == fDumpGdmlCmd) dc1->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0079 if (command == fDumpGdmlFileNameCmd) dc1->SetDumpGdmlFile(newValue);
0080 }
0081 else {
0082 auto dc2 = dynamic_cast<OpNoviceGDMLDetectorConstruction*>(fOpNoviceDetCon);
0083 if (command == fVerboseCmd) dc2->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0084 if (command == fDumpGdmlCmd) dc2->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0085 if (command == fDumpGdmlFileNameCmd) dc2->SetDumpGdmlFile(newValue);
0086 }
0087 }
0088