Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
TG4ModelConfigurationMessenger.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Geant4 Virtual Monte Carlo package
3
// Copyright (C) 2007 - 2015 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
14
15
#include "
TG4ModelConfigurationMessenger.h
"
16
#include "
TG4ModelConfigurationManager.h
"
17
18
#include <G4UIcmdWithAString.hh>
19
#include <G4UIdirectory.hh>
20
21
#include <locale>
22
23
//
24
// utility methods
25
//
26
27
namespace
28
{
29
30
//______________________________________________________________________________
31
G4String GetDirectoryName(
const
G4String& baseName)
32
{
33
std::string name(baseName);
34
// convert first letter to lower case
35
std::locale loc;
36
name.replace(0, 1, 1, std::tolower(name[0], loc));
37
return
"/mcPhysics/"
+ name +
"/"
;
38
}
39
40
}
// namespace
41
42
//
43
// ctors, dtor
44
//
45
46
//______________________________________________________________________________
47
TG4ModelConfigurationMessenger::TG4ModelConfigurationMessenger
(
48
TG4ModelConfigurationManager
* manager,
const
G4String& availableModels)
49
:
G4UImessenger
(),
50
fModelConfigurationManager
(manager),
51
fSelectedModel
(),
52
fDirectory
(0),
53
fSetModelCmd
(0),
54
fSetParticlesCmd
(0),
55
fSetExcludedParticlesCmd
(0),
56
fSetRegionsCmd
(0)
57
{
59
60
G4String physicsName =
fModelConfigurationManager
->GetName();
61
62
// Create directory with a name according to modelConfiguration name
63
G4String dirName = GetDirectoryName(physicsName);
64
fDirectory
=
new
G4UIdirectory(dirName);
65
G4String guidance = physicsName +
" physics commands."
;
66
fDirectory
->SetGuidance(guidance);
67
68
// setModel command
69
G4String commandName = dirName +
"setModel"
;
70
fSetModelCmd
=
new
G4UIcmdWithAString(commandName,
this
);
71
guidance =
"Define an extra "
+ physicsName;
72
fSetModelCmd
->SetGuidance(guidance);
73
fSetModelCmd
->SetParameterName(
"Model"
,
false
);
74
if
(availableModels.size())
fSetModelCmd
->SetCandidates(availableModels);
75
fSetModelCmd
->AvailableForStates(G4State_PreInit);
76
77
// setEmModel command = the same as setModel
78
// deprecated - kept for backward compatibility
79
commandName = dirName +
"setEmModel"
;
80
fSetEmModelCmd
=
new
G4UIcmdWithAString(commandName,
this
);
81
guidance =
"The same as setModel, kept for backward compatibility."
;
82
fSetEmModelCmd
->SetGuidance(guidance);
83
fSetEmModelCmd
->SetParameterName(
"EmModel"
,
false
);
84
if
(availableModels.size())
fSetEmModelCmd
->SetCandidates(availableModels);
85
fSetEmModelCmd
->AvailableForStates(G4State_PreInit);
86
87
// setParticles command
88
commandName = dirName +
"setParticles"
;
89
fSetParticlesCmd
=
new
G4UIcmdWithAString(commandName,
this
);
90
guidance =
"Set particles for the selected extra "
+ physicsName +
"\n"
+
91
"(all = select all particles which the model is applicable.)"
;
92
fSetParticlesCmd
->SetGuidance(guidance.c_str());
93
fSetParticlesCmd
->SetParameterName(
"Particles"
,
false
);
94
fSetParticlesCmd
->AvailableForStates(G4State_PreInit);
95
96
// setExcludedParticles command
97
commandName = dirName +
"setExcludedParticles"
;
98
fSetExcludedParticlesCmd
=
new
G4UIcmdWithAString(commandName,
this
);
99
guidance =
"Set to be excluded from the selected extra "
+ physicsName +
"\n"
+
100
"if 'all' was selected previously "
;
101
fSetExcludedParticlesCmd
->SetGuidance(guidance.c_str());
102
fSetExcludedParticlesCmd
->SetParameterName(
"Particles"
,
false
);
103
fSetExcludedParticlesCmd
->AvailableForStates(G4State_PreInit);
104
105
// setRegions command
106
commandName = dirName +
"setRegions"
;
107
fSetRegionsCmd
=
new
G4UIcmdWithAString(commandName,
this
);
108
guidance =
"Set tracking media names (regions) for the selected extra "
+
109
physicsName +
"\n"
+
110
"("
111
" = the model will be applied to the default world region."
;
112
fSetRegionsCmd
->SetGuidance(guidance);
113
fSetRegionsCmd
->SetParameterName(
"Regions"
,
false
);
114
fSetRegionsCmd
->AvailableForStates(G4State_PreInit);
115
116
// setOneRegion command
117
commandName = dirName +
"setOneRegion"
;
118
fSetOneRegionCmd
=
new
G4UIcmdWithAString(commandName,
this
);
119
guidance =
"Set one tracking medium name (regions) for the selected extra "
+
120
physicsName +
"\n"
+
121
"("
122
" = the model will be applied to the default world region."
;
123
fSetOneRegionCmd
->SetGuidance(guidance);
124
fSetOneRegionCmd
->SetParameterName(
"Region"
,
false
);
125
fSetOneRegionCmd
->AvailableForStates(G4State_PreInit);
126
}
127
128
//______________________________________________________________________________
129
TG4ModelConfigurationMessenger::~TG4ModelConfigurationMessenger
()
130
{
132
delete
fDirectory
;
133
delete
fSetModelCmd
;
134
delete
fSetEmModelCmd
;
135
delete
fSetParticlesCmd
;
136
delete
fSetExcludedParticlesCmd
;
137
delete
fSetRegionsCmd
;
138
delete
fSetOneRegionCmd
;
139
}
140
141
//
142
// public methods
143
//
144
145
//______________________________________________________________________________
146
void
TG4ModelConfigurationMessenger::SetNewValue
(
147
G4UIcommand
* command, G4String newValue)
148
{
150
151
if
(command ==
fSetModelCmd
|| command ==
fSetEmModelCmd
) {
152
fSelectedModel
= newValue;
153
fModelConfigurationManager
->SetModel(
fSelectedModel
);
154
}
155
else
if
(command ==
fSetParticlesCmd
) {
156
fModelConfigurationManager
->SetModelParticles(
fSelectedModel
, newValue);
157
}
158
else
if
(command ==
fSetExcludedParticlesCmd
) {
159
fModelConfigurationManager
->SetModelExcludedParticles(
fSelectedModel
, newValue);
160
}
161
else
if
(command ==
fSetRegionsCmd
) {
162
fModelConfigurationManager
->SetModelRegions(
fSelectedModel
, newValue);
163
}
164
else
if
(command ==
fSetOneRegionCmd
) {
165
fModelConfigurationManager
->SetOneModelRegion(
fSelectedModel
, newValue);
166
}
167
}
TG4ModelConfigurationManager.h
Definition of the TG4ModelConfigurationManager class.
TG4ModelConfigurationMessenger.h
Definition of the TG4ModelConfigurationMessenger class.
G4UIcommand
G4UImessenger
TG4ModelConfigurationManager
The model configuration vector with suitable setters and a messenger.
Definition
TG4ModelConfigurationManager.h:33
TG4ModelConfigurationMessenger::fSetModelCmd
G4UIcmdWithAString * fSetModelCmd
setModel command
Definition
TG4ModelConfigurationMessenger.h:73
TG4ModelConfigurationMessenger::SetNewValue
virtual void SetNewValue(G4UIcommand *command, G4String string)
Definition
TG4ModelConfigurationMessenger.cxx:146
TG4ModelConfigurationMessenger::fSetParticlesCmd
G4UIcmdWithAString * fSetParticlesCmd
setParticles command
Definition
TG4ModelConfigurationMessenger.h:79
TG4ModelConfigurationMessenger::~TG4ModelConfigurationMessenger
virtual ~TG4ModelConfigurationMessenger()
Definition
TG4ModelConfigurationMessenger.cxx:129
TG4ModelConfigurationMessenger::TG4ModelConfigurationMessenger
TG4ModelConfigurationMessenger()
Not implemented.
TG4ModelConfigurationMessenger::fModelConfigurationManager
TG4ModelConfigurationManager * fModelConfigurationManager
associated class
Definition
TG4ModelConfigurationMessenger.h:64
TG4ModelConfigurationMessenger::fSetRegionsCmd
G4UIcmdWithAString * fSetRegionsCmd
setRegions command
Definition
TG4ModelConfigurationMessenger.h:85
TG4ModelConfigurationMessenger::fSelectedModel
G4String fSelectedModel
current model name
Definition
TG4ModelConfigurationMessenger.h:67
TG4ModelConfigurationMessenger::fSetEmModelCmd
G4UIcmdWithAString * fSetEmModelCmd
setEmModel command (deprecated)
Definition
TG4ModelConfigurationMessenger.h:76
TG4ModelConfigurationMessenger::fDirectory
G4UIdirectory * fDirectory
command directory
Definition
TG4ModelConfigurationMessenger.h:70
TG4ModelConfigurationMessenger::fSetOneRegionCmd
G4UIcmdWithAString * fSetOneRegionCmd
setRegion command
Definition
TG4ModelConfigurationMessenger.h:88
TG4ModelConfigurationMessenger::fSetExcludedParticlesCmd
G4UIcmdWithAString * fSetExcludedParticlesCmd
setExcludedParticles command
Definition
TG4ModelConfigurationMessenger.h:82
Generated on
for Geant4 VMC by
1.17.0