Geant4 VMC Version 6.8
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),
53{
55
56 fDirectory = new G4UIdirectory("/mcDet/");
57 fDirectory->SetGuidance("Detector construction control commands.");
58
59 fIsLocalFieldCmd = new G4UIcmdWithABool("/mcDet/setIsLocalMagField", this);
60 fIsLocalFieldCmd->SetGuidance(
61 "Get local magnetic fields from Root geometry.");
62 fIsLocalFieldCmd->SetParameterName("IsLocalField", false);
63 fIsLocalFieldCmd->AvailableForStates(G4State_PreInit);
64
65 fIsZeroFieldCmd = new G4UIcmdWithABool("/mcDet/setIsZeroMagField", this);
66 G4String guidance =
67 "(In)activate propagating 'ifield = 0' flag defined in tracking media.\n";
68 guidance +=
69 "When activated: a zero local magnetic field is set to the volumes "
70 "defined\n";
71 guidance += " with tracking medium with 'ifield = 0'.";
72 fIsZeroFieldCmd->SetGuidance(guidance);
73 fIsZeroFieldCmd->SetParameterName("IsZeroField", false);
74 fIsZeroFieldCmd->AvailableForStates(G4State_PreInit);
75
76 fIsMonopoleFieldCmd = new G4UIcmdWithABool("/mcDet/setIsMonopoleField", this);
77 fIsMonopoleFieldCmd->SetGuidance(
78 "Get local magnetic fields from Root geometry.");
79 fIsMonopoleFieldCmd->SetParameterName("IsMonopoleField", false);
80 fIsMonopoleFieldCmd->AvailableForStates(G4State_PreInit);
81
82 fSeparatorCmd = new G4UIcmdWithAString("/mcDet/volNameSeparator", this);
83 guidance =
84 "Override the default value of the volume name separator in g3tog4\n";
85 fSeparatorCmd->SetGuidance(guidance);
86 fSeparatorCmd->SetParameterName("VolNameSeparator", true);
87 fSeparatorCmd->AvailableForStates(G4State_PreInit);
88
90 new G4UIcmdWithoutParameter("/mcDet/printMaterials", this);
91 fPrintMaterialsCmd->SetGuidance("Prints all materials.");
92 fPrintMaterialsCmd->AvailableForStates(
93 G4State_PreInit, G4State_Init, G4State_Idle);
94
96 new G4UIcmdWithoutParameter("/mcDet/printMaterialsProperties", this);
98 "Prints all material properties for all materials.");
99 fPrintMaterialsPropertiesCmd->AvailableForStates(
100 G4State_PreInit, G4State_Init, G4State_Idle);
101
102 fPrintMediaCmd = new G4UIcmdWithoutParameter("/mcDet/printMedia", this);
103 fPrintMediaCmd->SetGuidance("Prints all media.");
104 fPrintMediaCmd->AvailableForStates(
105 G4State_PreInit, G4State_Init, G4State_Idle);
106
107 fPrintVolumesCmd = new G4UIcmdWithoutParameter("/mcDet/printVolumes", this);
108 fPrintVolumesCmd->SetGuidance("Prints all volumes.");
109 fPrintVolumesCmd->AvailableForStates(G4State_Idle);
110
111 fPrintCutsCmd = new G4UIcmdWithAString("/mcDet/printCuts", this);
112 fPrintCutsCmd->SetGuidance(
113 "Prints the cut value for given CutName for all tracking media");
114 fPrintCutsCmd->SetParameterName("CutName", false);
115 fPrintCutsCmd->AvailableForStates(G4State_Idle);
116
117 fPrintControlsCmd = new G4UIcmdWithAString("/mcDet/printControls", this);
118 fPrintControlsCmd->SetGuidance(
119 "Prints the control value for given ControlName for all tracking media");
120 fPrintControlsCmd->SetParameterName("ControlName", false);
121 fPrintControlsCmd->AvailableForStates(G4State_Idle);
122
123 fIsUserMaxStepCmd = new G4UIcmdWithABool("/mcDet/setIsUserMaxStep", this);
124 fIsUserMaxStepCmd->SetGuidance(
125 "Active user step limits defined in tracking media.");
126 fIsUserMaxStepCmd->SetParameterName("IsUserMaxStep", false);
127 fIsUserMaxStepCmd->AvailableForStates(G4State_PreInit);
128
130 new G4UIcmdWithABool("/mcDet/setIsMaxStepInLowDensityMaterials", this);
132 "Active user step limits defined in tracking media.");
133 fIsMaxStepInLowDensityMaterialsCmd->SetParameterName(
134 "IsMaxStepInLowDensityMaterials", false);
135 fIsMaxStepInLowDensityMaterialsCmd->AvailableForStates(G4State_PreInit);
136
138 new G4UIcmdWithADoubleAndUnit("/mcDet/setLimitDensity", this);
139 fSetLimitDensityCmd->SetGuidance(
140 "Set the material density limit for setting max allowed step");
141 fSetLimitDensityCmd->SetGuidance(
142 "Note that setting step limits has to be activated first via:\n");
143 fSetLimitDensityCmd->SetGuidance(
144 "/mcDet/setIsMaxStepInLowDensityMaterials true");
145 fSetLimitDensityCmd->SetParameterName("LimitDensity", false);
146 fSetLimitDensityCmd->SetDefaultUnit("g/cm3");
147 fSetLimitDensityCmd->SetUnitCategory("Volumic Mass");
148 fSetLimitDensityCmd->AvailableForStates(G4State_PreInit);
149
150 fSetMaxStepInLowDensityMaterialsCmd = new G4UIcmdWithADoubleAndUnit(
151 "/mcDet/setMaxStepInLowDensityMaterials", this);
153 "Set max allowed step value in materials with density below the density "
154 "limit");
156 "Note that setting step limits has to be activated first via:\n");
158 "/mcDet/setIsMaxStepInLowDensityMaterials true");
159 fSetMaxStepInLowDensityMaterialsCmd->SetParameterName(
160 "MaxStepInLowDensityMaterials", false);
161 fSetMaxStepInLowDensityMaterialsCmd->SetDefaultUnit("mm");
162 fSetMaxStepInLowDensityMaterialsCmd->SetUnitCategory("Length");
163 fSetMaxStepInLowDensityMaterialsCmd->AvailableForStates(G4State_PreInit);
164
168
169 // This command is now deprecated, will be removed in the next version.
170 // It is replaced with a simple setNewRadiator command.
172
174 new G4UIcmdWithABool("/mcDet/setAccountAssemblyLevels", this);
175 fAccountAssemblyLevelsCmd->SetGuidance(
176 "Activate accounting assemblies in the volume level hierarchy.");
177 fAccountAssemblyLevelsCmd->SetParameterName(
178 "AccountAssemblyLevels", false);
179 fAccountAssemblyLevelsCmd->AvailableForStates(G4State_PreInit);
180}
181
182//_____________________________________________________________________________
208
209//
210// private methods
211//
212
213//_____________________________________________________________________________
215{
216 G4UIparameter* volumeName = new G4UIparameter("volumeName", 's', false);
217 volumeName->SetGuidance("Radiator envelope.");
218
219 G4UIparameter* xtrModel = new G4UIparameter("xtrModel", 's', false);
220 xtrModel->SetGuidance("XTR model.");
221 // xtrModel->SetCandidates("gammaR gammaM strawR regR transpR regM");
222
223 G4UIparameter* foilNumber = new G4UIparameter("foilNumber", 'i', false);
224 foilNumber->SetGuidance("Number of foils");
225
226 G4UIparameter* strawTubeMaterial =
227 new G4UIparameter("strawTubeMaterial", 's', true);
228 strawTubeMaterial->SetGuidance("Straw tube material name.");
229 strawTubeMaterial->SetDefaultValue("");
230
231 fSetNewRadiatorCmd = new G4UIcommand("/mcDet/setNewRadiator", this);
232 fSetNewRadiatorCmd->SetGuidance("Define new radiator.");
233 fSetNewRadiatorCmd->SetParameter(volumeName);
234 fSetNewRadiatorCmd->SetParameter(xtrModel);
235 fSetNewRadiatorCmd->SetParameter(foilNumber);
236 fSetNewRadiatorCmd->AvailableForStates(G4State_PreInit);
237}
238
239//_____________________________________________________________________________
241{
242 G4UIparameter* volumeName = new G4UIparameter("materialName", 's', false);
243 volumeName->SetGuidance("Layer material name.");
244
245 G4UIparameter* thickness = new G4UIparameter("thickness", 'd', false);
246 thickness->SetGuidance("The layer thickness (cm)");
247
248 G4UIparameter* fluctuation = new G4UIparameter("fluctuation", 'd', true);
249 G4String guidance =
250 "Parameter that refers to the layer Gamma-distributed thickness.\n";
251 guidance += "The relative thickness fluctuation is ~ 1/sqrt(param)";
252 fluctuation->SetGuidance(guidance);
253
254 fSetRadiatorLayerCmd = new G4UIcommand("/mcDet/setRadiatorLayer", this);
255 fSetRadiatorLayerCmd->SetGuidance(
256 "Define the radiator layer (foil/gass) properties.");
257 fSetRadiatorLayerCmd->SetParameter(volumeName);
258 fSetRadiatorLayerCmd->SetParameter(thickness);
259 fSetRadiatorLayerCmd->SetParameter(fluctuation);
260 fSetRadiatorLayerCmd->AvailableForStates(G4State_PreInit);
261}
262
263//_____________________________________________________________________________
265{
266 G4UIparameter* gasMaterialName =
267 new G4UIparameter("gasMaterialName", 's', false);
268 gasMaterialName->SetGuidance("Straw tube gas material name.");
269
270 G4UIparameter* wallThickness = new G4UIparameter("wallThickness", 'd', false);
271 wallThickness->SetGuidance("The mean straw tube wall thickness (cm)");
272
273 G4UIparameter* gasThickness = new G4UIparameter("gasThickness", 'd', false);
274 wallThickness->SetGuidance("The mean straw tube gass thickness (cm)");
275
277 new G4UIcommand("/mcDet/setRadiatorStrawTube", this);
278 fSetRadiatorStrawTubeCmd->SetGuidance(
279 "Define the radiator straw tube properties.");
280 fSetRadiatorStrawTubeCmd->SetParameter(gasMaterialName);
281 fSetRadiatorStrawTubeCmd->SetParameter(wallThickness);
282 fSetRadiatorStrawTubeCmd->SetParameter(gasThickness);
283 fSetRadiatorStrawTubeCmd->AvailableForStates(G4State_PreInit);
284}
285
286//_____________________________________________________________________________
288{
289 G4UIparameter* volumeName = new G4UIparameter("volumeName", 's', false);
290 volumeName->SetGuidance("Radiator envelope.");
291
292 G4UIparameter* xtrModel = new G4UIparameter("xtrModel", 's', false);
293 xtrModel->SetGuidance("XTR model.");
294 // xtrModel->SetCandidates("gammaR gammaM strawR regR transpR regM");
295
296 G4UIparameter* foilMaterial = new G4UIparameter("foilMaterial", 's', false);
297 foilMaterial->SetGuidance("Foil material name.");
298
299 G4UIparameter* gasMaterial = new G4UIparameter("gasMaterial", 's', false);
300 gasMaterial->SetGuidance("Gas material name.");
301
302 G4UIparameter* foilThickness = new G4UIparameter("foilThickness", 'd', false);
303 foilThickness->SetGuidance("Foil thickness (cm).");
304
305 G4UIparameter* gasThickness = new G4UIparameter("gasThickness", 'd', false);
306 gasThickness->SetGuidance("Gas thickness (cm).");
307
308 G4UIparameter* foilNumber = new G4UIparameter("foilNumber", 'i', false);
309 foilNumber->SetGuidance("Number of foils");
310
311 G4UIparameter* strawTubeMaterial =
312 new G4UIparameter("strawTubeMaterial", 's', true);
313 strawTubeMaterial->SetGuidance("Straw tube material name.");
314 strawTubeMaterial->SetDefaultValue("");
315
316 fSetRadiatorCmd = new G4UIcommand("/mcDet/setRadiator", this);
317 fSetRadiatorCmd->SetGuidance("Define radiator properties.");
318 fSetRadiatorCmd->SetParameter(volumeName);
319 fSetRadiatorCmd->SetParameter(xtrModel);
320 fSetRadiatorCmd->SetParameter(foilMaterial);
321 fSetRadiatorCmd->SetParameter(gasMaterial);
322 fSetRadiatorCmd->SetParameter(foilThickness);
323 fSetRadiatorCmd->SetParameter(gasThickness);
324 fSetRadiatorCmd->SetParameter(foilNumber);
325 fSetRadiatorCmd->SetParameter(strawTubeMaterial);
326 fSetRadiatorCmd->AvailableForStates(G4State_PreInit);
327}
328
329//
330// public methods
331//
332
333//_____________________________________________________________________________
335 G4UIcommand* command, G4String newValues)
336{
338
339 if (command == fIsLocalFieldCmd) {
341 fIsLocalFieldCmd->GetNewBoolValue(newValues));
342 }
343 else if (command == fIsZeroFieldCmd) {
345 fIsZeroFieldCmd->GetNewBoolValue(newValues));
346 }
347 else if (command == fIsMonopoleFieldCmd) {
349 fIsMonopoleFieldCmd->GetNewBoolValue(newValues));
350 }
351 else if (command == fSeparatorCmd) {
352 char separator = newValues[0];
354 }
355 else if (command == fPrintMaterialsCmd) {
357 }
358 else if (command == fPrintMaterialsPropertiesCmd) {
360 }
361 else if (command == fPrintMediaCmd) {
363 }
364 else if (command == fPrintVolumesCmd) {
366 }
367 else if (command == fPrintCutsCmd) {
369 }
370 else if (command == fPrintControlsCmd) {
372 }
373 else if (command == fIsUserMaxStepCmd) {
375 fIsUserMaxStepCmd->GetNewBoolValue(newValues));
376 }
377 else if (command == fIsMaxStepInLowDensityMaterialsCmd) {
379 fIsMaxStepInLowDensityMaterialsCmd->GetNewBoolValue(newValues));
380 }
381 else if (command == fSetLimitDensityCmd) {
383 fSetLimitDensityCmd->GetNewDoubleValue(newValues));
384 }
385 else if (command == fSetMaxStepInLowDensityMaterialsCmd) {
387 fSetMaxStepInLowDensityMaterialsCmd->GetNewDoubleValue(newValues));
388 }
389 else if (command == fSetNewRadiatorCmd) {
390 // tokenize parameters in a vector
391 std::vector<G4String> parameters;
392 G4Analysis::Tokenize(newValues, parameters);
393
394 G4int counter = 0;
395 G4String volumeName = parameters[counter++];
396 G4String xtrModel = parameters[counter++];
397 G4int foilNumber = G4UIcommand::ConvertToInt(parameters[counter++]);
398
401 fRadiatorDescription->SetXtrModel(xtrModel);
402 fRadiatorDescription->SetFoilNumber(foilNumber);
403 }
404 else if (command == fSetRadiatorLayerCmd) {
405
407 TG4Globals::Warning("TG4DetConstructionMessenger", "SetNewValue",
408 TString("Radiator was not defined.") + TG4Globals::Endl() +
409 TString("/mcDetector/setNewRadiator must be called first."));
410 return;
411 }
412
413 // tokenize parameters in a vector
414 std::vector<G4String> parameters;
415 G4Analysis::Tokenize(newValues, parameters);
416
417 G4int counter = 0;
418 G4String materialName = parameters[counter++];
419 G4double thickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
420 G4double fluctuation = 0.;
421 if (G4int(parameters.size()) > counter) {
422 fluctuation = G4UIcommand::ConvertToDouble(parameters[counter++]);
423 }
424
425 // apply units
426 thickness *= TG4G3Units::Length();
427
428 fRadiatorDescription->SetLayer(materialName, thickness, fluctuation);
429 }
430 else if (command == fSetRadiatorStrawTubeCmd) {
431
433 TG4Globals::Warning("TG4DetConstructionMessenger", "SetNewValue",
434 TString("Radiator was not defined.") + TG4Globals::Endl() +
435 TString("/mcDetector/setNewRadiator must be called first."));
436 return;
437 }
438
439 // tokenize parameters in a vector
440 std::vector<G4String> parameters;
441 G4Analysis::Tokenize(newValues, parameters);
442
443 G4int counter = 0;
444 G4String gasMaterialName = parameters[counter++];
445 G4double wallThickness =
446 G4UIcommand::ConvertToDouble(parameters[counter++]);
447 G4double gasThickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
448
449 // apply units
450 wallThickness *= TG4G3Units::Length();
451 gasThickness *= TG4G3Units::Length();
452
453 fRadiatorDescription->SetStrawTube(
454 gasMaterialName, wallThickness, gasThickness);
455 }
456 else if (command == fSetRadiatorCmd) {
457 // The following code is deprecated, will be removed in the next version
458
459 // tokenize parameters in a vector
460 std::vector<G4String> parameters;
461 G4Analysis::Tokenize(newValues, parameters);
462
463 G4int counter = 0;
464 G4String volumeName = parameters[counter++];
465 G4String xtrModel = parameters[counter++];
466 G4String foilMaterial = parameters[counter++];
467 G4String gasMaterial = parameters[counter++];
468 G4double foilThickness =
469 G4UIcommand::ConvertToDouble(parameters[counter++]);
470 G4double gasThickness = G4UIcommand::ConvertToDouble(parameters[counter++]);
471 G4int foilNumber = G4UIcommand::ConvertToInt(parameters[counter++]);
472 G4String strawTubeMaterial;
473 if (G4int(parameters.size()) > counter) {
474 strawTubeMaterial = parameters[counter++];
475 }
476
477 // apply units
478 foilThickness *= TG4G3Units::Length();
479 gasThickness *= TG4G3Units::Length();
480
481 TG4RadiatorDescription* radiatorDescription =
483 radiatorDescription->SetXtrModel(xtrModel);
484 radiatorDescription->SetFoilNumber(foilNumber);
485 radiatorDescription->SetLayer(foilMaterial, foilThickness, 100.);
486 radiatorDescription->SetLayer(gasMaterial, gasThickness, 100.);
487 if (strawTubeMaterial.size()) {
488 radiatorDescription->SetStrawTube(
489 strawTubeMaterial, 0.53 * CLHEP::mm, 3.14159 * CLHEP::mm);
490 }
491 }
492 else if (command == fAccountAssemblyLevelsCmd) {
494 fAccountAssemblyLevelsCmd->GetNewBoolValue(newValues));
495 }
496}
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
G4UIcmdWithABool * fIsMonopoleFieldCmd
command: setIsMonopole
TG4GeometryManager * fGeometryManager
associated class
G4UIcommand * fSetNewRadiatorCmd
command: setNewRadiator
G4UIcmdWithAString * fPrintControlsCmd
command: printControls
G4UIcmdWithABool * fIsMaxStepInLowDensityMaterialsCmd
command: setIsMaxStepInLowDensityMaterials
G4UIcmdWithABool * fIsZeroFieldCmd
command: setIsZeroMagField
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)
G4UIcmdWithABool * fAccountAssemblyLevelsCmd
command: setAccountAssemblyLevels
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)
TG4RadiatorDescription * CreateRadiator(const G4String &volName)
void SetMaxStepInLowDensityMaterials(G4double maxStep)
static TG4GeometryManager * Instance()
void SetIsUserMaxStep(G4bool isUserMaxStep)
void SetLimitDensity(G4double density)
void SetIsMonopoleField(G4bool isMonopoleField)
void PrintControls(const G4String &controlName) const
void SetAccountAssemblyLevels(G4bool option)
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:101
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.