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
G4ParticlePropertyMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ParticlePropertyMessenger.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
// G4ParticlePropertyMessenger.cc
32
//
33
// Description:
34
// This is a messenger class to interface to exchange information
35
// between ParticleDefinition 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
// 19 June 1998 H. Kurashige : adds UnitCategory
42
//---------------------------------------------------------------
43
44
#include "
G4ParticlePropertyMessenger.hh
"
45
#include "
G4UImanager.hh
"
46
#include "
G4UIdirectory.hh
"
47
#include "
G4UIcmdWithoutParameter.hh
"
48
#include "
G4UIcmdWithAnInteger.hh
"
49
#include "
G4UIcmdWithADoubleAndUnit.hh
"
50
#include "
G4UIcmdWithABool.hh
"
51
#include "
G4ParticleDefinition.hh
"
52
#include "
G4DecayTableMessenger.hh
"
53
#include "
G4ParticlePropertyMessenger.hh
"
54
#include "
G4ParticleTable.hh
"
55
#include "
G4ios.hh
"
// Include from 'system'
56
#include <iomanip>
// Include from 'system'
57
58
G4ParticlePropertyMessenger::G4ParticlePropertyMessenger
(
G4ParticleTable
* pTable)
59
:theParticleTable(pTable),
60
currentParticle(0),
61
fDecayTableMessenger(0)
62
{
63
if
(
theParticleTable
== 0)
theParticleTable
=
G4ParticleTable::GetParticleTable
();
64
//Commnad /particle/property/
65
thisDirectory
=
new
G4UIdirectory
(
"/particle/property/"
);
66
thisDirectory
->
SetGuidance
(
"Paricle Table control commands."
);
67
68
//Commnad /particle/property/dump
69
dumpCmd
=
new
G4UIcmdWithoutParameter
(
"/particle/property/dump"
,
this
);
70
dumpCmd
->
SetGuidance
(
"dump particle properties."
);
71
72
//Command /particle/property/stable
73
stableCmd
=
new
G4UIcmdWithABool
(
"/particle/property/stable"
,
this
);
74
stableCmd
->
SetGuidance
(
"Set stable flag."
);
75
stableCmd
->
SetGuidance
(
" false: Unstable true: Stable"
);
76
stableCmd
->
SetParameterName
(
"stable"
,
false
);
77
stableCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
,
G4State_GeomClosed
);
78
79
//particle/property/lifetime
80
lifetimeCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/particle/property/lifetime"
,
this
);
81
lifetimeCmd
->
SetGuidance
(
"Set life time."
);
82
lifetimeCmd
->
SetGuidance
(
"Unit of the time can be :"
);
83
lifetimeCmd
->
SetGuidance
(
" s, ms, ns (default)"
);
84
lifetimeCmd
->
SetParameterName
(
"life"
,
false
);
85
lifetimeCmd
->
SetDefaultValue
(0.0);
86
lifetimeCmd
->
SetRange
(
"life >0.0"
);
87
//lifetimeCmd->SetUnitCategory("Time");
88
//lifetimeCmd->SetUnitCandidates("s ms ns");
89
lifetimeCmd
->
SetDefaultUnit
(
"ns"
);
90
lifetimeCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
,
G4State_GeomClosed
);
91
92
// -- particle/property/Verbose ---
93
verboseCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/property/verbose"
,
this
);
94
verboseCmd
->
SetGuidance
(
"Set Verbose level of particle property."
);
95
verboseCmd
->
SetGuidance
(
" 0 : Silent (default)"
);
96
verboseCmd
->
SetGuidance
(
" 1 : Display warning messages"
);
97
verboseCmd
->
SetGuidance
(
" 2 : Display more"
);
98
verboseCmd
->
SetParameterName
(
"verbose_level"
,
true
);
99
verboseCmd
->
SetDefaultValue
(0);
100
verboseCmd
->
SetRange
(
"verbose_level >=0"
);
101
102
//UI messenger for Decay Table
103
fDecayTableMessenger
=
new
G4DecayTableMessenger
(
theParticleTable
);
104
105
}
106
107
G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger
()
108
{
109
if
(
fDecayTableMessenger
!=0)
delete
fDecayTableMessenger
;
110
fDecayTableMessenger
= 0;
111
112
delete
stableCmd
;
113
delete
verboseCmd
;
114
delete
lifetimeCmd
;
115
delete
dumpCmd
;
116
delete
thisDirectory
;
117
}
118
119
void
G4ParticlePropertyMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
120
{
121
if
(
SetCurrentParticle
()==0) {
122
G4cout
<<
"Particle is not selected yet !! Command ignored."
<<
G4endl
;
123
return
;
124
}
125
126
if
( command ==
dumpCmd
){
127
//Commnad /particle/property/dump
128
currentParticle
->
DumpTable
();
129
130
}
else
if
(command ==
lifetimeCmd
) {
131
//Commnad /particle/property/lifetime
132
currentParticle
->
SetPDGLifeTime
(
lifetimeCmd
->
GetNewDoubleValue
(newValue));
133
134
}
else
if
(command ==
stableCmd
) {
135
//Commnad /particle/property/stable
136
if
(
currentParticle
->
GetPDGLifeTime
()<0.0) {
137
G4cout
<<
"Life time is negative! Command ignored."
<<
G4endl
;
138
}
else
if
(
currentParticle
->
GetPDGMass
()<=0.0) {
139
G4cout
<<
"Zero Mass! Command ignored."
<<
G4endl
;
140
}
else
{
141
currentParticle
->
SetPDGStable
(
stableCmd
->
GetNewBoolValue
(newValue));
142
}
143
144
}
else
if
( command==
verboseCmd
) {
145
//Commnad /particle/property/Verbose
146
currentParticle
->
SetVerboseLevel
(
verboseCmd
->
GetNewIntValue
(newValue));
147
}
148
}
149
150
G4ParticleDefinition
*
G4ParticlePropertyMessenger::SetCurrentParticle
()
151
{
152
// set currentParticle pointer
153
154
// get particle name by asking G4ParticleMessenger via UImanager
155
156
G4String
particleName =
G4UImanager::GetUIpointer
()->
GetCurrentStringValue
(
"/particle/select"
);
157
158
if
(
currentParticle
!= 0 ){
159
// check whether selection is changed
160
if
(
currentParticle
->
GetParticleName
() != particleName) {
161
currentParticle
=
theParticleTable
->
FindParticle
(particleName);
162
}
163
}
else
{
164
currentParticle
=
theParticleTable
->
FindParticle
(particleName);
165
}
166
return
currentParticle
;
167
}
168
169
G4String
G4ParticlePropertyMessenger::GetCurrentValue
(
G4UIcommand
* command)
170
{
171
G4String
returnValue(
'\0'
);
172
173
if
(
SetCurrentParticle
()==0) {
174
// no particle is selected. return null
175
return
returnValue;
176
}
177
178
if
( command ==
stableCmd
){
179
//Commnad /particle/property/stable
180
returnValue =
stableCmd
->
ConvertToString
(
currentParticle
->
GetPDGStable
());
181
182
}
else
if
( command ==
lifetimeCmd
){
183
//Commnad /particle/property/lifetime
184
returnValue =
lifetimeCmd
->
ConvertToString
(
currentParticle
->
GetPDGLifeTime
() ,
"ns"
);
185
186
}
else
if
( command==
verboseCmd
){
187
//Commnad /particle/property/Verbose
188
returnValue=
verboseCmd
->
ConvertToString
(
currentParticle
->GetVerboseLevel());
189
190
}
191
192
return
returnValue;
193
}
194
195
196
197
198
199
200
201
geant4
tree
geant4-10.6-release
source
particles
management
src
G4ParticlePropertyMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:24
using
1.8.2 with
ECCE GitHub integration