Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 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 // 7 // >> 8 // $Id: G4OpBoundaryProcess.hh,v 1.5 1999/12/15 14:53:44 gunter Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ 28 // 10 // >> 11 // 29 ////////////////////////////////////////////// 12 //////////////////////////////////////////////////////////////////////// 30 // Optical Photon Boundary Process Class Defin 13 // Optical Photon Boundary Process Class Definition 31 ////////////////////////////////////////////// 14 //////////////////////////////////////////////////////////////////////// 32 // 15 // 33 // File: G4OpBoundaryProcess.hh 16 // File: G4OpBoundaryProcess.hh 34 // Description: Discrete Process -- reflection 17 // Description: Discrete Process -- reflection/refraction at 35 // optical in 18 // optical interfaces 36 // Version: 1.1 19 // Version: 1.1 37 // Created: 1997-06-18 20 // Created: 1997-06-18 38 // Modified: 2005-07-28 add G4ProcessType t << 21 // Modified: 1999-10-29 add method and class descriptors 39 // 1999-10-29 add method and clas << 22 // 1999-10-10 - Fill NewMomentum/NewPolarization in 40 // 1999-10-10 - Fill NewMomentum/ << 41 // DoAbsorption. The 23 // DoAbsorption. These members need to be 42 // filled since DoIt << 24 // filled since DoIt calls 43 // aParticleChange.S 25 // aParticleChange.SetMomentumChange etc. 44 // upon return (than 26 // upon return (thanks to: Clark McGrew) 45 // 2006-11-04 - add capability of << 46 // off a metal surfa << 47 // of refraction - T << 48 // Hauptman (Dept. o << 49 // 2009-11-10 - add capability of << 50 // with Look-Up-Tabl << 51 // optical reflectan << 52 // treatments - Than << 53 // William Moses (La << 54 // 2013-06-01 - add the capabilit << 55 // of a dichronic fi << 56 // 2017-02-24 - add capability of << 57 // with Look-Up-Tabl << 58 // 27 // 59 // Author: Peter Gumplinger 28 // Author: Peter Gumplinger 60 // adopted from work by Werner Ke 29 // adopted from work by Werner Keil - April 2/96 >> 30 // mail: gum@triumf.ca 61 // 31 // >> 32 // CVS version tag: 62 ////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////////////// 63 34 64 #ifndef G4OpBoundaryProcess_h 35 #ifndef G4OpBoundaryProcess_h 65 #define G4OpBoundaryProcess_h 1 36 #define G4OpBoundaryProcess_h 1 66 37 67 #include "G4OpticalPhoton.hh" << 38 ///////////// 68 #include "G4OpticalSurface.hh" << 39 // Includes 69 #include "G4RandomTools.hh" << 40 ///////////// >> 41 >> 42 #include "globals.hh" >> 43 #include "templates.hh" >> 44 #include "geomdefs.hh" >> 45 #include "Randomize.hh" >> 46 #include "G4Step.hh" 70 #include "G4VDiscreteProcess.hh" 47 #include "G4VDiscreteProcess.hh" >> 48 #include "G4DynamicParticle.hh" >> 49 #include "G4Material.hh" >> 50 #include "G4LogicalBorderSurface.hh" >> 51 #include "G4LogicalSkinSurface.hh" >> 52 #include "G4OpticalSurface.hh" >> 53 #include "G4OpticalPhoton.hh" >> 54 #include "G4TransportationManager.hh" 71 55 72 enum G4OpBoundaryProcessStatus << 56 // Class Description: 73 { << 57 // Discrete Process -- reflection/refraction at optical interfaces. 74 Undefined, << 58 // Class inherits publicly from G4VDiscreteProcess. 75 Transmission, << 59 // Class Description - End: 76 FresnelRefraction, << 60 77 FresnelReflection, << 61 ///////////////////// 78 TotalInternalReflection, << 62 // Class Definition 79 LambertianReflection, << 63 ///////////////////// 80 LobeReflection, << 81 SpikeReflection, << 82 BackScattering, << 83 Absorption, << 84 Detection, << 85 NotAtBoundary, << 86 SameMaterial, << 87 StepTooSmall, << 88 NoRINDEX, << 89 PolishedLumirrorAirReflection, << 90 PolishedLumirrorGlueReflection, << 91 PolishedAirReflection, << 92 PolishedTeflonAirReflection, << 93 PolishedTiOAirReflection, << 94 PolishedTyvekAirReflection, << 95 PolishedVM2000AirReflection, << 96 PolishedVM2000GlueReflection, << 97 EtchedLumirrorAirReflection, << 98 EtchedLumirrorGlueReflection, << 99 EtchedAirReflection, << 100 EtchedTeflonAirReflection, << 101 EtchedTiOAirReflection, << 102 EtchedTyvekAirReflection, << 103 EtchedVM2000AirReflection, << 104 EtchedVM2000GlueReflection, << 105 GroundLumirrorAirReflection, << 106 GroundLumirrorGlueReflection, << 107 GroundAirReflection, << 108 GroundTeflonAirReflection, << 109 GroundTiOAirReflection, << 110 GroundTyvekAirReflection, << 111 GroundVM2000AirReflection, << 112 GroundVM2000GlueReflection, << 113 Dichroic, << 114 CoatedDielectricReflection, << 115 CoatedDielectricRefraction, << 116 CoatedDielectricFrustratedTransmission << 117 }; << 118 64 119 class G4OpBoundaryProcess : public G4VDiscrete << 65 class G4OpBoundaryProcess : public G4VDiscreteProcess 120 { 66 { 121 public: << 122 explicit G4OpBoundaryProcess(const G4String& << 123 G4ProcessType t << 124 virtual ~G4OpBoundaryProcess(); << 125 67 126 virtual G4bool IsApplicable( << 68 enum G4OpBoundaryProcessStatus { Undefined, 127 const G4ParticleDefinition& aParticleType) << 69 FresnelRefraction, FresnelReflection, 128 // Returns true -> 'is applicable' only for << 70 TotalInternalReflection, >> 71 LambertianReflection, LobeReflection, >> 72 SpikeReflection, BackScattering, >> 73 Absorption, Detection }; >> 74 >> 75 private: 129 76 130 virtual G4double GetMeanFreePath(const G4Tra << 77 ////////////// 131 G4ForceCond << 78 // Operators 132 // Returns infinity; i. e. the process does << 79 ////////////// 133 // 'Forced' condition for the DoIt to be inv << 134 // at a boundary will any action be taken. << 135 80 136 G4VParticleChange* PostStepDoIt(const G4Trac << 81 // G4OpBoundaryProcess& operator=(const G4OpBoundaryProcess &right); 137 const G4Step << 138 // This is the method implementing boundary << 139 82 140 virtual G4OpBoundaryProcessStatus GetStatus( << 83 // G4OpBoundaryProcess(const G4OpBoundaryProcess &right); 141 // Returns the current status. << 142 84 143 virtual void SetInvokeSD(G4bool); << 85 public: // Without description 144 // Set flag for call to InvokeSD method. << 145 86 146 virtual void PreparePhysicsTable(const G4Par << 87 //////////////////////////////// >> 88 // Constructors and Destructor >> 89 //////////////////////////////// 147 90 148 virtual void Initialise(); << 91 G4OpBoundaryProcess(const G4String& processName = "Boundary"); 149 92 150 void SetVerboseLevel(G4int); << 93 ~G4OpBoundaryProcess(); 151 94 152 private: << 95 //////////// 153 G4OpBoundaryProcess(const G4OpBoundaryProces << 96 // Methods 154 G4OpBoundaryProcess& operator=(const G4OpBou << 97 //////////// 155 98 156 G4bool G4BooleanRand(const G4double prob) co << 99 public: // With description 157 100 158 G4ThreeVector GetFacetNormal(const G4ThreeVe << 101 G4bool IsApplicable(const G4ParticleDefinition& aParticleType); 159 const G4ThreeVe << 102 // Returns true -> 'is applicable' only for an optical photon. 160 103 161 void DielectricMetal(); << 104 G4double GetMeanFreePath(const G4Track& , 162 void DielectricDielectric(); << 105 G4double , >> 106 G4ForceCondition* condition); >> 107 // Returns infinity; i. e. the process does not limit the step, >> 108 // but sets the 'Forced' condition for the DoIt to be invoked at >> 109 // every step. However, only at a boundary will any action be >> 110 // taken. 163 111 164 void DielectricLUT(); << 112 G4VParticleChange* PostStepDoIt(const G4Track& aTrack, 165 void DielectricLUTDAVIS(); << 113 const G4Step& aStep); >> 114 // This is the method implementing boundary processes. 166 115 167 void DielectricDichroic(); << 116 G4OpticalSurfaceModel GetModel() const; 168 void CoatedDielectricDielectric(); << 117 // Returns the optical surface mode. 169 118 170 void ChooseReflection(); << 119 void SetModel(G4OpticalSurfaceModel model); 171 void DoAbsorption(); << 120 // Set the optical surface model to be followed 172 void DoReflection(); << 121 // (glisur || unified). 173 122 174 G4double GetIncidentAngle(); << 123 private: 175 // Returns the incident angle of optical pho << 176 124 177 G4double GetReflectivity(G4double E1_perp, G << 125 void G4Swap(G4double* a, G4double* b) const; 178 G4double incidentan << 179 G4double ImaginaryR << 180 // Returns the Reflectivity on a metallic su << 181 126 182 G4double GetReflectivityThroughThinLayer(G4d << 127 void G4Swap(G4Material* a, G4Material* b) const; 183 G4d << 184 G4d << 185 // Returns the Reflectivity on a coated surf << 186 128 187 void CalculateReflectivity(); << 129 void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const; 188 130 189 void BoundaryProcessVerbose() const; << 131 G4bool G4BooleanRand(const G4double prob) const; 190 132 191 // Invoke SD for post step point if the phot << 133 G4ThreeVector G4IsotropicRand() const; 192 G4bool InvokeSD(const G4Step* step); << 193 134 194 G4ThreeVector fOldMomentum; << 135 G4ThreeVector G4LambertianRand(const G4ThreeVector& normal); 195 G4ThreeVector fOldPolarization; << 196 136 197 G4ThreeVector fNewMomentum; << 137 G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const; 198 G4ThreeVector fNewPolarization; << 199 138 200 G4ThreeVector fGlobalNormal; << 139 G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum, 201 G4ThreeVector fFacetNormal; << 140 const G4ThreeVector& Normal) const; 202 141 203 const G4Material* fMaterial1; << 142 void DielectricMetal(); 204 const G4Material* fMaterial2; << 143 void DielectricDielectric(); 205 144 206 G4OpticalSurface* fOpticalSurface; << 145 void ChooseReflection(); >> 146 void DoAbsorption(); >> 147 void DoReflection(); 207 148 208 G4MaterialPropertyVector* fRealRIndexMPV; << 149 private: 209 G4MaterialPropertyVector* fImagRIndexMPV; << 210 G4Physics2DVector* fDichroicVector; << 211 150 212 G4double fPhotonMomentum; << 151 G4double thePhotonMomentum; 213 G4double fRindex1; << 214 G4double fRindex2; << 215 152 216 G4double fSint1; << 153 G4ThreeVector OldMomentum; >> 154 G4ThreeVector OldPolarization; 217 155 218 G4double fReflectivity; << 156 G4ThreeVector NewMomentum; 219 G4double fEfficiency; << 157 G4ThreeVector NewPolarization; 220 G4double fTransmittance; << 221 G4double fSurfaceRoughness; << 222 158 223 G4double fProb_sl, fProb_ss, fProb_bs; << 159 G4ThreeVector theGlobalNormal; 224 G4double fCarTolerance; << 160 G4ThreeVector theFacetNormal; 225 161 226 // Used by CoatedDielectricDielectric() << 162 G4Material* Material1; 227 G4double fCoatedRindex, fCoatedThickness; << 163 G4Material* Material2; 228 164 229 G4OpBoundaryProcessStatus fStatus; << 165 G4OpticalSurface* OpticalSurface; 230 G4OpticalSurfaceModel fModel; << 231 G4OpticalSurfaceFinish fFinish; << 232 166 233 G4int f_iTE, f_iTM; << 167 G4double Rindex1; >> 168 G4double Rindex2; 234 169 235 G4int fNumSmallStepWarnings = 0; // number o << 170 G4double cost1, cost2, sint1, sint2; 236 G4int fNumBdryTypeWarnings = 0; // number o << 237 171 238 size_t idx_dichroicX = 0; << 172 G4OpBoundaryProcessStatus theStatus; 239 size_t idx_dichroicY = 0; << 240 size_t idx_rindex1 = 0; << 241 size_t idx_rindex_surface = 0; << 242 size_t idx_reflect = 0; << 243 size_t idx_eff = 0; << 244 size_t idx_trans = 0; << 245 size_t idx_lobe = 0; << 246 size_t idx_spike = 0; << 247 size_t idx_back = 0; << 248 size_t idx_rindex2 = 0; << 249 size_t idx_groupvel = 0; << 250 size_t idx_rrindex = 0; << 251 size_t idx_irindex = 0; << 252 size_t idx_coatedrindex = 0; << 253 173 254 // Used by CoatedDielectricDielectric() << 174 G4OpticalSurfaceModel theModel; 255 G4bool fCoatedFrustratedTransmission = true; << 175 >> 176 G4OpticalSurfaceFinish theFinish; >> 177 >> 178 G4double theReflectivity; >> 179 G4double theEfficiency; >> 180 G4double prob_sl, prob_ss, prob_bs; 256 181 257 G4bool fInvokeSD; << 258 }; 182 }; 259 183 260 //////////////////// 184 //////////////////// 261 // Inline methods 185 // Inline methods 262 //////////////////// 186 //////////////////// 263 187 264 inline G4bool G4OpBoundaryProcess::G4BooleanRa << 188 inline >> 189 void G4OpBoundaryProcess::G4Swap(G4double* a, G4double* b) const 265 { 190 { 266 // Returns a random boolean variable with th << 191 // swaps the contents of the objects pointed >> 192 // to by 'a' and 'b'! >> 193 >> 194 G4double temp; >> 195 >> 196 temp = *a; >> 197 *a = *b; >> 198 *b = temp; >> 199 } >> 200 >> 201 inline >> 202 void G4OpBoundaryProcess::G4Swap(G4Material* a, G4Material* b) const >> 203 { >> 204 // ONLY swaps the pointers; i.e. what used to be pointed >> 205 // to by 'a' is now pointed to by 'b' and vice versa! >> 206 >> 207 G4Material* temp = a; >> 208 >> 209 a = b; >> 210 b = temp; >> 211 } >> 212 >> 213 inline >> 214 void G4OpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1, >> 215 G4ThreeVector* vec2) const >> 216 { >> 217 // swaps the contents of the objects pointed >> 218 // to by 'vec1' and 'vec2'! >> 219 >> 220 G4ThreeVector temp; >> 221 >> 222 temp = *vec1; >> 223 *vec1 = *vec2; >> 224 *vec2 = temp; >> 225 } >> 226 >> 227 inline >> 228 G4bool G4OpBoundaryProcess::G4BooleanRand(const G4double prob) const >> 229 { >> 230 /* Returns a random boolean variable with the specified probability */ >> 231 267 return (G4UniformRand() < prob); 232 return (G4UniformRand() < prob); 268 } 233 } 269 234 270 inline G4bool G4OpBoundaryProcess::IsApplicabl << 235 inline 271 const G4ParticleDefinition& aParticleType) << 236 G4ThreeVector G4OpBoundaryProcess::G4IsotropicRand() const 272 { 237 { 273 return (&aParticleType == G4OpticalPhoton::O << 238 /* Returns a random isotropic unit vector. */ >> 239 >> 240 G4ThreeVector vect; >> 241 G4double len2; >> 242 >> 243 do { >> 244 >> 245 vect.setX(G4UniformRand() - 0.5); >> 246 vect.setY(G4UniformRand() - 0.5); >> 247 vect.setZ(G4UniformRand() - 0.5); >> 248 >> 249 len2 = vect.mag2(); >> 250 >> 251 } while (len2 < 0.01 || len2 > 0.25); >> 252 >> 253 return vect.unit(); 274 } 254 } 275 255 276 inline G4OpBoundaryProcessStatus G4OpBoundaryP << 256 inline >> 257 G4ThreeVector G4OpBoundaryProcess:: >> 258 G4LambertianRand(const G4ThreeVector& normal) 277 { 259 { 278 return fStatus; << 260 /* Returns a random lambertian unit vector. */ 279 } << 261 280 << 262 G4ThreeVector vect; 281 inline void G4OpBoundaryProcess::ChooseReflect << 263 G4double ndotv; 282 { << 264 283 G4double rand = G4UniformRand(); << 265 do { 284 if(rand < fProb_ss) << 266 vect = G4IsotropicRand(); 285 { << 267 286 fStatus = SpikeReflection; << 268 ndotv = normal * vect; 287 fFacetNormal = fGlobalNormal; << 269 288 } << 270 if (ndotv < 0.0) { 289 else if(rand < fProb_ss + fProb_sl) << 271 vect = -vect; 290 { << 272 ndotv = -ndotv; 291 fStatus = LobeReflection; << 292 } << 293 else if(rand < fProb_ss + fProb_sl + fProb_b << 294 { << 295 fStatus = BackScattering; << 296 } << 297 else << 298 { << 299 fStatus = LambertianReflection; << 300 } << 301 } << 302 << 303 inline void G4OpBoundaryProcess::DoAbsorption( << 304 { << 305 fStatus = Absorption; << 306 << 307 if(G4BooleanRand(fEfficiency)) << 308 { << 309 // EnergyDeposited =/= 0 means: photon has << 310 fStatus = Detection; << 311 aParticleChange.ProposeLocalEnergyDeposit( << 312 } << 313 else << 314 { << 315 aParticleChange.ProposeLocalEnergyDeposit( << 316 } << 317 << 318 fNewMomentum = fOldMomentum; << 319 fNewPolarization = fOldPolarization; << 320 << 321 aParticleChange.ProposeTrackStatus(fStopAndK << 322 } << 323 << 324 inline void G4OpBoundaryProcess::DoReflection( << 325 { << 326 if(fStatus == LambertianReflection) << 327 { << 328 fNewMomentum = G4LambertianRand(fGlobalNor << 329 fFacetNormal = (fNewMomentum - fOldMomentu << 330 } << 331 else if(fFinish == ground) << 332 { << 333 fStatus = LobeReflection; << 334 if(!fRealRIndexMPV || !fImagRIndexMPV) << 335 { << 336 fFacetNormal = GetFacetNormal(fOldMoment << 337 } 273 } 338 // else << 274 339 // complex ref. index to be implemented << 275 } while (!G4BooleanRand(ndotv)); 340 fNewMomentum = << 276 return vect; 341 fOldMomentum - (2. * fOldMomentum * fFac << 277 } 342 } << 278 343 else << 279 inline 344 { << 280 G4ThreeVector G4OpBoundaryProcess:: 345 fStatus = SpikeReflection; << 281 G4PlaneVectorRand(const G4ThreeVector& normal) const 346 fFacetNormal = fGlobalNormal; << 282 347 fNewMomentum = << 283 /* This function chooses a random vector within a plane given 348 fOldMomentum - (2. * fOldMomentum * fFac << 284 by the unit normal */ 349 } << 285 { 350 fNewPolarization = << 286 G4ThreeVector vec1 = normal.orthogonal(); 351 -fOldPolarization + (2. * fOldPolarization << 287 >> 288 G4ThreeVector vec2 = vec1.cross(normal); >> 289 >> 290 G4double cost = 2.*G4UniformRand() - 1.0; >> 291 G4double sint = sqrt(1.0 - cost * cost); >> 292 >> 293 return cost * vec1 + sint * vec2; >> 294 } >> 295 >> 296 inline >> 297 G4bool G4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition& >> 298 aParticleType) >> 299 { >> 300 return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() ); >> 301 } >> 302 >> 303 inline >> 304 G4OpticalSurfaceModel G4OpBoundaryProcess::GetModel() const >> 305 { >> 306 return theModel; >> 307 } >> 308 >> 309 inline >> 310 void G4OpBoundaryProcess::SetModel(G4OpticalSurfaceModel model) >> 311 { >> 312 theModel = model; >> 313 } >> 314 >> 315 inline >> 316 void G4OpBoundaryProcess::ChooseReflection() >> 317 { >> 318 G4double rand = G4UniformRand(); >> 319 if ( rand >= 0.0 && rand < prob_ss ) { >> 320 theStatus = SpikeReflection; >> 321 theFacetNormal = theGlobalNormal; >> 322 } >> 323 else if ( rand >= prob_ss && >> 324 rand <= prob_ss+prob_sl) { >> 325 theStatus = LobeReflection; >> 326 } >> 327 else if ( rand > prob_ss+prob_sl && >> 328 rand < prob_ss+prob_sl+prob_bs ) { >> 329 theStatus = BackScattering; >> 330 } >> 331 else { >> 332 theStatus = LambertianReflection; >> 333 } >> 334 } >> 335 >> 336 inline >> 337 void G4OpBoundaryProcess::DoAbsorption() >> 338 { >> 339 theStatus = Absorption; >> 340 >> 341 if ( G4BooleanRand(theEfficiency) ) { >> 342 // EnergyDeposited =/= 0 means: photon has been detected >> 343 theStatus = Detection; >> 344 aParticleChange.SetLocalEnergyDeposit(thePhotonMomentum); >> 345 } >> 346 else { >> 347 aParticleChange.SetLocalEnergyDeposit(0.0); >> 348 } >> 349 >> 350 NewMomentum = OldMomentum; >> 351 NewPolarization = OldPolarization; >> 352 >> 353 // aParticleChange.SetEnergyChange(0.0); >> 354 aParticleChange.SetStatusChange(fStopAndKill); >> 355 } >> 356 >> 357 inline >> 358 void G4OpBoundaryProcess::DoReflection() >> 359 { >> 360 if ( theStatus == LambertianReflection ) { >> 361 >> 362 NewMomentum = G4LambertianRand(theGlobalNormal); >> 363 theFacetNormal = (NewMomentum - OldMomentum).unit(); >> 364 >> 365 } >> 366 else if ( theFinish == ground ) { >> 367 >> 368 theStatus = LobeReflection; >> 369 theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal); >> 370 G4double PdotN = OldMomentum * theFacetNormal; >> 371 NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal; >> 372 >> 373 } >> 374 else { >> 375 >> 376 theStatus = SpikeReflection; >> 377 theFacetNormal = theGlobalNormal; >> 378 G4double PdotN = OldMomentum * theFacetNormal; >> 379 NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal; >> 380 >> 381 } >> 382 G4double EdotN = OldPolarization * theFacetNormal; >> 383 NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal; 352 } 384 } 353 385 354 #endif /* G4OpBoundaryProcess_h */ 386 #endif /* G4OpBoundaryProcess_h */ 355 387