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
G4AdjointSimMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4AdjointSimMessenger.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
//
28
// Class Name: G4AdjointCrossSurfChecker
29
// Author: L. Desorgher
30
// Organisation: SpaceIT GmbH
31
// Contract: ESA contract 21435/08/NL/AT
32
// Customer: ESA/ESTEC
34
35
#include <sstream>
36
37
#include "
G4AdjointSimMessenger.hh
"
38
#include "
G4RunManager.hh
"
39
#include "
G4AdjointSimManager.hh
"
40
#include "
G4UIdirectory.hh
"
41
#include "
G4UIcmdWithABool.hh
"
42
#include "
G4UIcmdWithAnInteger.hh
"
43
#include "
G4UIcmdWithADoubleAndUnit.hh
"
44
#include "
G4UIcmdWithADouble.hh
"
45
#include "
G4UIcmdWithoutParameter.hh
"
46
#include "
G4UIcmdWithAString.hh
"
47
#include "
G4UnitsTable.hh
"
48
#include "
G4UIcmdWith3VectorAndUnit.hh
"
49
/*
50
#ifdef G4MULTITHREADED
51
#include "G4MTAdjointSimManager.hh"
52
#endif
53
*/
55
//
56
G4AdjointSimMessenger::G4AdjointSimMessenger
(
G4AdjointSimManager
* pAdjointRunManager)
57
: theAdjointRunManager(pAdjointRunManager)
58
/*
59
#ifdef G4MULTITHREADED
60
,theMTAdjointRunManager(0),beamOnCmd(0)
61
#endif
62
*/
63
64
{
65
AdjointSimDir
=
new
G4UIdirectory
(
"/adjoint/"
);
66
AdjointSimDir
->
SetGuidance
(
"Control of the adjoint or reverse monte carlo simulation"
);
67
68
69
//Start and adjoint Run
70
//---------------------
71
//if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM){
72
beamOnCmd
=
new
G4UIcommand
(
"/adjoint/start_run"
,
this
);
73
beamOnCmd
->
SetGuidance
(
"Start an adjoint Run."
);
74
beamOnCmd
->
SetGuidance
(
"Default number of events to be processed is 1."
);
75
beamOnCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
76
G4UIparameter
* p1 =
new
G4UIparameter
(
"numberOfEvent"
,
'i'
,
true
);
77
p1->
SetDefaultValue
(1);
78
p1->
SetParameterRange
(
"numberOfEvent >= 0"
);
79
beamOnCmd
->
SetParameter
(p1);
80
//}
81
82
//Commands to define parameters relative to the external source
83
//------------------------------------------------------------
84
85
G4UIparameter
* pos_x_par =
new
G4UIparameter
(
"X"
,
'd'
,
true
);
86
87
G4UIparameter
* pos_y_par =
new
G4UIparameter
(
"Y"
,
'd'
,
true
);
88
89
G4UIparameter
* pos_z_par =
new
G4UIparameter
(
"Z"
,
'd'
,
true
);
90
91
G4UIparameter
* radius_par =
new
G4UIparameter
(
"R"
,
'd'
,
true
);
92
93
radius_par->
SetParameterRange
(
"R >= 0"
);
94
95
G4UIparameter
* unit_par =
new
G4UIparameter
(
"unit"
,
's'
,
true
);
96
97
DefineSpherExtSourceCmd
=
new
G4UIcommand
(
"/adjoint/DefineSphericalExtSource"
,
this
);
98
DefineSpherExtSourceCmd
->
SetGuidance
(
"Define a spherical external source."
);
99
DefineSpherExtSourceCmd
->
SetParameter
(pos_x_par);
100
DefineSpherExtSourceCmd
->
SetParameter
(pos_y_par);
101
DefineSpherExtSourceCmd
->
SetParameter
(pos_z_par);
102
DefineSpherExtSourceCmd
->
SetParameter
(radius_par);
103
DefineSpherExtSourceCmd
->
SetParameter
(unit_par);
104
105
G4UIparameter
* phys_vol_name_par =
new
G4UIparameter
(
"phys_vol_name"
,
's'
,
true
);
106
107
DefineSpherExtSourceCenteredOnAVolumeCmd
=
new
G4UIcommand
(
"/adjoint/DefineSphericalExtSourceCenteredOnAVolume"
,
this
);
108
DefineSpherExtSourceCenteredOnAVolumeCmd
->
SetGuidance
(
"Define a spherical external source with the center located at the center of a physical volume"
);
109
DefineSpherExtSourceCenteredOnAVolumeCmd
->
SetParameter
(phys_vol_name_par);
110
DefineSpherExtSourceCenteredOnAVolumeCmd
->
SetParameter
(radius_par);
111
DefineSpherExtSourceCenteredOnAVolumeCmd
->
SetParameter
(unit_par);
112
113
DefineExtSourceOnAVolumeExtSurfaceCmd
=
new
G4UIcmdWithAString
(
"/adjoint/DefineExtSourceOnExtSurfaceOfAVolume"
,
this
);
114
DefineExtSourceOnAVolumeExtSurfaceCmd
->
SetGuidance
(
"Set the external source on the external surface of a physical volume"
);
115
DefineExtSourceOnAVolumeExtSurfaceCmd
->
SetParameterName
(
"phys_vol_name"
,
false
);
116
117
setExtSourceEMaxCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/adjoint/SetExtSourceEmax"
,
this
);
118
setExtSourceEMaxCmd
->
SetGuidance
(
"Set the maximum energy of the external source"
);
119
setExtSourceEMaxCmd
->
SetParameterName
(
"Emax"
,
false
);
120
setExtSourceEMaxCmd
->
SetUnitCategory
(
"Energy"
);
121
setExtSourceEMaxCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
122
123
//Commands to define the adjoint source
124
//------------------------------------------------------------
125
126
DefineSpherAdjSourceCmd
=
new
G4UIcommand
(
"/adjoint/DefineSphericalAdjSource"
,
this
);
127
DefineSpherAdjSourceCmd
->
SetGuidance
(
"Define a spherical adjoint source."
);
128
DefineSpherAdjSourceCmd
->
SetParameter
(pos_x_par);
129
DefineSpherAdjSourceCmd
->
SetParameter
(pos_y_par);
130
DefineSpherAdjSourceCmd
->
SetParameter
(pos_z_par);
131
DefineSpherAdjSourceCmd
->
SetParameter
(radius_par);
132
DefineSpherAdjSourceCmd
->
SetParameter
(unit_par);
133
134
DefineSpherAdjSourceCenteredOnAVolumeCmd
=
new
G4UIcommand
(
"/adjoint/DefineSphericalAdjSourceCenteredOnAVolume"
,
this
);
135
DefineSpherAdjSourceCenteredOnAVolumeCmd
->
SetGuidance
(
"Define a spherical adjoint source with the center located at the center of a physical volume"
);
136
DefineSpherAdjSourceCenteredOnAVolumeCmd
->
SetParameter
(phys_vol_name_par);
137
DefineSpherAdjSourceCenteredOnAVolumeCmd
->
SetParameter
(radius_par);
138
DefineSpherAdjSourceCenteredOnAVolumeCmd
->
SetParameter
(unit_par);
139
140
DefineAdjSourceOnAVolumeExtSurfaceCmd
=
new
G4UIcmdWithAString
(
"/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume"
,
this
);
141
DefineAdjSourceOnAVolumeExtSurfaceCmd
->
SetGuidance
(
"Set the adjoint source on the external surface of physical volume"
);
142
DefineAdjSourceOnAVolumeExtSurfaceCmd
->
SetParameterName
(
"phys_vol_name"
,
false
);
143
144
setAdjSourceEminCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/adjoint/SetAdjSourceEmin"
,
this
);
145
setAdjSourceEminCmd
->
SetGuidance
(
"Set the minimum energy of the adjoint source"
);
146
setAdjSourceEminCmd
->
SetParameterName
(
"Emin"
,
false
);
147
setAdjSourceEminCmd
->
SetUnitCategory
(
"Energy"
);
148
setAdjSourceEminCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
149
150
setAdjSourceEmaxCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/adjoint/SetAdjSourceEmax"
,
this
);
151
setAdjSourceEmaxCmd
->
SetGuidance
(
"Set the maximum energy of the adjoint source"
);
152
setAdjSourceEmaxCmd
->
SetParameterName
(
"Emax"
,
false
);
153
setAdjSourceEmaxCmd
->
SetUnitCategory
(
"Energy"
);
154
setAdjSourceEmaxCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
155
156
ConsiderParticleAsPrimaryCmd
=
new
G4UIcmdWithAString
(
"/adjoint/ConsiderAsPrimary"
,
this
);
157
ConsiderParticleAsPrimaryCmd
->
SetGuidance
(
"Set the selected particle as primary"
);
158
ConsiderParticleAsPrimaryCmd
->
SetParameterName
(
"particle"
,
false
);
159
ConsiderParticleAsPrimaryCmd
->
SetCandidates
(
"e- gamma proton ion"
);
160
161
NeglectParticleAsPrimaryCmd
=
new
G4UIcmdWithAString
(
"/adjoint/NeglectAsPrimary"
,
this
);
162
NeglectParticleAsPrimaryCmd
->
SetGuidance
(
"Remove the selected particle from the list of primaries"
);
163
NeglectParticleAsPrimaryCmd
->
SetParameterName
(
"particle"
,
false
);
164
NeglectParticleAsPrimaryCmd
->
SetCandidates
(
"e- gamma proton ion"
);
165
166
167
setNbOfPrimaryFwdGammasPerEventCmd
=
168
new
G4UIcmdWithAnInteger
(
"/adjoint/SetNbOfPrimaryFwdGammasPerEvent"
,
this
);
169
setNbOfPrimaryFwdGammasPerEventCmd
->
SetGuidance
(
"Set the nb of primary fwd gamm generated on the adjoint source"
);
170
setNbOfPrimaryFwdGammasPerEventCmd
->
SetParameterName
(
"Nb_gammas"
,
false
);
171
setNbOfPrimaryFwdGammasPerEventCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
172
173
setNbOfPrimaryAdjGammasPerEventCmd
=
174
new
G4UIcmdWithAnInteger
(
"/adjoint/SetNbOfPrimaryAdjGammasPerEvent"
,
this
);
175
setNbOfPrimaryAdjGammasPerEventCmd
->
SetGuidance
(
"Set the nb of primary fwd gamm generated on the adjoint source"
);
176
setNbOfPrimaryAdjGammasPerEventCmd
->
SetParameterName
(
"Nb_gammas"
,
false
);
177
setNbOfPrimaryAdjGammasPerEventCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
178
179
setNbOfPrimaryAdjElectronsPerEventCmd
=
180
new
G4UIcmdWithAnInteger
(
"/adjoint/SetNbOfPrimaryAdjElectronsPerEvent"
,
this
);
181
setNbOfPrimaryAdjElectronsPerEventCmd
->
SetGuidance
(
"Set the nb of primary fwd gamm generated on the adjoint source"
);
182
setNbOfPrimaryAdjElectronsPerEventCmd
->
SetParameterName
(
"Nb_gammas"
,
false
);
183
setNbOfPrimaryAdjElectronsPerEventCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
184
185
186
187
188
}
190
//
191
/*
192
#ifdef G4MULTITHREADED
193
G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunManager)
194
: theAdjointRunManager(0),theMTAdjointRunManager(pAdjointRunManager),DefineSpherExtSourceCmd(0),
195
DefineSpherExtSourceCenteredOnAVolumeCmd(0), DefineExtSourceOnAVolumeExtSurfaceCmd(0),
196
setExtSourceEMaxCmd(0),DefineSpherAdjSourceCmd(0),DefineSpherAdjSourceCenteredOnAVolumeCmd(0),
197
DefineAdjSourceOnAVolumeExtSurfaceCmd(0),setAdjSourceEminCmd(0),setAdjSourceEmaxCmd(0),
198
ConsiderParticleAsPrimaryCmd(0),NeglectParticleAsPrimaryCmd(0)
199
{
200
AdjointSimDir = new G4UIdirectory("/adjoint/");
201
AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
202
203
204
//Start and adjoint Run
205
//---------------------
206
beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
207
beamOnCmd->SetGuidance("Start an adjoint Run.");
208
beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
209
beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
210
G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
211
p1->SetDefaultValue(1);
212
p1->SetParameterRange("numberOfEvent >= 0");
213
beamOnCmd->SetParameter(p1);
214
215
216
ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
217
ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
218
ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
219
ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
220
221
NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
222
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
223
NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
224
NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
225
226
227
}
228
#endif
229
*/
230
232
//
233
234
G4AdjointSimMessenger::~G4AdjointSimMessenger
()
235
{
236
if
(
beamOnCmd
)
delete
beamOnCmd
;
237
}
238
240
//
241
242
void
G4AdjointSimMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
243
{
244
if
(!command)
return
;
245
if
( command==
beamOnCmd
)
246
{
247
G4int
nev;
248
const
char
* nv = (
const
char
*)newValue;
249
std::istringstream is(nv);
250
is >> nev ;
251
if
(
G4RunManager::GetRunManager
()->GetRunManagerType() ==
G4RunManager::sequentialRM
)
theAdjointRunManager
->
RunAdjointSimulation
(nev);
252
/*
253
#ifdef G4MULTITHREADED
254
else if (theMTAdjointRunManager) theMTAdjointRunManager->RunAdjointSimulation(nev);
255
else if (theAdjointRunManager) theAdjointRunManager->SwitchToAdjointSimulationMode();
256
#endif
257
*/
258
//G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
259
}
260
else
if
( command==
ConsiderParticleAsPrimaryCmd
){
261
theAdjointRunManager
->
ConsiderParticleAsPrimary
(newValue);
262
}
263
else
if
( command==
NeglectParticleAsPrimaryCmd
){
264
theAdjointRunManager
->
NeglectParticleAsPrimary
(newValue);
265
}
266
/*
267
#ifdef G4MULTITHREADED
268
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::masterRM) return;
269
#endif
270
*/
271
if
( command==
DefineSpherExtSourceCmd
){
272
273
G4double
x
,
y
,
z
,
r
;
274
G4String
unit;
275
const
char
* nv = (
const
char
*)newValue;
276
std::istringstream is(nv);
277
is >> x>>y>>z>>r>>unit;
278
279
x*=
G4UnitDefinition::GetValueOf
(unit);
280
y*=
G4UnitDefinition::GetValueOf
(unit);
281
z*=
G4UnitDefinition::GetValueOf
(unit);
282
r*=
G4UnitDefinition::GetValueOf
(unit);
283
theAdjointRunManager
->
DefineSphericalExtSource
(r,
G4ThreeVector
(x,y,z));
284
}
285
else
if
( command==
DefineSpherExtSourceCenteredOnAVolumeCmd
){
286
287
G4double
r
;
288
G4String
vol_name, unit;
289
const
char
* nv = (
const
char
*)newValue;
290
std::istringstream is(nv);
291
is >>vol_name>>r>>unit;
292
r*=
G4UnitDefinition::GetValueOf
(unit);
293
theAdjointRunManager
->
DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume
(r,vol_name);
294
}
295
else
if
( command==
DefineExtSourceOnAVolumeExtSurfaceCmd
){
296
theAdjointRunManager
->
DefineExtSourceOnTheExtSurfaceOfAVolume
(newValue);
297
}
298
else
if
( command==
setExtSourceEMaxCmd
){
299
300
theAdjointRunManager
->
SetExtSourceEmax
(
setExtSourceEMaxCmd
->
GetNewDoubleValue
(newValue));
301
}
302
else
if
( command==
DefineSpherAdjSourceCmd
){
303
304
G4double
x
,
y
,
z
,
r
;
305
G4String
unit;
306
const
char
* nv = (
const
char
*)newValue;
307
std::istringstream is(nv);
308
is >> x>>y>>z>>r>>unit;
309
310
x*=
G4UnitDefinition::GetValueOf
(unit);
311
y*=
G4UnitDefinition::GetValueOf
(unit);
312
z*=
G4UnitDefinition::GetValueOf
(unit);
313
r*=
G4UnitDefinition::GetValueOf
(unit);
314
theAdjointRunManager
->
DefineSphericalAdjointSource
(r,
G4ThreeVector
(x,y,z));
315
}
316
else
if
( command==
DefineSpherAdjSourceCenteredOnAVolumeCmd
){
317
318
G4double
r
;
319
G4String
vol_name, unit;
320
const
char
* nv = (
const
char
*)newValue;
321
std::istringstream is(nv);
322
is >>vol_name>>r>>unit;
323
r*=
G4UnitDefinition::GetValueOf
(unit);
324
theAdjointRunManager
->
DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume
(r,vol_name);
325
}
326
else
if
( command==
DefineAdjSourceOnAVolumeExtSurfaceCmd
){
327
328
theAdjointRunManager
->
DefineAdjointSourceOnTheExtSurfaceOfAVolume
(newValue);
329
}
330
else
if
( command==
setAdjSourceEminCmd
){
331
332
theAdjointRunManager
->
SetAdjointSourceEmin
(
setAdjSourceEminCmd
->
GetNewDoubleValue
(newValue));
333
}
334
else
if
( command==
setAdjSourceEmaxCmd
){
335
336
theAdjointRunManager
->
SetAdjointSourceEmax
(
setAdjSourceEmaxCmd
->
GetNewDoubleValue
(newValue));
337
}
338
else
if
( command==
setNbOfPrimaryFwdGammasPerEventCmd
){
339
theAdjointRunManager
->
SetNbOfPrimaryFwdGammasPerEvent
(
setNbOfPrimaryFwdGammasPerEventCmd
->
GetNewIntValue
(newValue));
340
}
341
else
if
( command==
setNbOfPrimaryAdjGammasPerEventCmd
){
342
theAdjointRunManager
->
SetNbAdjointPrimaryGammasPerEvent
(
setNbOfPrimaryAdjGammasPerEventCmd
->
GetNewIntValue
(newValue));
343
}
344
else
if
( command==
setNbOfPrimaryAdjElectronsPerEventCmd
){
345
theAdjointRunManager
->
SetNbAdjointPrimaryElectronsPerEvent
(
setNbOfPrimaryAdjElectronsPerEventCmd
->
GetNewIntValue
(newValue));
346
}
347
348
349
}
350
geant4
tree
geant4-10.6-release
source
run
src
G4AdjointSimMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:53
using
1.8.2 with
ECCE GitHub integration