Geant4 Cross Reference |
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 /// \file optical/OpNovice2/src/DetectorMessenger.cc 27 /// \brief Implementation of the DetectorMessenger class 28 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 33 #include "DetectorMessenger.hh" 34 35 #include "DetectorConstruction.hh" 36 37 #include "G4OpticalSurface.hh" 38 #include "G4UIcmdWithADouble.hh" 39 #include "G4UIcmdWithADoubleAndUnit.hh" 40 #include "G4UIcmdWithAString.hh" 41 #include "G4UIcmdWithAnInteger.hh" 42 #include "G4UIcmdWithoutParameter.hh" 43 #include "G4UIcommand.hh" 44 #include "G4UIdirectory.hh" 45 #include "G4UIparameter.hh" 46 47 #include <iostream> 48 #include <sstream> 49 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 52 DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : G4UImessenger(), fDetector(Det) 53 { 54 fOpticalDir = new G4UIdirectory("/opnovice2/"); 55 fOpticalDir->SetGuidance("Parameters for optical simulation."); 56 57 fSurfaceTypeCmd = new G4UIcmdWithAString("/opnovice2/surfaceType", this); 58 fSurfaceTypeCmd->SetGuidance("Surface type."); 59 fSurfaceTypeCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 60 fSurfaceTypeCmd->SetToBeBroadcasted(false); 61 62 fSurfaceFinishCmd = new G4UIcmdWithAString("/opnovice2/surfaceFinish", this); 63 fSurfaceFinishCmd->SetGuidance("Surface finish."); 64 fSurfaceFinishCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 65 fSurfaceFinishCmd->SetToBeBroadcasted(false); 66 67 fSurfaceModelCmd = new G4UIcmdWithAString("/opnovice2/surfaceModel", this); 68 fSurfaceModelCmd->SetGuidance("surface model."); 69 fSurfaceModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 70 fSurfaceModelCmd->SetToBeBroadcasted(false); 71 72 fSurfaceSigmaAlphaCmd = new G4UIcmdWithADouble("/opnovice2/surfaceSigmaAlpha", this); 73 fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha"); 74 fSurfaceSigmaAlphaCmd->SetGuidance(" parameter."); 75 fSurfaceSigmaAlphaCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 76 fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(false); 77 78 fSurfacePolishCmd = new G4UIcmdWithADouble("/opnovice2/surfacePolish", this); 79 fSurfacePolishCmd->SetGuidance("surface polish"); 80 fSurfacePolishCmd->SetGuidance(" parameter (for Glisur model)."); 81 fSurfacePolishCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 82 fSurfacePolishCmd->SetToBeBroadcasted(false); 83 84 fSurfaceMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/surfaceProperty", this); 85 fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector"); 86 fSurfaceMatPropVectorCmd->SetGuidance(" for the surface."); 87 fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 88 fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false); 89 90 fSurfaceMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/surfaceConstProperty", this); 91 fSurfaceMatPropConstCmd->SetGuidance("Set material constant property"); 92 fSurfaceMatPropConstCmd->SetGuidance(" for the surface."); 93 fSurfaceMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 94 fSurfaceMatPropConstCmd->SetToBeBroadcasted(false); 95 96 fTankMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/boxProperty", this); 97 fTankMatPropVectorCmd->SetGuidance("Set material property vector for "); 98 fTankMatPropVectorCmd->SetGuidance("the box."); 99 fTankMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 100 fTankMatPropVectorCmd->SetToBeBroadcasted(false); 101 102 fTankMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/boxConstProperty", this); 103 fTankMatPropConstCmd->SetGuidance("Set material constant property "); 104 fTankMatPropConstCmd->SetGuidance("for the box."); 105 fTankMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 106 fTankMatPropConstCmd->SetToBeBroadcasted(false); 107 108 fTankMaterialCmd = new G4UIcmdWithAString("/opnovice2/boxMaterial", this); 109 fTankMaterialCmd->SetGuidance("Set material of box."); 110 fTankMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 111 fTankMaterialCmd->SetToBeBroadcasted(false); 112 113 fWorldMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/worldProperty", this); 114 fWorldMatPropVectorCmd->SetGuidance("Set material property vector "); 115 fWorldMatPropVectorCmd->SetGuidance("for the world."); 116 fWorldMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 117 fWorldMatPropVectorCmd->SetToBeBroadcasted(false); 118 119 fWorldMatPropConstCmd = new G4UIcmdWithAString("/opnovice2/worldConstProperty", this); 120 fWorldMatPropConstCmd->SetGuidance("Set material constant property"); 121 fWorldMatPropConstCmd->SetGuidance(" for the world."); 122 fWorldMatPropConstCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 123 fWorldMatPropConstCmd->SetToBeBroadcasted(false); 124 125 fWorldMaterialCmd = new G4UIcmdWithAString("/opnovice2/worldMaterial", this); 126 fWorldMaterialCmd->SetGuidance("Set material of world."); 127 fWorldMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 128 fWorldMaterialCmd->SetToBeBroadcasted(false); 129 } 130 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 132 133 DetectorMessenger::~DetectorMessenger() 134 { 135 delete fOpticalDir; 136 delete fSurfaceFinishCmd; 137 delete fSurfaceTypeCmd; 138 delete fSurfaceModelCmd; 139 delete fSurfaceSigmaAlphaCmd; 140 delete fSurfacePolishCmd; 141 delete fSurfaceMatPropVectorCmd; 142 delete fSurfaceMatPropConstCmd; 143 delete fTankMatPropVectorCmd; 144 delete fTankMatPropConstCmd; 145 delete fTankMaterialCmd; 146 delete fWorldMatPropVectorCmd; 147 delete fWorldMatPropConstCmd; 148 delete fWorldMaterialCmd; 149 } 150 151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 152 153 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 154 { 155 // FINISH 156 if (command == fSurfaceFinishCmd) { 157 if (newValue == "polished") { 158 fDetector->SetSurfaceFinish(polished); 159 } 160 else if (newValue == "polishedfrontpainted") { 161 fDetector->SetSurfaceFinish(polishedfrontpainted); 162 } 163 else if (newValue == "polishedbackpainted") { 164 fDetector->SetSurfaceFinish(polishedbackpainted); 165 } 166 else if (newValue == "ground") { 167 fDetector->SetSurfaceFinish(ground); 168 } 169 else if (newValue == "groundfrontpainted") { 170 fDetector->SetSurfaceFinish(groundfrontpainted); 171 } 172 else if (newValue == "groundbackpainted") { 173 fDetector->SetSurfaceFinish(groundbackpainted); 174 } 175 else if (newValue == "polishedlumirrorair") { 176 fDetector->SetSurfaceFinish(polishedlumirrorair); 177 } 178 else if (newValue == "polishedlumirrorglue") { 179 fDetector->SetSurfaceFinish(polishedlumirrorglue); 180 } 181 else if (newValue == "polishedair") { 182 fDetector->SetSurfaceFinish(polishedair); 183 } 184 else if (newValue == "polishedteflonair") { 185 fDetector->SetSurfaceFinish(polishedteflonair); 186 } 187 else if (newValue == "polishedtioair") { 188 fDetector->SetSurfaceFinish(polishedtioair); 189 } 190 else if (newValue == "polishedtyvekair") { 191 fDetector->SetSurfaceFinish(polishedtyvekair); 192 } 193 else if (newValue == "polishedvm2000air") { 194 fDetector->SetSurfaceFinish(polishedvm2000air); 195 } 196 else if (newValue == "polishedvm2000glue") { 197 fDetector->SetSurfaceFinish(polishedvm2000glue); 198 } 199 else if (newValue == "etchedlumirrorair") { 200 fDetector->SetSurfaceFinish(etchedlumirrorair); 201 } 202 else if (newValue == "etchedlumirrorglue") { 203 fDetector->SetSurfaceFinish(etchedlumirrorglue); 204 } 205 else if (newValue == "etchedair") { 206 fDetector->SetSurfaceFinish(etchedair); 207 } 208 else if (newValue == "etchedteflonair") { 209 fDetector->SetSurfaceFinish(etchedteflonair); 210 } 211 else if (newValue == "etchedtioair") { 212 fDetector->SetSurfaceFinish(etchedtioair); 213 } 214 else if (newValue == "etchedtyvekair") { 215 fDetector->SetSurfaceFinish(etchedtyvekair); 216 } 217 else if (newValue == "etchedvm2000air") { 218 fDetector->SetSurfaceFinish(etchedvm2000air); 219 } 220 else if (newValue == "etchedvm2000glue") { 221 fDetector->SetSurfaceFinish(etchedvm2000glue); 222 } 223 else if (newValue == "groundlumirrorair") { 224 fDetector->SetSurfaceFinish(groundlumirrorair); 225 } 226 else if (newValue == "groundlumirrorglue") { 227 fDetector->SetSurfaceFinish(groundlumirrorglue); 228 } 229 else if (newValue == "groundair") { 230 fDetector->SetSurfaceFinish(groundair); 231 } 232 else if (newValue == "groundteflonair") { 233 fDetector->SetSurfaceFinish(groundteflonair); 234 } 235 else if (newValue == "groundtioair") { 236 fDetector->SetSurfaceFinish(groundtioair); 237 } 238 else if (newValue == "groundtyvekair") { 239 fDetector->SetSurfaceFinish(groundtyvekair); 240 } 241 else if (newValue == "groundvm2000air") { 242 fDetector->SetSurfaceFinish(groundvm2000air); 243 } 244 else if (newValue == "groundvm2000glue") { 245 fDetector->SetSurfaceFinish(groundvm2000glue); 246 } 247 // for Davis model 248 else if (newValue == "Rough_LUT") { 249 fDetector->SetSurfaceFinish(Rough_LUT); 250 } 251 else if (newValue == "RoughTeflon_LUT") { 252 fDetector->SetSurfaceFinish(RoughTeflon_LUT); 253 } 254 else if (newValue == "RoughESR_LUT") { 255 fDetector->SetSurfaceFinish(RoughESR_LUT); 256 } 257 else if (newValue == "RoughESRGrease_LUT") { 258 fDetector->SetSurfaceFinish(RoughESRGrease_LUT); 259 } 260 else if (newValue == "Polished_LUT") { 261 fDetector->SetSurfaceFinish(Polished_LUT); 262 } 263 else if (newValue == "PolishedTeflon_LUT") { 264 fDetector->SetSurfaceFinish(PolishedTeflon_LUT); 265 } 266 else if (newValue == "PolishedESR_LUT") { 267 fDetector->SetSurfaceFinish(PolishedESR_LUT); 268 } 269 else if (newValue == "PolishedESRGrease_LUT") { 270 fDetector->SetSurfaceFinish(PolishedESRGrease_LUT); 271 } 272 else if (newValue == "Detector_LUT") { 273 fDetector->SetSurfaceFinish(Detector_LUT); 274 } 275 else { 276 G4ExceptionDescription ed; 277 ed << "Invalid surface finish: " << newValue; 278 G4Exception("DetectorMessenger", "OpNovice2_003", FatalException, ed); 279 } 280 } 281 282 // MODEL 283 else if (command == fSurfaceModelCmd) { 284 if (newValue == "glisur") { 285 fDetector->SetSurfaceModel(glisur); 286 } 287 else if (newValue == "unified") { 288 fDetector->SetSurfaceModel(unified); 289 } 290 else if (newValue == "LUT") { 291 fDetector->SetSurfaceModel(LUT); 292 } 293 else if (newValue == "DAVIS") { 294 fDetector->SetSurfaceModel(DAVIS); 295 } 296 else if (newValue == "dichroic") { 297 fDetector->SetSurfaceModel(dichroic); 298 } 299 else { 300 G4ExceptionDescription ed; 301 ed << "Invalid surface model: " << newValue; 302 G4Exception("DetectorMessenger", "ONovice2_001", FatalException, ed); 303 } 304 } 305 306 // TYPE 307 else if (command == fSurfaceTypeCmd) { 308 if (newValue == "dielectric_metal") { 309 fDetector->SetSurfaceType(dielectric_metal); 310 } 311 else if (newValue == "dielectric_dielectric") { 312 fDetector->SetSurfaceType(dielectric_dielectric); 313 } 314 else if (newValue == "dielectric_LUT") { 315 fDetector->SetSurfaceType(dielectric_LUT); 316 } 317 else if (newValue == "dielectric_LUTDAVIS") { 318 fDetector->SetSurfaceType(dielectric_LUTDAVIS); 319 } 320 else if (newValue == "coated") { 321 fDetector->SetSurfaceType(coated); 322 } 323 else { 324 G4ExceptionDescription ed; 325 ed << "Invalid surface type: " << newValue; 326 G4Exception("DetectorMessenger", "OpNovice2_002", FatalException, ed); 327 } 328 } 329 else if (command == fSurfaceSigmaAlphaCmd) { 330 fDetector->SetSurfaceSigmaAlpha(G4UIcmdWithADouble::GetNewDoubleValue(newValue)); 331 } 332 else if (command == fSurfacePolishCmd) { 333 fDetector->SetSurfacePolish(G4UIcmdWithADouble::GetNewDoubleValue(newValue)); 334 } 335 else if (command == fTankMatPropVectorCmd) { 336 // got a string. need to convert it to physics vector. 337 // string format is property name, then pairs of energy, value 338 // specify units for each value, eg 3.0*eV 339 // space delimited 340 auto mpv = new G4MaterialPropertyVector(); 341 std::istringstream instring(newValue); 342 G4String prop; 343 instring >> prop; 344 while (instring) { 345 G4String tmp; 346 instring >> tmp; 347 if (tmp == "") { 348 break; 349 } 350 G4double en = G4UIcommand::ConvertToDouble(tmp); 351 instring >> tmp; 352 G4double val = G4UIcommand::ConvertToDouble(tmp); 353 mpv->InsertValues(en, val); 354 } 355 356 fDetector->AddTankMPV(prop, mpv); 357 } 358 else if (command == fWorldMatPropVectorCmd) { 359 // Convert string to physics vector 360 // string format is property name, then pairs of energy, value 361 auto mpv = new G4MaterialPropertyVector(); 362 std::istringstream instring(newValue); 363 G4String prop; 364 instring >> prop; 365 while (instring) { 366 G4String tmp; 367 instring >> tmp; 368 if (tmp == "") { 369 break; 370 } 371 G4double en = G4UIcommand::ConvertToDouble(tmp); 372 instring >> tmp; 373 G4double val = G4UIcommand::ConvertToDouble(tmp); 374 mpv->InsertValues(en, val); 375 } 376 fDetector->AddWorldMPV(prop, mpv); 377 } 378 else if (command == fSurfaceMatPropVectorCmd) { 379 // Convert string to physics vector 380 // string format is property name, then pairs of energy, value 381 // space delimited 382 auto mpv = new G4MaterialPropertyVector(); 383 G4cout << newValue << G4endl; 384 std::istringstream instring(newValue); 385 G4String prop; 386 instring >> prop; 387 while (instring) { 388 G4String tmp; 389 instring >> tmp; 390 if (tmp == "") { 391 break; 392 } 393 G4double en = G4UIcommand::ConvertToDouble(tmp); 394 instring >> tmp; 395 G4double val = G4UIcommand::ConvertToDouble(tmp); 396 mpv->InsertValues(en, val); 397 } 398 fDetector->AddSurfaceMPV(prop, mpv); 399 } 400 401 else if (command == fTankMatPropConstCmd) { 402 // Convert string to physics vector 403 // string format is property name, then value 404 // space delimited 405 std::istringstream instring(newValue); 406 G4String prop; 407 G4String tmp; 408 instring >> prop; 409 instring >> tmp; 410 G4double val = G4UIcommand::ConvertToDouble(tmp); 411 fDetector->AddTankMPC(prop, val); 412 } 413 else if (command == fWorldMatPropConstCmd) { 414 // Convert string to physics vector 415 // string format is property name, then value 416 // space delimited 417 std::istringstream instring(newValue); 418 G4String prop; 419 G4String tmp; 420 instring >> prop; 421 instring >> tmp; 422 G4double val = G4UIcommand::ConvertToDouble(tmp); 423 fDetector->AddWorldMPC(prop, val); 424 } 425 else if (command == fSurfaceMatPropConstCmd) { 426 // Convert string to physics vector 427 // string format is property name, then value 428 // space delimited 429 std::istringstream instring(newValue); 430 G4String prop; 431 G4String tmp; 432 instring >> prop; 433 instring >> tmp; 434 G4double val = G4UIcommand::ConvertToDouble(tmp); 435 fDetector->AddSurfaceMPC(prop, val); 436 } 437 else if (command == fWorldMaterialCmd) { 438 fDetector->SetWorldMaterial(newValue); 439 } 440 else if (command == fTankMaterialCmd) { 441 fDetector->SetTankMaterial(newValue); 442 } 443 } 444 445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 446