Files
geant4/source/processes/electromagnetic/lowenergy/include/G4DNADingfelderChargeChangeTotalCrossSectionPolicy.icc
T
2016-06-09 14:44:26 +02:00

145 lines
5.9 KiB
Plaintext

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * 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. 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 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: G4DNADingfelderChargeChangeTotalCrossSectionPolicy.icc,v 1.3 2006/06/29 19:33:52 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
#ifdef G4DNADINGFELDERCHARGECHANGETOTALCROSSSECTIONPOLICY_HH
#include "Randomize.hh"
template <typename IncomingParticlePolicy, typename EnergyLimitsPolicy>
G4double G4DNADingfelderChargeChangeTotalCrossSectionPolicy<IncomingParticlePolicy, EnergyLimitsPolicy> :: TotalCrossSection(G4double k, G4int z)
{
if (k < EnergyLimitsPolicy::lowEnergyLimit)
{
if (EnergyLimitsPolicy::zeroBelowLowEnergyLimit)
return 0;
k=EnergyLimitsPolicy::lowEnergyLimit;
}
else if (k > EnergyLimitsPolicy::highEnergyLimit)
{
if (EnergyLimitsPolicy::zeroAboveHighEnergyLimit)
return 0;
k=EnergyLimitsPolicy::highEnergyLimit;
}
G4int i(IncomingParticlePolicy::NumberOfPartialCrossSections());
G4double totalCrossSection(0.);
while (i>0)
{
i--;
totalCrossSection+=PartialCrossSection(k, z, i);
}
return totalCrossSection;
}
template <typename IncomingParticlePolicy, typename EnergyLimitsPolicy>
G4int G4DNADingfelderChargeChangeTotalCrossSectionPolicy<IncomingParticlePolicy, EnergyLimitsPolicy> :: RandomizePartialCrossSection(G4double k, G4int z)
{
const G4int n(IncomingParticlePolicy::NumberOfPartialCrossSections());
G4double * values(new G4double[n]);
G4double value(0);
G4int i(n);
while (i>0)
{
i--;
values[i]=PartialCrossSection(k, z, i);
value+=values[i];
}
value*=G4UniformRand();
i=n;
while (i>0)
{
i--;
if (values[i]>value)
break;
value-=values[i];
}
delete[] values;
return i;
}
template <typename IncomingParticlePolicy, typename EnergyLimitsPolicy>
G4double G4DNADingfelderChargeChangeTotalCrossSectionPolicy<IncomingParticlePolicy, EnergyLimitsPolicy> :: PartialCrossSection(G4double k, G4int /* z */, G4int index)
{
//
// sigma(T) = f0 10 ^ y(std::log10(T/eV))
//
// / a0 x + b0 x < x0
// |
// y(x) = < a0 x + b0 - c0 (x - x0)^d0 x0 <= x < x1
// |
// \ a1 x + b1 x >= x1
//
//
// f0, a0, a1, b0, b1, c0, d0, x0, x1 are parameters that change for protons and helium (0, +, ++)
//
// f0 has been added to the code in order to manage partial (shell-dependent) cross sections (if no shell dependence is present. f0=1. Sum of f0 over the considered shells should give 1)
//
// From Rad. Phys. and Chem. 59 (2000) 255-275, M. Dingfelder et al.
// Inelastic-collision cross sections of liquid water for interactions of energetic proton
//
if (IncomingParticlePolicy::x1[index]<IncomingParticlePolicy::x0[index])
{
//
// if x1 < x0 means that x1 and b1 will be calculated with the following formula (this piece of code is run on all alphas and not on protons)
//
// x1 = x0 + ((a0 - a1)/(c0 * d0)) ^ (1 / (d0 - 1))
//
// b1 = (a0 - a1) * x1 + b0 - c0 * (x1 - x0) ^ d0
//
IncomingParticlePolicy::x1[index]=IncomingParticlePolicy::x0[index] + std::pow((IncomingParticlePolicy::a0[index] - IncomingParticlePolicy::a1[index]) / (IncomingParticlePolicy::c0[index] * IncomingParticlePolicy::d0[index]), 1. / (IncomingParticlePolicy::d0[index] - 1.));
IncomingParticlePolicy::b1[index]=(IncomingParticlePolicy::a0[index] - IncomingParticlePolicy::a1[index]) * IncomingParticlePolicy::x1[index] + IncomingParticlePolicy::b0[index] - IncomingParticlePolicy::c0[index] * std::pow(IncomingParticlePolicy::x1[index] - IncomingParticlePolicy::x0[index], IncomingParticlePolicy::d0[index]);
}
G4double x(std::log10(k/eV));
G4double y;
if (x<IncomingParticlePolicy::x0[index])
y=IncomingParticlePolicy::a0[index] * x + IncomingParticlePolicy::b0[index];
else if (x<IncomingParticlePolicy::x1[index])
y=IncomingParticlePolicy::a0[index] * x + IncomingParticlePolicy::b0[index] - IncomingParticlePolicy::c0[index] * std::pow(x - IncomingParticlePolicy::x0[index], IncomingParticlePolicy::d0[index]);
else
y=IncomingParticlePolicy::a1[index] * x + IncomingParticlePolicy::b1[index];
return IncomingParticlePolicy::f0[index] * std::pow(10., y)*m*m;
}
#endif /* G4DNADINGFELDERCHARGECHANGETOTALCROSSSECTIONPOLICY_HH */