Geant4 VMC Version 6.7
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
17
18#include <G4UIcmdWithAString.hh>
19#include <G4UIdirectory.hh>
20
21#include <locale>
22
23//
24// utility methods
25//
26
27namespace
28{
29
30//______________________________________________________________________________
31G4String 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//______________________________________________________________________________
48 TG4ModelConfigurationManager* manager, const G4String& availableModels)
49 : G4UImessenger(),
52 fDirectory(0),
53 fSetModelCmd(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//______________________________________________________________________________
140
141//
142// public methods
143//
144
145//______________________________________________________________________________
147 G4UIcommand* command, G4String newValue)
148{
150
151 if (command == fSetModelCmd || command == fSetEmModelCmd) {
152 fSelectedModel = newValue;
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}
Definition of the TG4ModelConfigurationManager class.
Definition of the TG4ModelConfigurationMessenger class.
The model configuration vector with suitable setters and a messenger.
G4UIcmdWithAString * fSetModelCmd
setModel command
virtual void SetNewValue(G4UIcommand *command, G4String string)
G4UIcmdWithAString * fSetParticlesCmd
setParticles command
TG4ModelConfigurationMessenger()
Not implemented.
TG4ModelConfigurationManager * fModelConfigurationManager
associated class
G4UIcmdWithAString * fSetRegionsCmd
setRegions command
G4UIcmdWithAString * fSetEmModelCmd
setEmModel command (deprecated)
G4UIdirectory * fDirectory
command directory
G4UIcmdWithAString * fSetOneRegionCmd
setRegion command
G4UIcmdWithAString * fSetExcludedParticlesCmd
setExcludedParticles command