Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4MatScanMessenger implementation 26 // G4MatScanMessenger implementation 27 // 27 // 28 // Author: M.Asai, May 2006 28 // Author: M.Asai, May 2006 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4MatScanMessenger.hh" 31 #include "G4MatScanMessenger.hh" 32 32 33 #include "G4MaterialScanner.hh" 33 #include "G4MaterialScanner.hh" 34 #include "G4SystemOfUnits.hh" 34 #include "G4SystemOfUnits.hh" 35 #include "G4ThreeVector.hh" 35 #include "G4ThreeVector.hh" 36 #include "G4Tokenizer.hh" 36 #include "G4Tokenizer.hh" 37 #include "G4UIcmdWith3Vector.hh" 37 #include "G4UIcmdWith3Vector.hh" 38 #include "G4UIcmdWith3VectorAndUnit.hh" 38 #include "G4UIcmdWith3VectorAndUnit.hh" 39 #include "G4UIcmdWithABool.hh" 39 #include "G4UIcmdWithABool.hh" 40 #include "G4UIcmdWithAString.hh" 40 #include "G4UIcmdWithAString.hh" 41 #include "G4UIcmdWithoutParameter.hh" 41 #include "G4UIcmdWithoutParameter.hh" 42 #include "G4UIcmdWithAnInteger.hh" << 43 #include "G4UIcommand.hh" 42 #include "G4UIcommand.hh" 44 #include "G4UIdirectory.hh" 43 #include "G4UIdirectory.hh" 45 #include "G4UIparameter.hh" 44 #include "G4UIparameter.hh" 46 45 47 // ------------------------------------------- 46 // -------------------------------------------------------------------- 48 G4MatScanMessenger::G4MatScanMessenger(G4Mater 47 G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1) 49 { 48 { 50 theScanner = p1; 49 theScanner = p1; 51 G4UIparameter* par; 50 G4UIparameter* par; 52 msDirectory = new G4UIdirectory("/control/ma 51 msDirectory = new G4UIdirectory("/control/matScan/"); 53 msDirectory->SetGuidance("Material scanner c 52 msDirectory->SetGuidance("Material scanner commands."); 54 53 55 scanCmd = new G4UIcmdWithoutParameter("/cont 54 scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan", this); 56 scanCmd->SetGuidance("Start material scannin 55 scanCmd->SetGuidance("Start material scanning."); 57 scanCmd->SetGuidance("Scanning range should 56 scanCmd->SetGuidance("Scanning range should be defined with"); 58 scanCmd->SetGuidance("/control/matScan/theta << 57 scanCmd->SetGuidance( >> 58 "/control/matScan/theta and /control/matSca/phi commands."); 59 scanCmd->AvailableForStates(G4State_Idle); 59 scanCmd->AvailableForStates(G4State_Idle); 60 60 61 thetaCmd = new G4UIcommand("/control/matScan 61 thetaCmd = new G4UIcommand("/control/matScan/theta", this); 62 thetaCmd->SetGuidance("Define theta range.") 62 thetaCmd->SetGuidance("Define theta range."); 63 thetaCmd->SetGuidance("Usage : /control/matS << 63 thetaCmd->SetGuidance( >> 64 "Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]"); 64 thetaCmd->SetGuidance("Notation of angles :" 65 thetaCmd->SetGuidance("Notation of angles :"); 65 thetaCmd->SetGuidance(" theta --- +Z axis : << 66 thetaCmd->SetGuidance( >> 67 " theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg."); 66 par = new G4UIparameter("nbin", 'i', false); 68 par = new G4UIparameter("nbin", 'i', false); 67 par->SetParameterRange("nbin>0"); 69 par->SetParameterRange("nbin>0"); 68 thetaCmd->SetParameter(par); 70 thetaCmd->SetParameter(par); 69 par = new G4UIparameter("thetaMin", 'd', fal 71 par = new G4UIparameter("thetaMin", 'd', false); 70 thetaCmd->SetParameter(par); 72 thetaCmd->SetParameter(par); 71 par = new G4UIparameter("thetaSpan", 'd', tr 73 par = new G4UIparameter("thetaSpan", 'd', true); 72 par->SetParameterRange("thetaSpan>=0."); 74 par->SetParameterRange("thetaSpan>=0."); 73 par->SetDefaultValue(0.); 75 par->SetDefaultValue(0.); 74 thetaCmd->SetParameter(par); 76 thetaCmd->SetParameter(par); 75 par = new G4UIparameter("unit", 'c', true); 77 par = new G4UIparameter("unit", 'c', true); 76 par->SetDefaultValue("deg"); 78 par->SetDefaultValue("deg"); 77 par->SetParameterCandidates(thetaCmd->UnitsL 79 par->SetParameterCandidates(thetaCmd->UnitsList(thetaCmd->CategoryOf("deg"))); 78 thetaCmd->SetParameter(par); 80 thetaCmd->SetParameter(par); 79 81 80 phiCmd = new G4UIcommand("/control/matScan/p 82 phiCmd = new G4UIcommand("/control/matScan/phi", this); 81 phiCmd->SetGuidance("Define phi range."); 83 phiCmd->SetGuidance("Define phi range."); 82 phiCmd->SetGuidance("Usage : /control/matSca << 84 phiCmd->SetGuidance( >> 85 "Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]"); 83 phiCmd->SetGuidance("Notation of angles :"); 86 phiCmd->SetGuidance("Notation of angles :"); 84 phiCmd->SetGuidance( 87 phiCmd->SetGuidance( 85 " phi --- +X axis : 0 deg. / +Y axis : 9 88 " phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 " 86 "deg. / -Y axis : 270 deg."); 89 "deg. / -Y axis : 270 deg."); 87 par = new G4UIparameter("nbin", 'i', false); 90 par = new G4UIparameter("nbin", 'i', false); 88 par->SetParameterRange("nbin>0"); 91 par->SetParameterRange("nbin>0"); 89 phiCmd->SetParameter(par); 92 phiCmd->SetParameter(par); 90 par = new G4UIparameter("phiMin", 'd', false 93 par = new G4UIparameter("phiMin", 'd', false); 91 phiCmd->SetParameter(par); 94 phiCmd->SetParameter(par); 92 par = new G4UIparameter("phiSpan", 'd', true 95 par = new G4UIparameter("phiSpan", 'd', true); 93 par->SetParameterRange("phiSpan>=0."); 96 par->SetParameterRange("phiSpan>=0."); 94 par->SetDefaultValue(0.); 97 par->SetDefaultValue(0.); 95 phiCmd->SetParameter(par); 98 phiCmd->SetParameter(par); 96 par = new G4UIparameter("unit", 'c', true); 99 par = new G4UIparameter("unit", 'c', true); 97 par->SetDefaultValue("deg"); 100 par->SetDefaultValue("deg"); 98 par->SetParameterCandidates(phiCmd->UnitsLis 101 par->SetParameterCandidates(phiCmd->UnitsList(phiCmd->CategoryOf("deg"))); 99 phiCmd->SetParameter(par); 102 phiCmd->SetParameter(par); 100 103 101 singleCmd = new G4UIcommand("/control/matSca 104 singleCmd = new G4UIcommand("/control/matScan/singleMeasure", this); 102 singleCmd->SetGuidance("Measure thickness fo 105 singleCmd->SetGuidance("Measure thickness for one particular direction."); 103 singleCmd->SetGuidance("Notation of angles : 106 singleCmd->SetGuidance("Notation of angles :"); 104 singleCmd->SetGuidance(" theta --- +Z axis : << 107 singleCmd->SetGuidance( >> 108 " theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg."); 105 singleCmd->SetGuidance( 109 singleCmd->SetGuidance( 106 " phi --- +X axis : 0 deg. / +Y axis : 9 110 " phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : " 107 "180 deg. / -Y axis : 270 deg."); 111 "180 deg. / -Y axis : 270 deg."); 108 singleCmd->AvailableForStates(G4State_Idle); 112 singleCmd->AvailableForStates(G4State_Idle); 109 par = new G4UIparameter("theta", 'd', false) 113 par = new G4UIparameter("theta", 'd', false); 110 singleCmd->SetParameter(par); 114 singleCmd->SetParameter(par); 111 par = new G4UIparameter("phi", 'd', false); 115 par = new G4UIparameter("phi", 'd', false); 112 singleCmd->SetParameter(par); 116 singleCmd->SetParameter(par); 113 par = new G4UIparameter("unit", 'c', true); 117 par = new G4UIparameter("unit", 'c', true); 114 par->SetDefaultValue("deg"); 118 par->SetDefaultValue("deg"); 115 par->SetParameterCandidates(singleCmd->Units << 119 par->SetParameterCandidates( >> 120 singleCmd->UnitsList(singleCmd->CategoryOf("deg"))); 116 singleCmd->SetParameter(par); 121 singleCmd->SetParameter(par); 117 122 118 single2Cmd = new G4UIcmdWith3Vector("/contro 123 single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo", this); 119 single2Cmd->SetGuidance("Measure thickness f << 124 single2Cmd->SetGuidance( >> 125 "Measure thickness for one direction defined by a unit vector."); 120 single2Cmd->SetParameterName("X", "Y", "Z", 126 single2Cmd->SetParameterName("X", "Y", "Z", false); 121 127 122 eyePosCmd = new G4UIcmdWith3VectorAndUnit("/ << 128 eyePosCmd = >> 129 new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition", this); 123 eyePosCmd->SetGuidance("Define the eye posit 130 eyePosCmd->SetGuidance("Define the eye position."); 124 eyePosCmd->SetParameterName("X", "Y", "Z", t 131 eyePosCmd->SetParameterName("X", "Y", "Z", true); 125 eyePosCmd->SetDefaultValue(G4ThreeVector(0., 132 eyePosCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.)); 126 eyePosCmd->SetDefaultUnit("m"); 133 eyePosCmd->SetDefaultUnit("m"); 127 134 128 regSenseCmd = new G4UIcmdWithABool("/control 135 regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive", this); 129 regSenseCmd->SetGuidance("Set region sensiti 136 regSenseCmd->SetGuidance("Set region sensitivity."); 130 regSenseCmd->SetGuidance("This command is au 137 regSenseCmd->SetGuidance("This command is automatically set to TRUE"); 131 regSenseCmd->SetGuidance(" if /control/matSc 138 regSenseCmd->SetGuidance(" if /control/matScan/region command is issued."); 132 regSenseCmd->SetParameterName("senseFlag", t 139 regSenseCmd->SetParameterName("senseFlag", true); 133 regSenseCmd->SetDefaultValue(false); 140 regSenseCmd->SetDefaultValue(false); 134 141 135 regionCmd = new G4UIcmdWithAString("/control 142 regionCmd = new G4UIcmdWithAString("/control/matScan/region", this); 136 regionCmd->SetGuidance("Define region name t 143 regionCmd->SetGuidance("Define region name to be scanned."); 137 regionCmd->SetGuidance("/control/matScan/reg << 144 regionCmd->SetGuidance( >> 145 "/control/matScan/regionSensitive command is automatically"); 138 regionCmd->SetGuidance("set to TRUE with thi 146 regionCmd->SetGuidance("set to TRUE with this command."); 139 regionCmd->SetParameterName("region", true); 147 regionCmd->SetParameterName("region", true); 140 regionCmd->SetDefaultValue("DefaultRegionFor 148 regionCmd->SetDefaultValue("DefaultRegionForTheWorld"); 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 } 149 } 150 150 151 // ------------------------------------------- 151 // -------------------------------------------------------------------- 152 G4MatScanMessenger::~G4MatScanMessenger() 152 G4MatScanMessenger::~G4MatScanMessenger() 153 { 153 { 154 delete scanCmd; 154 delete scanCmd; 155 delete thetaCmd; 155 delete thetaCmd; 156 delete phiCmd; 156 delete phiCmd; 157 delete singleCmd; 157 delete singleCmd; 158 delete single2Cmd; 158 delete single2Cmd; 159 delete eyePosCmd; 159 delete eyePosCmd; 160 delete regSenseCmd; 160 delete regSenseCmd; 161 delete regionCmd; 161 delete regionCmd; 162 delete msDirectory; 162 delete msDirectory; 163 } 163 } 164 164 165 // ------------------------------------------- 165 // -------------------------------------------------------------------- 166 G4String G4MatScanMessenger::GetCurrentValue(G 166 G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand* command) 167 { 167 { 168 G4String currentValue; 168 G4String currentValue; 169 if (command == thetaCmd) { << 169 if(command == thetaCmd) >> 170 { 170 currentValue = thetaCmd->ConvertToString(t 171 currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta()); 171 currentValue += " "; 172 currentValue += " "; 172 currentValue += thetaCmd->ConvertToString( << 173 currentValue += >> 174 thetaCmd->ConvertToString((theScanner->GetThetaMin()) / deg); 173 currentValue += " "; 175 currentValue += " "; 174 currentValue += thetaCmd->ConvertToString( << 176 currentValue += >> 177 thetaCmd->ConvertToString((theScanner->GetThetaSpan()) / deg); 175 } 178 } 176 else if (command == phiCmd) { << 179 else if(command == phiCmd) >> 180 { 177 currentValue = phiCmd->ConvertToString(the 181 currentValue = phiCmd->ConvertToString(theScanner->GetNPhi()); 178 currentValue += " "; 182 currentValue += " "; 179 currentValue += phiCmd->ConvertToString((t 183 currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin()) / deg); 180 currentValue += " "; 184 currentValue += " "; 181 currentValue += phiCmd->ConvertToString((t 185 currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan()) / deg); 182 } 186 } 183 else if (command == eyePosCmd) { << 187 else if(command == eyePosCmd) 184 currentValue = eyePosCmd->ConvertToString( << 188 { >> 189 currentValue = >> 190 eyePosCmd->ConvertToString(theScanner->GetEyePosition(), "m"); 185 } 191 } 186 else if (command == regSenseCmd) { << 192 else if(command == regSenseCmd) 187 currentValue = regSenseCmd->ConvertToStrin << 193 { >> 194 currentValue = >> 195 regSenseCmd->ConvertToString(theScanner->GetRegionSensitive()); 188 } 196 } 189 else if (command == regionCmd) { << 197 else if(command == regionCmd) >> 198 { 190 currentValue = theScanner->GetRegionName() 199 currentValue = theScanner->GetRegionName(); 191 } 200 } 192 return currentValue; 201 return currentValue; 193 } 202 } 194 203 195 // ------------------------------------------- 204 // -------------------------------------------------------------------- 196 void G4MatScanMessenger::SetNewValue(G4UIcomma 205 void G4MatScanMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 197 { 206 { 198 if (command == scanCmd) { << 207 if(command == scanCmd) >> 208 { 199 theScanner->Scan(); 209 theScanner->Scan(); 200 } 210 } 201 else if (command == thetaCmd) { << 211 else if(command == thetaCmd) >> 212 { 202 G4Tokenizer next(newValue); 213 G4Tokenizer next(newValue); 203 G4int nbin = StoI(next()); << 214 G4int nbin = StoI(next()); 204 G4double thetaMin = StoD(next()); << 215 G4double thetaMin = StoD(next()); 205 G4double thetaSpan = StoD(next()); 216 G4double thetaSpan = StoD(next()); 206 G4String unit = next(); << 217 G4String unit = next(); 207 thetaMin *= thetaCmd->ValueOf(unit); 218 thetaMin *= thetaCmd->ValueOf(unit); 208 thetaSpan *= thetaCmd->ValueOf(unit); 219 thetaSpan *= thetaCmd->ValueOf(unit); 209 theScanner->SetNTheta(nbin); 220 theScanner->SetNTheta(nbin); 210 theScanner->SetThetaMin(thetaMin); 221 theScanner->SetThetaMin(thetaMin); 211 theScanner->SetThetaSpan(thetaSpan); 222 theScanner->SetThetaSpan(thetaSpan); 212 } 223 } 213 else if (command == phiCmd) { << 224 else if(command == phiCmd) >> 225 { 214 G4Tokenizer next(newValue); 226 G4Tokenizer next(newValue); 215 G4int nbin = StoI(next()); << 227 G4int nbin = StoI(next()); 216 G4double phiMin = StoD(next()); << 228 G4double phiMin = StoD(next()); 217 G4double phiSpan = StoD(next()); 229 G4double phiSpan = StoD(next()); 218 G4String unit = next(); << 230 G4String unit = next(); 219 phiMin *= phiCmd->ValueOf(unit); 231 phiMin *= phiCmd->ValueOf(unit); 220 phiSpan *= phiCmd->ValueOf(unit); 232 phiSpan *= phiCmd->ValueOf(unit); 221 theScanner->SetNPhi(nbin); 233 theScanner->SetNPhi(nbin); 222 theScanner->SetPhiMin(phiMin); 234 theScanner->SetPhiMin(phiMin); 223 theScanner->SetPhiSpan(phiSpan); 235 theScanner->SetPhiSpan(phiSpan); 224 } 236 } 225 else if (command == eyePosCmd) { << 237 else if(command == eyePosCmd) >> 238 { 226 theScanner->SetEyePosition(eyePosCmd->GetN 239 theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); 227 } 240 } 228 else if (command == regSenseCmd) { << 241 else if(command == regSenseCmd) >> 242 { 229 theScanner->SetRegionSensitive(regSenseCmd 243 theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue)); 230 } 244 } 231 else if (command == regionCmd) { << 245 else if(command == regionCmd) 232 if (theScanner->SetRegionName(newValue)) t << 233 } << 234 else if(command == verboseCmd) << 235 { 246 { 236 theScanner->SetVerbosity(StoI(newValue)); << 247 if(theScanner->SetRegionName(newValue)) >> 248 theScanner->SetRegionSensitive(true); 237 } 249 } 238 else if (command == singleCmd || command == << 250 else if(command == singleCmd || command == single2Cmd) 239 G4int ntheta = theScanner->GetNTheta(); << 251 { 240 G4double thetaMin = theScanner->GetThetaMi << 252 G4int ntheta = theScanner->GetNTheta(); >> 253 G4double thetaMin = theScanner->GetThetaMin(); 241 G4double thetaSpan = theScanner->GetThetaS 254 G4double thetaSpan = theScanner->GetThetaSpan(); 242 G4int nphi = theScanner->GetNPhi(); << 255 G4int nphi = theScanner->GetNPhi(); 243 G4double phiMin = theScanner->GetPhiMin(); << 256 G4double phiMin = theScanner->GetPhiMin(); 244 G4double phiSpan = theScanner->GetPhiSpan( << 257 G4double phiSpan = theScanner->GetPhiSpan(); 245 258 246 G4double theta = 0.; 259 G4double theta = 0.; 247 G4double phi = 0.; << 260 G4double phi = 0.; 248 if (command == singleCmd) { << 261 if(command == singleCmd) >> 262 { 249 G4Tokenizer next(newValue); 263 G4Tokenizer next(newValue); 250 theta = StoD(next()); << 264 theta = StoD(next()); 251 phi = StoD(next()); << 265 phi = StoD(next()); 252 G4String unit = next(); 266 G4String unit = next(); 253 theta *= singleCmd->ValueOf(unit); 267 theta *= singleCmd->ValueOf(unit); 254 phi *= singleCmd->ValueOf(unit); 268 phi *= singleCmd->ValueOf(unit); 255 } 269 } 256 else if (command == single2Cmd) { << 270 else if(command == single2Cmd) >> 271 { 257 G4ThreeVector v = single2Cmd->GetNew3Vec 272 G4ThreeVector v = single2Cmd->GetNew3VectorValue(newValue); 258 theta = 90. * deg - v.theta(); << 273 theta = 90. * deg - v.theta(); 259 phi = v.phi(); << 274 phi = v.phi(); 260 } 275 } 261 theScanner->SetNTheta(1); 276 theScanner->SetNTheta(1); 262 theScanner->SetThetaMin(theta); 277 theScanner->SetThetaMin(theta); 263 theScanner->SetThetaSpan(0.); 278 theScanner->SetThetaSpan(0.); 264 theScanner->SetNPhi(1); 279 theScanner->SetNPhi(1); 265 theScanner->SetPhiMin(phi); 280 theScanner->SetPhiMin(phi); 266 theScanner->SetPhiSpan(0.); 281 theScanner->SetPhiSpan(0.); 267 theScanner->Scan(); 282 theScanner->Scan(); 268 283 269 theScanner->SetNTheta(ntheta); 284 theScanner->SetNTheta(ntheta); 270 theScanner->SetThetaMin(thetaMin); 285 theScanner->SetThetaMin(thetaMin); 271 theScanner->SetThetaSpan(thetaSpan); 286 theScanner->SetThetaSpan(thetaSpan); 272 theScanner->SetNPhi(nphi); 287 theScanner->SetNPhi(nphi); 273 theScanner->SetPhiMin(phiMin); 288 theScanner->SetPhiMin(phiMin); 274 theScanner->SetPhiSpan(phiSpan); 289 theScanner->SetPhiSpan(phiSpan); 275 } 290 } 276 } 291 } 277 292