Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleMessenger Class Reference

#include <G4ParticleMessenger.hh>

Inheritance diagram for G4ParticleMessenger:
Collaboration diagram for G4ParticleMessenger:

Public Member Functions

 G4ParticleMessenger (G4ParticleTable *pTable=0)
 
virtual ~G4ParticleMessenger ()
 
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 ()
 
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)
 
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
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 

Detailed Description

Definition at line 93 of file G4ParticleMessenger.hh.

Constructor & Destructor Documentation

G4ParticleMessenger::G4ParticleMessenger ( G4ParticleTable pTable = 0)

Definition at line 60 of file G4ParticleMessenger.cc.

61 {
62  // get the pointer to ParticleTable
63  if ( pTable == 0) {
64  theParticleTable = G4ParticleTable::GetParticleTable();
65  } else {
66  theParticleTable = pTable;
67  }
68 
69  //Directory /particle/
70  thisDirectory = new G4UIdirectory("/particle/");
71  thisDirectory->SetGuidance("Particle control commands.");
72 
73  //Commnad /particle/select
74  selectCmd = new G4UIcmdWithAString("/particle/select",this);
75  selectCmd->SetGuidance("Select particle ");
76  selectCmd->SetDefaultValue("none");
77  selectCmd->SetParameterName("particle name", false);
79 
80  //Commnad /particle/list
81  listCmd = new G4UIcmdWithAString("/particle/list",this);
82  listCmd->SetGuidance("List name of particles.");
83  listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
84  listCmd->SetParameterName("particle type", true);
85  listCmd->SetDefaultValue("all");
86  listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
88 
89  //Commnad /particle/find
90  findCmd = new G4UIcmdWithAnInteger("/particle/find",this);
91  findCmd->SetGuidance("Find particle by encoding");
92  findCmd->SetDefaultValue(0);
93  findCmd->SetParameterName("encoding", false);
95 
96  //Commnad /particle/createAllIon
97  createAllIonCmd = new G4UIcmdWithoutParameter("/particle/createAllIon",this);
98  createAllIonCmd->SetGuidance("Create All ions (ground state)");
99  createAllIonCmd->AvailableForStates(G4State_Idle);
100  createAllIonCmd->SetToBeBroadcasted(false);
101 
102  //Commnad /particle/createAllIsomer
103  createAllIsomerCmd = new G4UIcmdWithoutParameter("/particle/createAllIsomer",this);
104  createAllIsomerCmd->SetGuidance("Create All isomers");
105  createAllIsomerCmd->AvailableForStates(G4State_Idle);
106  createAllIsomerCmd->SetToBeBroadcasted(false);
107 
108  // -- particle/property/Verbose ---
109  verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose",this);
110  verboseCmd->SetGuidance("Set Verbose level of particle table.");
111  verboseCmd->SetGuidance(" 0 : Silent (default)");
112  verboseCmd->SetGuidance(" 1 : Display warning messages");
113  verboseCmd->SetGuidance(" 2 : Display more");
114  verboseCmd->SetParameterName("verbose_level",true);
115  verboseCmd->SetDefaultValue(0);
116  verboseCmd->SetRange("verbose_level >=0");
117 
118  currentParticle = 0;
119 
120  //UI messenger for Particle Properties
121  fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
122 
123 }
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240
static G4ParticleTable * GetParticleTable()
void SetDefaultValue(const char *defVal)
void SetCandidates(const char *candidateList)
void SetDefaultValue(G4int defVal)

Here is the call graph for this function:

G4ParticleMessenger::~G4ParticleMessenger ( )
virtual

Definition at line 125 of file G4ParticleMessenger.cc.

126 {
127  delete fParticlePropertyMessenger;
128 
129  delete listCmd;
130  delete selectCmd;
131  delete findCmd;
132  delete createAllIonCmd;
133  delete createAllIsomerCmd;
134  delete verboseCmd;
135 
136  delete thisDirectory;
137 }

Member Function Documentation

G4String G4ParticleMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 203 of file G4ParticleMessenger.cc.

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

Here is the call graph for this function:

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

Reimplemented from G4UImessenger.

Definition at line 140 of file G4ParticleMessenger.cc.

141 {
142  if( command==listCmd ){
143  //Commnad /particle/List
144  G4int counter = 0;
145  G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
146  piter -> reset();
147 
148  while( (*piter)() ){// Loop checking, 09.08.2015, K.Kurashige
149  G4ParticleDefinition *particle = piter->value();
150  if ((newValues=="all") || (newValues==particle->GetParticleType())) {
151  G4cout << std::setw(19) << particle->GetParticleName();
152  if ((counter++)%4 == 3) {
153  G4cout << G4endl;
154  } else {
155  G4cout << ",";
156  }
157  }
158  }
159  G4cout << G4endl;
160  if (counter == 0) G4cout << newValues << " is not found " << G4endl;
161 
162  //Command /particle/select
163  // set candidate List
164  G4String candidates("none");
165  piter -> reset();
166  while( (*piter)() ){// Loop checking, 09.08.2015, K.Kurashige
167  G4ParticleDefinition *particle = piter->value();
168  candidates += " " + particle->GetParticleName();
169  }
170  selectCmd->SetCandidates((const char *)(candidates));
171 
172  } else if( command==selectCmd ){
173  //Commnad /particle/select
174  currentParticle = theParticleTable->FindParticle(newValues);
175  if(currentParticle == 0) {
176  G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
177  }
178 
179  } else if( command==findCmd ){
180  //Commnad /particle/find
181  G4ParticleDefinition* tmp = theParticleTable->FindParticle( findCmd->GetNewIntValue(newValues));
182  if(tmp == 0) {
183  G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
184  } else {
185  G4cout << tmp->GetParticleName() << G4endl;
186  tmp->DumpTable();
187  }
188 
189  } else if( command==createAllIonCmd ) {
190  //Commnad /particle/createAllIon
191  theParticleTable->GetIonTable()->CreateAllIon();
192 
193  } else if( command==createAllIsomerCmd ) {
194  //Commnad /particle/createAllIsomer
195  theParticleTable->GetIonTable()->CreateAllIsomer();
196 
197  } else if( command==verboseCmd ) {
198  //Commnad /particle/verbose
199  theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
200  }
201 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4int GetNewIntValue(const char *paramString)
void SetVerboseLevel(G4int value)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void CreateAllIsomer()
Definition: G4IonTable.cc:1612
G4IonTable * GetIonTable() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetParticleType() const
void CreateAllIon()
Definition: G4IonTable.cc:1606
void SetCandidates(const char *candidateList)
#define G4endl
Definition: G4ios.hh:61
G4PTblDicIterator * GetIterator() const

Here is the call graph for this function:


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