Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4OpAbsorption.cc 69576 2013-05-08 13:48:13Z gcosmo $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Optical Photon Absorption Class Implementation
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
// optical reflectance for a variety of surface
|
||||
// treatments - Thanks to Martin Janecek and
|
||||
// William Moses (Lawrence Berkeley National Lab.)
|
||||
// 2013-06-01 - add the capability of simulating the transmission
|
||||
// of a dichronic filter
|
||||
//
|
||||
// Author: Peter Gumplinger
|
||||
// adopted from work by Werner Keil - April 2/96
|
||||
@@ -77,6 +79,11 @@
|
||||
#include "G4OpBoundaryProcess.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4ParallelWorldProcess.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
/////////////////////////
|
||||
// Class Implementation
|
||||
/////////////////////////
|
||||
@@ -129,6 +136,9 @@ G4OpBoundaryProcess::G4OpBoundaryProcess(const G4String& processName,
|
||||
iTE = iTM = 0;
|
||||
thePhotonMomentum = 0.;
|
||||
Rindex1 = Rindex2 = cost1 = cost2 = sint1 = sint2 = 0.;
|
||||
|
||||
idx = idy = 0;
|
||||
DichroicVector = NULL;
|
||||
}
|
||||
|
||||
// G4OpBoundaryProcess::G4OpBoundaryProcess(const G4OpBoundaryProcess &right)
|
||||
@@ -148,6 +158,7 @@ G4OpBoundaryProcess::~G4OpBoundaryProcess(){}
|
||||
// PostStepDoIt
|
||||
// ------------
|
||||
//
|
||||
|
||||
G4VParticleChange*
|
||||
G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
{
|
||||
@@ -156,31 +167,45 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
aParticleChange.Initialize(aTrack);
|
||||
aParticleChange.ProposeVelocity(aTrack.GetVelocity());
|
||||
|
||||
G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
|
||||
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
|
||||
// Get hyperStep from G4ParallelWorldProcess
|
||||
// NOTE: PostSetpDoIt of this process should be
|
||||
// invoked after G4ParallelWorldProcess!
|
||||
|
||||
const G4Step* pStep = &aStep;
|
||||
|
||||
const G4Step* hStep = G4ParallelWorldProcess::GetHyperStep();
|
||||
|
||||
if (hStep) pStep = hStep;
|
||||
|
||||
G4bool isOnBoundary =
|
||||
(pStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
|
||||
if (isOnBoundary) {
|
||||
Material1 = pStep->GetPreStepPoint()->GetMaterial();
|
||||
Material2 = pStep->GetPostStepPoint()->GetMaterial();
|
||||
} else {
|
||||
theStatus = NotAtBoundary;
|
||||
if ( verboseLevel > 0) BoundaryProcessVerbose();
|
||||
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
|
||||
}
|
||||
|
||||
G4VPhysicalVolume* thePrePV =
|
||||
pStep->GetPreStepPoint() ->GetPhysicalVolume();
|
||||
G4VPhysicalVolume* thePostPV =
|
||||
pStep->GetPostStepPoint()->GetPhysicalVolume();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Material1 = pPreStepPoint -> GetMaterial();
|
||||
Material2 = pPostStepPoint -> GetMaterial();
|
||||
|
||||
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
|
||||
|
||||
thePhotonMomentum = aParticle->GetTotalMomentum();
|
||||
@@ -192,17 +217,20 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
G4cout << " Old Polarization: " << OldPolarization << G4endl;
|
||||
}
|
||||
|
||||
G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
|
||||
|
||||
G4Navigator* theNavigator =
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetNavigatorForTracking();
|
||||
G4ThreeVector theGlobalPoint = pStep->GetPostStepPoint()->GetPosition();
|
||||
|
||||
G4bool valid;
|
||||
// Use the new method for Exit Normal in global coordinates,
|
||||
// which provides the normal more reliably.
|
||||
theGlobalNormal =
|
||||
theNavigator->GetGlobalExitNormal(theGlobalPoint,&valid);
|
||||
// which provides the normal more reliably.
|
||||
|
||||
// ID of Navigator which limits step
|
||||
|
||||
G4int hNavId = G4ParallelWorldProcess::GetHypNavigatorID();
|
||||
std::vector<G4Navigator*>::iterator iNav =
|
||||
G4TransportationManager::GetTransportationManager()->
|
||||
GetActiveNavigatorsIterator();
|
||||
theGlobalNormal =
|
||||
(iNav[hNavId])->GetGlobalExitNormal(theGlobalPoint,&valid);
|
||||
|
||||
if (valid) {
|
||||
theGlobalNormal = -theGlobalNormal;
|
||||
@@ -280,32 +308,24 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
|
||||
G4LogicalSurface* Surface = NULL;
|
||||
|
||||
Surface = G4LogicalBorderSurface::GetSurface
|
||||
(pPreStepPoint ->GetPhysicalVolume(),
|
||||
pPostStepPoint->GetPhysicalVolume());
|
||||
Surface = G4LogicalBorderSurface::GetSurface(thePrePV, thePostPV);
|
||||
|
||||
if (Surface == NULL){
|
||||
G4bool enteredDaughter=(pPostStepPoint->GetPhysicalVolume()
|
||||
->GetMotherLogical() ==
|
||||
pPreStepPoint->GetPhysicalVolume()
|
||||
->GetLogicalVolume());
|
||||
G4bool enteredDaughter= (thePostPV->GetMotherLogical() ==
|
||||
thePrePV ->GetLogicalVolume());
|
||||
if(enteredDaughter){
|
||||
Surface = G4LogicalSkinSurface::GetSurface
|
||||
(pPostStepPoint->GetPhysicalVolume()->
|
||||
GetLogicalVolume());
|
||||
Surface =
|
||||
G4LogicalSkinSurface::GetSurface(thePostPV->GetLogicalVolume());
|
||||
if(Surface == NULL)
|
||||
Surface = G4LogicalSkinSurface::GetSurface
|
||||
(pPreStepPoint->GetPhysicalVolume()->
|
||||
GetLogicalVolume());
|
||||
Surface =
|
||||
G4LogicalSkinSurface::GetSurface(thePrePV->GetLogicalVolume());
|
||||
}
|
||||
else {
|
||||
Surface = G4LogicalSkinSurface::GetSurface
|
||||
(pPreStepPoint->GetPhysicalVolume()->
|
||||
GetLogicalVolume());
|
||||
Surface =
|
||||
G4LogicalSkinSurface::GetSurface(thePrePV->GetLogicalVolume());
|
||||
if(Surface == NULL)
|
||||
Surface = G4LogicalSkinSurface::GetSurface
|
||||
(pPostStepPoint->GetPhysicalVolume()->
|
||||
GetLogicalVolume());
|
||||
Surface =
|
||||
G4LogicalSkinSurface::GetSurface(thePostPV->GetLogicalVolume());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +470,11 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
|
||||
DielectricLUT();
|
||||
|
||||
}
|
||||
else if (type == dielectric_dichroic) {
|
||||
|
||||
DielectricDichroic();
|
||||
|
||||
}
|
||||
else if (type == dielectric_dielectric) {
|
||||
|
||||
@@ -501,6 +526,8 @@ G4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
aParticleChange.ProposeVelocity(finalVelocity);
|
||||
}
|
||||
|
||||
if ( theStatus == Detection ) InvokeSD(pStep);
|
||||
|
||||
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
|
||||
}
|
||||
|
||||
@@ -582,6 +609,8 @@ void G4OpBoundaryProcess::BoundaryProcessVerbose() const
|
||||
G4cout << " *** StepTooSmall *** " << G4endl;
|
||||
if ( theStatus == NoRINDEX )
|
||||
G4cout << " *** NoRINDEX *** " << G4endl;
|
||||
if ( theStatus == Dichroic )
|
||||
G4cout << " *** Dichroic Transmission *** " << G4endl;
|
||||
}
|
||||
|
||||
G4ThreeVector
|
||||
@@ -773,8 +802,8 @@ void G4OpBoundaryProcess::DielectricLUT()
|
||||
// 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);
|
||||
thetaIndex = G4RandFlat::shootInt(thetaIndexMax-1);
|
||||
phiIndex = G4RandFlat::shootInt(phiIndexMax-1);
|
||||
// Find probability with the new indeces from LUT
|
||||
AngularDistributionValue = OpticalSurface ->
|
||||
GetAngularDistributionValue(angleIncident,
|
||||
@@ -808,6 +837,47 @@ void G4OpBoundaryProcess::DielectricLUT()
|
||||
} while (NewMomentum * theGlobalNormal <= 0.0);
|
||||
}
|
||||
|
||||
void G4OpBoundaryProcess::DielectricDichroic()
|
||||
{
|
||||
// Calculate Angle between Normal and Photon Momentum
|
||||
G4double anglePhotonToNormal = OldMomentum.angle(-theGlobalNormal);
|
||||
|
||||
// Round it to closest integer
|
||||
G4double angleIncident = std::floor(180/pi*anglePhotonToNormal+0.5);
|
||||
|
||||
if (!DichroicVector) {
|
||||
if (OpticalSurface) DichroicVector = OpticalSurface->GetDichroicVector();
|
||||
}
|
||||
|
||||
|
||||
if (DichroicVector) {
|
||||
G4double wavelength = h_Planck*c_light/thePhotonMomentum;
|
||||
theTransmittance =
|
||||
DichroicVector->Value(wavelength/nm,angleIncident,idx,idy)*perCent;
|
||||
// G4cout << "wavelength: " << std::floor(wavelength/nm)
|
||||
// << "nm" << G4endl;
|
||||
// G4cout << "Incident angle: " << angleIncident << "deg" << G4endl;
|
||||
// G4cout << "Transmittance: "
|
||||
// << std::floor(theTransmittance/perCent) << "%" << G4endl;
|
||||
} else {
|
||||
G4ExceptionDescription ed;
|
||||
ed << " G4OpBoundaryProcess/DielectricDichroic(): "
|
||||
<< " The dichroic surface has no G4Physics2DVector"
|
||||
<< G4endl;
|
||||
G4Exception("G4OpBoundaryProcess::DielectricDichroic", "OpBoun03",
|
||||
FatalException,ed,
|
||||
"A dichroic surface must have an associated G4Physics2DVector");
|
||||
}
|
||||
|
||||
if ( !G4BooleanRand(theTransmittance) ) // Not transmitted, so reflect
|
||||
DoReflection();
|
||||
else {
|
||||
theStatus = Dichroic;
|
||||
NewMomentum = OldMomentum;
|
||||
NewPolarization = OldPolarization;
|
||||
}
|
||||
}
|
||||
|
||||
void G4OpBoundaryProcess::DielectricDielectric()
|
||||
{
|
||||
G4bool Inside = false;
|
||||
@@ -1174,3 +1244,14 @@ void G4OpBoundaryProcess::CalculateReflectivity()
|
||||
GetReflectivity(E1_perp, E1_parl, incidentangle,
|
||||
RealRindex, ImaginaryRindex);
|
||||
}
|
||||
|
||||
G4bool G4OpBoundaryProcess::InvokeSD(const G4Step* pStep)
|
||||
{
|
||||
G4Step aStep = *pStep;
|
||||
|
||||
aStep.AddTotalEnergyDeposit(thePhotonMomentum);
|
||||
|
||||
G4VSensitiveDetector* sd = aStep.GetPostStepPoint()->GetSensitiveDetector();
|
||||
if (sd) return sd->Hit(&aStep);
|
||||
else return false;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4OpRayleigh.cc 71487 2013-06-17 08:19:40Z gcosmo $
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -84,15 +84,13 @@ G4OpRayleigh::G4OpRayleigh(const G4String& processName, G4ProcessType type)
|
||||
{
|
||||
SetProcessSubType(fOpRayleigh);
|
||||
|
||||
thePhysicsTable = 0;
|
||||
thePhysicsTable = NULL;
|
||||
|
||||
DefaultWater = false;
|
||||
|
||||
if (verboseLevel>0) {
|
||||
G4cout << GetProcessName() << " is created " << G4endl;
|
||||
}
|
||||
|
||||
BuildThePhysicsTable();
|
||||
}
|
||||
|
||||
// G4OpRayleigh::G4OpRayleigh(const G4OpRayleigh &right)
|
||||
@@ -105,7 +103,7 @@ G4OpRayleigh::G4OpRayleigh(const G4String& processName, G4ProcessType type)
|
||||
|
||||
G4OpRayleigh::~G4OpRayleigh()
|
||||
{
|
||||
if (thePhysicsTable!= 0) {
|
||||
if (thePhysicsTable!= NULL) {
|
||||
thePhysicsTable->clearAndDestroy();
|
||||
delete thePhysicsTable;
|
||||
}
|
||||
@@ -115,6 +113,11 @@ G4OpRayleigh::~G4OpRayleigh()
|
||||
// Methods
|
||||
////////////
|
||||
|
||||
void G4OpRayleigh::BuildPhysicsTable(const G4ParticleDefinition&)
|
||||
{
|
||||
if (!thePhysicsTable) BuildThePhysicsTable();
|
||||
}
|
||||
|
||||
// PostStepDoIt
|
||||
// -------------
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id$
|
||||
// $Id: G4OpWLS.cc 71487 2013-06-17 08:19:40Z gcosmo $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Optical Photon WaveLength Shifting (WLS) Class Implementation
|
||||
@@ -66,7 +66,7 @@ G4OpWLS::G4OpWLS(const G4String& processName, G4ProcessType type)
|
||||
{
|
||||
SetProcessSubType(fOpWLS);
|
||||
|
||||
theIntegralTable = 0;
|
||||
theIntegralTable = NULL;
|
||||
|
||||
if (verboseLevel>0) {
|
||||
G4cout << GetProcessName() << " is created " << G4endl;
|
||||
@@ -75,7 +75,6 @@ G4OpWLS::G4OpWLS(const G4String& processName, G4ProcessType type)
|
||||
WLSTimeGeneratorProfile =
|
||||
new G4WLSTimeGeneratorProfileDelta("WLSTimeGeneratorProfileDelta");
|
||||
|
||||
BuildThePhysicsTable();
|
||||
}
|
||||
|
||||
////////////////
|
||||
@@ -95,6 +94,11 @@ G4OpWLS::~G4OpWLS()
|
||||
// Methods
|
||||
////////////
|
||||
|
||||
void G4OpWLS::BuildPhysicsTable(const G4ParticleDefinition&)
|
||||
{
|
||||
if (!theIntegralTable) BuildThePhysicsTable();
|
||||
}
|
||||
|
||||
// PostStepDoIt
|
||||
// -------------
|
||||
//
|
||||
@@ -147,6 +151,8 @@ G4OpWLS::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
|
||||
aParticleChange.SetNumberOfSecondaries(NumPhotons);
|
||||
|
||||
G4double primaryEnergy = aTrack.GetDynamicParticle()->GetKineticEnergy();
|
||||
|
||||
G4int materialIndex = aMaterial->GetIndex();
|
||||
|
||||
// Retrieve the WLS Integral for this material
|
||||
@@ -163,20 +169,47 @@ G4OpWLS::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
|
||||
// Max WLS Integral
|
||||
|
||||
G4double CIImax = WLSIntegral->GetMaxValue();
|
||||
|
||||
|
||||
G4int NumberOfPhotons = NumPhotons;
|
||||
|
||||
for (G4int i = 0; i < NumPhotons; i++) {
|
||||
|
||||
G4double sampledEnergy;
|
||||
|
||||
// Determine photon energy
|
||||
|
||||
G4double CIIvalue = G4UniformRand()*CIImax;
|
||||
G4double sampledEnergy =
|
||||
WLSIntegral->GetEnergy(CIIvalue);
|
||||
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "sampledEnergy = " << sampledEnergy << G4endl;
|
||||
G4cout << "CIIvalue = " << CIIvalue << G4endl;
|
||||
// Make sure the energy of the secondary is less than that of the primary
|
||||
|
||||
for (G4int j = 1; j <= 100; j++) {
|
||||
|
||||
// Determine photon energy
|
||||
|
||||
G4double CIIvalue = G4UniformRand()*CIImax;
|
||||
sampledEnergy = WLSIntegral->GetEnergy(CIIvalue);
|
||||
|
||||
if (verboseLevel>1) {
|
||||
G4cout << "sampledEnergy = " << sampledEnergy << G4endl;
|
||||
G4cout << "CIIvalue = " << CIIvalue << G4endl;
|
||||
}
|
||||
|
||||
if (sampledEnergy <= primaryEnergy) break;
|
||||
}
|
||||
|
||||
|
||||
// If no such energy can be sampled, return one less secondary, or none
|
||||
|
||||
if (sampledEnergy > primaryEnergy) {
|
||||
if (verboseLevel>1)
|
||||
G4cout << " *** One less WLS photon will be returned ***" << G4endl;
|
||||
NumberOfPhotons--;
|
||||
aParticleChange.SetNumberOfSecondaries(NumberOfPhotons);
|
||||
if (NumberOfPhotons == 0) {
|
||||
if (verboseLevel>1)
|
||||
G4cout << " *** No WLS photon can be sampled for this primary ***"
|
||||
<< G4endl;
|
||||
// return unchanged particle and no secondaries
|
||||
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate random photon direction
|
||||
|
||||
G4double cost = 1. - 2.*G4UniformRand();
|
||||
|
||||
Reference in New Issue
Block a user