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), fTesthadDir(0), fDetDir(0), fMaterCmd(0), fSizeCmd(0),
48
fIsotopeCmd(0)
49
{
50
fTesthadDir
=
new
G4UIdirectory
(
"/testhadr/"
);
51
fTesthadDir
->
SetGuidance
(
"commands specific to this example"
);
52
53
fDetDir
=
new
G4UIdirectory
(
"/testhadr/det/"
);
54
fDetDir
->
SetGuidance
(
"detector construction commands"
);
55
56
fMaterCmd
=
new
G4UIcmdWithAString
(
"/testhadr/det/setMat"
,
this
);
57
fMaterCmd
->
SetGuidance
(
"Select material of the box."
);
58
fMaterCmd
->
SetParameterName
(
"choice"
,
false
);
59
fMaterCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
60
fMaterCmd
->
SetToBeBroadcasted
(
false
);
61
62
fSizeCmd
=
new
G4UIcmdWithADoubleAndUnit
(
"/testhadr/det/setSize"
,
this
);
63
fSizeCmd
->
SetGuidance
(
"Set size of the box"
);
64
fSizeCmd
->
SetParameterName
(
"Size"
,
false
);
65
fSizeCmd
->
SetRange
(
"Size>0."
);
66
fSizeCmd
->
SetUnitCategory
(
"Length"
);
67
fSizeCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
68
fSizeCmd
->
SetToBeBroadcasted
(
false
);
69
70
fIsotopeCmd
=
new
G4UIcommand
(
"/testhadr/det/setIsotopeMat"
,
this
);
71
fIsotopeCmd
->
SetGuidance
(
"Build and select a material with single isotope"
);
72
fIsotopeCmd
->
SetGuidance
(
" symbol of isotope, Z, A, density of material"
);
73
//
74
G4UIparameter
* symbPrm =
new
G4UIparameter
(
"isotope"
,
's'
,
false
);
75
symbPrm->
SetGuidance
(
"isotope symbol"
);
76
fIsotopeCmd
->
SetParameter
(symbPrm);
77
//
78
G4UIparameter
* ZPrm =
new
G4UIparameter
(
"Z"
,
'i'
,
false
);
79
ZPrm->
SetGuidance
(
"Z"
);
80
ZPrm->
SetParameterRange
(
"Z>0"
);
81
fIsotopeCmd
->
SetParameter
(ZPrm);
82
//
83
G4UIparameter
* APrm =
new
G4UIparameter
(
"A"
,
'i'
,
false
);
84
APrm->
SetGuidance
(
"A"
);
85
APrm->
SetParameterRange
(
"A>0"
);
86
fIsotopeCmd
->
SetParameter
(APrm);
87
//
88
G4UIparameter
* densityPrm =
new
G4UIparameter
(
"density"
,
'd'
,
false
);
89
densityPrm->
SetGuidance
(
"density of material"
);
90
densityPrm->
SetParameterRange
(
"density>0."
);
91
fIsotopeCmd
->
SetParameter
(densityPrm);
92
//
93
G4UIparameter
* unitPrm =
new
G4UIparameter
(
"unit"
,
's'
,
false
);
94
unitPrm->
SetGuidance
(
"unit of density"
);
95
G4String
unitList =
G4UIcommand::UnitsList
(
G4UIcommand::CategoryOf
(
"g/cm3"
));
96
unitPrm->
SetParameterCandidates
(unitList);
97
fIsotopeCmd
->
SetParameter
(unitPrm);
98
//
99
fIsotopeCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
100
fIsotopeCmd
->
SetToBeBroadcasted
(
false
);
101
}
102
103
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104
105
DetectorMessenger::~DetectorMessenger
()
106
{
107
delete
fMaterCmd
;
108
delete
fSizeCmd
;
109
delete
fIsotopeCmd
;
110
delete
fDetDir
;
111
delete
fTesthadDir
;
112
}
113
114
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115
116
void
DetectorMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
117
{
118
if
( command ==
fMaterCmd
)
119
{
fDetector
->
SetMaterial
(newValue);}
120
121
if
( command ==
fSizeCmd
)
122
{
fDetector
->
SetSize
(
fSizeCmd
->
GetNewDoubleValue
(newValue));}
123
124
if
(command ==
fIsotopeCmd
)
125
{
126
G4int
Z
;
G4int
A
;
G4double
dens;
127
G4String
name
, unt;
128
std::istringstream is(newValue);
129
is >> name >> Z >> A >> dens >> unt;
130
dens *=
G4UIcommand::ValueOf
(unt);
131
fDetector
->
MaterialWithSingleIsotope
(name,name,dens,Z,A);
132
fDetector
->
SetMaterial
(name);
133
}
134
}
135
136
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr03
src
DetectorMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:50
using
1.8.2 with
ECCE GitHub integration