44G4double G4VRangeToEnergyConverter::sEmin = CLHEP::keV;
45G4double G4VRangeToEnergyConverter::sEmax = 10.*CLHEP::GeV;
47std::vector<G4double>* G4VRangeToEnergyConverter::sEnergy =
nullptr;
49G4int G4VRangeToEnergyConverter::sNbinPerDecade = 50;
50G4int G4VRangeToEnergyConverter::sNbin = 350;
55 if(
nullptr == sEnergy)
58 if(
nullptr == sEnergy)
60 isFirstInstance =
true;
67 FillEnergyVector(CLHEP::keV, 10.0*CLHEP::GeV);
79 sEmax = 10.*CLHEP::GeV;
90 G4cout <<
"G4VRangeToEnergyConverter::Convert() - ";
92 <<
" with Range Cut " << rangeCut/mm <<
"[mm]" <<
G4endl;
99 cut = ConvertForGamma(rangeCut, material);
103 cut = ConvertForElectron(rangeCut, material);
105 const G4double tune = 0.025*CLHEP::mm*CLHEP::g/CLHEP::cm3;
106 const G4double lowen = 30.*CLHEP::keV;
110 cut /= (1.+(1.-cut/lowen)*tune/(rangeCut*material->
GetDensity()));
114 cut = std::max(sEmin, std::min(cut, sEmax));
122 G4double ehigh = std::min(10.*CLHEP::GeV, highedge);
125 FillEnergyVector(lowedge, ehigh);
151 G4double ehigh = std::min(10.*CLHEP::GeV, value);
154 FillEnergyVector(sEmin, ehigh);
159void G4VRangeToEnergyConverter::FillEnergyVector(
const G4double emin,
162 if(emin != sEmin || emax != sEmax ||
nullptr == sEnergy)
166 sNbin = sNbinPerDecade*
G4lrint(std::log10(emax/emin));
167 if(
nullptr == sEnergy) { sEnergy =
new std::vector<G4double>; }
168 sEnergy->resize(sNbin + 1);
169 (*sEnergy)[0] = emin;
170 (*sEnergy)[sNbin] = emax;
172 for(
G4int i=1; i<sNbin; ++i) { (*sEnergy)[i] = emin*
G4Exp(i * fact); }
178G4VRangeToEnergyConverter::ConvertForGamma(
const G4double rangeCut,
190 for (
G4int i=0; i<sNbin; ++i)
195 for (
G4int j=0; j<nelm; ++j)
197 sig += dens[j]*
ComputeValue((*elm)[j]->GetZasInt(), e2);
199 range2 = (sig > 0.0) ? 5./sig :
DBL_MAX;
200 if(i == 0 || range2 < rangeCut)
210 return LiniearInterpolation(e1, e2, range1, range2, rangeCut);
215G4VRangeToEnergyConverter::ConvertForElectron(
const G4double rangeCut,
230 for (
G4int i=0; i<sNbin; ++i)
234 for (
G4int j=0; j<nelm; ++j)
236 dedx2 += dens[j]*
ComputeValue((*elm)[j]->GetZasInt(), e2);
238 range += (dedx1 + dedx2 > 0.0) ? 2*(e2 - e1)/(dedx1 + dedx2) : 0.0;
240 if(range2 < rangeCut)
251 return LiniearInterpolation(e1, e2, range1, range2, rangeCut);
std::vector< const G4Element * > G4ElementVector
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
size_t GetNumberOfElements() const
const G4double * GetAtomicNumDensityVector() const
const G4String & GetName() const
static void SetMaxEnergyCut(const G4double value)
virtual G4double ComputeValue(const G4int Z, const G4double kinEnergy)=0
static G4double GetMaxEnergyCut()
G4int GetVerboseLevel() const
G4VRangeToEnergyConverter()
virtual G4double Convert(const G4double rangeCut, const G4Material *material)
static void SetEnergyRange(const G4double lowedge, const G4double highedge)
static G4double GetLowEdgeEnergy()
virtual ~G4VRangeToEnergyConverter()
static G4double GetHighEdgeEnergy()