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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /run/src/G4MatScanMessenger.cc (Version 11.3.0) and /run/src/G4MatScanMessenger.cc (Version 4.1.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 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"                  
 38 #include "G4UIcmdWith3VectorAndUnit.hh"           
 39 #include "G4UIcmdWithABool.hh"                    
 40 #include "G4UIcmdWithAString.hh"                  
 41 #include "G4UIcmdWithoutParameter.hh"             
 42 #include "G4UIcmdWithAnInteger.hh"                
 43 #include "G4UIcommand.hh"                         
 44 #include "G4UIdirectory.hh"                       
 45 #include "G4UIparameter.hh"                       
 46                                                   
 47 // -------------------------------------------    
 48 G4MatScanMessenger::G4MatScanMessenger(G4Mater    
 49 {                                                 
 50   theScanner = p1;                                
 51   G4UIparameter* par;                             
 52   msDirectory = new G4UIdirectory("/control/ma    
 53   msDirectory->SetGuidance("Material scanner c    
 54                                                   
 55   scanCmd = new G4UIcmdWithoutParameter("/cont    
 56   scanCmd->SetGuidance("Start material scannin    
 57   scanCmd->SetGuidance("Scanning range should     
 58   scanCmd->SetGuidance("/control/matScan/theta    
 59   scanCmd->AvailableForStates(G4State_Idle);      
 60                                                   
 61   thetaCmd = new G4UIcommand("/control/matScan    
 62   thetaCmd->SetGuidance("Define theta range.")    
 63   thetaCmd->SetGuidance("Usage : /control/matS    
 64   thetaCmd->SetGuidance("Notation of angles :"    
 65   thetaCmd->SetGuidance(" theta --- +Z axis :     
 66   par = new G4UIparameter("nbin", 'i', false);    
 67   par->SetParameterRange("nbin>0");               
 68   thetaCmd->SetParameter(par);                    
 69   par = new G4UIparameter("thetaMin", 'd', fal    
 70   thetaCmd->SetParameter(par);                    
 71   par = new G4UIparameter("thetaSpan", 'd', tr    
 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->UnitsL    
 78   thetaCmd->SetParameter(par);                    
 79                                                   
 80   phiCmd = new G4UIcommand("/control/matScan/p    
 81   phiCmd->SetGuidance("Define phi range.");       
 82   phiCmd->SetGuidance("Usage : /control/matSca    
 83   phiCmd->SetGuidance("Notation of angles :");    
 84   phiCmd->SetGuidance(                            
 85     " phi   --- +X axis : 0 deg. / +Y axis : 9    
 86     "deg. / -Y axis : 270 deg.");                 
 87   par = new G4UIparameter("nbin", 'i', false);    
 88   par->SetParameterRange("nbin>0");               
 89   phiCmd->SetParameter(par);                      
 90   par = new G4UIparameter("phiMin", 'd', false    
 91   phiCmd->SetParameter(par);                      
 92   par = new G4UIparameter("phiSpan", 'd', true    
 93   par->SetParameterRange("phiSpan>=0.");          
 94   par->SetDefaultValue(0.);                       
 95   phiCmd->SetParameter(par);                      
 96   par = new G4UIparameter("unit", 'c', true);     
 97   par->SetDefaultValue("deg");                    
 98   par->SetParameterCandidates(phiCmd->UnitsLis    
 99   phiCmd->SetParameter(par);                      
100                                                   
101   singleCmd = new G4UIcommand("/control/matSca    
102   singleCmd->SetGuidance("Measure thickness fo    
103   singleCmd->SetGuidance("Notation of angles :    
104   singleCmd->SetGuidance(" theta --- +Z axis :    
105   singleCmd->SetGuidance(                         
106     " phi   --- +X axis : 0 deg. / +Y axis : 9    
107     "180 deg. / -Y axis : 270 deg.");             
108   singleCmd->AvailableForStates(G4State_Idle);    
109   par = new G4UIparameter("theta", 'd', false)    
110   singleCmd->SetParameter(par);                   
111   par = new G4UIparameter("phi", 'd', false);     
112   singleCmd->SetParameter(par);                   
113   par = new G4UIparameter("unit", 'c', true);     
114   par->SetDefaultValue("deg");                    
115   par->SetParameterCandidates(singleCmd->Units    
116   singleCmd->SetParameter(par);                   
117                                                   
118   single2Cmd = new G4UIcmdWith3Vector("/contro    
119   single2Cmd->SetGuidance("Measure thickness f    
120   single2Cmd->SetParameterName("X", "Y", "Z",     
121                                                   
122   eyePosCmd = new G4UIcmdWith3VectorAndUnit("/    
123   eyePosCmd->SetGuidance("Define the eye posit    
124   eyePosCmd->SetParameterName("X", "Y", "Z", t    
125   eyePosCmd->SetDefaultValue(G4ThreeVector(0.,    
126   eyePosCmd->SetDefaultUnit("m");                 
127                                                   
128   regSenseCmd = new G4UIcmdWithABool("/control    
129   regSenseCmd->SetGuidance("Set region sensiti    
130   regSenseCmd->SetGuidance("This command is au    
131   regSenseCmd->SetGuidance(" if /control/matSc    
132   regSenseCmd->SetParameterName("senseFlag", t    
133   regSenseCmd->SetDefaultValue(false);            
134                                                   
135   regionCmd = new G4UIcmdWithAString("/control    
136   regionCmd->SetGuidance("Define region name t    
137   regionCmd->SetGuidance("/control/matScan/reg    
138   regionCmd->SetGuidance("set to TRUE with thi    
139   regionCmd->SetParameterName("region", true);    
140   regionCmd->SetDefaultValue("DefaultRegionFor    
141                                                   
142   verboseCmd = new G4UIcmdWithAnInteger("/cont    
143   verboseCmd->SetGuidance("Set verbose level o    
144   verboseCmd->SetGuidance("0: default, propert    
145   verboseCmd->SetGuidance("1: integrated prope    
146   verboseCmd->SetGuidance("2: detailed propert    
147   verboseCmd->SetParameterName("verbose_level"    
148   verboseCmd->SetDefaultValue(0);                 
149 }                                                 
150                                                   
151 // -------------------------------------------    
152 G4MatScanMessenger::~G4MatScanMessenger()         
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 // -------------------------------------------    
166 G4String G4MatScanMessenger::GetCurrentValue(G    
167 {                                                 
168   G4String currentValue;                          
169   if (command == thetaCmd) {                      
170     currentValue = thetaCmd->ConvertToString(t    
171     currentValue += " ";                          
172     currentValue += thetaCmd->ConvertToString(    
173     currentValue += " ";                          
174     currentValue += thetaCmd->ConvertToString(    
175   }                                               
176   else if (command == phiCmd) {                   
177     currentValue = phiCmd->ConvertToString(the    
178     currentValue += " ";                          
179     currentValue += phiCmd->ConvertToString((t    
180     currentValue += " ";                          
181     currentValue += phiCmd->ConvertToString((t    
182   }                                               
183   else if (command == eyePosCmd) {                
184     currentValue = eyePosCmd->ConvertToString(    
185   }                                               
186   else if (command == regSenseCmd) {              
187     currentValue = regSenseCmd->ConvertToStrin    
188   }                                               
189   else if (command == regionCmd) {                
190     currentValue = theScanner->GetRegionName()    
191   }                                               
192   return currentValue;                            
193 }                                                 
194                                                   
195 // -------------------------------------------    
196 void G4MatScanMessenger::SetNewValue(G4UIcomma    
197 {                                                 
198   if (command == scanCmd) {                       
199     theScanner->Scan();                           
200   }                                               
201   else if (command == thetaCmd) {                 
202     G4Tokenizer next(newValue);                   
203     G4int nbin = StoI(next());                    
204     G4double thetaMin = StoD(next());             
205     G4double thetaSpan = StoD(next());            
206     G4String unit = next();                       
207     thetaMin *= thetaCmd->ValueOf(unit);          
208     thetaSpan *= thetaCmd->ValueOf(unit);         
209     theScanner->SetNTheta(nbin);                  
210     theScanner->SetThetaMin(thetaMin);            
211     theScanner->SetThetaSpan(thetaSpan);          
212   }                                               
213   else if (command == phiCmd) {                   
214     G4Tokenizer next(newValue);                   
215     G4int nbin = StoI(next());                    
216     G4double phiMin = StoD(next());               
217     G4double phiSpan = StoD(next());              
218     G4String unit = next();                       
219     phiMin *= phiCmd->ValueOf(unit);              
220     phiSpan *= phiCmd->ValueOf(unit);             
221     theScanner->SetNPhi(nbin);                    
222     theScanner->SetPhiMin(phiMin);                
223     theScanner->SetPhiSpan(phiSpan);              
224   }                                               
225   else if (command == eyePosCmd) {                
226     theScanner->SetEyePosition(eyePosCmd->GetN    
227   }                                               
228   else if (command == regSenseCmd) {              
229     theScanner->SetRegionSensitive(regSenseCmd    
230   }                                               
231   else if (command == regionCmd) {                
232     if (theScanner->SetRegionName(newValue)) t    
233   }                                               
234   else if(command == verboseCmd)                  
235   {                                               
236     theScanner->SetVerbosity(StoI(newValue));     
237   }                                               
238   else if (command == singleCmd || command ==     
239     G4int ntheta = theScanner->GetNTheta();       
240     G4double thetaMin = theScanner->GetThetaMi    
241     G4double thetaSpan = theScanner->GetThetaS    
242     G4int nphi = theScanner->GetNPhi();           
243     G4double phiMin = theScanner->GetPhiMin();    
244     G4double phiSpan = theScanner->GetPhiSpan(    
245                                                   
246     G4double theta = 0.;                          
247     G4double phi = 0.;                            
248     if (command == singleCmd) {                   
249       G4Tokenizer next(newValue);                 
250       theta = StoD(next());                       
251       phi = StoD(next());                         
252       G4String unit = next();                     
253       theta *= singleCmd->ValueOf(unit);          
254       phi *= singleCmd->ValueOf(unit);            
255     }                                             
256     else if (command == single2Cmd) {             
257       G4ThreeVector v = single2Cmd->GetNew3Vec    
258       theta = 90. * deg - v.theta();              
259       phi = v.phi();                              
260     }                                             
261     theScanner->SetNTheta(1);                     
262     theScanner->SetThetaMin(theta);               
263     theScanner->SetThetaSpan(0.);                 
264     theScanner->SetNPhi(1);                       
265     theScanner->SetPhiMin(phi);                   
266     theScanner->SetPhiSpan(0.);                   
267     theScanner->Scan();                           
268                                                   
269     theScanner->SetNTheta(ntheta);                
270     theScanner->SetThetaMin(thetaMin);            
271     theScanner->SetThetaSpan(thetaSpan);          
272     theScanner->SetNPhi(nphi);                    
273     theScanner->SetPhiMin(phiMin);                
274     theScanner->SetPhiSpan(phiSpan);              
275   }                                               
276 }                                                 
277