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