Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AngleDirect.cc 73844 2013-09-13 14:16:30Z vnivanch $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DummyModel.cc 97432 2016-06-03 07:23:39Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ElectronIonPair.cc 92921 2015-09-21 15:06:51Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmBiasingManager.cc 98860 2016-08-15 09:59:59Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -48,6 +47,7 @@
#include "G4EmBiasingManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4ProductionCutsTable.hh"
#include "G4ProductionCuts.hh"
@@ -55,10 +55,12 @@
#include "G4RegionStore.hh"
#include "G4Track.hh"
#include "G4Electron.hh"
#include "G4Gamma.hh"
#include "G4VEmModel.hh"
#include "G4LossTableManager.hh"
#include "G4ParticleChangeForLoss.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -68,6 +70,13 @@ G4EmBiasingManager::G4EmBiasingManager()
{
fSafetyMin = 1.e-6*mm;
theElectron = G4Electron::Electron();
theGamma = G4Gamma::Gamma();
fDirectionalSplitting = false;
fDirectionalSplittingRadius = 0.;
fDirectionalSplittingTarget = G4ThreeVector(0.,0.,0.);
fDirectionalSplittingWeights.clear();
fWeight = 1.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -116,6 +125,14 @@ void G4EmBiasingManager::Initialise(const G4ParticleDefinition& part,
}
}
}
G4EmParameters* param = G4EmParameters::Instance();
SetDirectionalSplitting(param->GetDirectionalSplitting());
if (fDirectionalSplitting) {
SetDirectionalSplittingTarget(param->GetDirectionalSplittingTarget());
SetDirectionalSplittingRadius(param->GetDirectionalSplittingRadius());
}
if (nForcedRegions > 0 && 0 < verbose) {
G4cout << " Forced Interaction is activated for "
<< part.GetParticleName() << " and "
@@ -138,6 +155,13 @@ void G4EmBiasingManager::Initialise(const G4ParticleDefinition& part,
<< " BiasingWeight= " << secBiasedWeight[i] << G4endl;
}
}
if (fDirectionalSplitting) {
G4cout << " Directional splitting activated, with target position: "
<< fDirectionalSplittingTarget/cm
<< " cm; radius: "
<< fDirectionalSplittingRadius/cm
<< "cm." << G4endl;
}
}
}
@@ -280,14 +304,15 @@ G4EmBiasingManager::ApplySecondaryBiasing(
G4double safety)
{
G4int index = idxSecBiasedCouple[coupleIdx];
G4double weight = 1.0;
fWeight = 1.0;
if(0 <= index) {
size_t n = vd.size();
// the check cannot be applied per secondary particle
// because weight correction is common, so the first
// secondary is checked
if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
if((0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index])
|| fDirectionalSplitting) {
G4int nsplit = nBremSplitting[index];
@@ -297,21 +322,26 @@ G4EmBiasingManager::ApplySecondaryBiasing(
// Russian Roulette
} else if(1 == nsplit) {
weight = ApplyRussianRoulette(vd, index);
fWeight = ApplyRussianRoulette(vd, index);
// Splitting
} else {
G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
if (fDirectionalSplitting) {
ApplyDirectionalSplitting(vd, track, currentModel, index, tcut);
fWeight = 1.;
} else {
G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
weight = ApplySplitting(vd, track, currentModel, index, tcut);
fWeight = ApplySplitting(vd, track, currentModel, index, tcut);
pPartChange->SetProposedKineticEnergy(tmpEnergy);
pPartChange->ProposeMomentumDirection(tmpMomDir);
pPartChange->SetProposedKineticEnergy(tmpEnergy);
pPartChange->ProposeMomentumDirection(tmpMomDir);
}
}
}
}
return weight;
return fWeight;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -328,14 +358,15 @@ G4EmBiasingManager::ApplySecondaryBiasing(
G4double safety)
{
G4int index = idxSecBiasedCouple[coupleIdx];
G4double weight = 1.0;
fWeight = 1.0;
if(0 <= index) {
size_t n = vd.size();
// the check cannot be applied per secondary particle
// because weight correction is common, so the first
// secondary is checked
if(0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index]) {
if((0 < n && vd[0]->GetKineticEnergy() < secBiasedEnegryLimit[index])
|| fDirectionalSplitting) {
G4int nsplit = nBremSplitting[index];
@@ -345,21 +376,27 @@ G4EmBiasingManager::ApplySecondaryBiasing(
// Russian Roulette
} else if(1 == nsplit) {
weight = ApplyRussianRoulette(vd, index);
fWeight = ApplyRussianRoulette(vd, index);
// Splitting
} else {
G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
if (fDirectionalSplitting) {
ApplyDirectionalSplitting(vd, track, currentModel,
index, tcut, pPartChange);
fWeight = 1.;
} else {
G4double tmpEnergy = pPartChange->GetProposedKineticEnergy();
G4ThreeVector tmpMomDir = pPartChange->GetProposedMomentumDirection();
weight = ApplySplitting(vd, track, currentModel, index, tcut);
fWeight = ApplySplitting(vd, track, currentModel, index, tcut);
pPartChange->SetProposedKineticEnergy(tmpEnergy);
pPartChange->ProposeMomentumDirection(tmpMomDir);
pPartChange->SetProposedKineticEnergy(tmpEnergy);
pPartChange->ProposeMomentumDirection(tmpMomDir);
}
}
}
}
return weight;
return fWeight;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -369,7 +406,7 @@ G4EmBiasingManager::ApplySecondaryBiasing(std::vector<G4Track*>& track,
G4int coupleIdx)
{
G4int index = idxSecBiasedCouple[coupleIdx];
G4double weight = 1.0;
fWeight = 1.0;
if(0 <= index) {
size_t n = track.size();
@@ -382,9 +419,9 @@ G4EmBiasingManager::ApplySecondaryBiasing(std::vector<G4Track*>& track,
// Russian Roulette only
if(1 == nsplit) {
weight = secBiasedWeight[index];
fWeight = secBiasedWeight[index];
for(size_t k=0; k<n; ++k) {
if(G4UniformRand()*weight > 1.0) {
if(G4UniformRand()*fWeight > 1.0) {
const G4Track* t = track[k];
delete t;
track[k] = 0;
@@ -393,7 +430,7 @@ G4EmBiasingManager::ApplySecondaryBiasing(std::vector<G4Track*>& track,
}
}
}
return weight;
return fWeight;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -426,6 +463,20 @@ G4EmBiasingManager::ApplyRangeCut(std::vector<G4DynamicParticle*>& vd,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4EmBiasingManager::CheckDirection(G4ThreeVector pos,
G4ThreeVector momdir) const
{
G4ThreeVector delta = fDirectionalSplittingTarget - pos;
G4double angle = momdir.angle(delta);
G4double dist = delta.cross(momdir).mag();
if (dist <= fDirectionalSplittingRadius && angle < halfpi) {
return true;
}
return false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double
G4EmBiasingManager::ApplySplitting(std::vector<G4DynamicParticle*>& vd,
const G4Track& track,
@@ -434,28 +485,28 @@ G4EmBiasingManager::ApplySplitting(std::vector<G4DynamicParticle*>& vd,
G4double tcut)
{
// method is applied only if 1 secondary created PostStep
// in the case of many secodndaries there is a contrudition
G4double weight = 1.0;
// in the case of many secondaries there is a contradiction
fWeight = 1.0;
size_t n = vd.size();
G4double w = secBiasedWeight[index];
if(1 != n || 1.0 <= w) { return weight; }
if(1 != n || 1.0 <= w) { return fWeight; }
G4double trackWeight = track.GetWeight();
const G4DynamicParticle* dynParticle = track.GetDynamicParticle();
G4int nsplit = nBremSplitting[index];
// double splitting is supressed
// double splitting is suppressed
if(1 < nsplit && trackWeight>w) {
weight = w;
// start from 1, because already one secondary created
fWeight = w;
if(nsplit > (G4int)tmpSecondaries.size()) {
tmpSecondaries.reserve(nsplit);
}
const G4MaterialCutsCouple* couple = track.GetMaterialCutsCouple();
for(G4int k=1; k<nsplit; ++k) {
// start from 1, because already one secondary created
for(G4int k=1; k<nsplit; ++k) {
tmpSecondaries.clear();
currentModel->SampleSecondaries(&tmpSecondaries, couple, dynParticle,
tcut);
@@ -464,7 +515,183 @@ G4EmBiasingManager::ApplySplitting(std::vector<G4DynamicParticle*>& vd,
}
}
}
return weight;
return fWeight;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void
G4EmBiasingManager::ApplyDirectionalSplitting(
std::vector<G4DynamicParticle*>& vd,
const G4Track& track,
G4VEmModel* currentModel,
G4int index,
G4double tcut,
G4ParticleChangeForGamma* partChange)
{
// primary is gamma. do splitting/RR as appropriate
// method applied for any number of secondaries
G4double weight = 1.0;
G4double w = secBiasedWeight[index];
fDirectionalSplittingWeights.clear();
if(1.0 <= w) {
fDirectionalSplittingWeights.push_back(fWeight);
return;
}
G4double trackWeight = track.GetWeight();
G4int nsplit = nBremSplitting[index];
// double splitting is suppressed
if(1 < nsplit && trackWeight>w) {
weight = w;
const G4ThreeVector pos = track.GetPosition();
G4bool foundPrimaryParticle = false;
G4double primaryEnergy = 0.;
G4ThreeVector primaryMomdir(0.,0.,0.);
G4double primaryWeight = trackWeight;
tmpSecondaries = vd;
vd.clear();
vd.reserve(nsplit);
for (G4int k=0; k<nsplit; ++k) {
if (k>0) { // for k==0, SampleSecondaries has already been called
tmpSecondaries.clear();
// SampleSecondaries modifies primary info stored in partChange
currentModel->SampleSecondaries(&tmpSecondaries,
track.GetMaterialCutsCouple(),
track.GetDynamicParticle(), tcut);
}
for (auto sec : tmpSecondaries) {
if (sec->GetParticleDefinition() == theGamma) {
if (CheckDirection(pos, sec->GetMomentumDirection())) {
vd.push_back(sec);
fDirectionalSplittingWeights.push_back(weight);
} else if (G4UniformRand() < w) {
vd.push_back(sec);
fDirectionalSplittingWeights.push_back(1.0);
}
} else if (k==0) { // not gamma
vd.push_back(sec);
fDirectionalSplittingWeights.push_back(1.);
}
}
// primary
G4double en = partChange->GetProposedKineticEnergy();
if (en>0.) { // don't add if kinetic energy = 0
G4ThreeVector momdir = partChange->GetProposedMomentumDirection();
if (CheckDirection(pos,momdir)) {
// keep only one primary; others are secondaries
if (!foundPrimaryParticle) {
primaryEnergy = en;
primaryMomdir = momdir;
foundPrimaryParticle = true;
primaryWeight = weight;
} else {
G4DynamicParticle* dp = new G4DynamicParticle(theGamma,
partChange->GetProposedMomentumDirection(),
partChange->GetProposedKineticEnergy());
vd.push_back(dp);
fDirectionalSplittingWeights.push_back(weight);
}
} else if (G4UniformRand()<w) { // not going to target. play RR.
if (!foundPrimaryParticle) {
foundPrimaryParticle = true;
primaryEnergy = en;
primaryMomdir = momdir;
primaryWeight = 1.;
} else {
G4DynamicParticle* dp = new G4DynamicParticle(theGamma,
partChange->GetProposedMomentumDirection(),
partChange->GetProposedKineticEnergy());
vd.push_back(dp);
fDirectionalSplittingWeights.push_back(1.0);
}
}
}
} // end of loop over nsplit
partChange->ProposeWeight(primaryWeight);
partChange->SetProposedKineticEnergy(primaryEnergy);
partChange->ProposeMomentumDirection(primaryMomdir);
} else {
for (size_t i = 0; i < vd.size(); ++i) {
fDirectionalSplittingWeights.push_back(trackWeight);
}
}
return;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4EmBiasingManager::GetWeight(G4int i)
{
if (fDirectionalSplittingWeights.size() >= (unsigned int)(i+1) ) {
return fDirectionalSplittingWeights[i];
}
else {
return fWeight;
}
}
void
G4EmBiasingManager::ApplyDirectionalSplitting(
std::vector<G4DynamicParticle*>& vd,
const G4Track& track,
G4VEmModel* currentModel,
G4int index,
G4double tcut)
{
// Do nothing with primary
G4double weight = 1.0;
G4double w = secBiasedWeight[index];
fDirectionalSplittingWeights.clear();
if(1.0 <= w) {
fDirectionalSplittingWeights.push_back(weight);
return;
}
G4double trackWeight = track.GetWeight();
G4int nsplit = nBremSplitting[index];
// double splitting is suppressed
if(1 < nsplit && trackWeight>w) {
weight = w;
const G4ThreeVector pos = track.GetPosition();
tmpSecondaries = vd;
vd.clear();
vd.reserve(nsplit);
for (G4int k=0; k<nsplit; ++k) {
if (k>0) {
tmpSecondaries.clear();
currentModel->SampleSecondaries(&tmpSecondaries,
track.GetMaterialCutsCouple(),
track.GetDynamicParticle(), tcut);
}
for (auto sec : tmpSecondaries) {
if (CheckDirection(pos, sec->GetMomentumDirection())) {
vd.push_back(sec);
fDirectionalSplittingWeights.push_back(weight);
} else if (G4UniformRand()<w) {
vd.push_back(sec);
fDirectionalSplittingWeights.push_back(1.0);
}
}
} // end of loop over nsplit
} else { // no splitting was done; still need weights
for (size_t i = 0; i < vd.size(); ++i) {
fDirectionalSplittingWeights.push_back(trackWeight);
}
}
return;
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmCalculator.cc 108306 2018-02-02 13:10:06Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -36,28 +35,8 @@
//
// Creation date: 28.06.2004
//
// Modifications:
// 12.09.2004 Add verbosity (V.Ivanchenko)
// 17.11.2004 Change signature of methods, add new methods (V.Ivanchenko)
// 08.04.2005 Major optimisation of internal interfaces (V.Ivantchenko)
// 08.05.2005 Use updated interfaces (V.Ivantchenko)
// 23.10.2005 Fix computations for ions (V.Ivantchenko)
// 11.01.2006 Add GetCSDARange (V.Ivantchenko)
// 26.01.2006 Rename GetRange -> GetRangeFromRestricteDEDX (V.Ivanchenko)
// 14.03.2006 correction in GetCrossSectionPerVolume (mma)
// suppress GetCrossSectionPerAtom
// elm->GetA() in ComputeCrossSectionPerAtom
// 22.03.2006 Add ComputeElectronicDEDX and ComputeTotalDEDX (V.Ivanchenko)
// 13.05.2006 Add Corrections for ion stopping (V.Ivanchenko)
// 29.09.2006 Uncomment computation of smoothing factor (V.Ivanchenko)
// 27.10.2006 Change test energy to access lowEnergy model from
// 10 keV to 1 keV (V. Ivanchenko)
// 15.03.2007 Add ComputeEnergyCutFromRangeCut methods (V.Ivanchenko)
// 21.04.2008 Updated computations for ions (V.Ivanchenko)
// 02.02.2018 Fix the MCS (i.e. transport mean free path) case in
// GetCrossSectionPerVolume (M. Novak)
//
// Class Description:
// Class Description: V.Ivanchenko & M.Novak
//
// -------------------------------------------------------------------
//
@@ -289,7 +268,7 @@ G4double G4EmCalculator::GetCrossSectionPerVolume(G4double kinEnergy,
G4VEmProcess* emproc = FindDiscreteProcess(p, processName);
if(emproc) {
res = emproc->CrossSectionPerVolume(kinEnergy, couple);
res = emproc->CrossSectionPerVolume(kinEnergy, couple);
} else if(currentLambda) {
// special tables are built for Msc models (procType is set in FindLambdaTable
if(procType==2) {
@@ -408,7 +387,8 @@ G4double G4EmCalculator::ComputeDEDX(G4double kinEnergy,
if(FindEmModel(p, processName, kinEnergy)) {
// Special case of ICRU'73 model
if(currentModel->GetName() == "ParamICRU73") {
const G4String& mname = currentModel->GetName();
if(mname == "ParamICRU73" || mname == "LinhardSorensen" || mname == "Atima") {
res = currentModel->ComputeDEDXPerVolume(mat, p, kinEnergy, cut);
if(verbose > 1) {
G4cout << " ICRU73 ion E(MeV)= " << kinEnergy << " ";
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmConfigurator.cc 106507 2017-10-12 08:24:49Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmCorrections.cc 110572 2018-05-30 13:08:12Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmDataHandler.cc 73844 2013-09-13 14:16:30Z vnivanch $
//
// -------------------------------------------------------------------
//
@@ -45,25 +44,22 @@
#include "G4ParticleDefinition.hh"
#include "G4EmParameters.hh"
#include "G4PhysicsTableHelper.hh"
#include "G4VEmProcess.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4EmDataHandler::G4EmDataHandler(size_t n) : tLength(0)
G4EmDataHandler::G4EmDataHandler(size_t n) : tLength(n)
{
data.reserve(n);
data.resize(n, nullptr);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4EmDataHandler::~G4EmDataHandler()
{
for(auto & table : data) {
if(table) {
table->clearAndDestroy();
delete table;
}
}
data.clear();
//std::cout << "G4EmDataHandler::~G4EmDataHandler "
// << tLength << " " << this << std::endl;
for(size_t i=0; i<tLength; ++i) { CleanTable(i); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -77,37 +73,53 @@ size_t G4EmDataHandler::SetTable(G4PhysicsTable* ptr)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4PhysicsTable* G4EmDataHandler::MakeTable()
G4PhysicsTable* G4EmDataHandler::MakeTable(size_t i)
{
G4PhysicsTable* table = nullptr;
table = G4PhysicsTableHelper::PreparePhysicsTable(table);
data.push_back(table);
++tLength;
// create new table only if index corresponds to the
// position in the vector
if(i <= tLength) {
if(i < tLength) { table = data[i]; }
table = G4PhysicsTableHelper::PreparePhysicsTable(table);
if(i == tLength) {
data.push_back(table);
++tLength;
} else { data[i] = table; }
}
return table;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4EmDataHandler::CleanTable(size_t i)
{
//std::cout << i << " " << data[i] << std::endl;
if(i < tLength && data[i]) {
data[i]->clearAndDestroy();
delete data[i];
data[i] = nullptr;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4EmDataHandler::StorePhysicsTable(size_t idx,
const G4ParticleDefinition* part,
const G4String& namet,
const G4String& procname,
const G4String& fname,
G4bool ascii)
{
G4bool yes = true;
if(data[idx]) {
yes = data[idx]->StorePhysicsTable(namet, ascii);
yes = data[idx]->StorePhysicsTable(fname, ascii);
if ( yes ) {
G4cout << "Physics table is stored for "
<< part->GetParticleName()
<< " and process " << procname
<< " <" << namet << "> " << G4endl;
<< " <" << fname << "> " << G4endl;
} else {
G4cout << "Fail to store Physics Table for "
<< part->GetParticleName()
<< " and process " << procname
<< " <" << namet << "> " << G4endl;
<< " <" << fname << "> " << G4endl;
}
}
return yes;
@@ -117,20 +129,17 @@ G4bool G4EmDataHandler::StorePhysicsTable(size_t idx,
G4bool G4EmDataHandler::RetrievePhysicsTable(size_t idx,
const G4ParticleDefinition* part,
const G4String& namet,
const G4String& procname,
const G4String& fname,
G4bool ascii)
{
G4bool yes =
G4PhysicsTableHelper::RetrievePhysicsTable(data[idx],
namet, ascii);
G4PhysicsTableHelper::RetrievePhysicsTable(data[idx], fname, ascii);
G4EmParameters* param = G4EmParameters::Instance();
if ( yes ) {
if (0 < param->Verbose()) {
G4cout << "Physics table for "
G4cout << "Physics table " << idx << " for "
<< part->GetParticleName()
<< " and " << procname
<< " is retrieved from <" << namet << ">"
<< " is retrieved from <" << fname << ">"
<< G4endl;
}
if(param->Spline()) {
@@ -141,12 +150,27 @@ G4bool G4EmDataHandler::RetrievePhysicsTable(size_t idx,
}
}
} else if (1 < param->Verbose()) {
G4cout << "Fail to retrieve physics table for "
<< part->GetParticleName()
<< " and " << procname << " from <"
<< namet << ">" << G4endl;
G4cout << "Fail to retrieve physics table " << idx << " for "
<< part->GetParticleName() << " from <"
<< fname << ">" << G4endl;
}
return yes;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4EmDataHandler::SetMasterProcess(const G4VEmProcess* ptr)
{
masterProcess.push_back(ptr);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VEmProcess* G4EmDataHandler::GetMasterProcess(size_t idx) const
{
const G4VEmProcess* ptr =
(idx < masterProcess.size()) ? masterProcess[idx] : nullptr;
return ptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmElementSelector.cc 92921 2015-09-21 15:06:51Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmModelManager.cc 106714 2017-10-20 09:38:06Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -799,14 +798,6 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::DumpModelList(std::ostream& out, G4int verb)
{
DumpModelList(out, verb, G4String("\n"));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::DumpModelList(std::ostream& out, G4int verb,
G4String endOfLine)
{
if(verb == 0) { return; }
for(G4int i=0; i<nRegions; ++i) {
@@ -815,7 +806,7 @@ void G4EmModelManager::DumpModelList(std::ostream& out, G4int verb,
G4int n = r->NumberOfModels();
if(n > 0) {
out << " ===== EM models for the G4Region " << reg->GetName()
<< " ======" << endOfLine;
<< " ======" << G4endl;
for(G4int j=0; j<n; ++j) {
G4VEmModel* model = models[r->ModelIndex(j)];
G4double emin =
@@ -848,15 +839,14 @@ void G4EmModelManager::DumpModelList(std::ostream& out, G4int verb,
if(fluoFlag && model->DeexcitationFlag()) {
out << " FluoActive";
}
out << endOfLine;
out << G4endl;
}
}
}
if(1 == nEmModels) { break; }
}
if(theCutsNew) {
out << " ===== Limit on energy threshold has been applied "
<< endOfLine;
out << " ===== Limit on energy threshold has been applied " << G4endl;
}
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmMultiModel.cc 92921 2015-09-21 15:06:51Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmParameters.cc 69320 2013-04-30 15:59:36Z vnivanch $
//
// -------------------------------------------------------------------
//
@@ -131,11 +130,13 @@ void G4EmParameters::Initialise()
useMottCorrection = false;
integral = true;
birks = false;
fICRU90 = false;
dnaFast = false;
dnaStationary = false;
dnaMsc = false;
gammaShark = false;
gener = false;
onIsolated = false;
enableSamplingTable = false;
minSubRange = 1.0;
minKinEnergy = 0.1*CLHEP::keV;
@@ -173,6 +174,10 @@ void G4EmParameters::Initialise()
namePIXE = "Empirical";
nameElectronPIXE = "Livermore";
directionalSplitting = false;
directionalSplittingTarget = G4ThreeVector(0.,0.,0.);
directionalSplittingRadius = 0.;
}
void G4EmParameters::SetLossFluctuations(G4bool val)
@@ -406,6 +411,16 @@ G4bool G4EmParameters::BirksActive() const
return birks;
}
void G4EmParameters::SetUseICRU90Data(G4bool val)
{
fICRU90 = val;
}
G4bool G4EmParameters::UseICRU90Data() const
{
return fICRU90;
}
void G4EmParameters::SetDNAFast(G4bool val)
{
if(IsLocked()) { return; }
@@ -439,15 +454,25 @@ G4bool G4EmParameters::DNAElectronMsc() const
return dnaMsc;
}
void G4EmParameters::SetGammaSharkActive(G4bool val)
void G4EmParameters::SetGeneralProcessActive(G4bool val)
{
if(IsLocked()) { return; }
gammaShark = val;
gener = val;
// if general interaction is enabled then sub-cutoff and
// force interaction options should be disabled
if(gener) {
m_regnamesForced.clear();
m_procForced.clear();
m_lengthForced.clear();
m_weightForced.clear();
m_regnamesSubCut.clear();
m_subCuts.clear();
}
}
G4bool G4EmParameters::GammaSharkActive() const
G4bool G4EmParameters::GeneralProcessActive() const
{
return gammaShark;
return gener;
}
void G4EmParameters::SetEmSaturation(G4EmSaturation* ptr)
@@ -470,6 +495,17 @@ G4bool G4EmParameters::OnIsolated() const
return onIsolated;
}
void G4EmParameters::SetEnableSamplingTable(G4bool val)
{
if(IsLocked()) { return; }
enableSamplingTable = val;
}
G4bool G4EmParameters::EnableSamplingTable() const
{
return enableSamplingTable;
}
G4EmSaturation* G4EmParameters::GetEmSaturation()
{
if(!emSaturation) { SetBirksActive(true); }
@@ -1063,39 +1099,39 @@ void G4EmParameters::AddMsc(const G4String& region, const G4String& type)
const std::vector<G4String>& G4EmParameters::RegionsMsc() const
{
return m_regnamesMsc;
return m_regnamesPhys;
}
const std::vector<G4String>& G4EmParameters::TypesMsc() const
{
return m_typesMsc;
return m_typesPhys;
}
void G4EmParameters::AddPhysics(const G4String& region, const G4String& type)
{
if(IsLocked()) { return; }
G4String r = CheckRegion(region);
G4int nreg = m_regnamesMsc.size();
G4int nreg = m_regnamesPhys.size();
for(G4int i=0; i<nreg; ++i) {
if(r == m_regnamesMsc[i]) { return; }
if(r == m_regnamesPhys[i]) { return; }
}
m_regnamesMsc.push_back(r);
m_typesMsc.push_back(type);
m_regnamesPhys.push_back(r);
m_typesPhys.push_back(type);
}
const std::vector<G4String>& G4EmParameters::RegionsPhysics() const
{
return m_regnamesMsc;
return m_regnamesPhys;
}
const std::vector<G4String>& G4EmParameters::TypesPhysics() const
{
return m_typesMsc;
return m_typesPhys;
}
void G4EmParameters::SetSubCutoff(G4bool val, const G4String& region)
{
if(IsLocked()) { return; }
if(IsLocked() && !gener) { return; }
G4String r = CheckRegion(region);
G4int nreg = m_regnamesSubCut.size();
for(G4int i=0; i<nreg; ++i) {
@@ -1168,7 +1204,7 @@ G4EmParameters::ActivateForcedInteraction(const G4String& procname,
G4double length,
G4bool wflag)
{
if(IsLocked()) { return; }
if(IsLocked() && !gener) { return; }
G4String r = CheckRegion(region);
if(length >= 0.0) {
G4int n = m_procForced.size();
@@ -1309,8 +1345,10 @@ std::ostream& G4EmParameters::StreamInfo(std::ostream& os) const
os << "=======================================================================" << "\n";
os << "LPM effect enabled " <<flagLPM << "\n";
os << "Spline of EM tables enabled " <<spline << "\n";
os << "Enable creation and use of sampling tables " <<enableSamplingTable << "\n";
os << "Apply cuts on all EM processes " <<applyCuts << "\n";
os << "Use integral approach for tracking " <<integral << "\n";
os << "Use general process " <<gener << "\n";
os << "X-section factor for integral approach " <<lambdaFactor << "\n";
os << "Min kinetic energy for tables "
<<G4BestUnit(minKinEnergy,"Energy") << "\n";
@@ -1340,9 +1378,10 @@ std::ostream& G4EmParameters::StreamInfo(std::ostream& os) const
os << "Lowest muon/hadron kinetic energy "
<<G4BestUnit(lowestMuHadEnergy,"Energy") << "\n";
os << "Fluctuations of dE/dx are enabled " <<lossFluctuation << "\n";
os << "Use ICRU90 data " << fICRU90 << "\n";
os << "Use built-in Birks satuaration " << birks << "\n";
os << "Build CSDA range enabled " <<buildCSDARange << "\n";
os << "Use cut as a final range enabled " <<finalRange << "\n";
os << "Use cut as a final range enabled " <<cutAsFinalRange << "\n";
os << "Enable angular generator interface "
<<useAngGeneratorForIonisation << "\n";
os << "Factor of cut reduction for sub-cutoff method " << minSubRange << "\n";
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmParametersMessenger.cc 66241 2012-12-13 18:34:42Z gunter $
//
// -------------------------------------------------------------------
//
@@ -52,6 +51,7 @@
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UImanager.hh"
#include "G4MscStepLimitType.hh"
#include "G4NuclearFormfactorType.hh"
@@ -213,12 +213,24 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
dnamscCmd->SetDefaultValue(false);
dnamscCmd->AvailableForStates(G4State_PreInit);
sharkCmd = new G4UIcmdWithABool("/process/em/UseGammaShark",this);
sharkCmd->SetGuidance("Enable gamma super-process");
sharkCmd->SetParameterName("shark",true);
sharkCmd = new G4UIcmdWithABool("/process/em/UseGeneralProcess",this);
sharkCmd->SetGuidance("Enable gamma, e+- general process");
sharkCmd->SetParameterName("gen",true);
sharkCmd->SetDefaultValue(false);
sharkCmd->AvailableForStates(G4State_PreInit);
sampleTCmd = new G4UIcmdWithABool("/process/em/enableSamplingTable",this);
sampleTCmd->SetGuidance("Enable usage of sampling table for secondary generation");
sampleTCmd->SetParameterName("sampleT",true);
sampleTCmd->SetDefaultValue(false);
sampleTCmd->AvailableForStates(G4State_PreInit);
icru90Cmd = new G4UIcmdWithABool("/process/eLoss/UseICRU90",this);
icru90Cmd->SetGuidance("Enable usage of ICRU90 stopping powers");
icru90Cmd->SetParameterName("icru90",true);
icru90Cmd->SetDefaultValue(false);
icru90Cmd->AvailableForStates(G4State_PreInit);
minSubSecCmd = new G4UIcmdWithADouble("/process/eLoss/minsubsec",this);
minSubSecCmd->SetGuidance("Set the ratio subcut/cut ");
minSubSecCmd->SetParameterName("rcmin",true);
@@ -407,6 +419,7 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
G4UIparameter* ptype = new G4UIparameter("type",'s',false);
paiCmd->SetParameter(ptype);
ptype->SetParameterCandidates("pai PAI PAIphoton");
meCmd = new G4UIcmdWithAString("/process/em/AddMicroElecRegion",this);
meCmd->SetGuidance("Activate MicroElec model in the G4Region");
@@ -424,11 +437,12 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
G4UIparameter* type = new G4UIparameter("dnaType",'s',false);
dnaCmd->SetParameter(type);
type->SetParameterCandidates("DNA_Opt0");
mscoCmd = new G4UIcommand("/process/em/AddEmRegion",this);
mscoCmd->SetGuidance("Add optional EM configuration for a G4Region.");
mscoCmd->SetGuidance(" regName : G4Region name");
mscoCmd->SetGuidance(" mscType : G4EmStandard, G4EmStandard_opt1, ...");
mscoCmd->SetGuidance(" regName : G4Region name");
mscoCmd->SetGuidance(" emType : G4EmStandard, G4EmStandard_opt1, ...");
mscoCmd->AvailableForStates(G4State_PreInit);
G4UIparameter* mregName = new G4UIparameter("regName",'s',false);
@@ -436,6 +450,7 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
G4UIparameter* mtype = new G4UIparameter("mscType",'s',false);
mscoCmd->SetParameter(mtype);
mtype->SetParameterCandidates("G4EmStandard G4EmStandard_opt1 G4EmStandard_opt2 G4EmStandard_opt3 G4EmStandard_opt4 G4EmStandardGS G4EmStandardSS G4EmLivermore G4EmPenelope G4RadioactiveDecay");
dumpCmd = new G4UIcommand("/process/em/printParameters",this);
dumpCmd->SetGuidance("Print all EM parameters.");
@@ -572,6 +587,18 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
G4UIparameter* bUnit = new G4UIparameter("bUnit",'s',true);
bsCmd->SetParameter(bUnit);
dirSplitCmd = new G4UIcmdWithABool("/process/em/setDirectionalSplitting",this);
dirSplitCmd->SetGuidance("Enable directional brem splitting");
dirSplitCmd->AvailableForStates(G4State_Idle,G4State_Idle);
dirSplitTargetCmd = new G4UIcmdWith3VectorAndUnit("/process/em/setDirectionalSplittingTarget",this);
dirSplitTargetCmd->SetGuidance("Position of arget for directional splitting");
dirSplitTargetCmd->AvailableForStates(G4State_Idle,G4State_Idle);
dirSplitRadiusCmd = new G4UIcmdWithADoubleAndUnit("/process/em/setDirectionalSplittingRadius",this);
dirSplitRadiusCmd->SetGuidance("Radius of target for directional splitting");
dirSplitRadiusCmd->AvailableForStates(G4State_Idle,G4State_Idle);
nffCmd = new G4UIcmdWithAString("/process/em/setNuclearFormFactor",this);
nffCmd->SetGuidance("Define typy of nuclear form-factor");
nffCmd->SetParameterName("NucFF",true);
@@ -631,6 +658,8 @@ G4EmParametersMessenger::~G4EmParametersMessenger()
delete dnasCmd;
delete dnamscCmd;
delete sharkCmd;
delete sampleTCmd;
delete icru90Cmd;
delete minSubSecCmd;
delete minEnCmd;
@@ -678,6 +707,9 @@ G4EmParametersMessenger::~G4EmParametersMessenger()
delete bfCmd;
delete fiCmd;
delete bsCmd;
delete dirSplitCmd;
delete dirSplitTargetCmd;
delete dirSplitRadiusCmd;
delete nffCmd;
delete onIsolatedCmd;
@@ -744,12 +776,14 @@ void G4EmParametersMessenger::SetNewValue(G4UIcommand* command,
theParameters->SetUseMottCorrection(mottCmd->GetNewBoolValue(newValue));
} else if (command == birksCmd) {
theParameters->SetBirksActive(birksCmd->GetNewBoolValue(newValue));
} else if (command == icru90Cmd) {
theParameters->SetUseICRU90Data(icru90Cmd->GetNewBoolValue(newValue));
} else if (command == dnafCmd) {
theParameters->SetDNAFast(dnafCmd->GetNewBoolValue(newValue));
} else if (command == dnasCmd) {
theParameters->SetDNAStationary(dnasCmd->GetNewBoolValue(newValue));
} else if (command == dnamscCmd) {
theParameters->SetBirksActive(dnamscCmd->GetNewBoolValue(newValue));
theParameters->SetDNAElectronMsc(dnamscCmd->GetNewBoolValue(newValue));
} else if (command == dnaSolCmd) {
G4DNAModelSubType ttt = fDNAUnknownModel;
if(newValue == "Ritchie1994") {
@@ -761,7 +795,9 @@ void G4EmParametersMessenger::SetNewValue(G4UIcommand* command,
}
theParameters->SetDNAeSolvationSubType(ttt);
} else if (command == sharkCmd) {
theParameters->SetGammaSharkActive(sharkCmd->GetNewBoolValue(newValue));
theParameters->SetGeneralProcessActive(sharkCmd->GetNewBoolValue(newValue));
} else if (command == sampleTCmd) {
theParameters->SetEnableSamplingTable(sampleTCmd->GetNewBoolValue(newValue));
} else if (command == minSubSecCmd) {
theParameters->SetMinSubRange(minSubSecCmd->GetNewDoubleValue(newValue));
@@ -930,6 +966,18 @@ void G4EmParametersMessenger::SetNewValue(G4UIcommand* command,
en *= G4UIcommand::ValueOf(unt);
theParameters->ActivateSecondaryBiasing(s1,s2,fb,en);
physicsModified = true;
} else if (command == dirSplitCmd) {
theParameters->SetDirectionalSplitting(
dirSplitCmd->GetNewBoolValue(newValue));
physicsModified = true;
} else if (command == dirSplitTargetCmd) {
G4ThreeVector t = dirSplitTargetCmd->GetNew3VectorValue(newValue);
theParameters->SetDirectionalSplittingTarget(t);
physicsModified = true;
} else if (command == dirSplitRadiusCmd) {
G4double r = dirSplitRadiusCmd->GetNewDoubleValue(newValue);
theParameters->SetDirectionalSplittingRadius(r);
physicsModified = true;
} else if (command == nffCmd) {
G4NuclearFormfactorType x = fNoneNF;
if(newValue == "Exponential") { x = fExponentialNF; }
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmProcessOptions.cc 96088 2016-03-14 16:03:38Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmSaturation.cc 104372 2017-05-29 09:55:44Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4EnergyLossTables.cc 92921 2015-09-21 15:06:51Z gcosmo $
//
// -------------------------------------------------------------------
// first version created by P.Urban , 06/04/1998
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4LossTableBuilder.cc 96088 2016-03-14 16:03:38Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4LossTableManager.cc 110572 2018-05-30 13:08:12Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -198,7 +197,8 @@ G4LossTableManager::G4LossTableManager()
emElectronIonPair = nullptr;
atomDeexcitation = nullptr;
subcutProducer = nullptr;
gammaShark = nullptr;
gGeneral = nullptr;
eGeneral = nullptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
@@ -1059,25 +1059,20 @@ void G4LossTableManager::DumpHtml()
// Automatic generation of html documentation page for physics lists
// List processes and models for the most important
// particles in descending order of importance
// NB. for model names with length > 18 characters the .rst file needs
// to be edited by hand. Or modify G4EmModelManager::DumpModelList
char* dirName = getenv("G4PhysListDocDir");
char* physListName = getenv("G4PhysListName");
if (dirName && physListName) {
G4String pathName = G4String(dirName) + "/" + G4String(physListName)
+ ".html";
char* physList = getenv("G4PhysListName");
if (dirName && physList) {
G4String physListName = G4String(physList);
G4String pathName = G4String(dirName) + "/" + physListName + ".rst";
std::ofstream outFile;
outFile.open(pathName);
outFile << "<html>\n";
outFile << "<head>\n";
outFile << "<title>Physics List Summary</title>\n";
outFile << "</head>\n";
outFile << "<body>\n";
outFile << "<h2> Summary of Electromagnetic Processes, Models and Cross "
<< "Sections for Physics List "
<< G4String(physListName) << "</h2>\n";
outFile << "<ul>\n";
outFile << physListName << G4endl;
outFile << std::string(physListName.length(), '=') << G4endl;
std::vector<G4ParticleDefinition*> particles {
G4Gamma::Gamma(),
@@ -1095,9 +1090,10 @@ void G4LossTableManager::DumpHtml()
GetMultipleScatteringVector();
for (auto theParticle : particles) {
outFile << "<li><h3>" << theParticle->GetParticleName() << "</h3><ul>\n";
outFile << G4endl << "**" << theParticle->GetParticleName()
<< "**" << G4endl << G4endl << " .. code-block:: none" << G4endl;
G4ProcessManager* pm = theParticle->GetProcessManager();
G4ProcessManager* pm = theParticle->GetProcessManager();
G4ProcessVector* pv = pm->GetProcessList();
G4int plen = pm->GetProcessListLength();
@@ -1105,9 +1101,8 @@ void G4LossTableManager::DumpHtml()
for (G4int i = 0; i < plen; ++i) {
G4VProcess* proc = (*pv)[i];
if (proc == emproc) {
outFile << "<li>\n";
outFile << G4endl;
proc->ProcessDescription(outFile);
outFile << "</li>\n";
break;
}
}
@@ -1117,9 +1112,8 @@ void G4LossTableManager::DumpHtml()
for (G4int i = 0; i < plen; ++i) {
G4VProcess* proc = (*pv)[i];
if (proc == mscproc) {
outFile << "<li>\n";
outFile << G4endl;
proc->ProcessDescription(outFile);
outFile << "</li>\n";
break;
}
}
@@ -1129,19 +1123,13 @@ void G4LossTableManager::DumpHtml()
for (G4int i = 0; i < plen; ++i) {
G4VProcess* proc = (*pv)[i];
if (proc == enlossproc) {
outFile << "<li>\n";
outFile << G4endl;
proc->ProcessDescription(outFile);
outFile << "</li>\n";
break;
}
}
}
outFile << "</ul>\n";
outFile << "</li>\n";
}
outFile << "</ul>\n";
outFile << "</body>\n";
outFile << "</html>\n";
outFile.close();
}
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VAtomDeexcitation.cc 108386 2018-02-09 15:38:32Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmAngularDistribution.cc 110416 2018-05-23 06:45:42Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmFluctuationModel.cc 106208 2017-09-20 01:53:57Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmModel.cc 110572 2018-05-30 13:08:12Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -475,16 +474,7 @@ void G4VEmModel::SetCrossSectionTable(G4PhysicsTable* p, G4bool isLocal)
void G4VEmModel::ModelDescription(std::ostream& outFile) const
{
ModelDescription(outFile, G4String("\n"));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::ModelDescription(std::ostream& outFile,
G4String endOfLine) const
{
outFile << "The description for this model has not been written yet."
<< endOfLine;
outFile << "The description for this model has not been written yet.\n";
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmProcess.cc 109178 2018-04-03 07:13:58Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -36,25 +35,9 @@
//
// Creation date: 01.10.2003
//
// Modifications:
// 30-06-04 make it to be pure discrete process (V.Ivanchenko)
// 30-09-08 optimise integral option (V.Ivanchenko)
// 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko)
// 11-03-05 Shift verbose level by 1, add applyCuts and killPrimary flags (VI)
// 14-03-05 Update logic PostStepDoIt (V.Ivanchenko)
// 08-04-05 Major optimisation of internal interfaces (V.Ivanchenko)
// 18-04-05 Use G4ParticleChangeForGamma (V.Ivanchenko)
// 25-07-05 Add protection: integral mode only for charged particles (VI)
// 04-09-05 default lambdaFactor 0.8 (V.Ivanchenko)
// 11-01-06 add A to parameters of ComputeCrossSectionPerAtom (VI)
// 12-09-06 add SetModel() (mma)
// 12-04-07 remove double call to Clear model manager (V.Ivanchenko)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
// 17-02-10 Added pointer currentParticle (VI)
// 30-05-12 allow Russian roulette, brem splitting (D. Sawkey)
// Modifications: by V.Ivanchenko
//
// Class Description:
// Class Description: based class for discrete and rest/discrete EM processes
//
// -------------------------------------------------------------------
@@ -73,6 +56,7 @@
#include "G4VEmModel.hh"
#include "G4DataVector.hh"
#include "G4PhysicsTable.hh"
#include "G4EmDataHandler.hh"
#include "G4PhysicsLogVector.hh"
#include "G4VParticleChange.hh"
#include "G4ProductionCutsTable.hh"
@@ -103,6 +87,9 @@ G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
splineFlag(true),
isIon(false),
currentCouple(nullptr),
isTheMaster(true),
masterProc(nullptr),
theData(nullptr),
currentModel(nullptr),
particle(nullptr),
currentParticle(nullptr)
@@ -174,20 +161,14 @@ G4VEmProcess::~G4VEmProcess()
<< " " << this << " " << theLambdaTable <<G4endl;
}
*/
if(lManager->IsMaster()) {
if(theLambdaTable) {
theLambdaTable->clearAndDestroy();
delete theLambdaTable;
}
if(theLambdaTablePrim) {
theLambdaTablePrim->clearAndDestroy();
delete theLambdaTablePrim;
}
if(isTheMaster) {
delete theData;
theData = nullptr;
}
delete modelManager;
delete biasManager;
lManager->DeRegister(this);
//G4cout << "G4VEmProcess removed " << G4endl;
//std::cout << "G4VEmProcess removed " << GetProcessName() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -196,7 +177,6 @@ void G4VEmProcess::Clear()
{
currentCouple = nullptr;
preStepLambda = 0.0;
mfpKinEnergy = DBL_MAX;
idxLambda = idxLambdaPrim = 0;
}
@@ -273,7 +253,7 @@ G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) const
void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
{
G4bool isMaster = lManager->IsMaster();
isTheMaster = lManager->IsMaster();
if(!particle) { SetParticle(&part); }
@@ -303,7 +283,7 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
G4LossTableBuilder* bld = lManager->GetTableBuilder();
lManager->PreparePhysicsTable(&part, this, isMaster);
lManager->PreparePhysicsTable(&part, this, isTheMaster);
Clear();
InitialiseProcess(particle);
@@ -320,8 +300,12 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
if(!actMaxKinEnergy) { maxKinEnergy = theParameters->MaxKinEnergy(); }
if(!actSpline) { splineFlag = theParameters->Spline(); }
if(isMaster) { SetVerboseLevel(theParameters->Verbose()); }
else { SetVerboseLevel(theParameters->WorkerVerbose()); }
if(isTheMaster) {
SetVerboseLevel(theParameters->Verbose());
if(!theData) { theData = new G4EmDataHandler(2); }
} else {
SetVerboseLevel(theParameters->WorkerVerbose());
}
applyCuts = theParameters->ApplyCuts();
lambdaFactor = theParameters->LambdaFactor();
theParameters->DefineRegParamForEM(this);
@@ -332,7 +316,7 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
G4VEmModel* mod = modelManager->GetModel(i);
if(0 == i) { currentModel = mod; }
mod->SetPolarAngleLimit(theParameters->MscThetaLimit());
mod->SetMasterThread(isMaster);
mod->SetMasterThread(isTheMaster);
if(mod->HighEnergyLimit() > maxKinEnergy) {
mod->SetHighEnergyLimit(maxKinEnergy);
}
@@ -346,15 +330,13 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut);
// prepare tables
if(buildLambdaTable && isMaster){
theLambdaTable =
G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
if(buildLambdaTable && isTheMaster){
theLambdaTable = theData->MakeTable(0);
bld->InitialiseBaseMaterials(theLambdaTable);
}
// high energy table
if(isMaster && minKinEnergyPrim < maxKinEnergy){
theLambdaTablePrim =
G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTablePrim);
if(isTheMaster && minKinEnergyPrim < maxKinEnergy){
theLambdaTablePrim = theData->MakeTable(1);
bld->InitialiseBaseMaterials(theLambdaTablePrim);
}
// forced biasing
@@ -379,9 +361,10 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
{
G4bool isMaster = lManager->IsMaster();
const G4VEmProcess* masterProc =
static_cast<const G4VEmProcess*>(GetMasterProcess());
if(!masterProc) {
if(isTheMaster) { masterProc = this; }
else { masterProc = static_cast<const G4VEmProcess*>(GetMasterProcess());}
}
G4String num = part.GetParticleName();
if(1 < verboseLevel) {
@@ -389,7 +372,8 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
<< GetProcessName()
<< " and particle " << num
<< " buildLambdaTable= " << buildLambdaTable
<< " isMaster= " << isMaster
<< " isTheMaster= " << isTheMaster
<< " " << masterProc
<< G4endl;
}
@@ -398,7 +382,7 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
G4LossTableBuilder* bld = lManager->GetTableBuilder();
// worker initialisation
if(!isMaster) {
if(!isTheMaster) {
theLambdaTable = masterProc->LambdaTable();
theLambdaTablePrim = masterProc->LambdaTablePrim();
@@ -417,6 +401,8 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
for(G4int i=0; i<numberOfModels; ++i) {
G4VEmModel* mod = GetModelByIndex(i, printing);
G4VEmModel* mod0= masterProc->GetModelByIndex(i, printing);
//G4cout << i << ". " << mod << " " << mod0 << " "
// << particle->GetParticleName() << G4endl;
mod->InitialiseLocal(particle, mod0);
}
// master thread
@@ -475,8 +461,8 @@ void G4VEmProcess::BuildLambdaTable()
G4PhysicsLogVector* bVectorPrim = nullptr;
G4double scale = theParameters->MaxKinEnergy()/theParameters->MinKinEnergy();
G4int nbin = theParameters->NumberOfBinsPerDecade()
*G4lrint(std::log10(scale));
G4int nbin =
theParameters->NumberOfBinsPerDecade()*G4lrint(std::log10(scale));
scale = G4Log(scale);
if(actBinning) { nbin = std::max(nbin, nLambdaBins); }
G4double emax1 = std::min(maxKinEnergy, minKinEnergyPrim);
@@ -550,11 +536,12 @@ void G4VEmProcess::BuildLambdaTable()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::StreamInfo(std::ostream& out,
const G4ParticleDefinition& part, G4String endOfLine) const
const G4ParticleDefinition& part, G4bool rst) const
{
G4String indent = (rst ? " " : "");
out << std::setprecision(6);
out << endOfLine << GetProcessName() << ": ";
if (endOfLine != G4String("<br>\n")) {
out << G4endl << indent << GetProcessName() << ": ";
if (!rst) {
out << " for " << part.GetParticleName();
if (integral) { out << ","; }
}
@@ -562,62 +549,59 @@ void G4VEmProcess::StreamInfo(std::ostream& out,
if(applyCuts) { out << ", applyCuts: 1 "; }
out << " SubType= " << GetProcessSubType();;
if(biasFactor != 1.0) { out << " BiasingFactor= " << biasFactor; }
out << " BuildTable= " << buildLambdaTable;
out << endOfLine;
out << " BuildTable= " << buildLambdaTable << G4endl;
if(buildLambdaTable) {
if(particle == &part) {
size_t length = theLambdaTable->length();
for(size_t i=0; i<length; ++i) {
G4PhysicsVector* v = (*theLambdaTable)[i];
if(v) {
out << " Lambda table from ";
G4double emin = v->Energy(0);
G4double emax = v->GetMaxEnergy();
G4int nbin = v->GetVectorLength() - 1;
if(emin > minKinEnergy) { out << "threshold "; }
else { out << G4BestUnit(emin,"Energy"); }
out << " to "
<< G4BestUnit(emax,"Energy")
<< ", " << G4lrint(nbin/std::log10(emax/emin))
<< " bins per decade, spline: "
<< splineFlag
<< endOfLine;
break;
}
G4PhysicsVector* v = (*theLambdaTable)[i];
if(v) {
out << " Lambda table from ";
G4double emin = v->Energy(0);
G4double emax = v->GetMaxEnergy();
G4int nbin = v->GetVectorLength() - 1;
if(emin > minKinEnergy) { out << "threshold "; }
else { out << G4BestUnit(emin,"Energy"); }
out << " to "
<< G4BestUnit(emax,"Energy")
<< ", " << G4lrint(nbin/std::log10(emax/emin))
<< " bins per decade, spline: "
<< splineFlag << G4endl;
break;
}
}
} else {
out << " Used Lambda table of "
<< particle->GetParticleName() << endOfLine;
<< particle->GetParticleName() << G4endl;
}
}
if(minKinEnergyPrim < maxKinEnergy) {
if(particle == &part) {
size_t length = theLambdaTablePrim->length();
for(size_t i=0; i<length; ++i) {
G4PhysicsVector* v = (*theLambdaTablePrim)[i];
if(v) {
out << " LambdaPrime table from "
<< G4BestUnit(v->Energy(0),"Energy")
<< " to "
<< G4BestUnit(v->GetMaxEnergy(),"Energy")
<< " in " << v->GetVectorLength()-1
<< " bins "
<< endOfLine;
break;
}
G4PhysicsVector* v = (*theLambdaTablePrim)[i];
if(v) {
out << " LambdaPrime table from "
<< G4BestUnit(v->Energy(0),"Energy")
<< " to "
<< G4BestUnit(v->GetMaxEnergy(),"Energy")
<< " in " << v->GetVectorLength()-1
<< " bins " << G4endl;
break;
}
}
} else {
out << " Used LambdaPrime table of "
<< particle->GetParticleName() << endOfLine;
<< particle->GetParticleName() << G4endl;
}
}
StreamProcessInfo(out, endOfLine);
modelManager->DumpModelList(out, verboseLevel, endOfLine);
StreamProcessInfo(out);
modelManager->DumpModelList(out, verboseLevel);
if(verboseLevel > 2 && buildLambdaTable) {
out << " LambdaTable address= " << theLambdaTable << endOfLine;
out << " LambdaTable address= " << theLambdaTable << G4endl;
if(theLambdaTable && particle == &part) {
out << (*theLambdaTable) << endOfLine;
out << (*theLambdaTable) << G4endl;
}
}
}
@@ -630,7 +614,7 @@ void G4VEmProcess::StartTracking(G4Track* track)
currentParticle = track->GetParticleDefinition();
theNumberOfInteractionLengthLeft = -1.0;
mfpKinEnergy = DBL_MAX;
massRatio = (isIon) ? proton_mass_c2/currentParticle->GetPDGMass() : 1.0;
if(isIon) { massRatio = proton_mass_c2/currentParticle->GetPDGMass(); }
// forced biasing only for primary particles
if(biasManager) {
@@ -652,8 +636,8 @@ G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
*condition = NotForced;
G4double x = DBL_MAX;
preStepKinEnergy = track.GetKineticEnergy();
DefineMaterial(track.GetMaterialCutsCouple());
preStepKinEnergy = track.GetKineticEnergy();
G4double scaledEnergy = preStepKinEnergy*massRatio;
SelectModel(scaledEnergy, currentCoupleIndex);
@@ -705,26 +689,42 @@ G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
// new mean free path and step limit for the next step
currentInteractionLength = 1.0/preStepLambda;
x = theNumberOfInteractionLengthLeft * currentInteractionLength;
/*
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength ";
G4cout << "[ " << GetProcessName() << "]" << G4endl;
G4cout << " for " << currentParticle->GetParticleName()
<< " in Material " << currentMaterial->GetName()
<< " Ekin(MeV)= " << preStepKinEnergy/MeV
<<G4endl;
G4cout << " MeanFreePath = " << currentInteractionLength/cm << "[cm]"
<< " InteractionLength= " << x/cm <<"[cm] " <<G4endl;
}
#endif
*/
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::ComputeIntegralLambda(G4double e)
{
// condition to skip recomputation of cross section
G4double epeak = theEnergyOfCrossSectionMax[currentCoupleIndex];
if(e <= epeak && e/lambdaFactor >= mfpKinEnergy) { return; }
// recomputation is needed
if (e <= epeak) {
preStepLambda = GetCurrentLambda(e);
mfpKinEnergy = e;
} else {
G4double e1 = e*lambdaFactor;
if(e1 > epeak) {
preStepLambda = GetCurrentLambda(e);
mfpKinEnergy = e;
G4double preStepLambda1 = GetCurrentLambda(e1);
if(preStepLambda1 > preStepLambda) {
mfpKinEnergy = e1;
preStepLambda = preStepLambda1;
}
} else {
preStepLambda = fFactor*theCrossSectionMax[currentCoupleIndex];
mfpKinEnergy = epeak;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
const G4Step& step)
{
@@ -843,7 +843,11 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
if (good) {
G4Track* t = new G4Track(dp, time, track.GetPosition());
t->SetTouchableHandle(track.GetTouchableHandle());
t->SetWeight(weight);
if (biasManager) {
t->SetWeight(biasManager->GetWeight(i));
} else {
t->SetWeight(weight);
}
pParticleChange->AddSecondary(t);
// define type of secondary
@@ -885,18 +889,16 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
const G4String& directory,
G4bool ascii)
{
G4bool yes = true;
const G4VEmProcess* masterProc =
static_cast<const G4VEmProcess*>(GetMasterProcess());
if(masterProc && masterProc != this) { return yes; }
if(!isTheMaster) { return yes; }
if ( theLambdaTable && part == particle) {
const G4String name =
const G4String& nam =
GetPhysicsTableFileName(part,directory,"Lambda",ascii);
yes = theLambdaTable->StorePhysicsTable(name,ascii);
yes = theLambdaTable->StorePhysicsTable(nam,ascii);
if ( yes ) {
G4cout << "Physics table is stored for " << particle->GetParticleName()
@@ -912,7 +914,7 @@ G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
}
}
if ( theLambdaTablePrim && part == particle) {
const G4String name =
const G4String& name =
GetPhysicsTableFileName(part,directory,"LambdaPrim",ascii);
yes = theLambdaTablePrim->StorePhysicsTable(name,ascii);
@@ -936,7 +938,7 @@ G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
if(1 < verboseLevel) {
@@ -950,10 +952,10 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
|| particle != part) { return yes; }
const G4String particleName = part->GetParticleName();
G4String filename;
if(buildLambdaTable) {
filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
const G4String& filename =
GetPhysicsTableFileName(part,directory,"Lambda",ascii);
yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,
filename,ascii);
if ( yes ) {
@@ -980,7 +982,8 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
}
}
if(minKinEnergyPrim < maxKinEnergy) {
filename = GetPhysicsTableFileName(part,directory,"LambdaPrim",ascii);
const G4String& filename =
GetPhysicsTableFileName(part,directory,"LambdaPrim",ascii);
yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTablePrim,
filename,ascii);
if ( yes ) {
@@ -1006,7 +1009,6 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
}
}
}
return yes;
}
@@ -1019,17 +1021,17 @@ G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
// Cross section per atom is calculated
DefineMaterial(couple);
G4double cross = 0.0;
if(buildLambdaTable && theLambdaTable) {
if(buildLambdaTable) {
cross = GetCurrentLambda(kineticEnergy);
} else {
SelectModel(kineticEnergy, currentCoupleIndex);
cross = fFactor*currentModel->CrossSectionPerVolume(currentMaterial,
currentParticle,
kineticEnergy);
if(currentModel) {
cross = fFactor*currentModel->CrossSectionPerVolume(currentMaterial,
currentParticle,
kineticEnergy);
}
}
if(cross < 0.0) { cross = 0.0; }
return cross;
return std::max(cross, 0.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1046,26 +1048,22 @@ G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
G4double G4VEmProcess::MeanFreePath(const G4Track& track)
{
DefineMaterial(track.GetMaterialCutsCouple());
preStepLambda = GetCurrentLambda(track.GetKineticEnergy());
G4double x = DBL_MAX;
if(0.0 < preStepLambda) { x = 1.0/preStepLambda; }
return x;
G4double kinEnergy = track.GetKineticEnergy();
CurrentSetup(track.GetMaterialCutsCouple(), kinEnergy);
G4double xs = GetCurrentLambda(kinEnergy);
return (0.0 < xs) ? 1.0/xs : DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double
G4VEmProcess::ComputeCrossSectionPerAtom(G4double kineticEnergy,
G4VEmProcess::ComputeCrossSectionPerAtom(G4double kinEnergy,
G4double Z, G4double A, G4double cut)
{
SelectModel(kineticEnergy, currentCoupleIndex);
G4double x = 0.0;
if(currentModel) {
x = currentModel->ComputeCrossSectionPerAtom(currentParticle,kineticEnergy,
Z,A,cut);
}
return x;
SelectModel(kinEnergy, currentCoupleIndex);
return (currentModel) ?
currentModel->ComputeCrossSectionPerAtom(currentParticle, kinEnergy,
Z, A, cut) : 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1135,8 +1133,8 @@ G4VEmProcess::LambdaPhysicsVector(const G4MaterialCutsCouple*)
const G4Element* G4VEmProcess::GetCurrentElement() const
{
const G4Element* elm = nullptr;
if(currentModel) {elm = currentModel->GetCurrentElement(); }
const G4Element* elm =
(currentModel) ? currentModel->GetCurrentElement() : nullptr;
return elm;
}
@@ -1268,7 +1266,7 @@ void G4VEmProcess::PrintWarning(G4String tit, G4double val)
void G4VEmProcess::ProcessDescription(std::ostream& out) const
{
if(particle) {
StreamInfo(out, *particle, G4String("<br>\n"));
StreamInfo(out, *particle, true);
}
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEnergyLossProcess.cc 107959 2017-12-14 13:05:59Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -36,87 +35,8 @@
//
// Creation date: 03.01.2002
//
// Modifications:
// Modifications: Vladimir Ivanchenko
//
// 13-11-02 Minor fix - use normalised direction (V.Ivanchenko)
// 04-12-02 Minor change in PostStepDoIt (V.Ivanchenko)
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 26-12-02 Secondary production moved to derived classes (V.Ivanchenko)
// 04-01-03 Fix problem of very small steps for ions (V.Ivanchenko)
// 20-01-03 Migrade to cut per region (V.Ivanchenko)
// 24-01-03 Temporarily close a control on usage of couples (V.Ivanchenko)
// 24-01-03 Make models region aware (V.Ivanchenko)
// 05-02-03 Fix compilation warnings (V.Ivanchenko)
// 06-02-03 Add control on tmax in PostStepDoIt (V.Ivanchenko)
// 13-02-03 SubCutoffProcessors defined for regions (V.Ivanchenko)
// 15-02-03 Lambda table can be scaled (V.Ivanchenko)
// 17-02-03 Fix problem of store/restore tables (V.Ivanchenko)
// 18-02-03 Add control on CutCouple usage (V.Ivanchenko)
// 26-02-03 Simplify control on GenericIons (V.Ivanchenko)
// 06-03-03 Control on GenericIons using SubType+ update verbose (V.Ivanchenko)
// 10-03-03 Add Ion registration (V.Ivanchenko)
// 22-03-03 Add Initialisation of cash (V.Ivanchenko)
// 26-03-03 Remove finalRange modification (V.Ivanchenko)
// 09-04-03 Fix problem of negative range limit for non integral (V.Ivanchenko)
// 26-04-03 Fix retrieve tables (V.Ivanchenko)
// 06-05-03 Set defalt finalRange = 1 mm (V.Ivanchenko)
// 12-05-03 Update range calculations + lowKinEnergy (V.Ivanchenko)
// 13-05-03 Add calculation of precise range (V.Ivanchenko)
// 23-05-03 Remove tracking cuts (V.Ivanchenko)
// 03-06-03 Fix initialisation problem for STD ionisation (V.Ivanchenko)
// 21-07-03 Add UpdateEmModel method (V.Ivanchenko)
// 03-11-03 Fix initialisation problem in RetrievePhysicsTable (V.Ivanchenko)
// 04-11-03 Add checks in RetrievePhysicsTable (V.Ivanchenko)
// 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko)
// 21-01-04 Migrade to G4ParticleChangeForLoss (V.Ivanchenko)
// 27-02-04 Fix problem of loss in low presure gases, cleanup precise range
// calculation, use functions ForLoss in AlongStepDoIt (V.Ivanchenko)
// 10-03-04 Fix a problem of Precise Range table (V.Ivanchenko)
// 19-03-04 Fix a problem energy below lowestKinEnergy (V.Ivanchenko)
// 31-03-04 Fix a problem of retrieve tables (V.Ivanchenko)
// 21-07-04 Check weather AtRest are active or not (V.Ivanchenko)
// 03-08-04 Add pointer of DEDX table to all processes (V.Ivanchenko)
// 06-08-04 Clear up names of member functions (V.Ivanchenko)
// 06-08-04 Clear up names of member functions (V.Ivanchenko)
// 27-08-04 Add NeedBuildTables method (V.Ivanchneko)
// 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko)
// 11-03-05 Shift verbose level by 1 (V.Ivantchenko)
// 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko)
// 11-04-05 Use MaxSecondaryEnergy from a model (V.Ivanchenko)
// 25-07-05 Add extra protection PostStep for non-integral mode (V.Ivanchenko)
// 12-08-05 Integral=false; SetStepFunction(0.2, 0.1*mm) (mma)
// 18-08-05 Return back both AlongStep and PostStep from 7.0 (V.Ivanchenko)
// 02-09-05 Default StepFunction 0.2 1 mm + integral (V.Ivanchenko)
// 04-09-05 default lambdaFactor 0.8 (V.Ivanchenko)
// 05-10-05 protection against 0 energy loss added (L.Urban)
// 17-10-05 protection above has been removed (L.Urban)
// 06-01-06 reset currentCouple when StepFunction is changed (V.Ivanchenko)
// 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko)
// 18-01-06 Clean up subcutoff including recalculation of presafety (VI)
// 20-01-06 Introduce G4EmTableType and reducing number of methods (VI)
// 22-03-06 Add control on warning printout AlongStep (VI)
// 23-03-06 Use isIonisation flag (V.Ivanchenko)
// 07-06-06 Do not reflect AlongStep in subcutoff regime (V.Ivanchenko)
// 14-01-07 add SetEmModel(index) and SetFluctModel() (mma)
// 16-01-07 add IonisationTable and IonisationSubTable (V.Ivanchenko)
// 16-02-07 set linLossLimit=1.e-6 (V.Ivanchenko)
// 13-03-07 use SafetyHelper instead of navigator (V.Ivanchenko)
// 10-04-07 use unique SafetyHelper (V.Ivanchenko)
// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
// 25-04-07 move initialisation of safety helper to BuildPhysicsTable (VI)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
// 01-25-09 (Xin Dong) Phase II change for Geant4 multi-threading:
// New methods SlavePreparePhysicsTable, SlaveBuildPhysicsTable
// Worker threads share physics tables with the master thread for
// this kind of process. This member function is used by worker
// threads to achieve the partial effect of the master thread when
// it builds physcis tables.
// 15-10-10 Fixed 4-momentum balance if deexcitation is active (L.Pandola)
// 30-05-12 Call new ApplySecondaryBiasing so 2ries may be unique (D. Sawkey)
// 30-05-12 Fix bug in forced biasing: now called on first step (D. Sawkey)
// 04-06-13 Adoptation to MT mode, adding internal cache to GetRangeForLoss,
// more accurate initialisation for ions (V.Ivanchenko)
//
// Class Description:
//
@@ -193,9 +113,9 @@ G4VEnergyLossProcess::G4VEnergyLossProcess(const G4String& name,
isIonisation(true),
useSubCutoff(false),
useDeexcitation(false),
particle(nullptr),
currentCouple(nullptr),
mfpKinEnergy(0.0)
mfpKinEnergy(0.0),
particle(nullptr)
{
theParameters = G4EmParameters::Instance();
SetVerboseLevel(1);
@@ -289,7 +209,7 @@ G4VEnergyLossProcess::~G4VEnergyLossProcess()
if(theDEDXTable) {
//G4cout << " theIonisationTable " << theIonisationTable << G4endl;
if(theIonisationTable == theDEDXTable) { theIonisationTable = 0; }
if(theIonisationTable == theDEDXTable) { theIonisationTable = nullptr; }
//G4cout << " delete theDEDXTable " << theDEDXTable << G4endl;
theDEDXTable->clearAndDestroy();
delete theDEDXTable;
@@ -547,11 +467,8 @@ G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
chargeSqRatio = q*q;
if(chargeSqRatio > 0.0) { reduceFactor = 1.0/(chargeSqRatio*massRatio); }
}
if(initialMass < MeV) {
lowestKinEnergy = theParameters->LowestElectronEnergy();
} else {
lowestKinEnergy = theParameters->LowestMuHadEnergy();
}
lowestKinEnergy = (initialMass < MeV) ? theParameters->LowestElectronEnergy()
: theParameters->LowestMuHadEnergy();
// Tables preparation
if (isMaster && !baseParticle) {
@@ -965,77 +882,72 @@ G4PhysicsTable* G4VEnergyLossProcess::BuildLambdaTable(G4EmTableType tType)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEnergyLossProcess::StreamInfo(std::ostream& out,
const G4ParticleDefinition& part, G4String endOfLine) const
const G4ParticleDefinition& part, G4bool rst) const
{
G4String indent = (rst ? " " : "");
out << std::setprecision(6);
out << endOfLine << GetProcessName() << ": ";
if (endOfLine != G4String("<br>\n")) {
out << " for " << part.GetParticleName();
}
out << " SubType= " << GetProcessSubType() << endOfLine
out << G4endl << indent << GetProcessName() << ": ";
if (!rst) out << " for " << part.GetParticleName();
out << " SubType= " << GetProcessSubType() << G4endl
<< " dE/dx and range tables from "
<< G4BestUnit(minKinEnergy,"Energy")
<< " to " << G4BestUnit(maxKinEnergy,"Energy")
<< " in " << nBins << " bins" << endOfLine
<< " in " << nBins << " bins" << G4endl
<< " Lambda tables from threshold to "
<< G4BestUnit(maxKinEnergy,"Energy")
<< ", " << theParameters->NumberOfBinsPerDecade()
<< " bins per decade, spline: "
<< theParameters->Spline()
<< endOfLine;
<< G4endl;
if(theRangeTableForLoss && isIonisation) {
out << " finalRange(mm)= " << finalRange/mm
<< ", dRoverRange= " << dRoverRange
<< ", integral: " << integral
<< ", fluct: " << lossFluctuationFlag
<< ", linLossLimit= " << linLossLimit
<< endOfLine;
<< G4endl;
}
StreamProcessInfo(out, endOfLine);
modelManager->DumpModelList(out, verboseLevel, endOfLine);
StreamProcessInfo(out);
modelManager->DumpModelList(out, verboseLevel);
if(theCSDARangeTable && isIonisation) {
out << " CSDA range table up"
<< " to " << G4BestUnit(maxKinEnergyCSDA,"Energy")
<< " in " << nBinsCSDA << " bins" << endOfLine;
<< " in " << nBinsCSDA << " bins" << G4endl;
}
if(nSCoffRegions>0 && isIonisation) {
out << " Subcutoff sampling in " << nSCoffRegions
<< " regions" << endOfLine;
<< " regions" << G4endl;
}
if(2 < verboseLevel) {
out << " DEDXTable address= " << theDEDXTable << endOfLine;
if(theDEDXTable && isIonisation) out << (*theDEDXTable) << endOfLine;
out << " DEDXTable address= " << theDEDXTable << G4endl;
if(theDEDXTable && isIonisation) out << (*theDEDXTable) << G4endl;
out << "non restricted DEDXTable address= "
<< theDEDXunRestrictedTable << endOfLine;
<< theDEDXunRestrictedTable << G4endl;
if(theDEDXunRestrictedTable && isIonisation) {
out << (*theDEDXunRestrictedTable) << endOfLine;
out << (*theDEDXunRestrictedTable) << G4endl;
}
if(theDEDXSubTable && isIonisation) {
out << (*theDEDXSubTable) << endOfLine;
out << (*theDEDXSubTable) << G4endl;
}
out << " CSDARangeTable address= " << theCSDARangeTable
<< endOfLine;
out << " CSDARangeTable address= " << theCSDARangeTable << G4endl;
if(theCSDARangeTable && isIonisation) {
out << (*theCSDARangeTable) << endOfLine;
out << (*theCSDARangeTable) << G4endl;
}
out << " RangeTableForLoss address= " << theRangeTableForLoss
<< endOfLine;
out << " RangeTableForLoss address= " << theRangeTableForLoss << G4endl;
if(theRangeTableForLoss && isIonisation) {
out << (*theRangeTableForLoss) << endOfLine;
out << (*theRangeTableForLoss) << G4endl;
}
out << " InverseRangeTable address= " << theInverseRangeTable
<< endOfLine;
out << " InverseRangeTable address= " << theInverseRangeTable << G4endl;
if(theInverseRangeTable && isIonisation) {
out << (*theInverseRangeTable) << endOfLine;
out << (*theInverseRangeTable) << G4endl;
}
out << " LambdaTable address= " << theLambdaTable << endOfLine;
out << " LambdaTable address= " << theLambdaTable << G4endl;
if(theLambdaTable && isIonisation) {
out << (*theLambdaTable) << endOfLine;
out << (*theLambdaTable) << G4endl;
}
out << " SubLambdaTable address= " << theSubLambdaTable
<< endOfLine;
out << " SubLambdaTable address= " << theSubLambdaTable << G4endl;
if(theSubLambdaTable && isIonisation) {
out << (*theSubLambdaTable) << endOfLine;
out << (*theSubLambdaTable) << G4endl;
}
}
}
@@ -1181,7 +1093,7 @@ G4double G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength(
// compute mean free path
if(preStepScaledEnergy < mfpKinEnergy) {
if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); }
else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); }
else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); }
// zero cross section
if(preStepLambda <= 0.0) {
@@ -1231,6 +1143,36 @@ G4double G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEnergyLossProcess::ComputeLambdaForScaledEnergy(G4double e)
{
// condition to skip recomputation of cross section
G4double epeak = theEnergyOfCrossSectionMax[currentCoupleIndex];
if(e <= epeak && e/lambdaFactor >= mfpKinEnergy) { return; }
// recomputation is needed
if (e <= epeak) {
preStepLambda = GetLambdaForScaledEnergy(e);
mfpKinEnergy = e;
} else {
G4double e1 = e*lambdaFactor;
if(e1 > epeak) {
preStepLambda = GetLambdaForScaledEnergy(e);
mfpKinEnergy = e;
G4double preStepLambda1 = GetLambdaForScaledEnergy(e1);
if(preStepLambda1 > preStepLambda) {
mfpKinEnergy = e1;
preStepLambda = preStepLambda1;
}
} else {
preStepLambda = fFactor*theCrossSectionMax[currentCoupleIndex];
mfpKinEnergy = epeak;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
const G4Step& step)
{
@@ -1700,7 +1642,11 @@ G4VParticleChange* G4VEnergyLossProcess::PostStepDoIt(const G4Track& track,
if(secParticles[i]) {
G4Track* t = new G4Track(secParticles[i], time, track.GetPosition());
t->SetTouchableHandle(track.GetTouchableHandle());
t->SetWeight(weight);
if (biasManager) {
t->SetWeight(biasManager->GetWeight(i));
} else {
t->SetWeight(weight);
}
if(i < num0) { t->SetCreatorModelIndex(secID); }
else { t->SetCreatorModelIndex(biasID); }
@@ -1959,8 +1905,7 @@ G4double G4VEnergyLossProcess::CrossSectionPerVolume(
particle, kineticEnergy,
(*theCuts)[currentCoupleIndex]));
}
if(cross < 0.0) { cross = 0.0; }
return cross;
return std::max(cross, 0.0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1968,10 +1913,8 @@ G4double G4VEnergyLossProcess::CrossSectionPerVolume(
G4double G4VEnergyLossProcess::MeanFreePath(const G4Track& track)
{
DefineMaterial(track.GetMaterialCutsCouple());
preStepLambda = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio);
G4double x = DBL_MAX;
if(0.0 < preStepLambda) { x = 1.0/preStepLambda; }
return x;
G4double cs = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio);
return (0.0 < cs) ? 1.0/cs : DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -2318,8 +2261,7 @@ G4VEnergyLossProcess::ActivateSecondaryBiasing(const G4String& region,
void G4VEnergyLossProcess::SetIonisation(G4bool val)
{
isIonisation = val;
if(val) { aGPILSelection = CandidateForSelection; }
else { aGPILSelection = NotCandidateForSelection; }
aGPILSelection = (val) ? CandidateForSelection : NotCandidateForSelection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -2409,7 +2351,7 @@ void G4VEnergyLossProcess::PrintWarning(G4String tit, G4double val)
void G4VEnergyLossProcess::ProcessDescription(std::ostream& out) const
{
if(particle) { StreamInfo(out, *particle, G4String("<br>\n")); }
if(particle) { StreamInfo(out, *particle, true); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMscModel.cc 105745 2017-08-16 13:14:37Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMultipleScattering.cc 107364 2017-11-09 10:53:25Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -350,15 +349,14 @@ void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::StreamInfo(std::ostream& outFile,
const G4ParticleDefinition& part, G4String endOfLine) const
const G4ParticleDefinition& part, G4bool rst) const
{
outFile << endOfLine << GetProcessName() << ": ";
if (endOfLine != G4String("<br>\n")) {
outFile << " for " << part.GetParticleName();
}
outFile << " SubType= " << GetProcessSubType() << endOfLine;
StreamProcessInfo(outFile, endOfLine);
modelManager->DumpModelList(outFile, verboseLevel, endOfLine);
G4String indent = (rst ? " " : "");
outFile << G4endl << indent << GetProcessName() << ": ";
if (!rst) outFile << " for " << part.GetParticleName();
outFile << " SubType= " << GetProcessSubType() << G4endl;
StreamProcessInfo(outFile);
modelManager->DumpModelList(outFile, verboseLevel);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -733,7 +731,7 @@ void G4VMultipleScattering::SetIonisation(G4VEnergyLossProcess* p)
void G4VMultipleScattering::ProcessDescription(std::ostream& outFile) const
{
if(firstParticle) {
StreamInfo(outFile, *firstParticle, G4String("<br>\n"));
StreamInfo(outFile, *firstParticle, true);
}
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ionEffectiveCharge.cc 108386 2018-02-09 15:38:32Z gcosmo $
//
// -------------------------------------------------------------------
//