Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIcmdWithADoubleAndUnit Class Reference

#include <G4UIcmdWithADoubleAndUnit.hh>

+ Inheritance diagram for G4UIcmdWithADoubleAndUnit:

Public Member Functions

 G4UIcmdWithADoubleAndUnit (const char *theCommandPath, G4UImessenger *theMessenger)
 
G4int DoIt (G4String parameterList) override
 
G4String ConvertToStringWithBestUnit (G4double val)
 
G4String ConvertToStringWithDefaultUnit (G4double val)
 
void SetParameterName (const char *theName, G4bool omittable, G4bool currentAsDefault=false)
 
void SetDefaultValue (G4double defVal)
 
void SetUnitCategory (const char *unitCategory)
 
void SetUnitCandidates (const char *candidateList)
 
void SetDefaultUnit (const char *defUnit)
 
- Public Member Functions inherited from G4UIcommand
 G4UIcommand ()=default
 
 G4UIcommand (const char *theCommandPath, G4UImessenger *theMessenger, G4bool tBB=true)
 
virtual ~G4UIcommand ()
 
G4bool operator== (const G4UIcommand &right) const
 
G4bool operator!= (const G4UIcommand &right) const
 
G4String GetCurrentValue ()
 
void AvailableForStates (G4ApplicationState s1)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4, G4ApplicationState s5)
 
G4bool IsAvailable ()
 
virtual void List ()
 
void SetRange (const char *rs)
 
const G4StringGetRange () const
 
std::size_t GetGuidanceEntries () const
 
const G4StringGetGuidanceLine (G4int i) const
 
const G4StringGetCommandPath () const
 
const G4StringGetCommandName () const
 
std::size_t GetParameterEntries () const
 
G4UIparameterGetParameter (G4int i) const
 
std::vector< G4ApplicationState > * GetStateList ()
 
G4UImessengerGetMessenger () const
 
void SetParameter (G4UIparameter *const newParameter)
 
void SetGuidance (const char *aGuidance)
 
const G4String GetTitle () const
 
void SetToBeBroadcasted (G4bool val)
 
G4bool ToBeBroadcasted () const
 
void SetToBeFlushed (G4bool val)
 
G4bool ToBeFlushed () const
 
void SetWorkerThreadOnly (G4bool val=true)
 
G4bool IsWorkerThreadOnly () const
 
void CommandFailed (G4int errCode, G4ExceptionDescription &ed)
 
void CommandFailed (G4ExceptionDescription &ed)
 
G4int IfCommandFailed ()
 
const G4StringGetFailureDescription ()
 
void ResetFailure ()
 
CommandType GetCommandType () const
 
void SetCommandType (CommandType)
 
void SetDefaultSortFlag (G4bool val)
 

Static Public Member Functions

static G4double GetNewDoubleValue (const char *paramString)
 
static G4double GetNewDoubleRawValue (const char *paramString)
 
static G4double GetNewUnitValue (const char *paramString)
 
- Static Public Member Functions inherited from G4UIcommand
static G4String ConvertToString (G4bool boolVal)
 
static G4String ConvertToString (G4int intValue)
 
static G4String ConvertToString (G4long longValue)
 
static G4String ConvertToString (G4double doubleValue)
 
static G4String ConvertToString (G4double doubleValue, const char *unitName)
 
static G4String ConvertToString (const G4ThreeVector &vec)
 
static G4String ConvertToString (const G4ThreeVector &vec, const char *unitName)
 
static G4bool ConvertToBool (const char *st)
 
static G4int ConvertToInt (const char *st)
 
static G4long ConvertToLongInt (const char *st)
 
static G4double ConvertToDouble (const char *st)
 
static G4double ConvertToDimensionedDouble (const char *st)
 
static G4ThreeVector ConvertTo3Vector (const char *st)
 
static G4ThreeVector ConvertToDimensioned3Vector (const char *st)
 
static G4double ValueOf (const char *unitName)
 
static G4String CategoryOf (const char *unitName)
 
static G4String UnitsList (const char *unitCategory)
 

Additional Inherited Members

