#include "FCALPrimaryGeneratorMessenger.hh" #include "FCALPrimaryGeneratorAction.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWith3VectorAndUnit.hh" FCALPrimaryGeneratorMessenger::FCALPrimaryGeneratorMessenger(FCALPrimaryGeneratorAction* 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("GeV"); 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"); } FCALPrimaryGeneratorMessenger::~FCALPrimaryGeneratorMessenger() { delete energy_Cmd; delete position_Cmd; delete gun_Dir; } void FCALPrimaryGeneratorMessenger::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)); } }