76 :maxEnergyTransfer(
DBL_MAX),verbose(verb),isInitialised(false)
89 mass = charge2 = electronDensity = radLength = bg2 = beta2
90 = kineticEnergy = tmax = 0;
93 dedxElectron = dedxPositron = dedxProton = rangeElectron
94 = rangePositron = rangeProton = invRangeElectron = invRangePositron
95 = invRangeProton = mscElectron = dedxMuon = rangeMuon = invRangeMuon = 0;
97 electron = positron = proton = muonPlus = muonMinus = 0;
104 for(
G4int i=0; i<nmat; i++) {
delete couples[i];}
109 delete rangeElectron;
110 delete rangePositron;
113 delete invRangeElectron;
114 delete invRangePositron;
115 delete invRangeProton;
128 if(!isInitialised) Initialisation();
129 G4double kinEnergyFinal = kinEnergy;
130 if(SetupKinematics(part, mat, kinEnergy)) {
134 kinEnergyFinal = 0.0;
135 }
else if(step < linLossLimit*r) {
136 kinEnergyFinal -= step*
ComputeDEDX(kinEnergy,part);
142 return kinEnergyFinal;
152 if(!isInitialised) Initialisation();
153 G4double kinEnergyFinal = kinEnergy;
155 if(SetupKinematics(part, mat, kinEnergy)) {
159 if(step < linLossLimit*r) {
160 kinEnergyFinal += step*
ComputeDEDX(kinEnergy,part);
166 return kinEnergyFinal;
177 if(!isInitialised) Initialisation();
178 if(SetupKinematics(part, mat, kinEnergy)) {
179 if(part == electron || part == positron) {
180 G4double x = stepLength*ComputeValue(kinEnergy, mscElectron);
181 if(x < 0.2) res *= (1.0 + 0.5*x + x*x/3.0);
182 else if(x < 0.9999) res = -std::log(1.0 - x)*stepLength/x;
198 if(!part || !mat || kinEnergy < keV)
return false;
199 if(!isInitialised) Initialisation();
201 if(part != currentParticle) {
203 currentParticle = part;
208 if(mat != currentMaterial) {
211 G4cout <<
"### G4EnergyLossForExtrapolator WARNING:index i= "
212 << i <<
" is out of table - NO extrapolation" <<
G4endl;
215 currentMaterial = mat;
221 if(flag || kinEnergy != kineticEnergy) {
222 kineticEnergy = kinEnergy;
226 bg2 = tau * (tau + 2.0);
227 beta2 = bg2/(gam*gam);
229 if(part == electron) tmax *= 0.5;
230 else if(part != positron) {
232 tmax = 2.0*bg2*electron_mass_c2/(1.0 + 2.0*gam*r + r*r);
234 if(tmax > maxEnergyTransfer) tmax = maxEnergyTransfer;
241void G4EnergyLossForExtrapolator::Initialisation()
243 isInitialised =
true;
245 G4cout <<
"### G4EnergyLossForExtrapolator::Initialisation" <<
G4endl;
257 currentParticleName =
"";
264 for(
G4int i=0; i<nmat; i++) {
266 couples.push_back(couple);
269 dedxElectron = PrepareTable();
270 dedxPositron = PrepareTable();
271 dedxMuon = PrepareTable();
272 dedxProton = PrepareTable();
273 rangeElectron = PrepareTable();
274 rangePositron = PrepareTable();
275 rangeMuon = PrepareTable();
276 rangeProton = PrepareTable();
277 invRangeElectron = PrepareTable();
278 invRangePositron = PrepareTable();
279 invRangeMuon = PrepareTable();
280 invRangeProton = PrepareTable();
281 mscElectron = PrepareTable();
286 G4cout <<
"### G4EnergyLossForExtrapolator Builds electron tables" <<
G4endl;
288 ComputeElectronDEDX(electron, dedxElectron);
293 G4cout <<
"### G4EnergyLossForExtrapolator Builds positron tables" <<
G4endl;
295 ComputeElectronDEDX(positron, dedxPositron);
300 G4cout <<
"### G4EnergyLossForExtrapolator Builds muon tables" <<
G4endl;
302 ComputeMuonDEDX(muonPlus, dedxMuon);
307 G4cout <<
"### G4EnergyLossForExtrapolator Builds proton tables" <<
G4endl;
309 ComputeProtonDEDX(proton, dedxProton);
313 ComputeTrasportXS(electron, mscElectron);
322 for(
G4int i=0; i<nmat; i++) {
336 if(name != currentParticleName) {
339 G4cout <<
"### G4EnergyLossForExtrapolator WARNING:FindParticle fails to find "
354 if(part == electron) x = ComputeValue(kinEnergy, dedxElectron);
355 else if(part == positron) x = ComputeValue(kinEnergy, dedxPositron);
356 else if(part == muonPlus || part == muonMinus) {
357 x = ComputeValue(kinEnergy, dedxMuon);
359 G4double e = kinEnergy*proton_mass_c2/mass;
360 x = ComputeValue(e, dedxProton)*charge2;
371 if(part == electron) x = ComputeValue(kinEnergy, rangeElectron);
372 else if(part == positron) x = ComputeValue(kinEnergy, rangePositron);
373 else if(part == muonPlus || part == muonMinus)
374 x = ComputeValue(kinEnergy, rangeMuon);
376 G4double massratio = proton_mass_c2/mass;
378 x = ComputeValue(e, rangeProton)/(charge2*massratio);
389 if(part == electron) x = ComputeValue(range, invRangeElectron);
390 else if(part == positron) x = ComputeValue(range, invRangePositron);
391 else if(part == muonPlus || part == muonMinus)
392 x = ComputeValue(range, invRangeMuon);
394 G4double massratio = proton_mass_c2/mass;
395 G4double r = range*massratio*charge2;
396 x = ComputeValue(r, invRangeProton)/massratio;
412 mass = electron_mass_c2;
414 currentParticle = part;
418 G4cout <<
"G4EnergyLossForExtrapolator::ComputeElectronDEDX for "
422 for(
G4int i=0; i<nmat; i++) {
430 for(
G4int j=0; j<=nbins; j++) {
436 <<
" e(MeV)= " << e/MeV
437 <<
" dedx(Mev/cm)= " << dedx*cm/MeV
438 <<
" dedx(Mev.cm2/g)= " << dedx/((MeV*mat->
GetDensity())/(g/cm2)) <<
G4endl;
462 currentParticle = part;
471 for(
G4int i=0; i<nmat; i++) {
478 for(
G4int j=0; j<=nbins; j++) {
487 <<
" e(MeV)= " << e/MeV
488 <<
" dedx(Mev/cm)= " << dedx*cm/MeV
489 <<
" dedx(Mev/(g/cm2)= " << dedx/((MeV*mat->
GetDensity())/(g/cm2)) <<
G4endl;
507 currentParticle = part;
516 for(
G4int i=0; i<nmat; i++) {
523 for(
G4int j=0; j<=nbins; j++) {
530 <<
" e(MeV)= " << e/MeV
531 <<
" dedx(Mev/cm)= " << dedx*cm/MeV
551 currentParticle = part;
560 for(
G4int i=0; i<nmat; i++) {
567 for(
G4int j=0; j<=nbins; j++) {
573 G4cout <<
"j= " << j <<
" e(MeV)= " << e/MeV
574 <<
" xs(1/mm)= " << xs*mm <<
G4endl;
std::vector< G4Material * > G4MaterialTable
G4DLLIMPORT std::ostream G4cout
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
static G4Electron * Electron()
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
static G4LossTableManager * Instance()
G4double GetDensity() const
static const G4MaterialTable * GetMaterialTable()
static size_t GetNumberOfMaterials()
G4double GetElectronDensity() const
G4double GetRadlen() const
const G4String & GetName() const
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
static G4MuonMinus * MuonMinus()
static G4MuonPlus * MuonPlus()
G4double GetPDGMass() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
void push_back(G4PhysicsVector *)
G4double Energy(size_t index) const
void PutValue(size_t index, G4double theValue)
static G4Positron * Positron()
static G4Proton * Proton()
void SetPolarAngleLimit(G4double)
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void SetCurrentCouple(const G4MaterialCutsCouple *)
G4double ComputeDEDX(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=DBL_MAX)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)