#include "LGPrimaryGeneratorMessenger.hh" #include "LGPrimaryGeneratorAction.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWith3VectorAndUnit.hh" LGPrimaryGeneratorMessenger::LGPrimaryGeneratorMessenger(LGPrimaryGeneratorAction* generator_Act) : generator_Action(generator_Act) { gun_Dir = new G4UIdirectory("/gun/"); gun_Dir->SetGuidance("particle gun control commands"); energy_Cmd = new G4UIcmdWithADoubleAndUnit("/gun/energy", this); energy_Cmd->SetGuidance("set kinetic energy"); energy_Cmd->SetParameterName("Energy", true, true); energy_Cmd->SetDefaultUnit("eV"); energy_Cmd->SetUnitCandidates("eV keV MeV GeV TeV"); position_Cmd = new G4UIcmdWith3VectorAndUnit("/gun/position", this); position_Cmd->SetGuidance("set starting position of the particle"); position_Cmd->SetParameterName("X", "Y", "Z", true, true); position_Cmd->SetDefaultUnit("cm"); position_Cmd->SetUnitCandidates("micron mm cm m km"); } LGPrimaryGeneratorMessenger::~LGPrimaryGeneratorMessenger() { delete energy_Cmd; delete position_Cmd; delete gun_Dir; } void LGPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String new_Value) { if (command == energy_Cmd) { generator_Action->setParticleEnergy(energy_Cmd->GetNewDoubleValue(new_Value)); } if (command == position_Cmd) { generator_Action->setGunPosition(position_Cmd->GetNew3VectorValue(new_Value)); } }