// RAT::CoincidenceMessenger // 16 July 2008 JR Wilson // updated 21 June 2013 Zack Blair // Provide user commands to allow the user to change // the parameters of the Coincidence_Gen generator via the command line. #include #include #include #include #include #include #include #include #include using namespace CLHEP; namespace RAT { CoincidenceMessenger::CoincidenceMessenger(Coincidence_Gen* cg):fCoGen(cg){ // Commands will in a /generator/coincidence/ directory G4UIdirectory* dir = new G4UIdirectory("/generator/coincidence/"); dir->SetGuidance("Control the parameters of the coincidence generator"); fGenAddCmd = new G4UIcommand("/generator/coincidence/add", this); fGenAddCmd->SetGuidance("Enable and add new interaction to coincidence generator."); fGenAddCmd->SetGuidance("Usage: /generator/coincidence/add generator_name:generator_state"); fGenAddCmd->SetParameter(new G4UIparameter("gen_name", 's', true)); fGenAddCmd->SetParameter(new G4UIparameter("gen_state", 's', true)); fVtxSetCmd= new G4UIcommand("/generator/coincidence/vtx/set",this); fVtxSetCmd->SetGuidance("Set vertex generator for most recently added coincidence interaction"); fVtxSetCmd->SetParameter(new G4UIparameter("setting", 's', true)); fPosSetCmd= new G4UIcommand("/generator/coincidence/pos/set",this); fPosSetCmd->SetGuidance("Set position generator for most recently added coincidence interaction"); fPosSetCmd->SetParameter(new G4UIparameter("setting", 's', true)); fTimeWinCmd = new G4UIcmdWithADouble("/generator/coincidence/timewindow", this); fTimeWinCmd->SetGuidance("Set time window of coincidences in ns (default = 400ns)"); fTimeWinCmd->SetParameterName("timewin",false); fTimeWinCmd->SetDefaultValue(400); fERangeCmd= new G4UIcommand("/generator/coincidence/energyrange",this); fERangeCmd->SetGuidance("Set range for generated total energy"); fERangeCmd->SetParameter(new G4UIparameter("Erange", 's', true)); fExpCmd= new G4UIcommand("/generator/coincidence/exponential",this); fExpCmd->SetGuidance("Set time constants in ns for subsequent decays (max of 5)"); fExpCmd->SetParameter(new G4UIparameter("Exponents", 's', true)); fFixedCmd = new G4UIcommand("/generator/coincidence/fixed",this); fFixedCmd->SetGuidance("Set time in ns between subsequent decays (max of 5)"); fFixedCmd->SetParameter(new G4UIparameter("fixedtimes", 's', true)); fGaussCmd = new G4UIcommand("/generator/coincidence/gaussian",this); fGaussCmd->SetGuidance("Set mean and standard deviation for Gaussian distribution between subsequent decays (max of 5)"); fGaussCmd->SetParameter(new G4UIparameter("GaussTimes", 's', true)); fQuadraticCmd = new G4UIcommand("/generator/coincidence/quadratic",this); fQuadraticCmd->SetGuidance("Set coefficients for a quadratic probability density function for subsequent decays (max of 5). \nUse the form /generator/coincidence/quadratic A1 B1 C1 A2 B2 C2... \nfor PDFs A1t^2 + B1t + C1, A2t^2 + B2t + C2, ..."); fQuadraticCmd->SetParameter(new G4UIparameter("Quadratic", 's', true)); } CoincidenceMessenger::~CoincidenceMessenger(){ delete fGenAddCmd; delete fVtxSetCmd; delete fPosSetCmd; delete fERangeCmd; delete fTimeWinCmd; delete fExpCmd; delete fFixedCmd; delete fGaussCmd; delete fQuadraticCmd; } void CoincidenceMessenger::SetNewValue(G4UIcommand* command, G4String newValues) { if ( command == fGenAddCmd ){ fCoGen->AddExtra(newValues); }else if ( command == fVtxSetCmd ){ fCoGen->SetExtraVertexState(newValues); }else if ( command == fPosSetCmd ){ fCoGen->SetExtraPosState(newValues); }else if ( command == fTimeWinCmd ){ double tw = fTimeWinCmd->GetNewDoubleValue( newValues ); fCoGen->SetTimeWindow(tw); }else if ( command == fERangeCmd ){ fCoGen->SetEnergyRange(newValues); }else if ( command == fExpCmd ){ fCoGen->SetExponentials(newValues); }else if ( command == fFixedCmd ){ fCoGen->SetFixedTimes(newValues); }else if ( command == fGaussCmd ){ fCoGen->SetGaussians(newValues); }else if ( command == fQuadraticCmd ){ fCoGen->SetQuadratic(newValues); }else{ // Error if we reach here. warn << "Error: CoincidenceMessenger invalid command\n"; } } G4String CoincidenceMessenger::GetCurrentValue(G4UIcommand * command) { // This parameter is unused - flag it as such __unused_parameter(command); // should add some returns here eventually return G4String("invalid Coincidence Messenger \"get\" command"); } }