Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
electromagnetic
TestEm12
src
DetectorMessenger.cc
Go to the documentation of this file.
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
// $Id$
30
//
31
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33
34
#include "DetectorMessenger.hh"
35
36
#include "DetectorConstruction.hh"
37
#include "
G4UIdirectory.hh
"
38
#include "
G4UIcmdWithAString.hh
"
39
#include "
G4UIcmdWithAnInteger.hh
"
40
#include "
G4UIcmdWithADoubleAndUnit.hh
"
41
#include "
G4UIcmdWithoutParameter.hh
"
42
43
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45
DetectorMessenger::DetectorMessenger
(
DetectorConstruction
* Det)
46
:fDetector(Det)
47
{
48
fTestemDir =
new
G4UIdirectory
(
"/testem/"
);
49
fTestemDir->
SetGuidance
(
" detector control."
);
50
51
fDetDir =
new
G4UIdirectory
(
"/testem/det/"
);
52
fDetDir->
SetGuidance
(
"detector construction commands"
);
53
54
fMaterCmd =
new
G4UIcmdWithAString
(
"/testem/det/setMat"
,
this
);
55
fMaterCmd->
SetGuidance
(
"Select material of the box."
);
56
fMaterCmd->
SetParameterName
(
"choice"
,
false
);
57
fMaterCmd->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
58
59
fRadiusCmd =
new
G4UIcmdWithADoubleAndUnit
(
"/testem/det/setRadius"
,
this
);
60
fRadiusCmd->
SetGuidance
(
"Set radius of the absorber"
);
61
fRadiusCmd->
SetParameterName
(
"Radius"
,
false
);
62
fRadiusCmd->
SetRange
(
"Radius>0."
);
63
fRadiusCmd->
SetUnitCategory
(
"Length"
);
64
fRadiusCmd->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
65
66
fNbLayersCmd =
new
G4UIcmdWithAnInteger
(
"/testem/det/setNbOfLayers"
,
this
);
67
fNbLayersCmd->
SetGuidance
(
"Set number of layers"
);
68
fNbLayersCmd->
SetParameterName
(
"NbLayers"
,
false
);
69
fNbLayersCmd->
SetRange
(
"NbLayers>0"
);
70
fNbLayersCmd->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
71
72
fMagFieldCmd =
new
G4UIcmdWithADoubleAndUnit
(
"/testem/det/setField"
,
this
);
73
fMagFieldCmd->
SetGuidance
(
"Define magnetic field."
);
74
fMagFieldCmd->
SetGuidance
(
"Magnetic field will be in Z direction."
);
75
fMagFieldCmd->
SetParameterName
(
"Bz"
,
false
);
76
fMagFieldCmd->
SetUnitCategory
(
"Magnetic flux density"
);
77
fMagFieldCmd->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
78
79
fUpdateCmd =
new
G4UIcmdWithoutParameter
(
"/testem/det/update"
,
this
);
80
fUpdateCmd->
SetGuidance
(
"Update calorimeter geometry."
);
81
fUpdateCmd->
SetGuidance
(
"This command MUST be applied before \"beamOn\" "
);
82
fUpdateCmd->
SetGuidance
(
"if you changed geometrical value(s)."
);
83
fUpdateCmd->
AvailableForStates
(
G4State_Idle
);
84
}
85
86
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87
88
DetectorMessenger::~DetectorMessenger
()
89
{
90
delete
fMaterCmd;
91
delete
fRadiusCmd;
92
delete
fNbLayersCmd;
93
delete
fMagFieldCmd;
94
delete
fUpdateCmd;
95
delete
fDetDir;
96
delete
fTestemDir;
97
}
98
99
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100
101
void
DetectorMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
102
{
103
if
( command == fMaterCmd )
104
{ fDetector->
SetMaterial
(newValue);}
105
106
if
( command == fRadiusCmd )
107
{ fDetector->
SetRadius
(fRadiusCmd->
GetNewDoubleValue
(newValue));}
108
109
if
( command == fNbLayersCmd )
110
{ fDetector->
SetNbOfLayers
(fNbLayersCmd->
GetNewIntValue
(newValue));}
111
112
if
( command == fMagFieldCmd )
113
{ fDetector->
SetMagField
(fMagFieldCmd->
GetNewDoubleValue
(newValue));}
114
115
if
( command == fUpdateCmd )
116
{ fDetector->
UpdateGeometry
();}
117
}
118
119
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Generated on Sat May 25 2013 14:31:56 for Geant4 by
1.8.4