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 // ------------------------------------------- 27 // 28 // GEANT4 Class file 29 // 30 // File name: G4OpticalParameters 31 // 32 // Author: Daren Sawkey based on G4EmPa 33 // 34 // Creation date: 14.07.2020 35 // 36 // Modifications: 37 // 38 // ------------------------------------------- 39 // 40 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oo 42 43 #include "G4OpticalParameters.hh" 44 #include "G4OpticalParametersMessenger.hh" 45 #include "G4PhysicalConstants.hh" 46 #include "G4UnitsTable.hh" 47 #include "G4SystemOfUnits.hh" 48 #include "G4ApplicationState.hh" 49 #include "G4StateManager.hh" 50 51 G4OpticalParameters* G4OpticalParameters::theI 52 53 #ifdef G4MULTITHREADED 54 G4Mutex G4OpticalParameters::opticalParameters 55 #endif 56 57 //....oooOO0OOooo........oooOO0OOooo........oo 58 59 G4OpticalParameters* G4OpticalParameters::Inst 60 { 61 if(nullptr == theInstance) 62 { 63 #ifdef G4MULTITHREADED 64 G4MUTEXLOCK(&opticalParametersMutex); 65 if(nullptr == theInstance) 66 { 67 #endif 68 static G4OpticalParameters manager; 69 theInstance = &manager; 70 #ifdef G4MULTITHREADED 71 } 72 G4MUTEXUNLOCK(&opticalParametersMutex); 73 #endif 74 } 75 return theInstance; 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oo 79 80 G4OpticalParameters::~G4OpticalParameters() { 81 82 //....oooOO0OOooo........oooOO0OOooo........oo 83 84 G4OpticalParameters::G4OpticalParameters() 85 { 86 theMessenger = new G4OpticalParametersMessen 87 Initialise(); 88 89 fStateManager = G4StateManager::GetStateMana 90 } 91 92 void G4OpticalParameters::SetDefaults() 93 { 94 if(!IsLocked()) 95 { 96 Initialise(); 97 } 98 } 99 100 void G4OpticalParameters::Initialise() 101 { 102 verboseLevel = 1; 103 104 cerenkovStackPhotons = true; 105 cerenkovTrackSecondariesFirst = true; 106 cerenkovVerboseLevel = 1; 107 cerenkovMaxPhotons = 100; 108 cerenkovMaxBetaChange = 10.; 109 110 scintByParticleType = false; 111 scintTrackInfo = false; 112 scintStackPhotons = true; 113 scintFiniteRiseTime = false; 114 scintTrackSecondariesFirst = true; 115 scintVerboseLevel = 1; 116 117 wlsTimeProfileName = "delta"; 118 wlsVerboseLevel = 1; 119 120 wls2TimeProfileName = "delta"; 121 wls2VerboseLevel = 1; 122 123 absorptionVerboseLevel = 1; 124 125 rayleighVerboseLevel = 1; 126 127 mieVerboseLevel = 1; 128 129 boundaryInvokeSD = false; 130 boundaryVerboseLevel = 1; 131 132 processActivation["OpRayleigh"] = true; 133 processActivation["OpBoundary"] = true; 134 processActivation["OpMieHG"] = true; 135 processActivation["OpAbsorption"] = true; 136 processActivation["OpWLS"] = true; 137 processActivation["OpWLS2"] = true; 138 processActivation["Cerenkov"] = true; 139 processActivation["Scintillation"] = true; 140 } 141 142 void G4OpticalParameters::SetVerboseLevel(G4in 143 { 144 if(IsLocked()) 145 { 146 return; 147 } 148 verboseLevel = val; 149 SetCerenkovVerboseLevel(verboseLevel); 150 SetScintVerboseLevel(verboseLevel); 151 SetRayleighVerboseLevel(verboseLevel); 152 SetAbsorptionVerboseLevel(verboseLevel); 153 SetMieVerboseLevel(verboseLevel); 154 SetBoundaryVerboseLevel(verboseLevel); 155 SetWLSVerboseLevel(verboseLevel); 156 SetWLS2VerboseLevel(verboseLevel); 157 } 158 159 G4int G4OpticalParameters::GetVerboseLevel() c 160 161 void G4OpticalParameters::SetProcessActivation 162 163 { 164 // Configure the physics constructor to use/ 165 // This method can only be called in PreInit 166 // ConstructProcess). The process is not add 167 // and so it cannot be re-activated later in 168 // /process/activate. 169 170 if(IsLocked()) 171 { 172 return; 173 } 174 if(processActivation[process] == val) 175 return; 176 177 // processActivation keys defined at initial 178 if(processActivation.find(process) != proces 179 { 180 processActivation[process] = val; 181 } 182 else 183 { 184 G4ExceptionDescription ed; 185 ed << "Process name " << process << " out 186 G4Exception("G4OpticalParameters::SetProce 187 FatalException, ed); 188 } 189 } 190 191 G4bool G4OpticalParameters::GetProcessActivati 192 { 193 return processActivation.find(process)->seco 194 } 195 196 void G4OpticalParameters::SetCerenkovStackPhot 197 { 198 if(IsLocked()) 199 { 200 return; 201 } 202 cerenkovStackPhotons = val; 203 } 204 205 G4bool G4OpticalParameters::GetCerenkovStackPh 206 { 207 return cerenkovStackPhotons; 208 } 209 210 void G4OpticalParameters::SetCerenkovVerboseLe 211 { 212 if(IsLocked()) 213 { 214 return; 215 } 216 cerenkovVerboseLevel = val; 217 } 218 219 G4int G4OpticalParameters::GetCerenkovVerboseL 220 { 221 return cerenkovVerboseLevel; 222 } 223 224 void G4OpticalParameters::SetCerenkovMaxPhoton 225 { 226 if(IsLocked()) 227 { 228 return; 229 } 230 cerenkovMaxPhotons = val; 231 } 232 233 G4int G4OpticalParameters::GetCerenkovMaxPhoto 234 { 235 return cerenkovMaxPhotons; 236 } 237 238 void G4OpticalParameters::SetCerenkovMaxBetaCh 239 { 240 if(IsLocked()) 241 { 242 return; 243 } 244 cerenkovMaxBetaChange = val; 245 } 246 247 G4double G4OpticalParameters::GetCerenkovMaxBe 248 { 249 return cerenkovMaxBetaChange; 250 } 251 252 void G4OpticalParameters::SetCerenkovTrackSeco 253 { 254 if(IsLocked()) 255 { 256 return; 257 } 258 cerenkovTrackSecondariesFirst = val; 259 } 260 261 G4bool G4OpticalParameters::GetCerenkovTrackSe 262 { 263 return cerenkovTrackSecondariesFirst; 264 } 265 266 void G4OpticalParameters::SetScintByParticleTy 267 { 268 if(IsLocked()) 269 { 270 return; 271 } 272 scintByParticleType = val; 273 } 274 275 G4bool G4OpticalParameters::GetScintByParticle 276 { 277 return scintByParticleType; 278 } 279 280 void G4OpticalParameters::SetScintTrackInfo(G4 281 { 282 if(IsLocked()) 283 { 284 return; 285 } 286 scintTrackInfo = val; 287 } 288 289 G4bool G4OpticalParameters::GetScintTrackInfo( 290 291 void G4OpticalParameters::SetScintTrackSeconda 292 { 293 if(IsLocked()) 294 { 295 return; 296 } 297 scintTrackSecondariesFirst = val; 298 } 299 300 G4bool G4OpticalParameters::GetScintTrackSecon 301 { 302 return scintTrackSecondariesFirst; 303 } 304 305 void G4OpticalParameters::SetScintFiniteRiseTi 306 { 307 if(IsLocked()) 308 { 309 return; 310 } 311 scintFiniteRiseTime = val; 312 } 313 314 G4bool G4OpticalParameters::GetScintFiniteRise 315 { 316 return scintFiniteRiseTime; 317 } 318 319 void G4OpticalParameters::SetScintStackPhotons 320 { 321 if(IsLocked()) 322 { 323 return; 324 } 325 scintStackPhotons = val; 326 } 327 328 G4bool G4OpticalParameters::GetScintStackPhoto 329 { 330 return scintStackPhotons; 331 } 332 333 void G4OpticalParameters::SetScintVerboseLevel 334 { 335 if(IsLocked()) 336 { 337 return; 338 } 339 scintVerboseLevel = val; 340 } 341 342 G4int G4OpticalParameters::GetScintVerboseLeve 343 { 344 return scintVerboseLevel; 345 } 346 347 void G4OpticalParameters::SetWLSTimeProfile(co 348 { 349 if(IsLocked()) 350 { 351 return; 352 } 353 wlsTimeProfileName = val; 354 } 355 356 G4String G4OpticalParameters::GetWLSTimeProfil 357 { 358 return wlsTimeProfileName; 359 } 360 361 void G4OpticalParameters::SetWLSVerboseLevel(G 362 { 363 if(IsLocked()) 364 { 365 return; 366 } 367 wlsVerboseLevel = val; 368 } 369 370 G4int G4OpticalParameters::GetWLSVerboseLevel( 371 { 372 return wlsVerboseLevel; 373 } 374 375 void G4OpticalParameters::SetWLS2TimeProfile(c 376 { 377 if(IsLocked()) 378 { 379 return; 380 } 381 wls2TimeProfileName = val; 382 } 383 384 G4String G4OpticalParameters::GetWLS2TimeProfi 385 { 386 return wls2TimeProfileName; 387 } 388 389 void G4OpticalParameters::SetWLS2VerboseLevel( 390 { 391 if(IsLocked()) 392 { 393 return; 394 } 395 wls2VerboseLevel = val; 396 } 397 398 G4int G4OpticalParameters::GetWLS2VerboseLevel 399 { 400 return wls2VerboseLevel; 401 } 402 403 void G4OpticalParameters::SetBoundaryVerboseLe 404 { 405 if(IsLocked()) 406 { 407 return; 408 } 409 boundaryVerboseLevel = val; 410 } 411 412 G4int G4OpticalParameters::GetBoundaryVerboseL 413 { 414 return boundaryVerboseLevel; 415 } 416 417 void G4OpticalParameters::SetBoundaryInvokeSD( 418 { 419 if(IsLocked()) 420 { 421 return; 422 } 423 boundaryInvokeSD = val; 424 } 425 426 G4bool G4OpticalParameters::GetBoundaryInvokeS 427 { 428 return boundaryInvokeSD; 429 } 430 431 void G4OpticalParameters::SetAbsorptionVerbose 432 { 433 if(IsLocked()) 434 { 435 return; 436 } 437 absorptionVerboseLevel = val; 438 } 439 440 G4int G4OpticalParameters::GetAbsorptionVerbos 441 { 442 return absorptionVerboseLevel; 443 } 444 445 void G4OpticalParameters::SetRayleighVerboseLe 446 { 447 if(IsLocked()) 448 { 449 return; 450 } 451 rayleighVerboseLevel = val; 452 } 453 454 G4int G4OpticalParameters::GetRayleighVerboseL 455 { 456 return rayleighVerboseLevel; 457 } 458 459 void G4OpticalParameters::SetMieVerboseLevel(G 460 { 461 if(IsLocked()) 462 { 463 return; 464 } 465 mieVerboseLevel = val; 466 } 467 468 G4int G4OpticalParameters::GetMieVerboseLevel( 469 { 470 return mieVerboseLevel; 471 } 472 473 void G4OpticalParameters::PrintWarning(G4Excep 474 { 475 G4Exception("G4EmParameters", "Optical0020", 476 } 477 478 void G4OpticalParameters::StreamInfo(std::ostr 479 { 480 G4long prec = os.precision(5); 481 os 482 << "====================================== 483 << "\n"; 484 os 485 << "====== Optical 486 << "\n"; 487 os 488 << "====================================== 489 << "\n"; 490 491 os << " Cerenkov process active: 492 << GetProcessActivation("Cerenkov") << "\ 493 os << " Cerenkov maximum photons per step: 494 << "\n"; 495 os << " Cerenkov maximum beta change per ste 496 << " %\n"; 497 os << " Cerenkov stack photons: 498 << "\n"; 499 os << " Cerenkov track secondaries first: 500 << cerenkovTrackSecondariesFirst << "\n"; 501 os << " Scintillation process active: 502 << GetProcessActivation("Scintillation") 503 os << " Scintillation finite rise time: 504 << "\n"; 505 os << " Scintillation by particle type: 506 << "\n"; 507 os << " Scintillation record track info: 508 os << " Scintillation stack photons: 509 os << " Scintillation track secondaries firs 510 << "\n"; 511 os << " WLS process active: 512 << GetProcessActivation("OpWLS") << "\n"; 513 os << " WLS time profile name: 514 << "\n"; 515 os << " WLS2 process active: 516 << GetProcessActivation("OpWLS2") << "\n" 517 os << " WLS2 time profile name: 518 << "\n"; 519 os << " Boundary process active: 520 << GetProcessActivation("OpBoundary") << 521 os << " Boundary invoke sensitive detector: 522 os << " Rayleigh process active: 523 << GetProcessActivation("OpRayleigh") << 524 os << " MieHG process active: 525 << GetProcessActivation("OpMieHG") << "\n 526 os << " Absorption process active: 527 << GetProcessActivation("OpAbsorption") < 528 os 529 << "====================================== 530 << "\n"; 531 os.precision(prec); 532 } 533 534 void G4OpticalParameters::Dump() const 535 { 536 #ifdef G4MULTITHREADED 537 G4MUTEXLOCK(&opticalParametersMutex); 538 #endif 539 StreamInfo(G4cout); 540 #ifdef G4MULTITHREADED 541 G4MUTEXUNLOCK(&opticalParametersMutex); 542 #endif 543 } 544 545 std::ostream& operator<<(std::ostream& os, con 546 { 547 par.StreamInfo(os); 548 return os; 549 } 550 551 G4bool G4OpticalParameters::IsLocked() const 552 { 553 return (!G4Threading::IsMasterThread() || 554 (fStateManager->GetCurrentState() != 555 fStateManager->GetCurrentState() != 556 fStateManager->GetCurrentState() != 557 } 558