Geant4 Cross Reference |
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 /// \file optical/OpNovice2/src/DetectorMessen 27 /// \brief Implementation of the DetectorMesse 28 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oo 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........oo 51 52 DetectorMessenger::DetectorMessenger(DetectorC 53 { 54 fOpticalDir = new G4UIdirectory("/opnovice2/ 55 fOpticalDir->SetGuidance("Parameters for opt 56 57 fSurfaceTypeCmd = new G4UIcmdWithAString("/o 58 fSurfaceTypeCmd->SetGuidance("Surface type." 59 fSurfaceTypeCmd->AvailableForStates(G4State_ 60 fSurfaceTypeCmd->SetToBeBroadcasted(false); 61 62 fSurfaceFinishCmd = new G4UIcmdWithAString(" 63 fSurfaceFinishCmd->SetGuidance("Surface fini 64 fSurfaceFinishCmd->AvailableForStates(G4Stat 65 fSurfaceFinishCmd->SetToBeBroadcasted(false) 66 67 fSurfaceModelCmd = new G4UIcmdWithAString("/ 68 fSurfaceModelCmd->SetGuidance("surface model 69 fSurfaceModelCmd->AvailableForStates(G4State 70 fSurfaceModelCmd->SetToBeBroadcasted(false); 71 72 fSurfaceSigmaAlphaCmd = new G4UIcmdWithADoub 73 fSurfaceSigmaAlphaCmd->SetGuidance("surface 74 fSurfaceSigmaAlphaCmd->SetGuidance(" paramet 75 fSurfaceSigmaAlphaCmd->AvailableForStates(G4 76 fSurfaceSigmaAlphaCmd->SetToBeBroadcasted(fa 77 78 fSurfacePolishCmd = new G4UIcmdWithADouble(" 79 fSurfacePolishCmd->SetGuidance("surface poli 80 fSurfacePolishCmd->SetGuidance(" parameter ( 81 fSurfacePolishCmd->AvailableForStates(G4Stat 82 fSurfacePolishCmd->SetToBeBroadcasted(false) 83 84 fSurfaceMatPropVectorCmd = new G4UIcmdWithAS 85 fSurfaceMatPropVectorCmd->SetGuidance("Set m 86 fSurfaceMatPropVectorCmd->SetGuidance(" for 87 fSurfaceMatPropVectorCmd->AvailableForStates 88 fSurfaceMatPropVectorCmd->SetToBeBroadcasted 89 90 fSurfaceMatPropConstCmd = new G4UIcmdWithASt 91 fSurfaceMatPropConstCmd->SetGuidance("Set ma 92 fSurfaceMatPropConstCmd->SetGuidance(" for t 93 fSurfaceMatPropConstCmd->AvailableForStates( 94 fSurfaceMatPropConstCmd->SetToBeBroadcasted( 95 96 fTankMatPropVectorCmd = new G4UIcmdWithAStri 97 fTankMatPropVectorCmd->SetGuidance("Set mate 98 fTankMatPropVectorCmd->SetGuidance("the box. 99 fTankMatPropVectorCmd->AvailableForStates(G4 100 fTankMatPropVectorCmd->SetToBeBroadcasted(fa 101 102 fTankMatPropConstCmd = new G4UIcmdWithAStrin 103 fTankMatPropConstCmd->SetGuidance("Set mater 104 fTankMatPropConstCmd->SetGuidance("for the b 105 fTankMatPropConstCmd->AvailableForStates(G4S 106 fTankMatPropConstCmd->SetToBeBroadcasted(fal 107 108 fTankMaterialCmd = new G4UIcmdWithAString("/ 109 fTankMaterialCmd->SetGuidance("Set material 110 fTankMaterialCmd->AvailableForStates(G4State 111 fTankMaterialCmd->SetToBeBroadcasted(false); 112 113 fWorldMatPropVectorCmd = new G4UIcmdWithAStr 114 fWorldMatPropVectorCmd->SetGuidance("Set mat 115 fWorldMatPropVectorCmd->SetGuidance("for the 116 fWorldMatPropVectorCmd->AvailableForStates(G 117 fWorldMatPropVectorCmd->SetToBeBroadcasted(f 118 119 fWorldMatPropConstCmd = new G4UIcmdWithAStri 120 fWorldMatPropConstCmd->SetGuidance("Set mate 121 fWorldMatPropConstCmd->SetGuidance(" for the 122 fWorldMatPropConstCmd->AvailableForStates(G4 123 fWorldMatPropConstCmd->SetToBeBroadcasted(fa 124 125 fWorldMaterialCmd = new G4UIcmdWithAString(" 126 fWorldMaterialCmd->SetGuidance("Set material 127 fWorldMaterialCmd->AvailableForStates(G4Stat 128 fWorldMaterialCmd->SetToBeBroadcasted(false) 129 } 130 131 //....oooOO0OOooo........oooOO0OOooo........oo 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........oo 152 153 void DetectorMessenger::SetNewValue(G4UIcomman 154 { 155 // FINISH 156 if (command == fSurfaceFinishCmd) { 157 if (newValue == "polished") { 158 fDetector->SetSurfaceFinish(polished); 159 } 160 else if (newValue == "polishedfrontpainted 161 fDetector->SetSurfaceFinish(polishedfron 162 } 163 else if (newValue == "polishedbackpainted" 164 fDetector->SetSurfaceFinish(polishedback 165 } 166 else if (newValue == "ground") { 167 fDetector->SetSurfaceFinish(ground); 168 } 169 else if (newValue == "groundfrontpainted") 170 fDetector->SetSurfaceFinish(groundfrontp 171 } 172 else if (newValue == "groundbackpainted") 173 fDetector->SetSurfaceFinish(groundbackpa 174 } 175 else if (newValue == "polishedlumirrorair" 176 fDetector->SetSurfaceFinish(polishedlumi 177 } 178 else if (newValue == "polishedlumirrorglue 179 fDetector->SetSurfaceFinish(polishedlumi 180 } 181 else if (newValue == "polishedair") { 182 fDetector->SetSurfaceFinish(polishedair) 183 } 184 else if (newValue == "polishedteflonair") 185 fDetector->SetSurfaceFinish(polishedtefl 186 } 187 else if (newValue == "polishedtioair") { 188 fDetector->SetSurfaceFinish(polishedtioa 189 } 190 else if (newValue == "polishedtyvekair") { 191 fDetector->SetSurfaceFinish(polishedtyve 192 } 193 else if (newValue == "polishedvm2000air") 194 fDetector->SetSurfaceFinish(polishedvm20 195 } 196 else if (newValue == "polishedvm2000glue") 197 fDetector->SetSurfaceFinish(polishedvm20 198 } 199 else if (newValue == "etchedlumirrorair") 200 fDetector->SetSurfaceFinish(etchedlumirr 201 } 202 else if (newValue == "etchedlumirrorglue") 203 fDetector->SetSurfaceFinish(etchedlumirr 204 } 205 else if (newValue == "etchedair") { 206 fDetector->SetSurfaceFinish(etchedair); 207 } 208 else if (newValue == "etchedteflonair") { 209 fDetector->SetSurfaceFinish(etchedteflon 210 } 211 else if (newValue == "etchedtioair") { 212 fDetector->SetSurfaceFinish(etchedtioair 213 } 214 else if (newValue == "etchedtyvekair") { 215 fDetector->SetSurfaceFinish(etchedtyveka 216 } 217 else if (newValue == "etchedvm2000air") { 218 fDetector->SetSurfaceFinish(etchedvm2000 219 } 220 else if (newValue == "etchedvm2000glue") { 221 fDetector->SetSurfaceFinish(etchedvm2000 222 } 223 else if (newValue == "groundlumirrorair") 224 fDetector->SetSurfaceFinish(groundlumirr 225 } 226 else if (newValue == "groundlumirrorglue") 227 fDetector->SetSurfaceFinish(groundlumirr 228 } 229 else if (newValue == "groundair") { 230 fDetector->SetSurfaceFinish(groundair); 231 } 232 else if (newValue == "groundteflonair") { 233 fDetector->SetSurfaceFinish(groundteflon 234 } 235 else if (newValue == "groundtioair") { 236 fDetector->SetSurfaceFinish(groundtioair 237 } 238 else if (newValue == "groundtyvekair") { 239 fDetector->SetSurfaceFinish(groundtyveka 240 } 241 else if (newValue == "groundvm2000air") { 242 fDetector->SetSurfaceFinish(groundvm2000 243 } 244 else if (newValue == "groundvm2000glue") { 245 fDetector->SetSurfaceFinish(groundvm2000 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_ 253 } 254 else if (newValue == "RoughESR_LUT") { 255 fDetector->SetSurfaceFinish(RoughESR_LUT 256 } 257 else if (newValue == "RoughESRGrease_LUT") 258 fDetector->SetSurfaceFinish(RoughESRGrea 259 } 260 else if (newValue == "Polished_LUT") { 261 fDetector->SetSurfaceFinish(Polished_LUT 262 } 263 else if (newValue == "PolishedTeflon_LUT") 264 fDetector->SetSurfaceFinish(PolishedTefl 265 } 266 else if (newValue == "PolishedESR_LUT") { 267 fDetector->SetSurfaceFinish(PolishedESR_ 268 } 269 else if (newValue == "PolishedESRGrease_LU 270 fDetector->SetSurfaceFinish(PolishedESRG 271 } 272 else if (newValue == "Detector_LUT") { 273 fDetector->SetSurfaceFinish(Detector_LUT 274 } 275 else { 276 G4ExceptionDescription ed; 277 ed << "Invalid surface finish: " << newV 278 G4Exception("DetectorMessenger", "OpNovi 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: " << newVa 302 G4Exception("DetectorMessenger", "ONovic 303 } 304 } 305 306 // TYPE 307 else if (command == fSurfaceTypeCmd) { 308 if (newValue == "dielectric_metal") { 309 fDetector->SetSurfaceType(dielectric_met 310 } 311 else if (newValue == "dielectric_dielectri 312 fDetector->SetSurfaceType(dielectric_die 313 } 314 else if (newValue == "dielectric_LUT") { 315 fDetector->SetSurfaceType(dielectric_LUT 316 } 317 else if (newValue == "dielectric_LUTDAVIS" 318 fDetector->SetSurfaceType(dielectric_LUT 319 } 320 else if (newValue == "coated") { 321 fDetector->SetSurfaceType(coated); 322 } 323 else { 324 G4ExceptionDescription ed; 325 ed << "Invalid surface type: " << newVal 326 G4Exception("DetectorMessenger", "OpNovi 327 } 328 } 329 else if (command == fSurfaceSigmaAlphaCmd) { 330 fDetector->SetSurfaceSigmaAlpha(G4UIcmdWit 331 } 332 else if (command == fSurfacePolishCmd) { 333 fDetector->SetSurfacePolish(G4UIcmdWithADo 334 } 335 else if (command == fTankMatPropVectorCmd) { 336 // got a string. need to convert it to phy 337 // string format is property name, then pa 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::ConvertToDoub 351 instring >> tmp; 352 G4double val = G4UIcommand::ConvertToDou 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 pa 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::ConvertToDoub 372 instring >> tmp; 373 G4double val = G4UIcommand::ConvertToDou 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 pa 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::ConvertToDoub 394 instring >> tmp; 395 G4double val = G4UIcommand::ConvertToDou 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 va 404 // space delimited 405 std::istringstream instring(newValue); 406 G4String prop; 407 G4String tmp; 408 instring >> prop; 409 instring >> tmp; 410 G4double val = G4UIcommand::ConvertToDoubl 411 fDetector->AddTankMPC(prop, val); 412 } 413 else if (command == fWorldMatPropConstCmd) { 414 // Convert string to physics vector 415 // string format is property name, then va 416 // space delimited 417 std::istringstream instring(newValue); 418 G4String prop; 419 G4String tmp; 420 instring >> prop; 421 instring >> tmp; 422 G4double val = G4UIcommand::ConvertToDoubl 423 fDetector->AddWorldMPC(prop, val); 424 } 425 else if (command == fSurfaceMatPropConstCmd) 426 // Convert string to physics vector 427 // string format is property name, then va 428 // space delimited 429 std::istringstream instring(newValue); 430 G4String prop; 431 G4String tmp; 432 instring >> prop; 433 instring >> tmp; 434 G4double val = G4UIcommand::ConvertToDoubl 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........oo 446