Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -164,15 +164,13 @@ void G4AdjointCSManager::RegisterEmProcess(G4VEmProcess* aProcess,
|
||||
if(anAdjPartDef && aProcess)
|
||||
{
|
||||
RegisterAdjointParticle(anAdjPartDef);
|
||||
G4int index = -1;
|
||||
|
||||
for(size_t i = 0; i < fAdjointParticlesInAction.size(); ++i)
|
||||
{
|
||||
if(anAdjPartDef->GetParticleName() ==
|
||||
fAdjointParticlesInAction[i]->GetParticleName())
|
||||
index = i;
|
||||
fForwardProcesses[i]->push_back(aProcess);
|
||||
}
|
||||
fForwardProcesses[index]->push_back(aProcess);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,14 +183,13 @@ void G4AdjointCSManager::RegisterEnergyLossProcess(
|
||||
if(anAdjPartDef && aProcess)
|
||||
{
|
||||
RegisterAdjointParticle(anAdjPartDef);
|
||||
G4int index = -1;
|
||||
for(size_t i = 0; i < fAdjointParticlesInAction.size(); ++i)
|
||||
{
|
||||
if(anAdjPartDef->GetParticleName() ==
|
||||
fAdjointParticlesInAction[i]->GetParticleName())
|
||||
index = i;
|
||||
fForwardLossProcesses[i]->push_back(aProcess);
|
||||
|
||||
}
|
||||
fForwardLossProcesses[index]->push_back(aProcess);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,9 +440,8 @@ G4double G4AdjointCSManager::GetTotalAdjointCS(
|
||||
{
|
||||
DefineCurrentMaterial(aCouple);
|
||||
DefineCurrentParticle(aPartDef);
|
||||
G4bool b;
|
||||
return (((*fTotalAdjSigmaTable[fCurrentParticleIndex])[fCurrentMatIndex])
|
||||
->GetValue(Ekin * fMassRatio, b));
|
||||
->Value(Ekin * fMassRatio));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -455,9 +451,8 @@ G4double G4AdjointCSManager::GetTotalForwardCS(
|
||||
{
|
||||
DefineCurrentMaterial(aCouple);
|
||||
DefineCurrentParticle(aPartDef);
|
||||
G4bool b;
|
||||
return (((*fTotalFwdSigmaTable[fCurrentParticleIndex])[fCurrentMatIndex])
|
||||
->GetValue(Ekin * fMassRatio, b));
|
||||
->Value(Ekin * fMassRatio));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -466,15 +461,13 @@ G4double G4AdjointCSManager::GetAdjointSigma(
|
||||
const G4MaterialCutsCouple* aCouple)
|
||||
{
|
||||
DefineCurrentMaterial(aCouple);
|
||||
G4bool b;
|
||||
if(is_scat_proj_to_proj)
|
||||
return (((*fSigmaTableForAdjointModelScatProjToProj[index_model])
|
||||
[fCurrentMatIndex])
|
||||
->GetValue(Ekin_nuc, b));
|
||||
[fCurrentMatIndex])->Value(Ekin_nuc));
|
||||
else
|
||||
return (
|
||||
((*fSigmaTableForAdjointModelProdToProj[index_model])[fCurrentMatIndex])
|
||||
->GetValue(Ekin_nuc, b));
|
||||
->Value(Ekin_nuc));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -500,9 +493,8 @@ void G4AdjointCSManager::GetMaxFwdTotalCS(G4ParticleDefinition* aPartDef,
|
||||
DefineCurrentMaterial(aCouple);
|
||||
DefineCurrentParticle(aPartDef);
|
||||
e_sigma_max = fEkinofFwdSigmaMax[fCurrentParticleIndex][fCurrentMatIndex];
|
||||
G4bool b;
|
||||
sigma_max = ((*fTotalFwdSigmaTable[fCurrentParticleIndex])[fCurrentMatIndex])
|
||||
->GetValue(e_sigma_max, b);
|
||||
->Value(e_sigma_max);
|
||||
e_sigma_max /= fMassRatio;
|
||||
}
|
||||
|
||||
@@ -515,9 +507,8 @@ void G4AdjointCSManager::GetMaxAdjTotalCS(G4ParticleDefinition* aPartDef,
|
||||
DefineCurrentMaterial(aCouple);
|
||||
DefineCurrentParticle(aPartDef);
|
||||
e_sigma_max = fEkinofAdjSigmaMax[fCurrentParticleIndex][fCurrentMatIndex];
|
||||
G4bool b;
|
||||
sigma_max = ((*fTotalAdjSigmaTable[fCurrentParticleIndex])[fCurrentMatIndex])
|
||||
->GetValue(e_sigma_max, b);
|
||||
->Value(e_sigma_max);
|
||||
e_sigma_max /= fMassRatio;
|
||||
}
|
||||
|
||||
@@ -1129,6 +1120,11 @@ G4double G4AdjointCSManager::ComputeAdjointCS(
|
||||
anAdjointCSMatrix->GetData(ind + 1, aLogPrimEnergy2, aLogCS2, log02,
|
||||
aLogSecondEnergyVector2, aLogProbVector2,
|
||||
aLogProbVectorIndex2);
|
||||
if (! (aLogProbVector1 && aLogProbVector2 &&
|
||||
aLogSecondEnergyVector1 && aLogSecondEnergyVector2)){
|
||||
return 0.;
|
||||
}
|
||||
|
||||
if(anAdjointCSMatrix->IsScatProjToProj())
|
||||
{ // case where the Tcut plays a role
|
||||
G4double log_minimum_prob1, log_minimum_prob2;
|
||||
|
||||
@@ -103,6 +103,7 @@ G4VParticleChange* G4AdjointForcedInteractionForGamma::PostStepDoIt(
|
||||
// Selection of the model to be called
|
||||
G4VEmAdjointModel* theSelectedModel = nullptr;
|
||||
G4bool is_scat_proj_to_proj_case = false;
|
||||
G4double factor=1.;
|
||||
if(!fAdjointComptonModel && !fAdjointBremModel)
|
||||
return fParticleChange;
|
||||
if(!fAdjointComptonModel)
|
||||
@@ -120,30 +121,32 @@ G4VParticleChange* G4AdjointForcedInteractionForGamma::PostStepDoIt(
|
||||
is_scat_proj_to_proj_case = true;
|
||||
}
|
||||
else
|
||||
{ // Choose the model according to cross sections
|
||||
{ // Choose the model according to a 50-50 % probability
|
||||
G4double bremAdjCS = fAdjointBremModel->AdjointCrossSection(
|
||||
track.GetMaterialCutsCouple(), track.GetKineticEnergy(), false);
|
||||
if(G4UniformRand() * fLastAdjCS < bremAdjCS)
|
||||
if(G4UniformRand() < 0.5)
|
||||
{
|
||||
theSelectedModel = fAdjointBremModel;
|
||||
is_scat_proj_to_proj_case = false;
|
||||
factor=bremAdjCS/fLastAdjCS/0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
theSelectedModel = fAdjointComptonModel;
|
||||
is_scat_proj_to_proj_case = true;
|
||||
factor=(fLastAdjCS-bremAdjCS)/fLastAdjCS/0.5;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the weight correction factor
|
||||
G4double invEffectiveAdjointCS =
|
||||
(1. - std::exp(fNbAdjIntLength - fTotNbAdjIntLength)) / fLastAdjCS;
|
||||
(1. - std::exp(fNbAdjIntLength - fTotNbAdjIntLength)) / fLastAdjCS/fCSBias;
|
||||
|
||||
// Call the selected model without correction of the weight in the model
|
||||
theSelectedModel->SetCorrectWeightForPostStepInModel(false);
|
||||
theSelectedModel
|
||||
->SetAdditionalWeightCorrectionFactorForPostStepOutsideModel(
|
||||
fLastAdjCS * invEffectiveAdjointCS);
|
||||
factor*fLastAdjCS * invEffectiveAdjointCS);
|
||||
theSelectedModel->SampleSecondaries(track, is_scat_proj_to_proj_case,
|
||||
fParticleChange);
|
||||
theSelectedModel->SetCorrectWeightForPostStepInModel(true);
|
||||
@@ -183,8 +186,8 @@ G4VParticleChange* G4AdjointForcedInteractionForGamma::AlongStepDoIt(
|
||||
else
|
||||
{
|
||||
G4double previous_acc_nb_adj_interaction_length = fNbAdjIntLength;
|
||||
fNbAdjIntLength += nb_adj_interaction_length_over_step;
|
||||
theNumberOfInteractionLengthLeft -= nb_adj_interaction_length_over_step;
|
||||
fNbAdjIntLength += fCSBias*nb_adj_interaction_length_over_step;
|
||||
theNumberOfInteractionLengthLeft -= fCSBias*nb_adj_interaction_length_over_step;
|
||||
|
||||
// protection against rare race condition
|
||||
if(std::abs(fTotNbAdjIntLength - previous_acc_nb_adj_interaction_length) <=
|
||||
@@ -253,6 +256,8 @@ G4AdjointForcedInteractionForGamma::PostStepGetPhysicalInteractionLength(
|
||||
{ // compute the interaction length for forced interaction
|
||||
if(step_id == 1)
|
||||
{
|
||||
fCSBias=0.000001/fTotNbAdjIntLength;
|
||||
fTotNbAdjIntLength*=fCSBias;
|
||||
G4double min_val = std::exp(-fTotNbAdjIntLength);
|
||||
theNumberOfInteractionLengthLeft =
|
||||
-std::log(min_val + G4UniformRand() * (1. - min_val));
|
||||
@@ -270,7 +275,7 @@ G4AdjointForcedInteractionForGamma::PostStepGetPhysicalInteractionLength(
|
||||
thePostPhysVolume->GetLogicalVolume()->GetMaterialCutsCouple());
|
||||
}
|
||||
if(postCS > 0.)
|
||||
return theNumberOfInteractionLengthLeft / postCS;
|
||||
return theNumberOfInteractionLengthLeft / postCS /fCSBias;
|
||||
else
|
||||
return DBL_MAX;
|
||||
}
|
||||
|
||||
@@ -226,6 +226,8 @@ void G4AdjointhIonisationModel::RapidSampleSecondaries(
|
||||
DiffCrossSectionPerAtomPrimToSecond(projectileKinEnergy, eEnergy, 1, 1);
|
||||
w_corr *= diffCS / diffCS_perAtom_Used;
|
||||
|
||||
if (isScatProjToProj && fTcutSecond>0.005) w_corr=1.;
|
||||
|
||||
G4double new_weight = aTrack.GetWeight() * w_corr;
|
||||
fParticleChange->SetParentWeightByProcess(false);
|
||||
fParticleChange->SetSecondaryWeightByProcess(false);
|
||||
@@ -290,7 +292,8 @@ G4double G4AdjointhIonisationModel::DiffCrossSectionPerAtomPrimToSecond(
|
||||
{
|
||||
G4double Tmax = kinEnergyProj;
|
||||
G4double E1 = kinEnergyProd;
|
||||
G4double E2 = kinEnergyProd * 1.000001;
|
||||
//1.0006 factor seems to give the best diff CS, important impact on proton correction factor
|
||||
G4double E2 = kinEnergyProd *1.0006;
|
||||
G4double sigma1, sigma2;
|
||||
if(kinEnergyProj > 2. * MeV)
|
||||
{
|
||||
|
||||
@@ -142,7 +142,7 @@ G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
|
||||
degain = E - Tkin;
|
||||
}
|
||||
G4double tmax = fCurrentModel->MaxSecondaryKinEnergy(dynParticle);
|
||||
tmax = std::min(tmax, fCurrentTcut);
|
||||
fCurrentTcut = std::min(fCurrentTcut, tmax);
|
||||
|
||||
dynParticle->SetKineticEnergy(Tkin + degain);
|
||||
|
||||
@@ -154,8 +154,8 @@ G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
|
||||
if(fLossFluctuationFlag)
|
||||
{
|
||||
deltaE = fCurrentModel->GetModelOfFluctuations()->SampleFluctuations(
|
||||
fCurrentCouple, dynParticle, tmax, dlength, degain) -
|
||||
degain;
|
||||
fCurrentCouple, dynParticle, fCurrentTcut, tmax, dlength, degain)
|
||||
- degain;
|
||||
}
|
||||
|
||||
G4double egain = degain + deltaE;
|
||||
|
||||
@@ -240,6 +240,10 @@ G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerAtomForSecond(
|
||||
res_mat.push_back(log_ESec_vector);
|
||||
res_mat.push_back(log_Prob_vector);
|
||||
}
|
||||
else {
|
||||
delete log_ESec_vector;
|
||||
delete log_Prob_vector;
|
||||
}
|
||||
return res_mat;
|
||||
}
|
||||
|
||||
@@ -289,6 +293,10 @@ G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerAtomForScatProj(
|
||||
res_mat.push_back(log_ESec_vector);
|
||||
res_mat.push_back(log_Prob_vector);
|
||||
}
|
||||
else {
|
||||
delete log_ESec_vector;
|
||||
delete log_Prob_vector;
|
||||
}
|
||||
|
||||
return res_mat;
|
||||
}
|
||||
@@ -340,6 +348,10 @@ G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerVolumeForSecond(
|
||||
res_mat.push_back(log_ESec_vector);
|
||||
res_mat.push_back(log_Prob_vector);
|
||||
}
|
||||
else {
|
||||
delete log_ESec_vector;
|
||||
delete log_Prob_vector;
|
||||
}
|
||||
return res_mat;
|
||||
}
|
||||
|
||||
@@ -389,6 +401,10 @@ G4VEmAdjointModel::ComputeAdjointCrossSectionVectorPerVolumeForScatProj(
|
||||
res_mat.push_back(log_ESec_vector);
|
||||
res_mat.push_back(log_Prob_vector);
|
||||
}
|
||||
else {
|
||||
delete log_ESec_vector;
|
||||
delete log_Prob_vector;
|
||||
}
|
||||
|
||||
return res_mat;
|
||||
}
|
||||
@@ -427,11 +443,16 @@ G4double G4VEmAdjointModel::SampleAdjSecEnergyFromCSMatrix(
|
||||
|
||||
theMatrix->GetData(ind, aLogPrimEnergy1, aLogCS1, log01,
|
||||
aLogSecondEnergyVector1, aLogProbVector1,
|
||||
aLogProbVectorIndex1);
|
||||
aLogProbVectorIndex1 );
|
||||
theMatrix->GetData(ind + 1, aLogPrimEnergy2, aLogCS2, log02,
|
||||
aLogSecondEnergyVector2, aLogProbVector2,
|
||||
aLogProbVectorIndex2);
|
||||
|
||||
if (! (aLogProbVector1 && aLogProbVector2 &&
|
||||
aLogSecondEnergyVector1 && aLogSecondEnergyVector2)){
|
||||
return 0.;
|
||||
}
|
||||
|
||||
G4double rand_var = G4UniformRand();
|
||||
G4double log_rand_var = std::log(rand_var);
|
||||
G4double log_Tcut = std::log(fTcutSecond);
|
||||
|
||||
Reference in New Issue
Block a user