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 "DetectorConstruction.hh"
36
#include "
G4UIdirectory.hh
"
37
#include "
G4UIcommand.hh
"
38
#include "
G4UIparameter.hh
"
39
#include "
G4UIcmdWithAString.hh
"
40
#include "
G4UIcmdWithAnInteger.hh
"
41
#include "
G4UIcmdWithADoubleAndUnit.hh
"
42
#include "
G4UIcmdWithoutParameter.hh
"
43
44
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46
DetectorMessenger::DetectorMessenger
(
DetectorConstruction
* Det)
47
:
G4UImessenger
(),fDetector(Det),
48
fTestemDir(nullptr),
49
fDetDir(nullptr),
50
fMaterCmd(nullptr),
51
fWMaterCmd(nullptr),
52
fSizeXCmd(nullptr),
53
fSizeYZCmd(nullptr),
54
fMagFieldCmd(nullptr),
55
fTalNbCmd(nullptr),
56
fTalDefCmd(nullptr),
57
fTalPosiCmd(nullptr)
58
{
59
fTestemDir
=
new
G4UIdirectory
(
"/testem/"
);
60
fTestemDir
->
SetGuidance
(
" detector control."
);
61
62
fDetDir
=
new
G4UIdirectory
(
"/testem/det/"
);
63
fDetDir
->
SetGuidance
(
"detector construction commands"
);
64
65
fMaterCmd
=
new
G4UIcmdWithAString
(
"/testem/det/setMat"
,
this
);
66
fMaterCmd
->
SetGuidance
(
"Select material of the box."
);
67
fMaterCmd
->
SetParameterName
(
"choice"
,
false
);
68
fMaterCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
69
70
fWMaterCmd
=
new
G4UIcmdWithAString
(
"/testem/det/setWorldMat"
,
this
);
71
fWMaterCmd
->
SetGuidance
(
"Select material of the world."
);
72
fWMaterCmd
->
SetParameterName
(
"choice"
,
false
);
73
fWMaterCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
74
75
fSizeXCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/testem/det/setSizeX"
,
this
);
76
fSizeXCmd
->
SetGuidance
(
"Set sizeX of the absorber"
);
77
fSizeXCmd
->
SetParameterName
(
"SizeX"
,
false
);
78
fSizeXCmd
->
SetRange
(
"SizeX>0."
);
79
fSizeXCmd
->
SetUnitCategory
(
"Length"
);
80
fSizeXCmd
->
AvailableForStates
(
G4State_PreInit
);
81
82
fSizeYZCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/testem/det/setSizeYZ"
,
this
);
83
fSizeYZCmd
->
SetGuidance
(
"Set sizeYZ of the absorber"
);
84
fSizeYZCmd
->
SetParameterName
(
"SizeYZ"
,
false
);
85
fSizeYZCmd
->
SetRange
(
"SizeYZ>0."
);
86
fSizeYZCmd
->
SetUnitCategory
(
"Length"
);
87
fSizeYZCmd
->
AvailableForStates
(
G4State_PreInit
);
88
89
fMagFieldCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/testem/det/setField"
,
this
);
90
fMagFieldCmd
->
SetGuidance
(
"Define magnetic field."
);
91
fMagFieldCmd
->
SetGuidance
(
"Magnetic field will be in Z direction."
);
92
fMagFieldCmd
->
SetParameterName
(
"Bz"
,
false
);
93
fMagFieldCmd
->
SetUnitCategory
(
"Magnetic flux density"
);
94
fMagFieldCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
95
96
fTalNbCmd
=
new
G4UIcmdWithAnInteger
(
"/testem/det/tallyNumber"
,
this
);
97
fTalNbCmd
->
SetGuidance
(
"Set number of fTallies."
);
98
fTalNbCmd
->
SetParameterName
(
"tallyNb"
,
false
);
99
fTalNbCmd
->
SetRange
(
"tallyNb>=0"
);
100
fTalNbCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
101
102
fTalDefCmd
=
new
G4UIcommand
(
"/testem/det/tallyDefinition"
,
this
);
103
fTalDefCmd
->
SetGuidance
(
"Set tally nb, box dimensions."
);
104
fTalDefCmd
->
SetGuidance
(
" tally number : from 0 to tallyNumber"
);
105
fTalDefCmd
->
SetGuidance
(
" material name"
);
106
fTalDefCmd
->
SetGuidance
(
" dimensions (3-vector with unit)"
);
107
//
108
G4UIparameter
* fTalNbPrm =
new
G4UIparameter
(
"tallyNb"
,
'i'
,
false
);
109
fTalNbPrm->
SetGuidance
(
"tally number : from 0 to tallyNumber"
);
110
fTalNbPrm->
SetParameterRange
(
"tallyNb>=0"
);
111
fTalDefCmd
->
SetParameter
(fTalNbPrm);
112
//
113
G4UIparameter
* SizeXPrm =
new
G4UIparameter
(
"sizeX"
,
'd'
,
false
);
114
SizeXPrm->
SetGuidance
(
"sizeX"
);
115
SizeXPrm->
SetParameterRange
(
"sizeX>0."
);
116
fTalDefCmd
->
SetParameter
(SizeXPrm);
117
//
118
G4UIparameter
* SizeYPrm =
new
G4UIparameter
(
"sizeY"
,
'd'
,
false
);
119
SizeYPrm->
SetGuidance
(
"sizeY"
);
120
SizeYPrm->
SetParameterRange
(
"sizeY>0."
);
121
fTalDefCmd
->
SetParameter
(SizeYPrm);
122
//
123
G4UIparameter
* SizeZPrm =
new
G4UIparameter
(
"sizeZ"
,
'd'
,
false
);
124
SizeZPrm->
SetGuidance
(
"sizeZ"
);
125
SizeZPrm->
SetParameterRange
(
"sizeZ>0."
);
126
fTalDefCmd
->
SetParameter
(SizeZPrm);
127
//
128
G4UIparameter
* unitPrm =
new
G4UIparameter
(
"unit"
,
's'
,
false
);
129
unitPrm->
SetGuidance
(
"unit of dimensions"
);
130
G4String
unitList =
G4UIcommand::UnitsList
(
G4UIcommand::CategoryOf
(
"mm"
));
131
unitPrm->
SetParameterCandidates
(unitList);
132
fTalDefCmd
->
SetParameter
(unitPrm);
133
//
134
fTalDefCmd
->
AvailableForStates
(
G4State_PreInit
);
135
136
fTalPosiCmd
=
new
G4UIcommand
(
"/testem/det/tallyPosition"
,
this
);
137
fTalPosiCmd
->
SetGuidance
(
"Set tally nb, position"
);
138
fTalPosiCmd
->
SetGuidance
(
" tally number : from 0 to tallyNumber"
);
139
fTalPosiCmd
->
SetGuidance
(
" position (3-vector with unit)"
);
140
//
141
G4UIparameter
* fTalNumPrm =
new
G4UIparameter
(
"tallyNum"
,
'i'
,
false
);
142
fTalNumPrm->
SetGuidance
(
"tally number : from 0 to tallyNumber"
);
143
fTalNumPrm->
SetParameterRange
(
"tallyNum>=0"
);
144
fTalPosiCmd
->
SetParameter
(fTalNumPrm);
145
//
146
G4UIparameter
* PosiXPrm =
new
G4UIparameter
(
"posiX"
,
'd'
,
false
);
147
PosiXPrm->
SetGuidance
(
"position X"
);
148
fTalPosiCmd
->
SetParameter
(PosiXPrm);
149
//
150
G4UIparameter
* PosiYPrm =
new
G4UIparameter
(
"posiY"
,
'd'
,
false
);
151
PosiYPrm->
SetGuidance
(
"position Y"
);
152
fTalPosiCmd
->
SetParameter
(PosiYPrm);
153
//
154
G4UIparameter
* PosiZPrm =
new
G4UIparameter
(
"posiZ"
,
'd'
,
false
);
155
PosiZPrm->
SetGuidance
(
"position Z"
);
156
fTalPosiCmd
->
SetParameter
(PosiZPrm);
157
//
158
G4UIparameter
* unitPr =
new
G4UIparameter
(
"unit"
,
's'
,
false
);
159
unitPr->
SetGuidance
(
"unit of position"
);
160
unitPr->
SetParameterCandidates
(unitList);
161
fTalPosiCmd
->
SetParameter
(unitPr);
162
//
163
fTalPosiCmd
->
AvailableForStates
(
G4State_PreInit
);
164
165
}
166
167
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
169
DetectorMessenger::~DetectorMessenger
()
170
{
171
delete
fMaterCmd
;
172
delete
fWMaterCmd
;
173
delete
fSizeXCmd
;
174
delete
fSizeYZCmd
;
175
delete
fMagFieldCmd
;
176
delete
fTalNbCmd
;
177
delete
fTalDefCmd
;
178
delete
fTalPosiCmd
;
179
delete
fDetDir
;
180
delete
fTestemDir
;
181
}
182
183
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184
185
void
DetectorMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
186
{
187
if
( command ==
fMaterCmd
)
188
{
fDetector
->
SetMaterial
(newValue);}
189
190
if
( command ==
fWMaterCmd
)
191
{
fDetector
->
SetWorldMaterial
(newValue);}
192
193
if
( command ==
fSizeXCmd
)
194
{
fDetector
->
SetSizeX
(
fSizeXCmd
->
GetNewDoubleValue
(newValue));}
195
196
if
( command ==
fSizeYZCmd
)
197
{
fDetector
->
SetSizeYZ
(
fSizeYZCmd
->
GetNewDoubleValue
(newValue));}
198
199
if
( command ==
fMagFieldCmd
)
200
{
fDetector
->
SetMagField
(
fMagFieldCmd
->
GetNewDoubleValue
(newValue));}
201
202
if
( command ==
fTalNbCmd
)
203
{
fDetector
->
SetTallyNumber
(
fTalNbCmd
->
GetNewIntValue
(newValue));}
204
205
if
(command ==
fTalDefCmd
)
206
{
207
G4int
num
;
G4double
v1
,
v2
,
v3
;
208
G4String
unt;
209
std::istringstream is(newValue);
210
is >> num >> v1 >> v2 >> v3 >> unt;
211
G4ThreeVector
vec(v1,v2,v3);
212
vec *=
G4UIcommand::ValueOf
(unt);
213
fDetector
->
SetTallySize
(num,vec);
214
}
215
216
if
(command ==
fTalPosiCmd
)
217
{
218
G4int
num
;
G4double
v1
,
v2
,
v3
;
219
G4String
unt;
220
std::istringstream is(newValue);
221
is >> num >> v1 >> v2 >> v3 >> unt;
222
G4ThreeVector
vec(v1,v2,v3);
223
vec *=
G4UIcommand::ValueOf
(unt);
224
fDetector
->
SetTallyPosition
(num,vec);
225
}
226
}
227
228
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
electromagnetic
TestEm7
src
DetectorMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:50
using
1.8.2 with
ECCE GitHub integration