Import Geant4 9.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:15:05 +02:00
parent b79225fb37
commit 74cad5e589
3877 changed files with 234205 additions and 167127 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4LossTableBuilder.cc,v 1.27 2008/07/22 15:55:15 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4LossTableBuilder.cc,v 1.32 2009/08/11 17:24:53 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -46,6 +46,7 @@
// 27-03-06 Add bool options isIonisation (V.Ivanchenko)
// 16-01-07 Fill new (not old) DEDX table (V.Ivanchenko)
// 12-02-07 Use G4LPhysicsFreeVector for the inverse range table (V.Ivanchenko)
// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
//
// Class Description:
//
@@ -84,26 +85,23 @@ G4LossTableBuilder::BuildDEDXTable(G4PhysicsTable* dedxTable,
size_t n_vectors = (list[0])->length();
if(0 >= n_vectors) return;
G4bool b;
G4PhysicsVector* pv = (*(list[0]))[0];
size_t nbins = pv->GetVectorLength();
G4double elow = pv->GetLowEdgeEnergy(0);
G4double ehigh = pv->GetLowEdgeEnergy(nbins);
G4PhysicsLogVector* pv0 = static_cast<G4PhysicsLogVector*>((*(list[0]))[0]);
size_t npoints = pv0->GetVectorLength();
for (size_t i=0; i<n_vectors; i++) {
pv = new G4PhysicsLogVector(elow, ehigh, nbins);
G4PhysicsLogVector* pv = new G4PhysicsLogVector(*pv0);
// pv = new G4PhysicsLogVector(elow, ehigh, npoints-1);
pv->SetSpline(splineFlag);
for (size_t j=0; j<nbins; j++) {
for (size_t j=0; j<npoints; j++) {
G4double dedx = 0.0;
G4double energy = pv->GetLowEdgeEnergy(j);
for (size_t k=0; k<n_processes; k++) {
dedx += ((*(list[k]))[i])->GetValue(energy, b);
G4PhysicsVector* pv1 = (*(list[k]))[i];
dedx += (*pv1)[j];
}
pv->PutValue(j, dedx);
G4PhysicsTableHelper::SetPhysicsVector(dedxTable, i, pv);
}
if(splineFlag) pv->FillSecondDerivatives();
G4PhysicsTableHelper::SetPhysicsVector(dedxTable, i, pv);
}
}
@@ -117,33 +115,46 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
size_t n_vectors = dedxTable->length();
if(!n_vectors) return;
G4bool b;
size_t n = 100;
G4double del = 1.0/(G4double)n;
for (size_t i=0; i<n_vectors; i++) {
if (rangeTable->GetFlag(i) || !isIonisation) {
G4PhysicsVector* pv = (*dedxTable)[i];
size_t nbins = pv->GetVectorLength();
size_t bin0 = 0;
G4double elow = pv->GetLowEdgeEnergy(0);
G4double ehigh = pv->GetLowEdgeEnergy(nbins);
G4double dedx1 = pv->GetValue(elow, b);
G4PhysicsLogVector* pv =
static_cast<G4PhysicsLogVector*>((*dedxTable)[i]);
size_t npoints = pv->GetVectorLength();
size_t bin0 = 0;
G4double elow = pv->Energy(0);
G4double ehigh = pv->Energy(npoints-1);
G4double dedx1 = pv->Value(elow);
//G4cout << "nbins= " << nbins << " dedx1= " << dedx1 << G4endl;
// protection for specific cases dedx=0
if(dedx1 == 0.0) {
for (size_t k=1; k<nbins; k++) {
for (size_t k=1; k<npoints; k++) {
bin0++;
elow = pv->GetLowEdgeEnergy(k);
dedx1 = pv->GetValue(elow, b);
elow = pv->Energy(k);
dedx1 = (*pv)[k];
if(dedx1 > 0.0) break;
}
nbins -= bin0;
npoints -= bin0;
}
// G4cout<<"New Range vector" << G4endl;
// G4cout<<"nbins= "<<npoints-1<<" elow= "<<elow<<" ehigh= "<<ehigh<<G4endl;
// initialisation of a new vector
G4PhysicsLogVector* v = new G4PhysicsLogVector(elow, ehigh, nbins);
if(npoints < 2) npoints = 2;
G4PhysicsLogVector* v;
if(0 == bin0) { v = new G4PhysicsLogVector(*pv); }
else { v = new G4PhysicsLogVector(elow, ehigh, npoints-1); }
// dedx is exect zero
if(2 == npoints) {
v->PutValue(0,1000.);
v->PutValue(1,2000.);
G4PhysicsTableHelper::SetPhysicsVector(rangeTable, i, v);
return;
}
v->SetSpline(splineFlag);
// assumed dedx proportional to beta
@@ -151,21 +162,23 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
v->PutValue(0,range);
G4double energy1 = elow;
for (size_t j=1; j<nbins; j++) {
for (size_t j=1; j<npoints; j++) {
G4double energy2 = pv->GetLowEdgeEnergy(j+bin0);
G4double energy2 = pv->Energy(j+bin0);
G4double de = (energy2 - energy1) * del;
G4double energy = energy2 + de*0.5;
G4double sum = 0.0;
for (size_t k=0; k<n; k++) {
energy -= de;
dedx1 = pv->GetValue(energy, b);
if(dedx1 > 0.0) range += de/dedx1;
dedx1 = pv->Value(energy);
if(dedx1 > 0.0) sum += de/dedx1;
}
range += sum;
// G4cout << "Range i= " <<i << " j= " << j << G4endl;
v->PutValue(j,range);
energy1 = energy2;
}
if(splineFlag) v->FillSecondDerivatives();
G4PhysicsTableHelper::SetPhysicsVector(rangeTable, i, v);
}
}
@@ -180,27 +193,24 @@ void G4LossTableBuilder::BuildInverseRangeTable(const G4PhysicsTable* rangeTable
{
size_t n_vectors = rangeTable->length();
if(!n_vectors) return;
G4bool b;
for (size_t i=0; i<n_vectors; i++) {
if (invRangeTable->GetFlag(i) || !isIonisation) {
G4PhysicsVector* pv = (*rangeTable)[i];
size_t nbins = pv->GetVectorLength();
G4double elow = pv->GetLowEdgeEnergy(0);
G4double ehigh = pv->GetLowEdgeEnergy(nbins-1);
G4double rlow = pv->GetValue(elow, b);
G4double rhigh = pv->GetValue(ehigh, b);
size_t npoints = pv->GetVectorLength();
G4double rlow = (*pv)[0];
G4double rhigh = (*pv)[npoints-1];
G4LPhysicsFreeVector* v = new G4LPhysicsFreeVector(nbins,rlow,rhigh);
G4LPhysicsFreeVector* v = new G4LPhysicsFreeVector(npoints,rlow,rhigh);
v->SetSpline(splineFlag);
for (size_t j=0; j<nbins; j++) {
G4double e = pv->GetLowEdgeEnergy(j);
G4double r = pv->GetValue(e, b);
for (size_t j=0; j<npoints; j++) {
G4double e = pv->Energy(j);
G4double r = (*pv)[j];
v->PutValues(j,r,e);
}
v->PutValues(nbins,rhigh+rlow,ehigh);
if(splineFlag) v->FillSecondDerivatives();
G4PhysicsTableHelper::SetPhysicsVector(invRangeTable, i, v);
}