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
DetectorMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file DetectorMessenger.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
//
28
//
29
//
30
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33
#include "DetectorMessenger.hh"
34
35
#include <sstream>
36
#include <iostream>
37
38
#include "
G4OpticalSurface.hh
"
39
40
#include "DetectorConstruction.hh"
41
#include "
G4UIdirectory.hh
"
42
#include "
G4UIcommand.hh
"
43
#include "
G4UIparameter.hh
"
44
#include "
G4UIcmdWithAString.hh
"
45
#include "
G4UIcmdWithADouble.hh
"
46
#include "
G4UIcmdWithAnInteger.hh
"
47
#include "
G4UIcmdWithADoubleAndUnit.hh
"
48
#include "
G4UIcmdWithoutParameter.hh
"
49
50
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
52
DetectorMessenger::DetectorMessenger
(
DetectorConstruction
* Det)
53
:
G4UImessenger
(),fDetector(Det)
54
{
55
fOpticalDir
=
new
G4UIdirectory
(
"/opnovice2/"
);
56
fOpticalDir
->
SetGuidance
(
"Parameters for optical simulation."
);
57
58
fSurfaceTypeCmd
=
new
G4UIcmdWithAString
(
"/opnovice2/surfaceType"
,
this
);
59
fSurfaceTypeCmd
->
SetGuidance
(
"Surface type."
);
60
fSurfaceTypeCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
61
fSurfaceTypeCmd
->
SetToBeBroadcasted
(
false
);
62
63
fSurfaceFinishCmd
=
new
G4UIcmdWithAString
(
"/opnovice2/surfaceFinish"
,
this
);
64
fSurfaceFinishCmd
->
SetGuidance
(
"Surface finish."
);
65
fSurfaceFinishCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
66
fSurfaceFinishCmd
->
SetToBeBroadcasted
(
false
);
67
68
fSurfaceModelCmd
=
69
new
G4UIcmdWithAString
(
"/opnovice2/surfaceModel"
,
this
);
70
fSurfaceModelCmd
->
SetGuidance
(
"surface model."
);
71
fSurfaceModelCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
72
fSurfaceModelCmd
->
SetToBeBroadcasted
(
false
);
73
74
fSurfaceSigmaAlphaCmd
=
75
new
G4UIcmdWithADouble
(
"/opnovice2/surfaceSigmaAlpha"
,
this
);
76
fSurfaceSigmaAlphaCmd
->
SetGuidance
(
"surface sigma alpha"
);
77
fSurfaceSigmaAlphaCmd
->
SetGuidance
(
" parameter."
);
78
fSurfaceSigmaAlphaCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
79
fSurfaceSigmaAlphaCmd
->
SetToBeBroadcasted
(
false
);
80
81
fSurfacePolishCmd
=
82
new
G4UIcmdWithADouble
(
"/opnovice2/surfacePolish"
,
this
);
83
fSurfacePolishCmd
->
SetGuidance
(
"surface polish"
);
84
fSurfacePolishCmd
->
SetGuidance
(
" parameter (for Glisur model)."
);
85
fSurfacePolishCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
86
fSurfacePolishCmd
->
SetToBeBroadcasted
(
false
);
87
88
fSurfaceMatPropVectorCmd
=
89
new
G4UIcmdWithAString
(
"/opnovice2/surfaceProperty"
,
this
);
90
fSurfaceMatPropVectorCmd
->
SetGuidance
(
"Set material property vector"
);
91
fSurfaceMatPropVectorCmd
->
SetGuidance
(
" for the surface."
);
92
fSurfaceMatPropVectorCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
93
fSurfaceMatPropVectorCmd
->
SetToBeBroadcasted
(
false
);
94
95
fSurfaceMatPropConstCmd
=
96
new
G4UIcmdWithAString
(
"/opnovice2/surfaceConstProperty"
,
this
);
97
fSurfaceMatPropConstCmd
->
SetGuidance
(
"Set material constant property"
);
98
fSurfaceMatPropConstCmd
->
SetGuidance
(
" for the surface."
);
99
fSurfaceMatPropConstCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
100
fSurfaceMatPropConstCmd
->
SetToBeBroadcasted
(
false
);
101
102
fTankMatPropVectorCmd
=
103
new
G4UIcmdWithAString
(
"/opnovice2/boxProperty"
,
this
);
104
fTankMatPropVectorCmd
->
SetGuidance
(
"Set material property vector for "
);
105
fTankMatPropVectorCmd
->
SetGuidance
(
"the box."
);
106
fTankMatPropVectorCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
107
fTankMatPropVectorCmd
->
SetToBeBroadcasted
(
false
);
108
109
fTankMatPropConstCmd
=
110
new
G4UIcmdWithAString
(
"/opnovice2/boxConstProperty"
,
this
);
111
fTankMatPropConstCmd
->
SetGuidance
(
"Set material constant property "
);
112
fTankMatPropConstCmd
->
SetGuidance
(
"for the box."
);
113
fTankMatPropConstCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
114
fTankMatPropConstCmd
->
SetToBeBroadcasted
(
false
);
115
116
fTankMaterialCmd
=
new
G4UIcmdWithAString
(
"/opnovice2/boxMaterial"
,
this
);
117
fTankMaterialCmd
->
SetGuidance
(
"Set material of box."
);
118
fTankMaterialCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
119
fTankMaterialCmd
->
SetToBeBroadcasted
(
false
);
120
121
fWorldMatPropVectorCmd
=
122
new
G4UIcmdWithAString
(
"/opnovice2/worldProperty"
,
this
);
123
fWorldMatPropVectorCmd
->
SetGuidance
(
"Set material property vector "
);
124
fWorldMatPropVectorCmd
->
SetGuidance
(
"for the world."
);
125
fWorldMatPropVectorCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
126
fWorldMatPropVectorCmd
->
SetToBeBroadcasted
(
false
);
127
128
fWorldMatPropConstCmd
=
129
new
G4UIcmdWithAString
(
"/opnovice2/worldConstProperty"
,
this
);
130
fWorldMatPropConstCmd
->
SetGuidance
(
"Set material constant property"
);
131
fWorldMatPropConstCmd
->
SetGuidance
(
" for the world."
);
132
fWorldMatPropConstCmd
->
133
AvailableForStates(
G4State_PreInit
,
G4State_Idle
);
134
fWorldMatPropConstCmd
->
SetToBeBroadcasted
(
false
);
135
136
fWorldMaterialCmd
=
new
G4UIcmdWithAString
(
"/opnovice2/worldMaterial"
,
this
);
137
fWorldMaterialCmd
->
SetGuidance
(
"Set material of world."
);
138
fWorldMaterialCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
139
fWorldMaterialCmd
->
SetToBeBroadcasted
(
false
);
140
141
}
142
143
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144
145
DetectorMessenger::~DetectorMessenger
()
146
{
147
delete
fSurfaceFinishCmd
;
148
delete
fSurfaceTypeCmd
;
149
delete
fSurfaceModelCmd
;
150
delete
fSurfaceSigmaAlphaCmd
;
151
delete
fSurfacePolishCmd
;
152
delete
fSurfaceMatPropVectorCmd
;
153
delete
fSurfaceMatPropConstCmd
;
154
delete
fTankMatPropVectorCmd
;
155
delete
fTankMatPropConstCmd
;
156
delete
fTankMaterialCmd
;
157
delete
fWorldMatPropVectorCmd
;
158
delete
fWorldMatPropConstCmd
;
159
delete
fWorldMaterialCmd
;
160
}
161
162
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163
164
void
DetectorMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
165
{
166
// FINISH
167
if
(command ==
fSurfaceFinishCmd
) {
168
if
(newValue ==
"polished"
) {
169
fDetector
->
SetSurfaceFinish
(
polished
);
170
}
171
else
if
(newValue ==
"polishedfrontpainted"
) {
172
fDetector
->
SetSurfaceFinish
(
polishedfrontpainted
);
173
}
174
else
if
(newValue ==
"polishedbackpainted"
) {
175
fDetector
->
SetSurfaceFinish
(
polishedbackpainted
);
176
}
177
else
if
(newValue ==
"ground"
) {
178
fDetector
->
SetSurfaceFinish
(
ground
);
179
}
180
else
if
(newValue ==
"groundfrontpainted"
) {
181
fDetector
->
SetSurfaceFinish
(
groundfrontpainted
);
182
}
183
else
if
(newValue ==
"groundbackpainted"
) {
184
fDetector
->
SetSurfaceFinish
(
groundbackpainted
);
185
}
186
else
if
(newValue ==
"polishedlumirrorair"
) {
187
fDetector
->
SetSurfaceFinish
(
polishedlumirrorair
);
188
}
189
else
if
(newValue ==
"polishedlumirrorglue"
) {
190
fDetector
->
SetSurfaceFinish
(
polishedlumirrorglue
);
191
}
192
else
if
(newValue ==
"polishedair"
) {
193
fDetector
->
SetSurfaceFinish
(
polishedair
);
194
}
195
else
if
(newValue ==
"polishedteflonair"
) {
196
fDetector
->
SetSurfaceFinish
(
polishedteflonair
);
197
}
198
else
if
(newValue ==
"polishedtioair"
) {
199
fDetector
->
SetSurfaceFinish
(
polishedtioair
);
200
}
201
else
if
(newValue ==
"polishedtyvekair"
) {
202
fDetector
->
SetSurfaceFinish
(
polishedtyvekair
);
203
}
204
else
if
(newValue ==
"polishedvm2000air"
) {
205
fDetector
->
SetSurfaceFinish
(
polishedvm2000air
);
206
}
207
else
if
(newValue ==
"polishedvm2000glue"
) {
208
fDetector
->
SetSurfaceFinish
(
polishedvm2000glue
);
209
}
210
else
if
(newValue ==
"etchedlumirrorair"
) {
211
fDetector
->
SetSurfaceFinish
(
etchedlumirrorair
);
212
}
213
else
if
(newValue ==
"etchedlumirrorglue"
) {
214
fDetector
->
SetSurfaceFinish
(
etchedlumirrorglue
);
215
}
216
else
if
(newValue ==
"etchedair"
) {
217
fDetector
->
SetSurfaceFinish
(
etchedair
);
218
}
219
else
if
(newValue ==
"etchedteflonair"
) {
220
fDetector
->
SetSurfaceFinish
(
etchedteflonair
);
221
}
222
else
if
(newValue ==
"etchedtioair"
) {
223
fDetector
->
SetSurfaceFinish
(
etchedtioair
);
224
}
225
else
if
(newValue ==
"etchedtyvekair"
) {
226
fDetector
->
SetSurfaceFinish
(
etchedtyvekair
);
227
}
228
else
if
(newValue ==
"etchedvm2000air"
) {
229
fDetector
->
SetSurfaceFinish
(
etchedvm2000air
);
230
}
231
else
if
(newValue ==
"etchedvm2000glue"
) {
232
fDetector
->
SetSurfaceFinish
(
etchedvm2000glue
);
233
}
234
else
if
(newValue ==
"groundlumirrorair"
) {
235
fDetector
->
SetSurfaceFinish
(
groundlumirrorair
);
236
}
237
else
if
(newValue ==
"groundlumirrorglue"
) {
238
fDetector
->
SetSurfaceFinish
(
groundlumirrorglue
);
239
}
240
else
if
(newValue ==
"groundair"
) {
241
fDetector
->
SetSurfaceFinish
(
groundair
);
242
}
243
else
if
(newValue ==
"groundteflonair"
) {
244
fDetector
->
SetSurfaceFinish
(
groundteflonair
);
245
}
246
else
if
(newValue ==
"groundtioair"
) {
247
fDetector
->
SetSurfaceFinish
(
groundtioair
);
248
}
249
else
if
(newValue ==
"groundtyvekair"
) {
250
fDetector
->
SetSurfaceFinish
(
groundtyvekair
);
251
}
252
else
if
(newValue ==
"groundvm2000air"
) {
253
fDetector
->
SetSurfaceFinish
(
groundvm2000air
);
254
}
255
else
if
(newValue ==
"groundvm2000glue"
) {
256
fDetector
->
SetSurfaceFinish
(
groundvm2000glue
);
257
}
258
// for Davis model
259
else
if
(newValue ==
"Rough_LUT"
) {
260
fDetector
->
SetSurfaceFinish
(
Rough_LUT
);
261
}
262
else
if
(newValue ==
"RoughTeflon_LUT"
) {
263
fDetector
->
SetSurfaceFinish
(
RoughTeflon_LUT
);
264
}
265
else
if
(newValue ==
"RoughESR_LUT"
) {
266
fDetector
->
SetSurfaceFinish
(
RoughESR_LUT
);
267
}
268
else
if
(newValue ==
"RoughESRGrease_LUT"
) {
269
fDetector
->
SetSurfaceFinish
(
RoughESRGrease_LUT
);
270
}
271
else
if
(newValue ==
"Polished_LUT"
) {
272
fDetector
->
SetSurfaceFinish
(
Polished_LUT
);
273
}
274
else
if
(newValue ==
"PolishedTeflon_LUT"
) {
275
fDetector
->
SetSurfaceFinish
(
PolishedTeflon_LUT
);
276
}
277
else
if
(newValue ==
"PolishedESR_LUT"
) {
278
fDetector
->
SetSurfaceFinish
(
PolishedESR_LUT
);
279
}
280
else
if
(newValue ==
"PolishedESRGrease_LUT"
) {
281
fDetector
->
SetSurfaceFinish
(
PolishedESRGrease_LUT
);
282
}
283
else
if
(newValue ==
"Detector_LUT"
) {
284
fDetector
->
SetSurfaceFinish
(
Detector_LUT
);
285
}
286
else
{
287
G4ExceptionDescription
ed;
288
ed <<
"Invalid surface finish: "
<< newValue;
289
G4Exception
(
"DetectorMessenger"
,
"OpNovice2_003"
,
FatalException
,ed);
290
}
291
}
292
293
// MODEL
294
else
if
(command ==
fSurfaceModelCmd
) {
295
if
(newValue ==
"glisur"
) {
296
fDetector
->
SetSurfaceModel
(
glisur
);
297
}
298
else
if
(newValue ==
"unified"
) {
299
fDetector
->
SetSurfaceModel
(
unified
);
300
}
301
else
if
(newValue ==
"LUT"
) {
302
fDetector
->
SetSurfaceModel
(
LUT
);
303
}
304
else
if
(newValue ==
"DAVIS"
) {
305
fDetector
->
SetSurfaceModel
(
DAVIS
);
306
}
307
else
if
(newValue ==
"dichroic"
) {
308
fDetector
->
SetSurfaceModel
(
dichroic
);
309
}
310
else
{
311
G4ExceptionDescription
ed;
312
ed <<
"Invalid surface model: "
<< newValue;
313
G4Exception
(
"DetectorMessenger"
,
"ONovice2_001"
,
314
FatalException
,ed);
315
}
316
}
317
318
// TYPE
319
else
if
(command ==
fSurfaceTypeCmd
) {
320
if
(newValue ==
"dielectric_metal"
) {
321
fDetector
->
SetSurfaceType
(
dielectric_metal
);
322
}
323
else
if
(newValue ==
"dielectric_dielectric"
) {
324
fDetector
->
SetSurfaceType
(
dielectric_dielectric
);
325
}
326
else
if
(newValue ==
"dielectric_LUT"
) {
327
fDetector
->
SetSurfaceType
(
dielectric_LUT
);
328
}
329
else
if
(newValue ==
"dielectric_LUTDAVIS"
) {
330
fDetector
->
SetSurfaceType
(
dielectric_LUTDAVIS
);
331
}
332
else
{
333
G4ExceptionDescription
ed;
334
ed <<
"Invalid surface type: "
<< newValue;
335
G4Exception
(
"DetectorMessenger"
,
"OpNovice2_002"
,
FatalException
,ed);
336
}
337
}
338
else
if
(command ==
fSurfaceSigmaAlphaCmd
) {
339
fDetector
->
SetSurfaceSigmaAlpha
(
340
G4UIcmdWithADouble::GetNewDoubleValue
(newValue));
341
}
342
else
if
(command ==
fSurfacePolishCmd
) {
343
fDetector
->
SetSurfacePolish
(
344
G4UIcmdWithADouble::GetNewDoubleValue
(newValue));
345
}
346
else
if
(command ==
fTankMatPropVectorCmd
) {
347
// got a string. need to convert it to physics vector.
348
// string format is property name, then pairs of energy, value
349
// specify units for each value, eg 3.0*eV
350
// space delimited
351
G4MaterialPropertyVector
* mpv =
new
G4MaterialPropertyVector
();
352
std::istringstream instring(newValue);
353
G4String
prop;
354
instring >> prop;
355
while
(instring) {
356
G4String
tmp
;
357
instring >>
tmp
;
358
if
(tmp ==
""
) {
break
; }
359
G4double
en =
G4UIcommand::ConvertToDouble
(tmp);
360
instring >>
tmp
;
361
G4double
val;
362
val =
G4UIcommand::ConvertToDouble
(tmp);
363
mpv->
InsertValues
(en, val);
364
}
365
const
char
*
c
= prop.c_str();
366
367
fDetector
->
AddTankMPV
(c, mpv);
368
}
369
else
if
(command ==
fWorldMatPropVectorCmd
) {
370
// Convert string to physics vector
371
// string format is property name, then pairs of energy, value
372
G4MaterialPropertyVector
* mpv =
new
G4MaterialPropertyVector
();
373
std::istringstream instring(newValue);
374
G4String
prop;
375
instring >> prop;
376
while
(instring) {
377
G4String
tmp
;
378
instring >>
tmp
;
379
if
(tmp ==
""
) {
break
; }
380
G4double
en =
G4UIcommand::ConvertToDouble
(tmp);
381
instring >>
tmp
;
382
G4double
val;
383
val =
G4UIcommand::ConvertToDouble
(tmp);
384
mpv->
InsertValues
(en, val);
385
}
386
const
char
* c = prop.c_str();
387
fDetector
->
AddWorldMPV
(c, mpv);
388
}
389
else
if
(command ==
fSurfaceMatPropVectorCmd
) {
390
// Convert string to physics vector
391
// string format is property name, then pairs of energy, value
392
// space delimited
393
G4MaterialPropertyVector
* mpv =
new
G4MaterialPropertyVector
();
394
G4cout
<< newValue <<
G4endl
;
395
std::istringstream instring(newValue);
396
G4String
prop;
397
instring >> prop;
398
while
(instring) {
399
G4String
tmp
;
400
instring >>
tmp
;
401
if
(tmp ==
""
) {
break
; }
402
G4double
en =
G4UIcommand::ConvertToDouble
(tmp);
403
instring >>
tmp
;
404
G4double
val;
405
val =
G4UIcommand::ConvertToDouble
(tmp);
406
mpv->
InsertValues
(en, val);
407
}
408
const
char
* c = prop.c_str();
409
fDetector
->
AddSurfaceMPV
(c, mpv);
410
}
411
412
else
if
(command ==
fTankMatPropConstCmd
) {
413
// Convert string to physics vector
414
// string format is property name, then value
415
// space delimited
416
std::istringstream instring(newValue);
417
G4String
prop;
418
G4String
tmp
;
419
instring >> prop;
420
instring >>
tmp
;
421
G4double
val =
G4UIcommand::ConvertToDouble
(tmp);
422
const
char
* c = prop.c_str();
423
fDetector
->
AddTankMPC
(c, val);
424
}
425
else
if
(command ==
fWorldMatPropConstCmd
) {
426
// Convert string to physics vector
427
// string format is property name, then value
428
// space delimited
429
std::istringstream instring(newValue);
430
G4String
prop;
431
G4String
tmp
;
432
instring >> prop;
433
instring >>
tmp
;
434
G4double
val =
G4UIcommand::ConvertToDouble
(tmp);
435
const
char
* c = prop.c_str();
436
fDetector
->
AddTankMPC
(c, val);
437
}
438
else
if
(command ==
fSurfaceMatPropConstCmd
) {
439
// Convert string to physics vector
440
// string format is property name, then value
441
// space delimited
442
std::istringstream instring(newValue);
443
G4String
prop;
444
G4String
tmp
;
445
instring >> prop;
446
instring >>
tmp
;
447
G4double
val =
G4UIcommand::ConvertToDouble
(tmp);
448
const
char
* c = prop.c_str();
449
fDetector
->
AddSurfaceMPC
(c, val);
450
}
451
else
if
(command ==
fWorldMaterialCmd
) {
452
fDetector
->
SetWorldMaterial
(newValue);
453
}
454
else
if
(command ==
fTankMaterialCmd
) {
455
fDetector
->
SetTankMaterial
(newValue);
456
}
457
}
458
459
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
optical
OpNovice2
src
DetectorMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:50
using
1.8.2 with
ECCE GitHub integration