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 "
G4UIcmdWithADoubleAndUnit.hh
"
41
#include "
G4UIcmdWithoutParameter.hh
"
42
43
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45
DetectorMessenger::DetectorMessenger
(
DetectorConstruction
* Det)
46
:
G4UImessenger
(),
47
fDetector(Det), fTesthadrDir(0), fDetDir(0), fMaterCmd1(0), fMaterCmd2(0),
48
fSizeCmd1(0), fSizeCmd2(0), fSizeCmd3(0),
49
fIsotopeCmd(0)
50
{
51
fTesthadrDir
=
new
G4UIdirectory
(
"/testhadr/"
);
52
fTesthadrDir
->
SetGuidance
(
"commands specific to this example"
);
53
54
G4bool
broadcast =
false
;
55
fDetDir
=
new
G4UIdirectory
(
"/testhadr/det/"
,broadcast);
56
fDetDir
->
SetGuidance
(
"detector construction commands"
);
57
58
fMaterCmd1
=
new
G4UIcmdWithAString
(
"/testhadr/det/setAbsorMat"
,
this
);
59
fMaterCmd1
->
SetGuidance
(
"Select absorber material"
);
60
fMaterCmd1
->
SetParameterName
(
"choice"
,
false
);
61
fMaterCmd1
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
62
63
fMaterCmd2
=
new
G4UIcmdWithAString
(
"/testhadr/det/setContMat"
,
this
);
64
fMaterCmd2
->
SetGuidance
(
"Select container material"
);
65
fMaterCmd2
->
SetParameterName
(
"choice"
,
false
);
66
fMaterCmd2
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
67
68
fSizeCmd1
=
new
G4UIcmdWithADoubleAndUnit
(
"/testhadr/det/setAbsorRadius"
,
this
);
69
fSizeCmd1
->
SetGuidance
(
"Set absorber radius"
);
70
fSizeCmd1
->
SetParameterName
(
"Radius"
,
false
);
71
fSizeCmd1
->
SetRange
(
"Radius>0."
);
72
fSizeCmd1
->
SetUnitCategory
(
"Length"
);
73
fSizeCmd1
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
74
75
fSizeCmd2
=
new
G4UIcmdWithADoubleAndUnit
(
"/testhadr/det/setAbsorLength"
,
this
);
76
fSizeCmd2
->
SetGuidance
(
"Set absorber length"
);
77
fSizeCmd2
->
SetParameterName
(
"Length"
,
false
);
78
fSizeCmd2
->
SetRange
(
"Length>0."
);
79
fSizeCmd2
->
SetUnitCategory
(
"Length"
);
80
fSizeCmd2
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
81
82
fSizeCmd3
=
new
G4UIcmdWithADoubleAndUnit
(
"/testhadr/det/setContThick"
,
this
);
83
fSizeCmd3
->
SetGuidance
(
"Set container thickness"
);
84
fSizeCmd3
->
SetParameterName
(
"Thick"
,
false
);
85
fSizeCmd3
->
SetRange
(
"Thick>0."
);
86
fSizeCmd3
->
SetUnitCategory
(
"Length"
);
87
fSizeCmd3
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
88
89
fIsotopeCmd
=
new
G4UIcommand
(
"/testhadr/det/setIsotopeMat"
,
this
);
90
fIsotopeCmd
->
SetGuidance
(
"Build and select a material with single isotope"
);
91
fIsotopeCmd
->
SetGuidance
(
" symbol of isotope, Z, A, density of material"
);
92
//
93
G4UIparameter
* symbPrm =
new
G4UIparameter
(
"isotope"
,
's'
,
false
);
94
symbPrm->
SetGuidance
(
"isotope symbol"
);
95
fIsotopeCmd
->
SetParameter
(symbPrm);
96
//
97
G4UIparameter
* ZPrm =
new
G4UIparameter
(
"Z"
,
'i'
,
false
);
98
ZPrm->
SetGuidance
(
"Z"
);
99
ZPrm->
SetParameterRange
(
"Z>0"
);
100
fIsotopeCmd
->
SetParameter
(ZPrm);
101
//
102
G4UIparameter
* APrm =
new
G4UIparameter
(
"A"
,
'i'
,
false
);
103
APrm->
SetGuidance
(
"A"
);
104
APrm->
SetParameterRange
(
"A>0"
);
105
fIsotopeCmd
->
SetParameter
(APrm);
106
//
107
G4UIparameter
* densityPrm =
new
G4UIparameter
(
"density"
,
'd'
,
false
);
108
densityPrm->
SetGuidance
(
"density of material"
);
109
densityPrm->
SetParameterRange
(
"density>0."
);
110
fIsotopeCmd
->
SetParameter
(densityPrm);
111
//
112
G4UIparameter
* unitPrm =
new
G4UIparameter
(
"unit"
,
's'
,
false
);
113
unitPrm->
SetGuidance
(
"unit of density"
);
114
G4String
unitList =
G4UIcommand::UnitsList
(
G4UIcommand::CategoryOf
(
"g/cm3"
));
115
unitPrm->
SetParameterCandidates
(unitList);
116
fIsotopeCmd
->
SetParameter
(unitPrm);
117
//
118
fIsotopeCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
119
}
120
121
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122
123
DetectorMessenger::~DetectorMessenger
()
124
{
125
delete
fMaterCmd1
;
126
delete
fMaterCmd2
;
127
delete
fSizeCmd1
;
128
delete
fSizeCmd2
;
129
delete
fSizeCmd3
;
130
delete
fIsotopeCmd
;
131
delete
fDetDir
;
132
delete
fTesthadrDir
;
133
}
134
135
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136
137
void
DetectorMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
138
{
139
if
( command ==
fMaterCmd1
)
140
{
fDetector
->
SetAbsorMaterial
(newValue);}
141
if
( command ==
fMaterCmd2
)
142
{
fDetector
->
SetContainMaterial
(newValue);}
143
144
if
( command ==
fSizeCmd1
)
145
{
fDetector
->
SetAbsorRadius
(
fSizeCmd1
->
GetNewDoubleValue
(newValue));}
146
147
if
( command ==
fSizeCmd2
)
148
{
fDetector
->
SetAbsorLength
(
fSizeCmd2
->
GetNewDoubleValue
(newValue));}
149
150
if
( command ==
fSizeCmd3
)
151
{
fDetector
->
SetContainThickness
(
fSizeCmd3
->
GetNewDoubleValue
(newValue));}
152
153
if
(command ==
fIsotopeCmd
)
154
{
155
G4int
Z
;
G4int
A
;
G4double
dens;
156
G4String
name
, unt;
157
std::istringstream is(newValue);
158
is >> name >> Z >> A >> dens >> unt;
159
dens *=
G4UIcommand::ValueOf
(unt);
160
fDetector
->
MaterialWithSingleIsotope
(name,name,dens,Z,A);
161
fDetector
->
SetAbsorMaterial
(name);
162
}
163
}
164
165
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
NeutronSource
src
DetectorMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:50
using
1.8.2 with
ECCE GitHub integration