ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4ParticleMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file 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
//
28
//
29
//---------------------------------------------------------------
30
//
31
// G4ParticleMessenger.cc
32
//
33
// Description:
34
// This is a messenger class to interface to exchange information
35
// between Particle related classes and UI.
36
//
37
// History:
38
// 13 June 1997, H. Kurashige : The 1st version created.
39
// 10 Nov. 1997 H. Kurashige : fixed bugs
40
// 08 Jan. 1998 H. Kurashige : new UIcommnds
41
// 08 June 1998, H. Kurashige : remove fProcessManagerMessenger
42
// 25 Nov. 1998, H. Kurashige : add /particle/find
43
//---------------------------------------------------------------
44
45
#include "
G4ios.hh
"
// Include from 'system'
46
#include <iomanip>
// Include from 'system'
47
48
#include "
G4ParticleMessenger.hh
"
49
#include "
G4UImanager.hh
"
50
#include "
G4UIdirectory.hh
"
51
#include "
G4UIcmdWithAString.hh
"
52
#include "
G4UIcmdWithAnInteger.hh
"
53
#include "
G4UIcmdWithoutParameter.hh
"
54
#include "
G4ParticleTable.hh
"
55
#include "
G4IonTable.hh
"
56
#include "
G4ParticleDefinition.hh
"
57
#include "
G4ParticlePropertyMessenger.hh
"
58
59
G4ParticleMessenger::G4ParticleMessenger
(
G4ParticleTable
* pTable)
60
{
61
// get the pointer to ParticleTable
62
if
( pTable == 0) {
63
theParticleTable
=
G4ParticleTable::GetParticleTable
();
64
}
else
{
65
theParticleTable
= pTable;
66
}
67
68
//Directory /particle/
69
thisDirectory
=
new
G4UIdirectory
(
"/particle/"
);
70
thisDirectory
->
SetGuidance
(
"Particle control commands."
);
71
72
//Commnad /particle/select
73
selectCmd
=
new
G4UIcmdWithAString
(
"/particle/select"
,
this
);
74
selectCmd
->
SetGuidance
(
"Select particle "
);
75
selectCmd
->
SetDefaultValue
(
"none"
);
76
selectCmd
->
SetParameterName
(
"particle name"
,
false
);
77
selectCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
78
79
//Commnad /particle/list
80
listCmd
=
new
G4UIcmdWithAString
(
"/particle/list"
,
this
);
81
listCmd
->
SetGuidance
(
"List name of particles."
);
82
listCmd
->
SetGuidance
(
" all(default)/lepton/baryon/meson/nucleus/quarks"
);
83
listCmd
->
SetParameterName
(
"particle type"
,
true
);
84
listCmd
->
SetDefaultValue
(
"all"
);
85
listCmd
->
SetCandidates
(
"all lepton baryon meson nucleus quarks"
);
86
listCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
87
88
//Commnad /particle/find
89
findCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/find"
,
this
);
90
findCmd
->
SetGuidance
(
"Find particle by encoding"
);
91
findCmd
->
SetDefaultValue
(0);
92
findCmd
->
SetParameterName
(
"encoding"
,
false
);
93
findCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
94
95
//Commnad /particle/createAllIon
96
createAllIonCmd
=
new
G4UIcmdWithoutParameter
(
"/particle/createAllIon"
,
this
);
97
createAllIonCmd
->
SetGuidance
(
"Create All ions (ground state)"
);
98
createAllIonCmd
->
AvailableForStates
(
G4State_Idle
);
99
createAllIonCmd
->
SetToBeBroadcasted
(
false
);
100
101
//Commnad /particle/createAllIsomer
102
createAllIsomerCmd
=
new
G4UIcmdWithoutParameter
(
"/particle/createAllIsomer"
,
this
);
103
createAllIsomerCmd
->
SetGuidance
(
"Create All isomers"
);
104
createAllIsomerCmd
->
AvailableForStates
(
G4State_Idle
);
105
createAllIsomerCmd
->
SetToBeBroadcasted
(
false
);
106
107
// -- particle/property/Verbose ---
108
verboseCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/verbose"
,
this
);
109
verboseCmd
->
SetGuidance
(
"Set Verbose level of particle table."
);
110
verboseCmd
->
SetGuidance
(
" 0 : Silent (default)"
);
111
verboseCmd
->
SetGuidance
(
" 1 : Display warning messages"
);
112
verboseCmd
->
SetGuidance
(
" 2 : Display more"
);
113
verboseCmd
->
SetParameterName
(
"verbose_level"
,
true
);
114
verboseCmd
->
SetDefaultValue
(0);
115
verboseCmd
->
SetRange
(
"verbose_level >=0"
);
116
117
currentParticle
= 0;
118
119
//UI messenger for Particle Properties
120
fParticlePropertyMessenger
=
new
G4ParticlePropertyMessenger
(
theParticleTable
);
121
122
}
123
124
G4ParticleMessenger::~G4ParticleMessenger
()
125
{
126
delete
fParticlePropertyMessenger
;
127
128
delete
listCmd
;
129
delete
selectCmd
;
130
delete
findCmd
;
131
delete
createAllIonCmd
;
132
delete
createAllIsomerCmd
;
133
delete
verboseCmd
;
134
135
delete
thisDirectory
;
136
}
137
138
139
void
G4ParticleMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValues)
140
{
141
if
( command==
listCmd
){
142
//Commnad /particle/List
143
G4int
counter = 0;
144
G4ParticleTable::G4PTblDicIterator
*
piter
=
theParticleTable
->
GetIterator
();
145
piter -> reset();
146
147
while
( (*piter)() ){
// Loop checking, 09.08.2015, K.Kurashige
148
G4ParticleDefinition
*
particle
= piter->
value
();
149
if
((newValues==
"all"
) || (newValues==particle->
GetParticleType
())) {
150
G4cout
<< std::setw(19) << particle->
GetParticleName
();
151
if
((counter++)%4 == 3) {
152
G4cout
<<
G4endl
;
153
}
else
{
154
G4cout
<<
","
;
155
}
156
}
157
}
158
G4cout
<<
G4endl
;
159
if
(counter == 0)
G4cout
<< newValues <<
" is not found "
<<
G4endl
;
160
161
//Command /particle/select
162
// set candidate List
163
G4String
candidates(
"none"
);
164
piter -> reset();
165
while
( (*piter)() ){
// Loop checking, 09.08.2015, K.Kurashige
166
G4ParticleDefinition
*
particle
= piter->
value
();
167
candidates +=
" "
+ particle->
GetParticleName
();
168
}
169
selectCmd
->
SetCandidates
((
const
char
*)(candidates));
170
171
}
else
if
( command==
selectCmd
){
172
//Commnad /particle/select
173
currentParticle
=
theParticleTable
->
FindParticle
(newValues);
174
if
(
currentParticle
== 0) {
175
G4cout
<<
"Unknown particle ["
<< newValues <<
"]. Command ignored."
<<
G4endl
;
176
}
177
178
}
else
if
( command==
findCmd
){
179
//Commnad /particle/find
180
G4ParticleDefinition
*
tmp
=
theParticleTable
->
FindParticle
(
findCmd
->
GetNewIntValue
(newValues));
181
if
(tmp == 0) {
182
G4cout
<<
"Unknown particle ["
<< newValues <<
"]. Command ignored."
<<
G4endl
;
183
}
else
{
184
G4cout
<< tmp->
GetParticleName
() <<
G4endl
;
185
tmp->
DumpTable
();
186
}
187
188
}
else
if
( command==
createAllIonCmd
) {
189
//Commnad /particle/createAllIon
190
theParticleTable
->
GetIonTable
()->
CreateAllIon
();
191
192
}
else
if
( command==
createAllIsomerCmd
) {
193
//Commnad /particle/createAllIsomer
194
theParticleTable
->
GetIonTable
()->
CreateAllIsomer
();
195
196
}
else
if
( command==
verboseCmd
) {
197
//Commnad /particle/verbose
198
theParticleTable
->
SetVerboseLevel
(
verboseCmd
->
GetNewIntValue
(newValues));
199
}
200
}
201
202
G4String
G4ParticleMessenger::GetCurrentValue
(
G4UIcommand
* command)
203
{
204
if
( command==
selectCmd
){
205
//Command /particle/select
206
// set candidate List
207
G4String
candidates(
"none"
);
208
G4ParticleTable::G4PTblDicIterator
*
piter
=
theParticleTable
->
GetIterator
();
209
piter -> reset();
210
while
( (*piter)() ){
// Loop checking, 09.08.2015, K.Kurashige
211
G4ParticleDefinition
*
particle
= piter->
value
();
212
candidates +=
" "
+ particle->
GetParticleName
();
213
}
214
selectCmd
->
SetCandidates
((
const
char
*)(candidates));
215
216
static
const
G4String
noName(
"none"
);
217
// current value
218
if
(
currentParticle
== 0) {
219
// no particle is selected. return null
220
return
noName;
221
}
else
{
222
return
currentParticle
->
GetParticleName
();
223
}
224
}
else
if
( command==
verboseCmd
){
225
//Commnad /particle/verbose
226
return
verboseCmd
->
ConvertToString
(
theParticleTable
->
GetVerboseLevel
());
227
}
228
return
""
;
229
}
230
231
232
233
234
235
geant4
tree
geant4-10.6-release
source
particles
management
src
G4ParticleMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:24
using
1.8.2 with
ECCE GitHub integration