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

Last change on this file since 1315 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 17.2 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.38 2009/10/29 19:25:28 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-03 $
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// 11-03-08 add /process/em directory and commands (V.Ivanchenko)
52//
53// -------------------------------------------------------------------
54//
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58
59#include "G4EnergyLossMessenger.hh"
60
61#include "G4VEnergyLoss.hh"
62
63#include "G4UIdirectory.hh"
64#include "G4UIcommand.hh"
65#include "G4UIparameter.hh"
66#include "G4UIcmdWithABool.hh"
67#include "G4UIcmdWithAnInteger.hh"
68#include "G4UIcmdWithADouble.hh"
69#include "G4UIcmdWithADoubleAndUnit.hh"
70#include "G4UIcmdWithAString.hh"
71#include "G4EmProcessOptions.hh"
72#include "G4UImanager.hh"
73#include "G4MscStepLimitType.hh"
74#include "G4EmProcessOptions.hh"
75
76#include <sstream>
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79
80G4EnergyLossMessenger::G4EnergyLossMessenger()
81{
82 opt = 0;
83 eLossDirectory = new G4UIdirectory("/process/eLoss/");
84 eLossDirectory->SetGuidance("Commands for EM processes.");
85 mscDirectory = new G4UIdirectory("/process/msc/");
86 mscDirectory->SetGuidance("Commands for EM scattering processes.");
87 emDirectory = new G4UIdirectory("/process/em/");
88 emDirectory->SetGuidance("General commands for EM processes.");
89
90 RndmStepCmd = new G4UIcmdWithABool("/process/eLoss/rndmStep",this);
91 RndmStepCmd->SetGuidance("Randomize the proposed step by eLoss.");
92 RndmStepCmd->SetParameterName("choice",true);
93 RndmStepCmd->SetDefaultValue(false);
94 RndmStepCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
95
96 EnlossFlucCmd = new G4UIcmdWithABool("/process/eLoss/fluct",this);
97 EnlossFlucCmd->SetGuidance("Switch true/false the energy loss fluctuations.");
98 EnlossFlucCmd->SetParameterName("choice",true);
99 EnlossFlucCmd->SetDefaultValue(true);
100 EnlossFlucCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
101
102 SubSecCmd = new G4UIcmdWithABool("/process/eLoss/subsec",this);
103 SubSecCmd->SetGuidance("Switch true/false the subcutoff generation.");
104 SubSecCmd->SetParameterName("choice",true);
105 SubSecCmd->SetDefaultValue(true);
106 SubSecCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
107
108 MinSubSecCmd = new G4UIcmdWithADouble("/process/eLoss/minsubsec",this);
109 MinSubSecCmd->SetGuidance("Set the ratio subcut/cut ");
110 MinSubSecCmd->SetParameterName("rcmin",true);
111 MinSubSecCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
112
113 StepFuncCmd = new G4UIcommand("/process/eLoss/StepFunction",this);
114 StepFuncCmd->SetGuidance("Set the energy loss step limitation parameters.");
115 StepFuncCmd->SetGuidance(" dRoverR : max Range variation per step");
116 StepFuncCmd->SetGuidance(" finalRange: range for final step");
117
118 G4UIparameter* dRoverRPrm = new G4UIparameter("dRoverR",'d',false);
119 dRoverRPrm->SetGuidance("max Range variation per step (fractional number)");
120 dRoverRPrm->SetParameterRange("dRoverR>0. && dRoverR<=1.");
121 StepFuncCmd->SetParameter(dRoverRPrm);
122
123 G4UIparameter* finalRangePrm = new G4UIparameter("finalRange",'d',false);
124 finalRangePrm->SetGuidance("range for final step");
125 finalRangePrm->SetParameterRange("finalRange>0.");
126 StepFuncCmd->SetParameter(finalRangePrm);
127
128 G4UIparameter* unitPrm = new G4UIparameter("unit",'s',true);
129 unitPrm->SetGuidance("unit of finalRange");
130 unitPrm->SetDefaultValue("mm");
131 G4String unitCandidates =
132 G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
133 unitPrm->SetParameterCandidates(unitCandidates);
134
135 StepFuncCmd->SetParameter(unitPrm);
136 StepFuncCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
137
138 MinEnCmd = new G4UIcmdWithADoubleAndUnit("/process/eLoss/minKinEnergy",this);
139 MinEnCmd->SetGuidance("Set the min kinetic energy");
140 MinEnCmd->SetParameterName("emin",true);
141 MinEnCmd->SetUnitCategory("Energy");
142 MinEnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
143
144 MaxEnCmd = new G4UIcmdWithADoubleAndUnit("/process/eLoss/maxKinEnergy",this);
145 MaxEnCmd->SetGuidance("Set the max kinetic energy");
146 MaxEnCmd->SetParameterName("emax",true);
147 MaxEnCmd->SetUnitCategory("Energy");
148 MaxEnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
149
150 IntegCmd = new G4UIcmdWithABool("/process/eLoss/integral",this);
151 IntegCmd->SetGuidance("Switch true/false the integral option");
152 IntegCmd->SetParameterName("integ",true);
153 IntegCmd->SetDefaultValue(true);
154 IntegCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
155
156 rangeCmd = new G4UIcmdWithABool("/process/eLoss/CSDARange",this);
157 rangeCmd->SetGuidance("Switch true/false the CSDA range calculation");
158 rangeCmd->SetParameterName("range",true);
159 rangeCmd->SetDefaultValue(true);
160 rangeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
161
162 lpmCmd = new G4UIcmdWithABool("/process/eLoss/LPM",this);
163 lpmCmd->SetGuidance("The flag of the LPM effect calculation");
164 lpmCmd->SetParameterName("lpm",true);
165 lpmCmd->SetDefaultValue(true);
166 lpmCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
167
168 splCmd = new G4UIcmdWithABool("/process/em/spline",this);
169 splCmd->SetGuidance("The flag of usage spline for Physics Vectors");
170 splCmd->SetParameterName("spl",true);
171 splCmd->SetDefaultValue(false);
172 splCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
173
174 aplCmd = new G4UIcmdWithABool("/process/em/applyCuts",this);
175 aplCmd->SetGuidance("The flag to Apply Cuts for gamma processes");
176 aplCmd->SetParameterName("apl",true);
177 aplCmd->SetDefaultValue(false);
178 aplCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
179
180 deexCmd = new G4UIcommand("/process/em/deexcitation",this);
181 deexCmd->SetGuidance("Set deexcitation flag per process and G4Region.");
182 deexCmd->SetGuidance(" procName : process name");
183 deexCmd->SetGuidance(" flag : flag");
184 deexCmd->SetGuidance(" regName : G4Region name");
185
186 G4UIparameter* pName = new G4UIparameter("pName",'s',false);
187 deexCmd->SetParameter(pName);
188
189 G4UIparameter* flag = new G4UIparameter("flag",'s',false);
190 deexCmd->SetParameter(flag);
191
192 G4UIparameter* regName = new G4UIparameter("regName",'s',false);
193 deexCmd->SetParameter(regName);
194
195 dedxCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsDEDX",this);
196 dedxCmd->SetGuidance("Set number of bins for DEDX tables");
197 dedxCmd->SetParameterName("binsDEDX",true);
198 dedxCmd->SetDefaultValue(77);
199 dedxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
200
201 lamCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsLambda",this);
202 lamCmd->SetGuidance("Set number of bins for Lambda tables");
203 lamCmd->SetParameterName("binsL",true);
204 lamCmd->SetDefaultValue(77);
205 lamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
206
207 verCmd = new G4UIcmdWithAnInteger("/process/eLoss/verbose",this);
208 verCmd->SetGuidance("Set verbose level for EM physics");
209 verCmd->SetParameterName("verb",true);
210 verCmd->SetDefaultValue(1);
211 verCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
212
213 ver1Cmd = new G4UIcmdWithAnInteger("/process/em/verbose",this);
214 ver1Cmd->SetGuidance("Set verbose level for EM physics");
215 ver1Cmd->SetParameterName("verb1",true);
216 ver1Cmd->SetDefaultValue(1);
217 ver1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
218
219 lllCmd = new G4UIcmdWithADouble("/process/eLoss/linLossLimit",this);
220 lllCmd->SetGuidance("Set linearLossLimit parameter");
221 lllCmd->SetParameterName("linlim",true);
222 lllCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
223
224 labCmd = new G4UIcmdWithADouble("/process/eLoss/LambdaFactor",this);
225 labCmd->SetGuidance("Set lambdaFactor parameter for integral option");
226 labCmd->SetParameterName("Fl",true);
227 labCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
228
229 mscCmd = new G4UIcmdWithAString("/process/msc/StepLimit",this);
230 mscCmd->SetGuidance("Set msc step limitation type");
231 mscCmd->SetParameterName("StepLim",true);
232 mscCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
233
234 latCmd = new G4UIcmdWithABool("/process/msc/LateralDisplacement",this);
235 latCmd->SetGuidance("Set flag of sampling of lateral displacement");
236 latCmd->SetParameterName("lat",true);
237 latCmd->SetDefaultValue(true);
238 latCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
239
240 frCmd = new G4UIcmdWithADouble("/process/msc/RangeFactor",this);
241 frCmd->SetGuidance("Set RangeFactor parameter for msc processes");
242 frCmd->SetParameterName("Fr",true);
243 frCmd->SetRange("Fr>0");
244 frCmd->SetDefaultValue(0.04);
245 frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
246
247 fgCmd = new G4UIcmdWithADouble("/process/msc/GeomFactor",this);
248 fgCmd->SetGuidance("Set GeomFactor parameter for msc processes");
249 fgCmd->SetParameterName("Fg",true);
250 fgCmd->SetRange("Fg>0");
251 fgCmd->SetDefaultValue(3.5);
252 fgCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
253
254 mscfCmd = new G4UIcmdWithADouble("/process/msc/FactorForAngleLimit",this);
255 mscfCmd->SetGuidance("Set factor for computation of a limit for -t (invariant trasfer)");
256 mscfCmd->SetParameterName("Fact",true);
257 mscfCmd->SetRange("Fact>0");
258 mscfCmd->SetDefaultValue(1.);
259 mscfCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
260
261 skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
262 skinCmd->SetGuidance("Set skin parameter for msc processes");
263 skinCmd->SetParameterName("skin",true);
264 skinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
265
266 angCmd = new G4UIcmdWithADoubleAndUnit("/process/msc/ThetaLimit",this);
267 angCmd->SetGuidance("Set the limit on the polar angle for msc and single scattering");
268 angCmd->SetParameterName("theta",true);
269 angCmd->SetUnitCategory("Angle");
270 angCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
271}
272
273//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
274
275G4EnergyLossMessenger::~G4EnergyLossMessenger()
276{
277 delete opt;
278 delete RndmStepCmd;
279 delete EnlossFlucCmd;
280 delete SubSecCmd;
281 delete MinSubSecCmd;
282 delete StepFuncCmd;
283 delete deexCmd;
284 delete eLossDirectory;
285 delete mscDirectory;
286 delete emDirectory;
287 delete MinEnCmd;
288 delete MaxEnCmd;
289 delete IntegCmd;
290 delete rangeCmd;
291 delete lpmCmd;
292 delete splCmd;
293 delete aplCmd;
294 delete latCmd;
295 delete verCmd;
296 delete ver1Cmd;
297 delete mscCmd;
298 delete dedxCmd;
299 delete frCmd;
300 delete fgCmd;
301 delete lllCmd;
302 delete lamCmd;
303 delete labCmd;
304 delete skinCmd;
305 delete angCmd;
306 delete mscfCmd;
307}
308
309//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
310
311void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
312{
313 if(!opt) opt = new G4EmProcessOptions();
314
315 if (command == RndmStepCmd) {
316 G4VEnergyLoss::SetRndmStep(RndmStepCmd->GetNewBoolValue(newValue));
317 opt->SetRandomStep(RndmStepCmd->GetNewBoolValue(newValue));
318 }
319
320 if (command == EnlossFlucCmd) {
321 G4VEnergyLoss::SetEnlossFluc(EnlossFlucCmd->GetNewBoolValue(newValue));
322 opt->SetLossFluctuations(EnlossFlucCmd->GetNewBoolValue(newValue));
323 }
324
325 if (command == SubSecCmd) {
326 G4VEnergyLoss::SetSubSec(SubSecCmd->GetNewBoolValue(newValue));
327 opt->SetSubCutoff(SubSecCmd->GetNewBoolValue(newValue));
328 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
329 }
330
331 if (command == MinSubSecCmd) {
332 opt->SetMinSubRange(MinSubSecCmd->GetNewDoubleValue(newValue));
333 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
334 }
335
336 if (command == StepFuncCmd) {
337 G4double v1,v2;
338 G4String unt;
339 std::istringstream is(newValue);
340 is >> v1 >> v2 >> unt;
341 v2 *= G4UIcommand::ValueOf(unt);
342 G4VEnergyLoss::SetStepFunction(v1,v2);
343 opt->SetStepFunction(v1,v2);
344 }
345
346 if (command == deexCmd) {
347 G4String s1 (""), s2(""), s3("");
348 G4bool b = false;
349 std::istringstream is(newValue);
350 is >> s1 >> s2 >> s3;
351 if(s2 == "true") b = true;
352 opt->ActivateDeexcitation(s1,b,s3);
353 }
354
355 if (command == mscCmd) {
356 if(newValue == "Minimal")
357 opt->SetMscStepLimitation(fMinimal);
358
359 else if(newValue == "UseDistanceToBoundary")
360 opt->SetMscStepLimitation(fUseDistanceToBoundary);
361
362 else if(newValue == "UseSafety")
363 opt->SetMscStepLimitation(fUseSafety);
364
365 else {
366 G4cout << "### G4EnergyLossMessenger WARNING: StepLimit type <"
367 << newValue << "> unknown!" << G4endl;
368 return;
369 }
370 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
371 }
372
373 if (command == MinEnCmd) {
374 opt->SetMinEnergy(MinEnCmd->GetNewDoubleValue(newValue));
375 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
376 }
377
378 if (command == MaxEnCmd) {
379 opt->SetMaxEnergy(MaxEnCmd->GetNewDoubleValue(newValue));
380 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
381 }
382
383 if (command == IntegCmd) {
384 opt->SetIntegral(IntegCmd->GetNewBoolValue(newValue));
385 }
386 if (command == rangeCmd) {
387 opt->SetBuildCSDARange(rangeCmd->GetNewBoolValue(newValue));
388 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
389 }
390
391 if (command == lpmCmd) {
392 opt->SetLPMFlag(lpmCmd->GetNewBoolValue(newValue));
393 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
394 }
395
396 if (command == splCmd) {
397 opt->SetSplineFlag(splCmd->GetNewBoolValue(newValue));
398 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
399 }
400
401 if (command == aplCmd) {
402 opt->SetApplyCuts(aplCmd->GetNewBoolValue(newValue));
403 }
404
405 if (command == latCmd) {
406 opt->SetMscLateralDisplacement(latCmd->GetNewBoolValue(newValue));
407 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
408 }
409
410 if (command == verCmd) {
411 opt->SetVerbose(verCmd->GetNewIntValue(newValue));
412 }
413 if (command == ver1Cmd) {
414 opt->SetVerbose(ver1Cmd->GetNewIntValue(newValue));
415 }
416 if (command == lllCmd) {
417 opt->SetLinearLossLimit(lllCmd->GetNewDoubleValue(newValue));
418 }
419 if (command == labCmd) {
420 opt->SetLambdaFactor(labCmd->GetNewDoubleValue(newValue));
421 }
422 if (command == skinCmd) {
423 opt->SetSkin(skinCmd->GetNewDoubleValue(newValue));
424 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
425 }
426 if (command == dedxCmd) {
427 opt->SetDEDXBinning(dedxCmd->GetNewIntValue(newValue));
428 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
429 }
430 if (command == lamCmd) {
431 opt->SetLambdaBinning(lamCmd->GetNewIntValue(newValue));
432 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
433 }
434 if (command == frCmd) {
435 opt->SetMscRangeFactor(frCmd->GetNewDoubleValue(newValue));
436 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
437 }
438 if (command == fgCmd) {
439 opt->SetMscGeomFactor(fgCmd->GetNewDoubleValue(newValue));
440 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
441 }
442 if (command == mscfCmd) {
443 opt->SetFactorForAngleLimit(mscfCmd->GetNewDoubleValue(newValue));
444 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
445 }
446 if (command == angCmd) {
447 opt->SetPolarAngleLimit(angCmd->GetNewDoubleValue(newValue));
448 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
449 }
450}
451
452//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.