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
+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");
}
}