#include #include #include #include "COMETUserStackingActionMessenger.hh" #include "COMETUserStackingAction.hh" #include COMETUserStackingActionMessenger::COMETUserStackingActionMessenger( COMETUserStackingAction* action) : fUserStackingAction(action) { G4UIparameter* parameter=NULL; fMinEnergyCmd = new G4UIcommand("/comet/killSecondariesIfEnergyBelow",this); fMinEnergyCmd->SetGuidance("Set the minimum kinetic energy for secondaries with a given PDG encoding. Below this value, particles will be killed."); fMinEnergyCmd->SetParameter(new G4UIparameter("PID",'i',false)); parameter=new G4UIparameter("min_kinetic_energy",'d',false); parameter->SetParameterRange("min_kinetic_energy>=0"); fMinEnergyCmd->SetParameter(parameter); parameter=new G4UIparameter("units",'s',true); parameter->SetParameterCandidates(G4UIcommand::UnitsList("Energy")); parameter->SetDefaultValue("MeV"); fMinEnergyCmd->SetParameter(parameter); fMaxEnergyCmd = new G4UIcommand("/comet/killSecondariesIfEnergyAbove",this); fMaxEnergyCmd->SetGuidance("Set the maximum kinetic energy for secondaries with a given PDG encoding. Above this value, particles will be killed."); fMaxEnergyCmd->SetParameter(new G4UIparameter("PID",'i',false)); parameter=new G4UIparameter("max_kinetic_energy",'d',false); parameter->SetParameterRange("max_kinetic_energy>=0"); fMaxEnergyCmd->SetParameter(parameter); parameter=new G4UIparameter("units",'s',true); parameter->SetDefaultValue("MeV"); parameter->SetParameterCandidates(G4UIcommand::UnitsList("Energy")); fMaxEnergyCmd->SetParameter(parameter); } COMETUserStackingActionMessenger::~COMETUserStackingActionMessenger() { delete fMinEnergyCmd; delete fMaxEnergyCmd; } void COMETUserStackingActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { if (command == fMinEnergyCmd || command == fMaxEnergyCmd) { int pid; double energy; G4String units; std::stringstream sstream(newValue); sstream>>pid>>energy>>units; energy*=G4UIcommand::ValueOf(units); if (command == fMinEnergyCmd ) { fUserStackingAction->SetMinEnergy(pid,energy); }else{ fUserStackingAction->SetMaxEnergy(pid,energy); } } }