- Public Types inherited from G4UIcommand
enum  CommandType {
  BaseClassCmd , WithoutParameterCmd , WithABoolCmd , WithAnIntegerCmd ,
  WithALongIntCmd , WithADoubleCmd , WithADoubleAndUnitCmd , With3VectorCmd ,
  With3VectorAndUnitCmd , WithAStringCmd , CmdDirectory = -1
}
 
- Protected Types inherited from G4UIcommand
using yystype = G4UItokenNum::yystype
 
using tokenNum = G4UItokenNum::tokenNum
 
- Protected Member Functions inherited from G4UIcommand
G4int CheckNewValue (const char *newValue)
 
- Protected Attributes inherited from G4UIcommand
G4bool toBeBroadcasted = false
 
G4bool toBeFlushed = false
 
G4bool workerThreadOnly = false
 
G4int commandFailureCode = 0
 
G4String failureDescription = ""
 
G4bool ifSort = false
 

Detailed Description

Definition at line 41 of file G4UIcmdWithADoubleAndUnit.hh.

Constructor & Destructor Documentation

◆ G4UIcmdWithADoubleAndUnit()

G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit ( const char * theCommandPath,
G4UImessenger * theMessenger )

Definition at line 41 of file G4UIcmdWithADoubleAndUnit.cc.

43 : G4UIcommand(theCommandPath, theMessenger)
44{
45 auto* dblParam = new G4UIparameter('d');
46 SetParameter(dblParam);
47 auto* untParam = new G4UIparameter('s');
48 untParam->SetParameterName("Unit");
49 SetParameter(untParam);
51}
G4UIcommand()=default
void SetCommandType(CommandType)
void SetParameter(G4UIparameter *const newParameter)

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit ( G4double val)

Definition at line 121 of file G4UIcmdWithADoubleAndUnit.cc.

122{
123 G4UIparameter* unitParam = GetParameter(1);
124 G4String canList = unitParam->GetParameterCandidates();
125 G4Tokenizer candidateTokenizer(canList);
126 G4String aToken = candidateTokenizer();
127 std::ostringstream os;
128 os << G4BestUnit(val, CategoryOf(aToken));
129
130 G4String st = os.str();
131 return st;
132}
#define G4BestUnit(a, b)
G4UIparameter * GetParameter(G4int i) const
static G4String CategoryOf(const char *unitName)
const G4String & GetParameterCandidates() const

Referenced by ConvertToStringWithDefaultUnit(), and G4MoleculeShootMessenger::GetCurrentValue().

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithDefaultUnit ( G4double val)

Definition at line 135 of file G4UIcmdWithADoubleAndUnit.cc.

136{
137 G4UIparameter* unitParam = GetParameter(1);
138 G4String st;
139 if (unitParam->IsOmittable()) {
140 st = ConvertToString(val, unitParam->GetDefaultValue());
141 }
142 else {
144 }
145 return st;
146}
G4String ConvertToStringWithBestUnit(G4double val)
static G4String ConvertToString(G4bool boolVal)
G4bool IsOmittable() const
const G4String & GetDefaultValue() const

◆ DoIt()

G4int G4UIcmdWithADoubleAndUnit::DoIt ( G4String parameterList)
overridevirtual

Reimplemented from G4UIcommand.

Definition at line 54 of file G4UIcmdWithADoubleAndUnit.cc.

55{
56 std::vector<G4String> token_vector;
57 G4Tokenizer tkn(parameterList);
58 G4String str;
59 while (!(str = tkn()).empty()) {
60 token_vector.push_back(str);
61 }
62
63 // convert a value in default unit
64 G4String converted_parameter;
65 G4String default_unit = GetParameter(1)->GetDefaultValue();
66 if (!default_unit.empty() && token_vector.size() >= 2) {
67 if (CategoryOf(token_vector[1]) != CategoryOf(default_unit)) {
69 }
70 G4double value_given = ValueOf(token_vector[1]);
71 G4double value_default = ValueOf(default_unit);
72 G4double value = ConvertToDouble(token_vector[0]) * value_given / value_default;
73 // reconstruct parameter list
74 converted_parameter += ConvertToString(value);
75 converted_parameter += " ";
76 converted_parameter += default_unit;
77 for (std::size_t i = 2; i < token_vector.size(); ++i) {
78 converted_parameter += " ";
79 converted_parameter += token_vector[i];
80 }
81 }
82 else {
83 converted_parameter = parameterList;
84 }
85
86 return G4UIcommand::DoIt(converted_parameter);
87}
double G4double
Definition G4Types.hh:83
@ fParameterOutOfCandidates
static G4double ValueOf(const char *unitName)
virtual G4int DoIt(G4String parameterList)
static G4double ConvertToDouble(const char *st)

