FDsimG4OpBoundaryProcess.hh
Go to the documentation of this file.
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 //
27 // GEANT4 tag $Name: geant4-09-01-patch-03 $
28 //
29 //
31 // Optical Photon Boundary Process Class Definition
33 //
34 // File: FDsimG4OpBoundaryProcess.hh
35 // Description: Discrete Process -- reflection/refraction at
36 // optical interfaces
37 // Version: 1.1
38 // Created: 1997-06-18
39 // Modified: 2005-07-28 add G4ProcessType to constructor
40 // 1999-10-29 add method and class descriptors
41 // 1999-10-10 - Fill NewMomentum/NewPolarization in
42 // DoAbsorption. These members need to be
43 // filled since DoIt calls
44 // aParticleChange.SetMomentumChange etc.
45 // upon return (thanks to: Clark McGrew)
46 // 2006-11-04 - add capability of calculating the reflectivity
47 // off a metal surface by way of a complex index
48 // of refraction - Thanks to Sehwook Lee and John
49 // Hauptman (Dept. of Physics - Iowa State Univ.)
50 //
51 // Author: Peter Gumplinger
52 // adopted from work by Werner Keil - April 2/96
53 // mail: gum@triumf.ca
54 //
55 // CVS version tag:
57 
58 #ifndef FDsimG4OpBoundaryProcess_h
59 #define FDsimG4OpBoundaryProcess_h 1
60 
62 // Includes
64 
65 #include "globals.hh"
66 #include "templates.hh"
67 #include "geomdefs.hh"
68 #include "Randomize.hh"
69 #include "G4Step.hh"
70 #include "G4VDiscreteProcess.hh"
71 #include "G4DynamicParticle.hh"
72 #include "G4Material.hh"
73 #include "G4LogicalBorderSurface.hh"
74 #include "G4LogicalSkinSurface.hh"
75 #include "G4OpticalSurface.hh"
76 #include "G4OpticalPhoton.hh"
77 #include "G4TransportationManager.hh"
78 
79 // Class Description:
80 // Discrete Process -- reflection/refraction at optical interfaces.
81 // Class inherits publicly from G4VDiscreteProcess.
82 // Class Description - End:
83 
85 // Class Definition
86 
88 
89 namespace TelescopeSimulatorLX {
90 
98 
99 
100 
101 class FDsimG4OpBoundaryProcess : public G4VDiscreteProcess
102 {
103 
104 private:
105 
107  // Operators
109 
110  // FDsimG4OpBoundaryProcess& operator=(const FDsimG4OpBoundaryProcess &right);
111 
112  // FDsimG4OpBoundaryProcess(const FDsimG4OpBoundaryProcess &right);
113 
114 public: // Without description
115 
117  // Constructors and Destructor
119 
120  FDsimG4OpBoundaryProcess(const G4String& processName = "OpBoundary",
121  G4ProcessType type = fOptical);
122 
124 
126  // Methods
128 
129 public: // With description
130 
131  G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
132  // Returns true -> 'is applicable' only for an optical photon.
133 
134  G4double GetMeanFreePath(const G4Track& ,
135  G4double ,
136  G4ForceCondition* condition);
137  // Returns infinity; i. e. the process does not limit the step,
138  // but sets the 'Forced' condition for the DoIt to be invoked at
139  // every step. However, only at a boundary will any action be
140  // taken.
141 
142  G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
143  const G4Step& aStep);
144  // This is the method implementing boundary processes.
145 
146  G4OpticalSurfaceModel GetModel() const;
147  // Returns the optical surface mode.
148 
150  // Returns the current status.
151 
152  G4double GetIncidentAngle();
153  // Returns the incident angle of optical photon
154 
155  G4double GetReflectivity(G4double E1_perp,
156  G4double E1_parl,
157  G4double incidentangle,
158  G4double RealRindex,
159  G4double ImaginaryRindex);
160  // Returns the Reflectivity on a metalic surface
161 
162  G4double GetReflectivityThinFilm(G4double incidentangle,
163  G4double n1,
164  G4complex n2,
165  G4double n3,
166  G4double thickness);
167 
168  // Returns the Reflectivity on a thin metalic surface
169 
170  void SetModel(G4OpticalSurfaceModel model);
171  // Set the optical surface model to be followed
172  // (glisur || unified).
173 
174 private:
175 
176  void G4Swap(G4double* a, G4double* b) const;
177 
178  void G4Swap(G4Material* a, G4Material* b) const;
179 
180  void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const;
181 
182  G4bool G4BooleanRand(const G4double prob) const;
183 
184  G4ThreeVector G4IsotropicRand() const;
185 
186  G4ThreeVector G4LambertianRand(const G4ThreeVector& normal);
187 
188  G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const;
189 
190  G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
191  const G4ThreeVector& Normal) const;
192 
193  void DielectricMetal();
194  void DielectricDielectric();
195 
196  void ChooseReflection();
197  void DoAbsorption();
198  void DoReflection();
199 
200 private:
201 
203 
204  G4ThreeVector OldMomentum;
205  G4ThreeVector OldPolarization;
206 
207  G4ThreeVector NewMomentum;
208  G4ThreeVector NewPolarization;
209 
210  G4ThreeVector theGlobalNormal;
211  G4ThreeVector theFacetNormal;
212 
213  G4Material* Material1;
214  G4Material* Material2;
215 
216  G4OpticalSurface* OpticalSurface;
217 
218  G4double Rindex1;
219  G4double Rindex2;
220 
221  G4double cost1, cost2, sint1, sint2;
222 
224 
225  G4OpticalSurfaceModel theModel;
226 
227  G4OpticalSurfaceFinish theFinish;
228 
229  G4double theReflectivity;
230  G4double theEfficiency;
231  G4double prob_sl, prob_ss, prob_bs;
232 
233  G4int iTE, iTM;
234 
235  G4double kCarTolerance;
236 };
237 
239 // Inline methods
241 
242 inline
243 void FDsimG4OpBoundaryProcess::G4Swap(G4double* a, G4double* b) const
244 {
245  // swaps the contents of the objects pointed
246  // to by 'a' and 'b'!
247 
248  G4double temp;
249 
250  temp = *a;
251  *a = *b;
252  *b = temp;
253 }
254 
255 inline
256 void FDsimG4OpBoundaryProcess::G4Swap(G4Material* a, G4Material* b) const
257 {
258  // ONLY swaps the pointers; i.e. what used to be pointed
259  // to by 'a' is now pointed to by 'b' and vice versa!
260 
261  G4Material* temp = a;
262 
263  a = b;
264  b = temp;
265 }
266 
267 inline
268 void FDsimG4OpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1,
269  G4ThreeVector* vec2) const
270 {
271  // swaps the contents of the objects pointed
272  // to by 'vec1' and 'vec2'!
273 
274  G4ThreeVector temp;
275 
276  temp = *vec1;
277  *vec1 = *vec2;
278  *vec2 = temp;
279 }
280 
281 inline
282 G4bool FDsimG4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
283 {
284  /* Returns a random boolean variable with the specified probability */
285 
286  return (G4UniformRand() < prob);
287 }
288 
289 inline
291 {
292  /* Returns a random isotropic unit vector. */
293 
294  G4ThreeVector vect;
295  G4double len2;
296 
297  do {
298 
299  vect.setX(G4UniformRand() - 0.5);
300  vect.setY(G4UniformRand() - 0.5);
301  vect.setZ(G4UniformRand() - 0.5);
302 
303  len2 = vect.mag2();
304 
305  } while (len2 < 0.01 || len2 > 0.25);
306 
307  return vect.unit();
308 }
309 
310 inline
311 G4ThreeVector FDsimG4OpBoundaryProcess::
312  G4LambertianRand(const G4ThreeVector& normal)
313 {
314  /* Returns a random lambertian unit vector. */
315 
316  G4ThreeVector vect;
317  G4double ndotv;
318 
319  do {
320  vect = G4IsotropicRand();
321 
322  ndotv = normal * vect;
323 
324  if (ndotv < 0.0) {
325  vect = -vect;
326  ndotv = -ndotv;
327  }
328 
329  } while (!G4BooleanRand(ndotv));
330  return vect;
331 }
332 
333 inline
334 G4ThreeVector FDsimG4OpBoundaryProcess::
335  G4PlaneVectorRand(const G4ThreeVector& normal) const
336 
337  /* This function chooses a random vector within a plane given
338  by the unit normal */
339 {
340  G4ThreeVector vec1 = normal.orthogonal();
341 
342  G4ThreeVector vec2 = vec1.cross(normal);
343 
344  G4double phi = twopi*G4UniformRand();
345  G4double cosphi = std::cos(phi);
346  G4double sinphi = std::sin(phi);
347 
348  return cosphi * vec1 + sinphi * vec2;
349 }
350 
351 inline
352 G4bool FDsimG4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition&
353  aParticleType)
354 {
355  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
356 }
357 
358 inline
359 G4OpticalSurfaceModel FDsimG4OpBoundaryProcess::GetModel() const
360 {
361  return theModel;
362 }
363 
364 inline
366 {
367  return theStatus;
368 }
369 
370 inline
371 void FDsimG4OpBoundaryProcess::SetModel(G4OpticalSurfaceModel model)
372 {
373  theModel = model;
374 }
375 
376 inline
378 {
379  G4double rand = G4UniformRand();
380  if ( rand >= 0.0 && rand < prob_ss ) {
383  }
384  else if ( rand >= prob_ss &&
385  rand <= prob_ss+prob_sl) {
387  }
388  else if ( rand > prob_ss+prob_sl &&
389  rand < prob_ss+prob_sl+prob_bs ) {
391  }
392  else {
394  }
395 }
396 
397 inline
399 {
401 
402  if ( G4BooleanRand(theEfficiency) ) {
403 
404  // EnergyDeposited =/= 0 means: photon has been detected
406  aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
407  }
408  else {
409  aParticleChange.ProposeLocalEnergyDeposit(0.0);
410  }
411 
414 
415 // aParticleChange.ProposeEnergy(0.0);
416  aParticleChange.ProposeTrackStatus(fStopAndKill);
417 }
418 
419 inline
421 {
422  if ( theStatus == LambertianReflection ) {
423 
426 
427  }
428  else if ( theFinish == ground ) {
429 
432  G4double PdotN = OldMomentum * theFacetNormal;
433  NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
434 
435  }
436  else {
437 
440  G4double PdotN = OldMomentum * theFacetNormal;
441  NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
442 
443  }
444  G4double EdotN = OldPolarization * theFacetNormal;
445  NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
446 }
447 
448 
449 } // End namespace
450 
451 #endif /* FDsimG4OpBoundaryProcess_h */
G4ThreeVector G4LambertianRand(const G4ThreeVector &normal)
G4bool IsApplicable(const G4ParticleDefinition &aParticleType)
void G4VectorSwap(G4ThreeVector *vec1, G4ThreeVector *vec2) const
G4double GetReflectivity(G4double E1_perp, G4double E1_parl, G4double incidentangle, G4double RealRindex, G4double ImaginaryRindex)
G4ThreeVector GetFacetNormal(const G4ThreeVector &Momentum, const G4ThreeVector &Normal) const
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition)
G4double GetReflectivityThinFilm(G4double incidentangle, G4double n1, G4complex n2, G4double n3, G4double thickness)
G4ThreeVector G4PlaneVectorRand(const G4ThreeVector &normal) const
FDsimG4OpBoundaryProcessStatus GetStatus() const
FDsimG4OpBoundaryProcess(const G4String &processName="OpBoundary", G4ProcessType type=fOptical)
const double unit[npar]
Definition: UnivRec.h:76
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)

, generated on Tue Sep 26 2023.