54 #include "G4ProcessType.hh"
58 #include <utl/config.h>
64 using namespace G4TankSimulatorOG;
78 using CLHEP::RandGauss;
86 G4TankOpBoundaryProcess::G4TankOpBoundaryProcess(
const G4String& processName,
88 G4VDiscreteProcess(processName, fOptical)
96 G4cerr << GetProcessName() <<
" is created " << G4endl;
122 const G4Step& aStep) {
124 aParticleChange.Initialize(aTrack);
126 G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
127 G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
129 if (pPostStepPoint->GetStepStatus() != fGeomBoundary)
130 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
133 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
136 pPreStepPoint ->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
138 pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
141 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
143 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
149 if (verboseLevel > 0) {
151 G4cerr <<
" Photon at Boundary! " << G4endl;
152 G4cerr <<
" Old Momentum Direction: " <<
OldMomentum << G4endl;
157 G4MaterialPropertiesTable* aMaterialPropertiesTable;
158 G4MaterialPropertyVector* Rindex;
160 aMaterialPropertiesTable =
Material1->GetMaterialPropertiesTable();
162 if (aMaterialPropertiesTable) {
164 Rindex = aMaterialPropertiesTable->GetProperty(
"RINDEX");
168 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
169 aParticleChange.ProposeTrackStatus (fStopAndKill);
171 aParticleChange.SetStatusChange (fStopAndKill);
172 #endif // ------------------------------------------------------------------
174 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
185 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
186 aParticleChange.ProposeTrackStatus (fStopAndKill);
188 aParticleChange.SetStatusChange (fStopAndKill);
189 #endif // ------------------------------------------------------------------
191 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
198 aMaterialPropertiesTable =
Material2->GetMaterialPropertiesTable();
200 if (aMaterialPropertiesTable) {
202 Rindex = aMaterialPropertiesTable->GetProperty(
"RINDEX");
206 G4LogicalSurface* Surface =
207 G4LogicalBorderSurface::GetSurface(pPreStepPoint ->GetPhysicalVolume(),
208 pPostStepPoint->GetPhysicalVolume());
210 if (Surface == NULL) {
213 G4LogicalSkinSurface::GetSurface(pPreStepPoint->GetPhysicalVolume()
214 ->GetLogicalVolume());
218 if (Surface != NULL) {
221 OpticalSurface = (G4OpticalSurface*) Surface->GetSurfaceProperty();
233 type = dielectric_dielectric;
242 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
243 aParticleChange.ProposeTrackStatus (fStopAndKill);
245 aParticleChange.SetStatusChange (fStopAndKill);
246 #endif // ------------------------------------------------------------------
248 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
257 aMaterialPropertiesTable =
OpticalSurface->GetMaterialPropertiesTable();
259 if (aMaterialPropertiesTable) {
261 G4MaterialPropertyVector* PropertyPointer;
265 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"RINDEX");
272 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"REFLECTIVITY");
277 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"EFFICIENCY");
285 aMaterialPropertiesTable->GetProperty(
"SPECULARLOBECONSTANT");
291 aMaterialPropertiesTable->GetProperty(
"SPECULARSPIKECONSTANT");
297 aMaterialPropertiesTable->GetProperty(
"BACKSCATTERCONSTANT");
310 G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
312 G4Navigator *theNavigator =
313 G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
315 G4ThreeVector theLocalPoint =
316 theNavigator->GetGlobalToLocalTransform().TransformPoint(theGlobalPoint);
318 G4ThreeVector theLocalNormal;
322 theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
326 theLocalNormal = -theLocalNormal;
330 G4cerr <<
" G4TankOpBoundaryProcess/PostStepDoIt(): "
331 <<
" The Navigator reports that it returned an invalid normal"
337 theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
351 if (type == dielectric_metal) {
355 }
else if (type == dielectric_dielectric) {
406 G4cerr <<
" Error: G4BoundaryProcess: illegal boundary type " << G4endl;
407 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
414 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
415 aParticleChange.ProposeMomentumDirection (
NewMomentum);
420 #endif // ------------------------------------------------------------------
422 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
428 const G4ThreeVector& Normal)
const {
430 G4ThreeVector FacetNormal;
442 G4double sigma_alpha = 0.0;
446 G4double f_max = std::min(1.0,4.*sigma_alpha);
451 alpha = RandGauss::shoot(0.0,sigma_alpha);
452 }
while (G4UniformRand()*f_max > std::sin(alpha) || alpha >= halfpi);
454 G4double phi = G4UniformRand() * CLHEP::twopi;
456 G4double SinAlpha = std::sin(alpha);
457 G4double CosAlpha = std::cos(alpha);
458 G4double SinPhi = std::sin(phi);
459 G4double CosPhi = std::cos(phi);
461 G4double unit_x = SinAlpha * CosPhi;
462 G4double unit_y = SinAlpha * SinPhi;
463 G4double unit_z = CosAlpha;
465 FacetNormal.setX(unit_x);
466 FacetNormal.setY(unit_y);
467 FacetNormal.setZ(unit_z);
469 G4ThreeVector tmpNormal = Normal;
471 FacetNormal.rotateUz(tmpNormal);
473 }
while (Momentum * FacetNormal >= 0.0);
477 G4double polish = 1.0;
489 smear.setX(2.*G4UniformRand()-1.0);
490 smear.setY(2.*G4UniformRand()-1.0);
491 smear.setZ(2.*G4UniformRand()-1.0);
493 }
while (smear.mag() > 1.0);
495 smear = (1.-polish) * smear;
496 FacetNormal = Normal + smear;
498 }
while (Momentum * FacetNormal >= 0.0);
500 FacetNormal = FacetNormal.unit();
504 FacetNormal = Normal;
540 G4bool Inside =
false;
545 G4bool Through =
false;
591 if (Swap) Swap = !Swap;
616 }
else if (
sint2 < 1.0) {
630 G4ThreeVector A_trans, Atrans, E1pp, E1pl;
631 G4double E1_perp, E1_parl;
636 Atrans = A_trans.unit();
638 E1pp = E1_perp * Atrans;
640 E1_parl = E1pl.mag();
653 G4double E2_perp = 0;
654 G4double E2_parl = 0;
655 G4double E2_total = 0;
656 G4double TransCoeff = 0;
663 E2_total = E2_perp*E2_perp + E2_parl*E2_parl;
669 G4ThreeVector Refracted, Deflected;
670 G4double E2_abs, C_parl, C_perp;
676 if (Swap) Swap = !Swap;
700 E2_perp = E2_perp - E1_perp;
701 E2_total = E2_perp*E2_perp + E2_parl*E2_parl;
704 C_parl = E2_parl/E2_abs;
705 C_perp = E2_perp/E2_abs;
733 C_parl = E2_parl/E2_abs;
734 C_perp = E2_perp/E2_abs;
763 if (Inside && !Swap) {
807 G4ForceCondition* condition) {
G4ThreeVector NewMomentum
G4bool G4BooleanRand(const G4double prob) const
G4OpticalSurfaceFinish theFinish
G4ThreeVector GetFacetNormal(const G4ThreeVector &Momentum, const G4ThreeVector &Normal) const
G4ThreeVector OldMomentum
~G4TankOpBoundaryProcess()
G4TankOpBoundaryProcessStatus theStatus
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition)
void G4Swap(G4double *a, G4double *b) const
double abs(const SVector< n, T > &v)
G4OpticalSurface * OpticalSurface
G4ThreeVector OldPolarization
G4ThreeVector theFacetNormal
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
G4ThreeVector NewPolarization
G4OpticalSurfaceModel theModel
G4double thePhotonMomentum
void DielectricDielectric()
G4ThreeVector theGlobalNormal