Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
G4ParticleMessenger Class Reference

#include <G4ParticleMessenger.hh>

Inheritance diagram for G4ParticleMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4ParticleMessenger (const G4ParticleMessenger &)=delete
 
 G4ParticleMessenger (G4ParticleTable *pTable=nullptr)
 
G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4ParticleMessengeroperator= (const G4ParticleMessenger &)=delete
 
G4bool operator== (const G4UImessenger &messenger) const
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual ~G4ParticleMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Attributes

G4UIcmdWithoutParametercreateAllIonCmd = nullptr
 
G4UIcmdWithoutParametercreateAllIsomerCmd = nullptr
 
G4ParticleDefinitioncurrentParticle = nullptr
 
G4UIcmdWithAnIntegerfindCmd = nullptr
 
G4ParticlePropertyMessengerfParticlePropertyMessenger = nullptr
 
G4UIcmdWithAStringlistCmd = nullptr
 
G4UIcmdWithAStringselectCmd = nullptr
 
G4ParticleTabletheParticleTable = nullptr
 
G4UIdirectorythisDirectory = nullptr
 
G4UIcmdWithAnIntegerverboseCmd = nullptr
 

Detailed Description

Definition at line 75 of file G4ParticleMessenger.hh.

Constructor & Destructor Documentation

◆ G4ParticleMessenger() [1/2]

G4ParticleMessenger::G4ParticleMessenger ( G4ParticleTable pTable = nullptr)

Definition at line 46 of file G4ParticleMessenger.cc.

47{
48 // get the pointer to ParticleTable
49 if ( pTable == nullptr)
50 {
52 }
53 else
54 {
55 theParticleTable = pTable;
56 }
57
58 // Directory /particle/
59 thisDirectory = new G4UIdirectory("/particle/");
60 thisDirectory->SetGuidance("Particle control commands.");
61
62 // Command /particle/select
63 selectCmd = new G4UIcmdWithAString("/particle/select",this);
64 selectCmd->SetGuidance("Select particle ");
66 selectCmd->SetParameterName("particle name", false);
68
69 // Command /particle/list
70 listCmd = new G4UIcmdWithAString("/particle/list",this);
71 listCmd->SetGuidance("List name of particles.");
72 listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
73 listCmd->SetParameterName("particle type", true);
75 listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
77
78 // Command /particle/find
79 findCmd = new G4UIcmdWithAnInteger("/particle/find",this);
80 findCmd->SetGuidance("Find particle by encoding");
82 findCmd->SetParameterName("encoding", false);
84
85 // Command /particle/createAllIon
86 createAllIonCmd = new G4UIcmdWithoutParameter("/particle/createAllIon",this);
87 createAllIonCmd->SetGuidance("Create All ions (ground state)");
90
91 // Command /particle/createAllIsomer
92 createAllIsomerCmd = new G4UIcmdWithoutParameter("/particle/createAllIsomer",this);
93 createAllIsomerCmd->SetGuidance("Create All isomers");
96
97 // -- particle/property/Verbose ---
98 verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose",this);
99 verboseCmd->SetGuidance("Set Verbose level of particle table.");
100 verboseCmd->SetGuidance(" 0 : Silent (default)");
101 verboseCmd->SetGuidance(" 1 : Display warning messages");
102 verboseCmd->SetGuidance(" 2 : Display more");
103 verboseCmd->SetParameterName("verbose_level",true);
105 verboseCmd->SetRange("verbose_level >=0");
106
107 // UI messenger for Particle Properties
109}
@ G4State_Idle
@ G4State_PreInit
G4ParticleTable * theParticleTable
G4ParticlePropertyMessenger * fParticlePropertyMessenger
G4UIcmdWithAnInteger * findCmd
G4UIcmdWithAnInteger * verboseCmd
G4UIdirectory * thisDirectory
G4UIcmdWithAString * selectCmd
G4UIcmdWithoutParameter * createAllIonCmd
G4UIcmdWithoutParameter * createAllIsomerCmd
G4UIcmdWithAString * listCmd
static G4ParticleTable * GetParticleTable()
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:288

References G4UIcommand::AvailableForStates(), createAllIonCmd, createAllIsomerCmd, findCmd, fParticlePropertyMessenger, G4State_Idle, G4State_PreInit, G4ParticleTable::GetParticleTable(), listCmd, selectCmd, G4UIcmdWithAString::SetCandidates(), G4UIcmdWithAString::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIcommand::SetRange(), G4UIcommand::SetToBeBroadcasted(), theParticleTable, thisDirectory, and verboseCmd.

◆ ~G4ParticleMessenger()

G4ParticleMessenger::~G4ParticleMessenger ( )
virtual

Definition at line 112 of file G4ParticleMessenger.cc.

113{
115
116 delete listCmd;
117 delete selectCmd;
118 delete findCmd;
119 delete createAllIonCmd;
120 delete createAllIsomerCmd;
121 delete verboseCmd;
122
123 delete thisDirectory;
124}

References createAllIonCmd, createAllIsomerCmd, findCmd, fParticlePropertyMessenger, listCmd, selectCmd, thisDirectory, and verboseCmd.

◆ G4ParticleMessenger() [2/2]

G4ParticleMessenger::G4ParticleMessenger ( const G4ParticleMessenger )
delete

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4ParticleMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 206 of file G4ParticleMessenger.cc.

