Geant4-11
G4MatScanMessenger.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// G4MatScanMessenger implementation
27//
28// Author: M.Asai, May 2006
29// --------------------------------------------------------------------
30
31#include "G4MatScanMessenger.hh"
32
33#include "G4MaterialScanner.hh"
34#include "G4SystemOfUnits.hh"
35#include "G4ThreeVector.hh"
36#include "G4Tokenizer.hh"
37#include "G4UIcmdWith3Vector.hh"
39#include "G4UIcmdWithABool.hh"
40#include "G4UIcmdWithAString.hh"
42#include "G4UIcommand.hh"
43#include "G4UIdirectory.hh"
44#include "G4UIparameter.hh"
45
46// --------------------------------------------------------------------
48{
49 theScanner = p1;
50 G4UIparameter* par;
51 msDirectory = new G4UIdirectory("/control/matScan/");
52 msDirectory->SetGuidance("Material scanner commands.");
53
54 scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan", this);
55 scanCmd->SetGuidance("Start material scanning.");
56 scanCmd->SetGuidance("Scanning range should be defined with");
58 "/control/matScan/theta and /control/matSca/phi commands.");
60
61 thetaCmd = new G4UIcommand("/control/matScan/theta", this);
62 thetaCmd->SetGuidance("Define theta range.");
64 "Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
65 thetaCmd->SetGuidance("Notation of angles :");
67 " theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
68 par = new G4UIparameter("nbin", 'i', false);
69 par->SetParameterRange("nbin>0");
71 par = new G4UIparameter("thetaMin", 'd', false);
73 par = new G4UIparameter("thetaSpan", 'd', true);
74 par->SetParameterRange("thetaSpan>=0.");
75 par->SetDefaultValue(0.);
77 par = new G4UIparameter("unit", 'c', true);
78 par->SetDefaultValue("deg");
81
82 phiCmd = new G4UIcommand("/control/matScan/phi", this);
83 phiCmd->SetGuidance("Define phi range.");
85 "Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
86 phiCmd->SetGuidance("Notation of angles :");
88 " phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 "
89 "deg. / -Y axis : 270 deg.");
90 par = new G4UIparameter("nbin", 'i', false);
91 par->SetParameterRange("nbin>0");
92 phiCmd->SetParameter(par);
93 par = new G4UIparameter("phiMin", 'd', false);
94 phiCmd->SetParameter(par);
95 par = new G4UIparameter("phiSpan", 'd', true);
96 par->SetParameterRange("phiSpan>=0.");
97 par->SetDefaultValue(0.);
98 phiCmd->SetParameter(par);
99 par = new G4UIparameter("unit", 'c', true);
100 par->SetDefaultValue("deg");
102 phiCmd->SetParameter(par);
103
104 singleCmd = new G4UIcommand("/control/matScan/singleMeasure", this);
105 singleCmd->SetGuidance("Measure thickness for one particular direction.");
106 singleCmd->SetGuidance("Notation of angles :");
108 " theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
110 " phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : "
111 "180 deg. / -Y axis : 270 deg.");
113 par = new G4UIparameter("theta", 'd', false);
115 par = new G4UIparameter("phi", 'd', false);
117 par = new G4UIparameter("unit", 'c', true);
118 par->SetDefaultValue("deg");
122
123 single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo", this);
125 "Measure thickness for one direction defined by a unit vector.");
126 single2Cmd->SetParameterName("X", "Y", "Z", false);
127
128 eyePosCmd =
129 new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition", this);
130 eyePosCmd->SetGuidance("Define the eye position.");
131 eyePosCmd->SetParameterName("X", "Y", "Z", true);
134
135 regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive", this);
136 regSenseCmd->SetGuidance("Set region sensitivity.");
137 regSenseCmd->SetGuidance("This command is automatically set to TRUE");
138 regSenseCmd->SetGuidance(" if /control/matScan/region command is issued.");
139 regSenseCmd->SetParameterName("senseFlag", true);
141
142 regionCmd = new G4UIcmdWithAString("/control/matScan/region", this);
143 regionCmd->SetGuidance("Define region name to be scanned.");
145 "/control/matScan/regionSensitive command is automatically");
146 regionCmd->SetGuidance("set to TRUE with this command.");
147 regionCmd->SetParameterName("region", true);
148 regionCmd->SetDefaultValue("DefaultRegionForTheWorld");
149}
150
151// --------------------------------------------------------------------
153{
154 delete scanCmd;
155 delete thetaCmd;
156 delete phiCmd;
157 delete singleCmd;
158 delete single2Cmd;
159 delete eyePosCmd;
160 delete regSenseCmd;
161 delete regionCmd;
162 delete msDirectory;
163}
164
165// --------------------------------------------------------------------
167{
168 G4String currentValue;
169 if(command == thetaCmd)
170 {
171 currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
172 currentValue += " ";
173 currentValue +=
175 currentValue += " ";
176 currentValue +=
178 }
179 else if(command == phiCmd)
180 {
181 currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
182 currentValue += " ";
183 currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin()) / deg);
184 currentValue += " ";
185 currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan()) / deg);
186 }
187 else if(command == eyePosCmd)
188 {
189 currentValue =
191 }
192 else if(command == regSenseCmd)
193 {
194 currentValue =
196 }
197 else if(command == regionCmd)
198 {
199 currentValue = theScanner->GetRegionName();
200 }
201 return currentValue;
202}
203
204// --------------------------------------------------------------------
206{
207 if(command == scanCmd)
208 {
209 theScanner->Scan();
210 }
211 else if(command == thetaCmd)
212 {
213 G4Tokenizer next(newValue);
214 G4int nbin = StoI(next());
215 G4double thetaMin = StoD(next());
216 G4double thetaSpan = StoD(next());
217 G4String unit = next();
218 thetaMin *= thetaCmd->ValueOf(unit);
219 thetaSpan *= thetaCmd->ValueOf(unit);
220 theScanner->SetNTheta(nbin);
221 theScanner->SetThetaMin(thetaMin);
222 theScanner->SetThetaSpan(thetaSpan);
223 }
224 else if(command == phiCmd)
225 {
226 G4Tokenizer next(newValue);
227 G4int nbin = StoI(next());
228 G4double phiMin = StoD(next());
229 G4double phiSpan = StoD(next());
230 G4String unit = next();
231 phiMin *= phiCmd->ValueOf(unit);
232 phiSpan *= phiCmd->ValueOf(unit);
233 theScanner->SetNPhi(nbin);
234 theScanner->SetPhiMin(phiMin);
235 theScanner->SetPhiSpan(phiSpan);
236 }
237 else if(command == eyePosCmd)
238 {
240 }
241 else if(command == regSenseCmd)
242 {
244 }
245 else if(command == regionCmd)
246 {
247 if(theScanner->SetRegionName(newValue))
249 }
250 else if(command == singleCmd || command == single2Cmd)
251 {
252 G4int ntheta = theScanner->GetNTheta();
253 G4double thetaMin = theScanner->GetThetaMin();
254 G4double thetaSpan = theScanner->GetThetaSpan();
255 G4int nphi = theScanner->GetNPhi();
256 G4double phiMin = theScanner->GetPhiMin();
257 G4double phiSpan = theScanner->GetPhiSpan();
258
259 G4double theta = 0.;
260 G4double phi = 0.;
261 if(command == singleCmd)
262 {
263 G4Tokenizer next(newValue);
264 theta = StoD(next());
265 phi = StoD(next());
266 G4String unit = next();
267 theta *= singleCmd->ValueOf(unit);
268 phi *= singleCmd->ValueOf(unit);
269 }
270 else if(command == single2Cmd)
271 {
273 theta = 90. * deg - v.theta();
274 phi = v.phi();
275 }
277 theScanner->SetThetaMin(theta);
280 theScanner->SetPhiMin(phi);
282 theScanner->Scan();
283
284 theScanner->SetNTheta(ntheta);
285 theScanner->SetThetaMin(thetaMin);
286 theScanner->SetThetaSpan(thetaSpan);
287 theScanner->SetNPhi(nphi);
288 theScanner->SetPhiMin(phiMin);
289 theScanner->SetPhiSpan(phiSpan);
290 }
291}
@ G4State_Idle
static constexpr double deg
Definition: G4SIunits.hh:132
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
double phi() const
double theta() const
G4UIcmdWithABool * regSenseCmd
G4UIcmdWithoutParameter * scanCmd
G4UIdirectory * msDirectory
G4UIcmdWith3Vector * single2Cmd
virtual G4String GetCurrentValue(G4UIcommand *command)
G4MatScanMessenger(G4MaterialScanner *p1)
G4UIcmdWith3VectorAndUnit * eyePosCmd
G4UIcmdWithAString * regionCmd
G4MaterialScanner * theScanner
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNPhi(G4int val)
G4bool GetRegionSensitive() const
void SetThetaSpan(G4double val)
G4bool SetRegionName(const G4String &val)
G4double GetThetaMin() const
void SetRegionSensitive(G4bool val=true)
void SetThetaMin(G4double val)
G4double GetThetaSpan() const
void SetPhiMin(G4double val)
void SetEyePosition(const G4ThreeVector &val)
void SetPhiSpan(G4double val)
G4int GetNPhi() const
G4ThreeVector GetEyePosition() const
G4double GetPhiMin() const
const G4String & GetRegionName() const
G4int GetNTheta() const
G4double GetPhiSpan() const
void SetNTheta(G4int val)
void SetDefaultUnit(const char *defUnit)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4ThreeVector defVal)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:371
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:363
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:377
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:288
G4int StoI(G4String s)
G4double StoD(G4String s)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)