35 #include "G4ProcessType.hh"
40 #include <utl/config.h>
48 namespace G4StationSimulatorOG {
50 G4TankOpBoundaryProcess::G4TankOpBoundaryProcess(
const G4String& processName,
51 const G4ProcessType ) :
52 G4VDiscreteProcess(processName, fOptical)
55 G4cerr << GetProcessName() <<
" is created " << G4endl;
62 aParticleChange.Initialize(track);
64 G4StepPoint*
const preStepPoint = step.GetPreStepPoint();
65 G4StepPoint*
const postStepPoint = step.GetPostStepPoint();
67 if (postStepPoint->GetStepStatus() != fGeomBoundary)
68 return G4VDiscreteProcess::PostStepDoIt(track, step);
71 return G4VDiscreteProcess::PostStepDoIt(track, step);
73 fMaterial1 = preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
74 fMaterial2 = postStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
77 return G4VDiscreteProcess::PostStepDoIt(track, step);
79 const G4DynamicParticle*
const particle = track.GetDynamicParticle();
85 if (verboseLevel > 0) {
86 G4cerr <<
" Photon at Boundary!\n"
92 const auto t =
fMaterial1->GetMaterialPropertiesTable();
93 const auto ri = t ? t->GetProperty(
"RINDEX") :
nullptr;
98 aParticleChange.ProposeTrackStatus(fStopAndKill);
99 return G4VDiscreteProcess::PostStepDoIt(track, step);
103 if (
const auto s = G4LogicalBorderSurface::GetSurface(preStepPoint->GetPhysicalVolume(), postStepPoint->GetPhysicalVolume()))
105 else if (
const auto s = G4LogicalSkinSurface::GetSurface(preStepPoint->GetPhysicalVolume()->GetLogicalVolume()))
113 G4SurfaceType type = dielectric_dielectric;
116 const auto t =
fMaterial2->GetMaterialPropertiesTable();
117 const auto ri = t ? t->GetProperty(
"RINDEX") :
nullptr;
124 aParticleChange.ProposeTrackStatus(fStopAndKill);
125 return G4VDiscreteProcess::PostStepDoIt(track, step);
135 if (
const auto p = t->GetProperty(
"RINDEX"))
138 if (
const auto p = t->GetProperty(
"REFLECTIVITY"))
140 if (
const auto p = t->GetProperty(
"EFFICIENCY"))
143 if (
const auto p = t->GetProperty(
"SPECULARLOBECONSTANT"))
145 if (
const auto p = t->GetProperty(
"SPECULARSPIKECONSTANT"))
147 if (
const auto p = t->GetProperty(
"BACKSCATTERCONSTANT"))
155 const G4ThreeVector& globalPoint = postStepPoint->GetPosition();
157 G4Navigator*
const navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
159 const G4ThreeVector localPoint = navigator->GetGlobalToLocalTransform().TransformPoint(globalPoint);
161 G4bool valid =
false;
163 const G4ThreeVector localNormal = -navigator->GetLocalExitNormal(&valid);
165 G4cerr <<
" G4TankOpBoundaryProcess/PostStepDoIt(): "
166 " The Navigator reports that it returned an invalid normal"
170 fGlobalNormal = navigator->GetLocalToGlobalTransform().TransformAxis(localNormal);
173 if (type == dielectric_metal)
177 else if (type == dielectric_dielectric) {
179 if (
fFinish == polishedfrontpainted ||
fFinish == groundfrontpainted) {
187 if (
fFinish == groundfrontpainted)
224 G4cerr <<
" Error: G4BoundaryProcess: illegal boundary type " << G4endl;
225 return G4VDiscreteProcess::PostStepDoIt(track, step);
235 return G4VDiscreteProcess::PostStepDoIt(track, step);
247 vect.set(G4UniformRand() - 0.5, G4UniformRand() - 0.5, G4UniformRand() - 0.5);
249 }
while (len2 < 0.01 || len2 > 0.25);
263 ndotv = normal * vect;
278 const G4ThreeVector vec1 = normal.orthogonal();
279 const G4ThreeVector vec2 = vec1.cross(normal);
280 const G4double phi = twopi * G4UniformRand();
281 const G4double cosphi = std::cos(phi);
282 const G4double sinphi = std::sin(phi);
283 return cosphi * vec1 + sinphi * vec2;
291 G4ThreeVector facetNormal;
301 G4double sigmaAlpha = 0;
306 const G4double maxF = std::min(1., 4 * sigmaAlpha);
312 alpha = G4RandGauss::shoot(0, sigmaAlpha);
313 }
while (G4UniformRand() * maxF > std::sin(alpha) || alpha >= halfpi);
314 const G4double phi = G4UniformRand() * twopi;
316 const G4double sinAlpha = std::sin(alpha);
317 const G4double cosAlpha = std::cos(alpha);
318 const G4double sinPhi = std::sin(phi);
319 const G4double cosPhi = std::cos(phi);
321 facetNormal.set(sinAlpha*cosPhi, sinAlpha*sinPhi, cosAlpha);
322 facetNormal.rotateUz(normal);
324 }
while (momentum * facetNormal >= 0);
334 facetNormal = normal;
340 2 * G4UniformRand() - 1,
341 2 * G4UniformRand() - 1,
342 2 * G4UniformRand() - 1
344 }
while (smear.mag() > 1);
345 smear = (1 - polish) * smear;
346 facetNormal = normal + smear;
347 }
while (momentum * facetNormal >= 0);
348 facetNormal = facetNormal.unit();
377 G4bool inside =
false;
383 G4bool through =
false;
434 }
else if (sint2 < 1) {
439 G4ThreeVector a_trans;
440 G4ThreeVector atrans;
448 atrans = a_trans.unit();
450 e1pp = e1_perp * atrans;
452 e1_parl = e1pl.mag();
461 G4double e2_perp = 0;
462 G4double e2_parl = 0;
463 G4double e2_total = 0;
464 G4double transCoeff = 0;
467 const G4double s1 =
fRIndex1 * cost1;
470 e2_total = e2_perp * e2_perp + e2_parl * e2_parl;
471 const G4double s2 =
fRIndex2 * cost2 * e2_total;
472 transCoeff = s2 / s1;
475 G4ThreeVector refracted;
476 G4ThreeVector deflected;
509 e2_perp = e2_perp - e1_perp;
510 e2_total = e2_perp * e2_perp + e2_parl * e2_parl;
513 c_parl = e2_parl / e2_abs;
514 c_perp = e2_perp / e2_abs;
537 const G4double pDotN = -cost2;
540 c_parl = e2_parl / e2_abs;
541 c_perp = e2_perp / e2_abs;
567 (
fFinish == polishedbackpainted ||
fFinish == groundbackpainted)) {
580 if (
fFinish == groundbackpainted)
600 const G4double rand = G4UniformRand();
623 aParticleChange.ProposeLocalEnergyDeposit(0);
628 aParticleChange.ProposeTrackStatus(fStopAndKill);
638 }
else if (
fFinish == ground) {
G4ThreeVector fOldPolarization
G4ThreeVector G4LambertianRand(const G4ThreeVector &normal) const
G4ThreeVector GetFacetNormal(const G4ThreeVector &momentum, const G4ThreeVector &normal) const
void swap(utl::Trace< T > &t1, utl::Trace< T > &t2)
G4ThreeVector fGlobalNormal
constexpr T Sqr(const T &x)
G4ThreeVector fOldMomentum
G4TankOpBoundaryProcessStatus fStatus
void swap(OverCounted &oc1, OverCounted &oc2)
G4OpticalSurfaceFinish fFinish
G4bool G4BooleanRand(const G4double prob) const
void DielectricDielectric()
G4OpticalSurfaceModel fModel
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step) override
double abs(const SVector< n, T > &v)
G4ThreeVector fNewPolarization
G4ThreeVector G4PlaneVectorRand(const G4ThreeVector &normal) const
G4ThreeVector fFacetNormal
struct particle_info particle[80]
G4OpticalSurface * fOpticalSurface
G4ThreeVector fNewMomentum
G4ThreeVector G4IsotropicRand() const