Geant4  10.01.p02
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 // $Id: G4CascadeParamMessenger.cc 72016 2013-07-03 16:24:15Z mkelsey $
27 // Define simple UI commands as alternative to environment variables
28 //
29 // 20130304 M. Kelsey -- Add flag to collect and display cascade structure
30 // 20130621 M. Kelsey -- Add flag for CHECK_ECONS, replacing #ifdef's; add
31 // flag to use three-body momentum parametrizations
32 // 20130703 M. Kelsey -- Add flag for USE_PHASESPACE
33 // 20141030 M. Kelsey -- Add flag to enable direct pi-N absorption
34 
36 #include "G4CascadeParameters.hh"
37 #include "G4UIcmdWithABool.hh"
38 #include "G4UIcmdWithADouble.hh"
39 #include "G4UIcmdWithAString.hh"
40 #include "G4UIcmdWithAnInteger.hh"
42 #include "G4UIcommand.hh"
43 #include "G4UIcommandTree.hh"
44 #include "G4UIdirectory.hh"
45 #include "G4UImanager.hh"
46 
47 
48 // Constructor and destructor
49 
51  : G4UImessenger(), theParams(params), cmdDir(0), localCmdDir(false) {
52  // NOTE: Put under same top-level tree as EM
53  CreateDirectory("/process/had/cascade/","Bertini-esque cascade parameters");
54 
55  verboseCmd = CreateCommand<G4UIcmdWithAnInteger>("verbose",
56  "Enable information messages");
57  balanceCmd = CreateCommand<G4UIcmdWithABool>("checkBalance",
58  "Enable internal conservation checking");
59  reportCmd = CreateCommand<G4UIcmdWithoutParameter>("report",
60  "Dump all non-default parameter settings");
61  usePreCoCmd = CreateCommand<G4UIcmdWithABool>("usePreCompound",
62  "Use PreCompoundModel for nuclear de-excitation");
63  doCoalCmd = CreateCommand<G4UIcmdWithABool>("doCoalescence",
64  "Apply final-state nucleon clustering");
65  piNAbsCmd = CreateCommand<G4UIcmdWithABool>("piNAbsorption",
66  "Allow pion absorption on single nucleon");
67  historyCmd = CreateCommand<G4UIcmdWithABool>("showHistory",
68  "Collect and report full structure of cascade");
69  use3BodyCmd = CreateCommand<G4UIcmdWithABool>("use3BodyMom",
70  "Use three-body momentum parametrizations");
71  usePSCmd = CreateCommand<G4UIcmdWithABool>("usePhaseSpace",
72  "Use Kopylov N-body momentum generator");
73  randomFileCmd = CreateCommand<G4UIcmdWithAString>("randomFile",
74  "Save random-engine to file at each interaction");
75  nucUseBestCmd = CreateCommand<G4UIcmdWithABool>("useBestNuclearModel",
76  "Use all physical-units for nuclear structure");
77  nucRad2parCmd = CreateCommand<G4UIcmdWithADouble>("useTwoParamNuclearRadius",
78  "Use R = C1*cbrt(A) + C2/cbrt(A)");
79  nucRadScaleCmd = CreateCommand<G4UIcmdWithADouble>("nuclearRadiusScale",
80  "Set length scale for nuclear model");
81  nucRadSmallCmd = CreateCommand<G4UIcmdWithADouble>("smallNucleusRadius",
82  "Set radius of A<4 nuclei");
83  nucRadAlphaCmd = CreateCommand<G4UIcmdWithADouble>("alphaRadiusScale",
84  "Fraction of small-radius for He-4");
85  nucRadTrailingCmd = CreateCommand<G4UIcmdWithADouble>("shadowningRadius",
86  "Effective nucleon radius for trailing effect");
87  nucFermiScaleCmd = CreateCommand<G4UIcmdWithADouble>("fermiScale",
88  "Scale factor for fermi momentum");
89  nucXsecScaleCmd = CreateCommand<G4UIcmdWithADouble>("crossSectionScale",
90  "Scale fator for total cross-sections");
91  nucGammaQDCmd = CreateCommand<G4UIcmdWithADouble>("gammaQuasiDeutScale",
92  "Scale factor for gamma-quasideutron cross-sections");
93  coalDPmax2Cmd = CreateCommand<G4UIcmdWithADouble>("cluster2DPmax",
94  "Maximum momentum for p-n clusters");
95  coalDPmax3Cmd = CreateCommand<G4UIcmdWithADouble>("cluster3DPmax",
96  "Maximum momentum for ppn/pnn clusters");
97  coalDPmax4Cmd = CreateCommand<G4UIcmdWithADouble>("cluster4DPmax",
98  "Maximum momentum for alpha clusters");
99 }
100 
102  delete verboseCmd;
103  delete balanceCmd;
104  delete reportCmd;
105  delete usePreCoCmd;
106  delete doCoalCmd;
107  delete piNAbsCmd;
108  delete historyCmd;
109  delete use3BodyCmd;
110  delete usePSCmd;
111  delete randomFileCmd;
112  delete nucUseBestCmd;
113  delete nucRad2parCmd;
114  delete nucRadScaleCmd;
115  delete nucRadSmallCmd;
116  delete nucRadAlphaCmd;
117  delete nucRadTrailingCmd;
118  delete nucFermiScaleCmd;
119  delete nucXsecScaleCmd;
120  delete nucGammaQDCmd;
121  delete coalDPmax2Cmd;
122  delete coalDPmax3Cmd;
123  delete coalDPmax4Cmd;
124  if (localCmdDir) delete cmdDir;
125 }
126 
127 
128 // Create or reuse existing UIdirectory path
129 
131  const char* desc) {
133  if (!UIman) return;
134 
135  // Directory path must be absolute, prepend "/" if ncessary
136  G4String fullPath = path;
137  if (fullPath(0) != '/') fullPath.prepend("/");
138  if (fullPath(fullPath.length()-1) != '/') fullPath.append("/");
139 
140  // See if input path has already been registered
141  G4UIcommand* foundPath = UIman->GetTree()->FindPath(fullPath);
142  if (foundPath) cmdDir = dynamic_cast<G4UIdirectory*>(foundPath);
143 
144  if (!cmdDir) { // Create local deletable directory
145  localCmdDir = true;
146  cmdDir = new G4UIdirectory(fullPath.c_str());
147  cmdDir->SetGuidance(desc);
148  }
149 }
150 
151 
152 // Use command argument (literal string) to set envvar maps in container
153 
155  if (cmd == reportCmd) theParams->DumpConfig(G4cout);
156 
157  if (cmd == verboseCmd)
158  theParams->G4CASCADE_VERBOSE = strdup(arg.c_str());
159 
160  if (cmd == balanceCmd)
161  theParams->G4CASCADE_CHECK_ECONS = StoB(arg) ? strdup(arg.c_str()) : 0;
162 
163  if (cmd == usePreCoCmd)
164  theParams->G4CASCADE_USE_PRECOMPOUND = StoB(arg) ? strdup(arg.c_str()) : 0;
165 
166  if (cmd == doCoalCmd)
167  theParams->G4CASCADE_DO_COALESCENCE = StoB(arg) ? strdup(arg.c_str()) : 0;
168 
169  if (cmd == piNAbsCmd)
170  theParams->G4CASCADE_PIN_ABSORPTION = StoB(arg) ? strdup(arg.c_str()) : 0;
171 
172  if (cmd == historyCmd)
173  theParams->G4CASCADE_SHOW_HISTORY = StoB(arg) ? strdup(arg.c_str()) : 0;
174 
175  if (cmd == use3BodyCmd)
176  theParams->G4CASCADE_USE_3BODYMOM = StoB(arg) ? strdup(arg.c_str()) : 0;
177 
178  if (cmd == usePSCmd)
179  theParams->G4CASCADE_USE_PHASESPACE = StoB(arg) ? strdup(arg.c_str()) : 0;
180 
181  if (cmd == randomFileCmd)
182  theParams->G4CASCADE_RANDOM_FILE = arg.empty() ? 0 : strdup(arg.c_str());
183 
184  if (cmd == nucUseBestCmd)
185  theParams->G4NUCMODEL_USE_BEST = StoB(arg) ? strdup(arg.c_str()) : 0;
186 
187  if (cmd == nucRad2parCmd)
188  theParams->G4NUCMODEL_RAD_2PAR = strdup(arg.c_str());
189 
190  if (cmd == nucRadScaleCmd)
191  theParams->G4NUCMODEL_RAD_SCALE = strdup(arg.c_str());
192 
193  if (cmd == nucRadSmallCmd)
194  theParams->G4NUCMODEL_RAD_SMALL = strdup(arg.c_str());
195 
196  if (cmd == nucRadAlphaCmd)
197  theParams->G4NUCMODEL_RAD_ALPHA = strdup(arg.c_str());
198 
199  if (cmd == nucRadTrailingCmd)
200  theParams->G4NUCMODEL_RAD_TRAILING = strdup(arg.c_str());
201 
202  if (cmd == nucFermiScaleCmd)
203  theParams->G4NUCMODEL_FERMI_SCALE = strdup(arg.c_str());
204 
205  if (cmd == nucXsecScaleCmd)
206  theParams->G4NUCMODEL_XSEC_SCALE = strdup(arg.c_str());
207 
208  if (cmd == nucGammaQDCmd)
209  theParams->G4NUCMODEL_GAMMAQD = strdup(arg.c_str());
210 
211  if (cmd == coalDPmax2Cmd)
212  theParams->DPMAX_2CLUSTER = strdup(arg.c_str());
213 
214  if (cmd == coalDPmax3Cmd)
215  theParams->DPMAX_3CLUSTER = strdup(arg.c_str());
216 
217  if (cmd == coalDPmax4Cmd)
218  theParams->DPMAX_4CLUSTER = strdup(arg.c_str());
219 
220  theParams->Initialize(); // Update numerical values from settings
221 }
const char * G4NUCMODEL_USE_BEST
void DumpConfig(std::ostream &os) const
G4UIcmdWithADouble * nucRad2parCmd
const char * G4NUCMODEL_RAD_SMALL
G4UIcommand * FindPath(const char *commandPath) const
const char * G4CASCADE_VERBOSE
const char * G4CASCADE_SHOW_HISTORY
G4CascadeParameters * theParams
G4UIcmdWithADouble * nucRadAlphaCmd
const char * G4NUCMODEL_XSEC_SCALE
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4bool StoB(G4String s)
G4UIcmdWithADouble * nucFermiScaleCmd
G4String & prepend(const char *)
const char * G4CASCADE_DO_COALESCENCE
G4UIcmdWithADouble * nucRadSmallCmd
const char * G4NUCMODEL_RAD_TRAILING
G4GLOB_DLL std::ostream G4cout
G4UIcmdWithAnInteger * verboseCmd
const char * G4NUCMODEL_RAD_2PAR
const char * G4NUCMODEL_RAD_SCALE
const char * G4NUCMODEL_FERMI_SCALE
G4UIcmdWithADouble * nucRadScaleCmd
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
const char * G4CASCADE_PIN_ABSORPTION
G4UIcmdWithADouble * coalDPmax2Cmd
G4UIcmdWithADouble * nucXsecScaleCmd
const char * G4CASCADE_CHECK_ECONS
G4UIcmdWithoutParameter * reportCmd
G4UIcmdWithADouble * nucRadTrailingCmd
G4UIcmdWithADouble * nucGammaQDCmd
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:206
const char * G4CASCADE_USE_3BODYMOM
G4String & append(const G4String &)
G4CascadeParamMessenger(G4CascadeParameters *params)
const char * G4CASCADE_USE_PRECOMPOUND
const char * G4CASCADE_USE_PHASESPACE
const char * G4CASCADE_RANDOM_FILE
G4UIcmdWithADouble * coalDPmax3Cmd
void CreateDirectory(const char *path, const char *desc)
const char * G4NUCMODEL_GAMMAQD
const char * G4NUCMODEL_RAD_ALPHA
G4UIcmdWithADouble * coalDPmax4Cmd
G4UIcmdWithAString * randomFileCmd