207{
208 if( command==selectCmd )
209 {
210 // Command /particle/select
211 // set candidate List
212 G4String candidates("none");
214 piter -> reset();
215 while( (*piter)() ) // Loop checking, 09.08.2015, K.Kurashige
216 {
217 G4ParticleDefinition *particle = piter->value();
218 candidates += " " + particle->GetParticleName();
219 }
220 selectCmd->SetCandidates((const char *)(candidates));
221
222 static const G4String noName("none");
223 // current value
224 if(currentParticle == nullptr)
225 {
226 // no particle is selected. return null
227 return noName;
228 }
229 else
230 {
232 }
233 }
234 else if( command==verboseCmd )
235 {
236 // Command /particle/verbose
238 }
239 return "";
240}
const G4String & GetParticleName() const
G4ParticleDefinition * currentParticle
G4int GetVerboseLevel() const
G4PTblDicIterator * GetIterator() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445

References G4UIcommand::ConvertToString(), currentParticle, G4ParticleTable::GetIterator(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetVerboseLevel(), selectCmd, G4UIcmdWithAString::SetCandidates(), theParticleTable, G4ParticleTableIterator< K, V >::value(), and verboseCmd.

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator=()

G4ParticleMessenger & G4ParticleMessenger::operator= ( const G4ParticleMessenger )
delete

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

void G4ParticleMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 127 of file G4ParticleMessenger.cc.

128{
129 if( command==listCmd )
130 {
131 // Command /particle/List
132 G4int counter = 0;
134 piter -> reset();
135
136 while( (*piter)() ) // Loop checking, 09.08.2015, K.Kurashige
137 {
138 G4ParticleDefinition* particle = piter->value();
139 if ((newValues=="all") || (newValues==particle->GetParticleType()))
140 {
141 G4cout << std::setw(19) << particle->GetParticleName();
142 if ((counter++)%4 == 3)
143 {
144 G4cout << G4endl;
145 }
146 else
147 {
148 G4cout << ",";
149 }
150 }
151 }
152 G4cout << G4endl;
153 if (counter == 0) { G4cout << newValues << " is not found " << G4endl; }
154
155 // Command /particle/select
156 // set candidate List
157 G4String candidates("none");
158 piter -> reset();
159 while( (*piter)() ) // Loop checking, 09.08.2015, K.Kurashige
160 {
161 G4ParticleDefinition* particle = piter->value();
162 candidates += " " + particle->GetParticleName();
163 }
164 selectCmd->SetCandidates((const char *)(candidates));
165
166 }
167 else if( command==selectCmd )
168 {
169 // Command /particle/select
171 }
172 else if( command==findCmd )
173 {
174 // Command /particle/find
177 if(tmp == nullptr)
178 {
179 G4cout << "Unknown particle [" << newValues << "]. Command ignored."
180 << G4endl;
181 }
182 else
183 {
184 G4cout << tmp->GetParticleName() << G4endl;
185 tmp->DumpTable();
186 }
187 }
188 else if( command==createAllIonCmd )
189 {
190 // Command /particle/createAllIon
192 }
193 else if( command==createAllIsomerCmd )
194 {
195 // Command /particle/createAllIsomer
197 }
198 else if( command==verboseCmd )
199 {
200 // Command /particle/verbose
202 }
203}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
void CreateAllIsomer()
Definition: G4IonTable.cc:1867
void CreateAllIon()
Definition: G4IonTable.cc:1859
const G4String & GetParticleType() const
G4IonTable * GetIonTable() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetVerboseLevel(G4int value)
void SelectParticle(const G4String &name)
static G4int GetNewIntValue(const char *paramString)

References G4IonTable::CreateAllIon(), createAllIonCmd, G4IonTable::CreateAllIsomer(), createAllIsomerCmd, G4ParticleDefinition::DumpTable(), findCmd, G4ParticleTable::FindParticle(), G4cout, G4endl, G4ParticleTable::GetIonTable(), G4ParticleTable::GetIterator(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetParticleType(), listCmd, selectCmd, G4ParticleTable::SelectParticle(), G4UIcmdWithAString::SetCandidates(), G4ParticleTable::SetVerboseLevel(), theParticleTable, G4ParticleTableIterator< K, V >::value(), and verboseCmd.

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ createAllIonCmd

G4UIcmdWithoutParameter* G4ParticleMessenger::createAllIonCmd = nullptr
private

Definition at line 94 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), SetNewValue(), and ~G4ParticleMessenger().

◆ createAllIsomerCmd

G4UIcmdWithoutParameter* G4ParticleMessenger::createAllIsomerCmd = nullptr
private

Definition at line 95 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), SetNewValue(), and ~G4ParticleMessenger().

◆ currentParticle

G4ParticleDefinition* G4ParticleMessenger::currentParticle = nullptr
private

Definition at line 99 of file G4ParticleMessenger.hh.

Referenced by GetCurrentValue().

◆ findCmd

G4UIcmdWithAnInteger* G4ParticleMessenger::findCmd = nullptr
private

Definition at line 93 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), SetNewValue(), and ~G4ParticleMessenger().

◆ fParticlePropertyMessenger

G4ParticlePropertyMessenger* G4ParticleMessenger::fParticlePropertyMessenger = nullptr
private

Definition at line 101 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), and ~G4ParticleMessenger().

◆ listCmd

G4UIcmdWithAString* G4ParticleMessenger::listCmd = nullptr
private

Definition at line 91 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), SetNewValue(), and ~G4ParticleMessenger().

◆ selectCmd

G4UIcmdWithAString* G4ParticleMessenger::selectCmd = nullptr
private

◆ theParticleTable

G4ParticleTable* G4ParticleMessenger::theParticleTable = nullptr
private

Definition at line 98 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), GetCurrentValue(), and SetNewValue().

◆ thisDirectory

G4UIdirectory* G4ParticleMessenger::thisDirectory = nullptr
private

Definition at line 90 of file G4ParticleMessenger.hh.

Referenced by G4ParticleMessenger(), and ~G4ParticleMessenger().

◆ verboseCmd

G4UIcmdWithAnInteger* G4ParticleMessenger::verboseCmd = nullptr
private

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