[1203] | 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 | #include "G4OpticalPhysicsMessenger.hh" |
---|
| 27 | #include "G4OpticalPhysics.hh" |
---|
| 28 | |
---|
| 29 | #include "G4UIcommand.hh" |
---|
| 30 | #include "G4UIdirectory.hh" |
---|
| 31 | |
---|
| 32 | #include "G4UIcommand.hh" |
---|
| 33 | #include "G4UIdirectory.hh" |
---|
| 34 | #include "G4UIcmdWithABool.hh" |
---|
| 35 | #include "G4UIcmdWithAString.hh" |
---|
| 36 | #include "G4UIcmdWithADouble.hh" |
---|
| 37 | #include "G4UIcmdWithAnInteger.hh" |
---|
| 38 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
| 39 | |
---|
| 40 | #include "G4ParticleTable.hh" |
---|
| 41 | #include "G4ProcessVector.hh" |
---|
| 42 | #include "G4ProcessManager.hh" |
---|
| 43 | #include "G4ParticleDefinition.hh" |
---|
| 44 | |
---|
| 45 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
| 46 | G4OpticalPhysicsMessenger::G4OpticalPhysicsMessenger( |
---|
| 47 | G4OpticalPhysics* opticalPhysics) |
---|
| 48 | : G4UImessenger(), |
---|
| 49 | fOpticalPhysics(opticalPhysics), |
---|
| 50 | fSelectedProcess(0), |
---|
| 51 | fSelectOpProcessCmd(0), |
---|
| 52 | fSetOpProcessActivationCmd(0), |
---|
| 53 | fSetOpProcessVerboseCmd(0), |
---|
| 54 | fSetCerenkovMaxPhotonsCmd(0), |
---|
| 55 | fSetCerenkovMaxBetaChangeCmd(0), |
---|
| 56 | fSetScintillationYieldFactorCmd(0), |
---|
| 57 | fSetOpticalSurfaceModelCmd(0), |
---|
| 58 | fSetWLSTimeProfileCmd(0), |
---|
| 59 | fSetTrackSecondariesFirstCmd(0) |
---|
| 60 | { |
---|
| 61 | /// Standard constructor |
---|
| 62 | |
---|
| 63 | fDir = new G4UIdirectory("/optics_engine/"); |
---|
| 64 | fDir->SetGuidance("Commands related to the optical physics simulation engine."); |
---|
| 65 | |
---|
| 66 | fSelectOpProcessCmd |
---|
| 67 | = new G4UIcmdWithAString("/optics_engine/selectOpProcess", this); |
---|
| 68 | fSelectOpProcessCmd |
---|
| 69 | ->SetGuidance("Select optical process for applying verbose/activation/trackfirst commands"); |
---|
| 70 | fSelectOpProcessCmd->SetParameterName("OpProcess", false); |
---|
| 71 | fSelectOpProcessCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 72 | |
---|
| 73 | fSetOpProcessActivationCmd |
---|
| 74 | = new G4UIcmdWithABool("/optics_engine/setOpProcessActivation", this); |
---|
| 75 | fSetOpProcessActivationCmd->SetGuidance("Activate/Inactivate selected optical process"); |
---|
| 76 | fSetOpProcessActivationCmd->SetParameterName("OpProcessActivation", false); |
---|
| 77 | fSetOpProcessActivationCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 78 | |
---|
| 79 | fSetOpProcessVerboseCmd |
---|
| 80 | = new G4UIcmdWithAnInteger("/optics_engine/setOpProcessVerbose", this); |
---|
| 81 | fSetOpProcessVerboseCmd->SetGuidance("Set verbosity level for selected optical process"); |
---|
| 82 | fSetOpProcessVerboseCmd->SetParameterName("OpProcessVerbose", false); |
---|
| 83 | fSetOpProcessVerboseCmd->SetRange("OpProcessVerbose>=0"); |
---|
| 84 | fSetOpProcessVerboseCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 85 | |
---|
| 86 | fSetCerenkovMaxPhotonsCmd |
---|
| 87 | = new G4UIcmdWithAnInteger("/optics_engine/setCerenkovMaxPhotons", this); |
---|
| 88 | fSetCerenkovMaxPhotonsCmd->SetGuidance("Set maximum number of photons per step"); |
---|
| 89 | fSetCerenkovMaxPhotonsCmd->SetParameterName("CerenkovMaxPhotons", false); |
---|
| 90 | fSetCerenkovMaxPhotonsCmd->SetRange("CerenkovMaxPhotons>=0"); |
---|
| 91 | fSetCerenkovMaxPhotonsCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 92 | |
---|
| 93 | fSetCerenkovMaxBetaChangeCmd |
---|
| 94 | = new G4UIcmdWithADouble("/optics_engine/setCerenkovMaxBetaChange", this); |
---|
| 95 | fSetCerenkovMaxBetaChangeCmd |
---|
| 96 | ->SetGuidance("Set maximum change of beta of parent particle per step"); |
---|
| 97 | fSetCerenkovMaxBetaChangeCmd->SetParameterName("CerenkovMaxBetaChange", false); |
---|
| 98 | fSetCerenkovMaxBetaChangeCmd->SetRange("CerenkovMaxBetaChange>=0"); |
---|
| 99 | fSetCerenkovMaxBetaChangeCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 100 | |
---|
| 101 | fSetScintillationYieldFactorCmd |
---|
| 102 | = new G4UIcmdWithADouble("/optics_engine/setScintillationYieldFactor", this); |
---|
| 103 | fSetScintillationYieldFactorCmd->SetGuidance("Set scintillation yield factor"); |
---|
| 104 | fSetScintillationYieldFactorCmd->SetParameterName("ScintillationYieldFactor", false); |
---|
| 105 | fSetScintillationYieldFactorCmd->SetRange("ScintillationYieldFactor>=0"); |
---|
| 106 | fSetScintillationYieldFactorCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 107 | |
---|
| 108 | fSetOpticalSurfaceModelCmd |
---|
| 109 | = new G4UIcmdWithAString("/optics_engine/setOpticalSurfaceModel", this); |
---|
| 110 | fSetOpticalSurfaceModelCmd |
---|
| 111 | ->SetGuidance("Set optical surface model (glisur or unified)"); |
---|
| 112 | fSetOpticalSurfaceModelCmd->SetParameterName("OpticalSurfaceModel", false); |
---|
| 113 | fSetOpticalSurfaceModelCmd->SetCandidates("glisur unified"); |
---|
| 114 | fSetOpticalSurfaceModelCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 115 | |
---|
| 116 | fSetWLSTimeProfileCmd |
---|
| 117 | = new G4UIcmdWithAString("/optics_engine/setWLSTimeProfile", this); |
---|
| 118 | fSetWLSTimeProfileCmd |
---|
| 119 | ->SetGuidance("Set the WLS time profile (delta or exponential)"); |
---|
| 120 | fSetWLSTimeProfileCmd->SetParameterName("WLSTimeProfile", false); |
---|
| 121 | fSetWLSTimeProfileCmd->SetCandidates("delta exponential"); |
---|
| 122 | fSetWLSTimeProfileCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 123 | |
---|
| 124 | fSetTrackSecondariesFirstCmd |
---|
| 125 | = new G4UIcmdWithABool("/optics_engine/setTrackSecondariesFirst", this); |
---|
| 126 | fSetTrackSecondariesFirstCmd |
---|
| 127 | ->SetGuidance("Set option to track secondaries before finishing their parent track"); |
---|
| 128 | fSetTrackSecondariesFirstCmd->SetParameterName("TrackSecondariesFirst", false); |
---|
| 129 | fSetTrackSecondariesFirstCmd->AvailableForStates(G4State_Idle,G4State_GeomClosed,G4State_EventProc); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
| 133 | G4OpticalPhysicsMessenger::~G4OpticalPhysicsMessenger() |
---|
| 134 | { |
---|
| 135 | /// Destructor |
---|
| 136 | delete fDir; |
---|
| 137 | delete fSelectOpProcessCmd; |
---|
| 138 | delete fSetOpProcessActivationCmd; |
---|
| 139 | delete fSetOpProcessVerboseCmd; |
---|
| 140 | delete fSetCerenkovMaxPhotonsCmd; |
---|
| 141 | delete fSetCerenkovMaxBetaChangeCmd; |
---|
| 142 | delete fSetScintillationYieldFactorCmd; |
---|
| 143 | delete fSetOpticalSurfaceModelCmd; |
---|
| 144 | delete fSetWLSTimeProfileCmd; |
---|
| 145 | delete fSetTrackSecondariesFirstCmd; |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ |
---|
| 149 | void G4OpticalPhysicsMessenger::SetNewValue(G4UIcommand* command, G4String newValue) |
---|
| 150 | { |
---|
| 151 | /// Apply command to the associated object. |
---|
| 152 | |
---|
| 153 | if (command == fSelectOpProcessCmd) { |
---|
| 154 | if ( newValue == "Cerenkov" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 155 | GetCerenkovProcess(); |
---|
| 156 | else if ( newValue == "Scintillation" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 157 | GetScintillationProcess(); |
---|
| 158 | else if ( newValue == "OpAbsorption" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 159 | GetOpAbsorptionProcess(); |
---|
| 160 | else if ( newValue == "OpRayleigh" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 161 | GetOpRayleighProcess(); |
---|
| 162 | else if ( newValue == "OpBoundary" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 163 | GetOpBoundaryProcess(); |
---|
| 164 | else if ( newValue == "OpWLS" ) fSelectedProcess = fOpticalPhysics-> |
---|
| 165 | GetOpWLSProcess(); |
---|
| 166 | } |
---|
| 167 | else if (command == fSetOpProcessActivationCmd) { |
---|
| 168 | G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); |
---|
| 169 | G4ParticleTable::G4PTblDicIterator* theParticleIterator = |
---|
| 170 | theParticleTable->GetIterator(); |
---|
| 171 | if ( fSelectedProcess ) { |
---|
| 172 | theParticleIterator->reset(); |
---|
| 173 | while( (*theParticleIterator)() ) { |
---|
| 174 | G4ParticleDefinition* particle = theParticleIterator->value(); |
---|
| 175 | G4ProcessManager* processManager = particle->GetProcessManager(); |
---|
| 176 | G4ProcessVector* processVector = processManager->GetProcessList(); |
---|
| 177 | |
---|
| 178 | // activate or inactivate processes according to |
---|
| 179 | for (G4int i=0; i<processVector->length(); i++) { |
---|
| 180 | if ( (*processVector)[i] != fSelectedProcess ) continue; |
---|
| 181 | G4cout << "Setting process activation: " |
---|
| 182 | << fSelectedProcess->GetProcessName() << " " |
---|
| 183 | << fSetOpProcessActivationCmd->GetNewBoolValue(newValue) |
---|
| 184 | << G4endl; |
---|
| 185 | processManager->SetProcessActivation(fSelectedProcess, |
---|
| 186 | fSetOpProcessActivationCmd->GetNewBoolValue(newValue)); |
---|
| 187 | } |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | else if (command == fSetOpProcessVerboseCmd) { |
---|
| 192 | if ( fSelectedProcess ) |
---|
| 193 | fSelectedProcess->SetVerboseLevel |
---|
| 194 | (fSetOpProcessVerboseCmd->GetNewIntValue(newValue)); |
---|
| 195 | } |
---|
| 196 | else if (command == fSetCerenkovMaxPhotonsCmd) { |
---|
| 197 | fOpticalPhysics |
---|
| 198 | ->SetMaxNumPhotonsPerStep( |
---|
| 199 | fSetCerenkovMaxPhotonsCmd->GetNewIntValue(newValue)); |
---|
| 200 | } |
---|
| 201 | else if (command == fSetCerenkovMaxBetaChangeCmd) { |
---|
| 202 | fOpticalPhysics |
---|
| 203 | ->SetMaxBetaChangePerStep( |
---|
| 204 | fSetCerenkovMaxBetaChangeCmd->GetNewDoubleValue(newValue)); |
---|
| 205 | } |
---|
| 206 | else if (command == fSetScintillationYieldFactorCmd) { |
---|
| 207 | fOpticalPhysics |
---|
| 208 | ->SetScintillationYieldFactor( |
---|
| 209 | fSetScintillationYieldFactorCmd->GetNewDoubleValue(newValue)); |
---|
| 210 | } |
---|
| 211 | else if (command == fSetOpticalSurfaceModelCmd) { |
---|
| 212 | if ( newValue == "glisur" ) { |
---|
| 213 | fOpticalPhysics |
---|
| 214 | ->SetOpticalSurfaceModel(glisur); |
---|
| 215 | } |
---|
| 216 | if ( newValue == "unified" ) { |
---|
| 217 | fOpticalPhysics |
---|
| 218 | ->SetOpticalSurfaceModel(unified); |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | else if (command == fSetWLSTimeProfileCmd) { |
---|
| 222 | if ( newValue == "delta" ) { |
---|
| 223 | fOpticalPhysics |
---|
| 224 | ->SetWLSTimeProfile("delta"); } |
---|
| 225 | if ( newValue == "exponential" ) { |
---|
| 226 | fOpticalPhysics |
---|
| 227 | ->SetWLSTimeProfile("exponential"); |
---|
| 228 | } |
---|
| 229 | } |
---|
| 230 | else if (command == fSetTrackSecondariesFirstCmd) { |
---|
| 231 | if ( fSelectedProcess ) { |
---|
| 232 | G4Scintillation* scintillation = |
---|
| 233 | static_cast<G4Scintillation*>(fSelectedProcess); |
---|
| 234 | if (scintillation) scintillation -> |
---|
| 235 | SetTrackSecondariesFirst( |
---|
| 236 | fSetTrackSecondariesFirstCmd->GetNewBoolValue(newValue)); |
---|
| 237 | G4Cerenkov* cerenkov = |
---|
| 238 | static_cast<G4Cerenkov*>(fSelectedProcess); |
---|
| 239 | if (cerenkov) cerenkov -> |
---|
| 240 | SetTrackSecondariesFirst( |
---|
| 241 | fSetTrackSecondariesFirstCmd->GetNewBoolValue(newValue)); |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | } |
---|