Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CascadeParamMessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4CascadeParamMessenger.hh
27// Define simple UI commands as alternative to environment variables
28//
29
32#include "G4UIcmdWithABool.hh"
33#include "G4UIcmdWithADouble.hh"
34#include "G4UIcmdWithAString.hh"
37#include "G4UIcommand.hh"
38#include "G4UIcommandTree.hh"
39#include "G4UIdirectory.hh"
40#include "G4UImanager.hh"
41
42
43// Constructor and destructor
44
46 : G4UImessenger(), theParams(params), cmdDir(0), localCmdDir(false) {
47 // NOTE: Put under same top-level tree as EM
48 CreateDirectory("/process/had/cascade/","Bertini-esque cascade parameters");
49
50 verboseCmd = CreateCommand<G4UIcmdWithAnInteger>("verbose",
51 "Enable information messages");
52 reportCmd = CreateCommand<G4UIcmdWithoutParameter>("report",
53 "Dump all non-default parameter settings");
54 usePreCoCmd = CreateCommand<G4UIcmdWithABool>("usePreCompound",
55 "Use PreCompoundModel for nuclear de-excitation");
56 doCoalCmd = CreateCommand<G4UIcmdWithABool>("doCoalescence",
57 "Apply final-state nucleon clustering");
58 randomFileCmd = CreateCommand<G4UIcmdWithAString>("randomFile",
59 "Save random-engine to file at each interaction");
60 nucUseBestCmd = CreateCommand<G4UIcmdWithABool>("useBestNuclearModel",
61 "Use all physical-units for nuclear structure");
62 nucRad2parCmd = CreateCommand<G4UIcmdWithADouble>("useTwoParamNuclearRadius",
63 "Use R = C1*cbrt(A) + C2/cbrt(A)");
64 nucRadScaleCmd = CreateCommand<G4UIcmdWithADouble>("nuclearRadiusScale",
65 "Set length scale for nuclear model");
66 nucRadSmallCmd = CreateCommand<G4UIcmdWithADouble>("smallNucleusRadius",
67 "Set radius of A<4 nuclei");
68 nucRadAlphaCmd = CreateCommand<G4UIcmdWithADouble>("alphaRadiusScale",
69 "Fraction of small-radius for He-4");
70 nucRadTrailingCmd = CreateCommand<G4UIcmdWithADouble>("shadowningRadius",
71 "Effective nucleon radius for trailing effect");
72 nucFermiScaleCmd = CreateCommand<G4UIcmdWithADouble>("fermiScale",
73 "Scale factor for fermi momentum");
74 nucXsecScaleCmd = CreateCommand<G4UIcmdWithADouble>("crossSectionScale",
75 "Scale fator for total cross-sections");
76 nucGammaQDCmd = CreateCommand<G4UIcmdWithADouble>("gammaQuasiDeutScale",
77 "Scale factor for gamma-quasideutron cross-sections");
78 coalDPmax2Cmd = CreateCommand<G4UIcmdWithADouble>("cluster2DPmax",
79 "Maximum momentum for p-n clusters");
80 coalDPmax3Cmd = CreateCommand<G4UIcmdWithADouble>("cluster3DPmax",
81 "Maximum momentum for ppn/pnn clusters");
82 coalDPmax4Cmd = CreateCommand<G4UIcmdWithADouble>("cluster4DPmax",
83 "Maximum momentum for alpha clusters");
84}
85
87 delete verboseCmd;
88 delete reportCmd;
89 delete usePreCoCmd;
90 delete doCoalCmd;
91 delete randomFileCmd;
92 delete nucUseBestCmd;
93 delete nucRad2parCmd;
94 delete nucRadScaleCmd;
95 delete nucRadSmallCmd;
96 delete nucRadAlphaCmd;
97 delete nucRadTrailingCmd;
98 delete nucFermiScaleCmd;
99 delete nucXsecScaleCmd;
100 delete nucGammaQDCmd;
101 delete coalDPmax2Cmd;
102 delete coalDPmax3Cmd;
103 delete coalDPmax4Cmd;
104 if (localCmdDir) delete cmdDir;
105}
106
107
108// Create or reuse existing UIdirectory path
109
111 const char* desc) {
113 if (!UIman) return;
114
115 // Directory path must be absolute, prepend "/" if ncessary
116 G4String fullPath = path;
117 if (fullPath(0) != '/') fullPath.prepend("/");
118 if (fullPath(fullPath.length()-1) != '/') fullPath.append("/");
119
120 // See if input path has already been registered
121 G4UIcommand* foundPath = UIman->GetTree()->FindPath(fullPath);
122 if (foundPath) cmdDir = dynamic_cast<G4UIdirectory*>(foundPath);
123
124 if (!cmdDir) { // Create local deletable directory
125 localCmdDir = true;
126 cmdDir = new G4UIdirectory(fullPath.c_str());
127 cmdDir->SetGuidance(desc);
128 }
129}
130
131
132// Use command argument (literal string) to set envvar maps in container
133
135 if (cmd == reportCmd) theParams->DumpConfig(G4cout);
136
137 if (cmd == verboseCmd)
138 theParams->G4CASCADE_VERBOSE = strdup(arg.c_str());
139
140 if (cmd == usePreCoCmd)
141 theParams->G4CASCADE_USE_PRECOMPOUND = StoB(arg) ? strdup(arg.c_str()) : 0;
142
143 if (cmd == doCoalCmd)
144 theParams->G4CASCADE_DO_COALESCENCE = StoB(arg) ? strdup(arg.c_str()) : 0;
145
146 if (cmd == randomFileCmd)
147 theParams->G4CASCADE_RANDOM_FILE = arg.empty() ? 0 : strdup(arg.c_str());
148
149 if (cmd == nucUseBestCmd)
150 theParams->G4NUCMODEL_USE_BEST = StoB(arg) ? strdup(arg.c_str()) : 0;
151
152 if (cmd == nucRad2parCmd)
153 theParams->G4NUCMODEL_RAD_2PAR = strdup(arg.c_str());
154
155 if (cmd == nucRadScaleCmd)
156 theParams->G4NUCMODEL_RAD_SCALE = strdup(arg.c_str());
157
158 if (cmd == nucRadSmallCmd)
159 theParams->G4NUCMODEL_RAD_SMALL = strdup(arg.c_str());
160
161 if (cmd == nucRadAlphaCmd)
162 theParams->G4NUCMODEL_RAD_ALPHA = strdup(arg.c_str());
163
164 if (cmd == nucRadTrailingCmd)
165 theParams->G4NUCMODEL_RAD_TRAILING = strdup(arg.c_str());
166
167 if (cmd == nucFermiScaleCmd)
168 theParams->G4NUCMODEL_FERMI_SCALE = strdup(arg.c_str());
169
170 if (cmd == nucXsecScaleCmd)
171 theParams->G4NUCMODEL_XSEC_SCALE = strdup(arg.c_str());
172
173 if (cmd == nucGammaQDCmd)
174 theParams->G4NUCMODEL_GAMMAQD = strdup(arg.c_str());
175
176 if (cmd == coalDPmax2Cmd)
177 theParams->DPMAX_2CLUSTER = strdup(arg.c_str());
178
179 if (cmd == coalDPmax3Cmd)
180 theParams->DPMAX_3CLUSTER = strdup(arg.c_str());
181
182 if (cmd == coalDPmax4Cmd)
183 theParams->DPMAX_4CLUSTER = strdup(arg.c_str());
184
185 theParams->Initialize(); // Update numerical values from settings
186}
G4DLLIMPORT std::ostream G4cout
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4CascadeParamMessenger(G4CascadeParameters *params)
void CreateDirectory(const char *path, const char *desc)
G4String & append(const G4String &)
G4String & prepend(const char *)
G4UIcommand * FindPath(const char *commandPath) const
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:197
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
G4bool StoB(G4String s)