Import Geant4 8.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:44:26 +02:00
parent 8a51e0bc40
commit 216a75eeb1
8717 changed files with 360418 additions and 141343 deletions
@@ -1,27 +1,30 @@
//
// ********************************************************************
// * DISCLAIMER *
// * License and Disclaimer *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmModelManager.cc,v 1.31 2005/11/29 08:06:32 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-00 $
// $Id: G4EmModelManager.cc,v 1.36 2006/06/29 19:55:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
// -------------------------------------------------------------------
//
@@ -53,6 +56,8 @@
// 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko)
// 18-08-05 Fix cut for e+e- pair production (V.Ivanchenko)
// 29-11-05 Add protection for arithmetic operations with cut=DBL_MAX (V.Ivanchenko)
// 20-01-06 Introduce G4EmTableType and reducing number of methods (VI)
// 13-05-06 Add GetModel by index method (VI)
//
// Class Description:
//
@@ -181,7 +186,8 @@ void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p,
G4VEmFluctuationModel* fm, const G4Region* r)
{
if(!p) {
G4cout << "G4EmModelManager::AddEmModel WARNING: no model defined." << G4endl;
G4cout << "G4EmModelManager::AddEmModel WARNING: no model defined."
<< G4endl;
return;
}
models.push_back(p);
@@ -209,7 +215,8 @@ void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::UpdateEmModel(const G4String& nam, G4double emin, G4double emax)
void G4EmModelManager::UpdateEmModel(const G4String& nam,
G4double emin, G4double emax)
{
if (nEmModels) {
for(G4int i=0; i<nEmModels; i++) {
@@ -227,6 +234,19 @@ void G4EmModelManager::UpdateEmModel(const G4String& nam, G4double emin, G4doubl
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmModel* G4EmModelManager::GetModel(G4int i)
{
G4VEmModel* m = 0;
if(i >= 0 && i < nEmModels) m = models[i];
else if(verboseLevel > 0)
G4cout << "G4EmModelManager::GetModel WARNING: "
<< "index " << i << " is wrong Nmodels= "
<< nEmModels << G4endl;
return m;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
const G4ParticleDefinition* sp,
G4double theMinSubRange,
@@ -248,7 +268,8 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
Clear();
G4RegionStore* regionStore = G4RegionStore::GetInstance();
const G4Region* world = regionStore->GetRegion("DefaultRegionForTheWorld", false);
const G4Region* world =
regionStore->GetRegion("DefaultRegionForTheWorld", false);
// Identify the list of regions with different set of models
nRegions = 1;
@@ -308,7 +329,8 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
if (n>0) tmin = std::max(tmin, eHigh[n-1]);
if(1 < verboseLevel) {
G4cout << "Model #" << ii << " <" << model->GetName() << "> for region <";
G4cout << "Model #" << ii
<< " <" << model->GetName() << "> for region <";
if (region) G4cout << region->GetName();
G4cout << "> "
<< " tmin(MeV)= " << tmin/MeV
@@ -351,7 +373,8 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
for(G4int i=0; i<numOfCouples; i++) {
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
const G4ProductionCuts* pcuts = couple->GetProductionCuts();
@@ -374,7 +397,8 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
if( secondaryParticle == G4Gamma::Gamma() ) idx = 0;
cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
if( secondaryParticle == G4Positron::Positron() && cut < DBL_MAX )
cut += (*theCoupleTable->GetEnergyCutsVector(2))[i] + 2.0*electron_mass_c2;
cut += (*theCoupleTable->GetEnergyCutsVector(2))[i] +
2.0*electron_mass_c2;
if( cut < DBL_MAX ) subcut = minSubRange*cut;
}
@@ -385,14 +409,15 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
G4double tcutmin = model->MinEnergyCut(particle, couple);
cut = std::max(cut, tcutmin);
subcut = std::max(subcut, tcutmin);
if(cut < tcutmin) cut = tcutmin;
if(subcut < tcutmin) subcut = tcutmin;
if(1 < verboseLevel) {
G4cout << "The model # " << j
<< "; tcutmin(MeV)= " << tcutmin/MeV
<< "; tcut(MeV)= " << cut/MeV
<< "; tsubcut(MeV)= " << subcut/MeV
<< G4endl;
<< " for " << particle->GetParticleName()
<< G4endl;
}
}
theCuts.push_back(cut);
@@ -417,7 +442,8 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
const G4MaterialCutsCouple* couple)
const G4MaterialCutsCouple* couple,
G4EmTableType tType)
{
// vectors to provide continues dE/dx
@@ -429,11 +455,18 @@ void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4double subcut = 0.0;
if(fTotal == tType) cut = DBL_MAX;
else if(fSubRestricted == tType) subcut = theSubCuts[i];
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::FillDEDXVector() for "
<< couple->GetMaterial()->GetName()
<< " Ecut(MeV)= " << cut/MeV
<< " Ecut(MeV)= " << cut
<< " Esubcut(MeV)= " << subcut
<< " Type " << tType
<< " for " << particle->GetParticleName()
<< G4endl;
}
@@ -444,7 +477,6 @@ void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
dedxLow.resize(nmod);
dedxHigh.resize(nmod);
if(1 < verboseLevel) {
G4cout << "There are " << nmod << " models for "
<< couple->GetMaterial()->GetName()
@@ -464,15 +496,27 @@ void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
e = upperEkin[regModels->ModelIndex(0)];
G4VEmModel* model = models[regModels->ModelIndex(0)];
dedxHigh[0] = 0.0;
if(model) dedxHigh[0] = model->ComputeDEDX(couple,particle,e,cut);
if(model && cut > subcut) {
dedxHigh[0] = model->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0)
dedxHigh[0] -= model->ComputeDEDX(couple,particle,e,subcut);
}
if(nmod > 1) {
for(j=1; j<nmod; j++) {
e = upperEkin[regModels->ModelIndex(j-1)];
dedxLow[j] = models[regModels->ModelIndex(j)]->ComputeDEDX(couple,particle,e,cut);
e = upperEkin[regModels->ModelIndex(j)];
dedxHigh[j] = models[regModels->ModelIndex(j)]->ComputeDEDX(couple,particle,e,cut);
G4int idx = regModels->ModelIndex(j);
dedxLow[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0)
dedxLow[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
if(subcut == cut) dedxLow[j] = 0.0;
e = upperEkin[idx];
dedxHigh[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0)
dedxHigh[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
if(subcut == cut) dedxHigh[j] = 0.0;
}
for(j=1; j<nmod; j++) {
@@ -502,115 +546,20 @@ void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
model = models[regModels->ModelIndex(k)];
G4double dedx = 0.0;
if(model) dedx = model->ComputeDEDX(couple,particle,e,cut)*fac;
if(dedx < 0.0) dedx = 0.0;
if(2 < verboseLevel) {
G4cout << "Material= " << couple->GetMaterial()->GetName()
<< " E(MeV)= " << e/MeV
<< " dEdx(MeV/mm)= " << dedx*mm/MeV
<< " fac= " << fac
<< G4endl;
}
aVector->PutValue(j, dedx);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::FillDEDXVectorForPreciseRange(
G4PhysicsVector* aVector,
const G4MaterialCutsCouple* couple)
{
// vectors to provide continues dE/dx
G4DataVector factor;
G4DataVector dedxLow;
G4DataVector dedxHigh;
G4double e;
size_t i = couple->GetIndex();
if(2 < verboseLevel) {
G4cout << "G4EmModelManager::FillDEDXVectorForPreciseRange() for "
<< couple->GetMaterial()->GetName()
<< G4endl;
}
G4int reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
factor.resize(nmod);
dedxLow.resize(nmod);
dedxHigh.resize(nmod);
if(2 < verboseLevel) {
G4cout << "There are " << nmod << " models for "
<< couple->GetMaterial()->GetName()
<< " at the region #" << reg
<< G4endl;
}
// calculate factors to provide continuity of energy loss
factor[0] = 1.0;
G4int j;
G4int totBinsLoss = aVector->GetVectorLength();
dedxLow[0] = 0.0;
e = upperEkin[regModels->ModelIndex(0)];
G4VEmModel* model = models[regModels->ModelIndex(0)];
dedxHigh[0] = 0.0;
if(model) dedxHigh[0] = model->ComputeDEDX(couple,particle,e,e);
if(nmod > 1) {
for(j=1; j<nmod; j++) {
e = upperEkin[regModels->ModelIndex(j-1)];
dedxLow[j] = models[regModels->ModelIndex(j)]->ComputeDEDX(couple,particle,e,e);
e = upperEkin[regModels->ModelIndex(j)];
dedxHigh[j] = models[regModels->ModelIndex(j)]->ComputeDEDX(couple,particle,e,e);
}
for(j=1; j<nmod; j++) {
if(dedxLow[j] > 0.0) factor[j] = (dedxHigh[j-1]/dedxLow[j] - 1.0);
else factor[j] = 0.0;
}
if(2 < verboseLevel) {
G4cout << "Loop over " << totBinsLoss << " bins start " << G4endl;
}
}
// Calculate energy losses vector
for(j=0; j<totBinsLoss; j++) {
G4double e = aVector->GetLowEdgeEnergy(j);
G4double fac = 1.0;
// Choose a model of energy losses
G4int k = 0;
if (nmod > 1 && e > upperEkin[regModels->ModelIndex(0)]) {
do {
k++;
fac *= (1.0 + factor[k]*upperEkin[regModels->ModelIndex(k-1)]/e);
} while (k<nmod-1 && e > upperEkin[regModels->ModelIndex(k)] );
}
model = models[regModels->ModelIndex(k)];
G4double dedx = 0.0;
if(model) dedx = model->ComputeDEDX(couple,particle,e,e)*fac;
G4double dedx0 = 0.0;
if(model && cut > subcut) {
dedx = model->ComputeDEDX(couple,particle,e,cut);
dedx0 = dedx;
if(subcut > 0.0) dedx -= model->ComputeDEDX(couple,particle,e,subcut);
dedx *= fac;
}
if(dedx < 0.0) dedx = 0.0;
if(2 < verboseLevel) {
G4cout << "Material= " << couple->GetMaterial()->GetName()
<< " E(MeV)= " << e/MeV
<< " dEdx(MeV/mm)= " << dedx*mm/MeV
<< " dEdx0(MeV/mm)= " << dedx0*mm/MeV
<< " fac= " << fac
<< G4endl;
}
@@ -621,28 +570,35 @@ void G4EmModelManager::FillDEDXVectorForPreciseRange(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
const G4MaterialCutsCouple* couple,
G4bool startFromNull)
const G4MaterialCutsCouple* couple,
G4bool startFromNull,
G4EmTableType tType)
{
// vectors to provide continues dE/dx
// vectors to provide continues cross section
G4DataVector factor;
G4DataVector sigmaLow;
G4DataVector sigmaHigh;
G4double e;
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4double tmax = DBL_MAX;
if (fSubRestricted == tType) {
tmax = cut;
cut = theSubCuts[i];
}
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::FillLambdaVector() for particle "
<< particle->GetParticleName()
<< " in " << couple->GetMaterial()->GetName()
<< " Ecut(MeV)= " << cut
<< " Emax(MeV)= " << tmax
<< " Type " << tType
<< G4endl;
}
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4int reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
@@ -665,7 +621,7 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
e = upperEkin[regModels->ModelIndex(0)];
G4VEmModel* model = models[regModels->ModelIndex(0)];
sigmaHigh[0] = 0.0;
if(model) sigmaHigh[0] = model->CrossSection(couple,particle,e,cut,e);
if(model) sigmaHigh[0] = model->CrossSection(couple,particle,e,cut,tmax);
if(2 < verboseLevel) {
G4cout << "### For material " << couple->GetMaterial()->GetName()
@@ -675,7 +631,8 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
<< " Emax(MeV)= " << e/MeV
<< " nbins= " << totBinsLambda
<< G4endl;
G4cout << " model #0 eUp= " << e << " sigmaUp= " << sigmaHigh[0] << G4endl;
G4cout << " model #0 eUp= " << e
<< " sigmaUp= " << sigmaHigh[0] << G4endl;
}
@@ -684,9 +641,11 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
for(j=1; j<nmod; j++) {
e = upperEkin[regModels->ModelIndex(j-1)];
sigmaLow[j] = models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,cut,e);
sigmaLow[j] =
models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,cut,tmax);
e = upperEkin[regModels->ModelIndex(j)];
sigmaHigh[j] = models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,cut,e);
sigmaHigh[j] =
models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,cut,tmax);
if(1 < verboseLevel) {
G4cout << " model #" << j << " eUp= " << e
<< " sigmaUp= " << sigmaHigh[j]
@@ -717,119 +676,15 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
model = models[regModels->ModelIndex(k)];
G4double cross = 0.0;
if(model) cross = model->CrossSection(couple,particle,e,cut,e)*fac;
if(model) cross = model->CrossSection(couple,particle,e,cut,tmax)*fac;
if(j==0 && startFromNull) cross = 0.0;
if(2 < verboseLevel) {
G4cout << "FillLambdaVector: " << j << ". e(MeV)= " << e/MeV
<< " cross(1/mm)= " << cross*mm
<< " fac= " << fac << " k= " << k << " model= " << regModels->ModelIndex(k)
<< G4endl;
}
if(cross < 0.0) cross = 0.0;
aVector->PutValue(j, cross);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmModelManager::FillSubLambdaVector(G4PhysicsVector* aVector,
const G4MaterialCutsCouple* couple,
G4bool startFromNull)
{
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::FillSubLambdaTable() for particle "
<< particle->GetParticleName() << G4endl;
}
// vectors to provide continues dE/dx
G4DataVector factor;
G4DataVector sigmaLow;
G4DataVector sigmaHigh;
G4double e;
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4double subcut = theSubCuts[i];
G4int reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
factor.resize(nmod);
sigmaLow.resize(nmod);
sigmaHigh.resize(nmod);
if(2 < verboseLevel) {
G4cout << "There are " << nmod << " models for "
<< couple->GetMaterial()->GetName() << G4endl;
}
// calculate factors to provide continuity of energy loss
factor[0] = 1.0;
G4int j;
G4int totBinsLambda = aVector->GetVectorLength();
sigmaLow[0] = 0.0;
e = upperEkin[regModels->ModelIndex(0)];
if(2 < verboseLevel) {
G4cout << "### For material " << couple->GetMaterial()->GetName()
<< " are available " << nmod
<< " models"
<< " Ecut(MeV)= " << cut/MeV
<< " nbins= " << totBinsLambda
<< G4endl;
}
G4VEmModel* model = models[regModels->ModelIndex(0)];
sigmaHigh[0] = 0.0;
if(model) sigmaHigh[0] = model->CrossSection(couple,particle,e,subcut,cut);
if(nmod > 1) {
for(j=1; j<nmod; j++) {
e = upperEkin[regModels->ModelIndex(j-1)];
sigmaLow[j] = models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,subcut,cut);
e = upperEkin[regModels->ModelIndex(j)];
sigmaHigh[j] = models[regModels->ModelIndex(j)]->CrossSection(couple,particle,e,subcut,cut);
}
for(j=1; j<nmod; j++) {
if(sigmaLow[j] > 0.0) factor[j] = (sigmaHigh[j-1]/sigmaLow[j] - 1.0);
else factor[j] = 0.0;
}
}
// Calculate energy losses vector
for(j=0; j<totBinsLambda; j++) {
e = aVector->GetLowEdgeEnergy(j);
// Choose a model of energy losses
G4int k = 0;
G4double fac = 1.0;
if (nmod > 1 && e > upperEkin[regModels->ModelIndex(0)]) {
do {
k++;
fac *= (1.0 + factor[k]*upperEkin[regModels->ModelIndex(k-1)]/e);
} while (k<nmod-1 && e > upperEkin[regModels->ModelIndex(k)] );
}
model = models[regModels->ModelIndex(k)];
G4double cross = 0.0;
if(model) cross = model->CrossSection(couple,particle,e,subcut,cut)*fac;
if(j==0 && startFromNull) cross = 0.0;
if(2 < verboseLevel) {
G4cout << "BuildLambdaTable: e(MeV)= " << e/MeV
<< " cross(1/mm)= " << cross*mm
<< " fac= " << fac
<< G4endl;
<< " cross(1/mm)= " << cross*mm
<< " fac= " << fac << " k= " << k
<< " model= " << regModels->ModelIndex(k)
<< G4endl;
}
if(cross < 0.0) cross = 0.0;