// M Hentz, 2016 #include "PrimaryGeneratorMessenger.hh" #include "PrimaryGeneratorAction.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithADouble.hh" PrimaryGeneratorMessenger::PrimaryGeneratorMessenger( PrimaryGeneratorAction* primaryGenAction ) :G4UImessenger(), fPrimaryGenAction(primaryGenAction), fPrimaryGenDir(0), fReadCmd(0) { fPrimaryGenDir = new G4UIdirectory( "/primarygenerator/" ); fPrimaryGenDir->SetGuidance( " primary generator control." ); fReadCmd = new G4UIcmdWithAString( "/primarygenerator/input", this ); fReadCmd->SetGuidance( "Read from input file " ); fReadCmd->SetParameterName( "fInputFileName", false ); fReadCmd->AvailableForStates( G4State_PreInit ); // Set position where primaries read from phase space file should be generated fGenerateCmd = new G4UIcmdWithADouble( "/primarygenerator/generateAt", this ); fGenerateCmd->SetGuidance( "Set position where primaries should be generated " ); fGenerateCmd->SetParameterName( "fPrimaryPosition", false ); fGenerateCmd->AvailableForStates( G4State_PreInit ); } PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() { delete fReadCmd; delete fGenerateCmd; delete fPrimaryGenDir; } void PrimaryGeneratorMessenger::SetNewValue( G4UIcommand* command, G4String newValue ) { if(command == fReadCmd) { fPrimaryGenAction->SetInputFileName( newValue ); } if(command == fGenerateCmd) { fPrimaryGenAction->SetPrimaryPosition( fGenerateCmd->GetNewDoubleValue( newValue ) );} }