G4TankSimulatorOG/G4TankOpBoundaryProcess.h
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-00-patch-01 $
28 //
29 //
31 // Optical Photon Boundary Process Class Definition
33 //
34 // File: G4TankOpBoundaryProcess.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 //
47 // Author: Peter Gumplinger
48 // adopted from work by Werner Keil - April 2/96
49 // mail: gum@triumf.ca
50 //
51 // CVS version tag:
53 
54 #ifndef _G4TankSimulatorOG_G4TankOpBoundaryProcess_h_
55 #define _G4TankSimulatorOG_G4TankOpBoundaryProcess_h_
56 
58 // Includes
60 
61 #include "globals.hh"
62 #include "templates.hh"
63 #include "geomdefs.hh"
64 #include "Randomize.hh"
65 #include "G4Step.hh"
66 #include "G4VDiscreteProcess.hh"
67 #include "G4DynamicParticle.hh"
68 #include "G4Material.hh"
69 #include "G4LogicalBorderSurface.hh"
70 #include "G4LogicalSkinSurface.hh"
71 #include "G4OpticalSurface.hh"
72 #include "G4OpticalPhoton.hh"
73 #include "G4TransportationManager.hh"
74 
75 // Class Description:
76 // Discrete Process -- reflection/refraction at optical interfaces.
77 // Class inherits publicly from G4VDiscreteProcess.
78 // Class Description - End:
79 
80 namespace G4TankSimulatorOG {
81 
83 // Class Definition
85 
93 
94 class G4TankOpBoundaryProcess : public G4VDiscreteProcess
95 {
96 
97 private:
98 
100  // Operators
102 
103  // G4TankOpBoundaryProcess& operator=(const G4TankOpBoundaryProcess& right);
104 
105  // G4TankOpBoundaryProcess(const G4TankOpBoundaryProcess& right);
106 
107 public: // Without description
108 
110  // Constructors and Destructor
112 
113  G4TankOpBoundaryProcess(const G4String& processName = "OpBoundary",
114  G4ProcessType type = fOptical);
115 
117 
119  // Methods
121 
122 public: // With description
123 
124  G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
125  // Returns true -> 'is applicable' only for an optical photon.
126 
127  G4double GetMeanFreePath(const G4Track& ,
128  G4double ,
129  G4ForceCondition* condition);
130  // Returns infinity; i. e. the process does not limit the step,
131  // but sets the 'Forced' condition for the DoIt to be invoked at
132  // every step. However, only at a boundary will any action be
133  // taken.
134 
135  G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
136  const G4Step& aStep);
137  // This is the method implementing boundary processes.
138 
139  G4OpticalSurfaceModel GetModel() const;
140  // Returns the optical surface mode.
141 
143  // Returns the current status.
144 
145  void SetModel(G4OpticalSurfaceModel model);
146  // Set the optical surface model to be followed
147  // (glisur || unified).
148 
149 private:
150 
151  void G4Swap(G4double* a, G4double* b) const;
152 
153  void G4Swap(G4Material* a, G4Material* b) const;
154 
155  void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const;
156 
157  G4bool G4BooleanRand(const G4double prob) const;
158 
159  G4ThreeVector G4IsotropicRand() const;
160 
161  G4ThreeVector G4LambertianRand(const G4ThreeVector& normal);
162 
163  G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const;
164 
165  G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
166  const G4ThreeVector& Normal) const;
167 
168  void DielectricMetal();
169  void DielectricDielectric();
170 
171  void ChooseReflection();
172  void DoAbsorption();
173  void DoReflection();
174 
175 private:
176 
178 
179  G4ThreeVector OldMomentum;
180  G4ThreeVector OldPolarization;
181 
182  G4ThreeVector NewMomentum;
183  G4ThreeVector NewPolarization;
184 
185  G4ThreeVector theGlobalNormal;
186  G4ThreeVector theFacetNormal;
187 
188  G4Material* Material1;
189  G4Material* Material2;
190 
191  G4OpticalSurface* OpticalSurface;
192 
193  G4double Rindex1;
194  G4double Rindex2;
195 
196  G4double cost1, cost2, sint1, sint2;
197 
199 
200  G4OpticalSurfaceModel theModel;
201 
202  G4OpticalSurfaceFinish theFinish;
203 
204  G4double theReflectivity;
205  G4double theEfficiency;
206  G4double prob_sl, prob_ss, prob_bs;
207  G4double kCarTolerance;
208 };
209 
211 // Inline methods
213 
214 inline
215 void G4TankOpBoundaryProcess::G4Swap(G4double* a, G4double* b) const
216 {
217  // swaps the contents of the objects pointed
218  // to by 'a' and 'b'!
219 
220  G4double temp;
221 
222  temp = *a;
223  *a = *b;
224  *b = temp;
225 }
226 
227 inline
228 void G4TankOpBoundaryProcess::G4Swap(G4Material* a, G4Material* b) const
229 {
230  // ONLY swaps the pointers; i.e. what used to be pointed
231  // to by 'a' is now pointed to by 'b' and vice versa!
232 
233  G4Material* temp = a;
234 
235  a = b;
236  b = temp;
237 }
238 
239 inline
240 void G4TankOpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1,
241  G4ThreeVector* vec2) const
242 {
243  // swaps the contents of the objects pointed
244  // to by 'vec1' and 'vec2'!
245 
246  G4ThreeVector temp;
247 
248  temp = *vec1;
249  *vec1 = *vec2;
250  *vec2 = temp;
251 }
252 
253 inline
254 G4bool G4TankOpBoundaryProcess::G4BooleanRand(const G4double prob) const
255 {
256  /* Returns a random boolean variable with the specified probability */
257 
258  return (G4UniformRand() < prob);
259 }
260 
261 inline
263 {
264  /* Returns a random isotropic unit vector. */
265 
266  G4ThreeVector vect;
267  G4double len2;
268 
269  do {
270 
271  vect.setX(G4UniformRand() - 0.5);
272  vect.setY(G4UniformRand() - 0.5);
273  vect.setZ(G4UniformRand() - 0.5);
274 
275  len2 = vect.mag2();
276 
277  } while (len2 < 0.01 || len2 > 0.25);
278 
279  return vect.unit();
280 }
281 
282 inline
283 G4ThreeVector G4TankOpBoundaryProcess::
284  G4LambertianRand(const G4ThreeVector& normal)
285 {
286  /* Returns a random lambertian unit vector. */
287 
288  G4ThreeVector vect;
289  G4double ndotv;
290 
291  do {
292  vect = G4IsotropicRand();
293 
294  ndotv = normal * vect;
295 
296  if (ndotv < 0.0) {
297  vect = -vect;
298  ndotv = -ndotv;
299  }
300 
301  } while (!G4BooleanRand(ndotv));
302  return vect;
303 }
304 
305 inline
306 G4ThreeVector G4TankOpBoundaryProcess::
307  G4PlaneVectorRand(const G4ThreeVector& normal) const
308 
309  /* This function chooses a random vector within a plane given
310  by the unit normal */
311 {
312  G4ThreeVector vec1 = normal.orthogonal();
313 
314  G4ThreeVector vec2 = vec1.cross(normal);
315 
316  G4double phi = CLHEP::twopi*G4UniformRand();
317  G4double cosphi = std::cos(phi);
318  G4double sinphi = std::sin(phi);
319 
320  return cosphi * vec1 + sinphi * vec2;
321 }
322 
323 inline
324 G4bool G4TankOpBoundaryProcess::IsApplicable(const G4ParticleDefinition&
325  aParticleType)
326 {
327  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
328 }
329 
330 inline
331 G4OpticalSurfaceModel G4TankOpBoundaryProcess::GetModel() const
332 {
333  return theModel;
334 }
335 
336 inline
338 {
339  return theStatus;
340 }
341 
342 inline
343 void G4TankOpBoundaryProcess::SetModel(G4OpticalSurfaceModel model)
344 {
345  theModel = model;
346 }
347 
348 inline
350 {
351  G4double rand = G4UniformRand();
352  if ( rand >= 0.0 && rand < prob_ss ) {
355  }
356  else if ( rand >= prob_ss &&
357  rand <= prob_ss+prob_sl) {
359  }
360  else if ( rand > prob_ss+prob_sl &&
361  rand < prob_ss+prob_sl+prob_bs ) {
363  }
364  else {
366  }
367 }
368 
369 inline
371 {
373 
374  if ( G4BooleanRand(theEfficiency) ) {
375 
376  // EnergyDeposited =/= 0 means: photon has been detected
378  aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
379  }
380  else {
381  aParticleChange.ProposeLocalEnergyDeposit(0.0);
382  }
383 
386 
387 // aParticleChange.ProposeEnergy(0.0);
388  aParticleChange.ProposeTrackStatus(fStopAndKill);
389 }
390 
391 inline
393 {
394  if ( theStatus == LambertianReflection ) {
395 
398 
399  }
400  else if ( theFinish == ground ) {
401 
404  G4double PdotN = OldMomentum * theFacetNormal;
405  NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
406 
407  }
408  else {
409 
412  G4double PdotN = OldMomentum * theFacetNormal;
413  NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
414 
415  }
416  G4double EdotN = OldPolarization * theFacetNormal;
417  NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
418 }
419 
420 }
421 
422 #endif /* G4TankOpBoundaryProcess_h */
G4ThreeVector GetFacetNormal(const G4ThreeVector &Momentum, const G4ThreeVector &Normal) const
G4ThreeVector G4PlaneVectorRand(const G4ThreeVector &normal) const
G4bool IsApplicable(const G4ParticleDefinition &aParticleType)
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition)
void G4VectorSwap(G4ThreeVector *vec1, G4ThreeVector *vec2) const
G4TankOpBoundaryProcess(const G4String &processName="OpBoundary", G4ProcessType type=fOptical)
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
const double unit[npar]
Definition: UnivRec.h:76

, generated on Tue Sep 26 2023.