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