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

Last change on this file since 980 was 961, checked in by garnier, 17 years ago

update processes

File size: 16.7 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.37 2009/02/18 14:43:27 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-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// 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(120);
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(120);
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.02);
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 skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
255 skinCmd->SetGuidance("Set skin parameter for msc processes");
256 skinCmd->SetParameterName("skin",true);
257 skinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
258
259 angCmd = new G4UIcmdWithADoubleAndUnit("/process/msc/ThetaLimit",this);
260 angCmd->SetGuidance("Set the limit on the polar angle");
261 angCmd->SetParameterName("theta",true);
262 angCmd->SetUnitCategory("Angle");
263 angCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
264}
265
266//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
267
268G4EnergyLossMessenger::~G4EnergyLossMessenger()
269{
270 delete opt;
271 delete RndmStepCmd;
272 delete EnlossFlucCmd;
273 delete SubSecCmd;
274 delete MinSubSecCmd;
275 delete StepFuncCmd;
276 delete deexCmd;
277 delete eLossDirectory;
278 delete mscDirectory;
279 delete emDirectory;
280 delete MinEnCmd;
281 delete MaxEnCmd;
282 delete IntegCmd;
283 delete rangeCmd;
284 delete lpmCmd;
285 delete splCmd;
286 delete aplCmd;
287 delete latCmd;
288 delete verCmd;
289 delete ver1Cmd;
290 delete mscCmd;
291 delete dedxCmd;
292 delete frCmd;
293 delete fgCmd;
294 delete lllCmd;
295 delete lamCmd;
296 delete labCmd;
297 delete skinCmd;
298 delete angCmd;
299}
300
301//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
302
303void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
304{
305 if(!opt) opt = new G4EmProcessOptions();
306
307 if (command == RndmStepCmd) {
308 G4VEnergyLoss::SetRndmStep(RndmStepCmd->GetNewBoolValue(newValue));
309 opt->SetRandomStep(RndmStepCmd->GetNewBoolValue(newValue));
310 }
311
312 if (command == EnlossFlucCmd) {
313 G4VEnergyLoss::SetEnlossFluc(EnlossFlucCmd->GetNewBoolValue(newValue));
314 opt->SetLossFluctuations(EnlossFlucCmd->GetNewBoolValue(newValue));
315 }
316
317 if (command == SubSecCmd) {
318 G4VEnergyLoss::SetSubSec(SubSecCmd->GetNewBoolValue(newValue));
319 opt->SetSubCutoff(SubSecCmd->GetNewBoolValue(newValue));
320 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
321 }
322
323 if (command == MinSubSecCmd) {
324 opt->SetMinSubRange(MinSubSecCmd->GetNewDoubleValue(newValue));
325 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
326 }
327
328 if (command == StepFuncCmd) {
329 G4double v1,v2;
330 G4String unt;
331 std::istringstream is(newValue);
332 is >> v1 >> v2 >> unt;
333 v2 *= G4UIcommand::ValueOf(unt);
334 G4VEnergyLoss::SetStepFunction(v1,v2);
335 opt->SetStepFunction(v1,v2);
336 }
337
338 if (command == deexCmd) {
339 G4String s1 (""), s2(""), s3("");
340 G4bool b = false;
341 std::istringstream is(newValue);
342 is >> s1 >> s2 >> s3;
343 if(s2 == "true") b = true;
344 opt->ActivateDeexcitation(s1,b,s3);
345 }
346
347 if (command == mscCmd) {
348 if(newValue == "Minimal")
349 opt->SetMscStepLimitation(fMinimal);
350
351 else if(newValue == "UseDistanceToBoundary")
352 opt->SetMscStepLimitation(fUseDistanceToBoundary);
353
354 else if(newValue == "UseSafety")
355 opt->SetMscStepLimitation(fUseSafety);
356
357 else {
358 G4cout << "### G4EnergyLossMessenger WARNING: StepLimit type <"
359 << newValue << "> unknown!" << G4endl;
360 return;
361 }
362 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
363 }
364
365 if (command == MinEnCmd) {
366 opt->SetMinEnergy(MinEnCmd->GetNewDoubleValue(newValue));
367 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
368 }
369
370 if (command == MaxEnCmd) {
371 opt->SetMaxEnergy(MaxEnCmd->GetNewDoubleValue(newValue));
372 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
373 }
374
375 if (command == IntegCmd) {
376 opt->SetIntegral(IntegCmd->GetNewBoolValue(newValue));
377 }
378 if (command == rangeCmd) {
379 opt->SetBuildCSDARange(rangeCmd->GetNewBoolValue(newValue));
380 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
381 }
382
383 if (command == lpmCmd) {
384 opt->SetLPMFlag(lpmCmd->GetNewBoolValue(newValue));
385 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
386 }
387
388 if (command == splCmd) {
389 opt->SetSplineFlag(splCmd->GetNewBoolValue(newValue));
390 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
391 }
392
393 if (command == aplCmd) {
394 opt->SetApplyCuts(aplCmd->GetNewBoolValue(newValue));
395 }
396
397 if (command == latCmd) {
398 opt->SetMscLateralDisplacement(latCmd->GetNewBoolValue(newValue));
399 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
400 }
401
402 if (command == verCmd) {
403 opt->SetVerbose(verCmd->GetNewIntValue(newValue));
404 }
405 if (command == ver1Cmd) {
406 opt->SetVerbose(ver1Cmd->GetNewIntValue(newValue));
407 }
408 if (command == lllCmd) {
409 opt->SetLinearLossLimit(lllCmd->GetNewDoubleValue(newValue));
410 }
411 if (command == labCmd) {
412 opt->SetLambdaFactor(labCmd->GetNewDoubleValue(newValue));
413 }
414 if (command == skinCmd) {
415 opt->SetSkin(skinCmd->GetNewDoubleValue(newValue));
416 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
417 }
418 if (command == dedxCmd) {
419 opt->SetDEDXBinning(dedxCmd->GetNewIntValue(newValue));
420 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
421 }
422 if (command == lamCmd) {
423 opt->SetLambdaBinning(lamCmd->GetNewIntValue(newValue));
424 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
425 }
426 if (command == frCmd) {
427 opt->SetMscRangeFactor(frCmd->GetNewDoubleValue(newValue));
428 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
429 }
430 if (command == fgCmd) {
431 opt->SetMscGeomFactor(fgCmd->GetNewDoubleValue(newValue));
432 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
433 }
434 if (command == angCmd) {
435 opt->SetPolarAngleLimit(angCmd->GetNewDoubleValue(newValue));
436 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
437 }
438}
439
440//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.