Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleMessenger.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ParticleMessenger.cc 91885 2015-08-10 07:05:56Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4ParticleMessenger.cc
33 //
34 // Description:
35 // This is a messenger class to interface to exchange information
36 // between Particle related classes and UI.
37 //
38 // History:
39 // 13 June 1997, H. Kurashige : The 1st version created.
40 // 10 Nov. 1997 H. Kurashige : fixed bugs
41 // 08 Jan. 1998 H. Kurashige : new UIcommnds
42 // 08 June 1998, H. Kurashige : remove fProcessManagerMessenger
43 // 25 Nov. 1998, H. Kurashige : add /particle/find
44 //---------------------------------------------------------------
45 
46 #include "G4ios.hh" // Include from 'system'
47 #include <iomanip> // Include from 'system'
48 
49 #include "G4ParticleMessenger.hh"
50 #include "G4UImanager.hh"
51 #include "G4UIdirectory.hh"
52 #include "G4UIcmdWithAString.hh"
53 #include "G4UIcmdWithAnInteger.hh"
55 #include "G4ParticleTable.hh"
56 #include "G4IonTable.hh"
57 #include "G4ParticleDefinition.hh"
59 
61 {
62  // get the pointer to ParticleTable
63  if ( pTable == 0) {
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");
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)");
101 
102  //Commnad /particle/createAllIsomer
103  createAllIsomerCmd = new G4UIcmdWithoutParameter("/particle/createAllIsomer",this);
104  createAllIsomerCmd->SetGuidance("Create All isomers");
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);
116  verboseCmd->SetRange("verbose_level >=0");
117 
118  currentParticle = 0;
119 
120  //UI messenger for Particle Properties
122 
123 }
124 
126 {
128 
129  delete listCmd;
130  delete selectCmd;
131  delete findCmd;
132  delete createAllIonCmd;
133  delete createAllIsomerCmd;
134  delete verboseCmd;
135 
136  delete thisDirectory;
137 }
138 
139 
141 {
142  if( command==listCmd ){
143  //Commnad /particle/List
144  G4int counter = 0;
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
175  if(currentParticle == 0) {
176  G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
177  }
178 
179  } else if( command==findCmd ){
180  //Commnad /particle/find
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
192 
193  } else if( command==createAllIsomerCmd ) {
194  //Commnad /particle/createAllIsomer
196 
197  } else if( command==verboseCmd ) {
198  //Commnad /particle/verbose
200  }
201 }
202 
204 {
205  if( command==selectCmd ){
206  //Command /particle/select
207  // set candidate List
208  G4String candidates("none");
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 {
224  }
225  } else if( command==verboseCmd ){
226  //Commnad /particle/verbose
228  }
229  return "";
230 }
231 
232 
233 
234 
235 
236 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4UIcmdWithAnInteger * verboseCmd
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4UIcmdWithoutParameter * createAllIonCmd
void SetNewValue(G4UIcommand *command, G4String newValues)
static G4ParticleTable * GetParticleTable()
G4UIcmdWithAnInteger * findCmd
G4ParticlePropertyMessenger * fParticlePropertyMessenger
G4ParticleMessenger(G4ParticleTable *pTable=0)
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
const G4String & GetParticleType() const
G4IonTable * GetIonTable() const
G4String GetCurrentValue(G4UIcommand *command)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
Float_t tmp
void SetDefaultValue(const char *defVal)
G4PTblDicIterator * GetIterator() const
G4ParticleTable * theParticleTable
G4UIdirectory * thisDirectory
G4int GetVerboseLevel() const
void SetCandidates(const char *candidateList)
G4UIcmdWithoutParameter * createAllIsomerCmd
G4ParticleDefinition * currentParticle
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4GLOB_DLL std::ostream G4cout
void CreateAllIon()
Definition: G4IonTable.cc:1652
G4UIcmdWithAString * selectCmd
void SetVerboseLevel(G4int value)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
G4UIcmdWithAString * listCmd
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
void CreateAllIsomer()
Definition: G4IonTable.cc:1658