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

#include <G4ParticleMessenger.hh>

+ Inheritance diagram for G4ParticleMessenger:

Public Member Functions

 G4ParticleMessenger (G4ParticleTable *pTable=nullptr)
 
virtual ~G4ParticleMessenger ()
 
 G4ParticleMessenger (const G4ParticleMessenger &)=delete
 
G4ParticleMessengeroperator= (const G4ParticleMessenger &)=delete
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

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 {
51 theParticleTable = G4ParticleTable::GetParticleTable();
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 ");
65 selectCmd->SetDefaultValue("none");
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);
74 listCmd->SetDefaultValue("all");
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");
81 findCmd->SetDefaultValue(0);
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)");
88 createAllIonCmd->AvailableForStates(G4State_Idle);
89 createAllIonCmd->SetToBeBroadcasted(false);
90
91 // Command /particle/createAllIsomer
92 createAllIsomerCmd = new G4UIcmdWithoutParameter("/particle/createAllIsomer",this);
93 createAllIsomerCmd->SetGuidance("Create All isomers");
94 createAllIsomerCmd->AvailableForStates(G4State_Idle);
95 createAllIsomerCmd->SetToBeBroadcasted(false);
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);
104 verboseCmd->SetDefaultValue(0);
105 verboseCmd->SetRange("verbose_level >=0");
106
107 // UI messenger for Particle Properties
108 fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
109}
@ G4State_Idle
@ G4State_PreInit
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:273

◆ ~G4ParticleMessenger()

G4ParticleMessenger::~G4ParticleMessenger ( )
virtual

Definition at line 112 of file G4ParticleMessenger.cc.

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

◆ G4ParticleMessenger() [2/2]

G4ParticleMessenger::G4ParticleMessenger ( const G4ParticleMessenger )
delete

Member Function Documentation

◆ 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");
213 G4ParticleTable::G4PTblDicIterator* piter = theParticleTable->GetIterator();
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 {
231 return currentParticle->GetParticleName();
232 }
233 }
234 else if( command==verboseCmd )
235 {
236 // Command /particle/verbose
237 return verboseCmd->ConvertToString(theParticleTable->GetVerboseLevel());
238 }
239 return "";
240}
const G4String & GetParticleName() const
G4int GetVerboseLevel() const
G4PTblDicIterator * GetIterator() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430

◆ operator=()

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

◆ 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;
133 G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
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
170 theParticleTable->SelectParticle(newValues);
171 }
172 else if( command==findCmd )
173 {
174 // Command /particle/find
176 = theParticleTable->FindParticle( findCmd->GetNewIntValue(newValues));
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
191 theParticleTable->GetIonTable()->CreateAllIon();
192 }
193 else if( command==createAllIsomerCmd )
194 {
195 // Command /particle/createAllIsomer
196 theParticleTable->GetIonTable()->CreateAllIsomer();
197 }
198 else if( command==verboseCmd )
199 {
200 // Command /particle/verbose
201 theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
202 }
203}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
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)

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