source: trunk/source/processes/electromagnetic/utils/src/G4EnergyLossMessenger.cc@ 877

Last change on this file since 877 was 819, checked in by garnier, 17 years ago

import all except CVS

File size: 14.1 KB
Line 
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//
27// $Id: G4EnergyLossMessenger.cc,v 1.29 2007/06/11 14:56:51 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-01-patch-02 $
29//
30// -------------------------------------------------------------------
31//
32// GEANT4 Class file
33//
34// File name: G4EnergyLossMessenger
35//
36// Author: Michel Maire
37//
38// Creation date: 22-06-2000
39//
40// Modifications:
41// 10-01-06 SetStepLimits -> SetStepFunction (V.Ivanchenko)
42// 10-01-06 PreciseRange -> CSDARange (V.Ivanchenko)
43// 10-05-06 Add command MscStepLimit (V.Ivanchenko)
44// 10-10-06 Add DEDXBinning command (V.Ivanchenko)
45// 07-02-07 Add MscLateralDisplacement command (V.Ivanchenko)
46// 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko)
47// 15-03-07 Send a message "/run/physicsModified" if reinitialisation
48// is needed after the command (V.Ivanchenko)
49// 16-03-07 modify /process/eLoss/minsubsec command (V.Ivanchenko)
50// 18-05-07 add /process/msc directory and commands (V.Ivanchenko)
51//
52// -------------------------------------------------------------------
53//
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
57
58#include "G4EnergyLossMessenger.hh"
59
60#include "G4VEnergyLoss.hh"
61
62#include "G4UIdirectory.hh"
63#include "G4UIcommand.hh"
64#include "G4UIparameter.hh"
65#include "G4UIcmdWithABool.hh"
66#include "G4UIcmdWithAnInteger.hh"
67#include "G4UIcmdWithADouble.hh"
68#include "G4UIcmdWithADoubleAndUnit.hh"
69#include "G4UIcmdWithAString.hh"
70#include "G4EmProcessOptions.hh"
71#include "G4UImanager.hh"
72#include "G4MscStepLimitType.hh"
73#include "G4EmProcessOptions.hh"
74
75#include <sstream>
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78
79G4EnergyLossMessenger::G4EnergyLossMessenger()
80{
81 opt = 0;
82 eLossDirectory = new G4UIdirectory("/process/eLoss/");
83 eLossDirectory->SetGuidance("Commands for EM processes.");
84 mscDirectory = new G4UIdirectory("/process/msc/");
85 mscDirectory->SetGuidance("Commands for EM scattering processes.");
86
87 RndmStepCmd = new G4UIcmdWithABool("/process/eLoss/rndmStep",this);
88 RndmStepCmd->SetGuidance("Randomize the proposed step by eLoss.");
89 RndmStepCmd->SetParameterName("choice",true);
90 RndmStepCmd->SetDefaultValue(false);
91 RndmStepCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
92
93 EnlossFlucCmd = new G4UIcmdWithABool("/process/eLoss/fluct",this);
94 EnlossFlucCmd->SetGuidance("Switch true/false the energy loss fluctuations.");
95 EnlossFlucCmd->SetParameterName("choice",true);
96 EnlossFlucCmd->SetDefaultValue(true);
97 EnlossFlucCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
98
99 SubSecCmd = new G4UIcmdWithABool("/process/eLoss/subsec",this);
100 SubSecCmd->SetGuidance("Switch true/false the subcutoff generation.");
101 SubSecCmd->SetParameterName("choice",true);
102 SubSecCmd->SetDefaultValue(true);
103 SubSecCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
104
105 MinSubSecCmd = new G4UIcmdWithADouble("/process/eLoss/minsubsec",this);
106 MinSubSecCmd->SetGuidance("Set the ratio subcut/cut ");
107 MinSubSecCmd->SetParameterName("rcmin",true);
108 MinSubSecCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
109
110 StepFuncCmd = new G4UIcommand("/process/eLoss/StepFunction",this);
111 StepFuncCmd->SetGuidance("Set the energy loss step limitation parameters.");
112 StepFuncCmd->SetGuidance(" dRoverR : max Range variation per step");
113 StepFuncCmd->SetGuidance(" finalRange: range for final step");
114
115 G4UIparameter* dRoverRPrm = new G4UIparameter("dRoverR",'d',false);
116 dRoverRPrm->SetGuidance("max Range variation per step (fractional number)");
117 dRoverRPrm->SetParameterRange("dRoverR>0. && dRoverR<=1.");
118 StepFuncCmd->SetParameter(dRoverRPrm);
119
120 G4UIparameter* finalRangePrm = new G4UIparameter("finalRange",'d',false);
121 finalRangePrm->SetGuidance("range for final step");
122 finalRangePrm->SetParameterRange("finalRange>0.");
123 StepFuncCmd->SetParameter(finalRangePrm);
124
125 G4UIparameter* unitPrm = new G4UIparameter("unit",'s',true);
126 unitPrm->SetGuidance("unit of finalRange");
127 unitPrm->SetDefaultValue("mm");
128 G4String unitCandidates =
129 G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
130 unitPrm->SetParameterCandidates(unitCandidates);
131
132 StepFuncCmd->SetParameter(unitPrm);
133 StepFuncCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
134
135 MinEnCmd = new G4UIcmdWithADoubleAndUnit("/process/eLoss/minKinEnergy",this);
136 MinEnCmd->SetGuidance("Set the min kinetic energy");
137 MinEnCmd->SetParameterName("emin",true);
138 MinEnCmd->SetUnitCategory("Energy");
139 MinEnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
140
141 MaxEnCmd = new G4UIcmdWithADoubleAndUnit("/process/eLoss/maxKinEnergy",this);
142 MaxEnCmd->SetGuidance("Set the max kinetic energy");
143 MaxEnCmd->SetParameterName("emax",true);
144 MaxEnCmd->SetUnitCategory("Energy");
145 MaxEnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
146
147 IntegCmd = new G4UIcmdWithABool("/process/eLoss/integral",this);
148 IntegCmd->SetGuidance("Switch true/false the integration of cross section over step.");
149 IntegCmd->SetParameterName("integ",true);
150 IntegCmd->SetDefaultValue(true);
151 IntegCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
152
153 rangeCmd = new G4UIcmdWithABool("/process/eLoss/CSDARange",this);
154 rangeCmd->SetGuidance("Switch true/false the precise range calculation.");
155 rangeCmd->SetParameterName("range",true);
156 rangeCmd->SetDefaultValue(true);
157 rangeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
158
159 lpmCmd = new G4UIcmdWithABool("/process/eLoss/LPM",this);
160 lpmCmd->SetGuidance("Switch true/false the LPM effect calculation.");
161 lpmCmd->SetParameterName("lpm",true);
162 lpmCmd->SetDefaultValue(true);
163 lpmCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
164
165 dedxCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsDEDX",this);
166 dedxCmd->SetGuidance("Set number of bins for DEDX tables.");
167 dedxCmd->SetParameterName("binsDEDX",true);
168 dedxCmd->SetDefaultValue(120);
169 dedxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
170
171 lamCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsLambda",this);
172 lamCmd->SetGuidance("Set number of bins for Lambda tables.");
173 lamCmd->SetParameterName("binsL",true);
174 lamCmd->SetDefaultValue(120);
175 lamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
176
177 verCmd = new G4UIcmdWithAnInteger("/process/eLoss/verbose",this);
178 verCmd->SetGuidance("Set verbose level for EM physics.");
179 verCmd->SetParameterName("verb",true);
180 verCmd->SetDefaultValue(1);
181 verCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
182
183 lllCmd = new G4UIcmdWithADouble("/process/eLoss/linLossLimit",this);
184 lllCmd->SetGuidance("Set linearLossLimit parameter.");
185 lllCmd->SetParameterName("linlim",true);
186 lllCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
187
188 labCmd = new G4UIcmdWithADouble("/process/eLoss/lambdaFactor",this);
189 labCmd->SetGuidance("Set lambdaFactor parameter.");
190 labCmd->SetParameterName("Fl",true);
191 labCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
192
193 mscCmd = new G4UIcmdWithAString("/process/msc/StepLimit",this);
194 mscCmd->SetGuidance("Set msc step limitation type.");
195 mscCmd->SetParameterName("StepLim",true);
196 mscCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
197
198 latCmd = new G4UIcmdWithABool("/process/msc/LateralDisplacement",this);
199 latCmd->SetGuidance("Switch true/false sampling of latra dislacent.");
200 latCmd->SetParameterName("lat",true);
201 latCmd->SetDefaultValue(true);
202 latCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
203
204 frCmd = new G4UIcmdWithADouble("/process/msc/RangeFactor",this);
205 frCmd->SetGuidance("Set RangeFactor parameter for msc process.");
206 frCmd->SetParameterName("Fr",true);
207 frCmd->SetRange("Fr>0");
208 frCmd->SetDefaultValue(0.02);
209 frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
210
211 fgCmd = new G4UIcmdWithADouble("/process/msc/GeomFactor",this);
212 fgCmd->SetGuidance("Set GeomFactor parameter for msc process.");
213 fgCmd->SetParameterName("Fg",true);
214 fgCmd->SetRange("Fg>0");
215 fgCmd->SetDefaultValue(3.5);
216 fgCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
217
218 skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
219 skinCmd->SetGuidance("Set skin parameter for multiple scattering.");
220 skinCmd->SetParameterName("skin",true);
221 skinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
222
223}
224
225//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
226
227G4EnergyLossMessenger::~G4EnergyLossMessenger()
228{
229 delete opt;
230 delete RndmStepCmd;
231 delete EnlossFlucCmd;
232 delete SubSecCmd;
233 delete MinSubSecCmd;
234 delete StepFuncCmd;
235 delete eLossDirectory;
236 delete mscDirectory;
237 delete MinEnCmd;
238 delete MaxEnCmd;
239 delete IntegCmd;
240 delete rangeCmd;
241 delete lpmCmd;
242 delete latCmd;
243 delete verCmd;
244 delete mscCmd;
245 delete dedxCmd;
246 delete frCmd;
247 delete fgCmd;
248 delete lllCmd;
249 delete lamCmd;
250 delete labCmd;
251 delete skinCmd;
252}
253
254//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
255
256void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
257{
258 if(!opt) opt = new G4EmProcessOptions();
259
260 if (command == RndmStepCmd) {
261 G4VEnergyLoss::SetRndmStep(RndmStepCmd->GetNewBoolValue(newValue));
262 opt->SetRandomStep(RndmStepCmd->GetNewBoolValue(newValue));
263 }
264
265 if (command == EnlossFlucCmd) {
266 G4VEnergyLoss::SetEnlossFluc(EnlossFlucCmd->GetNewBoolValue(newValue));
267 opt->SetLossFluctuations(EnlossFlucCmd->GetNewBoolValue(newValue));
268 }
269
270 if (command == SubSecCmd) {
271 G4VEnergyLoss::SetSubSec(SubSecCmd->GetNewBoolValue(newValue));
272 opt->SetSubCutoff(SubSecCmd->GetNewBoolValue(newValue));
273 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
274 }
275
276 if (command == MinSubSecCmd) {
277 opt->SetMinSubRange(MinSubSecCmd->GetNewDoubleValue(newValue));
278 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
279 }
280
281 if (command == StepFuncCmd) {
282 G4double v1,v2;
283 G4String unt;
284 std::istringstream is(newValue);
285 is >> v1 >> v2 >> unt;
286 v2 *= G4UIcommand::ValueOf(unt);
287 G4VEnergyLoss::SetStepFunction(v1,v2);
288 opt->SetStepFunction(v1,v2);
289 }
290
291 if (command == mscCmd) {
292 if(newValue == "Minimal")
293 opt->SetMscStepLimitation(fMinimal);
294
295 else if(newValue == "UseDistanceToBoundary")
296 opt->SetMscStepLimitation(fUseDistanceToBoundary);
297
298 else if(newValue == "UseSafety")
299 opt->SetMscStepLimitation(fUseSafety);
300
301 else {
302 G4cout << "### G4EnergyLossMessenger WARNING: StepLimit type <"
303 << newValue << "> unknown!" << G4endl;
304 return;
305 }
306 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
307 }
308
309 if (command == MinEnCmd) {
310 opt->SetMinEnergy(MinEnCmd->GetNewDoubleValue(newValue));
311 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
312 }
313
314 if (command == MaxEnCmd) {
315 opt->SetMaxEnergy(MaxEnCmd->GetNewDoubleValue(newValue));
316 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
317 }
318
319 if (command == IntegCmd)
320 opt->SetIntegral(IntegCmd->GetNewBoolValue(newValue));
321
322 if (command == rangeCmd) {
323 opt->SetBuildCSDARange(rangeCmd->GetNewBoolValue(newValue));
324 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
325 }
326
327 if (command == lpmCmd) {
328 opt->SetLPMFlag(lpmCmd->GetNewBoolValue(newValue));
329 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
330 }
331
332 if (command == latCmd) {
333 opt->SetMscLateralDisplacement(latCmd->GetNewBoolValue(newValue));
334 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
335 }
336
337 if (command == verCmd)
338 opt->SetVerbose(verCmd->GetNewIntValue(newValue));
339
340 if (command == lllCmd)
341 opt->SetLinearLossLimit(lllCmd->GetNewDoubleValue(newValue));
342
343 if (command == labCmd)
344 opt->SetLambdaFactor(labCmd->GetNewDoubleValue(newValue));
345
346 if (command == skinCmd) {
347 opt->SetSkin(skinCmd->GetNewDoubleValue(newValue));
348 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
349 }
350 if (command == dedxCmd) {
351 opt->SetDEDXBinning(dedxCmd->GetNewIntValue(newValue));
352 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
353 }
354 if (command == lamCmd) {
355 opt->SetLambdaBinning(lamCmd->GetNewIntValue(newValue));
356 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
357 }
358 if (command == frCmd) {
359 opt->SetMscRangeFactor(frCmd->GetNewDoubleValue(newValue));
360 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
361 }
362 if (command == fgCmd) {
363 opt->SetMscGeomFactor(fgCmd->GetNewDoubleValue(newValue));
364 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
365 }
366}
367
368//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.