Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4RegionsMessenger.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 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 "TG4RegionsMessenger.h"
16#include "TG4Globals.h"
17#include "TG4RegionsManager.h"
18#include "TG4RegionsManager2.h"
19
20#include <G4UIcmdWithABool.hh>
21#include <G4UIcmdWithADouble.hh>
22#include <G4UIcmdWithAString.hh>
23#include <G4UIcmdWithAnInteger.hh>
24#include <G4UIdirectory.hh>
25
26//_____________________________________________________________________________
28 : fRegionsManager(regionsManager)
29{
31
33}
34
35//_____________________________________________________________________________
37 : fRegionsManager2(regionsManager)
38{
40
42}
43
44//_____________________________________________________________________________
46{
48
49 delete fDirectory;
50 delete fSetCheckCmd;
51 delete fSetPrintCmd;
52 delete fSetSaveCmd;
53 delete fSetFileNameCmd;
54 delete fDumpRegionCmd;
57 delete fApplyForGammaCmd;
60 delete fApplyForProtonCmd;
61 delete fSetLoadCmd;
62 delete fSetFromG4TableCmd;
63}
64
65//
66// private methods
67//
68
69//_____________________________________________________________________________
71{
73
74 fDirectory = new G4UIdirectory("/mcRegions/");
75 fDirectory->SetGuidance("TGeant4 regions commands.");
76
77 fSetCheckCmd = new G4UIcmdWithABool("/mcRegions/check", this);
78 fSetCheckCmd->SetGuidance(
79 "Switch on|off check if region properties are consistent");
80 fSetCheckCmd->SetGuidance("with energy cuts defined in limits");
81 fSetCheckCmd->SetParameterName("IsCheck", false);
82 fSetCheckCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle, G4State_EventProc);
83
84 fSetPrintCmd = new G4UIcmdWithABool("/mcRegions/print", this);
85 fSetPrintCmd->SetGuidance("Switch on|off printing of all regions properties");
86 fSetPrintCmd->SetParameterName("IsPrint", false);
87 fSetPrintCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle, G4State_EventProc);
88
89 fSetSaveCmd = new G4UIcmdWithABool("/mcRegions/save", this);
90 fSetSaveCmd->SetGuidance("Switch on|off saving of all regions properties in a file");
91 fSetSaveCmd->SetParameterName("IsSave", false);
92 fSetSaveCmd->AvailableForStates(G4State_PreInit, G4State_Init);
93
94 fSetFileNameCmd = new G4UIcmdWithAString("/mcRegions/setFileName", this);
95 fSetFileNameCmd->SetGuidance("Set file name for the regions output");
96 fSetFileNameCmd->SetParameterName("FileName", false);
97 fSetFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Init);
98
100 new G4UIcmdWithAnInteger("/mcRegions/setRangePrecision", this);
101 fSetRangePrecisionCmd->SetGuidance(
102 "Set the precision for calculating ranges");
103 fSetRangePrecisionCmd->SetParameterName("RangePrecision", false);
104 fSetRangePrecisionCmd->AvailableForStates(G4State_PreInit, G4State_Init);
105
106 fApplyForGammaCmd = new G4UIcmdWithABool("/mcRegions/applyForGamma", this);
107 fApplyForGammaCmd->SetGuidance("Switch on|off applying range cuts for gamma");
108 fApplyForGammaCmd->SetParameterName("ApplyForGamma", false);
109 fApplyForGammaCmd->AvailableForStates(G4State_PreInit, G4State_Init);
110
112 new G4UIcmdWithABool("/mcRegions/applyForElectron", this);
113 fApplyForElectronCmd->SetGuidance("Switch on|off applying range cuts for e-");
114 fApplyForElectronCmd->SetParameterName("ApplyForElectron", false);
115 fApplyForElectronCmd->AvailableForStates(G4State_PreInit, G4State_Init);
116
118 new G4UIcmdWithABool("/mcRegions/applyForPositron", this);
119 fApplyForPositronCmd->SetGuidance("Switch on|off applying range cuts for e+");
120 fApplyForPositronCmd->SetParameterName("ApplyForPositron", false);
121 fApplyForPositronCmd->AvailableForStates(G4State_PreInit, G4State_Init);
122
123 fApplyForProtonCmd = new G4UIcmdWithABool("/mcRegions/applyForProton", this);
124 fApplyForProtonCmd->SetGuidance(
125 "Switch on|off applying range cuts for protons");
126 fApplyForProtonCmd->SetParameterName("ApplyForProton", false);
127 fApplyForProtonCmd->AvailableForStates(G4State_PreInit, G4State_Init);
128
129 if (fRegionsManager != nullptr) {
130 // commands working only with old regions manager
131 fDumpRegionCmd = new G4UIcmdWithAString("/mcRegions/dumpRegion", this);
132 fDumpRegionCmd->SetGuidance("Dump characteristics of region ");
133 fDumpRegionCmd->SetParameterName("LVname", false);
134 fDumpRegionCmd->SetDefaultValue(" ");
135 fDumpRegionCmd->AvailableForStates(G4State_Idle, G4State_EventProc);
136
138 new G4UIcmdWithADouble("/mcRegions/setEnergyTolerance", this);
139 fSetEnergyToleranceCmd->SetGuidance(
140 "Set the tolerance (relative) for comparing energy cut values");
141 fSetEnergyToleranceCmd->SetParameterName("EnergyTolerance", false);
142 fSetEnergyToleranceCmd->AvailableForStates(G4State_PreInit, G4State_Init);
143
144 fSetLoadCmd = new G4UIcmdWithABool("/mcRegions/load", this);
145 fSetLoadCmd->SetGuidance("Switch on|off loading of all regions cuts & ranges from a file");
146 fSetLoadCmd->SetParameterName("IsLoad", false);
147 fSetLoadCmd->AvailableForStates(G4State_PreInit, G4State_Init);
148
149 fSetFromG4TableCmd = new G4UIcmdWithABool("/mcRegions/fromG4Table", this);
150 fSetFromG4TableCmd->SetGuidance("Switch on|off printing or saving regions properties\n"
151 "from production cuts table.\n"
152 "Must be called before \"print\" or \"save\" command.");
153 fSetFromG4TableCmd->SetParameterName("IsFromG4Table", false);
154 fSetFromG4TableCmd->AvailableForStates(G4State_PreInit, G4State_Init);
155 }
156}
157
158//
159// public methods
160//
161
162//_____________________________________________________________________________
163void TG4RegionsMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
164{
166
167 if (fRegionsManager2 != nullptr) {
168 if (command == fApplyForGammaCmd) {
170 fApplyForGammaCmd->GetNewBoolValue(newValue));
171 return;
172 }
173 if (command == fApplyForElectronCmd) {
175 fApplyForElectronCmd->GetNewBoolValue(newValue));
176 return;
177 }
178 if (command == fApplyForPositronCmd) {
180 fApplyForPositronCmd->GetNewBoolValue(newValue));
181 return;
182 }
183 if (command == fApplyForProtonCmd) {
185 fApplyForProtonCmd->GetNewBoolValue(newValue));
186 return;
187 }
188 if (command == fSetCheckCmd) {
189 fRegionsManager2->SetCheck(fSetCheckCmd->GetNewBoolValue(newValue));
190 return;
191 }
192 if (command == fSetPrintCmd) {
193 fRegionsManager2->SetPrint(fSetPrintCmd->GetNewBoolValue(newValue));
194 return;
195 }
196 if (command == fSetSaveCmd) {
197 fRegionsManager2->SetSave(fSetSaveCmd->GetNewBoolValue(newValue));
198 return;
199 }
200 if (command == fSetFileNameCmd) {
201 fRegionsManager2->SetFileName(newValue);
202 return;
203 }
204 if (command == fSetRangePrecisionCmd) {
205 TG4Globals::Warning("TG4RegionsMessenger", "SetNewValue",
206 "/mcRegions/setRangePrecision has no effect"
207 " when production cuts are set by energy.");
208 return;
209 }
210 }
211
212 if (fRegionsManager != nullptr) {
213 if (command == fSetCheckCmd) {
214 fRegionsManager-> SetCheck(fSetCheckCmd->GetNewBoolValue(newValue));
215 return;
216 }
217 if (command == fSetPrintCmd) {
218 fRegionsManager->SetPrint(fSetPrintCmd->GetNewBoolValue(newValue));
219 return;
220 }
221 if (command == fSetSaveCmd) {
222 fRegionsManager->SetSave(fSetSaveCmd->GetNewBoolValue(newValue));
223 return;
224 }
225 if (command == fSetFileNameCmd) {
226 fRegionsManager->SetFileName(newValue);
227 return;
228 }
229 if (command == fDumpRegionCmd) {
230 fRegionsManager-> DumpRegion(newValue);
231 return;
232 }
233 if (command == fSetRangePrecisionCmd) {
235 fSetRangePrecisionCmd->GetNewIntValue(newValue));
236 return;
237 }
238 if (command == fSetEnergyToleranceCmd) {
240 fSetEnergyToleranceCmd->GetNewDoubleValue(newValue));
241 return;
242 }
243 if (command == fApplyForGammaCmd) {
245 fApplyForGammaCmd->GetNewBoolValue(newValue));
246 return;
247 }
248 if (command == fApplyForElectronCmd) {
250 fApplyForElectronCmd->GetNewBoolValue(newValue));
251 return;
252 }
253 if (command == fApplyForPositronCmd) {
255 fApplyForPositronCmd->GetNewBoolValue(newValue));
256 return;
257 }
258 if (command == fApplyForProtonCmd) {
260 fApplyForProtonCmd->GetNewBoolValue(newValue));
261 return;
262 }
263 if (command == fSetLoadCmd) {
264 fRegionsManager->SetLoad(fSetLoadCmd->GetNewBoolValue(newValue));
265 return;
266 }
267 if (command == fSetFromG4TableCmd) {
269 fSetFromG4TableCmd->GetNewBoolValue(newValue));
270 return;
271 }
272 if (command == fSetFileNameCmd) {
273 fRegionsManager->SetFileName(newValue);
274 }
275 }
276}
Definition of the TG4Globals class and basic container types.
Definition of the TG4RegionsManager2 class.
Definition of the TG4RegionsManager class.
Definition of the TG4RegionsMessenger class.
static void Warning(const TString &className, const TString &methodName, const TString &text)
Manager class for setting VMC cuts in energy in G4 regions.
Manager class for converting VMC cuts in energy in G4 regions.
void SetLoad(G4bool isLoad)
void SetEnergyTolerance(G4double tolerance)
Set the tolerance (relative) for comparing energy cut values.
void SetFromG4Table(G4bool isG4Table)
Set the option to print/save cuts from G4 table.
void SetRangePrecision(G4int precision)
Set the precision for calculating ranges.
G4UIcmdWithAString * fSetFileNameCmd
command: /mcRegions/setFileName fileName
TG4RegionsManager * fRegionsManager
associated class
G4UIcmdWithABool * fApplyForPositronCmd
command: /mcRegions/applyForPositron true|false
G4UIcmdWithADouble * fSetEnergyToleranceCmd
command: /mcRegions/setEnergyTolerance value
G4UIcmdWithABool * fSetPrintCmd
command: /mcRegions/print [true|false]
G4UIcmdWithAnInteger * fSetRangePrecisionCmd
command: /mcRegions/setRangePrecision value
G4UIcmdWithAString * fDumpRegionCmd
command: /mcRegions/dump [lvName]
G4UIdirectory * fDirectory
command directory
G4UIcmdWithABool * fApplyForElectronCmd
command: /mcRegions/applyForElectron true|false
G4UIcmdWithABool * fSetSaveCmd
command: /mcRegions/save [true|false]
G4UIcmdWithABool * fApplyForProtonCmd
command: /mcRegions/applyForProton true|false
TG4RegionsMessenger()=delete
G4UIcmdWithABool * fApplyForGammaCmd
command: /mcRegions/applyForGamma true|false
G4UIcmdWithABool * fSetLoadCmd
command: /mcRegions/load [true|false]
TG4RegionsManager2 * fRegionsManager2
associated class
virtual void SetNewValue(G4UIcommand *command, G4String string)
G4UIcmdWithABool * fSetFromG4TableCmd
command: /mcRegions/fromG4Table [true|false]
G4UIcmdWithABool * fSetCheckCmd
command: /mcRegions/check [true|false]
void SetPrint(G4bool isPrint)
Set the option to print all regions.
void SetApplyForGamma(G4bool applyForGamma)
Set the option to apply range cuts for gamma (default is true)
void SetApplyForPositron(G4bool applyForPositron)
Set the option to apply range cuts for e+ (default is true)
void SetApplyForProton(G4bool applyForProton)
Set the option to apply range cuts for proton (default is true)
void SetCheck(G4bool isCheck)
Set the option to perform consistency check (by default false)
void SetFileName(const G4String &fileName)
Set the file name for regions output.
void SetApplyForElectron(G4bool applyForElectron)
Set the option to apply range cuts for e- (default is true)
void SetSave(G4bool isSave)
Set the option to save all regions in a file.