Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
+1
View File
@@ -20,6 +20,7 @@ CPPFLAGS += -I$(G4BASE)/global/management/include \
-I$(G4BASE)/digits_hits/hits/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/scoring/include \
-I$(G4BASE)/particles/management/include \
+13
View File
@@ -16,6 +16,19 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
04 Nov 20: D. Sawkey (op-V10-06-07)
- Fix reading Davis LUT out of bounds (addresses bug 2287)
05 Oct 20: D. Sawkey (op-V10-06-06)
- All files: apply clang-format style guidelines
30 Sept 20: D. Sawkey (op-V10-06-05)
- G4OpBoundaryProcess: increase geometry tolerance to kCarTolerance
20 July 20: D. Sawkey (op-V10-06-04)
- G4OpRayleigh, G4OpAbsorption, G4OpMieHG, G4OpWLS, G4OpWLS2: move to new
G4OpticalParameters class to control simulation parameters
29 May 20: D. Sawkey (op-V10-06-03)
- all files - thorough cleaning; shorten temporary variable names;
improve readability
@@ -51,37 +51,39 @@
class G4OpAbsorption : public G4VDiscreteProcess
{
public:
public:
explicit G4OpAbsorption(const G4String& processName = "OpAbsorption",
G4ProcessType type = fOptical);
virtual ~G4OpAbsorption();
G4ProcessType type = fOptical);
virtual ~G4OpAbsorption();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4ForceCondition*) override;
virtual G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the absorption length for bulk absorption of optical
// photons in media with a specified attenuation length.
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
// Method implementing bulk absorption of optical photons.
private:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
G4OpAbsorption(const G4OpAbsorption &right) = delete;
G4OpAbsorption& operator=(const G4OpAbsorption &right) = delete;
virtual void Initialise();
size_t idx_absorption = 0;
private:
G4OpAbsorption(const G4OpAbsorption& right) = delete;
G4OpAbsorption& operator=(const G4OpAbsorption& right) = delete;
size_t idx_absorption = 0;
};
// Inline methods
inline
G4bool G4OpAbsorption::IsApplicable(const G4ParticleDefinition& aParticleType)
inline G4bool G4OpAbsorption::IsApplicable(
const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
@@ -25,7 +25,7 @@
//
//
//
//
//
////////////////////////////////////////////////////////////////////////
// Optical Photon Boundary Process Class Definition
////////////////////////////////////////////////////////////////////////
@@ -37,9 +37,9 @@
// Created: 1997-06-18
// Modified: 2005-07-28 add G4ProcessType to constructor
// 1999-10-29 add method and class descriptors
// 1999-10-10 - Fill NewMomentum/NewPolarization in
// 1999-10-10 - Fill NewMomentum/NewPolarization in
// DoAbsorption. These members need to be
// filled since DoIt calls
// filled since DoIt calls
// aParticleChange.SetMomentumChange etc.
// upon return (thanks to: Clark McGrew)
// 2006-11-04 - add capability of calculating the reflectivity
@@ -69,48 +69,69 @@
#include "G4OpticalSurface.hh"
#include "G4OpticalPhoton.hh"
enum G4OpBoundaryProcessStatus {
enum G4OpBoundaryProcessStatus
{
Undefined,
Transmission, FresnelRefraction,
FresnelReflection, TotalInternalReflection,
LambertianReflection, LobeReflection,
SpikeReflection, BackScattering,
Absorption, Detection,
NotAtBoundary, 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,
Dichroic };
Transmission,
FresnelRefraction,
FresnelReflection,
TotalInternalReflection,
LambertianReflection,
LobeReflection,
SpikeReflection,
BackScattering,
Absorption,
Detection,
NotAtBoundary,
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,
Dichroic
};
class G4OpBoundaryProcess : public G4VDiscreteProcess
{
public:
public:
explicit G4OpBoundaryProcess(const G4String& processName = "OpBoundary",
G4ProcessType type = fOptical);
G4ProcessType type = fOptical);
virtual ~G4OpBoundaryProcess();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual G4double GetMeanFreePath(const G4Track&, G4double, G4ForceCondition* condition) override;
virtual G4double GetMeanFreePath(const G4Track&, G4double,
G4ForceCondition* condition) override;
// Returns infinity; i. e. the process does not limit the step, but sets the
// 'Forced' condition for the DoIt to be invoked at every step. However, only
// at a boundary will any action be taken.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
const G4Step& aStep) override;
// This is the method implementing boundary processes.
virtual G4OpBoundaryProcessStatus GetStatus() const;
@@ -119,15 +140,18 @@ public:
virtual void SetInvokeSD(G4bool);
// Set flag for call to InvokeSD method.
private:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
G4OpBoundaryProcess(const G4OpBoundaryProcess &right) = delete;
G4OpBoundaryProcess& operator=(const G4OpBoundaryProcess &right) = delete;
virtual void Initialise();
private:
G4OpBoundaryProcess(const G4OpBoundaryProcess& right) = delete;
G4OpBoundaryProcess& operator=(const G4OpBoundaryProcess& right) = delete;
G4bool G4BooleanRand(const G4double prob) const;
G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
const G4ThreeVector& Normal) const;
const G4ThreeVector& Normal) const;
void DielectricMetal();
void DielectricDielectric();
@@ -144,10 +168,8 @@ private:
G4double GetIncidentAngle();
// Returns the incident angle of optical photon
G4double GetReflectivity(G4double E1_perp,
G4double E1_parl,
G4double incidentangle,
G4double RealRindex,
G4double GetReflectivity(G4double E1_perp, G4double E1_parl,
G4double incidentangle, G4double RealRindex,
G4double ImaginaryRindex);
// Returns the Reflectivity on a metalic surface
@@ -205,81 +227,77 @@ private:
G4bool fInvokeSD;
size_t idx_rindex1 = 0;
size_t idx_rindex1 = 0;
size_t idx_rindex_surface = 0;
size_t idx_reflect = 0;
size_t idx_eff = 0;
size_t idx_trans = 0;
size_t idx_lobe = 0;
size_t idx_spike = 0;
size_t idx_back = 0;
size_t idx_rindex2 = 0;
size_t idx_groupvel = 0;
size_t idx_rrindex = 0;
size_t idx_irindex = 0;
size_t idx_reflect = 0;
size_t idx_eff = 0;
size_t idx_trans = 0;
size_t idx_lobe = 0;
size_t idx_spike = 0;
size_t idx_back = 0;
size_t idx_rindex2 = 0;
size_t idx_groupvel = 0;
size_t idx_rrindex = 0;
size_t idx_irindex = 0;
};
////////////////////
// Inline methods
////////////////////
inline
G4bool G4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
inline G4bool G4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
{
/* Returns a random boolean variable with the specified probability */
return (G4UniformRand() < prob);
}
inline
G4bool G4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition&
aParticleType)
inline G4bool G4OpBoundaryProcess::IsApplicable(
const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
inline
G4OpBoundaryProcessStatus G4OpBoundaryProcess::GetStatus() const
inline G4OpBoundaryProcessStatus G4OpBoundaryProcess::GetStatus() const
{
return theStatus;
}
inline
void G4OpBoundaryProcess::SetInvokeSD(G4bool flag)
{
fInvokeSD = flag;
}
inline void G4OpBoundaryProcess::SetInvokeSD(G4bool flag) { fInvokeSD = flag; }
inline
void G4OpBoundaryProcess::ChooseReflection()
inline void G4OpBoundaryProcess::ChooseReflection()
{
G4double rand = G4UniformRand();
if (rand >= 0.0 && rand < prob_ss) {
theStatus = SpikeReflection;
if(rand >= 0.0 && rand < prob_ss)
{
theStatus = SpikeReflection;
theFacetNormal = theGlobalNormal;
}
else if (rand >= prob_ss && rand <= prob_ss+prob_sl) {
else if(rand >= prob_ss && rand <= prob_ss + prob_sl)
{
theStatus = LobeReflection;
}
else if (rand > prob_ss+prob_sl && rand < prob_ss+prob_sl+prob_bs) {
else if(rand > prob_ss + prob_sl && rand < prob_ss + prob_sl + prob_bs)
{
theStatus = BackScattering;
}
else {
else
{
theStatus = LambertianReflection;
}
}
inline
void G4OpBoundaryProcess::DoAbsorption()
inline void G4OpBoundaryProcess::DoAbsorption()
{
theStatus = Absorption;
if (G4BooleanRand(theEfficiency)) {
if(G4BooleanRand(theEfficiency))
{
// EnergyDeposited =/= 0 means: photon has been detected
theStatus = Detection;
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
}
else {
else
{
aParticleChange.ProposeLocalEnergyDeposit(0.0);
}
@@ -289,31 +307,36 @@ void G4OpBoundaryProcess::DoAbsorption()
aParticleChange.ProposeTrackStatus(fStopAndKill);
}
inline
void G4OpBoundaryProcess::DoReflection()
inline void G4OpBoundaryProcess::DoReflection()
{
if (theStatus == LambertianReflection) {
NewMomentum = G4LambertianRand(theGlobalNormal);
if(theStatus == LambertianReflection)
{
NewMomentum = G4LambertianRand(theGlobalNormal);
theFacetNormal = (NewMomentum - OldMomentum).unit();
}
else if (theFinish == ground) {
else if(theFinish == ground)
{
theStatus = LobeReflection;
if (fRealRIndexMPV && fImagRIndexMPV) {
if(fRealRIndexMPV && fImagRIndexMPV)
{
//
} else {
theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal);
}
else
{
theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal);
}
G4double PdotN = OldMomentum * theFacetNormal;
NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
}
else {
theStatus = SpikeReflection;
else
{
theStatus = SpikeReflection;
theFacetNormal = theGlobalNormal;
G4double PdotN = OldMomentum * theFacetNormal;
NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
}
G4double EdotN = OldPolarization * theFacetNormal;
NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
G4double EdotN = OldPolarization * theFacetNormal;
NewPolarization = -OldPolarization + (2. * EdotN) * theFacetNormal;
}
#endif /* G4OpBoundaryProcess_h */
+13 -14
View File
@@ -31,7 +31,7 @@
// Author: Xin Qian
// Based on work from Vlasios Vasileiou
//
// This subroutine will mimic the Mie scattering based on
// This subroutine will mimic the Mie scattering based on
// Henyey-Greenstein phase function
// Forward and backward angles are treated separately.
//
@@ -45,35 +45,34 @@
class G4OpMieHG : public G4VDiscreteProcess
{
public:
public:
explicit G4OpMieHG(const G4String& processName = "OpMieHG",
G4ProcessType type = fOptical);
G4ProcessType type = fOptical);
virtual ~G4OpMieHG();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double,
virtual G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Return the mean free path of Mie scattering
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
const G4Step& aStep) override;
// This is the method implementing Mie scattering.
private:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
virtual void Initialise();
G4OpMieHG(const G4OpMieHG &right) = delete;
G4OpMieHG& operator=(const G4OpMieHG &right) = delete;
private:
G4OpMieHG(const G4OpMieHG& right) = delete;
G4OpMieHG& operator=(const G4OpMieHG& right) = delete;
size_t idx_mie = 0;
};
inline
G4bool G4OpMieHG::IsApplicable(const G4ParticleDefinition& aParticleType)
inline G4bool G4OpMieHG::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
@@ -40,8 +40,8 @@
#ifndef G4OpProcessSubType_h
#define G4OpProcessSubType_h 1
enum G4OpProcessSubType
{
enum G4OpProcessSubType
{
fOpAbsorption = 31,
fOpBoundary = 32,
fOpRayleigh = 33,
@@ -25,13 +25,13 @@
//
//
//
//
//
////////////////////////////////////////////////////////////////////////
// Optical Photon Rayleigh Scattering Class Definition
////////////////////////////////////////////////////////////////////////
//
// File: G4OpRayleigh.hh
// Description: Discrete Process -- Rayleigh scattering of optical photons
// Description: Discrete Process -- Rayleigh scattering of optical photons
// Version: 1.0
// Created: 1996-05-31
// Author: Juliet Armstrong
@@ -52,25 +52,25 @@
class G4OpRayleigh : public G4VDiscreteProcess
{
public:
public:
explicit G4OpRayleigh(const G4String& processName = "OpRayleigh",
G4ProcessType type = fOptical);
virtual ~G4OpRayleigh();
G4ProcessType type = fOptical);
virtual ~G4OpRayleigh();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
virtual void BuildPhysicsTable(
const G4ParticleDefinition& aParticleType) override;
// Build thePhysicsTable at a right time
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double,
virtual G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the mean free path for Rayleigh scattering
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
const G4Step& aStep) override;
// This is the method implementing Rayleigh scattering.
virtual G4PhysicsTable* GetPhysicsTable() const;
@@ -79,19 +79,20 @@ public:
virtual void DumpPhysicsTable() const;
// Prints the physics table.
protected:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
virtual void Initialise();
G4PhysicsTable* thePhysicsTable;
protected:
G4PhysicsTable* thePhysicsTable;
private:
G4OpRayleigh(const G4OpRayleigh &right) = delete;
G4OpRayleigh& operator=(const G4OpRayleigh &right) = delete;
private:
G4OpRayleigh(const G4OpRayleigh& right) = delete;
G4OpRayleigh& operator=(const G4OpRayleigh& right) = delete;
/// Calculates the mean free paths for a material as a function of
/// photon energy
G4PhysicsOrderedFreeVector*
CalculateRayleighMeanFreePaths(const G4Material* material) const;
G4PhysicsOrderedFreeVector* CalculateRayleighMeanFreePaths(
const G4Material* material) const;
size_t idx_rslength = 0;
};
@@ -100,18 +101,17 @@ private:
// Inline methods
////////////////////
inline
G4bool G4OpRayleigh::IsApplicable(const G4ParticleDefinition& aParticleType)
inline G4bool G4OpRayleigh::IsApplicable(
const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
inline
void G4OpRayleigh::DumpPhysicsTable() const
inline void G4OpRayleigh::DumpPhysicsTable() const
{
for (size_t i=0; i<thePhysicsTable->entries(); ++i)
for(size_t i = 0; i < thePhysicsTable->entries(); ++i)
{
((G4PhysicsOrderedFreeVector*)(*thePhysicsTable)[i])->DumpValues();
((G4PhysicsOrderedFreeVector*) (*thePhysicsTable)[i])->DumpValues();
}
}
+22 -24
View File
@@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////////
//
// File: G4OpWLS.hh
// Description: Discrete Process -- Wavelength Shifting of Optical Photons
// Description: Discrete Process -- Wavelength Shifting of Optical Photons
// Version: 1.0
// Created: 2003-05-13
// Author: John Paul Archambault
@@ -50,26 +50,26 @@ class G4VWLSTimeGeneratorProfile;
class G4OpWLS : public G4VDiscreteProcess
{
public:
public:
explicit G4OpWLS(const G4String& processName = "OpWLS",
G4ProcessType type = fOptical);
G4ProcessType type = fOptical);
virtual ~G4OpWLS();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
virtual void BuildPhysicsTable(
const G4ParticleDefinition& aParticleType) override;
// Build the WLS integral table at the right time
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double,
virtual G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the absorption length for WLS absorption of optical
// photons in media with a specified attenuation length.
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
const G4Step& aStep) override;
// This is the method implementing WLS for optical photons.
virtual G4PhysicsTable* GetIntegralTable() const;
@@ -78,18 +78,19 @@ public:
virtual void DumpPhysicsTable() const;
// Prints the WLS integral table.
void UseTimeProfile(const G4String name);
virtual void UseTimeProfile(const G4String name);
// Selects the time profile generator
protected:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
virtual void Initialise();
protected:
G4VWLSTimeGeneratorProfile* WLSTimeGeneratorProfile;
G4PhysicsTable* theIntegralTable;
private:
G4OpWLS(const G4OpWLS &right) = delete;
G4OpWLS& operator=(const G4OpWLS &right) = delete;
private:
G4OpWLS(const G4OpWLS& right) = delete;
G4OpWLS& operator=(const G4OpWLS& right) = delete;
size_t idx_wls = 0;
};
@@ -98,27 +99,24 @@ private:
// Inline methods
////////////////////
inline
G4bool G4OpWLS::IsApplicable(const G4ParticleDefinition& aParticleType)
inline G4bool G4OpWLS::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
inline
G4PhysicsTable* G4OpWLS::GetIntegralTable() const
inline G4PhysicsTable* G4OpWLS::GetIntegralTable() const
{
return theIntegralTable;
}
inline
void G4OpWLS::DumpPhysicsTable() const
inline void G4OpWLS::DumpPhysicsTable() const
{
G4int PhysicsTableSize = theIntegralTable->entries();
G4PhysicsOrderedFreeVector *v;
G4PhysicsOrderedFreeVector* v;
for (G4int i=0; i<PhysicsTableSize; ++i)
for(G4int i = 0; i < PhysicsTableSize; ++i)
{
v = (G4PhysicsOrderedFreeVector*)(*theIntegralTable)[i];
v = (G4PhysicsOrderedFreeVector*) (*theIntegralTable)[i];
v->DumpValues();
}
}
+25 -27
View File
@@ -30,7 +30,7 @@
////////////////////////////////////////////////////////////////////////
//
// File: G4OpWLS2.hh
// Description: Discrete Process -- Wavelength Shifting of Optical Photons
// Description: Discrete Process -- Wavelength Shifting of Optical Photons
// Version: 1.0
// Created: 2003-05-13
// Author: John Paul Archambault
@@ -41,35 +41,35 @@
////////////////////////////////////////////////////////////////////////
#ifndef G4OpWL2S_h
#define G4OpWLS2_h 1
# define G4OpWLS2_h 1
#include "G4VDiscreteProcess.hh"
#include "G4OpticalPhoton.hh"
# include "G4VDiscreteProcess.hh"
# include "G4OpticalPhoton.hh"
class G4VWLSTimeGeneratorProfile;
class G4OpWLS2 : public G4VDiscreteProcess
{
public:
public:
explicit G4OpWLS2(const G4String& processName = "OpWLS2",
G4ProcessType type = fOptical);
G4ProcessType type = fOptical);
virtual ~G4OpWLS2();
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
virtual G4bool IsApplicable(
const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable' only for an optical photon.
virtual void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
virtual void BuildPhysicsTable(
const G4ParticleDefinition& aParticleType) override;
// Build the WLS2 integral table at the right time
virtual G4double GetMeanFreePath(const G4Track& aTrack,
G4double,
virtual G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the absorption length for WLS2 absorption of optical
// photons in media with a specified attenuation length.
virtual G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
const G4Step& aStep) override;
// This is the method implementing WLS2 for optical photons.
virtual G4PhysicsTable* GetIntegralTable() const;
@@ -78,18 +78,19 @@ public:
virtual void DumpPhysicsTable() const;
// Prints the WLS2 integral table.
void UseTimeProfile(const G4String name);
virtual void UseTimeProfile(const G4String name);
// Selects the time profile generator
protected:
virtual void PreparePhysicsTable(const G4ParticleDefinition&) override;
virtual void Initialise();
protected:
G4VWLSTimeGeneratorProfile* WLSTimeGeneratorProfile;
G4PhysicsTable* theIntegralTable;
private:
G4OpWLS2(const G4OpWLS2 &right) = delete;
G4OpWLS2& operator=(const G4OpWLS2 &right) = delete;
private:
G4OpWLS2(const G4OpWLS2& right) = delete;
G4OpWLS2& operator=(const G4OpWLS2& right) = delete;
size_t idx_wls2 = 0;
};
@@ -98,27 +99,24 @@ private:
// Inline methods
////////////////////
inline
G4bool G4OpWLS2::IsApplicable(const G4ParticleDefinition& aParticleType)
inline G4bool G4OpWLS2::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
}
inline
G4PhysicsTable* G4OpWLS2::GetIntegralTable() const
inline G4PhysicsTable* G4OpWLS2::GetIntegralTable() const
{
return theIntegralTable;
}
inline
void G4OpWLS2::DumpPhysicsTable() const
inline void G4OpWLS2::DumpPhysicsTable() const
{
G4int PhysicsTableSize = theIntegralTable->entries();
G4PhysicsOrderedFreeVector *v;
G4PhysicsOrderedFreeVector* v;
for (G4int i=0; i<PhysicsTableSize; ++i)
for(G4int i = 0; i < PhysicsTableSize; ++i)
{
v = (G4PhysicsOrderedFreeVector*)(*theIntegralTable)[i];
v = (G4PhysicsOrderedFreeVector*) (*theIntegralTable)[i];
v->DumpValues();
}
}
@@ -32,13 +32,13 @@
// File name: G4VWLSTimeGeneratorProfile.hh
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
//
//
// Creation date: 2006-05-07
//
// Modifications:
// Modifications:
//
// Class Description:
// Class Description:
//
// Abstract class for a WLSTimeGeneratorProfile
@@ -51,28 +51,24 @@
#include "G4ios.hh"
//#include "globals.hh"
#include "G4MaterialPropertiesTable.hh"
//class G4MaterialPropertiesTable;
// class G4MaterialPropertiesTable;
class G4VWLSTimeGeneratorProfile
{
public:
public:
G4VWLSTimeGeneratorProfile(const G4String& name);
virtual ~G4VWLSTimeGeneratorProfile();
virtual G4double GenerateTime(const G4double time_constant) = 0;
virtual G4double GenerateTime(const G4double time_constant) = 0;
virtual G4double GenerateTime(const G4MaterialPropertiesTable*) = 0;
private:
private:
// hide assignment operator
G4VWLSTimeGeneratorProfile & operator=
(const G4VWLSTimeGeneratorProfile &right) = delete;
G4VWLSTimeGeneratorProfile(const G4VWLSTimeGeneratorProfile&) = delete;
G4VWLSTimeGeneratorProfile& operator=
(const G4VWLSTimeGeneratorProfile& right) = delete;
G4VWLSTimeGeneratorProfile(const G4VWLSTimeGeneratorProfile&) = delete;
};
#endif
@@ -32,10 +32,10 @@
// File name: G4WLSTimeGeneratorProfileDelta.hh
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
// Creation date: 2006-05-07
//
// Modifications:
// Modifications:
//
// Class Description: Discrete Class of WLSTimeGeneratorProfile
//
@@ -49,9 +49,7 @@
class G4WLSTimeGeneratorProfileDelta : public G4VWLSTimeGeneratorProfile
{
public:
public:
explicit G4WLSTimeGeneratorProfileDelta(const G4String& name);
virtual ~G4WLSTimeGeneratorProfileDelta();
@@ -60,16 +58,14 @@ public:
virtual G4double GenerateTime(const G4MaterialPropertiesTable*) override;
protected:
private:
protected:
private:
// hide assignment operator
G4WLSTimeGeneratorProfileDelta & operator=
(const G4WLSTimeGeneratorProfileDelta &right) = delete;
G4WLSTimeGeneratorProfileDelta(const G4WLSTimeGeneratorProfileDelta&) = delete;
G4WLSTimeGeneratorProfileDelta& operator=
(const G4WLSTimeGeneratorProfileDelta& right) = delete;
G4WLSTimeGeneratorProfileDelta(const G4WLSTimeGeneratorProfileDelta&) =
delete;
};
#endif
@@ -32,12 +32,12 @@
// File name: G4WLSTimeGeneratorProfileExponential.hh
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
// Creation date: 2006-05-07
//
// Modifications:
// Modifications:
//
// Class Description:
// Class Description:
//
// -------------------------------------------------------------------
@@ -50,9 +50,7 @@
class G4WLSTimeGeneratorProfileExponential : public G4VWLSTimeGeneratorProfile
{
public:
public:
explicit G4WLSTimeGeneratorProfileExponential(const G4String& name);
virtual ~G4WLSTimeGeneratorProfileExponential();
@@ -61,16 +59,14 @@ public:
virtual G4double GenerateTime(const G4MaterialPropertiesTable*) override;
protected:
private:
protected:
private:
// hide assignment operator
G4WLSTimeGeneratorProfileExponential & operator=
(const G4WLSTimeGeneratorProfileExponential &right) = delete;
G4WLSTimeGeneratorProfileExponential(const G4WLSTimeGeneratorProfileExponential&) = delete;
G4WLSTimeGeneratorProfileExponential& operator=
(const G4WLSTimeGeneratorProfileExponential& right) = delete;
G4WLSTimeGeneratorProfileExponential(
const G4WLSTimeGeneratorProfileExponential&) = delete;
};
#endif
+1 -22
View File
@@ -4,7 +4,7 @@
# Package: Geant4.src.G4processes.G4optical
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists the sources and headers of the code explicitly.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
@@ -14,30 +14,9 @@
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/bosons/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/scoring/include)
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/hits/include)
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/detector/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4optical
HEADERS
G4OpAbsorption.hh
+36 -18
View File
@@ -30,13 +30,13 @@
////////////////////////////////////////////////////////////////////////
//
// File: G4OpAbsorption.cc
// Description: Discrete Process -- Absorption of Optical Photons
// Description: Discrete Process -- Absorption of Optical Photons
// Version: 1.0
// Created: 1996-05-21
// Author: Juliet Armstrong
// Updated: 2005-07-28 - add G4ProcessType to constructor
// 2000-09-18 by Peter Gumplinger
// > comment out warning - "No Absorption length specified"
// > comment out warning - "No Absorption length specified"
// 1997-04-09 by Peter Gumplinger
// > new physics/tracking scheme
// 1998-08-25 by Stefano Magni
@@ -48,6 +48,7 @@
#include "G4ios.hh"
#include "G4OpProcessSubType.hh"
#include "G4OpticalParameters.hh"
#include "G4OpAbsorption.hh"
@@ -55,47 +56,64 @@
G4OpAbsorption::G4OpAbsorption(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
{
if (verboseLevel >0 ) {
G4cout << GetProcessName() << " is created " << G4endl;
Initialise();
if(verboseLevel > 0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
SetProcessSubType(fOpAbsorption);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4OpAbsorption::~G4OpAbsorption()
{}
G4OpAbsorption::~G4OpAbsorption() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4OpAbsorption::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4OpAbsorption::PreparePhysicsTable(const G4ParticleDefinition&)
{
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpAbsorption::Initialise()
{
SetVerboseLevel(G4OpticalParameters::Instance()->GetAbsorptionVerboseLevel());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4OpAbsorption::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
G4double thePhotonMomentum = aParticle->GetTotalMomentum();
G4double thePhotonMomentum = aParticle->GetTotalMomentum();
aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
aParticleChange.ProposeTrackStatus(fStopAndKill);
if (verboseLevel>1) {
if(verboseLevel > 1)
{
G4cout << "\n** OpAbsorption: Photon absorbed! **" << G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4OpAbsorption::GetMeanFreePath(const G4Track& aTrack,
G4double,
G4ForceCondition*)
G4double G4OpAbsorption::GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*)
{
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
G4double attLength = DBL_MAX;
if (MPT) {
if(MPT)
{
G4MaterialPropertyVector* attVector = MPT->GetProperty(kABSLENGTH);
if (attVector) {
attLength = attVector->Value(aParticle->GetTotalMomentum(), idx_absorption);
if(attVector)
{
attLength =
attVector->Value(aParticle->GetTotalMomentum(), idx_absorption);
}
}
File diff suppressed because it is too large Load Diff
+83 -47
View File
@@ -32,7 +32,7 @@
// Author: Xin Qian
// Based on work from Vlasios Vasileiou
//
// This subroutine will mimic the Mie scattering based on
// This subroutine will mimic the Mie scattering based on
// Henyey-Greenstein phase function
// Forward and backward angles are treated separately.
//
@@ -40,14 +40,17 @@
#include "G4OpMieHG.hh"
#include "G4PhysicalConstants.hh"
#include "G4OpticalParameters.hh"
#include "G4OpProcessSubType.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4OpMieHG::G4OpMieHG(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
: G4VDiscreteProcess(processName, type)
{
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created " << G4endl;
Initialise();
if(verboseLevel > 0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
SetProcessSubType(fOpMieHG);
}
@@ -56,92 +59,125 @@ G4OpMieHG::G4OpMieHG(const G4String& processName, G4ProcessType type)
G4OpMieHG::~G4OpMieHG() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4OpMieHG::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4OpMieHG::PreparePhysicsTable(const G4ParticleDefinition&)
{
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpMieHG::Initialise()
{
SetVerboseLevel(G4OpticalParameters::Instance()->GetMieVerboseLevel());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4OpMieHG::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
const G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
G4double forwardRatio = MPT->GetConstProperty(kMIEHG_FORWARD_RATIO);
G4double forwardRatio = MPT->GetConstProperty(kMIEHG_FORWARD_RATIO);
if (verboseLevel > 1) {
G4cout << "OpMie Scattering Photon!" << G4endl
<< " Old Momentum Direction: "
<< aParticle->GetMomentumDirection() << G4endl
<< " MIE Old Polarization: "
<< aParticle->GetPolarization() << G4endl;
}
if(verboseLevel > 1)
{
G4cout << "OpMie Scattering Photon!" << G4endl
<< " Old Momentum Direction: " << aParticle->GetMomentumDirection()
<< G4endl
<< " MIE Old Polarization: " << aParticle->GetPolarization()
<< G4endl;
}
G4double gg;
G4int direction;
if (G4UniformRand() <= forwardRatio) {
gg = MPT->GetConstProperty(kMIEHG_FORWARD);
direction = 1;
} else {
gg = MPT->GetConstProperty(kMIEHG_BACKWARD);
direction = -1;
}
if(G4UniformRand() <= forwardRatio)
{
gg = MPT->GetConstProperty(kMIEHG_FORWARD);
direction = 1;
}
else
{
gg = MPT->GetConstProperty(kMIEHG_BACKWARD);
direction = -1;
}
G4double r = G4UniformRand();
//sample the direction
// sample the direction
G4double theta;
if (gg != 0.) {
theta = std::acos(2.*r*(1.+gg)*(1.+gg)*(1.-gg+gg*r)/((1.-gg+2.*gg*r)*(1.-gg+2.*gg*r)) -1.);
} else {
theta = std::acos(2.*r-1.);
}
G4double phi = G4UniformRand()*twopi;
if(gg != 0.)
{
theta = std::acos(2. * r * (1. + gg) * (1. + gg) * (1. - gg + gg * r) /
((1. - gg + 2. * gg * r) * (1. - gg + 2. * gg * r)) -
1.);
}
else
{
theta = std::acos(2. * r - 1.);
}
G4double phi = G4UniformRand() * twopi;
if (direction == -1) theta = pi - theta; //backward scattering
if(direction == -1)
theta = pi - theta; // backward scattering
G4ThreeVector newMomDir, oldMomDir;
G4ThreeVector newPol, oldPol;
G4double sinth = std::sin(theta);
newMomDir.set(sinth*std::cos(phi), sinth*std::sin(phi), std::cos(theta));
newMomDir.set(sinth * std::cos(phi), sinth * std::sin(phi), std::cos(theta));
oldMomDir = aParticle->GetMomentumDirection();
newMomDir.rotateUz(oldMomDir);
newMomDir = newMomDir.unit();
oldPol = aParticle->GetPolarization();
newPol = newMomDir - oldPol/newMomDir.dot(oldPol);
newPol = newMomDir - oldPol / newMomDir.dot(oldPol);
newPol = newPol.unit();
if (newPol.mag() == 0.) {
r = G4UniformRand()*twopi;
if(newPol.mag() == 0.)
{
r = G4UniformRand() * twopi;
newPol.set(std::cos(r), std::sin(r), 0.);
newPol.rotateUz(newMomDir);
} else {
// There are two directions perpendicular to new momentum direction
if (G4UniformRand() < 0.5) newPol = -newPol;
}
else
{
// There are two directions perpendicular to new momentum direction
if(G4UniformRand() < 0.5)
newPol = -newPol;
}
aParticleChange.ProposePolarization(newPol);
aParticleChange.ProposeMomentumDirection(newMomDir);
if (verboseLevel > 1) {
if(verboseLevel > 1)
{
G4cout << "OpMie New Polarization: " << newPol << G4endl
<< " Polarization Change: " << *(aParticleChange.GetPolarization()) << G4endl
<< " New Momentum Direction: " << newMomDir << G4endl
<< " Momentum Change: " << *(aParticleChange.GetMomentumDirection()) << G4endl;
<< " Polarization Change: " << *(aParticleChange.GetPolarization())
<< G4endl << " New Momentum Direction: " << newMomDir << G4endl
<< " Momentum Change: " << *(aParticleChange.GetMomentumDirection())
<< G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4OpMieHG::GetMeanFreePath(const G4Track& aTrack,
G4double, G4ForceCondition*)
G4double G4OpMieHG::GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*)
{
G4double attLength = DBL_MAX;
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
if (MPT) {
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
if(MPT)
{
G4MaterialPropertyVector* attVector = MPT->GetProperty(kMIEHG);
if (attVector) {
attLength = attVector->Value(aTrack.GetDynamicParticle()->GetTotalEnergy(), idx_mie);
if(attVector)
{
attLength = attVector->Value(
aTrack.GetDynamicParticle()->GetTotalEnergy(), idx_mie);
}
}
return attLength;
+129 -93
View File
@@ -25,7 +25,7 @@
//
//
//
//
//
////////////////////////////////////////////////////////////////////////
// Optical Photon Rayleigh Scattering Class Implementation
////////////////////////////////////////////////////////////////////////
@@ -36,7 +36,7 @@
// Version: 1.0
// Created: 1996-05-31
// Author: Juliet Armstrong
// Updated: 2014-10-10 - This version calculates the Rayleigh scattering
// Updated: 2014-10-10 - This version calculates the Rayleigh scattering
// length for more materials than just Water (although the Water
// default is kept). To do this the user would need to specify the
// ISOTHERMAL_COMPRESSIBILITY as a material property and
@@ -64,16 +64,19 @@
#include "G4ios.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4OpticalParameters.hh"
#include "G4OpProcessSubType.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4OpRayleigh::G4OpRayleigh(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
: G4VDiscreteProcess(processName, type)
{
Initialise();
SetProcessSubType(fOpRayleigh);
thePhysicsTable = nullptr;
if (verboseLevel > 0) {
if(verboseLevel > 0)
{
G4cout << GetProcessName() << " is created " << G4endl;
}
}
@@ -82,25 +85,38 @@ G4OpRayleigh::G4OpRayleigh(const G4String& processName, G4ProcessType type)
G4OpRayleigh::~G4OpRayleigh()
{
// VI: inside this PhysicsTable all properties are unique
// it is not possible to destroy
if (thePhysicsTable) {
// it is not possible to destroy
if(thePhysicsTable)
{
delete thePhysicsTable;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4OpRayleigh::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4OpRayleigh::PreparePhysicsTable(const G4ParticleDefinition&)
{
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpRayleigh::Initialise()
{
SetVerboseLevel(G4OpticalParameters::Instance()->GetRayleighVerboseLevel());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4OpRayleigh::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
if (verboseLevel > 1) {
if(verboseLevel > 1)
{
G4cout << "OpRayleigh: Scattering Photon!" << G4endl
<< "Old Momentum Direction: "
<< aParticle->GetMomentumDirection() << G4endl
<< "Old Polarization: "
<< aParticle->GetPolarization() << G4endl;
<< "Old Momentum Direction: " << aParticle->GetMomentumDirection()
<< G4endl << "Old Polarization: " << aParticle->GetPolarization()
<< G4endl;
}
G4double cosTheta;
@@ -109,107 +125,117 @@ G4OpRayleigh::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double rand;
G4double cost, sint, sinphi, cosphi;
do {
// Try to simulate the scattered photon momentum direction
// w.r.t. the initial photon momentum direction
cost = G4UniformRand();
sint = std::sqrt(1.-cost*cost);
// consider for the angle 90-180 degrees
if (G4UniformRand() < 0.5) cost = -cost;
do
{
// Try to simulate the scattered photon momentum direction
// w.r.t. the initial photon momentum direction
cost = G4UniformRand();
sint = std::sqrt(1. - cost * cost);
// consider for the angle 90-180 degrees
if(G4UniformRand() < 0.5)
cost = -cost;
// simulate the phi angle
rand = twopi*G4UniformRand();
sinphi = std::sin(rand);
cosphi = std::cos(rand);
// simulate the phi angle
rand = twopi * G4UniformRand();
sinphi = std::sin(rand);
cosphi = std::cos(rand);
// construct the new momentum direction
newMomDir.set(sint*cosphi, sint*sinphi, cost);
oldMomDir = aParticle->GetMomentumDirection();
newMomDir.rotateUz(oldMomDir);
// construct the new momentum direction
newMomDir.set(sint * cosphi, sint * sinphi, cost);
oldMomDir = aParticle->GetMomentumDirection();
newMomDir.rotateUz(oldMomDir);
// calculate the new polarization direction
// The new polarization needs to be in the same plane as the new
// momentum direction and the old polarization direction
oldPol = aParticle->GetPolarization();
newPol = (oldPol - newMomDir.dot(oldPol) * newMomDir).unit();
// calculate the new polarization direction
// The new polarization needs to be in the same plane as the new
// momentum direction and the old polarization direction
oldPol = aParticle->GetPolarization();
newPol = (oldPol - newMomDir.dot(oldPol) * newMomDir).unit();
// There is a corner case, where the new momentum direction
// is the same as old polarization direction:
// random generate the azimuthal angle w.r.t. new momentum direction
if (newPol.mag() == 0.) {
rand = G4UniformRand()*twopi;
newPol.set(std::cos(rand), std::sin(rand), 0.);
newPol.rotateUz(newMomDir);
} else {
// There are two directions perpendicular to the new momentum direction
if (G4UniformRand() < 0.5) newPol = -newPol;
}
// There is a corner case, where the new momentum direction
// is the same as old polarization direction:
// random generate the azimuthal angle w.r.t. new momentum direction
if(newPol.mag() == 0.)
{
rand = G4UniformRand() * twopi;
newPol.set(std::cos(rand), std::sin(rand), 0.);
newPol.rotateUz(newMomDir);
}
else
{
// There are two directions perpendicular to the new momentum direction
if(G4UniformRand() < 0.5)
newPol = -newPol;
}
// simulate according to the distribution cos^2(theta)
cosTheta = newPol.dot(oldPol);
// Loop checking, 13-Aug-2015, Peter Gumplinger
} while (std::pow(cosTheta,2) < G4UniformRand());
// simulate according to the distribution cos^2(theta)
cosTheta = newPol.dot(oldPol);
// Loop checking, 13-Aug-2015, Peter Gumplinger
} while(std::pow(cosTheta, 2) < G4UniformRand());
aParticleChange.ProposePolarization(newPol);
aParticleChange.ProposeMomentumDirection(newMomDir);
aParticleChange.ProposePolarization(newPol);
aParticleChange.ProposeMomentumDirection(newMomDir);
if (verboseLevel > 1) {
G4cout << "New Polarization: " << newPol << G4endl
<< "Polarization Change: "
<< *(aParticleChange.GetPolarization()) << G4endl
<< "New Momentum Direction: " << newMomDir << G4endl
<< "Momentum Change: " << *(aParticleChange.GetMomentumDirection())
<< G4endl;
}
if(verboseLevel > 1)
{
G4cout << "New Polarization: " << newPol << G4endl
<< "Polarization Change: " << *(aParticleChange.GetPolarization())
<< G4endl << "New Momentum Direction: " << newMomDir << G4endl
<< "Momentum Change: " << *(aParticleChange.GetMomentumDirection())
<< G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpRayleigh::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (thePhysicsTable) {
//thePhysicsTable->clearAndDestroy();
if(thePhysicsTable)
{
// thePhysicsTable->clearAndDestroy();
delete thePhysicsTable;
thePhysicsTable = nullptr;
}
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
const size_t numOfMaterials = G4Material::GetNumberOfMaterials();
thePhysicsTable = new G4PhysicsTable(numOfMaterials);
const size_t numOfMaterials = G4Material::GetNumberOfMaterials();
thePhysicsTable = new G4PhysicsTable(numOfMaterials);
for (size_t i=0; i<numOfMaterials; ++i) {
G4Material* material = (*theMaterialTable)[i];
for(size_t i = 0; i < numOfMaterials; ++i)
{
G4Material* material = (*theMaterialTable)[i];
G4MaterialPropertiesTable* matProp = material->GetMaterialPropertiesTable();
G4PhysicsOrderedFreeVector* rayleigh = nullptr;
if (matProp) {
if(matProp)
{
rayleigh = matProp->GetProperty(kRAYLEIGH);
if (rayleigh == nullptr) rayleigh = CalculateRayleighMeanFreePaths(material);
if(rayleigh == nullptr)
rayleigh = CalculateRayleighMeanFreePaths(material);
}
thePhysicsTable->insertAt(i, rayleigh);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4OpRayleigh::GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4double G4OpRayleigh::GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*)
{
G4PhysicsOrderedFreeVector* rayleigh =
static_cast<G4PhysicsOrderedFreeVector*>
((*thePhysicsTable)(aTrack.GetMaterial()->GetIndex()));
static_cast<G4PhysicsOrderedFreeVector*>(
(*thePhysicsTable)(aTrack.GetMaterial()->GetIndex()));
G4double rsLength = DBL_MAX;
if (rayleigh) {
rsLength =rayleigh->Value(aTrack.GetDynamicParticle()->GetTotalMomentum(),
idx_rslength);
if(rayleigh)
{
rsLength = rayleigh->Value(aTrack.GetDynamicParticle()->GetTotalMomentum(),
idx_rslength);
}
return rsLength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4PhysicsOrderedFreeVector*
G4OpRayleigh::CalculateRayleighMeanFreePaths(const G4Material* material) const
G4PhysicsOrderedFreeVector* G4OpRayleigh::CalculateRayleighMeanFreePaths(
const G4Material* material) const
{
G4MaterialPropertiesTable* MPT = material->GetMaterialPropertiesTable();
@@ -217,52 +243,62 @@ G4OpRayleigh::CalculateRayleighMeanFreePaths(const G4Material* material) const
// compatibility use a constant if the material is "Water". If the material
// doesn't have an ISOTHERMAL_COMPRESSIBILITY constant then return
G4double betat;
if (material->GetName() == "Water") {
betat = 7.658e-23*m3/MeV;
if(material->GetName() == "Water")
{
betat = 7.658e-23 * m3 / MeV;
}
else if (MPT->ConstPropertyExists(kISOTHERMAL_COMPRESSIBILITY)) {
else if(MPT->ConstPropertyExists(kISOTHERMAL_COMPRESSIBILITY))
{
betat = MPT->GetConstProperty(kISOTHERMAL_COMPRESSIBILITY);
}
else {
else
{
return nullptr;
}
// If the material doesn't have a RINDEX property vector then return
G4MaterialPropertyVector* rIndex = MPT->GetProperty(kRINDEX);
if (rIndex == nullptr) return nullptr;
if(rIndex == nullptr)
return nullptr;
// Retrieve the optional scale factor (scales the scattering length)
G4double scaleFactor = 1.0;
if (MPT->ConstPropertyExists(kRS_SCALE_FACTOR)) {
if(MPT->ConstPropertyExists(kRS_SCALE_FACTOR))
{
scaleFactor = MPT->GetConstProperty(kRS_SCALE_FACTOR);
}
// Retrieve the material temperature. For backwards compatibility use a
// constant if the material is "Water"
G4double temperature;
if (material->GetName() == "Water") {
temperature = 283.15*kelvin; // Temperature of water is 10 degrees celsius
if(material->GetName() == "Water")
{
temperature =
283.15 * kelvin; // Temperature of water is 10 degrees celsius
}
else {
else
{
temperature = material->GetTemperature();
}
G4PhysicsOrderedFreeVector* rayleighMFPs = new G4PhysicsOrderedFreeVector();
// This calculates the meanFreePath via the Einstein-Smoluchowski formula
const G4double c1 = scaleFactor * betat * temperature * k_Boltzmann / (6.0*pi);
const G4double c1 =
scaleFactor * betat * temperature * k_Boltzmann / (6.0 * pi);
for (size_t uRIndex = 0; uRIndex < rIndex->GetVectorLength(); ++uRIndex)
for(size_t uRIndex = 0; uRIndex < rIndex->GetVectorLength(); ++uRIndex)
{
const G4double energy = rIndex->Energy(uRIndex);
const G4double energy = rIndex->Energy(uRIndex);
const G4double rIndexSquared = (*rIndex)[uRIndex] * (*rIndex)[uRIndex];
const G4double xlambda = h_Planck * c_light / energy;
const G4double c2 = std::pow(twopi/xlambda,4);
const G4double xlambda = h_Planck * c_light / energy;
const G4double c2 = std::pow(twopi / xlambda, 4);
const G4double c3 =
std::pow(((rIndexSquared-1.0)*(rIndexSquared+2.0)/3.0),2);
std::pow(((rIndexSquared - 1.0) * (rIndexSquared + 2.0) / 3.0), 2);
const G4double meanFreePath = 1.0 / (c1*c2*c3);
const G4double meanFreePath = 1.0 / (c1 * c2 * c3);
if( verboseLevel > 0) {
if(verboseLevel > 0)
{
G4cout << energy << "MeV\t" << meanFreePath << "mm" << G4endl;
}
+146 -95
View File
@@ -46,6 +46,7 @@
#include "G4SystemOfUnits.hh"
#include "G4OpProcessSubType.hh"
#include "G4Poisson.hh"
#include "G4OpticalParameters.hh"
#include "G4WLSTimeGeneratorProfileDelta.hh"
#include "G4WLSTimeGeneratorProfileExponential.hh"
@@ -53,19 +54,20 @@
G4OpWLS::G4OpWLS(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
{
WLSTimeGeneratorProfile = nullptr;
Initialise();
SetProcessSubType(fOpWLS);
theIntegralTable = nullptr;
WLSTimeGeneratorProfile =
new G4WLSTimeGeneratorProfileDelta("WLSTimeGeneratorProfileDelta");
if (verboseLevel>0) G4cout << GetProcessName() << " is created " << G4endl;
if(verboseLevel > 0)
G4cout << GetProcessName() << " is created " << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4OpWLS::~G4OpWLS()
{
if (theIntegralTable) {
if(theIntegralTable)
{
theIntegralTable->clearAndDestroy();
delete theIntegralTable;
}
@@ -73,168 +75,210 @@ G4OpWLS::~G4OpWLS()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4OpWLS::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4OpWLS::PreparePhysicsTable(const G4ParticleDefinition&) { Initialise(); }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS::Initialise()
{
G4OpticalParameters* params = G4OpticalParameters::Instance();
SetVerboseLevel(params->GetWLSVerboseLevel());
UseTimeProfile(params->GetWLSTimeProfile());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4OpWLS::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
std::vector<G4Track*> proposedSecondaries;
aParticleChange.Initialize(aTrack);
aParticleChange.ProposeTrackStatus(fStopAndKill);
if (verboseLevel>1) {
if(verboseLevel > 1)
{
G4cout << "\n** G4OpWLS: Photon absorbed! **" << G4endl;
}
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
if (!MPT) { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); }
if (!MPT->GetProperty(kWLSCOMPONENT)) { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); }
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
if(!MPT)
{
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if(!MPT->GetProperty(kWLSCOMPONENT))
{
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
G4int NumPhotons = 1;
if (MPT->ConstPropertyExists(kWLSMEANNUMBERPHOTONS)) {
G4double MeanNumberOfPhotons = MPT->GetConstProperty(kWLSMEANNUMBERPHOTONS);
NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
if (NumPhotons <= 0) {
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if(MPT->ConstPropertyExists(kWLSMEANNUMBERPHOTONS))
{
G4double MeanNumberOfPhotons = MPT->GetConstProperty(kWLSMEANNUMBERPHOTONS);
NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
if(NumPhotons <= 0)
{
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
}
// Retrieve the WLS Integral for this material
// new G4PhysicsOrderedFreeVector allocated to hold CII's
G4double primaryEnergy = aTrack.GetDynamicParticle()->GetKineticEnergy();
G4double WLSTime = 0.;
G4double WLSTime = 0.;
G4PhysicsOrderedFreeVector* WLSIntegral = nullptr;
WLSTime = MPT->GetConstProperty(kWLSTIMECONSTANT);
WLSIntegral =
(G4PhysicsOrderedFreeVector*)((*theIntegralTable)(aTrack.GetMaterial()->GetIndex()));
WLSTime = MPT->GetConstProperty(kWLSTIMECONSTANT);
WLSIntegral = (G4PhysicsOrderedFreeVector*) ((*theIntegralTable)(
aTrack.GetMaterial()->GetIndex()));
// Max WLS Integral
G4double CIImax = WLSIntegral->GetMaxValue();
G4double CIImax = WLSIntegral->GetMaxValue();
G4int NumberOfPhotons = NumPhotons;
for (G4int i=0; i<NumPhotons; ++i) {
for(G4int i = 0; i < NumPhotons; ++i)
{
G4double sampledEnergy;
// Make sure the energy of the secondary is less than that of the primary
for (G4int j=1; j<=100; ++j) {
for(G4int j = 1; j <= 100; ++j)
{
// Determine photon energy
G4double CIIvalue = G4UniformRand()*CIImax;
sampledEnergy = WLSIntegral->GetEnergy(CIIvalue);
if (sampledEnergy <= primaryEnergy) break;
G4double CIIvalue = G4UniformRand() * CIImax;
sampledEnergy = WLSIntegral->GetEnergy(CIIvalue);
if(sampledEnergy <= primaryEnergy)
break;
}
// If no such energy can be sampled, return one less secondary, or none
if (sampledEnergy > primaryEnergy) {
if (verboseLevel>1) {
G4cout << " *** G4OpWLS: One less WLS photon will be returned ***" << G4endl;
}
if(sampledEnergy > primaryEnergy)
{
if(verboseLevel > 1)
{
G4cout << " *** G4OpWLS: One less WLS photon will be returned ***"
<< G4endl;
}
NumberOfPhotons--;
if (NumberOfPhotons == 0) {
if (verboseLevel>1) {
G4cout << " *** G4OpWLS: No WLS photon can be sampled for this primary ***"
<< G4endl;
if(NumberOfPhotons == 0)
{
if(verboseLevel > 1)
{
G4cout
<< " *** G4OpWLS: No WLS photon can be sampled for this primary ***"
<< G4endl;
}
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
continue;
} else if (verboseLevel > 1) {
}
else if(verboseLevel > 1)
{
G4cout << "G4OpWLS: Created photon with energy: " << sampledEnergy
<< G4endl;
}
// Generate random photon direction
G4double cost = 1. - 2.*G4UniformRand();
G4double sint = std::sqrt((1.-cost)*(1.+cost));
G4double phi = twopi*G4UniformRand();
G4double cost = 1. - 2. * G4UniformRand();
G4double sint = std::sqrt((1. - cost) * (1. + cost));
G4double phi = twopi * G4UniformRand();
G4double sinp = std::sin(phi);
G4double cosp = std::cos(phi);
G4ParticleMomentum photonMomentum(sint*cosp, sint*sinp, cost);
G4ThreeVector photonPolarization(cost*cosp, cost*sinp, -sint);
G4ParticleMomentum photonMomentum(sint * cosp, sint * sinp, cost);
G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
G4ThreeVector perp = photonMomentum.cross(photonPolarization);
phi = twopi*G4UniformRand();
sinp = std::sin(phi);
cosp = std::cos(phi);
photonPolarization = (cosp*photonPolarization + sinp*perp).unit();
phi = twopi * G4UniformRand();
sinp = std::sin(phi);
cosp = std::cos(phi);
photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
// Generate a new photon:
G4DynamicParticle* sec_dp =
new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(), photonMomentum);
sec_dp->SetPolarization(photonPolarization);
sec_dp->SetKineticEnergy(sampledEnergy);
G4double secTime = pPostStepPoint->GetGlobalTime() +
G4double secTime = pPostStepPoint->GetGlobalTime() +
WLSTimeGeneratorProfile->GenerateTime(WLSTime);
G4ThreeVector secPos = pPostStepPoint->GetPosition();
G4Track* secTrack = new G4Track(sec_dp, secTime, secPos);
secTrack->SetTouchableHandle(aTrack.GetTouchableHandle());
G4Track* secTrack = new G4Track(sec_dp, secTime, secPos);
secTrack->SetTouchableHandle(aTrack.GetTouchableHandle());
secTrack->SetParentID(aTrack.GetTrackID());
proposedSecondaries.push_back(secTrack);
}
aParticleChange.SetNumberOfSecondaries(proposedSecondaries.size());
for (auto sec : proposedSecondaries) {
for(auto sec : proposedSecondaries)
{
aParticleChange.AddSecondary(sec);
}
if (verboseLevel>1) {
G4cout << "\n Exiting from G4OpWLS::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
if(verboseLevel > 1)
{
G4cout << "\n Exiting from G4OpWLS::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (theIntegralTable) {
if(theIntegralTable)
{
theIntegralTable->clearAndDestroy();
delete theIntegralTable;
theIntegralTable = nullptr;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
theIntegralTable = new G4PhysicsTable(numOfMaterials);
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
theIntegralTable = new G4PhysicsTable(numOfMaterials);
// loop for materials
for (G4int i=0; i<numOfMaterials; ++i) {
for(G4int i = 0; i < numOfMaterials; ++i)
{
G4PhysicsOrderedFreeVector* physVector = new G4PhysicsOrderedFreeVector();
// Retrieve vector of WLS wavelength intensity for
// the material from the material's optical properties table.
G4MaterialPropertiesTable* MPT = (*materialTable)[i]->GetMaterialPropertiesTable();
if (MPT) {
G4MaterialPropertiesTable* MPT =
(*materialTable)[i]->GetMaterialPropertiesTable();
if(MPT)
{
G4MaterialPropertyVector* wlsVector = MPT->GetProperty(kWLSCOMPONENT);
if (wlsVector) {
if(wlsVector)
{
// Retrieve the first intensity point in vector
// of (photon energy, intensity) pairs
G4double currentIN = (*wlsVector)[0];
if (currentIN >= 0.0) {
// Create first (photon energy)
G4double currentPM = wlsVector->Energy(0);
if(currentIN >= 0.0)
{
// Create first (photon energy)
G4double currentPM = wlsVector->Energy(0);
G4double currentCII = 0.0;
physVector->InsertValues(currentPM, currentCII);
// Set previous values to current ones prior to loop
G4double prevPM = currentPM;
G4double prevCII = currentCII;
G4double prevIN = currentIN;
// loop over all (photon energy, intensity)
// pairs stored for this material
for (size_t j=1; j<wlsVector->GetVectorLength(); ++j) {
for(size_t j = 1; j < wlsVector->GetVectorLength(); ++j)
{
currentPM = wlsVector->Energy(j);
currentIN = (*wlsVector)[j];
currentCII = prevCII + 0.5*(currentPM - prevPM)* (prevIN + currentIN);
currentCII =
prevCII + 0.5 * (currentPM - prevPM) * (prevIN + currentIN);
physVector->InsertValues(currentPM, currentCII);
prevPM = currentPM;
prevCII = currentCII;
prevIN = currentIN;
@@ -242,22 +286,24 @@ void G4OpWLS::BuildPhysicsTable(const G4ParticleDefinition&)
}
}
}
theIntegralTable->insertAt(i,physVector);
theIntegralTable->insertAt(i, physVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4OpWLS::GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4ForceCondition* )
G4double G4OpWLS::GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*)
{
G4double thePhotonEnergy = aTrack.GetDynamicParticle()->GetTotalEnergy();
G4double attLength = DBL_MAX;
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
G4double attLength = DBL_MAX;
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
if (MPT) {
if(MPT)
{
G4MaterialPropertyVector* attVector = MPT->GetProperty(kWLSABSLENGTH);
if (attVector) {
if(attVector)
{
attLength = attVector->Value(thePhotonEnergy, idx_wls);
}
}
@@ -267,18 +313,23 @@ G4double G4OpWLS::GetMeanFreePath(const G4Track& aTrack,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS::UseTimeProfile(const G4String name)
{
if (name.compare("delta") == 0) {
if(WLSTimeGeneratorProfile)
{
delete WLSTimeGeneratorProfile;
WLSTimeGeneratorProfile = nullptr;
}
if(name.compare("delta") == 0)
{
WLSTimeGeneratorProfile = new G4WLSTimeGeneratorProfileDelta("delta");
}
else if (name.compare("exponential") == 0) {
delete WLSTimeGeneratorProfile;
WLSTimeGeneratorProfile = new G4WLSTimeGeneratorProfileExponential("exponential");
else if(name.compare("exponential") == 0)
{
WLSTimeGeneratorProfile =
new G4WLSTimeGeneratorProfileExponential("exponential");
}
else
{
G4Exception("G4OpWLS::UseTimeProfile", "em0202",
FatalException,
G4Exception("G4OpWLS::UseTimeProfile", "em0202", FatalException,
"generator does not exist");
}
}
+149 -94
View File
@@ -46,6 +46,7 @@
#include "G4SystemOfUnits.hh"
#include "G4OpProcessSubType.hh"
#include "G4Poisson.hh"
#include "G4OpticalParameters.hh"
#include "G4WLSTimeGeneratorProfileDelta.hh"
#include "G4WLSTimeGeneratorProfileExponential.hh"
@@ -53,19 +54,20 @@
G4OpWLS2::G4OpWLS2(const G4String& processName, G4ProcessType type)
: G4VDiscreteProcess(processName, type)
{
WLSTimeGeneratorProfile = nullptr;
Initialise();
SetProcessSubType(fOpWLS);
theIntegralTable = nullptr;
WLSTimeGeneratorProfile =
new G4WLSTimeGeneratorProfileDelta("WLSTimeGeneratorProfileDelta");
if (verboseLevel>0) G4cout << GetProcessName() << " is created " << G4endl;
if(verboseLevel > 0)
G4cout << GetProcessName() << " is created " << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4OpWLS2::~G4OpWLS2()
{
if (theIntegralTable) {
if(theIntegralTable)
{
theIntegralTable->clearAndDestroy();
delete theIntegralTable;
}
@@ -73,65 +75,99 @@ G4OpWLS2::~G4OpWLS2()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4OpWLS2::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4OpWLS2::PreparePhysicsTable(const G4ParticleDefinition&)
{
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS2::Initialise()
{
G4OpticalParameters* params = G4OpticalParameters::Instance();
SetVerboseLevel(params->GetWLS2VerboseLevel());
UseTimeProfile(params->GetWLS2TimeProfile());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4OpWLS2::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
std::vector<G4Track*> proposedSecondaries;
aParticleChange.Initialize(aTrack);
aParticleChange.ProposeTrackStatus(fStopAndKill);
if (verboseLevel>1) {
if(verboseLevel > 1)
{
G4cout << "\n** G4OpWLS2: Photon absorbed! **" << G4endl;
}
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
if (!MPT) { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); }
if (!MPT->GetProperty(kWLSCOMPONENT2)) { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); }
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
if(!MPT)
{
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if(!MPT->GetProperty(kWLSCOMPONENT2))
{
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
G4int NumPhotons = 1;
if (MPT->ConstPropertyExists(kWLSMEANNUMBERPHOTONS2)) {
G4double MeanNumberOfPhotons = MPT->GetConstProperty(kWLSMEANNUMBERPHOTONS2);
NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
if (NumPhotons <= 0) {
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if(MPT->ConstPropertyExists(kWLSMEANNUMBERPHOTONS2))
{
G4double MeanNumberOfPhotons =
MPT->GetConstProperty(kWLSMEANNUMBERPHOTONS2);
NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
if(NumPhotons <= 0)
{
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
}
// Retrieve the WLS Integral for this material
// new G4PhysicsOrderedFreeVector allocated to hold CII's
G4double primaryEnergy = aTrack.GetDynamicParticle()->GetKineticEnergy();
G4double WLSTime = 0.;
G4double WLSTime = 0.;
G4PhysicsOrderedFreeVector* WLSIntegral = nullptr;
WLSTime = MPT->GetConstProperty(kWLSTIMECONSTANT2);
WLSIntegral =
(G4PhysicsOrderedFreeVector*)((*theIntegralTable)(aTrack.GetMaterial()->GetIndex()));
WLSTime = MPT->GetConstProperty(kWLSTIMECONSTANT2);
WLSIntegral = (G4PhysicsOrderedFreeVector*) ((*theIntegralTable)(
aTrack.GetMaterial()->GetIndex()));
// Max WLS Integral
G4double CIImax = WLSIntegral->GetMaxValue();
G4double CIImax = WLSIntegral->GetMaxValue();
G4int NumberOfPhotons = NumPhotons;
for (G4int i=0; i<NumPhotons; ++i) {
for(G4int i = 0; i < NumPhotons; ++i)
{
G4double sampledEnergy;
// Make sure the energy of the secondary is less than that of the primary
for (G4int j=1; j<=100; ++j) {
for(G4int j = 1; j <= 100; ++j)
{
// Determine photon energy
G4double CIIvalue = G4UniformRand()*CIImax;
sampledEnergy = WLSIntegral->GetEnergy(CIIvalue);
if (sampledEnergy <= primaryEnergy) break;
G4double CIIvalue = G4UniformRand() * CIImax;
sampledEnergy = WLSIntegral->GetEnergy(CIIvalue);
if(sampledEnergy <= primaryEnergy)
break;
}
// If no such energy can be sampled, return one less secondary, or none
if (sampledEnergy > primaryEnergy) {
if (verboseLevel>1) {
G4cout << " *** G4OpWLS2: One less WLS2 photon will be returned ***" << G4endl;
}
if(sampledEnergy > primaryEnergy)
{
if(verboseLevel > 1)
{
G4cout << " *** G4OpWLS2: One less WLS2 photon will be returned ***"
<< G4endl;
}
NumberOfPhotons--;
if (NumberOfPhotons == 0) {
if (verboseLevel>1) {
G4cout << " *** G4OpWLS2: No WLS2 photon can be sampled for this primary ***"
if(NumberOfPhotons == 0)
{
if(verboseLevel > 1)
{
G4cout << " *** G4OpWLS2: No WLS2 photon can be sampled for this "
"primary ***"
<< G4endl;
}
// return unchanged particle and no secondaries
@@ -139,102 +175,114 @@ G4OpWLS2::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
continue;
} else if (verboseLevel > 1) {
}
else if(verboseLevel > 1)
{
G4cout << "G4OpWLS2: Created photon with energy: " << sampledEnergy
<< G4endl;
}
// Generate random photon direction
G4double cost = 1. - 2.*G4UniformRand();
G4double sint = std::sqrt((1.-cost)*(1.+cost));
G4double phi = twopi*G4UniformRand();
G4double cost = 1. - 2. * G4UniformRand();
G4double sint = std::sqrt((1. - cost) * (1. + cost));
G4double phi = twopi * G4UniformRand();
G4double sinp = std::sin(phi);
G4double cosp = std::cos(phi);
G4ParticleMomentum photonMomentum(sint*cosp, sint*sinp, cost);
G4ThreeVector photonPolarization(cost*cosp, cost*sinp, -sint);
G4ParticleMomentum photonMomentum(sint * cosp, sint * sinp, cost);
G4ThreeVector photonPolarization(cost * cosp, cost * sinp, -sint);
G4ThreeVector perp = photonMomentum.cross(photonPolarization);
phi = twopi*G4UniformRand();
sinp = std::sin(phi);
cosp = std::cos(phi);
photonPolarization = (cosp*photonPolarization + sinp*perp).unit();
phi = twopi * G4UniformRand();
sinp = std::sin(phi);
cosp = std::cos(phi);
photonPolarization = (cosp * photonPolarization + sinp * perp).unit();
// Generate a new photon:
G4DynamicParticle* sec_dp =
new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(), photonMomentum);
sec_dp->SetPolarization(photonPolarization);
sec_dp->SetKineticEnergy(sampledEnergy);
G4double secTime = pPostStepPoint->GetGlobalTime() +
G4double secTime = pPostStepPoint->GetGlobalTime() +
WLSTimeGeneratorProfile->GenerateTime(WLSTime);
G4ThreeVector secPos = pPostStepPoint->GetPosition();
G4Track* secTrack = new G4Track(sec_dp, secTime, secPos);
secTrack->SetTouchableHandle(aTrack.GetTouchableHandle());
G4Track* secTrack = new G4Track(sec_dp, secTime, secPos);
secTrack->SetTouchableHandle(aTrack.GetTouchableHandle());
secTrack->SetParentID(aTrack.GetTrackID());
proposedSecondaries.push_back(secTrack);
}
aParticleChange.SetNumberOfSecondaries(proposedSecondaries.size());
for (auto sec : proposedSecondaries) {
for(auto sec : proposedSecondaries)
{
aParticleChange.AddSecondary(sec);
}
if (verboseLevel>1) {
G4cout << "\n Exiting from G4OpWLS2::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
if(verboseLevel > 1)
{
G4cout << "\n Exiting from G4OpWLS2::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS2::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (theIntegralTable) {
if(theIntegralTable)
{
theIntegralTable->clearAndDestroy();
delete theIntegralTable;
theIntegralTable = nullptr;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
theIntegralTable = new G4PhysicsTable(numOfMaterials);
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
theIntegralTable = new G4PhysicsTable(numOfMaterials);
// loop for materials
for (G4int i=0; i<numOfMaterials; ++i) {
for(G4int i = 0; i < numOfMaterials; ++i)
{
G4PhysicsOrderedFreeVector* physVector = new G4PhysicsOrderedFreeVector();
// Retrieve vector of WLS2 wavelength intensity for
// the material from the material's optical properties table.
G4MaterialPropertiesTable* MPT = (*materialTable)[i]->GetMaterialPropertiesTable();
if (MPT) {
G4MaterialPropertiesTable* MPT =
(*materialTable)[i]->GetMaterialPropertiesTable();
if(MPT)
{
G4MaterialPropertyVector* wlsVector = MPT->GetProperty(kWLSCOMPONENT2);
if (wlsVector) {
if(wlsVector)
{
// Retrieve the first intensity point in vector
// of (photon energy, intensity) pairs
G4double currentIN = (*wlsVector)[0];
if (currentIN >= 0.0) {
// Create first (photon energy)
G4double currentPM = wlsVector->Energy(0);
if(currentIN >= 0.0)
{
// Create first (photon energy)
G4double currentPM = wlsVector->Energy(0);
G4double currentCII = 0.0;
physVector->InsertValues(currentPM, currentCII);
// Set previous values to current ones prior to loop
G4double prevPM = currentPM;
G4double prevCII = currentCII;
G4double prevIN = currentIN;
// loop over all (photon energy, intensity)
// pairs stored for this material
for (size_t j=1; j<wlsVector->GetVectorLength(); ++j) {
for(size_t j = 1; j < wlsVector->GetVectorLength(); ++j)
{
currentPM = wlsVector->Energy(j);
currentIN = (*wlsVector)[j];
currentCII = prevCII + 0.5*(currentPM - prevPM)* (prevIN + currentIN);
currentCII =
prevCII + 0.5 * (currentPM - prevPM) * (prevIN + currentIN);
physVector->InsertValues(currentPM, currentCII);
prevPM = currentPM;
prevCII = currentCII;
prevIN = currentIN;
@@ -242,22 +290,24 @@ void G4OpWLS2::BuildPhysicsTable(const G4ParticleDefinition&)
}
}
}
theIntegralTable->insertAt(i,physVector);
theIntegralTable->insertAt(i, physVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4OpWLS2::GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4ForceCondition* )
G4double G4OpWLS2::GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*)
{
G4double thePhotonEnergy = aTrack.GetDynamicParticle()->GetTotalEnergy();
G4double attLength = DBL_MAX;
G4MaterialPropertiesTable* MPT = aTrack.GetMaterial()->GetMaterialPropertiesTable();
G4double attLength = DBL_MAX;
G4MaterialPropertiesTable* MPT =
aTrack.GetMaterial()->GetMaterialPropertiesTable();
if (MPT) {
if(MPT)
{
G4MaterialPropertyVector* attVector = MPT->GetProperty(kWLSABSLENGTH2);
if (attVector) {
if(attVector)
{
attLength = attVector->Value(thePhotonEnergy, idx_wls2);
}
}
@@ -267,18 +317,23 @@ G4double G4OpWLS2::GetMeanFreePath(const G4Track& aTrack,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4OpWLS2::UseTimeProfile(const G4String name)
{
if (name.compare("delta") == 0) {
if(WLSTimeGeneratorProfile)
{
delete WLSTimeGeneratorProfile;
WLSTimeGeneratorProfile = nullptr;
}
if(name.compare("delta") == 0)
{
WLSTimeGeneratorProfile = new G4WLSTimeGeneratorProfileDelta("delta");
}
else if (name.compare("exponential") == 0) {
delete WLSTimeGeneratorProfile;
WLSTimeGeneratorProfile = new G4WLSTimeGeneratorProfileExponential("exponential");
else if(name.compare("exponential") == 0)
{
WLSTimeGeneratorProfile =
new G4WLSTimeGeneratorProfileExponential("exponential");
}
else
{
G4Exception("G4OpWLS::UseTimeProfile", "em0202",
FatalException,
G4Exception("G4OpWLS::UseTimeProfile", "em0202", FatalException,
"generator does not exist");
}
}
@@ -31,33 +31,26 @@
//
// File name: G4VWLSTimeGeneratorProfile.cc
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
//
// Creation date: 2006-05-07
//
// Modifications:
// Modifications:
//
// Class Description:
// Class Description:
//
// Abstract base class
//
// Class Description: End
// Class Description: End
// -------------------------------------------------------------------
//
//
//
#include "G4VWLSTimeGeneratorProfile.hh"
//
G4VWLSTimeGeneratorProfile::G4VWLSTimeGeneratorProfile(const G4String& ) // name
{;}
//
G4VWLSTimeGeneratorProfile::~G4VWLSTimeGeneratorProfile()
{;}
G4VWLSTimeGeneratorProfile::G4VWLSTimeGeneratorProfile(const G4String&) {}
G4VWLSTimeGeneratorProfile::~G4VWLSTimeGeneratorProfile() {}
@@ -32,40 +32,43 @@
// File name: G4WLSTimeGeneratorProfileDelta.cc
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
// Creation date: 2006-05-07
//
// Modifications:
//
// Class Description:
// Class Description:
//
// Class Description: End
// Class Description: End
//
// -------------------------------------------------------------------
//
//
//
#include "G4WLSTimeGeneratorProfileDelta.hh"
#include "Randomize.hh"
//
//
G4WLSTimeGeneratorProfileDelta::G4WLSTimeGeneratorProfileDelta(const G4String& name):G4VWLSTimeGeneratorProfile(name)
{;}
//
G4WLSTimeGeneratorProfileDelta::~G4WLSTimeGeneratorProfileDelta()
{;}
G4WLSTimeGeneratorProfileDelta::G4WLSTimeGeneratorProfileDelta(
const G4String& name)
: G4VWLSTimeGeneratorProfile(name)
{}
//
G4double G4WLSTimeGeneratorProfileDelta::GenerateTime(const G4double time_constant)
G4WLSTimeGeneratorProfileDelta::~G4WLSTimeGeneratorProfileDelta() {}
//
G4double G4WLSTimeGeneratorProfileDelta::GenerateTime(
const G4double time_constant)
{
return time_constant;
}
G4double G4WLSTimeGeneratorProfileDelta::GenerateTime(const G4MaterialPropertiesTable*){
G4double G4WLSTimeGeneratorProfileDelta::GenerateTime(
const G4MaterialPropertiesTable*)
{
// This method is not currently in use
return 0;
return 0.;
}
@@ -32,39 +32,43 @@
// File name: G4WLSTimeGeneratorProfileExponential.cc
//
// Author: Pedro Rodrigues, Andreia Trindade
//
//
// Creation date: 2006-05-07
//
// Modifications:
//
// Class Description:
// Class Description:
//
// Class Description: End
// Class Description: End
//
// -------------------------------------------------------------------
//
//
//
#include "G4WLSTimeGeneratorProfileExponential.hh"
#include "Randomize.hh"
//
//
G4WLSTimeGeneratorProfileExponential::G4WLSTimeGeneratorProfileExponential(const G4String& name):G4VWLSTimeGeneratorProfile(name)
{;}
//
G4WLSTimeGeneratorProfileExponential::~G4WLSTimeGeneratorProfileExponential()
{;}
G4WLSTimeGeneratorProfileExponential::G4WLSTimeGeneratorProfileExponential(
const G4String& name)
: G4VWLSTimeGeneratorProfile(name)
{}
//
G4double G4WLSTimeGeneratorProfileExponential::GenerateTime(const G4double time_constant)
G4WLSTimeGeneratorProfileExponential::~G4WLSTimeGeneratorProfileExponential() {}
//
G4double G4WLSTimeGeneratorProfileExponential::GenerateTime(
const G4double time_constant)
{
return -std::log(G4UniformRand())*time_constant;
return -std::log(G4UniformRand()) * time_constant;
}
G4double G4WLSTimeGeneratorProfileExponential::GenerateTime(const G4MaterialPropertiesTable*){
G4double G4WLSTimeGeneratorProfileExponential::GenerateTime(
const G4MaterialPropertiesTable*)
{
// This method is not currently in use
return 0;
return 0.;
}