Geant4  10.03
G4OpticalPhysicsMessenger.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 //
27 //----------------------------------------------------------------------------
28 //
29 // ClassName: G4OpticalPhysicsMessenger
30 //
31 // Author: P.Gumplinger 30.09.2009 //
32 //
33 // Modified: P.Gumplinger 29.09.2011
34 // (based on code from I. Hrivnacova)
35 //
36 //----------------------------------------------------------------------------
37 //
38 
40 #include "G4OpticalPhysics.hh"
41 
42 #include "G4UIcommand.hh"
43 #include "G4UIdirectory.hh"
44 
45 #include "G4UIcommand.hh"
46 #include "G4UIdirectory.hh"
47 #include "G4UIcmdWithABool.hh"
48 #include "G4UIcmdWithAString.hh"
49 #include "G4UIcmdWithADouble.hh"
50 #include "G4UIcmdWithAnInteger.hh"
52 #include "G4UIparameter.hh"
53 
54 #include "G4ParticleTable.hh"
55 #include "G4ProcessManager.hh"
56 #include "G4ParticleDefinition.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61  G4OpticalPhysics* opticalPhysics)
62  : G4UImessenger(),
63  fOpticalPhysics(opticalPhysics),
64  fSelectedProcessIndex(kNoProcess),
65  fActivateProcessCmd(0),
66  fSetOpProcessVerboseCmd(0),
67  fSetCerenkovMaxPhotonsCmd(0),
68  fSetCerenkovMaxBetaChangeCmd(0),
69  fSetScintillationYieldFactorCmd(0),
70  fSetScintillationByParticleTypeCmd(0),
71  fSetScintillationTrackInfoCmd(0),
72  fSetWLSTimeProfileCmd(0),
73  fSetTrackSecondariesFirstCmd(0),
74  fSetFiniteRiseTimeCmd(0),
75  fSetInvokeSDCmd(0)
76 {
77  G4bool toBeBroadcasted = false;
78  fDir = new G4UIdirectory("/process/optical/defaults/",toBeBroadcasted);
79  fDir->SetGuidance("Commands related to the optical physics simulation engine.");
80  fDir2 = new G4UIdirectory("/process/optical/",toBeBroadcasted);
81  fDir2->SetGuidance("Commands related to the optical physics simulation engine.");
82 
83  fActivateProcessCmd= new G4UIcommand("/process/optical/processActivation", this);
84  fActivateProcessCmd->SetGuidance("Activate/deactivate the specified optical process");
85  G4UIparameter* par = new G4UIparameter("proc_name",'s',false);
86  G4String candidates;
87  for ( G4int i=0; i<kNoProcess; i++ ) {
88  candidates += G4OpticalProcessName(i);
89  candidates += G4String(" ");
90  }
91  par->SetParameterCandidates(candidates);
92  par->SetGuidance("the process name");
94  par = new G4UIparameter("flag",'b',true);
95  par->SetDefaultValue(true);
96  par->SetGuidance("activation flag");
99 
100 
101  fSetOpProcessVerboseCmd = new G4UIcmdWithAnInteger("/process/optical/verbose", this);
102  fSetOpProcessVerboseCmd->SetGuidance("Set default verbosity level for optical processes");
107 
108 
109  fSetTrackSecondariesFirstCmd = new G4UIcommand("/process/optical/setTrackSecondariesFirst", this);
110  fSetTrackSecondariesFirstCmd->SetGuidance("Activate/deactivate tracking of secondaries before finishing their parent track");
111  par = new G4UIparameter("proc_name",'s',false);
112  par->SetParameterCandidates(candidates);
114  par = new G4UIparameter("flag",'b',false);
115  par->SetDefaultValue(true);
118 
119  //This are repetition of process specific ui commands needed by ATLICE and VMC
120  //(UI messages needed to exist in PreInit state before actual processes are instantiated)
121  fSetCerenkovMaxPhotonsCmd = new G4UIcmdWithAnInteger("/process/optical/defaults/cerenkov/setMaxPhotons", this);
122  fSetCerenkovMaxPhotonsCmd->SetGuidance("Set default maximum number of photons per step");
123  fSetCerenkovMaxPhotonsCmd->SetGuidance("Note this command is used to set the default value,");
124  fSetCerenkovMaxPhotonsCmd->SetGuidance("if process is not active command will not have effect.");
125  fSetCerenkovMaxPhotonsCmd->SetParameterName("CerenkovMaxPhotons", false);
126  fSetCerenkovMaxPhotonsCmd->SetRange("CerenkovMaxPhotons>=0");
128 
129  fSetCerenkovMaxBetaChangeCmd = new G4UIcmdWithADouble("/process/optical/defaults/cerenkov/setMaxBetaChange", this);
130  fSetCerenkovMaxBetaChangeCmd->SetGuidance("Set default maximum change of beta of parent particle per step");
131  fSetCerenkovMaxBetaChangeCmd->SetGuidance("Note this command is used to set the default value,");
132  fSetCerenkovMaxBetaChangeCmd->SetGuidance("if process is not active command will not have effect.");
133  fSetCerenkovMaxBetaChangeCmd->SetParameterName("CerenkovMaxBetaChange", false);
134  fSetCerenkovMaxBetaChangeCmd->SetRange("CerenkovMaxBetaChange>=0");
136 
137  fSetScintillationYieldFactorCmd = new G4UIcmdWithADouble("/process/optical/defaults/scintillation/setYieldFactor", this);
138  fSetScintillationYieldFactorCmd->SetGuidance("Set scintillation yield factor");
139  fSetScintillationYieldFactorCmd->SetGuidance("Note this command is used to set the default value,");
140  fSetScintillationYieldFactorCmd->SetGuidance("if process is not active command will not have effect.");
141  fSetScintillationYieldFactorCmd->SetParameterName("ScintillationYieldFactor", false);
142  fSetScintillationYieldFactorCmd->SetRange("ScintillationYieldFactor>=0");
144 
145  fSetScintillationByParticleTypeCmd = new G4UIcmdWithABool("/process/optical/defaults/scintillation/setByParticleType", this);
146  fSetScintillationByParticleTypeCmd->SetGuidance("Activate/Inactivate scintillation process by particle type");
147  fSetScintillationByParticleTypeCmd->SetGuidance("Note this command is used to set the default value,");
148  fSetScintillationByParticleTypeCmd->SetGuidance("if process is not active command will not have effect.");
149  fSetScintillationByParticleTypeCmd->SetParameterName("ScintillationByParticleTypeActivation", false);
151 
152  fSetScintillationTrackInfoCmd = new G4UIcmdWithABool("/process/optical/defaults/scintillation/setTrackInfo", this);
153  fSetScintillationTrackInfoCmd->SetGuidance("Activate/Inactivate scintillation TrackInformation");
154  fSetScintillationTrackInfoCmd->SetParameterName("ScintillationTrackInfo", false);
156 
157  fSetFiniteRiseTimeCmd = new G4UIcmdWithABool("/process/optical/defaults/scintillation/setFiniteRiseTime", this);
158  fSetFiniteRiseTimeCmd->SetGuidance("Set option of a finite rise-time for G4Scintillation");
159  fSetFiniteRiseTimeCmd->SetGuidance("If set, the G4Scintillation process expects the user to have set the constant material property FAST/SLOWSCINTILLATIONRISETIME");
160  fSetFiniteRiseTimeCmd->SetGuidance("Note this command is used to set the default value,");
161  fSetFiniteRiseTimeCmd->SetGuidance("if process is not active command will not have effect.");
162  fSetFiniteRiseTimeCmd->SetParameterName("FiniteRiseTime", false);
164 
165  fSetWLSTimeProfileCmd = new G4UIcmdWithAString("/process/optical/defaults/wls/setTimeProfile", this);
166  fSetWLSTimeProfileCmd->SetGuidance("Set the WLS time profile (delta or exponential)");
167  fSetWLSTimeProfileCmd->SetParameterName("WLSTimeProfile", false);
168  fSetWLSTimeProfileCmd->SetCandidates("delta exponential");
170 
171  fSetInvokeSDCmd = new G4UIcmdWithABool("/process/optical/defaults/boundary/setInvokeSD", this);
172  fSetInvokeSDCmd->SetGuidance("Set option for calling InvokeSD in G4OpBoundaryProcess");
173  fSetInvokeSDCmd->SetParameterName("InvokeSD", false);
175 }
176 
178 {
179 // Destructor
180 
181  delete fDir;
182  delete fDir2;
183  delete fActivateProcessCmd;
190  delete fSetWLSTimeProfileCmd;
192  delete fSetFiniteRiseTimeCmd;
193  delete fSetInvokeSDCmd;
194 }
195 
196 #include <iostream>
198  G4String newValue)
199 {
201  if (command == fActivateProcessCmd) {
202  std::istringstream is(newValue.data());
203  G4String pn;
204  G4String flag;
205  is >> pn >> flag;
206  if ( pn == "Cerenkov" ) {
208  } else if ( pn == "Scintillation" ) {
210  } else if ( pn == "OpAbsorption" ) {
212  } else if ( pn == "OpRayleigh" ) {
214  } else if ( pn == "OpMieHG" ) {
216  } else if ( pn == "OpBoundary" ) {
218  } else if ( pn == "OpWLS" ) {
220  } else {
222  msg << "Not allowed process name: "<<pn<<" (UI: "<<newValue<<")";
223  G4Exception("G4OpticalPhysicsMessenger::SetNewValue(...)","Optical001",FatalException,msg);
224  }
225  G4bool value = G4UIcommand::ConvertToBool(flag);
227  }
228  else if (command == fSetTrackSecondariesFirstCmd )
229  {
230  std::istringstream is(newValue.data());
231  G4String pn;
232  G4String flag;
233  is >> pn >> flag;
234  if ( pn == "Cerenkov" ) {
236  } else if ( pn == "Scintillation" ) {
238  } else if ( pn == "OpAbsorption" ) {
240  } else if ( pn == "OpRayleigh" ) {
242  } else if ( pn == "OpMieHG" ) {
244  } else if ( pn == "OpBoundary" ) {
246  } else if ( pn == "OpWLS" ) {
248  } else {
250  msg << "Not allowed process name: "<<pn<<" (UI: "<<newValue<<")";
251  G4Exception("G4OpticalPhysicsMessenger::SetNewValue(...)","Optical001",FatalException,msg);
252  }
253  G4bool value = G4UIcommand::ConvertToBool(flag);
255  }
256  else if (command == fSetOpProcessVerboseCmd) {
258  }
259  else if (command == fSetCerenkovMaxPhotonsCmd) {
263  }
264  else if (command == fSetCerenkovMaxBetaChangeCmd) {
268  }
269  else if (command == fSetScintillationYieldFactorCmd) {
273  }
274  else if (command == fSetScintillationByParticleTypeCmd) {
278  }
279  else if (command == fSetScintillationTrackInfoCmd) {
283  }
284  else if (command == fSetFiniteRiseTimeCmd) {
288  }
289  else if (command == fSetWLSTimeProfileCmd) {
291  }
292  else if (command == fSetInvokeSDCmd) {
295  }
296 }
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4OpticalPhysics * fOpticalPhysics
associated class
virtual void SetNewValue(G4UIcommand *, G4String)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
G4UIcmdWithABool * fSetFiniteRiseTimeCmd
setFiniteRiseTime command
Number of processes, no selected process.
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4OpticalProcessIndex fSelectedProcessIndex
selected optical process
static G4int GetNewIntValue(const char *paramString)
void SetMaxBetaChangePerStep(G4double)
void SetParameterCandidates(const char *theString)
void SetInvokeSD(G4bool)
void SetDefaultValue(const char *theDefaultValue)
G4UIcmdWithAString * fSetWLSTimeProfileCmd
setWLSTimeProfile command
Scintillation process index.
G4UIcommand * fActivateProcessCmd
selectOpProcess command
G4UIcmdWithABool * fSetScintillationTrackInfoCmd
setScintillationTrackInfo command
Mie scattering process index.
G4UIcmdWithAnInteger * fSetOpProcessVerboseCmd
setProcessVerbose command
void SetFiniteRiseTime(G4bool)
Absorption process index.
int G4int
Definition: G4Types.hh:78
static G4bool GetNewBoolValue(const char *paramString)
void SetScintillationByParticleType(G4bool)
G4UIcmdWithABool * fSetInvokeSDCmd
setInvokeSD command
G4UIcmdWithAnInteger * fSetCerenkovMaxPhotonsCmd
setCerenkovMaxPhotons command
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetMaxNumPhotonsPerStep(G4int)
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
bool G4bool
Definition: G4Types.hh:79
void Configure(G4OpticalProcessIndex, G4bool)
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:239
void SetVerboseLevel(G4int value)
G4UIcmdWithABool * fSetScintillationByParticleTypeCmd
setScintillationByParticleType command
Wave Length Shifting process index.
G4OpticalPhysicsMessenger()
Not implemented.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4UIdirectory * fDir
command directory
const char * data() const
G4String G4OpticalProcessName(G4int)
Return the name for a given optical process index.
Boundary process index.
void SetScintillationYieldFactor(G4double)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
Cerenkov process index.
void SetScintillationTrackInfo(G4bool)
void SetWLSTimeProfile(G4String)
void SetTrackSecondariesFirst(G4OpticalProcessIndex, G4bool)
G4UIcmdWithADouble * fSetScintillationYieldFactorCmd
setScintillationYieldFactor command
void SetCandidates(const char *candidateList)
G4UIcmdWithADouble * fSetCerenkovMaxBetaChangeCmd
setCerenkovMaxBetaChange command
void SetDefaultValue(G4int defVal)
G4UIcommand * fSetTrackSecondariesFirstCmd
setTrackSecondariesFirst command
Rayleigh scattering process index.
void SetGuidance(const char *theGuidance)