// RAT::Gen_FluxMessenger // Provide user commands to allow the user to change // the parameters of the Gen_Flux generator via the command line. #include #include #include #include #include #include #include #include #include #define G4std std namespace RAT { Gen_FluxMessenger::Gen_FluxMessenger(Gen_Flux* lg):fGenFlux(lg){ // Commands will in a /generator/flux/ directory G4UIdirectory* dir = new G4UIdirectory("/generator/flux/"); dir->SetGuidance("Control the parameters of the Flux generator"); fTimeSetCmd= new G4UIcmdWithAString("/generator/flux/settimegen",this); fTimeSetCmd->SetGuidance("Set time generator for the used flux spectrum"); fTimeSetCmd->SetParameter(new G4UIparameter("setting", 's', true)); fSpectrumCmd = new G4UIcmdWithAString("/generator/flux/setspectrum",this); fSpectrumCmd->SetGuidance("Set flux spectrum"); fSpectrumCmd->SetParameter(new G4UIparameter("setting", 's', true)); fRadiusCmd = new G4UIcmdWithADouble("/generator/flux/setradius",this); fRadiusCmd->SetGuidance("Set radius of sphere"); fRadiusCmd->SetParameter(new G4UIparameter("setting", 'd', true)); } Gen_FluxMessenger::~Gen_FluxMessenger(){ delete fTimeSetCmd; delete fSpectrumCmd; delete fRadiusCmd; } void Gen_FluxMessenger::SetNewValue(G4UIcommand* command, G4String newValues) { if ( command == fTimeSetCmd ){ G4String state = util_strip_default(newValues); fGenFlux->SetTimeGen(state); } else if( command == fSpectrumCmd ){ G4String state = util_strip_default(newValues); fGenFlux->SetSpectrum(state); } else if( command == fRadiusCmd ){ G4String state = util_strip_default(newValues); G4std::istringstream is(state.c_str()); double radius; is >> radius; fGenFlux->SetRadius(radius); } else{ // Error if we reach here. warn << "Gen_FluxMessenger::SetNewValue: Error: Gen_FluxMessenger invalid command" << newline; } } G4String Gen_FluxMessenger::GetCurrentValue(G4UIcommand * command) { // The command parameter is totally unused. Mark it as such. __unused_parameter(command); return G4String("invalid Gen_Flux Messenger \"get\" command"); } }