Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmSaturation.cc 92921 2015-09-21 15:06:51Z gcosmo $
// $Id: G4EmSaturation.cc 100346 2016-10-18 15:30:36Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -54,22 +54,21 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4EmSaturation::nMaterials = 0;
std::vector<G4double> G4EmSaturation::massFactors;
std::vector<G4double> G4EmSaturation::effCharges;
std::vector<G4double> G4EmSaturation::g4MatData;
std::vector<G4String> G4EmSaturation::g4MatNames;
G4EmSaturation::G4EmSaturation(G4int verb)
: manager(nullptr)
{
verbose = verb;
curMaterial = nullptr;
curBirks = 0.0;
curRatio = 1.0;
curChargeSq = 1.0;
nMaterials = nWarnings = 0;
nWarnings = nG4Birks = 0;
electron = nullptr;
proton = nullptr;
nist = G4NistManager::Instance();
InitialiseG4materials();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -84,62 +83,79 @@ G4double G4EmSaturation::VisibleEnergyDeposition(
const G4MaterialCutsCouple* couple,
G4double length,
G4double edep,
G4double niel)
G4double niel) const
{
if(edep <= 0.0) { return 0.0; }
G4double evis = edep;
G4double bfactor = FindBirksCoefficient(couple->GetMaterial());
G4double bfactor = couple->GetMaterial()->GetIonisation()->GetBirksConstant();
if(bfactor > 0.0) {
G4int pdgCode = p->GetPDGEncoding();
// atomic relaxations for gamma incident
if(22 == pdgCode && electron) {
if(22 == p->GetPDGEncoding()) {
//G4cout << "%% gamma edep= " << edep/keV << " keV " <<manager << G4endl;
evis /= (1.0 + bfactor*edep/manager->GetRange(electron,edep,couple));
evis /= (1.0 + bfactor*edep/
G4LossTableManager::Instance()->GetRange(electron,edep,couple));
// energy loss
} else {
// protections
G4double nloss = niel;
if(nloss < 0.0) { nloss = 0.0; }
G4double nloss = std::max(niel, 0.0);
G4double eloss = edep - nloss;
// neutrons and neutral hadrons
if(0.0 == p->GetPDGCharge() || eloss < 0.0 || length <= 0.0) {
nloss = edep;
eloss = 0.0;
}
} else {
// continues energy loss
if(eloss > 0.0) { eloss /= (1.0 + bfactor*eloss/length); }
// continues energy loss
eloss /= (1.0 + bfactor*eloss/length);
}
// non-ionizing energy loss
if(nloss > 0.0 && proton) {
G4double escaled = nloss*curRatio;
if(nloss > 0.0) {
G4int idx = couple->GetMaterial()->GetIndex();
G4double escaled = nloss*massFactors[idx];
/*
G4cout << "%% p edep= " << nloss/keV << " keV Escaled= "
<< escaled << " MeV in " << couple->GetMaterial()->GetName()
<< " " << p->GetParticleName()
<< G4endl;
*/
G4double range = manager->GetRange(proton,escaled,couple)/curChargeSq;
G4double range = G4LossTableManager::Instance()
->GetRange(proton,escaled,couple)/effCharges[idx];
nloss /= (1.0 + bfactor*nloss/range);
}
evis = eloss + nloss;
}
}
return evis;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmSaturation::InitialiseG4Saturation()
{
nMaterials = G4Material::GetNumberOfMaterials();
massFactors.resize(nMaterials, 1.0);
effCharges.resize(nMaterials, 1.0);
if(0 == nG4Birks) { InitialiseG4materials(); }
for(G4int i=0; i<nMaterials; ++i) {
InitialiseBirksCoefficient((*G4Material::GetMaterialTable())[i]);
}
if(verbose > 0) { DumpBirksCoefficients(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4EmSaturation::FindG4BirksCoefficient(const G4Material* mat)
{
if(0 == nG4Birks) { InitialiseG4materials(); }
G4String name = mat->GetName();
// is this material in the vector?
@@ -152,7 +168,7 @@ G4double G4EmSaturation::FindG4BirksCoefficient(const G4Material* mat)
return g4MatData[j];
}
}
return FindBirksCoefficient(mat);
return 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -160,29 +176,18 @@ G4double G4EmSaturation::FindG4BirksCoefficient(const G4Material* mat)
void G4EmSaturation::InitialiseBirksCoefficient(const G4Material* mat)
{
// electron and proton should exist in any case
if(!manager) {
manager = G4LossTableManager::Instance();
if(!electron) {
electron = G4ParticleTable::GetParticleTable()->FindParticle("e-");
proton = G4ParticleTable::GetParticleTable()->FindParticle("proton");
}
curMaterial = mat;
curBirks = 0.0;
curRatio = 1.0;
curChargeSq = 1.0;
// seach in the run-time list
for(G4int i=0; i<nMaterials; ++i) {
if(mat == matPointers[i]) {
curBirks = mat->GetIonisation()->GetBirksConstant();
curRatio = massFactors[i];
curChargeSq = effCharges[i];
return;
if(!electron || !proton) {
G4Exception("G4EmSaturation::InitialiseBirksCoefficient", "em0001",
FatalException, "both electron and proton should exist");
}
}
G4double curBirks = mat->GetIonisation()->GetBirksConstant();
G4String name = mat->GetName();
curBirks = mat->GetIonisation()->GetBirksConstant();
// material has no Birks coeffitient defined
// seach in the Geant4 list
@@ -196,22 +201,11 @@ void G4EmSaturation::InitialiseBirksCoefficient(const G4Material* mat)
}
}
if(curBirks == 0.0) {
if(0 < nWarnings) {
++nWarnings;
G4ExceptionDescription ed;
ed << "Birks constants are not defined for material " << name
<< " ! \n Define Birks constants for the material"
<< " or not apply saturation.";
G4Exception("G4EmSaturation::InitialiseBirksCoefficient", "em0088",
JustWarning, ed);
}
return;
}
if(curBirks == 0.0) { return; }
// compute mean mass ratio
curRatio = 0.0;
curChargeSq = 0.0;
G4double curRatio = 0.0;
G4double curChargeSq = 0.0;
G4double norm = 0.0;
const G4ElementVector* theElementVector = mat->GetElementVector();
const G4double* theAtomNumDensityVector = mat->GetVecNbOfAtomsPerVolume();
@@ -228,31 +222,26 @@ void G4EmSaturation::InitialiseBirksCoefficient(const G4Material* mat)
curChargeSq /= norm;
// store results
matPointers.push_back(mat);
matNames.push_back(name);
massFactors.push_back(curRatio);
effCharges.push_back(curChargeSq);
nMaterials++;
if(verbose > 0) {
G4cout << "### G4EmSaturation::FindBirksCoefficient Birks coefficient for "
<< name << " " << curBirks*MeV/mm << " mm/MeV" << G4endl;
}
return;
G4int idx = mat->GetIndex();
massFactors[idx] = curRatio;
effCharges[idx] = curChargeSq;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmSaturation::DumpBirksCoefficients()
{
if(nMaterials > 0) {
G4cout << "### Birks coeffitients used in run time" << G4endl;
for(G4int i=0; i<nMaterials; ++i) {
G4double br = matPointers[i]->GetIonisation()->GetBirksConstant();
G4cout << " " << matNames[i] << " "
<< br*MeV/mm << " mm/MeV" << " "
<< br*matPointers[i]->GetDensity()*MeV*cm2/g
<< " g/cm^2/MeV"
<< G4endl;
G4cout << "### Birks coeffitients used in run time" << G4endl;
const G4MaterialTable* mtable = G4Material::GetMaterialTable();
for(G4int i=0; i<nMaterials; ++i) {
const G4Material* mat = (*mtable)[i];
G4double br = mat->GetIonisation()->GetBirksConstant();
if(br > 0.0) {
G4cout << " " << mat->GetName() << " "
<< br*MeV/mm << " mm/MeV" << " "
<< br*mat->GetDensity()*MeV*cm2/g
<< " g/cm^2/MeV massFactor= " << massFactors[i]
<< " effCharge= " << effCharges[i] << G4endl;
}
}
}
@@ -274,6 +263,9 @@ void G4EmSaturation::DumpG4BirksCoefficients()
void G4EmSaturation::InitialiseG4materials()
{
nG4Birks = 4;
g4MatData.reserve(nG4Birks);
// M.Hirschberg et al., IEEE Trans. Nuc. Sci. 39 (1992) 511
// SCSN-38 kB = 0.00842 g/cm^2/MeV; rho = 1.06 g/cm^3
g4MatNames.push_back("G4_POLYSTYRENE");
@@ -288,9 +280,12 @@ void G4EmSaturation::InitialiseG4materials()
// Scallettar et al., Phys. Rev. A25 (1982) 2419.
// NIM A 523 (2004) 275.
// kB = 0.022 g/cm^2/MeV; rho = 1.396 g/cm^3;
// ATLAS Efield = 10 kV/cm provide the strongest effect
// ATLAS Efield = 10 kV/cm provide the strongest effect
// kB = 0.1576*mm/MeV
// A. Kiryunin and P.Strizenec "Geant4 hadronic
// working group meeting " kB = 0.041/9.13 g/cm^2/MeV
g4MatNames.push_back("G4_lAr");
g4MatData.push_back(0.1576*mm/MeV);
g4MatData.push_back(0.032*mm/MeV);
//G4_BARIUM_FLUORIDE
//G4_CESIUM_IODIDE
@@ -300,10 +295,13 @@ void G4EmSaturation::InitialiseG4materials()
//G4_SODIUM_IODIDE
//G4_STILBENE
//G4_lAr
//G4_PbWO4
//G4_PbWO4 - CMS value
g4MatNames.push_back("G4_PbWO4");
g4MatData.push_back(0.0333333*mm/MeV);
//G4_Lucite
nG4Birks = g4MatData.size();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....