Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/optical/include/G4OpBoundaryProcess.hh

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/optical/include/G4OpBoundaryProcess.hh (Version 11.3.0) and /processes/optical/include/G4OpBoundaryProcess.hh (Version 9.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpBoundaryProcess.hh,v 1.15 2007/05/11 14:15:18 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-00 $
 27 //                                                 29 //
 28 //                                             <<  30 // 
 29 //////////////////////////////////////////////     31 ////////////////////////////////////////////////////////////////////////
 30 // Optical Photon Boundary Process Class Defin     32 // Optical Photon Boundary Process Class Definition
 31 //////////////////////////////////////////////     33 ////////////////////////////////////////////////////////////////////////
 32 //                                                 34 //
 33 // File:        G4OpBoundaryProcess.hh             35 // File:        G4OpBoundaryProcess.hh
 34 // Description: Discrete Process -- reflection     36 // Description: Discrete Process -- reflection/refraction at
 35 //                                  optical in     37 //                                  optical interfaces
 36 // Version:     1.1                                38 // Version:     1.1
 37 // Created:     1997-06-18                         39 // Created:     1997-06-18
 38 // Modified:    2005-07-28 add G4ProcessType t     40 // Modified:    2005-07-28 add G4ProcessType to constructor
 39 //              1999-10-29 add method and clas     41 //              1999-10-29 add method and class descriptors
 40 //              1999-10-10 - Fill NewMomentum/ <<  42 //              1999-10-10 - Fill NewMomentum/NewPolarization in 
 41 //                           DoAbsorption. The     43 //                           DoAbsorption. These members need to be
 42 //                           filled since DoIt <<  44 //                           filled since DoIt calls 
 43 //                           aParticleChange.S     45 //                           aParticleChange.SetMomentumChange etc.
 44 //                           upon return (than     46 //                           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 //                                                 47 //
 59 // Author:      Peter Gumplinger                   48 // Author:      Peter Gumplinger
 60 //              adopted from work by Werner Ke     49 //              adopted from work by Werner Keil - April 2/96
                                                   >>  50 // mail:        gum@triumf.ca
 61 //                                                 51 //
                                                   >>  52 // CVS version tag: 
 62 //////////////////////////////////////////////     53 ////////////////////////////////////////////////////////////////////////
 63                                                    54 
 64 #ifndef G4OpBoundaryProcess_h                      55 #ifndef G4OpBoundaryProcess_h
 65 #define G4OpBoundaryProcess_h 1                    56 #define G4OpBoundaryProcess_h 1
 66                                                    57 
 67 #include "G4OpticalPhoton.hh"                  <<  58 /////////////
 68 #include "G4OpticalSurface.hh"                 <<  59 // Includes
 69 #include "G4RandomTools.hh"                    <<  60 /////////////
                                                   >>  61 
                                                   >>  62 #include "globals.hh"
                                                   >>  63 #include "templates.hh"
                                                   >>  64 #include "geomdefs.hh"
                                                   >>  65 #include "Randomize.hh"
                                                   >>  66 #include "G4Step.hh"
 70 #include "G4VDiscreteProcess.hh"                   67 #include "G4VDiscreteProcess.hh"
                                                   >>  68 #include "G4DynamicParticle.hh"
                                                   >>  69 #include "G4Material.hh"
                                                   >>  70 #include "G4LogicalBorderSurface.hh"
                                                   >>  71 #include "G4LogicalSkinSurface.hh"
                                                   >>  72 #include "G4OpticalSurface.hh"
                                                   >>  73 #include "G4OpticalPhoton.hh"
                                                   >>  74 #include "G4TransportationManager.hh"
 71                                                    75 
 72 enum G4OpBoundaryProcessStatus                 <<  76 // Class Description:
 73 {                                              <<  77 // Discrete Process -- reflection/refraction at optical interfaces.
 74   Undefined,                                   <<  78 // Class inherits publicly from G4VDiscreteProcess.                  
 75   Transmission,                                <<  79 // Class Description - End:             
 76   FresnelRefraction,                           <<  80 
 77   FresnelReflection,                           <<  81 /////////////////////
 78   TotalInternalReflection,                     <<  82 // Class Definition
 79   LambertianReflection,                        <<  83 /////////////////////
 80   LobeReflection,                              <<  84 
 81   SpikeReflection,                             <<  85 enum G4OpBoundaryProcessStatus {  Undefined,
 82   BackScattering,                              <<  86                                   FresnelRefraction, FresnelReflection,
 83   Absorption,                                  <<  87                                   TotalInternalReflection,
 84   Detection,                                   <<  88                                   LambertianReflection, LobeReflection,
 85   NotAtBoundary,                               <<  89                                   SpikeReflection, BackScattering,
 86   SameMaterial,                                <<  90                                   Absorption, Detection, NotAtBoundary,
 87   StepTooSmall,                                <<  91                                   SameMaterial, StepTooSmall, NoRINDEX };
 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                                                    92 
119 class G4OpBoundaryProcess : public G4VDiscrete <<  93 class G4OpBoundaryProcess : public G4VDiscreteProcess 
120 {                                                  94 {
121  public:                                       << 
122   explicit G4OpBoundaryProcess(const G4String& << 
123                                G4ProcessType t << 
124   virtual ~G4OpBoundaryProcess();              << 
125                                                    95 
126   virtual G4bool IsApplicable(                 <<  96 private:
127     const G4ParticleDefinition& aParticleType) <<  97 
128   // Returns true -> 'is applicable' only for  <<  98         //////////////
                                                   >>  99         // Operators
                                                   >> 100         //////////////
                                                   >> 101 
                                                   >> 102         // G4OpBoundaryProcess& operator=(const G4OpBoundaryProcess &right);
129                                                   103 
130   virtual G4double GetMeanFreePath(const G4Tra << 104         // G4OpBoundaryProcess(const G4OpBoundaryProcess &right);
131                                    G4ForceCond << 
132   // Returns infinity; i. e. the process does  << 
133   // 'Forced' condition for the DoIt to be inv << 
134   // at a boundary will any action be taken.   << 
135                                                   105 
136   G4VParticleChange* PostStepDoIt(const G4Trac << 106 public: // Without description
137                                   const G4Step << 
138   // This is the method implementing boundary  << 
139                                                   107 
140   virtual G4OpBoundaryProcessStatus GetStatus( << 108         ////////////////////////////////
141   // Returns the current status.               << 109         // Constructors and Destructor
                                                   >> 110         ////////////////////////////////
142                                                   111 
143   virtual void SetInvokeSD(G4bool);            << 112         G4OpBoundaryProcess(const G4String& processName = "OpBoundary",
144   // Set flag for call to InvokeSD method.     << 113                                      G4ProcessType type = fOptical);
145                                                   114 
146   virtual void PreparePhysicsTable(const G4Par << 115   ~G4OpBoundaryProcess();
147                                                   116 
148   virtual void Initialise();                   << 117   ////////////
                                                   >> 118   // Methods
                                                   >> 119         ////////////
149                                                   120 
150   void SetVerboseLevel(G4int);                 << 121 public: // With description
151                                                   122 
152  private:                                      << 123         G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
153   G4OpBoundaryProcess(const G4OpBoundaryProces << 124         // Returns true -> 'is applicable' only for an optical photon.
154   G4OpBoundaryProcess& operator=(const G4OpBou << 
155                                                   125 
156   G4bool G4BooleanRand(const G4double prob) co << 126   G4double GetMeanFreePath(const G4Track& ,
                                                   >> 127          G4double ,
                                                   >> 128          G4ForceCondition* condition);
                                                   >> 129         // Returns infinity; i. e. the process does not limit the step,
                                                   >> 130         // but sets the 'Forced' condition for the DoIt to be invoked at
                                                   >> 131         // every step. However, only at a boundary will any action be
                                                   >> 132         // taken. 
157                                                   133 
158   G4ThreeVector GetFacetNormal(const G4ThreeVe << 134   G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
159                                const G4ThreeVe << 135                const G4Step&  aStep);
                                                   >> 136         // This is the method implementing boundary processes.
160                                                   137 
161   void DielectricMetal();                      << 138   G4OpticalSurfaceModel GetModel() const;
162   void DielectricDielectric();                 << 139         // Returns the optical surface mode.
163                                                   140 
164   void DielectricLUT();                        << 141         G4OpBoundaryProcessStatus GetStatus() const;
165   void DielectricLUTDAVIS();                   << 142         // Returns the current status.
166                                                   143 
167   void DielectricDichroic();                   << 144   void           SetModel(G4OpticalSurfaceModel model);
168   void CoatedDielectricDielectric();           << 145   // Set the optical surface model to be followed 
                                                   >> 146         // (glisur || unified). 
169                                                   147 
170   void ChooseReflection();                     << 148 private:
171   void DoAbsorption();                         << 
172   void DoReflection();                         << 
173                                                   149 
174   G4double GetIncidentAngle();                 << 150   void G4Swap(G4double* a, G4double* b) const;
175   // Returns the incident angle of optical pho << 
176                                                   151 
177   G4double GetReflectivity(G4double E1_perp, G << 152   void G4Swap(G4Material* a, G4Material* b) const;
178                            G4double incidentan << 
179                            G4double ImaginaryR << 
180   // Returns the Reflectivity on a metallic su << 
181                                                   153 
182   G4double GetReflectivityThroughThinLayer(G4d << 154   void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const;
183                                            G4d << 
184                                            G4d << 
185   // Returns the Reflectivity on a coated surf << 
186                                                   155 
187   void CalculateReflectivity();                << 156   G4bool G4BooleanRand(const G4double prob) const;
188                                                   157 
189   void BoundaryProcessVerbose() const;         << 158   G4ThreeVector G4IsotropicRand() const;
190                                                   159 
191   // Invoke SD for post step point if the phot << 160   G4ThreeVector G4LambertianRand(const G4ThreeVector& normal);
192   G4bool InvokeSD(const G4Step* step);         << 
193                                                   161 
194   G4ThreeVector fOldMomentum;                  << 162   G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const; 
195   G4ThreeVector fOldPolarization;              << 
196                                                   163 
197   G4ThreeVector fNewMomentum;                  << 164   G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
198   G4ThreeVector fNewPolarization;              << 165              const G4ThreeVector&  Normal) const;
199                                                   166 
200   G4ThreeVector fGlobalNormal;                 << 167   void DielectricMetal();
201   G4ThreeVector fFacetNormal;                  << 168   void DielectricDielectric();
202                                                   169 
203   const G4Material* fMaterial1;                << 170   void ChooseReflection();
204   const G4Material* fMaterial2;                << 171   void DoAbsorption();
                                                   >> 172   void DoReflection();
205                                                   173 
206   G4OpticalSurface* fOpticalSurface;           << 174 private:
207                                                   175 
208   G4MaterialPropertyVector* fRealRIndexMPV;    << 176   G4double thePhotonMomentum;
209   G4MaterialPropertyVector* fImagRIndexMPV;    << 
210   G4Physics2DVector* fDichroicVector;          << 
211                                                   177 
212   G4double fPhotonMomentum;                    << 178   G4ThreeVector OldMomentum;
213   G4double fRindex1;                           << 179   G4ThreeVector OldPolarization;
214   G4double fRindex2;                           << 
215                                                   180 
216   G4double fSint1;                             << 181   G4ThreeVector NewMomentum;
                                                   >> 182   G4ThreeVector NewPolarization;
217                                                   183 
218   G4double fReflectivity;                      << 184   G4ThreeVector theGlobalNormal;
219   G4double fEfficiency;                        << 185   G4ThreeVector theFacetNormal;
220   G4double fTransmittance;                     << 
221   G4double fSurfaceRoughness;                  << 
222                                                   186 
223   G4double fProb_sl, fProb_ss, fProb_bs;       << 187   G4Material* Material1;
224   G4double fCarTolerance;                      << 188   G4Material* Material2;
225                                                   189 
226   // Used by CoatedDielectricDielectric()      << 190   G4OpticalSurface* OpticalSurface;
227   G4double fCoatedRindex, fCoatedThickness;    << 
228                                                   191 
229   G4OpBoundaryProcessStatus fStatus;           << 192   G4double Rindex1;
230   G4OpticalSurfaceModel fModel;                << 193   G4double Rindex2;
231   G4OpticalSurfaceFinish fFinish;              << 
232                                                   194 
233   G4int f_iTE, f_iTM;                          << 195   G4double cost1, cost2, sint1, sint2;
234                                                   196 
235   G4int fNumSmallStepWarnings = 0; // number o << 197   G4OpBoundaryProcessStatus theStatus;
236   G4int fNumBdryTypeWarnings = 0;  // number o << 
237                                                   198 
238   size_t idx_dichroicX      = 0;               << 199   G4OpticalSurfaceModel theModel;
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                                                   200 
254   // Used by CoatedDielectricDielectric()      << 201   G4OpticalSurfaceFinish theFinish;
255   G4bool fCoatedFrustratedTransmission = true; << 
256                                                   202 
257   G4bool fInvokeSD;                            << 203   G4double theReflectivity;
                                                   >> 204   G4double theEfficiency;
                                                   >> 205   G4double prob_sl, prob_ss, prob_bs;
                                                   >> 206         G4double kCarTolerance;
258 };                                                207 };
259                                                   208 
260 ////////////////////                              209 ////////////////////
261 // Inline methods                                 210 // Inline methods
262 ////////////////////                              211 ////////////////////
263                                                   212 
264 inline G4bool G4OpBoundaryProcess::G4BooleanRa << 213 inline
                                                   >> 214 void G4OpBoundaryProcess::G4Swap(G4double* a, G4double* b) const
265 {                                                 215 {
266   // Returns a random boolean variable with th << 216   // swaps the contents of the objects pointed 
                                                   >> 217   // to by 'a' and 'b'!
                                                   >> 218 
                                                   >> 219   G4double temp;
                                                   >> 220 
                                                   >> 221   temp = *a;
                                                   >> 222   *a = *b;
                                                   >> 223   *b = temp;
                                                   >> 224 }
                                                   >> 225 
                                                   >> 226 inline
                                                   >> 227 void G4OpBoundaryProcess::G4Swap(G4Material* a, G4Material* b) const
                                                   >> 228 {
                                                   >> 229   // ONLY swaps the pointers; i.e. what used to be pointed
                                                   >> 230   // to by 'a' is now pointed to by 'b' and vice versa!
                                                   >> 231 
                                                   >> 232    G4Material* temp = a;
                                                   >> 233 
                                                   >> 234    a = b;
                                                   >> 235    b = temp;
                                                   >> 236 }
                                                   >> 237 
                                                   >> 238 inline
                                                   >> 239 void G4OpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1,
                                                   >> 240                G4ThreeVector* vec2) const
                                                   >> 241 {
                                                   >> 242         // swaps the contents of the objects pointed
                                                   >> 243         // to by 'vec1' and 'vec2'!
                                                   >> 244 
                                                   >> 245   G4ThreeVector temp;
                                                   >> 246 
                                                   >> 247   temp = *vec1;
                                                   >> 248   *vec1 = *vec2;
                                                   >> 249   *vec2 = temp;
                                                   >> 250 }
                                                   >> 251 
                                                   >> 252 inline
                                                   >> 253 G4bool G4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
                                                   >> 254 {
                                                   >> 255   /* Returns a random boolean variable with the specified probability */
                                                   >> 256 
267   return (G4UniformRand() < prob);                257   return (G4UniformRand() < prob);
268 }                                                 258 }
269                                                   259 
270 inline G4bool G4OpBoundaryProcess::IsApplicabl << 260 inline
271   const G4ParticleDefinition& aParticleType)   << 261 G4ThreeVector G4OpBoundaryProcess::G4IsotropicRand() const
272 {                                                 262 {
273   return (&aParticleType == G4OpticalPhoton::O << 263   /* Returns a random isotropic unit vector. */
                                                   >> 264 
                                                   >> 265   G4ThreeVector vect;
                                                   >> 266   G4double len2;
                                                   >> 267 
                                                   >> 268   do {
                                                   >> 269 
                                                   >> 270     vect.setX(G4UniformRand() - 0.5);
                                                   >> 271     vect.setY(G4UniformRand() - 0.5);
                                                   >> 272     vect.setZ(G4UniformRand() - 0.5);
                                                   >> 273 
                                                   >> 274     len2 = vect.mag2();
                                                   >> 275 
                                                   >> 276   } while (len2 < 0.01 || len2 > 0.25);
                                                   >> 277 
                                                   >> 278   return vect.unit();
274 }                                                 279 }
275                                                   280 
276 inline G4OpBoundaryProcessStatus G4OpBoundaryP << 281 inline
                                                   >> 282 G4ThreeVector G4OpBoundaryProcess::
                                                   >> 283         G4LambertianRand(const G4ThreeVector& normal)
277 {                                                 284 {
278   return fStatus;                              << 285   /* Returns a random lambertian unit vector. */
279 }                                              << 286 
280                                                << 287   G4ThreeVector vect;
281 inline void G4OpBoundaryProcess::ChooseReflect << 288   G4double ndotv;
282 {                                              << 289 
283   G4double rand = G4UniformRand();             << 290   do {
284   if(rand < fProb_ss)                          << 291     vect = G4IsotropicRand();
285   {                                            << 292 
286     fStatus      = SpikeReflection;            << 293     ndotv = normal * vect;
287     fFacetNormal = fGlobalNormal;              << 294 
288   }                                            << 295     if (ndotv < 0.0) {
289   else if(rand < fProb_ss + fProb_sl)          << 296       vect = -vect;
290   {                                            << 297       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     }                                             298     }
338     // else                                    << 299 
339       // complex ref. index to be implemented  << 300   } while (!G4BooleanRand(ndotv));
340     fNewMomentum =                             << 301   return vect;
341       fOldMomentum - (2. * fOldMomentum * fFac << 302 }
342   }                                            << 303 
343   else                                         << 304 inline
344   {                                            << 305 G4ThreeVector G4OpBoundaryProcess::
345     fStatus      = SpikeReflection;            << 306         G4PlaneVectorRand(const G4ThreeVector& normal) const
346     fFacetNormal = fGlobalNormal;              << 307 
347     fNewMomentum =                             << 308   /* This function chooses a random vector within a plane given
348       fOldMomentum - (2. * fOldMomentum * fFac << 309      by the unit normal */
349   }                                            << 310 {
350   fNewPolarization =                           << 311   G4ThreeVector vec1 = normal.orthogonal();
351     -fOldPolarization + (2. * fOldPolarization << 312 
                                                   >> 313   G4ThreeVector vec2 = vec1.cross(normal);
                                                   >> 314 
                                                   >> 315   G4double phi = twopi*G4UniformRand();
                                                   >> 316   G4double cosphi = std::cos(phi);
                                                   >> 317   G4double sinphi = std::sin(phi);
                                                   >> 318 
                                                   >> 319   return cosphi * vec1 + sinphi * vec2;
                                                   >> 320 }
                                                   >> 321 
                                                   >> 322 inline
                                                   >> 323 G4bool G4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition& 
                                                   >> 324                          aParticleType)
                                                   >> 325 {
                                                   >> 326    return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
                                                   >> 327 }
                                                   >> 328 
                                                   >> 329 inline
                                                   >> 330 G4OpticalSurfaceModel G4OpBoundaryProcess::GetModel() const
                                                   >> 331 {
                                                   >> 332    return theModel;
                                                   >> 333 }
                                                   >> 334 
                                                   >> 335 inline
                                                   >> 336 G4OpBoundaryProcessStatus G4OpBoundaryProcess::GetStatus() const
                                                   >> 337 {
                                                   >> 338    return theStatus;
                                                   >> 339 }
                                                   >> 340 
                                                   >> 341 inline
                                                   >> 342 void G4OpBoundaryProcess::SetModel(G4OpticalSurfaceModel model)
                                                   >> 343 {
                                                   >> 344    theModel = model;
                                                   >> 345 }
                                                   >> 346 
                                                   >> 347 inline
                                                   >> 348 void G4OpBoundaryProcess::ChooseReflection()
                                                   >> 349 {
                                                   >> 350                  G4double rand = G4UniformRand();
                                                   >> 351                  if ( rand >= 0.0 && rand < prob_ss ) {
                                                   >> 352                     theStatus = SpikeReflection;
                                                   >> 353                     theFacetNormal = theGlobalNormal;
                                                   >> 354                  }
                                                   >> 355                  else if ( rand >= prob_ss &&
                                                   >> 356                            rand <= prob_ss+prob_sl) {
                                                   >> 357                     theStatus = LobeReflection;
                                                   >> 358                  }
                                                   >> 359                  else if ( rand > prob_ss+prob_sl &&
                                                   >> 360                            rand < prob_ss+prob_sl+prob_bs ) {
                                                   >> 361                     theStatus = BackScattering;
                                                   >> 362                  }
                                                   >> 363                  else {
                                                   >> 364                     theStatus = LambertianReflection;
                                                   >> 365                  }
                                                   >> 366 }
                                                   >> 367 
                                                   >> 368 inline
                                                   >> 369 void G4OpBoundaryProcess::DoAbsorption()
                                                   >> 370 {
                                                   >> 371               theStatus = Absorption;
                                                   >> 372 
                                                   >> 373               if ( G4BooleanRand(theEfficiency) ) {
                                                   >> 374     
                                                   >> 375                  // EnergyDeposited =/= 0 means: photon has been detected
                                                   >> 376                  theStatus = Detection;
                                                   >> 377                  aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
                                                   >> 378               }
                                                   >> 379               else {
                                                   >> 380                  aParticleChange.ProposeLocalEnergyDeposit(0.0);
                                                   >> 381               }
                                                   >> 382 
                                                   >> 383               NewMomentum = OldMomentum;
                                                   >> 384               NewPolarization = OldPolarization;
                                                   >> 385 
                                                   >> 386 //              aParticleChange.ProposeEnergy(0.0);
                                                   >> 387               aParticleChange.ProposeTrackStatus(fStopAndKill);
                                                   >> 388 }
                                                   >> 389 
                                                   >> 390 inline
                                                   >> 391 void G4OpBoundaryProcess::DoReflection()
                                                   >> 392 {
                                                   >> 393         if ( theStatus == LambertianReflection ) {
                                                   >> 394 
                                                   >> 395           NewMomentum = G4LambertianRand(theGlobalNormal);
                                                   >> 396           theFacetNormal = (NewMomentum - OldMomentum).unit();
                                                   >> 397 
                                                   >> 398         }
                                                   >> 399         else if ( theFinish == ground ) {
                                                   >> 400 
                                                   >> 401     theStatus = LobeReflection;
                                                   >> 402           theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal);
                                                   >> 403           G4double PdotN = OldMomentum * theFacetNormal;
                                                   >> 404           NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
                                                   >> 405 
                                                   >> 406         }
                                                   >> 407         else {
                                                   >> 408 
                                                   >> 409           theStatus = SpikeReflection;
                                                   >> 410           theFacetNormal = theGlobalNormal;
                                                   >> 411           G4double PdotN = OldMomentum * theFacetNormal;
                                                   >> 412           NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
                                                   >> 413 
                                                   >> 414         }
                                                   >> 415         G4double EdotN = OldPolarization * theFacetNormal;
                                                   >> 416         NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
352 }                                                 417 }
353                                                   418 
354 #endif /* G4OpBoundaryProcess_h */                419 #endif /* G4OpBoundaryProcess_h */
355                                                   420