Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:47

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 //
0029 ////////////////////////////////////////////////////////////////////////
0030 // Optical Photon Boundary Process Class Definition
0031 ////////////////////////////////////////////////////////////////////////
0032 //
0033 // File:        G4OpBoundaryProcess.hh
0034 // Description: Discrete Process -- reflection/refraction at
0035 //                                  optical interfaces
0036 // Version:     1.1
0037 // Created:     1997-06-18
0038 // Modified:    2005-07-28 add G4ProcessType to constructor
0039 //              1999-10-29 add method and class descriptors
0040 //              1999-10-10 - Fill NewMomentum/NewPolarization in
0041 //                           DoAbsorption. These members need to be
0042 //                           filled since DoIt calls
0043 //                           aParticleChange.SetMomentumChange etc.
0044 //                           upon return (thanks to: Clark McGrew)
0045 //              2006-11-04 - add capability of calculating the reflectivity
0046 //                           off a metal surface by way of a complex index
0047 //                           of refraction - Thanks to Sehwook Lee and John
0048 //                           Hauptman (Dept. of Physics - Iowa State Univ.)
0049 //              2009-11-10 - add capability of simulating surface reflections
0050 //                           with Look-Up-Tables (LUT) containing measured
0051 //                           optical reflectance for a variety of surface
0052 //                           treatments - Thanks to Martin Janecek and
0053 //                           William Moses (Lawrence Berkeley National Lab.)
0054 //              2013-06-01 - add the capability of simulating the transmission
0055 //                           of a dichronic filter
0056 //              2017-02-24 - add capability of simulating surface reflections
0057 //                           with Look-Up-Tables (LUT) developed in DAVIS
0058 //
0059 // Author:      Peter Gumplinger
0060 //              adopted from work by Werner Keil - April 2/96
0061 //
0062 ////////////////////////////////////////////////////////////////////////
0063 
0064 #ifndef G4OpBoundaryProcess_h
0065 #define G4OpBoundaryProcess_h 1
0066 
0067 #include "G4OpticalPhoton.hh"
0068 #include "G4OpticalSurface.hh"
0069 #include "G4RandomTools.hh"
0070 #include "G4VDiscreteProcess.hh"
0071 
0072 enum G4OpBoundaryProcessStatus
0073 {
0074   Undefined,
0075   Transmission,
0076   FresnelRefraction,
0077   FresnelReflection,
0078   TotalInternalReflection,
0079   LambertianReflection,
0080   LobeReflection,
0081   SpikeReflection,
0082   BackScattering,
0083   Absorption,
0084   Detection,
0085   NotAtBoundary,
0086   SameMaterial,
0087   StepTooSmall,
0088   NoRINDEX,
0089   PolishedLumirrorAirReflection,
0090   PolishedLumirrorGlueReflection,
0091   PolishedAirReflection,
0092   PolishedTeflonAirReflection,
0093   PolishedTiOAirReflection,
0094   PolishedTyvekAirReflection,
0095   PolishedVM2000AirReflection,
0096   PolishedVM2000GlueReflection,
0097   EtchedLumirrorAirReflection,
0098   EtchedLumirrorGlueReflection,
0099   EtchedAirReflection,
0100   EtchedTeflonAirReflection,
0101   EtchedTiOAirReflection,
0102   EtchedTyvekAirReflection,
0103   EtchedVM2000AirReflection,
0104   EtchedVM2000GlueReflection,
0105   GroundLumirrorAirReflection,
0106   GroundLumirrorGlueReflection,
0107   GroundAirReflection,
0108   GroundTeflonAirReflection,
0109   GroundTiOAirReflection,
0110   GroundTyvekAirReflection,
0111   GroundVM2000AirReflection,
0112   GroundVM2000GlueReflection,
0113   Dichroic,
0114   CoatedDielectricReflection,
0115   CoatedDielectricRefraction,
0116   CoatedDielectricFrustratedTransmission
0117 };
0118 
0119 class G4OpBoundaryProcess : public G4VDiscreteProcess
0120 {
0121  public:
0122   explicit G4OpBoundaryProcess(const G4String& processName = "OpBoundary",
0123                                G4ProcessType type          = fOptical);
0124   virtual ~G4OpBoundaryProcess();
0125 
0126   virtual G4bool IsApplicable(
0127     const G4ParticleDefinition& aParticleType) override;
0128   // Returns true -> 'is applicable' only for an optical photon.
0129 
0130   virtual G4double GetMeanFreePath(const G4Track&, G4double,
0131                                    G4ForceCondition* condition) override;
0132   // Returns infinity; i. e. the process does not limit the step, but sets the
0133   // 'Forced' condition for the DoIt to be invoked at every step. However, only
0134   // at a boundary will any action be taken.
0135 
0136   G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
0137                                   const G4Step& aStep) override;
0138   // This is the method implementing boundary processes.
0139 
0140   virtual G4OpBoundaryProcessStatus GetStatus() const;
0141   // Returns the current status.
0142 
0143   virtual void SetInvokeSD(G4bool);
0144   // Set flag for call to InvokeSD method.
0145 
0146   virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
0147 
0148   virtual void Initialise();
0149 
0150   void SetVerboseLevel(G4int);
0151 
0152  private:
0153   G4OpBoundaryProcess(const G4OpBoundaryProcess& right) = delete;
0154   G4OpBoundaryProcess& operator=(const G4OpBoundaryProcess& right) = delete;
0155 
0156   G4bool G4BooleanRand(const G4double prob) const;
0157 
0158   G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
0159                                const G4ThreeVector& Normal) const;
0160 
0161   void DielectricMetal();
0162   void DielectricDielectric();
0163 
0164   void DielectricLUT();
0165   void DielectricLUTDAVIS();
0166 
0167   void DielectricDichroic();
0168   void CoatedDielectricDielectric();
0169 
0170   void ChooseReflection();
0171   void DoAbsorption();
0172   void DoReflection();
0173 
0174   G4double GetIncidentAngle();
0175   // Returns the incident angle of optical photon
0176 
0177   G4double GetReflectivity(G4double E1_perp, G4double E1_parl,
0178                            G4double incidentangle, G4double RealRindex,
0179                            G4double ImaginaryRindex);
0180   // Returns the Reflectivity on a metallic surface
0181 
0182   G4double GetReflectivityThroughThinLayer(G4double sinTL, G4double E1_perp,
0183                                            G4double E1_parl, G4double wavelength,
0184                                            G4double cost1, G4double cost2);
0185   // Returns the Reflectivity on a coated surface
0186 
0187   void CalculateReflectivity();
0188 
0189   void BoundaryProcessVerbose() const;
0190 
0191   // Invoke SD for post step point if the photon is 'detected'
0192   G4bool InvokeSD(const G4Step* step);
0193 
0194   G4ThreeVector fOldMomentum;
0195   G4ThreeVector fOldPolarization;
0196 
0197   G4ThreeVector fNewMomentum;
0198   G4ThreeVector fNewPolarization;
0199 
0200   G4ThreeVector fGlobalNormal;
0201   G4ThreeVector fFacetNormal;
0202 
0203   const G4Material* fMaterial1;
0204   const G4Material* fMaterial2;
0205 
0206   G4OpticalSurface* fOpticalSurface;
0207 
0208   G4MaterialPropertyVector* fRealRIndexMPV;
0209   G4MaterialPropertyVector* fImagRIndexMPV;
0210   G4Physics2DVector* fDichroicVector;
0211 
0212   G4double fPhotonMomentum;
0213   G4double fRindex1;
0214   G4double fRindex2;
0215 
0216   G4double fSint1;
0217 
0218   G4double fReflectivity;
0219   G4double fEfficiency;
0220   G4double fTransmittance;
0221   G4double fSurfaceRoughness;
0222 
0223   G4double fProb_sl, fProb_ss, fProb_bs;
0224   G4double fCarTolerance;
0225 
0226   // Used by CoatedDielectricDielectric()
0227   G4double fCoatedRindex, fCoatedThickness;
0228 
0229   G4OpBoundaryProcessStatus fStatus;
0230   G4OpticalSurfaceModel fModel;
0231   G4OpticalSurfaceFinish fFinish;
0232 
0233   G4int f_iTE, f_iTM;
0234 
0235   G4int fNumSmallStepWarnings = 0; // number of times small step warning printed
0236   G4int fNumBdryTypeWarnings = 0;  // number of times boundary type warning printed
0237 
0238   size_t idx_dichroicX      = 0;
0239   size_t idx_dichroicY      = 0;
0240   size_t idx_rindex1        = 0;
0241   size_t idx_rindex_surface = 0;
0242   size_t idx_reflect        = 0;
0243   size_t idx_eff            = 0;
0244   size_t idx_trans          = 0;
0245   size_t idx_lobe           = 0;
0246   size_t idx_spike          = 0;
0247   size_t idx_back           = 0;
0248   size_t idx_rindex2        = 0;
0249   size_t idx_groupvel       = 0;
0250   size_t idx_rrindex        = 0;
0251   size_t idx_irindex        = 0;
0252   size_t idx_coatedrindex   = 0;
0253 
0254   // Used by CoatedDielectricDielectric()
0255   G4bool fCoatedFrustratedTransmission = true;
0256 
0257   G4bool fInvokeSD;
0258 };
0259 
0260 ////////////////////
0261 // Inline methods
0262 ////////////////////
0263 
0264 inline G4bool G4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
0265 {
0266   // Returns a random boolean variable with the specified probability
0267   return (G4UniformRand() < prob);
0268 }
0269 
0270 inline G4bool G4OpBoundaryProcess::IsApplicable(
0271   const G4ParticleDefinition& aParticleType)
0272 {
0273   return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
0274 }
0275 
0276 inline G4OpBoundaryProcessStatus G4OpBoundaryProcess::GetStatus() const
0277 {
0278   return fStatus;
0279 }
0280 
0281 inline void G4OpBoundaryProcess::ChooseReflection()
0282 {
0283   G4double rand = G4UniformRand();
0284   if(rand < fProb_ss)
0285   {
0286     fStatus      = SpikeReflection;
0287     fFacetNormal = fGlobalNormal;
0288   }
0289   else if(rand < fProb_ss + fProb_sl)
0290   {
0291     fStatus = LobeReflection;
0292   }
0293   else if(rand < fProb_ss + fProb_sl + fProb_bs)
0294   {
0295     fStatus = BackScattering;
0296   }
0297   else
0298   {
0299     fStatus = LambertianReflection;
0300   }
0301 }
0302 
0303 inline void G4OpBoundaryProcess::DoAbsorption()
0304 {
0305   fStatus = Absorption;
0306 
0307   if(G4BooleanRand(fEfficiency))
0308   {
0309     // EnergyDeposited =/= 0 means: photon has been detected
0310     fStatus = Detection;
0311     aParticleChange.ProposeLocalEnergyDeposit(fPhotonMomentum);
0312   }
0313   else
0314   {
0315     aParticleChange.ProposeLocalEnergyDeposit(0.0);
0316   }
0317 
0318   fNewMomentum     = fOldMomentum;
0319   fNewPolarization = fOldPolarization;
0320 
0321   aParticleChange.ProposeTrackStatus(fStopAndKill);
0322 }
0323 
0324 inline void G4OpBoundaryProcess::DoReflection()
0325 {
0326   if(fStatus == LambertianReflection)
0327   {
0328     fNewMomentum = G4LambertianRand(fGlobalNormal);
0329     fFacetNormal = (fNewMomentum - fOldMomentum).unit();
0330   }
0331   else if(fFinish == ground)
0332   {
0333     fStatus = LobeReflection;
0334     if(!fRealRIndexMPV || !fImagRIndexMPV)
0335     {
0336       fFacetNormal = GetFacetNormal(fOldMomentum, fGlobalNormal);
0337     }
0338     // else
0339       // complex ref. index to be implemented
0340     fNewMomentum =
0341       fOldMomentum - (2. * fOldMomentum * fFacetNormal * fFacetNormal);
0342   }
0343   else
0344   {
0345     fStatus      = SpikeReflection;
0346     fFacetNormal = fGlobalNormal;
0347     fNewMomentum =
0348       fOldMomentum - (2. * fOldMomentum * fFacetNormal * fFacetNormal);
0349   }
0350   fNewPolarization =
0351     -fOldPolarization + (2. * fOldPolarization * fFacetNormal * fFacetNormal);
0352 }
0353 
0354 #endif /* G4OpBoundaryProcess_h */