Import Geant4 9.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:15:05 +02:00
parent b79225fb37
commit 74cad5e589
3877 changed files with 234205 additions and 167127 deletions
+39
View File
@@ -16,6 +16,45 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
19th Nov 2009 Peter Gumplinger (op-V09-02-06)
change the code such that the LUT are now read in and kept
by G4OpticalSurface and not G4OpBoundaryProcess, reordering
of enumeration and set theStatus in DielectricLUT.
11th Nov 2009 Peter Gumplinger (op-V09-02-05)
add capability of simulating surface reflections
with Look-Up-Tables (LUT) containing measured
optical reflectance for a variety of surface
treatments - Thanks to Martin Janecek and
William Moses (Lawrence Berkeley National Lab.)
9th Nov 2009 Peter Gumplinger (op-V09-02-04)
G4OpBoundary: initialze theReflectivity and theEfficiency
at the beginning of the PostStepDoIt; add method
BoundaryProcessVerbose which will now print the process
status for every call to PostStepDoIt.
5th Nov 2009 Peter Gumplinger (op-V09-02-03)
G4OpBoundary::PostStepDoIt - all dielectric_dielectric
surfaces may now have a reflectivity <1; not only
'frontpainted' as was the case in the past.
6th May 2009 Peter Gumplinger (op-V09-02-02)
G4OpBoundary::PostStepDoIt now throws an G4Exception
EventMustBeAborted when an invalid surface normal is returnd;
addresses bug report #1060
23th Mar 2009 Peter Gumplinger (op-V09-02-01)
for complex index of refraction: (1)resample the reflectivity
every time in the do-while of DielectricMetal, but don't
re-calculate theFacetNormal (which has already been chosen
in CalculateReflectivity), also (2) avoid an infinite loop by
resetting iTE and iTM inside the do-while of GetReflectivity;
both are bug-fixes.
14th Jan 2009 Peter Gumplinger (op-V09-02-00)
respond to bug report 1040 by fixing G4OpBoundaryProcess.cc
07th Nov 2008 Peter Gumplinger (op-V09-01-09)
use new global/HEPRandom's G4RandomTools.hh
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4OpBoundaryProcess.hh,v 1.18 2008/11/07 17:59:37 gum Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4OpBoundaryProcess.hh,v 1.22 2009/11/20 01:06:45 gum Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
////////////////////////////////////////////////////////////////////////
@@ -48,12 +48,16 @@
// off a metal surface by way of a complex index
// of refraction - Thanks to Sehwook Lee and John
// Hauptman (Dept. of Physics - Iowa State Univ.)
// 2009-11-10 - add capability of simulating surface reflections
// with Look-Up-Tables (LUT) containing measured
// optical reflectance for a variety of surface
// treatments - Thanks to Martin Janecek and
// William Moses (Lawrence Berkeley National Lab.)
//
// Author: Peter Gumplinger
// adopted from work by Werner Keil - April 2/96
// mail: gum@triumf.ca
//
// CVS version tag:
////////////////////////////////////////////////////////////////////////
#ifndef G4OpBoundaryProcess_h
@@ -96,7 +100,31 @@ enum G4OpBoundaryProcessStatus { Undefined,
LambertianReflection, LobeReflection,
SpikeReflection, BackScattering,
Absorption, Detection, NotAtBoundary,
SameMaterial, StepTooSmall, NoRINDEX };
SameMaterial, StepTooSmall, NoRINDEX,
PolishedLumirrorAirReflection,
PolishedLumirrorGlueReflection,
PolishedAirReflection,
PolishedTeflonAirReflection,
PolishedTiOAirReflection,
PolishedTyvekAirReflection,
PolishedVM2000AirReflection,
PolishedVM2000GlueReflection,
EtchedLumirrorAirReflection,
EtchedLumirrorGlueReflection,
EtchedAirReflection,
EtchedTeflonAirReflection,
EtchedTiOAirReflection,
EtchedTyvekAirReflection,
EtchedVM2000AirReflection,
EtchedVM2000GlueReflection,
GroundLumirrorAirReflection,
GroundLumirrorGlueReflection,
GroundAirReflection,
GroundTeflonAirReflection,
GroundTiOAirReflection,
GroundTyvekAirReflection,
GroundVM2000AirReflection,
GroundVM2000GlueReflection };
class G4OpBoundaryProcess : public G4VDiscreteProcess
{
@@ -149,19 +177,9 @@ public: // With description
G4OpBoundaryProcessStatus GetStatus() const;
// Returns the current status.
G4double GetIncidentAngle();
// Returns the incident angle of optical photon
G4double GetReflectivity(G4double E1_perp,
G4double E1_parl,
G4double incidentangle,
G4double RealRindex,
G4double ImaginaryRindex);
// Returns the Reflectivity on a metalic surface
void SetModel(G4OpticalSurfaceModel model);
void SetModel(G4OpticalSurfaceModel model);
// Set the optical surface model to be followed
// (glisur || unified).
// (glisur || unified || LUT).
private:
@@ -172,11 +190,26 @@ private:
void DielectricMetal();
void DielectricDielectric();
void DielectricLUT();
void ChooseReflection();
void DoAbsorption();
void DoReflection();
G4double GetIncidentAngle();
// Returns the incident angle of optical photon
G4double GetReflectivity(G4double E1_perp,
G4double E1_parl,
G4double incidentangle,
G4double RealRindex,
G4double ImaginaryRindex);
// Returns the Reflectivity on a metalic surface
void CalculateReflectivity(void);
void BoundaryProcessVerbose(void) const;
private:
G4double thePhotonMomentum;
@@ -195,6 +228,10 @@ private:
G4OpticalSurface* OpticalSurface;
G4MaterialPropertyVector* PropertyPointer;
G4MaterialPropertyVector* PropertyPointer1;
G4MaterialPropertyVector* PropertyPointer2;
G4double Rindex1;
G4double Rindex2;
@@ -213,6 +250,7 @@ private:
G4int iTE, iTM;
G4double kCarTolerance;
};
////////////////////
@@ -307,7 +345,11 @@ void G4OpBoundaryProcess::DoReflection()
else if ( theFinish == ground ) {
theStatus = LobeReflection;
theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal);
if ( PropertyPointer1 && PropertyPointer2 ){
} else {
theFacetNormal =
GetFacetNormal(OldMomentum,theGlobalNormal);
}
G4double PdotN = OldMomentum * theFacetNormal;
NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
@@ -58,6 +58,11 @@
// off a metal surface by way of a complex index
// of refraction - Thanks to Sehwook Lee and John
// Hauptman (Dept. of Physics - Iowa State Univ.)
// 2009-11-10 - add capability of simulating surface reflections
// with Look-Up-Tables (LUT) containing measured
// optical reflectance for a variety of surface
// treatments - Thanks to Martin Janecek and
// William Moses (Lawrence Berkeley National Lab.)
//
// Author: Peter Gumplinger
// adopted from work by Werner Keil - April 2/96
@@ -139,12 +144,22 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
if ( verboseLevel > 0 ) {
G4cout << " Photon at Boundary! " << G4endl;
G4VPhysicalVolume* thePrePV = pPreStepPoint->GetPhysicalVolume();
G4VPhysicalVolume* thePostPV = pPostStepPoint->GetPhysicalVolume();
if (thePrePV) G4cout << " thePrePV: " << thePrePV->GetName() << G4endl;
if (thePostPV) G4cout << " thePostPV: " << thePostPV->GetName() << G4endl;
}
if (pPostStepPoint->GetStepStatus() != fGeomBoundary){
theStatus = NotAtBoundary;
if ( verboseLevel > 0) BoundaryProcessVerbose();
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if (aTrack.GetStepLength()<=kCarTolerance/2){
theStatus = StepTooSmall;
if ( verboseLevel > 0) BoundaryProcessVerbose();
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -157,6 +172,11 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
OldMomentum = aParticle->GetMomentumDirection();
OldPolarization = aParticle->GetPolarization();
if ( verboseLevel > 0 ) {
G4cout << " Old Momentum Direction: " << OldMomentum << G4endl;
G4cout << " Old Polarization: " << OldPolarization << G4endl;
}
G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
G4Navigator* theNavigator =
@@ -177,8 +197,12 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else {
G4cerr << " G4OpBoundaryProcess/PostStepDoIt(): "
<< " The Navigator reports that it returned an invalid normal"
<< G4endl;
<< " The Navigator reports that it returned an invalid normal"
<< G4endl;
G4Exception("G4OpBoundaryProcess::PostStepDoIt",
"Invalid Surface Normal",
EventMustBeAborted,
"Geometry must return valid surface normal");
}
theGlobalNormal = theNavigator->GetLocalToGlobalTransform().
@@ -202,6 +226,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
@@ -211,10 +236,14 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
theReflectivity = 1.;
theEfficiency = 0.;
theModel = glisur;
theFinish = polished;
@@ -276,15 +305,12 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
}
G4MaterialPropertyVector* PropertyPointer;
G4MaterialPropertyVector* PropertyPointer1;
G4MaterialPropertyVector* PropertyPointer2;
PropertyPointer =
aMaterialPropertiesTable->GetProperty("REFLECTIVITY");
PropertyPointer1 =
@@ -302,60 +328,8 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
} else if (PropertyPointer1 && PropertyPointer2) {
G4double RealRindex =
PropertyPointer1->GetProperty(thePhotonMomentum);
G4double ImaginaryRindex =
PropertyPointer2->GetProperty(thePhotonMomentum);
CalculateReflectivity();
// calculate FacetNormal
if ( theFinish == ground ) {
theFacetNormal =
GetFacetNormal(OldMomentum, theGlobalNormal);
} else {
theFacetNormal = theGlobalNormal;
}
G4double PdotN = OldMomentum * theFacetNormal;
cost1 = -PdotN;
if (std::abs(cost1) < 1.0 - kCarTolerance) {
sint1 = std::sqrt(1. - cost1*cost1);
} else {
sint1 = 0.0;
}
G4ThreeVector A_trans, A_paral, E1pp, E1pl;
G4double E1_perp, E1_parl;
if (sint1 > 0.0 ) {
A_trans = OldMomentum.cross(theFacetNormal);
A_trans = A_trans.unit();
E1_perp = OldPolarization * A_trans;
E1pp = E1_perp * A_trans;
E1pl = OldPolarization - E1pp;
E1_parl = E1pl.mag();
}
else {
A_trans = OldPolarization;
// Here we Follow Jackson's conventions and we set the
// parallel component = 1 in case of a ray perpendicular
// to the surface
E1_perp = 0.0;
E1_parl = 1.0;
}
//calculate incident angle
G4double incidentangle = GetIncidentAngle();
//calculate the reflectivity depending on incident angle,
//polarization and complex refractive
theReflectivity =
GetReflectivity(E1_perp, E1_parl, incidentangle,
RealRindex, ImaginaryRindex);
} else {
theReflectivity = 1.0;
}
PropertyPointer =
@@ -363,8 +337,6 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (PropertyPointer) {
theEfficiency =
PropertyPointer->GetProperty(thePhotonMomentum);
} else {
theEfficiency = 0.0;
}
if ( theModel == unified ) {
@@ -408,6 +380,7 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (Material1 == Material2){
theStatus = SameMaterial;
if ( verboseLevel > 0) BoundaryProcessVerbose();
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
aMaterialPropertiesTable =
@@ -419,18 +392,13 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
else {
theStatus = NoRINDEX;
if ( verboseLevel > 0) BoundaryProcessVerbose();
aParticleChange.ProposeTrackStatus(fStopAndKill);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
}
}
if ( verboseLevel > 0 ) {
G4cout << " Photon at Boundary! " << G4endl;
G4cout << " Old Momentum Direction: " << OldMomentum << G4endl;
G4cout << " Old Polarization: " << OldPolarization << G4endl;
}
if (type == dielectric_metal) {
DielectricMetal();
@@ -442,11 +410,15 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// }
}
else if (type == dielectric_LUT) {
DielectricLUT();
}
else if (type == dielectric_dielectric) {
if ( theFinish == polishedfrontpainted ||
theFinish == groundfrontpainted ) {
if( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
}
@@ -457,7 +429,12 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
}
else {
DielectricDielectric();
if( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
}
else {
DielectricDielectric();
}
}
}
else {
@@ -471,36 +448,9 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
NewPolarization = NewPolarization.unit();
if ( verboseLevel > 0) {
G4cout << " New Momentum Direction: " << NewMomentum << G4endl;
G4cout << " New Polarization: " << NewPolarization << G4endl;
if ( theStatus == Undefined )
G4cout << " *** Undefined *** " << G4endl;
if ( theStatus == FresnelRefraction )
G4cout << " *** FresnelRefraction *** " << G4endl;
if ( theStatus == FresnelReflection )
G4cout << " *** FresnelReflection *** " << G4endl;
if ( theStatus == TotalInternalReflection )
G4cout << " *** TotalInternalReflection *** " << G4endl;
if ( theStatus == LambertianReflection )
G4cout << " *** LambertianReflection *** " << G4endl;
if ( theStatus == LobeReflection )
G4cout << " *** LobeReflection *** " << G4endl;
if ( theStatus == SpikeReflection )
G4cout << " *** SpikeReflection *** " << G4endl;
if ( theStatus == BackScattering )
G4cout << " *** BackScattering *** " << G4endl;
if ( theStatus == Absorption )
G4cout << " *** Absorption *** " << G4endl;
if ( theStatus == Detection )
G4cout << " *** Detection *** " << G4endl;
if ( theStatus == NotAtBoundary )
G4cout << " *** NotAtBoundary *** " << G4endl;
if ( theStatus == SameMaterial )
G4cout << " *** SameMaterial *** " << G4endl;
if ( theStatus == StepTooSmall )
G4cout << " *** StepTooSmall *** " << G4endl;
if ( theStatus == NoRINDEX )
G4cout << " *** NoRINDEX *** " << G4endl;
G4cout << " New Momentum Direction: " << NewMomentum << G4endl;
G4cout << " New Polarization: " << NewPolarization << G4endl;
BoundaryProcessVerbose();
}
aParticleChange.ProposeMomentumDirection(NewMomentum);
@@ -509,13 +459,93 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
void G4OpBoundaryProcess::BoundaryProcessVerbose() const
{
if ( theStatus == Undefined )
G4cout << " *** Undefined *** " << G4endl;
if ( theStatus == FresnelRefraction )
G4cout << " *** FresnelRefraction *** " << G4endl;
if ( theStatus == FresnelReflection )
G4cout << " *** FresnelReflection *** " << G4endl;
if ( theStatus == TotalInternalReflection )
G4cout << " *** TotalInternalReflection *** " << G4endl;
if ( theStatus == LambertianReflection )
G4cout << " *** LambertianReflection *** " << G4endl;
if ( theStatus == LobeReflection )
G4cout << " *** LobeReflection *** " << G4endl;
if ( theStatus == SpikeReflection )
G4cout << " *** SpikeReflection *** " << G4endl;
if ( theStatus == BackScattering )
G4cout << " *** BackScattering *** " << G4endl;
if ( theStatus == PolishedLumirrorAirReflection )
G4cout << " *** PolishedLumirrorAirReflection *** " << G4endl;
if ( theStatus == PolishedLumirrorGlueReflection )
G4cout << " *** PolishedLumirrorGlueReflection *** " << G4endl;
if ( theStatus == PolishedAirReflection )
G4cout << " *** PolishedAirReflection *** " << G4endl;
if ( theStatus == PolishedTeflonAirReflection )
G4cout << " *** PolishedTeflonAirReflection *** " << G4endl;
if ( theStatus == PolishedTiOAirReflection )
G4cout << " *** PolishedTiOAirReflection *** " << G4endl;
if ( theStatus == PolishedTyvekAirReflection )
G4cout << " *** PolishedTyvekAirReflection *** " << G4endl;
if ( theStatus == PolishedVM2000AirReflection )
G4cout << " *** PolishedVM2000AirReflection *** " << G4endl;
if ( theStatus == PolishedVM2000GlueReflection )
G4cout << " *** PolishedVM2000GlueReflection *** " << G4endl;
if ( theStatus == EtchedLumirrorAirReflection )
G4cout << " *** EtchedLumirrorAirReflection *** " << G4endl;
if ( theStatus == EtchedLumirrorGlueReflection )
G4cout << " *** EtchedLumirrorGlueReflection *** " << G4endl;
if ( theStatus == EtchedAirReflection )
G4cout << " *** EtchedAirReflection *** " << G4endl;
if ( theStatus == EtchedTeflonAirReflection )
G4cout << " *** EtchedTeflonAirReflection *** " << G4endl;
if ( theStatus == EtchedTiOAirReflection )
G4cout << " *** EtchedTiOAirReflection *** " << G4endl;
if ( theStatus == EtchedTyvekAirReflection )
G4cout << " *** EtchedTyvekAirReflection *** " << G4endl;
if ( theStatus == EtchedVM2000AirReflection )
G4cout << " *** EtchedVM2000AirReflection *** " << G4endl;
if ( theStatus == EtchedVM2000GlueReflection )
G4cout << " *** EtchedVM2000GlueReflection *** " << G4endl;
if ( theStatus == GroundLumirrorAirReflection )
G4cout << " *** GroundLumirrorAirReflection *** " << G4endl;
if ( theStatus == GroundLumirrorGlueReflection )
G4cout << " *** GroundLumirrorGlueReflection *** " << G4endl;
if ( theStatus == GroundAirReflection )
G4cout << " *** GroundAirReflection *** " << G4endl;
if ( theStatus == GroundTeflonAirReflection )
G4cout << " *** GroundTeflonAirReflection *** " << G4endl;
if ( theStatus == GroundTiOAirReflection )
G4cout << " *** GroundTiOAirReflection *** " << G4endl;
if ( theStatus == GroundTyvekAirReflection )
G4cout << " *** GroundTyvekAirReflection *** " << G4endl;
if ( theStatus == GroundVM2000AirReflection )
G4cout << " *** GroundVM2000AirReflection *** " << G4endl;
if ( theStatus == GroundVM2000GlueReflection )
G4cout << " *** GroundVM2000GlueReflection *** " << G4endl;
if ( theStatus == Absorption )
G4cout << " *** Absorption *** " << G4endl;
if ( theStatus == Detection )
G4cout << " *** Detection *** " << G4endl;
if ( theStatus == NotAtBoundary )
G4cout << " *** NotAtBoundary *** " << G4endl;
if ( theStatus == SameMaterial )
G4cout << " *** SameMaterial *** " << G4endl;
if ( theStatus == StepTooSmall )
G4cout << " *** StepTooSmall *** " << G4endl;
if ( theStatus == NoRINDEX )
G4cout << " *** NoRINDEX *** " << G4endl;
}
G4ThreeVector
G4OpBoundaryProcess::GetFacetNormal(const G4ThreeVector& Momentum,
const G4ThreeVector& Normal ) const
{
G4ThreeVector FacetNormal;
if (theModel == unified) {
if (theModel == unified || theModel == LUT) {
/* This function code alpha to a random value taken from the
distribution p(alpha) = g(alpha; 0, sigma_alpha)*std::sin(alpha),
@@ -590,16 +620,26 @@ void G4OpBoundaryProcess::DielectricMetal()
if( !G4BooleanRand(theReflectivity) && n == 1 ) {
// Comment out DoAbsorption if you wish to have
// Transmission instead of Absorption
// Comment out DoAbsorption and uncomment theStatus = Absorption;
// if you wish to have Transmission instead of Absorption
DoAbsorption();
theStatus = Absorption;
// theStatus = Absorption;
break;
}
else {
if (PropertyPointer1 && PropertyPointer2) {
if ( n > 1 ) {
CalculateReflectivity();
if ( !G4BooleanRand(theReflectivity) ) {
DoAbsorption();
break;
}
}
}
if ( theModel == glisur || theFinish == polished ) {
DoReflection();
@@ -617,8 +657,13 @@ void G4OpBoundaryProcess::DielectricMetal()
}
else {
if(theStatus==LobeReflection)theFacetNormal =
GetFacetNormal(OldMomentum,theGlobalNormal);
if(theStatus==LobeReflection){
if ( PropertyPointer1 && PropertyPointer2 ){
} else {
theFacetNormal =
GetFacetNormal(OldMomentum,theGlobalNormal);
}
}
G4double PdotN = OldMomentum * theFacetNormal;
NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
@@ -656,6 +701,66 @@ void G4OpBoundaryProcess::DielectricMetal()
} while (NewMomentum * theGlobalNormal < 0.0);
}
void G4OpBoundaryProcess::DielectricLUT()
{
G4int thetaIndex, phiIndex;
G4double AngularDistributionValue, thetaRad, phiRad, EdotN;
G4ThreeVector PerpendicularVectorTheta, PerpendicularVectorPhi;
theStatus = G4OpBoundaryProcessStatus(G4int(theFinish) +
(G4int(NoRINDEX)-G4int(groundbackpainted)));
G4int thetaIndexMax = OpticalSurface->GetThetaIndexMax();
G4int phiIndexMax = OpticalSurface->GetPhiIndexMax();
do {
if ( !G4BooleanRand(theReflectivity) ) // Not reflected, so Absorbed
DoAbsorption();
else {
// Calculate Angle between Normal and Photon Momentum
G4double anglePhotonToNormal =
OldMomentum.angle(-theGlobalNormal);
// Round it to closest integer
G4int angleIncident = G4int(std::floor(180/pi*anglePhotonToNormal+0.5));
// Take random angles THETA and PHI,
// and see if below Probability - if not - Redo
do {
thetaIndex = CLHEP::RandFlat::shootInt(thetaIndexMax-1);
phiIndex = CLHEP::RandFlat::shootInt(phiIndexMax-1);
// Find probability with the new indeces from LUT
AngularDistributionValue = OpticalSurface ->
GetAngularDistributionValue(angleIncident,
thetaIndex,
phiIndex);
} while ( !G4BooleanRand(AngularDistributionValue) );
thetaRad = (-90 + 4*thetaIndex)*pi/180;
phiRad = (-90 + 5*phiIndex)*pi/180;
// Rotate Photon Momentum in Theta, then in Phi
NewMomentum = -OldMomentum;
PerpendicularVectorTheta = NewMomentum.cross(theGlobalNormal);
if (PerpendicularVectorTheta.mag() > kCarTolerance ) {
PerpendicularVectorPhi =
PerpendicularVectorTheta.cross(NewMomentum);
}
else {
PerpendicularVectorTheta = NewMomentum.orthogonal();
PerpendicularVectorPhi =
PerpendicularVectorTheta.cross(NewMomentum);
}
NewMomentum =
NewMomentum.rotate(anglePhotonToNormal-thetaRad,
PerpendicularVectorTheta);
NewMomentum = NewMomentum.rotate(-phiRad,PerpendicularVectorPhi);
// Rotate Polarization too:
theFacetNormal = (NewMomentum - OldMomentum).unit();
EdotN = OldPolarization * theFacetNormal;
NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
}
} while (NewMomentum * theGlobalNormal <= 0.0);
}
void G4OpBoundaryProcess::DielectricDielectric()
{
G4bool Inside = false;
@@ -961,10 +1066,67 @@ G4double G4OpBoundaryProcess::GetReflectivity(G4double E1_perp,
Reflectivity = Reflectivity_TE + Reflectivity_TM;
do {
if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TE))iTE = -1;
if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TM))iTM = -1;
if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TE))
{iTE = -1;}else{iTE = 1;}
if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TM))
{iTM = -1;}else{iTM = 1;}
} while(iTE<0&&iTM<0);
return real(Reflectivity);
}
void G4OpBoundaryProcess::CalculateReflectivity()
{
G4double RealRindex =
PropertyPointer1->GetProperty(thePhotonMomentum);
G4double ImaginaryRindex =
PropertyPointer2->GetProperty(thePhotonMomentum);
// calculate FacetNormal
if ( theFinish == ground ) {
theFacetNormal =
GetFacetNormal(OldMomentum, theGlobalNormal);
} else {
theFacetNormal = theGlobalNormal;
}
G4double PdotN = OldMomentum * theFacetNormal;
cost1 = -PdotN;
if (std::abs(cost1) < 1.0 - kCarTolerance) {
sint1 = std::sqrt(1. - cost1*cost1);
} else {
sint1 = 0.0;
}
G4ThreeVector A_trans, A_paral, E1pp, E1pl;
G4double E1_perp, E1_parl;
if (sint1 > 0.0 ) {
A_trans = OldMomentum.cross(theFacetNormal);
A_trans = A_trans.unit();
E1_perp = OldPolarization * A_trans;
E1pp = E1_perp * A_trans;
E1pl = OldPolarization - E1pp;
E1_parl = E1pl.mag();
}
else {
A_trans = OldPolarization;
// Here we Follow Jackson's conventions and we set the
// parallel component = 1 in case of a ray perpendicular
// to the surface
E1_perp = 0.0;
E1_parl = 1.0;
}
//calculate incident angle
G4double incidentangle = GetIncidentAngle();
//calculate the reflectivity depending on incident angle,
//polarization and complex refractive
theReflectivity =
GetReflectivity(E1_perp, E1_parl, incidentangle,
RealRindex, ImaginaryRindex);
}