54 #include "G4ProcessType.hh"
58 #include <utl/config.h>
63 using namespace G4TankSimulatorASCII;
64 using CLHEP::RandGauss;
78 G4TankOpBoundaryProcess::G4TankOpBoundaryProcess(
const G4String& processName, G4ProcessType ) :
79 G4VDiscreteProcess(processName, fOptical)
82 G4cerr << GetProcessName() <<
" is created " << G4endl;
106 aParticleChange.Initialize(aTrack);
108 G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
109 G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
111 if (pPostStepPoint->GetStepStatus() != fGeomBoundary)
112 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
115 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
117 Material1 = pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
118 Material2 = pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial();
121 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
123 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
129 if (verboseLevel > 0)
130 G4cerr <<
" Photon at Boundary! \n"
134 G4MaterialPropertyVector* Rindex;
136 G4MaterialPropertiesTable* aMaterialPropertiesTable =
Material1->GetMaterialPropertiesTable();
138 if (aMaterialPropertiesTable) {
140 Rindex = aMaterialPropertiesTable->GetProperty(
"RINDEX");
144 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
145 aParticleChange.ProposeTrackStatus(fStopAndKill);
147 aParticleChange.SetStatusChange(fStopAndKill);
148 #endif // ------------------------------------------------------------------
150 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
160 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
161 aParticleChange.ProposeTrackStatus(fStopAndKill);
163 aParticleChange.SetStatusChange(fStopAndKill);
164 #endif // ------------------------------------------------------------------
166 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
173 aMaterialPropertiesTable =
Material2->GetMaterialPropertiesTable();
175 if (aMaterialPropertiesTable) {
177 Rindex = aMaterialPropertiesTable->GetProperty(
"RINDEX");
181 G4LogicalSurface* Surface =
182 G4LogicalBorderSurface::GetSurface(pPreStepPoint ->GetPhysicalVolume(),
183 pPostStepPoint->GetPhysicalVolume());
185 if (Surface == NULL) {
188 G4LogicalSkinSurface::GetSurface(pPreStepPoint->GetPhysicalVolume()
189 ->GetLogicalVolume());
193 if (Surface != NULL) {
196 OpticalSurface = (G4OpticalSurface*) Surface->GetSurfaceProperty();
208 type = dielectric_dielectric;
217 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
218 aParticleChange.ProposeTrackStatus(fStopAndKill);
220 aParticleChange.SetStatusChange(fStopAndKill);
221 #endif // ------------------------------------------------------------------
223 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
232 aMaterialPropertiesTable =
OpticalSurface->GetMaterialPropertiesTable();
234 if (aMaterialPropertiesTable) {
236 G4MaterialPropertyVector* PropertyPointer;
240 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"RINDEX");
247 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"REFLECTIVITY");
252 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"EFFICIENCY");
259 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"SPECULARLOBECONSTANT");
264 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"SPECULARSPIKECONSTANT");
269 PropertyPointer = aMaterialPropertiesTable->GetProperty(
"BACKSCATTERCONSTANT");
282 G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
284 G4Navigator* theNavigator =
285 G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
287 G4ThreeVector theLocalPoint =
288 theNavigator->GetGlobalToLocalTransform().TransformPoint(theGlobalPoint);
290 G4ThreeVector theLocalNormal;
294 theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
298 theLocalNormal = -theLocalNormal;
302 G4cerr <<
" G4TankOpBoundaryProcess/PostStepDoIt(): "
303 " The Navigator reports that it returned an invalid normal"
308 theGlobalNormal = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
322 if (type == dielectric_metal) {
326 }
else if (type == dielectric_dielectric) {
377 G4cerr <<
" Error: G4BoundaryProcess: illegal boundary type" << G4endl;
378 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
385 #ifdef GEANT4_V7 // ----------- see note on top of file --------------------
386 aParticleChange.ProposeMomentumDirection(
NewMomentum);
391 #endif // ------------------------------------------------------------------
393 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
401 G4ThreeVector FacetNormal;
413 G4double sigma_alpha = 0;
418 G4double f_max = std::min(1., 4.*sigma_alpha);
423 alpha = RandGauss::shoot(0, sigma_alpha);
424 }
while (G4UniformRand()*f_max > std::sin(alpha) || alpha >= halfpi);
426 G4double phi = G4UniformRand()*twopi;
428 G4double SinAlpha = std::sin(alpha);
429 G4double CosAlpha = std::cos(alpha);
430 G4double SinPhi = std::sin(phi);
431 G4double CosPhi = std::cos(phi);
433 G4double unit_x = SinAlpha * CosPhi;
434 G4double unit_y = SinAlpha * SinPhi;
435 G4double unit_z = CosAlpha;
437 FacetNormal.setX(unit_x);
438 FacetNormal.setY(unit_y);
439 FacetNormal.setZ(unit_z);
441 G4ThreeVector tmpNormal = Normal;
443 FacetNormal.rotateUz(tmpNormal);
445 }
while (Momentum * FacetNormal >= 0);
462 smear.setX(2.*G4UniformRand() - 1);
463 smear.setY(2.*G4UniformRand() - 1);
464 smear.setZ(2.*G4UniformRand() - 1);
466 }
while (smear.mag() > 1);
468 smear = (1 - polish) * smear;
469 FacetNormal = Normal + smear;
471 }
while (Momentum * FacetNormal >= 0);
473 FacetNormal = FacetNormal.unit();
477 FacetNormal = Normal;
513 G4bool Inside =
false;
518 G4bool Through =
false;
579 }
else if (
sint2 < 1) {
588 G4ThreeVector A_trans, Atrans, E1pp, E1pl;
589 G4double E1_perp, E1_parl;
594 Atrans = A_trans.unit();
596 E1pp = E1_perp * Atrans;
598 E1_parl = E1pl.mag();
611 G4double E2_perp = 0;
612 G4double E2_parl = 0;
613 G4double E2_total = 0;
614 G4double TransCoeff = 0;
621 E2_total = E2_perp*E2_perp + E2_parl*E2_parl;
627 G4ThreeVector Refracted, Deflected;
628 G4double E2_abs, C_parl, C_perp;
654 E2_perp = E2_perp - E1_perp;
655 E2_total = E2_perp*E2_perp + E2_parl*E2_parl;
658 C_parl = E2_parl/E2_abs;
659 C_perp = E2_perp/E2_abs;
684 C_parl = E2_parl/E2_abs;
685 C_perp = E2_perp/E2_abs;
709 if (Inside && !Swap) {
void G4Swap(G4double *a, G4double *b) const
G4bool G4BooleanRand(const G4double prob) const
G4ThreeVector NewMomentum
G4OpticalSurface * OpticalSurface
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition)
G4ThreeVector GetFacetNormal(const G4ThreeVector &Momentum, const G4ThreeVector &Normal) const
G4ThreeVector NewPolarization
G4OpticalSurfaceFinish theFinish
G4ThreeVector OldPolarization
G4ThreeVector OldMomentum
G4ThreeVector theFacetNormal
G4OpticalSurfaceModel theModel
G4double thePhotonMomentum
G4ThreeVector theGlobalNormal
G4TankOpBoundaryProcessStatus theStatus
~G4TankOpBoundaryProcess()
void DielectricDielectric()