72 algorithm(ionAlgorithm),
75 maxCacheEntries(maxCacheSize) {
77 if(
table ==
nullptr) {
78 G4cerr <<
"G4IonDEDXHandler::G4IonDEDXHandler() "
79 <<
" Pointer to G4VIonDEDXTable object is null-pointer."
84 G4cerr <<
"G4IonDEDXHandler::G4IonDEDXHandler() "
85 <<
" Pointer to G4VIonDEDXScalingAlgorithm object is null-pointer."
90 G4cerr <<
"G4IonDEDXHandler::G4IonDEDXHandler() "
91 <<
" Cache size <=0. Resetting to 5."
126 G4bool isApplicable =
true;
129 isApplicable =
false;
133 G4int atomicNumberIon = particle -> GetAtomicNumber();
134 G4int atomicNumberBase =
157 if(kineticEnergy <= 0.0) dedx = 0.0;
163 factor *=
algorithm -> ScalingFactorDEDX(particle,
174 dedx = factor * value.
dedxVector -> GetValue(scaledKineticEnergy, b);
176 if(dedx < 0.0) dedx = 0.0;
181 G4cout <<
"G4IonDEDXHandler::GetDEDX() E = "
182 << kineticEnergy /
MeV <<
" MeV * "
185 <<
" MeV, dE/dx = " << dedx /
MeV *
cm <<
" MeV/cm"
199 G4int atomicNumberIon = particle -> GetAtomicNumber();
210 G4int atomicNumberIon,
213 G4bool isApplicable =
true;
216 isApplicable =
false;
220 G4int atomicNumberBase =
235 isApplicable =
table -> BuildPhysicsVector(atomicNumberBase, chemFormula);
239 table -> GetPhysicsVector(atomicNumberBase, chemFormula);
243 isApplicable =
table -> BuildPhysicsVector(atomicNumberBase, materialName);
246 table -> GetPhysicsVector(atomicNumberBase, materialName);
253 std::vector<G4PhysicsVector*> dEdxTable;
255 size_t nmbElements =
material -> GetNumberOfElements();
257 for(
size_t i = 0; i < nmbElements; i++) {
259 G4int atomicNumberMat =
G4int((*elementVector)[i] -> GetZ());
261 isApplicable =
table -> BuildPhysicsVector(atomicNumberBase, atomicNumberMat);
266 table -> GetPhysicsVector(atomicNumberBase, atomicNumberMat);
267 dEdxTable.push_back(dEdx);
278 if(dEdxTable.size() > 0) {
280 size_t nmbdEdxBins = dEdxTable[0] -> GetVectorLength();
281 G4double lowerEdge = dEdxTable[0] -> GetLowEdgeEnergy(0);
282 G4double upperEdge = dEdxTable[0] -> GetLowEdgeEnergy(nmbdEdxBins-1);
293 for(
size_t j = 0; j < nmbdEdxBins; j++) {
295 G4double edge = dEdxTable[0] -> GetLowEdgeEnergy(j);
298 for(
size_t i = 0; i < nmbElements; i++) {
300 value += (dEdxTable[i] -> GetValue(edge ,b)) *
301 massFractionVector[i];
304 dEdxBragg -> PutValues(j, edge, value);
307 dEdxBragg -> FillSecondDerivatives();
310 G4cout <<
"G4IonDEDXHandler::BuildPhysicsVector() for ion with Z="
311 << atomicNumberBase <<
" in "
336 G4int atomicNumberIon = particle -> GetAtomicNumber();
337 G4int atomicNumberBase =
351 size_t nmbdEdxBins = value.
dedxVector -> GetVectorLength();
355 value.
dedxVector -> GetLowEdgeEnergy(nmbdEdxBins-1);
367 G4cout <<
"G4IonDEDXHandler::UpdateCacheValue() for "
368 << particle -> GetParticleName() <<
" in "
385 CacheEntryList::iterator* pointerIter =
394 CacheEntryList::iterator* pointerIter1 =
395 new CacheEntryList::iterator();
404 CacheEntryList::iterator* listPointerIter =
405 (CacheEntryList::iterator*) pointerIter2;
409 delete listPointerIter;
414 entry = *(*pointerIter);
431 for(;iter != iter_end; iter++) {
432 void* pointerIter = iter ->
second;
433 CacheEntryList::iterator* listPointerIter =
434 (CacheEntryList::iterator*) pointerIter;
436 delete listPointerIter;
453 G4double atomicMassNumber = particle -> GetAtomicMass();
456 G4cout <<
"# dE/dx table for " << particle -> GetParticleName()
458 <<
" of density " << materialDensity /
g *
cm3
461 <<
"# Projectile mass number A1 = " << atomicMassNumber
463 <<
"# Energy range (per nucleon) of tabulation: "
469 <<
"# ------------------------------------------------------"
472 << std::setw(13) << std::right <<
"E"
473 << std::setw(14) <<
"E/A1"
474 << std::setw(14) <<
"dE/dx"
475 << std::setw(14) <<
"1/rho*dE/dx"
478 << std::setw(13) << std::right <<
"(MeV)"
479 << std::setw(14) <<
"(MeV)"
480 << std::setw(14) <<
"(MeV/cm)"
481 << std::setw(14) <<
"(MeV*cm2/mg)"
483 <<
"# ------------------------------------------------------"
488 G4double energyLowerBoundary = lowerBoundary * atomicMassNumber;
489 G4double energyUpperBoundary = upperBoundary * atomicMassNumber;
493 energyLowerBoundary = std::log(energyLowerBoundary);
494 energyUpperBoundary = std::log(energyUpperBoundary);
497 G4double deltaEnergy = (energyUpperBoundary - energyLowerBoundary) /
501 for(
int i = 0; i < nmbBins + 1; i++) {
509 << std::setw(14) <<
energy / atomicMassNumber /
MeV
510 << std::setw(14) << loss /
MeV *
cm
511 << std::setw(14) << loss / materialDensity / (
MeV*
cm2/(0.001*
g))
std::vector< const G4Element * > G4ElementVector
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
static constexpr double cm3
static constexpr double cm2
static constexpr double second
static constexpr double g
static constexpr double MeV
static constexpr double cm
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void PrintDEDXTable(const G4ParticleDefinition *, const G4Material *, G4double, G4double, G4int, G4bool logScaleEnergy=true)
std::pair< const G4ParticleDefinition *, const G4Material * > G4CacheKey
DEDXTable stoppingPowerTable
CacheIterPointerMap cacheKeyPointers
G4bool BuildDEDXTable(const G4ParticleDefinition *, const G4Material *)
CacheEntryList cacheEntries
G4IonDEDXHandler(G4VIonDEDXTable *tables, G4VIonDEDXScalingAlgorithm *algorithm, const G4String &name, G4int maxCacheSize=5, G4bool splines=true)
G4bool IsApplicable(const G4ParticleDefinition *, const G4Material *)
std::pair< G4int, const G4Material * > G4IonKey
G4CacheValue UpdateCacheValue(const G4ParticleDefinition *, const G4Material *)
G4double GetLowerEnergyEdge(const G4ParticleDefinition *, const G4Material *)
G4VIonDEDXScalingAlgorithm * algorithm
DEDXTableBraggRule stoppingPowerTableBragg
G4double GetUpperEnergyEdge(const G4ParticleDefinition *, const G4Material *)
G4double GetDEDX(const G4ParticleDefinition *, const G4Material *, G4double)
G4CacheValue GetCacheValue(const G4ParticleDefinition *, const G4Material *)
G4double energy(const ThreeVector &p, const G4double m)
const char * name(G4int ptype)
G4PhysicsVector * dedxVector