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
G4ProcessManagerMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ProcessManagerMessenger.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
// G4ProcessManagerMessenger.cc
32
//
33
// Description:
34
// This is a messenger class to interface to exchange information
35
// between ProcessManagerand 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
// 02 June 2006 M. Maire : add physicsModified in activate/inactivate
42
//
43
//---------------------------------------------------------------
44
45
46
#include "
G4UImanager.hh
"
47
#include "
G4UIdirectory.hh
"
48
#include "
G4UIcmdWithoutParameter.hh
"
49
#include "
G4UIcmdWithAnInteger.hh
"
50
51
#include "
G4VProcess.hh
"
52
#include "
G4ProcessManager.hh
"
53
#include "
G4ParticleTable.hh
"
54
55
#include "
G4ProcessManagerMessenger.hh
"
56
#include "
G4ios.hh
"
// Include from 'system'
57
#include <iomanip>
// Include from 'system'
58
59
#include <sstream>
60
61
G4ProcessManagerMessenger::G4ProcessManagerMessenger
(
G4ParticleTable
* pTable)
62
:theParticleTable(pTable),
63
currentParticle(nullptr),
64
currentProcess(nullptr),
65
theManager(nullptr),
66
theProcessList(nullptr)
67
{
68
if
(
theParticleTable
==
nullptr
)
theParticleTable
=
G4ParticleTable::GetParticleTable
();
69
70
//Commnad /particle/process
71
thisDirectory
=
new
G4UIdirectory
(
"/particle/process/"
);
72
thisDirectory
->
SetGuidance
(
"Process Manager control commands."
);
73
74
//Commnad /particle/process/dump
75
dumpCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/process/dump"
,
this
);
76
dumpCmd
->
SetGuidance
(
"dump process manager or process information"
);
77
dumpCmd
->
SetGuidance
(
" dump [process index]"
);
78
dumpCmd
->
SetGuidance
(
" process index: -1 for process manager"
);
79
dumpCmd
->
SetParameterName
(
"index"
,
true
);
80
dumpCmd
->
SetDefaultValue
(-1);
81
82
//Commnad /particle/process/verbose
83
verboseCmd
=
new
G4UIcommand
(
"/particle/process/verbose"
,
this
);
84
verboseCmd
->
SetGuidance
(
"Set Verbose Level for Process or Process Manager"
);
85
verboseCmd
->
SetGuidance
(
" Verbose [Verbose] [process index]"
);
86
verboseCmd
->
SetGuidance
(
" process index: -1 for process manager"
);
87
G4UIparameter
* param =
new
G4UIparameter
(
"Verbose"
,
'i'
,
true
);
88
param->
SetDefaultValue
(1);
89
verboseCmd
->
SetParameter
(param);
90
param =
new
G4UIparameter
(
"index"
,
'i'
,
true
);
91
param->
SetDefaultValue
(-1);
92
verboseCmd
->
SetParameter
(param);
93
verboseCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Init
,
G4State_Idle
,
G4State_GeomClosed
,
G4State_EventProc
);
94
95
//Commnad /particle/process/activate
96
activateCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/process/activate"
,
this
);
97
activateCmd
->
SetGuidance
(
"Activate process "
);
98
activateCmd
->
SetGuidance
(
" Activate [process index]"
);
99
activateCmd
->
SetParameterName
(
"index"
,
false
);
100
activateCmd
->
SetDefaultValue
(0);
101
activateCmd
->
SetRange
(
"index >=0"
);
102
activateCmd
->
AvailableForStates
(
G4State_Idle
);
103
104
//Commnad /particle/process/inactivate
105
inactivateCmd
=
new
G4UIcmdWithAnInteger
(
"/particle/process/inactivate"
,
this
);
106
inactivateCmd
->
SetGuidance
(
"Inactivate process "
);
107
inactivateCmd
->
SetGuidance
(
" inactivate [process index]"
);
108
inactivateCmd
->
SetParameterName
(
"index"
,
false
);
109
inactivateCmd
->
SetDefaultValue
(0);
110
inactivateCmd
->
SetRange
(
"index >=0"
);
111
inactivateCmd
->
AvailableForStates
(
G4State_Idle
);
112
113
}
114
115
G4ProcessManagerMessenger::~G4ProcessManagerMessenger
()
116
{
117
delete
activateCmd
;
118
delete
inactivateCmd
;
119
delete
verboseCmd
;
120
delete
dumpCmd
;
121
delete
thisDirectory
;
122
}
123
124
G4ParticleDefinition
*
G4ProcessManagerMessenger::SetCurrentParticle
()
125
{
126
// set currentParticle pointer
127
// get particle name by asking G4ParticleMessenger
128
G4String
particleName =
G4UImanager::GetUIpointer
()->
GetCurrentStringValue
(
"/particle/select"
);
129
130
currentParticle
=
theParticleTable
->
FindParticle
(particleName);
131
if
(
currentParticle
==
nullptr
) {
132
theManager
=
nullptr
;
133
G4cout
<<
"G4ProcessManagerMessenger::SetCurrentParticle() "
;
134
G4cout
<< particleName <<
" not found "
<<
G4endl
;
135
}
else
{
136
theManager
=
currentParticle
->
GetProcessManager
();
137
theProcessList
=
theManager
->
GetProcessList
();
138
}
139
return
currentParticle
;
140
}
141
142
void
G4ProcessManagerMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
143
{
144
G4ExceptionDescription
ed;
145
if
(
SetCurrentParticle
()==
nullptr
) {
146
ed <<
"Particle is not selected yet !! Command ignored."
;
147
command->
CommandFailed
(ed);
148
return
;
149
}
150
if
( command ==
dumpCmd
){
151
//Commnad /particle/process/dump
152
G4int
index =
dumpCmd
->
GetNewIntValue
(newValue);
153
if
(index <0) {
154
theManager
->
DumpInfo
();
155
}
else
if
( index < theManager->GetProcessListLength()){
156
currentProcess
= (*theProcessList)(index);
157
if
(
currentProcess
==
nullptr
) {
158
ed <<
" no process at index of "
<< index
159
<<
" in the Process Vector"
;
160
command->
CommandFailed
(ed);
161
}
else
{
162
currentProcess
->
DumpInfo
();
163
}
164
}
else
{
165
ed <<
" illegal index !!! "
;
166
command->
CommandFailed
(ed);
167
currentProcess
=
nullptr
;
168
}
169
170
}
else
if
( command==
activateCmd
) {
171
//Commnad /particle/process/activate
172
theManager
->
SetProcessActivation
(
activateCmd
->
GetNewIntValue
(newValue),
true
);
173
G4UImanager::GetUIpointer
()->
ApplyCommand
(
"/run/physicsModified"
);
174
175
}
else
if
( command==
inactivateCmd
) {
176
//Commnad /particle/process/inactivate
177
theManager
->
SetProcessActivation
(
inactivateCmd
->
GetNewIntValue
(newValue),
false
);
178
G4UImanager::GetUIpointer
()->
ApplyCommand
(
"/run/physicsModified"
);
179
180
}
else
if
( command==
verboseCmd
) {
181
//Commnad /particle/process/Verbose
182
// inputstream for newValues
183
const
char
* temp = (
const
char
*)(newValue);
184
std::istringstream is((
char
*)temp);
185
G4int
Verbose, index;
186
is >>Verbose >>index;
187
if
(index <0) {
188
theManager
->
SetVerboseLevel
(Verbose);
189
190
}
else
if
( index < theManager->GetProcessListLength()){
191
currentProcess
= (*theProcessList)(index);
192
if
(
currentProcess
==
nullptr
) {
193
ed <<
" no process at index of "
<< index
194
<<
" in the Process Vector"
;
195
command->
CommandFailed
(ed);
196
}
else
{
197
currentProcess
->
SetVerboseLevel
(Verbose);
198
}
199
}
else
{
200
ed <<
" illegal index !!! "
;
201
command->
CommandFailed
(ed);
202
currentProcess
=
nullptr
;
203
}
204
}
205
}
206
207
208
G4String
G4ProcessManagerMessenger::GetCurrentValue
(
G4UIcommand
* command)
209
{
210
if
(
SetCurrentParticle
() ==
nullptr
)
return
""
;
211
212
if
( command==
verboseCmd
){
213
//Commnad /particle/process/Verbose
214
return
verboseCmd
->
ConvertToString
(
theManager
->
GetVerboseLevel
());
215
}
else
{
216
return
""
;
217
}
218
}
219
220
221
222
223
geant4
tree
geant4-10.6-release
source
processes
management
src
G4ProcessManagerMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:52
using
1.8.2 with
ECCE GitHub integration