Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4DetConstructionMessenger.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
16#include "TG4DetConstruction.h"
17#include "TG4G3Units.h"
18#include "TG4GeometryManager.h"
19#include "TG4GeometryServices.h"
20#include "TG4Globals.h"
22
23#include <G4AnalysisUtilities.hh>
24#include <G4UIcmdWithABool.hh>
25#include <G4UIcmdWithADoubleAndUnit.hh>
26#include <G4UIcmdWithAString.hh>
27#include <G4UIcmdWithoutParameter.hh>
28#include <G4UIdirectory.hh>
29
30//_____________________________________________________________________________
32 TG4GeometryManager* geometryManager)
33 : G4UImessenger(),
34 fGeometryManager(geometryManager),
35 fDirectory(0),
36 fUpdateFieldCmd(0),
37 fCreateFieldParametersCmd(0),
38 fIsLocalFieldCmd(0),
39 fIsZeroFieldCmd(0),
40 fSeparatorCmd(0),
41 fPrintMaterialsCmd(0),
42 fPrintMaterialsPropertiesCmd(0),
43 fPrintVolumesCmd(0),
44 fIsUserMaxStepCmd(),
45 fIsMaxStepInLowDensityMaterialsCmd(0),
46 fSetLimitDensityCmd(0),
47 fSetMaxStepInLowDensityMaterialsCmd(0),
48 fSetNewRadiatorCmd(0),
49 fSetRadiatorLayerCmd(0),
50 fSetRadiatorStrawTubeCmd(0),
51 fSetRadiatorCmd(0),
52 fRadiatorDescription(0)
53{
55
56 fDirectory = new G4UIdirectory("/mcDet/");
57 fDirectory->SetGuidance("Detector construction control commands.");
58
59 fUpdateFieldCmd = new G4UIcmdWithoutParameter("/mcDet/updateMagField", this);
60 G4String guidance = "Update magnetic field.\n";
61 guidance +=
62 "This command must be called if the field parameters were changed \n";
63 guidance += "in the Idle state.";
64 fUpdateFieldCmd->SetGuidance(guidance);
65 fUpdateFieldCmd->AvailableForStates(G4State_Idle);
66
68 new G4UIcmdWithAString("/mcDet/createMagFieldParameters", this);
69 fCreateFieldParametersCmd->SetGuidance(
70 "Create parameters (and their commands) for a local magnetic field \n");
71 fCreateFieldParametersCmd->SetGuidance(
72 "associated with the volume with the given name.");
73 fCreateFieldParametersCmd->SetParameterName("FieldVolName", false);
74 fCreateFieldParametersCmd->AvailableForStates(G4State_PreInit);
75
76 fIsLocalFieldCmd = new G4UIcmdWithABool("/mcDet/setIsLocalMagField", this);
77 fIsLocalFieldCmd->SetGuidance(
78 "Get local magnetic fields from Root geometry.");
79 fIsLocalFieldCmd->SetParameterName("IsLocalField", false);
80 fIsLocalFieldCmd->AvailableForStates(G4State_PreInit);
81
82 fIsZeroFieldCmd = new G4UIcmdWithABool("/mcDet/setIsZeroMagField", this);
83 guidance =
84 "(In)activate propagating 'ifield = 0' flag defined in tracking media.\n";
85 guidance +=
86 "When activated: a zero local magnetic field is set to the volumes "
87 "defined\n";
88 guidance += " with tracking medium with 'ifield = 0'.";
89 fIsZeroFieldCmd->SetGuidance(guidance);
90 fIsZeroFieldCmd->SetParameterName("IsZeroField", false);
91 fIsZeroFieldCmd->AvailableForStates(G4State_PreInit);
92
93 fSeparatorCmd = new G4UIcmdWithAString("/mcDet/volNameSeparator", this);
94 guidance =
95 "Override the default value of the volume name separator in g3tog4\n";
96 fSeparatorCmd->SetGuidance(guidance);
97 fSeparatorCmd->SetParameterName("VolNameSeparator", true);
98 fSeparatorCmd->AvailableForStates(G4State_PreInit);
99
101 new G4UIcmdWithoutParameter("/mcDet/printMaterials", this);
102 fPrintMaterialsCmd->SetGuidance("Prints all materials.");
103 fPrintMaterialsCmd->AvailableForStates(
104 G4State_PreInit, G4State_Init, G4State_Idle);
105
107 new G4UIcmdWithoutParameter("/mcDet/printMaterialsProperties", this);
108 fPrintMaterialsPropertiesCmd->SetGuidance(
109 "Prints all material properties for all materials.");
110 fPrintMaterialsPropertiesCmd->AvailableForStates(
111 G4State_PreInit, G4State_Init, G4State_Idle);
112
113 fPrintMediaCmd = new G4UIcmdWithoutParameter("/mcDet/printMedia", this);
114 fPrintMediaCmd->SetGuidance("Prints all media.");
115 fPrintMediaCmd->AvailableForStates(
116 G4State_PreInit, G4State_Init, G4State_Idle);
117
118 fPrintVolumesCmd = new G4UIcmdWithoutParameter("/mcDet/printVolumes", this);
119 fPrintVolumesCmd->SetGuidance("Prints all volumes.");
120 fPrintVolumesCmd->AvailableForStates(G4State_Idle);
121
122 fPrintCutsCmd = new G4UIcmdWithAString("/mcDet/printCuts", this);
123 fPrintCutsCmd->SetGuidance(
124 "Prints the cut value for given CutName for all tracking media");
125 fPrintCutsCmd->SetParameterName("CutName", false);
126 fPrintCutsCmd->AvailableForStates(G4State_Idle);
127
128 fPrintControlsCmd = new G4UIcmdWithAString("/mcDet/printControls", this);
129 fPrintControlsCmd->SetGuidance(
130 "Prints the control value for given ControlName for all tracking media");
131 fPrintControlsCmd->SetParameterName("ControlName", false);
132 fPrintControlsCmd->AvailableForStates(G4State_Idle);
133
134 fIsUserMaxStepCmd = new G4UIcmdWithABool("/mcDet/setIsUserMaxStep", this);
135 fIsUserMaxStepCmd->SetGuidance(
136 "Active user step limits defined in tracking media.");
137 fIsUserMaxStepCmd->SetParameterName("IsUserMaxStep", false);
138 fIsUserMaxStepCmd->AvailableForStates(G4State_PreInit);
139
141 new G4UIcmdWithABool("/mcDet/setIsMaxStepInLowDensityMaterials", this);
143 "Active user step limits defined in tracking media.");
144 fIsMaxStepInLowDensityMaterialsCmd->SetParameterName(
145 "IsMaxStepInLowDensityMaterials", false);
146 fIsMaxStepInLowDensityMaterialsCmd->AvailableForStates(G4State_PreInit);
147
149 new G4UIcmdWithADoubleAndUnit("/mcDet/setLimitDensity", this);
150 fSetLimitDensityCmd->SetGuidance(
151 "Set the material density limit for setting max allowed step");
152 fSetLimitDensityCmd->SetGuidance(
153 "Note that setting step limits has to be activated first via:\n");
154 fSetLimitDensityCmd->SetGuidance(
155 "/mcDet/setIsMaxStepInLowDensityMaterials true");
156 fSetLimitDensityCmd->SetParameterName("LimitDensity", false);
157 fSetLimitDensityCmd->SetDefaultUnit("g/cm3");
158 fSetLimitDensityCmd->SetUnitCategory("Volumic Mass");
159 fSetLimitDensityCmd->AvailableForStates(G4State_PreInit);
160
161 fSetMaxStepInLowDensityMaterialsCmd = new G4UIcmdWithADoubleAndUnit(
162 "/mcDet/setMaxStepInLowDensityMaterials", this);
164 "Set max allowed step value in materials with density below the density "
165 "limit");
167 "Note that setting step limits has to be activated first via:\n");
169 "/mcDet/setIsMaxStepInLowDensityMaterials true");
170 fSetMaxStepInLowDensityMaterialsCmd->SetParameterName(
171 "MaxStepInLowDensityMaterials", false);
172 fSetMaxStepInLowDensityMaterialsCmd->SetDefaultUnit("mm");
173 fSetMaxStepInLowDensityMaterialsCmd->SetUnitCategory("Length");
174 fSetMaxStepInLowDensityMaterialsCmd->AvailableForStates(G4State_PreInit);
175
179
180 // This command is now deprecated, will be removed in the next version.
181 // It is replaced with a simple setNewRadiator command.
183}
184
185//_____________________________________________________________________________
211
212//
213// private methods
214//
215
216//_____________________________________________________________________________
218{
219 G4UIparameter* volumeName = new G4UIparameter("volumeName", 's', false);
220 volumeName->SetGuidance("Radiator envelope.");
221
222 G4UIparameter* xtrModel = new G4UIparameter("xtrModel", 's', false);
223 xtrModel->SetGuidance("XTR model.");
224 // xtrModel->SetCandidates("gammaR gammaM strawR regR transpR regM");
225
226 G4UIparameter* foilNumber = new G4UIparameter("foilNumber", 'i', false);
227 foilNumber->SetGuidance("Number of foils");
228
229 G4UIparameter* strawTubeMaterial =
230 new G4UIparameter("strawTubeMaterial", 's', true);
231 strawTubeMaterial->SetGuidance("Straw tube material name.");
232 strawTubeMaterial->SetDefaultValue("");
233
234 fSetNewRadiatorCmd = new G4UIcommand("/mcDet/setNewRadiator", this);
235 fSetNewRadiatorCmd->SetGuidance("Define new radiator.");
236 fSetNewRadiatorCmd->SetParameter(volumeName);
237 fSetNewRadiatorCmd->SetParameter(xtrModel);
238 fSetNewRadiatorCmd->SetParameter(foilNumber);
239 fSetNewRadiatorCmd->AvailableForStates(G4State_PreInit);
240}
241
242//_____________________________________________________________________________
244{
245 G4UIparameter* volumeName = new G4UIparameter("materialName", 's', false);
246 volumeName->SetGuidance("Layer material name.");
247
248 G4UIparameter* thickness = new G4UIparameter("thickness", 'd', false);
249 thickness->SetGuidance("The layer thickness (cm)");
250
251 G4UIparameter* fluctuation = new G4UIparameter("fluctuation", 'd', true);
252 G4String guidance =
253 "Parameter that refers to the layer Gamma-distributed thickness.\n";
254 guidance += "The relative thickness fluctuation is ~ 1/sqrt(param)";
255 fluctuation->SetGuidance(guidance);
256
257 fSetRadiatorLayerCmd = new G4UIcommand("/mcDet/setRadiatorLayer", this);
258 fSetRadiatorLayerCmd->SetGuidance(
259 "Define the radiator layer (foil/gass) properties.");
260 fSetRadiatorLayerCmd->SetParameter(volumeName);
261 fSetRadiatorLayerCmd->SetParameter(thickness);
262 fSetRadiatorLayerCmd->SetParameter(fluctuation);
263 fSetRadiatorLayerCmd->AvailableForStates(G4State_PreInit);
264}
265
266//_____________________________________________________________________________
268{
269 G4UIparameter* gasMaterialName =
270 new G4UIparameter("gasMaterialName", 's', false);
271 gasMaterialName->SetGuidance("Straw tube gas material name.");
272
273 G4UIparameter* wallThickness = new G4UIparameter("wallThickness", 'd', false);
274 wallThickness->SetGuidance("The mean straw tube wall thickness (cm)");
275
276 G4UIparameter* gasThickness = new G4UIparameter("gasThickness", 'd', false);
277 wallThickness->SetGuidance("The mean straw tube gass thickness (cm)");
278
280 new G4UIcommand("/mcDet/setRadiatorStrawTube", this);
281 fSetRadiatorStrawTubeCmd->SetGuidance(
282 "Define the radiator straw tube properties.");
283 fSetRadiatorStrawTubeCmd->SetParameter(gasMaterialName);
284 fSetRadiatorStrawTubeCmd->SetParameter(wallThickness);
285 fSetRadiatorStrawTubeCmd->SetParameter(gasThickness);
286 fSetRadiatorStrawTubeCmd->AvailableForStates(G4State_PreInit);
287}
288
289//_____________________________________________________________________________
291{
292 G4UIparameter* volumeName = new G4UIparameter("volumeName", 's', false);
293 volumeName->SetGuidance("Radiator envelope.");
294
295 G4UIparameter* xtrModel = new G4UIparameter("xtrModel", 's', false);
296 xtrModel->SetGuidance("XTR model.");
297 // xtrModel->SetCandidates("gammaR gammaM strawR regR transpR regM");
298
299 G4UIparameter* foilMaterial = new G4UIparameter("foilMaterial", 's', false);
300 foilMaterial->SetGuidance("Foil material name.");
301
302 G4UIparameter* gasMaterial = new G4UIparameter("gasMaterial", 's', false);
303 gasMaterial->SetGuidance("Gas material name.");
304
305 G4UIparameter* foilThickness = new G4UIparameter("foilThickness", 'd', false);
306 foilThickness->SetGuidance("Foil thickness (cm).");
307
308 G4UIparameter* gasThickness = new G4UIparameter("gasThickness", 'd', false);
309 gasThickness->SetGuidance("Gas thickness (cm).");
310
311 G4UIparameter* foilNumber = new G4UIparameter("foilNumber", 'i', false);
312 foilNumber->SetGuidance("Number of foils");
313
314 G4UIparameter* strawTubeMaterial =
315 new G4UIparameter("strawTubeMaterial", 's', true);
316 strawTubeMaterial->SetGuidance("Straw tube material name.");
317 strawTubeMaterial->SetDefaultValue("");
318
319 fSetRadiatorCmd = new G4UIcommand("/mcDet/setRadiator", this);
320 fSetRadiatorCmd->SetGuidance("Define radiator properties.");
321 fSetRadiatorCmd->SetParameter(volumeName);
322 fSetRadiatorCmd->SetParameter(xtrModel);
323 fSetRadiatorCmd->SetParameter(foilMaterial);
324 fSetRadiatorCmd->SetParameter(gasMaterial);
325 fSetRadiatorCmd->SetParameter(foilThickness);
326 fSetRadiatorCmd->SetParameter(gasThickness);
327 fSetRadiatorCmd->SetParameter(foilNumber);
328 fSetRadiatorCmd->SetParameter(strawTubeMaterial);
329 fSetRadiatorCmd->AvailableForStates(G4State_PreInit);
330}
331
332//
333// public methods
334//
335
336//_____________________________________________________________________________
338 G4UIcommand* command, G4String newValues)
339{
341
342 if (command == fUpdateFieldCmd) {
344 }
345 else if (command == fCreateFieldParametersCmd) {
347 }
348 else if (command == fIsLocalFieldCmd) {
350 fIsLocalFieldCmd->GetNewBoolValue(newValues));
351 }
352 else if (command == fIsZeroFieldCmd) {
354 fIsZeroFieldCmd->GetNewBoolValue(newValues));
355 }
356 else if (command == fSeparatorCmd) {
357 char separator = newValues[0];
359 }
360 else if (command == fPrintMaterialsCmd) {
362 }
363 else if (command == fPrintMaterialsPropertiesCmd) {
365 }
366 else if (command == fPrintMediaCmd) {
368 }
369 else if (command == fPrintVolumesCmd) {
371 }
372 else if (command == fPrintCutsCmd) {
374 }
375 else if (command == fPrintControlsCmd) {
377 }
378 else if (command == fIsUserMaxStepCmd) {
380 fIsUserMaxStepCmd->GetNewBoolValue(newValues));
381 }
382 else if (command == fIsMaxStepInLowDensityMaterialsCmd) {
384 fIsMaxStepInLowDensityMaterialsCmd->GetNewBoolValue(newValues));
385 }
386 else if (command == fSetLimitDensityCmd) {
388 fSetLimitDensityCmd->GetNewDoubleValue(newValues));
389 }
390 else if (command == fSetMaxStepInLowDensityMaterialsCmd) {
392 fSetMaxStepInLowDensityMaterialsCmd->GetNewDoubleValue(newValues));
393 }
394 else if (command == fSetNewRadiatorCmd) {
395 // tokenize parameters in a vector
396 std::vector<G4String> parameters;
397 G4Analysis::Tokenize(newValues, parameters);
398
399 G4int counter = 0;
400 G4String volumeName = parameters[counter++];
401 G4String xtrModel = parameters[counter++];
402 G4int foilNumber = G4UIcommand::ConvertToInt(parameters[counter++]);
403
408 }
409 else if (command == fSetRadiatorLayerCmd) {
410
412 TG4Globals::Warning("TG4DetConstructionMessenger", "SetNewValue",
413 TString("Radiator was not defined.") + TG4Globals::Endl() +
414 TString("/mcDetector/setNewRadiator must be called first."));
415 return;
416 }
417
418 // tokenize parameters in a vector
419 std::vector<G4String> parameters;
420 G4Analysis::Tokenize(newValues, parameters);
421
422 G4int counter = 0;
423 G4String materialName = parameters[counter++];
424 G4double thickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
425 G4double fluctuation = 0.;
426 if (G4int(parameters.size()) > counter) {
427 fluctuation = G4UIcommand::ConvertToDouble(parameters[counter++]);
428 }
429
430 // apply units
431 thickness *= TG4G3Units::Length();
432
433 fRadiatorDescription->SetLayer(materialName, thickness, fluctuation);
434 }
435 else if (command == fSetRadiatorStrawTubeCmd) {
436
438 TG4Globals::Warning("TG4DetConstructionMessenger", "SetNewValue",
439 TString("Radiator was not defined.") + TG4Globals::Endl() +
440 TString("/mcDetector/setNewRadiator must be called first."));
441 return;
442 }
443
444 // tokenize parameters in a vector
445 std::vector<G4String> parameters;
446 G4Analysis::Tokenize(newValues, parameters);
447
448 G4int counter = 0;
449 G4String gasMaterialName = parameters[counter++];
450 G4double wallThickness =
451 G4UIcommand::ConvertToDouble(parameters[counter++]);
452 G4double gasThickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
453
454 // apply units
455 wallThickness *= TG4G3Units::Length();
456 gasThickness *= TG4G3Units::Length();
457
459 gasMaterialName, wallThickness, gasThickness);
460 }
461 else if (command == fSetRadiatorCmd) {
462 // The following code is deprecated, will be removed in the next version
463
464 // tokenize parameters in a vector
465 std::vector<G4String> parameters;
466 G4Analysis::Tokenize(newValues, parameters);
467
468 G4int counter = 0;
469 G4String volumeName = parameters[counter++];
470 G4String xtrModel = parameters[counter++];
471 G4String foilMaterial = parameters[counter++];
472 G4String gasMaterial = parameters[counter++];
473 G4double foilThickness =
474 G4UIcommand::ConvertToDouble(parameters[counter++]);
475 G4double gasThickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
476 G4int foilNumber = G4UIcommand::ConvertToInt(parameters[counter++]);
477 G4String strawTubeMaterial;
478 if (G4int(parameters.size()) > counter) {
479 strawTubeMaterial = parameters[counter++];
480 }
481
482 // apply units
483 foilThickness *= TG4G3Units::Length();
484 gasThickness *= TG4G3Units::Length();
485
486 TG4RadiatorDescription* radiatorDescription =
488 radiatorDescription->SetXtrModel(xtrModel);
489 radiatorDescription->SetFoilNumber(foilNumber);
490 radiatorDescription->SetLayer(foilMaterial, foilThickness, 100.);
491 radiatorDescription->SetLayer(gasMaterial, gasThickness, 100.);
492 if (strawTubeMaterial.size()) {
493 radiatorDescription->SetStrawTube(
494 strawTubeMaterial, 0.53 * CLHEP::mm, 3.14159 * CLHEP::mm);
495 }
496 }
497}
Definition of the TG4DetConstructionMessenger class.
Definition of the TG4DetConstruction class.
Definition of the TG4G3Units class.
Definition of the TG4GeometryManager class.
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4RadiatorDescription class.
G4UIcmdWithAString * fPrintCutsCmd
command: printCuts
G4UIcmdWithABool * fIsUserMaxStepCmd
command: setIsUserMaxStep
G4UIcmdWithABool * fIsLocalFieldCmd
command: setIsLocalMagField
G4UIcommand * fSetRadiatorStrawTubeCmd
command: setRadiatorStrawTube
TG4DetConstructionMessenger()
Not implemented.
G4UIcmdWithoutParameter * fPrintMediaCmd
command: printMedia
G4UIdirectory * fDirectory
command directory
G4UIcmdWithAString * fCreateFieldParametersCmd
command: createMagFieldParameters
G4UIcommand * fSetNewRadiatorCmd
command: setNewRadiator
G4UIcmdWithAString * fPrintControlsCmd
command: printControls
G4UIcmdWithABool * fIsMaxStepInLowDensityMaterialsCmd
command: setIsMaxStepInLowDensityMaterials
G4UIcmdWithABool * fIsZeroFieldCmd
command: setIsZeroMagField
G4UIcmdWithoutParameter * fUpdateFieldCmd
command: updateMagField
G4UIcmdWithADoubleAndUnit * fSetMaxStepInLowDensityMaterialsCmd
command: setMaxStepInLowDensityMaterials
G4UIcmdWithADoubleAndUnit * fSetLimitDensityCmd
command: setLimitDensity
G4UIcmdWithoutParameter * fPrintMaterialsCmd
command: printMatrials
G4UIcmdWithAString * fSeparatorCmd
command: volumeNameSeparator
void CreateSetRadiatorCmd()
The following command is deprecated, will be removed in the next version.
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
TG4RadiatorDescription * fRadiatorDescription
current radiator description
G4UIcmdWithoutParameter * fPrintMaterialsPropertiesCmd
command: printMaterialsProperties
G4UIcmdWithoutParameter * fPrintVolumesCmd
command: printVolumes
G4UIcommand * fSetRadiatorLayerCmd
command: setRadiatorLayer
static G4double Length()
Definition TG4G3Units.h:81
The manager class for building Geant4 geometry depending on a selected user input.
void SetIsLocalField(G4bool isLocalField)
void SetIsMaxStepInLowDensityMaterials(G4bool isMaxStep)
void SetIsZeroField(G4bool isZeroField)
void CreateFieldParameters(const G4String &fieldVolName)
TG4RadiatorDescription * CreateRadiator(const G4String &volName)
void SetMaxStepInLowDensityMaterials(G4double maxStep)
static TG4GeometryManager * Instance()
void SetIsUserMaxStep(G4bool isUserMaxStep)
void SetLimitDensity(G4double density)
void PrintControls(const G4String &controlName) const
static TG4GeometryServices * Instance()
void PrintMaterialsProperties() const
void SetG3toG4Separator(char separator)
void PrintCuts(const G4String &cutName) const
static void Warning(const TString &className, const TString &methodName, const TString &text)
static TString Endl()
Definition TG4Globals.h:100
The radiator description.
void SetStrawTube(const G4String &materialName, G4double wallThickness, G4double gasThickness)
void SetLayer(const G4String &materialName, G4double thickness, G4double fluctuation)
void SetXtrModel(const G4String &name)
Set the transition radiation process model.
void SetFoilNumber(G4int foilNumber)
Set the number of foils.