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