◆ GetNewDoubleRawValue()

G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue ( const char * paramString)
static

Definition at line 96 of file G4UIcmdWithADoubleAndUnit.cc.

97{
98 G4double vl;
99 char unts[30];
100
101 std::istringstream is(paramString);
102 is >> vl >> unts;
103
104 return vl;
105}

◆ GetNewDoubleValue()

G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleValue ( const char * paramString)
static

◆ GetNewUnitValue()

G4double G4UIcmdWithADoubleAndUnit::GetNewUnitValue ( const char * paramString)
static

Definition at line 108 of file G4UIcmdWithADoubleAndUnit.cc.

109{
110 G4double vl;
111 char unts[30];
112
113 std::istringstream is(paramString);
114 is >> vl >> unts;
115 G4String unt = unts;
116
117 return ValueOf(unt);
118}

Referenced by G4GeometryMessenger::SetNewValue().

◆ SetDefaultUnit()

◆ SetDefaultValue()

◆ SetParameterName()

void G4UIcmdWithADoubleAndUnit::SetParameterName ( const char * theName,
G4bool omittable,
G4bool currentAsDefault = false )

Definition at line 149 of file G4UIcmdWithADoubleAndUnit.cc.

151{
152 G4UIparameter* theParam = GetParameter(0);
153 theParam->SetParameterName(theName);
154 theParam->SetOmittable(omittable);
155 theParam->SetCurrentAsDefault(currentAsDefault);
156}
void SetParameterName(const char *pName)
void SetCurrentAsDefault(G4bool val)

Referenced by G4AdjointSimMessenger::G4AdjointSimMessenger(), G4ChargeExchangeMessenger::G4ChargeExchangeMessenger(), G4EmMessenger::G4EmMessenger(), G4EmParametersMessenger::G4EmParametersMessenger(), G4GeometryMessenger::G4GeometryMessenger(), G4HadronicEPTestMessenger::G4HadronicEPTestMessenger(), G4HadronicParametersMessenger::G4HadronicParametersMessenger(), G4INCLXXInterfaceMessenger::G4INCLXXInterfaceMessenger(), G4ModelCmdApplyDoubleAndUnit< M >::G4ModelCmdApplyDoubleAndUnit(), G4NeutronKillerMessenger::G4NeutronKillerMessenger(), G4NuclideTableMessenger::G4NuclideTableMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), G4ParticleHPMessenger::G4ParticleHPMessenger(), G4ParticlePropertyMessenger::G4ParticlePropertyMessenger(), G4ProductionCutsTableMessenger::G4ProductionCutsTableMessenger(), G4QSSMessenger::G4QSSMessenger(), G4RadioactivationMessenger::G4RadioactivationMessenger(), G4RadioactiveDecayMessenger::G4RadioactiveDecayMessenger(), G4ScoringMessenger::G4ScoringMessenger(), G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(), and GFlashShowerModelMessenger::GFlashShowerModelMessenger().

◆ SetUnitCandidates()

void G4UIcmdWithADoubleAndUnit::SetUnitCandidates ( const char * candidateList)

Definition at line 172 of file G4UIcmdWithADoubleAndUnit.cc.

173{
174 G4UIparameter* untParam = GetParameter(1);
175 G4String canList = candidateList;
176 untParam->SetParameterCandidates(canList);
177}
void SetParameterCandidates(const char *theString)

Referenced by SetUnitCategory().

◆ SetUnitCategory()


The documentation for this class was generated from the following files: