source: trunk/source/run/src/G4MatScanMessenger.cc@ 1167

Last change on this file since 1167 was 1058, checked in by garnier, 17 years ago

file release beta

File size: 10.0 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: G4MatScanMessenger.cc,v 1.5 2006/12/01 02:00:55 asaim Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31//
32
33
34#include "G4MatScanMessenger.hh"
35
36#include "G4UIdirectory.hh"
37#include "G4UIcommand.hh"
38#include "G4UIparameter.hh"
39#include "G4UIcmdWithoutParameter.hh"
40#include "G4UIcmdWithABool.hh"
41#include "G4UIcmdWith3VectorAndUnit.hh"
42#include "G4UIcmdWith3Vector.hh"
43#include "G4UIcmdWithAString.hh"
44#include "G4MaterialScanner.hh"
45#include "G4ThreeVector.hh"
46#include "G4Tokenizer.hh"
47
48G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1)
49{
50 theScanner = p1;
51 G4UIparameter* par;
52 msDirectory = new G4UIdirectory("/control/matScan/");
53 msDirectory->SetGuidance("Material scanner commands.");
54
55 scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan",this);
56 scanCmd->SetGuidance("Start material scanning.");
57 scanCmd->SetGuidance("Scanning range should be defined with");
58 scanCmd->SetGuidance("/control/matScan/theta and /control/matSca/phi commands.");
59 scanCmd->AvailableForStates(G4State_Idle);
60
61 thetaCmd = new G4UIcommand("/control/matScan/theta",this);
62 thetaCmd->SetGuidance("Define theta range.");
63 thetaCmd->SetGuidance("Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
64 thetaCmd->SetGuidance("Notation of angles :");
65 thetaCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
66 par = new G4UIparameter("nbin",'i',false);
67 par->SetParameterRange("nbin>0");
68 thetaCmd->SetParameter(par);
69 par = new G4UIparameter("thetaMin",'d',false);
70 thetaCmd->SetParameter(par);
71 par = new G4UIparameter("thetaSpan",'d',true);
72 par->SetParameterRange("thetaSpan>=0.");
73 par->SetDefaultValue(0.);
74 thetaCmd->SetParameter(par);
75 par = new G4UIparameter("unit",'c',true);
76 par->SetDefaultValue("deg");
77 par->SetParameterCandidates(thetaCmd->UnitsList(thetaCmd->CategoryOf("deg")));
78 thetaCmd->SetParameter(par);
79
80 phiCmd = new G4UIcommand("/control/matScan/phi",this);
81 phiCmd->SetGuidance("Define phi range.");
82 phiCmd->SetGuidance("Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
83 phiCmd->SetGuidance("Notation of angles :");
84 phiCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
85 par = new G4UIparameter("nbin",'i',false);
86 par->SetParameterRange("nbin>0");
87 phiCmd->SetParameter(par);
88 par = new G4UIparameter("phiMin",'d',false);
89 phiCmd->SetParameter(par);
90 par = new G4UIparameter("phiSpan",'d',true);
91 par->SetParameterRange("phiSpan>=0.");
92 par->SetDefaultValue(0.);
93 phiCmd->SetParameter(par);
94 par = new G4UIparameter("unit",'c',true);
95 par->SetDefaultValue("deg");
96 par->SetParameterCandidates(phiCmd->UnitsList(phiCmd->CategoryOf("deg")));
97 phiCmd->SetParameter(par);
98
99 singleCmd = new G4UIcommand("/control/matScan/singleMeasure",this);
100 singleCmd->SetGuidance("Measure thickness for one particular direction.");
101 singleCmd->SetGuidance("Notation of angles :");
102 singleCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
103 singleCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
104 singleCmd->AvailableForStates(G4State_Idle);
105 par = new G4UIparameter("theta",'d',false);
106 singleCmd->SetParameter(par);
107 par = new G4UIparameter("phi",'d',false);
108 singleCmd->SetParameter(par);
109 par = new G4UIparameter("unit",'c',true);
110 par->SetDefaultValue("deg");
111 par->SetParameterCandidates(singleCmd->UnitsList(singleCmd->CategoryOf("deg")));
112 singleCmd->SetParameter(par);
113
114 single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo",this);
115 single2Cmd->SetGuidance("Measure thicknesss for one direction defined by a unit vector.");
116 single2Cmd->SetParameterName("X","Y","Z",false);
117
118 eyePosCmd = new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition",this);
119 eyePosCmd->SetGuidance("Define the eye position.");
120 eyePosCmd->SetParameterName("X","Y","Z",true);
121 eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
122 eyePosCmd->SetDefaultUnit("m");
123
124 regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive",this);
125 regSenseCmd->SetGuidance("Set region sensitivity.");
126 regSenseCmd->SetGuidance("This command is automatically set to TRUE");
127 regSenseCmd->SetGuidance(" if /control/matScan/region command is issued.");
128 regSenseCmd->SetParameterName("senseFlag",true);
129 regSenseCmd->SetDefaultValue(false);
130
131 regionCmd = new G4UIcmdWithAString("/control/matScan/region",this);
132 regionCmd->SetGuidance("Define region name to be scanned.");
133 regionCmd->SetGuidance("/control/matScan/regionSensitive command is automatically");
134 regionCmd->SetGuidance("set to TRUE with this command.");
135 regionCmd->SetParameterName("region",true);
136 regionCmd->SetDefaultValue("DefaultRegionForTheWorld");
137}
138
139G4MatScanMessenger::~G4MatScanMessenger()
140{
141 delete scanCmd;
142 delete thetaCmd;
143 delete phiCmd;
144 delete singleCmd;
145 delete single2Cmd;
146 delete eyePosCmd;
147 delete regSenseCmd;
148 delete regionCmd;
149 delete msDirectory;
150}
151
152G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand * command)
153{
154 G4String currentValue;
155 if(command==thetaCmd)
156 {
157 currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
158 currentValue += " ";
159 currentValue += thetaCmd->ConvertToString((theScanner->GetThetaMin())/deg);
160 currentValue += " ";
161 currentValue += thetaCmd->ConvertToString((theScanner->GetThetaSpan())/deg);
162 }
163 else if(command==phiCmd)
164 {
165 currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
166 currentValue += " ";
167 currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin())/deg);
168 currentValue += " ";
169 currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan())/deg);
170 }
171 else if(command==eyePosCmd)
172 { currentValue = eyePosCmd->ConvertToString(theScanner->GetEyePosition(),"m"); }
173 else if(command==regSenseCmd)
174 { currentValue = regSenseCmd->ConvertToString(theScanner->GetRegionSensitive()); }
175 else if(command==regionCmd)
176 { currentValue = theScanner->GetRegionName(); }
177 return currentValue;
178}
179
180void G4MatScanMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
181{
182 if(command==scanCmd)
183 { theScanner->Scan(); }
184 else if(command==thetaCmd)
185 {
186 G4Tokenizer next( newValue );
187 G4int nbin = StoI(next());
188 G4double thetaMin = StoD(next());
189 G4double thetaSpan = StoD(next());
190 G4String unit = next();
191 thetaMin *= thetaCmd->ValueOf(unit);
192 thetaSpan *= thetaCmd->ValueOf(unit);
193 theScanner->SetNTheta(nbin);
194 theScanner->SetThetaMin(thetaMin);
195 theScanner->SetThetaSpan(thetaSpan);
196 }
197 else if(command==phiCmd)
198 {
199 G4Tokenizer next( newValue );
200 G4int nbin = StoI(next());
201 G4double phiMin = StoD(next());
202 G4double phiSpan = StoD(next());
203 G4String unit = next();
204 phiMin *= phiCmd->ValueOf(unit);
205 phiSpan *= phiCmd->ValueOf(unit);
206 theScanner->SetNPhi(nbin);
207 theScanner->SetPhiMin(phiMin);
208 theScanner->SetPhiSpan(phiSpan);
209 }
210 else if(command==eyePosCmd)
211 { theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
212 else if(command==regSenseCmd)
213 { theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue)); }
214 else if(command==regionCmd)
215 { if(theScanner->SetRegionName(newValue)) theScanner->SetRegionSensitive(true); }
216 else if(command==singleCmd || command==single2Cmd)
217 {
218 G4int ntheta = theScanner->GetNTheta();
219 G4double thetaMin = theScanner->GetThetaMin();
220 G4double thetaSpan = theScanner->GetThetaSpan();
221 G4int nphi = theScanner->GetNPhi();
222 G4double phiMin = theScanner->GetPhiMin();
223 G4double phiSpan = theScanner->GetPhiSpan();
224
225 G4double theta = 0.;
226 G4double phi = 0.;
227 if(command==singleCmd)
228 {
229 G4Tokenizer next( newValue );
230 theta = StoD(next());
231 phi = StoD(next());
232 G4String unit = next();
233 theta *= singleCmd->ValueOf(unit);
234 phi *= singleCmd->ValueOf(unit);
235 }
236 else if(command==single2Cmd)
237 {
238 G4ThreeVector v = single2Cmd->GetNew3VectorValue(newValue);
239 theta = 90.*deg - v.theta();
240 phi = v.phi();
241 }
242 theScanner->SetNTheta(1);
243 theScanner->SetThetaMin(theta);
244 theScanner->SetThetaSpan(0.);
245 theScanner->SetNPhi(1);
246 theScanner->SetPhiMin(phi);
247 theScanner->SetPhiSpan(0.);
248 theScanner->Scan();
249
250 theScanner->SetNTheta(ntheta);
251 theScanner->SetThetaMin(thetaMin);
252 theScanner->SetThetaSpan(thetaSpan);
253 theScanner->SetNPhi(nphi);
254 theScanner->SetPhiMin(phiMin);
255 theScanner->SetPhiSpan(phiSpan);
256 }
257
258}
259
260
261
262
263
Note: See TracBrowser for help on using the repository browser.