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

#include <G4UIcmdWith3VectorAndUnit.hh>

+ Inheritance diagram for G4UIcmdWith3VectorAndUnit:

Public Member Functions

 G4UIcmdWith3VectorAndUnit (const char *theCommandPath, G4UImessenger *theMessenger)
 
G4int DoIt (G4String parameterList) override
 
G4String ConvertToStringWithBestUnit (const G4ThreeVector &vec)
 
G4String ConvertToStringWithDefaultUnit (const G4ThreeVector &vec)
 
void SetParameterName (const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
 
void SetDefaultValue (const G4ThreeVector &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 G4ThreeVector GetNew3VectorValue (const char *paramString)
 
static G4ThreeVector GetNew3VectorRawValue (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 42 of file G4UIcmdWith3VectorAndUnit.hh.

Constructor & Destructor Documentation

◆ G4UIcmdWith3VectorAndUnit()

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

Definition at line 40 of file G4UIcmdWith3VectorAndUnit.cc.

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

Member Function Documentation

◆ ConvertToStringWithBestUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit ( const G4ThreeVector & vec)

Definition at line 131 of file G4UIcmdWith3VectorAndUnit.cc.

132{
133 G4UIparameter* unitParam = GetParameter(3);
134 G4String canList = unitParam->GetParameterCandidates();
135 G4Tokenizer candidateTokenizer(canList);
136 G4String aToken = candidateTokenizer();
137
138 std::ostringstream os;
139 os << G4BestUnit(vec, CategoryOf(aToken));
140 G4String st = os.str();
141
142 return st;
143}
#define G4BestUnit(a, b)
G4UIparameter * GetParameter(G4int i) const
static G4String CategoryOf(const char *unitName)
const G4String & GetParameterCandidates() const

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

◆ ConvertToStringWithDefaultUnit()

G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit ( const G4ThreeVector & vec)

Definition at line 146 of file G4UIcmdWith3VectorAndUnit.cc.

147{
148 G4UIparameter* unitParam = GetParameter(3);
149 G4String st;
150 if (unitParam->IsOmittable()) {
151 st = ConvertToString(vec, unitParam->GetDefaultValue());
152 }
153 else {
155 }
156 return st;
157}
G4String ConvertToStringWithBestUnit(const G4ThreeVector &vec)
static G4String ConvertToString(G4bool boolVal)
G4bool IsOmittable() const
const G4String & GetDefaultValue() const

◆ DoIt()

G4int G4UIcmdWith3VectorAndUnit::DoIt ( G4String parameterList)
overridevirtual

Reimplemented from G4UIcommand.

Definition at line 57 of file G4UIcmdWith3VectorAndUnit.cc.

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

◆ GetNew3VectorRawValue()

G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue ( const char * paramString)
static

Definition at line 106 of file G4UIcmdWith3VectorAndUnit.cc.

107{
108 G4double vx;
109 G4double vy;
110 G4double vz;
111 char unts[30];
112 std::istringstream is(paramString);
113 is >> vx >> vy >> vz >> unts;
114 return G4ThreeVector(vx, vy, vz);
115}
CLHEP::Hep3Vector G4ThreeVector

◆ GetNew3VectorValue()

◆ GetNewUnitValue()

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

Definition at line 118 of file G4UIcmdWith3VectorAndUnit.cc.

119{
120 G4double vx;
121 G4double vy;
122 G4double vz;
123 char unts[30];
124 std::istringstream is(paramString);
125 is >> vx >> vy >> vz >> unts;
126 G4String unt = unts;
127 return ValueOf(unt);
128}

◆ SetDefaultUnit()

void G4UIcmdWith3VectorAndUnit::SetDefaultUnit ( const char * defUnit)

Definition at line 204 of file G4UIcmdWith3VectorAndUnit.cc.

205{
206 G4UIparameter* untParam = GetParameter(3);
207 untParam->SetOmittable(true);
208 untParam->SetDefaultValue(defUnit);
209 SetUnitCategory(CategoryOf(defUnit));
210}
void SetUnitCategory(const char *unitCategory)
void SetDefaultValue(const char *theDefaultValue)
void SetOmittable(G4bool om)

Referenced by G4MatScanMessenger::G4MatScanMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), and G4ScoringMessenger::G4ScoringMessenger().

◆ SetDefaultValue()

void G4UIcmdWith3VectorAndUnit::SetDefaultValue ( const G4ThreeVector & defVal)

Definition at line 179 of file G4UIcmdWith3VectorAndUnit.cc.

180{
181 G4UIparameter* theParamX = GetParameter(0);
182 theParamX->SetDefaultValue(vec.x());
183 G4UIparameter* theParamY = GetParameter(1);
184 theParamY->SetDefaultValue(vec.y());
185 G4UIparameter* theParamZ = GetParameter(2);
186 theParamZ->SetDefaultValue(vec.z());
187}

Referenced by G4MatScanMessenger::G4MatScanMessenger().

◆ SetParameterName()

void G4UIcmdWith3VectorAndUnit::SetParameterName ( const char * theNameX,
const char * theNameY,
const char * theNameZ,
G4bool omittable,
G4bool currentAsDefault = false )

Definition at line 160 of file G4UIcmdWith3VectorAndUnit.cc.

163{
164 G4UIparameter* theParamX = GetParameter(0);
165 theParamX->SetParameterName(theNameX);
166 theParamX->SetOmittable(omittable);
167 theParamX->SetCurrentAsDefault(currentAsDefault);
168 G4UIparameter* theParamY = GetParameter(1);
169 theParamY->SetParameterName(theNameY);
170 theParamY->SetOmittable(omittable);
171 theParamY->SetCurrentAsDefault(currentAsDefault);
172 G4UIparameter* theParamZ = GetParameter(2);
173 theParamZ->SetParameterName(theNameZ);
174 theParamZ->SetOmittable(omittable);
175 theParamZ->SetCurrentAsDefault(currentAsDefault);
176}
void SetParameterName(const char *pName)
void SetCurrentAsDefault(G4bool val)

Referenced by G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(), G4MatScanMessenger::G4MatScanMessenger(), G4ParticleGunMessenger::G4ParticleGunMessenger(), G4ScoringMessenger::G4ScoringMessenger(), and G4VisCommandsViewerSet::G4VisCommandsViewerSet().

◆ SetUnitCandidates()

void G4UIcmdWith3VectorAndUnit::SetUnitCandidates ( const char * candidateList)

Definition at line 196 of file G4UIcmdWith3VectorAndUnit.cc.

197{
198 G4UIparameter* untParam = GetParameter(3);
199 G4String canList = candidateList;
200 untParam->SetParameterCandidates(canList);
201}
void SetParameterCandidates(const char *theString)

Referenced by SetUnitCategory().

◆ SetUnitCategory()

void G4UIcmdWith3VectorAndUnit::SetUnitCategory ( const char * unitCategory)

Definition at line 190 of file G4UIcmdWith3VectorAndUnit.cc.

191{
192 SetUnitCandidates(UnitsList(unitCategory));
193}
void SetUnitCandidates(const char *candidateList)
static G4String UnitsList(const char *unitCategory)

Referenced by G4GlobalMagFieldMessenger::G4GlobalMagFieldMessenger(), G4VisCommandsViewerSet::G4VisCommandsViewerSet(), and SetDefaultUnit().


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