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

Last change on this file since 1015 was 1007, checked in by garnier, 15 years ago

update to geant4.9.2

File size: 15.8 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.35 2008/10/20 13:27:45 vnivanch Exp $
28// GEANT4 tag $Name: geant4-09-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  dedxCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsDEDX",this);
181  dedxCmd->SetGuidance("Set number of bins for DEDX tables");
182  dedxCmd->SetParameterName("binsDEDX",true);
183  dedxCmd->SetDefaultValue(120);
184  dedxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
185
186  lamCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsLambda",this);
187  lamCmd->SetGuidance("Set number of bins for Lambda tables");
188  lamCmd->SetParameterName("binsL",true);
189  lamCmd->SetDefaultValue(120);
190  lamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
191
192  verCmd = new G4UIcmdWithAnInteger("/process/eLoss/verbose",this);
193  verCmd->SetGuidance("Set verbose level for EM physics");
194  verCmd->SetParameterName("verb",true);
195  verCmd->SetDefaultValue(1);
196  verCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
197
198  ver1Cmd = new G4UIcmdWithAnInteger("/process/em/verbose",this);
199  ver1Cmd->SetGuidance("Set verbose level for EM physics");
200  ver1Cmd->SetParameterName("verb1",true);
201  ver1Cmd->SetDefaultValue(1);
202  ver1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
203
204  lllCmd = new G4UIcmdWithADouble("/process/eLoss/linLossLimit",this);
205  lllCmd->SetGuidance("Set linearLossLimit parameter");
206  lllCmd->SetParameterName("linlim",true);
207  lllCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
208
209  labCmd = new G4UIcmdWithADouble("/process/eLoss/LambdaFactor",this);
210  labCmd->SetGuidance("Set lambdaFactor parameter for integral option");
211  labCmd->SetParameterName("Fl",true);
212  labCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
213
214  mscCmd = new G4UIcmdWithAString("/process/msc/StepLimit",this);
215  mscCmd->SetGuidance("Set msc step limitation type");
216  mscCmd->SetParameterName("StepLim",true);
217  mscCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
218
219  latCmd = new G4UIcmdWithABool("/process/msc/LateralDisplacement",this);
220  latCmd->SetGuidance("Set flag of sampling of lateral displacement");
221  latCmd->SetParameterName("lat",true);
222  latCmd->SetDefaultValue(true);
223  latCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
224
225  frCmd = new G4UIcmdWithADouble("/process/msc/RangeFactor",this);
226  frCmd->SetGuidance("Set RangeFactor parameter for msc processes");
227  frCmd->SetParameterName("Fr",true);
228  frCmd->SetRange("Fr>0");
229  frCmd->SetDefaultValue(0.02);
230  frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
231
232  fgCmd = new G4UIcmdWithADouble("/process/msc/GeomFactor",this);
233  fgCmd->SetGuidance("Set GeomFactor parameter for msc processes");
234  fgCmd->SetParameterName("Fg",true);
235  fgCmd->SetRange("Fg>0");
236  fgCmd->SetDefaultValue(3.5);
237  fgCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
238
239  skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
240  skinCmd->SetGuidance("Set skin parameter for msc processes");
241  skinCmd->SetParameterName("skin",true);
242  skinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
243
244  angCmd = new G4UIcmdWithADoubleAndUnit("/process/msc/ThetaLimit",this);
245  angCmd->SetGuidance("Set the limit on the polar angle");
246  angCmd->SetParameterName("theta",true);
247  angCmd->SetUnitCategory("Angle");
248  angCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
249}
250
251//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
252
253G4EnergyLossMessenger::~G4EnergyLossMessenger()
254{
255  delete opt;
256  delete RndmStepCmd;
257  delete EnlossFlucCmd;
258  delete SubSecCmd;
259  delete MinSubSecCmd;
260  delete StepFuncCmd;
261  delete eLossDirectory;
262  delete mscDirectory;
263  delete emDirectory;
264  delete MinEnCmd;
265  delete MaxEnCmd;
266  delete IntegCmd;
267  delete rangeCmd;
268  delete lpmCmd;
269  delete splCmd;
270  delete aplCmd;
271  delete latCmd;
272  delete verCmd;
273  delete ver1Cmd;
274  delete mscCmd;
275  delete dedxCmd;
276  delete frCmd;
277  delete fgCmd;
278  delete lllCmd;
279  delete lamCmd;
280  delete labCmd;
281  delete skinCmd;
282  delete angCmd;
283}
284
285//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
286
287void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
288{
289  if(!opt) opt = new G4EmProcessOptions();
290
291  if (command == RndmStepCmd) {
292    G4VEnergyLoss::SetRndmStep(RndmStepCmd->GetNewBoolValue(newValue));
293    opt->SetRandomStep(RndmStepCmd->GetNewBoolValue(newValue));
294  }
295
296  if (command == EnlossFlucCmd) {
297    G4VEnergyLoss::SetEnlossFluc(EnlossFlucCmd->GetNewBoolValue(newValue));
298    opt->SetLossFluctuations(EnlossFlucCmd->GetNewBoolValue(newValue));
299  }
300
301  if (command == SubSecCmd) {
302    G4VEnergyLoss::SetSubSec(SubSecCmd->GetNewBoolValue(newValue));
303    opt->SetSubCutoff(SubSecCmd->GetNewBoolValue(newValue));
304    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
305  }
306
307  if (command == MinSubSecCmd) {
308    opt->SetMinSubRange(MinSubSecCmd->GetNewDoubleValue(newValue));
309    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
310  }
311
312  if (command == StepFuncCmd) {
313    G4double v1,v2;
314    G4String unt;
315    std::istringstream is(newValue);
316    is >> v1 >> v2 >> unt;
317    v2 *= G4UIcommand::ValueOf(unt);
318    G4VEnergyLoss::SetStepFunction(v1,v2);
319    opt->SetStepFunction(v1,v2);
320  }
321
322  if (command == mscCmd) {
323    if(newValue == "Minimal") 
324      opt->SetMscStepLimitation(fMinimal);
325
326    else if(newValue == "UseDistanceToBoundary") 
327      opt->SetMscStepLimitation(fUseDistanceToBoundary);
328
329    else if(newValue == "UseSafety")
330      opt->SetMscStepLimitation(fUseSafety);
331
332    else {
333      G4cout << "### G4EnergyLossMessenger WARNING: StepLimit type <" 
334             << newValue << "> unknown!" << G4endl;
335      return;
336    }
337    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
338  }
339
340  if (command == MinEnCmd) {
341    opt->SetMinEnergy(MinEnCmd->GetNewDoubleValue(newValue));
342    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
343  }
344
345  if (command == MaxEnCmd) { 
346    opt->SetMaxEnergy(MaxEnCmd->GetNewDoubleValue(newValue));
347    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
348  } 
349
350  if (command == IntegCmd) {
351    opt->SetIntegral(IntegCmd->GetNewBoolValue(newValue));
352  }
353  if (command == rangeCmd) {
354    opt->SetBuildCSDARange(rangeCmd->GetNewBoolValue(newValue));
355    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
356  } 
357
358  if (command == lpmCmd) {
359    opt->SetLPMFlag(lpmCmd->GetNewBoolValue(newValue));
360    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
361  }
362
363  if (command == splCmd) {
364    opt->SetSplineFlag(splCmd->GetNewBoolValue(newValue));
365    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
366  }
367
368  if (command == aplCmd) {
369    opt->SetApplyCuts(aplCmd->GetNewBoolValue(newValue));
370  }
371
372  if (command == latCmd) {
373    opt->SetMscLateralDisplacement(latCmd->GetNewBoolValue(newValue));
374    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
375  }
376
377  if (command == verCmd) {
378    opt->SetVerbose(verCmd->GetNewIntValue(newValue));
379  }
380  if (command == ver1Cmd) {
381    opt->SetVerbose(ver1Cmd->GetNewIntValue(newValue));
382  }
383  if (command == lllCmd) {
384    opt->SetLinearLossLimit(lllCmd->GetNewDoubleValue(newValue));
385  }
386  if (command == labCmd) {
387    opt->SetLambdaFactor(labCmd->GetNewDoubleValue(newValue));
388  }
389  if (command == skinCmd) {
390    opt->SetSkin(skinCmd->GetNewDoubleValue(newValue));
391    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
392  } 
393  if (command == dedxCmd) { 
394    opt->SetDEDXBinning(dedxCmd->GetNewIntValue(newValue));
395    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
396  }
397  if (command == lamCmd) { 
398    opt->SetLambdaBinning(lamCmd->GetNewIntValue(newValue));
399    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
400  }
401  if (command == frCmd) {
402    opt->SetMscRangeFactor(frCmd->GetNewDoubleValue(newValue));
403    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
404  }
405  if (command == fgCmd) {
406    opt->SetMscGeomFactor(fgCmd->GetNewDoubleValue(newValue));
407    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
408  }
409  if (command == angCmd) { 
410    opt->SetPolarAngleLimit(angCmd->GetNewDoubleValue(newValue));
411    G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
412  } 
413}
414
415//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.