Geant4 11.2.2
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)
 
 ~G4ParticleMessenger () override
 
 G4ParticleMessenger (const G4ParticleMessenger &)=delete
 
G4ParticleMessengeroperator= (const G4ParticleMessenger &)=delete
 
void SetNewValue (G4UIcommand *command, G4String newValues) override
 
G4String GetCurrentValue (G4UIcommand *command) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 theParticleTable = G4ParticleTable::GetParticleTable();
51 }
52 else {
53 theParticleTable = pTable;
54 }
55
56 // Directory /particle/
57 thisDirectory = new G4UIdirectory("/particle/");
58 thisDirectory->SetGuidance("Particle control commands.");
59
60 // Command /particle/select
61 selectCmd = new G4UIcmdWithAString("/particle/select", this);
62 selectCmd->SetGuidance("Select particle ");
63 selectCmd->SetDefaultValue("none");
64 selectCmd->SetParameterName("particle name", false);
66
67 // Command /particle/list
68 listCmd = new G4UIcmdWithAString("/particle/list", this);
69 listCmd->SetGuidance("List name of particles.");
70 listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
71 listCmd->SetParameterName("particle type", true);
72 listCmd->SetDefaultValue("all");
73 listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
75
76 // Command /particle/find
77 findCmd = new G4UIcmdWithAnInteger("/particle/find", this);
78 findCmd->SetGuidance("Find particle by encoding");
79 findCmd->SetDefaultValue(0);
80 findCmd->SetParameterName("encoding", false);
82
83 // Command /particle/createAllIon
84 createAllIonCmd = new G4UIcmdWithoutParameter("/particle/createAllIon", this);
85 createAllIonCmd->SetGuidance("Create All ions (ground state)");
86 createAllIonCmd->AvailableForStates(G4State_Idle);
87 createAllIonCmd->SetToBeBroadcasted(false);
88
89 // Command /particle/createAllIsomer
90 createAllIsomerCmd = new G4UIcmdWithoutParameter("/particle/createAllIsomer", this);
91 createAllIsomerCmd->SetGuidance("Create All isomers");
92 createAllIsomerCmd->AvailableForStates(G4State_Idle);
93 createAllIsomerCmd->SetToBeBroadcasted(false);
94
95 // -- particle/property/Verbose ---
96 verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose", this);
97 verboseCmd->SetGuidance("Set Verbose level of particle table.");
98 verboseCmd->SetGuidance(" 0 : Silent (default)");
99 verboseCmd->SetGuidance(" 1 : Display warning messages");
100 verboseCmd->SetGuidance(" 2 : Display more");
101 verboseCmd->SetParameterName("verbose_level", true);
102 verboseCmd->SetDefaultValue(0);
103 verboseCmd->SetRange("verbose_level >=0");
104
105 // UI messenger for Particle Properties
106 fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
107}
@ 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)
void SetGuidance(const char *aGuidance)
void SetRange(const char *rs)
void AvailableForStates(G4ApplicationState s1)

◆ ~G4ParticleMessenger()

G4ParticleMessenger::~G4ParticleMessenger ( )
override

Definition at line 109 of file G4ParticleMessenger.cc.

110{
111 delete fParticlePropertyMessenger;
112
113 delete listCmd;
114 delete selectCmd;
115 delete findCmd;
116 delete createAllIonCmd;
117 delete createAllIsomerCmd;
118 delete verboseCmd;
119
120 delete thisDirectory;
121}

◆ G4ParticleMessenger() [2/2]

G4ParticleMessenger::G4ParticleMessenger ( const G4ParticleMessenger & )
delete

Member Function Documentation

◆ GetCurrentValue()

G4String G4ParticleMessenger::GetCurrentValue ( G4UIcommand * command)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 189 of file G4ParticleMessenger.cc.

190{
191 if (command == selectCmd) {
192 // Command /particle/select
193 // set candidate List
194 G4String candidates("none");
195 G4ParticleTable::G4PTblDicIterator* piter = theParticleTable->GetIterator();
196 piter->reset();
197 while ((*piter)()) // Loop checking, 09.08.2015, K.Kurashige
198 {
199 G4ParticleDefinition* particle = piter->value();
200 candidates += " " + particle->GetParticleName();
201 }
202 selectCmd->SetCandidates((const char*)(candidates));
203
204 static const G4String noName("none");
205 // current value
206 if (currentParticle == nullptr) {
207 // no particle is selected. return null
208 return noName;
209 }
210
211 return currentParticle->GetParticleName();
212 }
213 if (command == verboseCmd) {
214 // Command /particle/verbose
215 return verboseCmd->ConvertToString(theParticleTable->GetVerboseLevel());
216 }
217 return "";
218}
const G4String & GetParticleName() const
void reset(G4bool ifSkipIon=true)
G4int GetVerboseLevel() const
G4PTblDicIterator * GetIterator() const
static G4String ConvertToString(G4bool boolVal)

◆ operator=()

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

◆ SetNewValue()

void G4ParticleMessenger::SetNewValue ( G4UIcommand * command,
G4String newValues )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 123 of file G4ParticleMessenger.cc.

124{
125 if (command == listCmd) {
126 // Command /particle/List
127 G4int counter = 0;
128 G4ParticleTable::G4PTblDicIterator* piter = theParticleTable->GetIterator();
129 piter->reset();
130
131 while ((*piter)()) // Loop checking, 09.08.2015, K.Kurashige
132 {
133 G4ParticleDefinition* particle = piter->value();
134 if ((newValues == "all") || (newValues == particle->GetParticleType())) {
135 G4cout << std::setw(19) << particle->GetParticleName();
136 if ((counter++) % 4 == 3) {
137 G4cout << G4endl;
138 }
139 else {
140 G4cout << ",";
141 }
142 }
143 }
144 G4cout << G4endl;
145 if (counter == 0) {
146 G4cout << newValues << " is not found " << G4endl;
147 }
148
149 // Command /particle/select
150 // set candidate List
151 G4String candidates("none");
152 piter->reset();
153 while ((*piter)()) // Loop checking, 09.08.2015, K.Kurashige
154 {
155 G4ParticleDefinition* particle = piter->value();
156 candidates += " " + particle->GetParticleName();
157 }
158 selectCmd->SetCandidates((const char*)(candidates));
159 }
160 else if (command == selectCmd) {
161 // Command /particle/select
162 theParticleTable->SelectParticle(newValues);
163 }
164 else if (command == findCmd) {
165 // Command /particle/find
166 G4ParticleDefinition* tmp = theParticleTable->FindParticle(findCmd->GetNewIntValue(newValues));
167 if (tmp == nullptr) {
168 G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
169 }
170 else {
171 G4cout << tmp->GetParticleName() << G4endl;
172 tmp->DumpTable();
173 }
174 }
175 else if (command == createAllIonCmd) {
176 // Command /particle/createAllIon
177 theParticleTable->GetIonTable()->CreateAllIon();
178 }
179 else if (command == createAllIsomerCmd) {
180 // Command /particle/createAllIsomer
181 theParticleTable->GetIonTable()->CreateAllIsomer();
182 }
183 else if (command == verboseCmd) {
184 // Command /particle/verbose
185 theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
186 }
187}
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void CreateAllIsomer()
void CreateAllIon()
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: