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
@@ -0,0 +1,50 @@
//
// ********************************************************************
// * 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: G4AtomicShell.cc,v 1.2 ????
// GEANT4 tag $Name: geant4-09-03 $
//
// Authors: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
// Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
//
// History:
// -----------
// 16 Sept 2001 EG Modified according to a design iteration in the
// LowEnergy category
//
// -------------------------------------------------------------------
#include "G4AtomicShell.hh"
G4AtomicShell::G4AtomicShell(G4int id, G4double energy)
{
identifier = id;
bindingEnergy = energy;
}
G4AtomicShell::~G4AtomicShell()
{}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DummyModel.cc,v 1.3 2007/05/22 17:31:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4DummyModel.cc,v 1.4 2009/04/07 18:39:47 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -51,7 +51,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4DummyModel::G4DummyModel(const G4String& nam)
: G4VEmModel(nam)
: G4VMscModel(nam)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmCalculator.cc,v 1.44 2008/08/03 18:47:15 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmCalculator.cc,v 1.49 2009/11/22 17:58:39 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -126,26 +126,30 @@ G4double G4EmCalculator::GetDEDX(G4double kinEnergy, const G4ParticleDefinition*
const G4MaterialCutsCouple* couple = FindCouple(mat, region);
if(couple && UpdateParticle(p, kinEnergy) ) {
res = manager->GetDEDX(p, kinEnergy, couple);
if(isIon) {
G4double eth = 2.0*MeV/massRatio;
if(kinEnergy > eth) {
G4double x1 = corr->ComputeIonCorrections(p,mat,kinEnergy);
G4double x2 = corr->ComputeIonCorrections(p,mat,eth);
res += x1 - x2*eth/kinEnergy;
/*
G4cout << "### GetDEDX: E= " << kinEnergy << " res= " << res
<< " x1= " << x1 << " x2= " << x2
<< " del= " << x1 - x2*eth/kinEnergy << G4endl;;
*/
}
}
if(FindEmModel(p, currentProcessName, kinEnergy)) {
G4double length = CLHEP::nm;
G4double eloss = res*length;
//G4cout << "### GetDEDX: E= " << kinEnergy << " dedx0= " << res
// << " de= " << eloss << G4endl;;
G4double niel = 0.0;
dynParticle.SetKineticEnergy(kinEnergy);
currentModel->GetChargeSquareRatio(p, mat, kinEnergy);
currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
res = eloss/length;
//G4cout << " de1= " << eloss << " res1= " << res
// << " " << p->GetParticleName() <<G4endl;;
}
}
if(verbose>0) {
G4cout << "G4EmCalculator::GetDEDX: E(MeV)= " << kinEnergy/MeV
<< " DEDX(MeV/mm)= " << res*mm/MeV
<< " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
<< " " << p->GetParticleName()
<< " in " << mat->GetName()
<< " isIon= " << isIon
<< G4endl;
}
}
@@ -306,9 +310,8 @@ G4double G4EmCalculator::GetCrossSectionPerVolume(G4double kinEnergy,
G4int idx = couple->GetIndex();
FindLambdaTable(p, processName);
if(currentLambda) {
G4bool b;
G4double e = kinEnergy*massRatio;
res = (((*currentLambda)[idx])->GetValue(e,b))*chargeSquare;
res = (((*currentLambda)[idx])->Value(e))*chargeSquare;
if(verbose>0) {
G4cout << "E(MeV)= " << kinEnergy/MeV
<< " cross(cm-1)= " << res*cm
@@ -435,11 +438,10 @@ G4double G4EmCalculator::ComputeDEDX(G4double kinEnergy,
<< G4endl;
}
// emulate boundary region for different parameterisations
// emulate smoothing procedure
G4double eth = currentModel->LowEnergyLimit();
// G4cout << "massRatio= " << massRatio << " eth= " << eth << G4endl;
if(eth > 0.05*MeV && eth < 10.*MeV && escaled > eth &&
loweModel != currentModel && loweModel) {
if(loweModel) {
G4double res0 = 0.0;
G4double res1 = 0.0;
if(baseParticle) {
@@ -461,34 +463,38 @@ G4double G4EmCalculator::ComputeDEDX(G4double kinEnergy,
<< " res0= " << res0 << " res1= "
<< res1 << " q2= " << chargeSquare << G4endl;
*/
res *= (1.0 + (res0/res1 - 1.0)*eth/escaled);
res += (res0 - res1)*eth/escaled;
}
if(isIon) {
G4double ethscaled = eth/massRatio;
if(kinEnergy > ethscaled) {
G4double x1 = corr->ComputeIonCorrections(p,mat,kinEnergy);
G4double x2 = corr->ComputeIonCorrections(p,mat,ethscaled);
res += x1 - x2*ethscaled/kinEnergy;
}
// low energy correction for ions
if(isIon) {
G4double length = CLHEP::nm;
const G4Region* r = 0;
const G4MaterialCutsCouple* couple = FindCouple(mat, r);
G4double eloss = res*length;
G4double niel = 0.0;
dynParticle.SetKineticEnergy(kinEnergy);
currentModel->GetChargeSquareRatio(p, mat, kinEnergy);
currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
res = eloss/length;
if(verbose > 1) {
G4cout << "After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
<< " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
<< G4endl;
}
if(verbose > 1) {
G4cout << "After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
<< " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
<< G4endl;
}
}
}
if(verbose > 0) {
G4cout << "E(MeV)= " << kinEnergy/MeV
<< " DEDX(MeV/mm)= " << res*mm/MeV
<< " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
<< " cut(MeV)= " << cut/MeV
<< " " << p->GetParticleName()
<< " in " << currentMaterialName
<< " Zi^2= " << chargeSquare
<< G4endl;
}
if(verbose > 0) {
G4cout << "E(MeV)= " << kinEnergy/MeV
<< " DEDX(MeV/mm)= " << res*mm/MeV
<< " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
<< " cut(MeV)= " << cut/MeV
<< " " << p->GetParticleName()
<< " in " << currentMaterialName
<< " Zi^2= " << chargeSquare
<< G4endl;
}
}
return res;
@@ -744,7 +750,11 @@ G4bool G4EmCalculator::UpdateParticle(const G4ParticleDefinition* p,
G4double kinEnergy)
{
if(p != currentParticle) {
// new particle
currentParticle = p;
dynParticle.SetDefinition(const_cast<G4ParticleDefinition*>(p));
dynParticle.SetKineticEnergy(kinEnergy);
baseParticle = 0;
currentParticleName = p->GetParticleName();
massRatio = 1.0;
@@ -752,35 +762,41 @@ G4bool G4EmCalculator::UpdateParticle(const G4ParticleDefinition* p,
chargeSquare = 1.0;
currentProcess = FindEnergyLossProcess(p);
currentProcessName = "";
if(currentProcess) currentProcessName = currentProcess->GetProcessName();
isIon = false;
if(p->GetParticleType() == "nucleus" &&
currentParticleName != "deuteron" && currentParticleName != "triton") {
baseParticle = theGenericIon;
massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
isIon = true;
// G4cout << p->GetParticleName()
// << " in " << currentMaterial->GetName()
// << " e= " << kinEnergy << G4endl;
chargeSquare =
ionEffCharge->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy);
//G4cout << "q2= " << chargeSquare << G4endl;
} else {
isIon = false;
if(currentProcess) {
baseParticle = currentProcess->BaseParticle();
// ionisation process exist
if(currentProcess) {
currentProcessName = currentProcess->GetProcessName();
baseParticle = currentProcess->BaseParticle();
if(baseParticle) {
massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
G4double q = baseParticle->GetPDGCharge()/eplus;
chargeSquare /= (q*q);
}
// base particle is used
if(baseParticle) {
massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
G4double q = p->GetPDGCharge()/baseParticle->GetPDGCharge();
chargeSquare = q*q;
}
if(p->GetParticleType() == "nucleus"
&& currentParticleName != "deuteron"
&& currentParticleName != "triton"
&& currentParticleName != "alpha+"
&& currentParticleName != "helium"
&& currentParticleName != "hydrogen"
) {
isIon = true;
massRatio = theGenericIon->GetPDGMass()/p->GetPDGMass();
baseParticle = theGenericIon;
// G4cout << p->GetParticleName()
// << " in " << currentMaterial->GetName()
// << " e= " << kinEnergy << G4endl;
}
}
}
// Effective charge for ions
if(isIon) {
chargeSquare =
ionEffCharge->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy)
corr->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy)
* corr->EffectiveChargeCorrection(p,currentMaterial,kinEnergy);
if(currentProcess) {
currentProcess->SetDynamicMassCharge(massRatio,chargeSquare);
@@ -809,6 +825,15 @@ const G4ParticleDefinition* G4EmCalculator::FindParticle(const G4String& name)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4ParticleDefinition* G4EmCalculator::FindIon(G4int Z, G4int A)
{
const G4ParticleDefinition* p =
G4ParticleTable::GetParticleTable()->FindIon(Z,A,0,Z);
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4Material* G4EmCalculator::FindMaterial(const G4String& name)
{
if(name != currentMaterialName) {
@@ -891,21 +916,24 @@ void G4EmCalculator::FindLambdaTable(const G4ParticleDefinition* p,
G4String partname = p->GetParticleName();
const G4ParticleDefinition* part = p;
if(isIon) part = theGenericIon;
if(isIon) { part = theGenericIon; }
// energy loss process
G4LossTableManager* lManager = G4LossTableManager::Instance();
const std::vector<G4VEnergyLossProcess*> vel =
lManager->GetEnergyLossProcessVector();
lManager->GetEnergyLossProcessVector();
G4int n = vel.size();
for(G4int i=0; i<n; i++) {
if((vel[i])->GetProcessName() == currentName &&
(vel[i])->Particle() == part)
{
currentLambda = (vel[i])->LambdaTable();
isApplicable = true;
break;
}
{
currentLambda = (vel[i])->LambdaTable();
isApplicable = true;
break;
}
}
// discrete process
if(!currentLambda) {
const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector();
G4int n = vem.size();
@@ -919,6 +947,8 @@ void G4EmCalculator::FindLambdaTable(const G4ParticleDefinition* p,
}
}
}
// msc process
if(!currentLambda) {
const std::vector<G4VMultipleScattering*> vmsc =
lManager->GetMultipleScatteringVector();
@@ -942,26 +972,26 @@ G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
const G4String& processName,
G4double kinEnergy)
{
G4bool res = false;
isApplicable = false;
if(!p) {
G4cout << "G4EmCalculator::FindEmModel WARNING: no particle defined"
<< G4endl;
return res;
return isApplicable;
}
G4String partname = p->GetParticleName();
const G4ParticleDefinition* part = p;
G4double scaledEnergy = kinEnergy*massRatio;
if(isIon) part = theGenericIon;
if(isIon) { part = theGenericIon; }
if(verbose > 1) {
G4cout << "G4EmCalculator::FindEmModel for " << partname
<< " (type= " << p->GetParticleType()
<< ") and " << processName << " at e(MeV)= " << scaledEnergy;
<< ") and " << processName << " at E(MeV)= " << scaledEnergy;
if(p != part) G4cout << " GenericIon is the base particle";
G4cout << G4endl;
}
// Search for the process
// Search for energy loss process
currentName = processName;
currentModel = 0;
loweModel = 0;
@@ -970,32 +1000,32 @@ G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
const std::vector<G4VEnergyLossProcess*> vel =
lManager->GetEnergyLossProcessVector();
G4int n = vel.size();
G4VEnergyLossProcess* elproc = 0;
for(G4int i=0; i<n; i++) {
// G4cout << "i= " << i << " part= "
// << (vel[i])->Particle()->GetParticleName()
// << " proc= " << (vel[i])->GetProcessName() << G4endl;
if((vel[i])->GetProcessName() == currentName &&
(vel[i])->Particle() == part)
{
const G4ParticleDefinition* bp = (vel[i])->BaseParticle();
// G4cout << "i= " << i << " bp= " << bp << G4endl;
if(!bp) {
currentModel = (vel[i])->SelectModelForMaterial(scaledEnergy, idx);
loweModel = (vel[i])->SelectModelForMaterial(keV, idx);
isApplicable = true;
break;
if((vel[i])->GetProcessName() == currentName) {
if(baseParticle) {
if((vel[i])->Particle() == baseParticle) {
elproc = vel[i];
break;
}
} else {
for(G4int j=0; j<n; j++) {
if((vel[j])->Particle() == bp) {
currentModel = (vel[j])->SelectModelForMaterial(scaledEnergy, idx);
loweModel = (vel[j])->SelectModelForMaterial(keV, idx);
isApplicable = true;
break;
}
if((vel[i])->Particle() == part) {
elproc = vel[i];
break;
}
}
}
}
if(elproc) {
currentModel = elproc->SelectModelForMaterial(scaledEnergy, idx);
G4double eth = currentModel->LowEnergyLimit();
loweModel = elproc->SelectModelForMaterial(eth - CLHEP::eV, idx);
}
// Search for discrete process
if(!currentModel) {
const std::vector<G4VEmProcess*> vem = lManager->GetEmProcessVector();
G4int n = vem.size();
@@ -1004,12 +1034,14 @@ G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
(vem[i])->Particle() == part)
{
currentModel = (vem[i])->SelectModelForMaterial(kinEnergy, idx);
loweModel = (vem[i])->SelectModelForMaterial(keV, idx);
isApplicable = true;
G4double eth = currentModel->LowEnergyLimit();
loweModel = (vem[i])->SelectModelForMaterial(eth - CLHEP::eV, idx);
break;
}
}
}
// Search for msc process
if(!currentModel) {
const std::vector<G4VMultipleScattering*> vmsc =
lManager->GetMultipleScatteringVector();
@@ -1019,14 +1051,25 @@ G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
(vmsc[i])->Particle() == part)
{
currentModel = (vmsc[i])->SelectModelForMaterial(kinEnergy, idx);
loweModel = (vmsc[i])->SelectModelForMaterial(keV, idx);
isApplicable = true;
G4double eth = currentModel->LowEnergyLimit();
loweModel = (vmsc[i])->SelectModelForMaterial(eth - CLHEP::eV, idx);
break;
}
}
}
if(currentModel) res = true;
return res;
if(currentModel) {
if(loweModel == currentModel) { loweModel = 0; }
isApplicable = true;
if(verbose > 1) {
G4cout << "Model <" << currentModel->GetName()
<< "> Emin(MeV)= " << currentModel->LowEnergyLimit()/MeV;
if(loweModel) {
G4cout << " LowEnergy model <" << loweModel->GetName() << ">";
}
G4cout << G4endl;
}
}
return isApplicable;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1037,16 +1080,17 @@ G4VEnergyLossProcess* G4EmCalculator::FindEnergyLossProcess(
G4VEnergyLossProcess* elp = 0;
G4String partname = p->GetParticleName();
const G4ParticleDefinition* part = p;
if(p->GetParticleType() == "nucleus" &&
partname != "deuteron" &&
partname != "triton") part = G4GenericIon::GenericIon();
partname != "triton") { part = theGenericIon; }
G4LossTableManager* lManager = G4LossTableManager::Instance();
const std::vector<G4VEnergyLossProcess*> vel =
lManager->GetEnergyLossProcessVector();
G4int n = vel.size();
for(G4int i=0; i<n; i++) {
if((vel[i])->Particle() == part) {
if( (vel[i])->Particle() == part ) {
elp = vel[i];
break;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmConfigurator.cc,v 1.3 2008/11/21 12:30:29 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmConfigurator.cc,v 1.6 2009/11/22 19:48:30 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -66,7 +66,7 @@ enum PType {unknown=0, eloss, discrete, msc};
G4EmConfigurator::G4EmConfigurator()
{
index = 1;
index = -10;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -116,7 +116,9 @@ void G4EmConfigurator::SetExtraEmModel(const G4String& particleName,
AddExtraEmModel(particleName, mod, fm);
G4String fname = "";
if(fm) fname = fm->GetName();
AddModelForRegion(particleName, processName, mod->GetName(), regionName,
G4String mname = "";
if(mod) mname = mod->GetName();
AddModelForRegion(particleName, processName, mname, regionName,
emin, emax, fname);
}
@@ -153,7 +155,7 @@ void G4EmConfigurator::SetModelForRegion(const G4String& particleName,
//G4cout << " G4EmConfigurator::SetModelForRegion" << G4endl;
// new set
index--;
--index;
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
G4ParticleTable::GetParticleTable()->GetIterator();
@@ -202,7 +204,11 @@ void G4EmConfigurator::SetModelForRegion(const G4String& particleName,
//G4cout << "Search model " << modelName << " in " << nm << G4endl;
for(G4int i=0; i<nm; i++) {
if(modelName == modelList[i]->GetName() &&
G4String mname = "";
if(modelList[i]) mname = modelList[i]->GetName();
G4String fname = "";
if(flucModelList[i]) fname = flucModelList[i]->GetName();
if(modelName == mname && flucModelName == fname &&
(particleList[i] == "" || particleList[i] == particleName) ) {
mod = modelList[i];
fluc = flucModelList[i];
@@ -213,13 +219,22 @@ void G4EmConfigurator::SetModelForRegion(const G4String& particleName,
if("dummy" == modelName) mod = new G4DummyModel();
if(!mod) {
G4cout << "### G4EmConfigurator WARNING: fails to find a model <"
<< modelName << "> for process <"
<< processName << "> and " << particleName
<< G4endl;
if(flucModelName != "")
G4cout << " fluctuation model <"
<< flucModelName << G4endl;
// set fluctuation model for ionisation processes
if(fluc && ptype == eloss) {
G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
p->SetFluctModel(fluc);
} else {
G4cout << "### G4EmConfigurator WARNING: fails to find a model <"
<< modelName << "> for process <"
<< processName << "> and " << particleName
<< G4endl;
if(flucModelName != "") {
G4cout << " fluctuation model <"
<< flucModelName << G4endl;
}
}
} else {
// search for region
@@ -242,19 +257,21 @@ void G4EmConfigurator::SetModelForRegion(const G4String& particleName,
mod->SetLowEnergyLimit(e1);
mod->SetHighEnergyLimit(e2);
//G4cout << "e1= " << e1 << " e2= " << e2 << G4endl;
//G4cout << "index= " << index << " e1= " << e1 << " e2= " << e2 << G4endl;
// added model
if(ptype == eloss) {
G4VEnergyLossProcess* p = reinterpret_cast<G4VEnergyLossProcess*>(proc);
G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
p->AddEmModel(index,mod,fluc,reg);
//G4cout << "### Added eloss model order= " << index << " for "
// << particleName << " and " << processName << " " << mod << G4endl;
} else if(ptype == discrete) {
G4VEmProcess* p = reinterpret_cast<G4VEmProcess*>(proc);
G4VEmProcess* p = static_cast<G4VEmProcess*>(proc);
p->AddEmModel(index,mod,reg);
} else if(ptype == msc) {
G4VMultipleScattering* p = reinterpret_cast<G4VMultipleScattering*>(proc);
//G4cout << "### Added msc model order= " << index << " for "
// << particleName << " and " << processName << " " << mod << G4endl;
G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
p->AddEmModel(index,mod,reg);
}
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmCorrections.cc,v 1.51 2008/12/18 13:01:44 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmCorrections.cc,v 1.54 2009/10/29 17:56:36 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -686,28 +686,21 @@ G4double G4EmCorrections::EffectiveChargeCorrection(const G4ParticleDefinition*
}
massFactor = proton_mass_c2/p->GetPDGMass();
idx = -1;
G4int dz = 1000;
for(G4int i=0; i<nIons; i++) {
if(materialList[i] == mat) {
G4int delz = currentZ - Zion[i];
if(delz < 0) delz = -delz;
if(delz < dz) {
idx = i;
dz = delz;
if(0 == delz) break;
}
if(materialList[i] == mat && currentZ == Zion[i]) {
idx = i;
break;
}
}
// G4cout << " idx= " << idx << " dz= " << dz << G4endl;
if(idx > 0) {
// G4cout << " idx= " << idx << " dz= " << G4endl;
if(idx >= 0) {
if(!ionList[idx]) BuildCorrectionVector();
if(ionList[idx]) curVector = stopData[idx];
}
} else { return factor; }
}
if(curVector) {
G4bool b;
factor = curVector->GetValue(ekin*massFactor,b);
factor = curVector->Value(ekin*massFactor);
if(verbose > 1) {
G4cout << "E= " << ekin << " factor= " << factor << " massfactor= "
<< massFactor << G4endl;
@@ -770,13 +763,12 @@ void G4EmCorrections::BuildCorrectionVector()
<< materialName[idx] << " Ion Z= " << Z << " A= " << A
<< " massRatio= " << massRatio << G4endl;
}
G4bool b;
G4PhysicsLogVector* vv =
new G4PhysicsLogVector(eCorrMin,eCorrMax,nbinCorr);
vv->SetSpline(true);
G4double e, eion, dedx, dedx1;
G4double eth0 = v->GetLowEdgeEnergy(0);
G4double eth0 = v->Energy(0);
G4double escal = eth/massRatio;
G4double qe =
effCharge.EffectiveChargeSquareRatio(ion, curMaterial, escal);
@@ -789,14 +781,14 @@ void G4EmCorrections::BuildCorrectionVector()
//G4cout << "Escal(MeV)= "<<escal<<" dedxt0= " <<dedxt
// << " dedxt1= " << dedx1t << G4endl;
for(G4int i=0; i<nbinCorr; i++) {
e = vv->GetLowEdgeEnergy(i);
for(G4int i=0; i<=nbinCorr; i++) {
e = vv->Energy(i);
escal = e/massRatio;
eion = escal/A;
if(eion <= eth0) {
dedx = v->GetValue(eth0, b)*std::sqrt(eion/eth0);
dedx = v->Value(eth0)*std::sqrt(eion/eth0);
} else {
dedx = v->GetValue(eion, b);
dedx = v->Value(eion);
}
qe = effCharge.EffectiveChargeSquareRatio(curParticle,curMaterial,escal);
if(e <= eth) {
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmElementSelector.cc,v 1.4 2008/08/21 18:53:32 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmElementSelector.cc,v 1.11 2009/09/29 11:31:37 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -57,17 +57,19 @@ G4EmElementSelector::G4EmElementSelector(G4VEmModel* mod,
G4int bins,
G4double emin,
G4double emax,
G4bool spline):
G4bool /*spline*/):
model(mod), material(mat), nbins(bins), cutEnergy(-1.0),
lowEnergy(emin), highEnergy(emax)
{
G4int n = material->GetNumberOfElements();
nElmMinusOne = n - 1;
theElementVector = material->GetElementVector();
element = (*theElementVector)[0];
if(nElmMinusOne > 0) {
for(G4int i=0; i<nElmMinusOne; i++) {
xSections.reserve(n);
for(G4int i=0; i<n; ++i) {
G4PhysicsLogVector* v = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins);
v->SetSpline(spline);
//v->SetSpline(spline);
xSections.push_back(v);
}
}
@@ -79,7 +81,7 @@ G4EmElementSelector::G4EmElementSelector(G4VEmModel* mod,
G4EmElementSelector::~G4EmElementSelector()
{
if(nElmMinusOne > 0) {
for(G4int i=0; i<nElmMinusOne; i++) {
for(G4int i=0; i<=nElmMinusOne; ++i) {
delete xSections[i];
}
}
@@ -100,29 +102,44 @@ void G4EmElementSelector::Initialise(const G4ParticleDefinition* part,
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
G4int i;
G4int n = nElmMinusOne + 1;
G4double* xsec = new G4double[n];
// loop over bins
for(G4int j=0; j<nbins; j++) {
G4double e = (xSections[0])->GetLowEdgeEnergy(j);
for(G4int j=0; j<=nbins; ++j) {
G4double e = (xSections[0])->Energy(j);
model->SetupForMaterial(part, material, e);
cross = 0.0;
//G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl;
for (i=0; i<n; i++) {
for (i=0; i<=nElmMinusOne; ++i) {
cross += theAtomNumDensityVector[i]*
model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e,
cutEnergy, e);
xsec[i] = cross;
}
if(DBL_MIN >= cross) cross = 1.0;
// normalise cross section sum
for (i=0; i<nElmMinusOne; i++) {
xSections[i]->PutValue(j, xsec[i]/cross);
//G4cout << "i= " << i << " xs= " << xsec[i]/cross << G4endl;
xSections[i]->PutValue(j, cross);
}
}
// xSections start from null, so use probabilities from the next bin
if(DBL_MIN >= (*xSections[nElmMinusOne])[0]) {
for (i=0; i<=nElmMinusOne; ++i) {
xSections[i]->PutValue(0, (*xSections[i])[1]);
}
}
// xSections ends with null, so use probabilities from the previous bin
if(DBL_MIN >= (*xSections[nElmMinusOne])[nbins]) {
for (i=0; i<=nElmMinusOne; ++i) {
xSections[i]->PutValue(nbins, (*xSections[i])[nbins-1]);
}
}
// perform normalization
for(G4int j=0; j<=nbins; ++j) {
cross = (*xSections[nElmMinusOne])[j];
// only for positive X-section
if(cross > DBL_MIN) {
for (i=0; i<nElmMinusOne; ++i) {
G4double x = (*xSections[i])[j]/cross;
xSections[i]->PutValue(j, x);
}
}
}
delete [] xsec;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -138,9 +155,10 @@ void G4EmElementSelector::Dump(const G4ParticleDefinition* part)
G4cout << *(xSections[i]) << G4endl;
}
}
G4cout << "Last Element in element vector"
G4cout << "Last Element in element vector "
<< (*theElementVector)[nElmMinusOne]->GetName()
<< G4endl;
G4cout << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmModelManager.cc,v 1.46 2008/10/13 14:56:56 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmModelManager.cc,v 1.58 2009/10/29 18:07:08 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -60,6 +60,8 @@
// 13-05-06 Add GetModel by index method (VI)
// 15-03-07 Add maxCutInRange (V.Ivanchenko)
// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
// 08-04-08 Fixed and simplified initialisation of G4RegionModel (VI)
// 03-08-09 Create internal vectors only it is needed (VI)
//
// Class Description:
//
@@ -83,7 +85,7 @@ G4RegionModels::G4RegionModels(G4int nMod, std::vector<G4int>& indx,
nModelsForRegion = nMod;
theListOfModelIndexes = new G4int [nModelsForRegion];
lowKineticEnergy = new G4double [nModelsForRegion+1];
for (G4int i=0; i<nModelsForRegion; i++) {
for (G4int i=0; i<nModelsForRegion; ++i) {
theListOfModelIndexes[i] = indx[i];
lowKineticEnergy[i] = lowE[i];
}
@@ -112,33 +114,32 @@ G4RegionModels::~G4RegionModels()
#include "G4Gamma.hh"
#include "G4Positron.hh"
#include "G4UnitsTable.hh"
#include "G4DataVector.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4EmModelManager::G4EmModelManager():
nEmModels(0),
nRegions(0),
nCouples(0),
idxOfRegionModels(0),
setOfRegionModels(0),
minSubRange(0.1),
particle(0),
verboseLevel(0)
{
models.clear();
flucModels.clear();
regions.clear();
orderOfModels.clear();
maxCutInRange = 12.*cm;
maxSubCutInRange = 0.7*mm;
theGamma = G4Gamma::Gamma();
thePositron = G4Positron::Positron();
models.reserve(4);
flucModels.reserve(4);
regions.reserve(4);
orderOfModels.reserve(4);
isUsed.reserve(4);
severalModels = true;
currRegionModel = 0;
currModel = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4EmModelManager::~G4EmModelManager()
{
verboseLevel = 0; // no verbosity at destruction
Clear();
}
@@ -149,18 +150,13 @@ void G4EmModelManager::Clear()
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::Clear()" << G4endl;
}
theCuts.clear();
theSubCuts.clear();
if(idxOfRegionModels) delete [] idxOfRegionModels;
if(setOfRegionModels && nRegions) {
for(G4int i=0; i<nRegions; i++) {
delete (setOfRegionModels[i]);
size_t n = setOfRegionModels.size();
if(n > 0) {
for(size_t i=0; i<n; ++i) {
delete setOfRegionModels[i];
setOfRegionModels[i] = 0;
}
delete [] setOfRegionModels;
}
idxOfRegionModels = 0;
setOfRegionModels = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -177,6 +173,7 @@ void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p,
flucModels.push_back(fm);
regions.push_back(r);
orderOfModels.push_back(num);
isUsed.push_back(0);
p->DefineForRegion(r);
nEmModels++;
}
@@ -186,8 +183,8 @@ void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p,
void G4EmModelManager::UpdateEmModel(const G4String& nam,
G4double emin, G4double emax)
{
if (nEmModels) {
for(G4int i=0; i<nEmModels; i++) {
if (nEmModels > 0) {
for(G4int i=0; i<nEmModels; ++i) {
if(nam == models[i]->GetName()) {
models[i]->SetLowEnergyLimit(emin);
models[i]->SetHighEnergyLimit(emax);
@@ -218,26 +215,26 @@ G4VEmModel* G4EmModelManager::GetModel(G4int i, G4bool ver)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
const G4ParticleDefinition* sp,
G4double theMinSubRange,
G4int val)
const G4DataVector*
G4EmModelManager::Initialise(const G4ParticleDefinition* p,
const G4ParticleDefinition* secondaryParticle,
G4double minSubRange,
G4int val)
{
verboseLevel = val;
G4String partname = p->GetParticleName();
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::Initialise() for "
<< p->GetParticleName()
<< G4endl;
<< partname << G4endl;
}
// Are models defined?
if(!nEmModels) {
G4Exception("G4EmModelManager::Initialise without any model defined");
if(nEmModels < 1) {
G4Exception("G4EmModelManager::Initialise: no model defined for " + partname);
}
particle = p;
secondaryParticle = sp;
minSubRange = theMinSubRange;
Clear();
particle = p;
Clear(); // needed if run is not first
G4RegionStore* regionStore = G4RegionStore::GetInstance();
const G4Region* world =
regionStore->GetRegion("DefaultRegionForTheWorld", false);
@@ -248,7 +245,7 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
setr.push_back(world);
G4bool isWorld = false;
for (G4int ii=0; ii<nEmModels; ii++) {
for (G4int ii=0; ii<nEmModels; ++ii) {
const G4Region* r = regions[ii];
if ( r == 0 || r == world) {
isWorld = true;
@@ -256,7 +253,7 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
} else {
G4bool newRegion = true;
if (nRegions>1) {
for (G4int j=1; j<nRegions; j++) {
for (G4int j=1; j<nRegions; ++j) {
if ( r == setr[j] ) newRegion = false;
}
}
@@ -266,212 +263,208 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
}
}
}
// Are models defined?
if(!isWorld) {
G4Exception("G4EmModelManager::Initialise: no models defined for " +
partname + " in the World volume");
}
G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
G4int numOfCouples = theCoupleTable->GetTableSize();
idxOfRegionModels = new G4int[numOfCouples+1];
idxOfRegionModels[numOfCouples] = 0;
setOfRegionModels = new G4RegionModels*[nRegions];
size_t numOfCouples = theCoupleTable->GetTableSize();
// prepare vectors, shortcut for the case of only 1 model
if(nRegions > 1 && nEmModels > 1) {
if(numOfCouples > idxOfRegionModels.size()) idxOfRegionModels.resize(numOfCouples);
}
size_t nr = 1;
if(nEmModels > 1) nr = nRegions;
if(nr > setOfRegionModels.size()) setOfRegionModels.resize(nr);
std::vector<G4int> modelAtRegion(nEmModels);
std::vector<G4int> modelOrd(nEmModels);
G4DataVector eLow(nEmModels);
G4DataVector eLow(nEmModels+1);
G4DataVector eHigh(nEmModels);
G4int nmax = nEmModels;
// Order models for regions
for (G4int reg=0; reg<nRegions; reg++) {
for (G4int reg=0; reg<nRegions; ++reg) {
const G4Region* region = setr[reg];
G4int n = 0;
if(isWorld || 0 < reg) {
for (G4int ii=0; ii<nEmModels; ++ii) {
for (G4int ii=0; ii<nEmModels; ii++) {
G4VEmModel* model = models[ii];
if ( region == regions[ii] ) {
G4VEmModel* model = models[ii];
if ( region == regions[ii] ) {
G4double tmin = model->LowEnergyLimit();
G4double tmax = model->HighEnergyLimit();
G4int ord = orderOfModels[ii];
G4bool push = true;
G4bool insert = false;
G4int idx = n;
G4double tmin = model->LowEnergyLimit();
G4double tmax = model->HighEnergyLimit();
G4int ord = orderOfModels[ii];
G4bool push = true;
G4bool insert = false;
G4int idx = n;
if(1 < verboseLevel) {
G4cout << "Model #" << ii
<< " <" << model->GetName() << "> for region <";
if (region) G4cout << region->GetName();
G4cout << "> "
<< " tmin(MeV)= " << tmin/MeV
<< "; tmax(MeV)= " << tmax/MeV
if(1 < verboseLevel) {
G4cout << "Model #" << ii
<< " <" << model->GetName() << "> for region <";
if (region) G4cout << region->GetName();
G4cout << "> "
<< " tmin(MeV)= " << tmin/MeV
<< "; tmax(MeV)= " << tmax/MeV
<< "; order= " << ord
<< G4endl;
}
<< G4endl;
}
if (n == 0) n++;
else {
tmin = std::min(tmin, eHigh[n-1]);
if(tmin >= tmax) push = false;
else {
if(n > 0) {
// high energy model
if(tmin == eHigh[n-1] && tmax > eHigh[n-1]) n++;
else if (tmax > eHigh[n-1]) {
// compare order of models
for(G4int k = n-1; k>=0; k--) {
if (ord >= modelOrd[k]) {
tmin = std::max(tmin, eHigh[k]);
if(k < n-1) n = k + 2;
break;
} else if (tmin > eLow[k]) {
eHigh[k] = tmin;
n = k + 2;
break;
} else if (tmin == eLow[k]) {
n = k + 1;
break;
}
// extend energy range to previous models
tmin = std::min(tmin, eHigh[n-1]);
tmax = std::max(tmax, eLow[0]);
//G4cout << "tmin= " << tmin << " tmax= "
// << tmax << " ord= " << ord <<G4endl;
// empty energy range
if( tmax - tmin <= eV) push = false;
// low-energy model
else if (tmax == eLow[0]) {
push = false;
insert = true;
idx = 0;
// resolve intersections
} else if(tmin < eHigh[n-1]) {
// compare order
for(G4int k=0; k<n; ++k) {
// new model has lower application
if(ord >= modelOrd[k]) {
if(tmin < eHigh[k] && tmin >= eLow[k]) tmin = eHigh[k];
if(tmax <= eHigh[k] && tmax > eLow[k]) tmax = eLow[k];
if(tmax > eHigh[k] && tmin < eLow[k]) {
if(tmax - eHigh[k] > eLow[k] - tmin) tmin = eHigh[k];
else tmax = eLow[k];
}
if(tmin < eLow[0]) n = 1;
idx = n - 1;
// low energy model
} else {
tmax = std::max(tmax, eLow[0]);
insert = true;
push = false;
if( tmax - tmin <= eV) {
push = false;
break;
}
}
}
//G4cout << "tmin= " << tmin << " tmax= "
// << tmax << " push= " << push << " idx= " << idx <<G4endl;
if(push) {
if (tmax == eLow[0]) {
push = false;
insert = true;
idx = 0;
if(tmax <= eLow[0]) tmax = eLow[0];
else {
for(G4int k=0; k<n; k++) {
if (ord >= modelOrd[k]) {
if(k == 0) {
if(tmin < eLow[0]) tmax = eLow[0];
else insert = false;
break;
} else {
insert = false;
break;
}
} else if(tmax < eHigh[k]) {
idx = k;
if(k > 0) tmin = eLow[k];
eLow[k] = tmax;
break;
} else if(tmax == eHigh[k]) {
insert = false;
push = true;
idx = k;
if(k > 0) tmin = eLow[k];
else tmin = std::min(tmin,eLow[0]);
break;
} else {
// continue resolve intersections
} else if(tmin < eHigh[n-1]) {
// last energy interval
if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
eHigh[n-1] = tmin;
// first energy interval
} else if(tmin <= eLow[0] && tmax < eHigh[0]) {
eLow[0] = tmax;
push = false;
insert = true;
idx = 0;
} else {
// find energy interval to replace
for(G4int k=0; k<n; ++k) {
if(tmin <= eLow[k] && tmax >= eHigh[k]) {
push = false;
modelAtRegion[k] = ii;
modelOrd[k] = ord;
if(k == 0) eLow[idx] = std::min(tmin,eLow[0]);
}
isUsed[ii] = 1;
}
}
}
if(insert && idx < n) n++;
else insert = false;
}
}
}
if(n > nmax) {
nmax = n;
modelAtRegion.resize(nmax);
modelOrd.resize(nmax);
eLow.resize(nmax);
eHigh.resize(nmax);
}
if(insert) {
for(G4int k=n-2; k>=idx; k--) {
modelAtRegion[k+1] = modelAtRegion[k];
modelOrd[k+1] = modelOrd[k];
eLow[k+1] = eLow[k];
eHigh[k+1] = eHigh[k];
}
}
if (push || insert) {
modelAtRegion[idx] = ii;
modelOrd[idx] = ord;
eLow[idx] = tmin;
eHigh[idx] = tmax;
}
if(insert) {
for(G4int k=n-1; k>=idx; --k) {
modelAtRegion[k+1] = modelAtRegion[k];
modelOrd[k+1] = modelOrd[k];
eLow[k+1] = eLow[k];
eHigh[k+1] = eHigh[k];
}
}
//G4cout << "push= " << push << " insert= " << insert
//<< " idx= " << idx <<G4endl;
if (push || insert) {
++n;
modelAtRegion[idx] = ii;
modelOrd[idx] = ord;
eLow[idx] = tmin;
eHigh[idx] = tmax;
isUsed[ii] = 1;
}
}
} else {
n = 1;
models.push_back(0);
modelAtRegion.push_back(nEmModels);
eLow.push_back(0.0);
eHigh.push_back(DBL_MAX);
}
eLow[0] = 0.0;
if(n >= nmax) eLow.resize(nmax+1);
eLow[n] = eHigh[n-1];
if(1 < verboseLevel) {
G4cout << "New G4RegionModels set with " << n << " models for region <";
if (region) G4cout << region->GetName();
G4cout << "> Elow(MeV)= ";
for(G4int ii=0; ii<=n; ii++) {G4cout << eLow[ii]/MeV << " ";}
for(G4int ii=0; ii<=n; ++ii) {G4cout << eLow[ii]/MeV << " ";}
G4cout << G4endl;
}
G4RegionModels* rm = new G4RegionModels(n, modelAtRegion, eLow, region);
setOfRegionModels[reg] = rm;
if(1 == nEmModels) break;
}
// Access to materials and build cuts
currRegionModel = setOfRegionModels[0];
for(G4int i=0; i<numOfCouples; i++) {
// Access to materials and build cuts
size_t idx = 1;
if(secondaryParticle) {
if( secondaryParticle == G4Gamma::Gamma() ) idx = 0;
else if( secondaryParticle == G4Positron::Positron()) idx = 2;
}
if(numOfCouples > theCuts.size()) {theCuts.resize(numOfCouples);}
if(minSubRange < 1.0 && numOfCouples > theSubCuts.size()) {
theSubCuts.resize(numOfCouples);
}
for(size_t i=0; i<numOfCouples; ++i) {
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
const G4ProductionCuts* pcuts = couple->GetProductionCuts();
G4int reg = nRegions;
do {reg--;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
idxOfRegionModels[i] = reg;
G4int reg = 0;
if(nRegions > 1 && nEmModels > 1) {
reg = nRegions;
do {--reg;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
idxOfRegionModels[i] = reg;
}
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::Initialise() for "
<< material->GetName()
<< " indexOfCouple= " << i
<< " indexOfRegion= " << reg
<< G4endl;
<< material->GetName()
<< " indexOfCouple= " << i
<< " indexOfRegion= " << reg
<< G4endl;
}
G4double cut = DBL_MAX;
G4double cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
G4double subcut = DBL_MAX;
if(secondaryParticle) {
size_t idx = 1;
if( secondaryParticle == theGamma ) idx = 0;
cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i];
if( secondaryParticle == thePositron && cut < DBL_MAX )
cut += (*theCoupleTable->GetEnergyCutsVector(2))[i] +
2.0*electron_mass_c2;
// compute subcut
if( cut < DBL_MAX ) subcut = minSubRange*cut;
if(pcuts->GetProductionCut(idx) < maxCutInRange) {
if( cut < DBL_MAX && minSubRange < 1.0) {
subcut = minSubRange*cut;
G4double rcut = std::min(minSubRange*pcuts->GetProductionCut(idx),
maxSubCutInRange);
G4double tcutmax =
theCoupleTable->ConvertRangeToEnergy(secondaryParticle,
material,maxSubCutInRange);
theCoupleTable->ConvertRangeToEnergy(secondaryParticle,material,rcut);
if(tcutmax < subcut) subcut = tcutmax;
}
}
G4int nm = setOfRegionModels[reg]->NumberOfModels();
for(G4int j=0; j<nm; j++) {
for(G4int j=0; j<nm; ++j) {
G4VEmModel* model = models[setOfRegionModels[reg]->ModelIndex(j)];
@@ -488,15 +481,22 @@ const G4DataVector* G4EmModelManager::Initialise(const G4ParticleDefinition* p,
<< G4endl;
}
}
theCuts.push_back(cut);
theSubCuts.push_back(subcut);
theCuts[i] = cut;
if(minSubRange < 1.0) theSubCuts[i] = subcut;
}
for(G4int jj=0; jj<nEmModels; jj++) {
models[jj]->Initialise(particle, theCuts);
if(flucModels[jj]) flucModels[jj]->InitialiseMe(particle);
// initialize models
G4int nn = 0;
severalModels = true;
for(G4int jj=0; jj<nEmModels; ++jj) {
if(1 == isUsed[jj]) {
++nn;
currModel = models[jj];
currModel->Initialise(particle, theCuts);
if(flucModels[jj]) flucModels[jj]->InitialiseMe(particle);
}
}
if(1 == nn) severalModels = false;
if(1 < verboseLevel) {
G4cout << "G4EmModelManager for " << particle->GetParticleName()
@@ -513,143 +513,68 @@ void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
const G4MaterialCutsCouple* couple,
G4EmTableType tType)
{
G4double e;
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4double subcut = 0.0;
G4double emin = 0.0;
if(fTotal == tType) cut = DBL_MAX;
else if(fSubRestricted == tType) subcut = theSubCuts[i];
else if(fSubRestricted == tType) {
emin = cut;
if(theSubCuts.size() > 0) emin = theSubCuts[i];
}
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::FillDEDXVector() for "
<< couple->GetMaterial()->GetName()
<< " cut(MeV)= " << cut
<< " subcut(MeV)= " << subcut
<< " emin(MeV)= " << emin
<< " Type " << tType
<< " for " << particle->GetParticleName()
<< G4endl;
}
G4int reg = idxOfRegionModels[i];
G4int reg = 0;
if(nRegions > 1 && nEmModels > 1) reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
// vectors to provide continues dE/dx
G4DataVector factor(nmod);
G4DataVector eLow(nmod+1);
G4DataVector dedxLow(nmod);
G4DataVector dedxHigh(nmod);
if(1 < verboseLevel) {
G4cout << "There are " << nmod << " models for "
<< couple->GetMaterial()->GetName()
<< " at the region #" << reg
<< G4endl;
}
// calculate factors to provide continuity of energy loss
factor[0] = 1.0;
G4int j;
G4int totBinsLoss = aVector->GetVectorLength();
dedxLow[0] = 0.0;
eLow[0] = 0.0;
e = regModels->LowEdgeEnergy(1);
eLow[1] = e;
G4VEmModel* model = models[regModels->ModelIndex(0)];
dedxHigh[0] = 0.0;
if(model && cut > subcut) {
dedxHigh[0] = model->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0) {
dedxHigh[0] -= model->ComputeDEDX(couple,particle,e,subcut);
}
}
if(nmod > 1) {
for(j=1; j<nmod; j++) {
e = regModels->LowEdgeEnergy(j);
eLow[j] = e;
G4int idx = regModels->ModelIndex(j);
dedxLow[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0) {
dedxLow[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
}
if(subcut == cut) dedxLow[j] = 0.0;
e = regModels->LowEdgeEnergy(j+1);
eLow[j+1] = e;
dedxHigh[j] = models[idx]->ComputeDEDX(couple,particle,e,cut);
if(subcut > 0.0) {
dedxHigh[j] -= models[idx]->ComputeDEDX(couple,particle,e,subcut);
}
if(subcut == cut) dedxHigh[j] = 0.0;
}
if(1 < verboseLevel) {
G4cout << " model #0"
<< " dedx(" << eLow[0] << ")= " << dedxLow[0]
<< " dedx(" << eLow[1] << ")= " << dedxHigh[0]
<< G4endl;
}
for(j=1; j<nmod; j++) {
if(dedxLow[j] > 0.0) {
factor[j] = (dedxHigh[j-1]/dedxLow[j] - 1.0)*eLow[j];
} else factor[j] = 0.0;
if(1 < verboseLevel) {
G4cout << " model #" << j
<< " dedx(" << eLow[j] << ")= " << dedxLow[j]
<< " dedx(" << eLow[j+1] << ")= " << dedxHigh[j]
<< " factor= " << factor[j]/eLow[j]
<< G4endl;
}
}
if(2 < verboseLevel) {
G4cout << "Loop over " << totBinsLoss << " bins start " << G4endl;
}
}
// Calculate energy losses vector
for(j=0; j<totBinsLoss; j++) {
G4double e = aVector->GetLowEdgeEnergy(j);
G4double fac = 1.0;
//G4cout << "nmod= " << nmod << G4endl;
size_t totBinsLoss = aVector->GetVectorLength();
for(size_t j=0; j<totBinsLoss; ++j) {
// Choose a model of energy losses
G4double e = aVector->Energy(j);
G4double del = 0.0;
// Choose a model of energy losses
G4int k = 0;
if (nmod > 1 && e > eLow[1]) {
do {
k++;
fac *= (1.0 + factor[k]/e);
} while (k+1 < nmod && e > eLow[k+1]);
}
model = models[regModels->ModelIndex(k)];
G4double dedx = 0.0;
G4double dedx0 = 0.0;
if(model && cut > subcut) {
dedx = model->ComputeDEDX(couple,particle,e,cut);
dedx0 = dedx;
if(subcut > 0.0) dedx -= model->ComputeDEDX(couple,particle,e,subcut);
dedx *= fac;
if (nmod > 1) {
k = nmod;
do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
//G4cout << "k= " << k << G4endl;
if(k > 0) {
G4double elow = regModels->LowEdgeEnergy(k);
G4double dedx1 = ComputeDEDX(models[regModels->ModelIndex(k-1)],
couple,elow,cut,emin);
G4double dedx2 = ComputeDEDX(models[regModels->ModelIndex(k)],
couple,elow,cut,emin);
del = (dedx1 - dedx2)*elow/e;
//G4cout << "elow= " << elow
// << " dedx1= " << dedx1 << " dedx2= " << dedx2 << G4endl;
}
}
G4double dedx = ComputeDEDX(models[regModels->ModelIndex(k)],
couple,e,cut,emin) + del;
if(dedx < 0.0) dedx = 0.0;
if(2 < verboseLevel) {
G4cout << "Material= " << couple->GetMaterial()->GetName()
<< " E(MeV)= " << e/MeV
<< " dEdx(MeV/mm)= " << dedx*mm/MeV
<< " dEdx0(MeV/mm)= " << dedx0*mm/MeV
<< " fac= " << fac
<< G4endl;
G4cout << "Material= " << couple->GetMaterial()->GetName()
<< " E(MeV)= " << e/MeV
<< " dEdx(MeV/mm)= " << dedx*mm/MeV
<< " del= " << del*mm/MeV<< " k= " << k
<< " modelIdx= " << regModels->ModelIndex(k)
<< G4endl;
}
aVector->PutValue(j, dedx);
}
@@ -662,126 +587,62 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
G4bool startFromNull,
G4EmTableType tType)
{
G4double e;
size_t i = couple->GetIndex();
G4double cut = theCuts[i];
G4double tmax = DBL_MAX;
if (fSubRestricted == tType) {
tmax = cut;
cut = theSubCuts[i];
if(theSubCuts.size() > 0) cut = theSubCuts[i];
}
G4int reg = 0;
if(nRegions > 1 && nEmModels > 1) reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
if(1 < verboseLevel) {
G4cout << "G4EmModelManager::FillLambdaVector() for particle "
G4cout << "G4EmModelManager::FillLambdaVector() for "
<< particle->GetParticleName()
<< " in " << couple->GetMaterial()->GetName()
<< " Ecut(MeV)= " << cut
<< " Emax(MeV)= " << tmax
<< " Type " << tType
<< " Ecut(MeV)= " << cut
<< " Emax(MeV)= " << tmax
<< " Type " << tType
<< " nmod= " << nmod
<< G4endl;
}
G4int reg = idxOfRegionModels[i];
const G4RegionModels* regModels = setOfRegionModels[reg];
G4int nmod = regModels->NumberOfModels();
// vectors to provide continues dE/dx
G4DataVector factor(nmod);
G4DataVector eLow(nmod+1);
G4DataVector sigmaLow(nmod);
G4DataVector sigmaHigh(nmod);
if(2 < verboseLevel) {
G4cout << "There are " << nmod << " models for "
<< couple->GetMaterial()->GetName() << G4endl;
}
// calculate factors to provide continuity of energy loss
factor[0] = 1.0;
G4int j;
G4int totBinsLambda = aVector->GetVectorLength();
sigmaLow[0] = 0.0;
eLow[0] = 0.0;
e = regModels->LowEdgeEnergy(1);
eLow[1] = e;
G4VEmModel* model = models[regModels->ModelIndex(0)];
sigmaHigh[0] = 0.0;
if(model) sigmaHigh[0] = model->CrossSection(couple,particle,e,cut,tmax);
if(2 < verboseLevel) {
G4cout << "### For material " << couple->GetMaterial()->GetName()
<< " " << nmod
<< " models"
<< " Ecut(MeV)= " << cut/MeV
<< " Emax(MeV)= " << e/MeV
<< " nbins= " << totBinsLambda
<< G4endl;
G4cout << " model #0 eUp= " << e
<< " sigmaUp= " << sigmaHigh[0] << G4endl;
}
if(nmod > 1) {
for(j=1; j<nmod; j++) {
e = regModels->LowEdgeEnergy(j);
eLow[j] = e;
G4int idx = regModels->ModelIndex(j);
sigmaLow[j] = models[idx]->CrossSection(couple,particle,e,cut,tmax);
e = regModels->LowEdgeEnergy(j+1);
eLow[j+1] = e;
sigmaHigh[j] = models[idx]->CrossSection(couple,particle,e,cut,tmax);
}
if(1 < verboseLevel) {
G4cout << " model #0"
<< " sigma(" << eLow[0] << ")= " << sigmaLow[0]
<< " sigma(" << eLow[1] << ")= " << sigmaHigh[0]
<< G4endl;
}
for(j=1; j<nmod; j++) {
if(sigmaLow[j] > 0.0) {
factor[j] = (sigmaHigh[j-1]/sigmaLow[j] - 1.0)*eLow[j];
} else factor[j] = 0.0;
if(1 < verboseLevel) {
G4cout << " model #" << j
<< " sigma(" << eLow[j] << ")= " << sigmaLow[j]
<< " sigma(" << eLow[j+1] << ")= " << sigmaHigh[j]
<< " factor= " << factor[j]/eLow[j]
<< G4endl;
}
}
}
// Calculate lambda vector
for(j=0; j<totBinsLambda; j++) {
size_t totBinsLambda = aVector->GetVectorLength();
for(size_t j=0; j<totBinsLambda; ++j) {
e = aVector->GetLowEdgeEnergy(j);
G4double e = aVector->Energy(j);
// Choose a model of energy losses
G4double del = 0.0;
// Choose a model
G4int k = 0;
G4double fac = 1.0;
if (nmod > 1 && e > eLow[1]) {
do {
k++;
fac *= (1.0 + factor[k]/e);
} while ( k+1 < nmod && e > eLow[k+1] );
G4VEmModel* mod = models[regModels->ModelIndex(0)];
if (nmod > 1) {
k = nmod;
do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
if(k > 0) {
G4double elow = regModels->LowEdgeEnergy(k);
G4VEmModel* m = models[regModels->ModelIndex(k-1)];
G4double xs1 = m->CrossSection(couple,particle,elow,cut,tmax);
mod = models[regModels->ModelIndex(k)];
G4double xs2 = mod->CrossSection(couple,particle,elow,cut,tmax);
del = (xs1 - xs2)*elow/e;
}
}
model = models[regModels->ModelIndex(k)];
G4double cross = 0.0;
if(model) cross = model->CrossSection(couple,particle,e,cut,tmax)*fac;
G4double cross = mod->CrossSection(couple,particle,e,cut,tmax) + del;
if(j==0 && startFromNull) cross = 0.0;
if(2 < verboseLevel) {
G4cout << "FillLambdaVector: " << j << ". e(MeV)= " << e/MeV
<< " cross(1/mm)= " << cross*mm
<< " fac= " << fac << " k= " << k
<< " model= " << regModels->ModelIndex(k)
<< " del= " << del*mm << " k= " << k
<< " modelIdx= " << regModels->ModelIndex(k)
<< G4endl;
}
if(cross < 0.0) cross = 0.0;
@@ -795,16 +656,14 @@ void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
void G4EmModelManager::DumpModelList(G4int verb)
{
if(verb == 0) return;
for(G4int i=0; i<nRegions; i++) {
for(G4int i=0; i<nRegions; ++i) {
G4RegionModels* r = setOfRegionModels[i];
const G4Region* reg = r->Region();
if(verb > 1 || nRegions > 1) {
}
G4int n = r->NumberOfModels();
if(verb > 1 || n > 0) {
if(n > 0) {
G4cout << " ===== EM models for the G4Region " << reg->GetName()
<< " ======" << G4endl;;
for(G4int j=0; j<n; j++) {
for(G4int j=0; j<n; ++j) {
const G4VEmModel* m = models[r->ModelIndex(j)];
G4cout << std::setw(20);
G4cout << m->GetName() << " : Emin= "
@@ -814,6 +673,7 @@ void G4EmModelManager::DumpModelList(G4int verb)
<< G4endl;
}
}
if(1 == nEmModels) break;
}
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmProcessOptions.cc,v 1.24 2008/04/17 10:33:27 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmProcessOptions.cc,v 1.27 2009/10/29 19:25:28 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -58,6 +58,7 @@
#include "G4VEnergyLossProcess.hh"
#include "G4VMultipleScattering.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -391,21 +392,40 @@ void G4EmProcessOptions::SetLambdaFactor(G4double val)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmProcessOptions::ActivateDeexcitation(G4bool val, const G4Region* r)
void G4EmProcessOptions::ActivateDeexcitation(const G4String& pname,
G4bool val,
const G4String& reg)
{
G4RegionStore* regionStore = G4RegionStore::GetInstance();
const G4Region* r = 0;
if(reg == "" || reg == "World") {
r = regionStore->GetRegion("DefaultRegionForTheWorld", false);
} else {
r = regionStore->GetRegion(reg, false);
}
if(!r) {
G4cout << "G4EmProcessOptions::ActivateDeexcitation ERROR: G4Region <"
<< reg << "> not found, the command ignored" << G4endl;
return;
}
const std::vector<G4VEnergyLossProcess*>& v =
theManager->GetEnergyLossProcessVector();
std::vector<G4VEnergyLossProcess*>::const_iterator itr;
for(itr = v.begin(); itr != v.end(); itr++) {
G4VEnergyLossProcess* p = *itr;
if(p) p->ActivateDeexcitation(val,r);
if(p) {
if(pname == p->GetProcessName()) p->ActivateDeexcitation(val,r);
}
}
const std::vector<G4VEmProcess*>& w =
theManager->GetEmProcessVector();
std::vector<G4VEmProcess*>::const_iterator itp;
for(itp = w.begin(); itp != w.end(); itp++) {
G4VEmProcess* q = *itp;
if(q) q->ActivateDeexcitation(val,r);
if(q) {
if(pname == q->GetProcessName()) q->ActivateDeexcitation(val,r);
}
}
}
@@ -495,6 +515,13 @@ void G4EmProcessOptions::SetPolarAngleLimit(G4double val)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmProcessOptions::SetFactorForAngleLimit(G4double val)
{
theManager->SetFactorForAngleLimit(val);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4EmProcessOptions::SetLPMFlag(G4bool val)
{
theManager->SetLPMFlag(val);
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EmSaturation.cc,v 1.9 2008/11/12 15:37:33 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EmSaturation.cc,v 1.10 2009/09/25 09:16:40 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -45,14 +45,12 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#include "G4EmSaturation.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Neutron.hh"
#include "G4Proton.hh"
#include "G4LossTableManager.hh"
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4Electron.hh"
#include "G4Proton.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -65,7 +63,8 @@ G4EmSaturation::G4EmSaturation()
curRatio = 1.0;
curChargeSq = 1.0;
nMaterials = 0;
Initialise();
electron = 0;
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -89,8 +88,9 @@ G4double G4EmSaturation::VisibleEnergyDeposition(
if(bfactor > 0.0) {
// atomic relaxations
if(p == gamma) {
G4int pdgCode = p->GetPDGEncoding();
// atomic relaxations for gamma incident
if(22 == pdgCode) {
evis /= (1.0 + bfactor*edep/manager->GetRange(electron,edep,couple));
// energy loss
@@ -100,7 +100,9 @@ G4double G4EmSaturation::VisibleEnergyDeposition(
G4double nloss = niel;
if(nloss < 0.0) nloss = 0.0;
G4double eloss = edep - nloss;
if(p == neutron || eloss < 0.0 || length <= 0.0) {
// neutrons
if(2112 == pdgCode || eloss < 0.0 || length <= 0.0) {
nloss = edep;
eloss = 0.0;
}
@@ -110,6 +112,7 @@ G4double G4EmSaturation::VisibleEnergyDeposition(
// non-ionizing energy loss
if(nloss > 0.0) {
if(!proton) {proton = G4Proton::Proton();}
G4double escaled = nloss*curRatio;
G4double s = manager->GetRange(proton,escaled,couple)/curChargeSq;
nloss /= (1.0 + bfactor*nloss/s);
@@ -145,6 +148,14 @@ G4double G4EmSaturation::FindG4BirksCoefficient(const G4Material* mat)
G4double G4EmSaturation::FindBirksCoefficient(const G4Material* mat)
{
// electron should exist in any case
if(!manager) {
manager = G4LossTableManager::Instance();
nist = G4NistManager::Instance();
electron= G4Electron::Electron();
proton = 0;
}
if(mat == curMaterial) return curBirks;
curMaterial = mat;
@@ -162,15 +173,6 @@ G4double G4EmSaturation::FindBirksCoefficient(const G4Material* mat)
}
}
if(!manager) {
manager = G4LossTableManager::Instance();
nist = G4NistManager::Instance();
gamma = G4Gamma::Gamma();
electron= G4Electron::Electron();
proton = G4Proton::Proton();
neutron = G4Neutron::Neutron();
}
G4String name = mat->GetName();
curBirks = mat->GetIonisation()->GetBirksConstant();
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4EnergyLossMessenger.cc,v 1.35 2008/10/20 13:27:45 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EnergyLossMessenger.cc,v 1.38 2009/10/29 19:25:28 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -177,16 +177,31 @@ G4EnergyLossMessenger::G4EnergyLossMessenger()
aplCmd->SetDefaultValue(false);
aplCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
deexCmd = new G4UIcommand("/process/em/deexcitation",this);
deexCmd->SetGuidance("Set deexcitation flag per process and G4Region.");
deexCmd->SetGuidance(" procName : process name");
deexCmd->SetGuidance(" flag : flag");
deexCmd->SetGuidance(" regName : G4Region name");
G4UIparameter* pName = new G4UIparameter("pName",'s',false);
deexCmd->SetParameter(pName);
G4UIparameter* flag = new G4UIparameter("flag",'s',false);
deexCmd->SetParameter(flag);
G4UIparameter* regName = new G4UIparameter("regName",'s',false);
deexCmd->SetParameter(regName);
dedxCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsDEDX",this);
dedxCmd->SetGuidance("Set number of bins for DEDX tables");
dedxCmd->SetParameterName("binsDEDX",true);
dedxCmd->SetDefaultValue(120);
dedxCmd->SetDefaultValue(77);
dedxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
lamCmd = new G4UIcmdWithAnInteger("/process/eLoss/binsLambda",this);
lamCmd->SetGuidance("Set number of bins for Lambda tables");
lamCmd->SetParameterName("binsL",true);
lamCmd->SetDefaultValue(120);
lamCmd->SetDefaultValue(77);
lamCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
verCmd = new G4UIcmdWithAnInteger("/process/eLoss/verbose",this);
@@ -226,7 +241,7 @@ G4EnergyLossMessenger::G4EnergyLossMessenger()
frCmd->SetGuidance("Set RangeFactor parameter for msc processes");
frCmd->SetParameterName("Fr",true);
frCmd->SetRange("Fr>0");
frCmd->SetDefaultValue(0.02);
frCmd->SetDefaultValue(0.04);
frCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fgCmd = new G4UIcmdWithADouble("/process/msc/GeomFactor",this);
@@ -236,13 +251,20 @@ G4EnergyLossMessenger::G4EnergyLossMessenger()
fgCmd->SetDefaultValue(3.5);
fgCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
mscfCmd = new G4UIcmdWithADouble("/process/msc/FactorForAngleLimit",this);
mscfCmd->SetGuidance("Set factor for computation of a limit for -t (invariant trasfer)");
mscfCmd->SetParameterName("Fact",true);
mscfCmd->SetRange("Fact>0");
mscfCmd->SetDefaultValue(1.);
mscfCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
skinCmd = new G4UIcmdWithADouble("/process/msc/Skin",this);
skinCmd->SetGuidance("Set skin parameter for msc processes");
skinCmd->SetParameterName("skin",true);
skinCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
angCmd = new G4UIcmdWithADoubleAndUnit("/process/msc/ThetaLimit",this);
angCmd->SetGuidance("Set the limit on the polar angle");
angCmd->SetGuidance("Set the limit on the polar angle for msc and single scattering");
angCmd->SetParameterName("theta",true);
angCmd->SetUnitCategory("Angle");
angCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
@@ -258,6 +280,7 @@ G4EnergyLossMessenger::~G4EnergyLossMessenger()
delete SubSecCmd;
delete MinSubSecCmd;
delete StepFuncCmd;
delete deexCmd;
delete eLossDirectory;
delete mscDirectory;
delete emDirectory;
@@ -280,6 +303,7 @@ G4EnergyLossMessenger::~G4EnergyLossMessenger()
delete labCmd;
delete skinCmd;
delete angCmd;
delete mscfCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -319,6 +343,15 @@ void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
opt->SetStepFunction(v1,v2);
}
if (command == deexCmd) {
G4String s1 (""), s2(""), s3("");
G4bool b = false;
std::istringstream is(newValue);
is >> s1 >> s2 >> s3;
if(s2 == "true") b = true;
opt->ActivateDeexcitation(s1,b,s3);
}
if (command == mscCmd) {
if(newValue == "Minimal")
opt->SetMscStepLimitation(fMinimal);
@@ -406,6 +439,10 @@ void G4EnergyLossMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
opt->SetMscGeomFactor(fgCmd->GetNewDoubleValue(newValue));
G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
}
if (command == mscfCmd) {
opt->SetFactorForAngleLimit(mscfCmd->GetNewDoubleValue(newValue));
G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
}
if (command == angCmd) {
opt->SetPolarAngleLimit(angCmd->GetNewDoubleValue(newValue));
G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
@@ -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);
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4LossTableManager.cc,v 1.95 2008/11/13 18:23:39 schaelic Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4LossTableManager.cc,v 1.97 2009/10/29 19:25:28 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -92,6 +92,7 @@
#include "G4PhysicsTableHelper.hh"
#include "G4EmCorrections.hh"
#include "G4EmSaturation.hh"
#include "G4EmConfigurator.hh"
#include "G4EmTableType.hh"
#include "G4LossTableBuilder.hh"
@@ -163,6 +164,7 @@ G4LossTableManager::G4LossTableManager()
tableBuilder = new G4LossTableBuilder();
emCorrections= new G4EmCorrections();
emSaturation = new G4EmSaturation();
emConfigurator = new G4EmConfigurator();
integral = true;
integralActive = false;
buildCSDARange = false;
@@ -173,6 +175,7 @@ G4LossTableManager::G4LossTableManager()
flagLPM = true;
splineFlag = true;
bremsTh = DBL_MAX;
factorForAngleLimit = 1.0;
verbose = 1;
tableBuilder->SetSplineFlag(splineFlag);
}
@@ -917,6 +920,20 @@ G4double G4LossTableManager::BremsstrahlungTh() const
return bremsTh;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4LossTableManager::SetFactorForAngleLimit(G4double val)
{
if(val > 0.0) factorForAngleLimit = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4LossTableManager::FactorForAngleLimit() const
{
return factorForAngleLimit;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4EmCorrections* G4LossTableManager::EmCorrections()
@@ -931,4 +948,11 @@ G4EmSaturation* G4LossTableManager::EmSaturation()
return emSaturation;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4EmConfigurator* G4LossTableManager::EmConfigurator()
{
return emConfigurator;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmFluctuationModel.cc,v 1.3 2008/07/15 16:56:39 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VEmFluctuationModel.cc,v 1.4 2009/02/19 11:25:50 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -64,4 +64,11 @@ G4VEmFluctuationModel::~G4VEmFluctuationModel()
G4LossTableManager::Instance()->DeRegister(this);
}
void G4VEmFluctuationModel::InitialiseMe(const G4ParticleDefinition*)
{}
void G4VEmFluctuationModel::SetParticleAndCharge(const G4ParticleDefinition*,
G4double)
{}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmModel.cc,v 1.20 2008/11/13 23:13:18 schaelic Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VEmModel.cc,v 1.30 2009/09/23 14:42:47 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -40,6 +40,7 @@
// Modifications:
// 25.10.2005 Set default highLimit=100.TeV (V.Ivanchenko)
// 06.02.2006 add method ComputeMeanFreePath() (mma)
// 16.02.2009 Move implementations of virtual methods to source (VI)
//
//
// Class Description:
@@ -52,14 +53,19 @@
#include "G4VEmModel.hh"
#include "G4LossTableManager.hh"
#include "G4ProductionCutsTable.hh"
#include "G4ParticleChangeForLoss.hh"
#include "G4ParticleChangeForGamma.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VEmModel::G4VEmModel(const G4String& nam):
fluc(0), name(nam), lowLimit(0.1*keV), highLimit(100.0*TeV),
eMinActive(0.0),eMaxActive(DBL_MAX),
polarAngleLimit(0.0),secondaryThreshold(DBL_MAX),theLPMflag(false),
pParticleChange(0),nuclearStopping(false),nsec(5)
pParticleChange(0),nuclearStopping(false),
currentCouple(0),currentElement(0),
nsec(5),flagDeexcitation(false)
{
xsec.resize(nsec);
nSelectors = 0;
@@ -81,6 +87,88 @@ G4VEmModel::~G4VEmModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleChangeForLoss* G4VEmModel::GetParticleChangeForLoss()
{
G4ParticleChangeForLoss* p = 0;
if (pParticleChange) {
p = static_cast<G4ParticleChangeForLoss*>(pParticleChange);
} else {
p = new G4ParticleChangeForLoss();
pParticleChange = p;
}
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleChangeForGamma* G4VEmModel::GetParticleChangeForGamma()
{
G4ParticleChangeForGamma* p = 0;
if (pParticleChange) {
p = static_cast<G4ParticleChangeForGamma*>(pParticleChange);
} else {
p = new G4ParticleChangeForGamma();
pParticleChange = p;
}
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::InitialiseElementSelectors(const G4ParticleDefinition* p,
const G4DataVector& cuts)
{
// initialise before run
flagDeexcitation = false;
G4int nbins = G4int(std::log10(highLimit/lowLimit) + 0.5);
if(nbins < 3) nbins = 3;
G4bool spline = G4LossTableManager::Instance()->SplineFlag();
G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
G4int numOfCouples = theCoupleTable->GetTableSize();
// prepare vector
if(numOfCouples > nSelectors) elmSelectors.reserve(numOfCouples);
// initialise vector
for(G4int i=0; i<numOfCouples; i++) {
currentCouple = theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = currentCouple->GetMaterial();
G4int idx = currentCouple->GetIndex();
// selector already exist check if should be deleted
G4bool create = true;
if(i < nSelectors) {
if(elmSelectors[i]) {
if(material == elmSelectors[i]->GetMaterial()) create = false;
else delete elmSelectors[i];
}
} else {
nSelectors++;
elmSelectors.push_back(0);
}
if(create) {
elmSelectors[i] = new G4EmElementSelector(this,material,nbins,
lowLimit,highLimit,spline);
}
elmSelectors[i]->Initialise(p, cuts[idx]);
//elmSelectors[i]->Dump(p);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::ComputeDEDXPerVolume(const G4Material*,
const G4ParticleDefinition*,
G4double,G4double)
{
return 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::CrossSectionPerVolume(const G4Material* material,
const G4ParticleDefinition* p,
G4double ekin,
@@ -106,59 +194,69 @@ G4double G4VEmModel::CrossSectionPerVolume(const G4Material* material,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::ComputeMeanFreePath(const G4ParticleDefinition* p,
G4double ekin,
const G4Material* material,
G4double emin,
G4double emax)
G4double G4VEmModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
G4double, G4double, G4double,
G4double, G4double)
{
G4double mfp = DBL_MAX;
G4double cross = CrossSectionPerVolume(material,p,ekin,emin,emax);
if (cross > DBL_MIN) mfp = 1./cross;
return mfp;
return 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::InitialiseElementSelectors(const G4ParticleDefinition* p,
const G4DataVector& cuts)
void G4VEmModel::DefineForRegion(const G4Region*)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::MinEnergyCut(const G4ParticleDefinition*,
const G4MaterialCutsCouple*)
{
G4int nbins = G4int(std::log10(highLimit/lowLimit) + 0.5);
if(nbins < 3) nbins = 3;
G4bool spline = G4LossTableManager::Instance()->SplineFlag();
G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
G4int numOfCouples = theCoupleTable->GetTableSize();
// prepare vector
if(numOfCouples > nSelectors) {
elmSelectors.resize(numOfCouples);
nSelectors = numOfCouples;
}
// initialise vector
for(G4int i=0; i<numOfCouples; i++) {
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
G4int idx = couple->GetIndex();
// selector already exist check if should be deleted
G4bool create = true;
if(elmSelectors[i]) {
if(material == elmSelectors[i]->GetMaterial()) create = false;
else delete elmSelectors[i];
}
if(create) {
elmSelectors[i] = new G4EmElementSelector(this,material,nbins,
lowLimit,highLimit,spline);
}
elmSelectors[i]->Initialise(p, cuts[idx]);
//elmSelectors[i]->Dump(p);
}
return 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::GetChargeSquareRatio(const G4ParticleDefinition* p,
const G4Material*, G4double)
{
G4double q = p->GetPDGCharge()/CLHEP::eplus;
return q*q;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::GetParticleCharge(const G4ParticleDefinition* p,
const G4Material*, G4double)
{
return p->GetPDGCharge();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::CorrectionsAlongStep(const G4MaterialCutsCouple*,
const G4DynamicParticle*,
G4double&,G4double&,G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::SampleDeexcitationAlongStep(const G4Material*,
const G4Track&,
G4double& )
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VEmModel::MaxSecondaryEnergy(const G4ParticleDefinition*,
G4double kineticEnergy)
{
return kineticEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::SetupForMaterial(const G4ParticleDefinition*,
const G4Material*, G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmProcess.cc,v 1.60 2008/10/17 14:46:16 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VEmProcess.cc,v 1.79 2009/11/10 20:30:55 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -51,6 +51,7 @@
// 12-09-06 add SetModel() (mma)
// 12-04-07 remove double call to Clear model manager (V.Ivanchenko)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
//
// Class Description:
//
@@ -77,6 +78,7 @@
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4PhysicsTableHelper.hh"
#include "G4EmConfigurator.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -90,8 +92,10 @@ G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
integral(false),
applyCuts(false),
startFromNull(true),
nRegions(0),
selectedModel(0),
useDeexcitation(false),
nDERegions(0),
idxDERegions(0),
currentModel(0),
particle(0),
currentCouple(0)
{
@@ -99,8 +103,8 @@ G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
// Size of tables assuming spline
minKinEnergy = 0.1*keV;
maxKinEnergy = 100.0*TeV;
nLambdaBins = 84;
maxKinEnergy = 10.0*TeV;
nLambdaBins = 77;
// default lambda factor
lambdaFactor = 0.8;
@@ -138,6 +142,66 @@ G4VEmProcess::~G4VEmProcess()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::Clear()
{
delete [] theEnergyOfCrossSectionMax;
delete [] theCrossSectionMax;
delete [] idxDERegions;
theEnergyOfCrossSectionMax = 0;
theCrossSectionMax = 0;
idxDERegions = 0;
currentCouple = 0;
preStepLambda = 0.0;
mfpKinEnergy = DBL_MAX;
deRegions.clear();
nDERegions = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p,
const G4Region* region)
{
G4VEmFluctuationModel* fm = 0;
modelManager->AddEmModel(order, p, fm, region);
if(p) p->SetParticleChange(pParticleChange);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::SetModel(G4VEmModel* p, G4int index)
{
G4int n = emModels.size();
if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
emModels[index] = p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmModel* G4VEmProcess::Model(G4int index)
{
G4VEmModel* p = 0;
if(index >= 0 && index < G4int(emModels.size())) { p = emModels[index]; }
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::UpdateEmModel(const G4String& nam,
G4double emin, G4double emax)
{
modelManager->UpdateEmModel(nam, emin, emax);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver)
{
return modelManager->GetModel(idx, ver);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
{
if(!particle) particle = &part;
@@ -149,41 +213,75 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
<< G4endl;
}
(G4LossTableManager::Instance())->EmConfigurator()->AddModels();
if(particle == &part) {
Clear();
InitialiseProcess(particle);
// initialisation of models
G4int nmod = modelManager->NumberOfModels();
for(G4int i=0; i<nmod; ++i) {
G4VEmModel* mod = modelManager->GetModel(i);
mod->SetPolarAngleLimit(polarAngleLimit);
if(mod->HighEnergyLimit() > maxKinEnergy) {
mod->SetHighEnergyLimit(maxKinEnergy);
}
}
theCuts = modelManager->Initialise(particle,secondaryParticle,2.,verboseLevel);
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
theCutsGamma = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut);
theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut);
theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut);
if(buildLambdaTable)
// prepare tables
if(buildLambdaTable){
theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
}
}
}
// Sub Cutoff and Deexcitation
if (nDERegions>0) {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
void G4VEmProcess::Clear()
{
if(theEnergyOfCrossSectionMax) delete [] theEnergyOfCrossSectionMax;
if(theCrossSectionMax) delete [] theCrossSectionMax;
theEnergyOfCrossSectionMax = 0;
theCrossSectionMax = 0;
currentCouple = 0;
preStepLambda = 0.0;
mfpKinEnergy = DBL_MAX;
idxDERegions = new G4bool[numOfCouples];
for (size_t j=0; j<numOfCouples; ++j) {
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(j);
const G4ProductionCuts* pcuts = couple->GetProductionCuts();
G4bool reg = false;
for(G4int i=0; i<nDERegions; ++i) {
if(deRegions[i]) {
if(pcuts == deRegions[i]->GetProductionCuts()) reg = true;
}
}
idxDERegions[j] = reg;
}
}
if (1 < verboseLevel && nDERegions>0) {
G4cout << " Deexcitation is activated for regions: " << G4endl;
for (G4int i=0; i<nDERegions; ++i) {
const G4Region* r = deRegions[i];
G4cout << " " << r->GetName() << G4endl;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
{
G4String partname = part.GetParticleName();
if(1 < verboseLevel) {
G4cout << "G4VEmProcess::BuildPhysicsTable() for "
<< GetProcessName()
<< " and particle " << part.GetParticleName()
<< " and particle " << partname
<< " buildLambdaTable= " << buildLambdaTable
<< G4endl;
}
@@ -192,12 +290,18 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
BuildLambdaTable();
FindLambdaMax();
}
if(0 < verboseLevel) PrintInfoDefinition();
// reduce printout for nuclear stopping
G4bool gproc = true;
if(GetProcessName() == "nuclearStopping" &&
partname != "GenericIon" && partname != "alpha") { gproc = false; }
if(gproc && 0 < verboseLevel) { PrintInfoDefinition(); }
if(1 < verboseLevel) {
G4cout << "G4VEmProcess::BuildPhysicsTable() done for "
<< GetProcessName()
<< " and particle " << part.GetParticleName()
<< " and particle " << partname
<< G4endl;
}
}
@@ -217,14 +321,30 @@ void G4VEmProcess::BuildLambdaTable()
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
for(size_t i=0; i<numOfCouples; i++) {
G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
G4PhysicsLogVector* aVector = 0;
G4PhysicsLogVector* bVector = 0;
for(size_t i=0; i<numOfCouples; ++i) {
if (theLambdaTable->GetFlag(i)) {
// create physics vector and fill it
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
if(!bVector) {
aVector =
static_cast<G4PhysicsLogVector*>(LambdaPhysicsVector(couple));
bVector = aVector;
} else {
aVector = new G4PhysicsLogVector(*bVector);
}
// G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
aVector->SetSpline(splineFlag);
modelManager->FillLambdaVector(aVector, couple, startFromNull);
if(splineFlag) aVector->FillSecondDerivatives();
G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
}
}
@@ -241,6 +361,35 @@ void G4VEmProcess::BuildLambdaTable()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::PrintInfoDefinition()
{
if(verboseLevel > 0) {
G4cout << G4endl << GetProcessName() << ": for "
<< particle->GetParticleName();
if(integral) G4cout << ", integral: 1 ";
if(applyCuts) G4cout << ", applyCuts: 1 ";
G4cout << " SubType= " << GetProcessSubType() << G4endl;
if(buildLambdaTable) {
G4cout << " Lambda tables from "
<< G4BestUnit(minKinEnergy,"Energy")
<< " to "
<< G4BestUnit(maxKinEnergy,"Energy")
<< " in " << nLambdaBins << " bins, spline: "
<< (G4LossTableManager::Instance())->SplineFlag()
<< G4endl;
}
PrintInfo();
modelManager->DumpModelList(verboseLevel);
}
if(verboseLevel > 2 && buildLambdaTable) {
G4cout << " LambdaTable address= " << theLambdaTable << G4endl;
if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
const G4Track& track,
G4double previousStepSize,
@@ -251,6 +400,7 @@ G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
G4double x = DBL_MAX;
if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;
InitialiseStep(track);
if(!currentModel->IsActive(preStepKinEnergy)) return x;
if(preStepKinEnergy < mfpKinEnergy) {
if (integral) ComputeIntegralLambda(preStepKinEnergy);
@@ -303,16 +453,6 @@ G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
G4double,
G4ForceCondition* condition)
{
*condition = NotForced;
return G4VEmProcess::MeanFreePath(track);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
const G4Step&)
{
@@ -341,8 +481,11 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
}
}
G4VEmModel* currentModel = SelectModel(finalT);
SelectModel(finalT, currentCoupleIndex);
if(!currentModel->IsActive(finalT)) return &fParticleChange;
if(useDeexcitation) {
currentModel->SetDeexcitationFlag(idxDERegions[currentCoupleIndex]);
}
/*
if(0 < verboseLevel) {
G4cout << "G4VEmProcess::PostStepDoIt: Sample secondary; E= "
@@ -359,7 +502,7 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
currentModel->SampleSecondaries(&secParticles,
currentCouple,
track.GetDynamicParticle(),
(*theCuts)[currentMaterialIndex]);
(*theCuts)[currentCoupleIndex]);
// save secondaries
G4int num = secParticles.size();
@@ -368,21 +511,21 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
fParticleChange.SetNumberOfSecondaries(num);
G4double edep = fParticleChange.GetLocalEnergyDeposit();
for (G4int i=0; i<num; i++) {
for (G4int i=0; i<num; ++i) {
G4DynamicParticle* dp = secParticles[i];
const G4ParticleDefinition* p = dp->GetDefinition();
G4double e = dp->GetKineticEnergy();
G4bool good = true;
if(applyCuts) {
if (p == theGamma) {
if (e < (*theCutsGamma)[currentMaterialIndex]) good = false;
if (e < (*theCutsGamma)[currentCoupleIndex]) good = false;
} else if (p == theElectron) {
if (e < (*theCutsElectron)[currentMaterialIndex]) good = false;
if (e < (*theCutsElectron)[currentCoupleIndex]) good = false;
} else if (p == thePositron) {
if (electron_mass_c2 < (*theCutsGamma)[currentMaterialIndex] &&
e < (*theCutsPositron)[currentMaterialIndex]) {
if (electron_mass_c2 < (*theCutsGamma)[currentCoupleIndex] &&
e < (*theCutsPositron)[currentCoupleIndex]) {
good = false;
e += 2.0*electron_mass_c2;
}
@@ -403,56 +546,6 @@ G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::PrintInfoDefinition()
{
if(verboseLevel > 0) {
G4cout << G4endl << GetProcessName() << ": for "
<< particle->GetParticleName();
if(integral) G4cout << ", integral: 1 ";
if(applyCuts) G4cout << ", applyCuts: 1 ";
G4cout << " SubType= " << GetProcessSubType() << G4endl;
if(buildLambdaTable) {
G4cout << " Lambda tables from "
<< G4BestUnit(minKinEnergy,"Energy")
<< " to "
<< G4BestUnit(maxKinEnergy,"Energy")
<< " in " << nLambdaBins << " bins, spline: "
<< (G4LossTableManager::Instance())->SplineFlag()
<< G4endl;
}
PrintInfo();
modelManager->DumpModelList(verboseLevel);
}
if(verboseLevel > 2 && buildLambdaTable) {
G4cout << " LambdaTable address= " << theLambdaTable << G4endl;
if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
const G4MaterialCutsCouple* couple)
{
// Cross section per atom is calculated
DefineMaterial(couple);
G4double cross = 0.0;
G4bool b;
if(theLambdaTable) {
cross = (((*theLambdaTable)[currentMaterialIndex])->
GetValue(kineticEnergy, b));
} else {
G4VEmModel* model = SelectModel(kineticEnergy);
cross =
model->CrossSectionPerVolume(currentMaterial,particle,kineticEnergy);
}
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
@@ -484,7 +577,7 @@ G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
G4bool ascii)
{
if(1 < verboseLevel) {
G4cout << "G4VEmProcess::RetrievePhysicsTable() for "
@@ -503,13 +596,18 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
filename,ascii);
if ( yes ) {
if (0 < verboseLevel) {
G4cout << "Lambda table for " << particleName << " is Retrieved from <"
G4cout << "Lambda table for " << particleName
<< " is Retrieved from <"
<< filename << ">"
<< G4endl;
}
if((G4LossTableManager::Instance())->SplineFlag()) {
size_t n = theLambdaTable->length();
for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);}
for(size_t i=0; i<n; ++i) {
if((* theLambdaTable)[i]) {
(* theLambdaTable)[i]->SetSpline(true);
}
}
}
} else {
if (1 < verboseLevel) {
@@ -524,6 +622,63 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::ActivateDeexcitation(G4bool val, const G4Region* r)
{
G4RegionStore* regionStore = G4RegionStore::GetInstance();
const G4Region* reg = r;
if (!reg) {reg = regionStore->GetRegion("DefaultRegionForTheWorld", false);}
// the region is in the list
if (nDERegions) {
for (G4int i=0; i<nDERegions; ++i) {
if (reg == deRegions[i]) {
if(!val) deRegions[i] = 0;
return;
}
}
}
// new region
if(val) {
useDeexcitation = true;
deRegions.push_back(reg);
nDERegions++;
} else {
useDeexcitation = false;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
const G4MaterialCutsCouple* couple)
{
// Cross section per atom is calculated
DefineMaterial(couple);
G4double cross = 0.0;
if(theLambdaTable) {
cross = (((*theLambdaTable)[currentCoupleIndex])->Value(kineticEnergy));
} else {
SelectModel(kineticEnergy, currentCoupleIndex);
cross = currentModel->CrossSectionPerVolume(currentMaterial,
particle,kineticEnergy);
}
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
G4double,
G4ForceCondition* condition)
{
*condition = NotForced;
return G4VEmProcess::MeanFreePath(track);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::FindLambdaMax()
{
if(1 < verboseLevel) {
@@ -536,22 +691,23 @@ void G4VEmProcess::FindLambdaMax()
G4double e, s, emax, smax;
theEnergyOfCrossSectionMax = new G4double [n];
theCrossSectionMax = new G4double [n];
G4bool b;
for (size_t i=0; i<n; i++) {
for (size_t i=0; i<n; ++i) {
pv = (*theLambdaTable)[i];
emax = DBL_MAX;
smax = 0.0;
if(pv) {
size_t nb = pv->GetVectorLength();
emax = pv->GetLowEdgeEnergy(nb);
emax = DBL_MAX;
smax = 0.0;
for (size_t j=0; j<nb; j++) {
e = pv->GetLowEdgeEnergy(j);
s = pv->GetValue(e,b);
if(s > smax) {
smax = s;
emax = e;
if(nb > 0) {
for (size_t j=0; j<nb; ++j) {
e = pv->Energy(j);
s = (*pv)(j);
if(s > smax) {
smax = s;
emax = e;
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMscModel.cc,v 1.4 2008/03/10 18:39:45 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VMscModel.cc,v 1.13 2009/07/20 17:32:47 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -48,18 +48,22 @@
//
#include "G4VMscModel.hh"
#include "G4ParticleChangeForMSC.hh"
#include "G4TransportationManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VMscModel::G4VMscModel(const G4String& nam):
G4VEmModel(nam),
facrange(0.02),
safetyHelper(0),
facrange(0.04),
facgeom(2.5),
facsafety(0.25),
facsafety(0.3),
skin(3.0),
dtrl(0.05),
lambdalimit(mm),
geommax(1.e50*mm),
steppingAlgorithm(fUseSafety),
samplez(false),
latDisplasment(true)
@@ -71,3 +75,103 @@ G4VMscModel::~G4VMscModel()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleChangeForMSC* G4VMscModel::GetParticleChangeForMSC()
{
G4ParticleChangeForMSC* p = 0;
if (pParticleChange) {
p = static_cast<G4ParticleChangeForMSC*>(pParticleChange);
} else {
p = new G4ParticleChangeForMSC();
}
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VMscModel::InitialiseSafetyHelper()
{
if(!safetyHelper) {
safetyHelper = G4TransportationManager::GetTransportationManager()
->GetSafetyHelper();
safetyHelper->InitialiseHelper();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VMscModel::ComputeDisplacement(G4ParticleChangeForMSC* fParticleChange,
const G4ThreeVector& dir,
G4double displacement,
G4double postsafety)
{
const G4ThreeVector* pos = fParticleChange->GetProposedPosition();
G4double r = displacement;
if(r > postsafety) {
G4double newsafety = safetyHelper->ComputeSafety(*pos);
if(r > newsafety) r = newsafety;
}
if(r > 0.) {
// compute new endpoint of the Step
G4ThreeVector newPosition = *pos + r*dir;
// definitely not on boundary
if(displacement == r) {
safetyHelper->ReLocateWithinVolume(newPosition);
} else {
// check safety after displacement
G4double postsafety = safetyHelper->ComputeSafety(newPosition);
// displacement to boundary
if(postsafety <= 0.0) {
safetyHelper->Locate(newPosition,
*fParticleChange->GetProposedMomentumDirection());
// not on the boundary
} else {
safetyHelper->ReLocateWithinVolume(newPosition);
}
}
fParticleChange->ProposePosition(newPosition);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VMscModel::SampleScattering(const G4DynamicParticle*, G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::ComputeTruePathLengthLimit(const G4Track&,
G4PhysicsTable*,
G4double)
{
return DBL_MAX;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::ComputeGeomPathLength(G4double truePathLength)
{
return truePathLength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::ComputeTrueStepLength(G4double geomPathLength)
{
return geomPathLength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VMscModel::SampleSecondaries(std::vector<G4DynamicParticle*>*,
const G4MaterialCutsCouple*,
const G4DynamicParticle*,
G4double, G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMultipleScattering.cc,v 1.60 2008/11/20 20:32:40 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VMultipleScattering.cc,v 1.77 2009/10/29 18:07:08 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -55,6 +55,7 @@
// 12-04-07 Add verbosity at destruction (V.Ivanchenko)
// 27-10-07 Virtual functions moved to source (V.Ivanchenko)
// 11-03-08 Set skin value does not effect step limit type (V.Ivanchenko)
// 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
//
// Class Description:
//
@@ -82,6 +83,7 @@
#include "G4PhysicsTableHelper.hh"
#include "G4GenericIon.hh"
#include "G4Electron.hh"
#include "G4EmConfigurator.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -93,9 +95,10 @@ G4VMultipleScattering::G4VMultipleScattering(const G4String& name,
firstParticle(0),
stepLimit(fUseSafety),
skin(3.0),
facrange(0.02),
facrange(0.04),
facgeom(2.5),
latDisplasment(true),
isIon(false),
currentParticle(0),
currentCouple(0)
{
@@ -104,8 +107,8 @@ G4VMultipleScattering::G4VMultipleScattering(const G4String& name,
// Size of tables assuming spline
minKinEnergy = 0.1*keV;
maxKinEnergy = 100.0*TeV;
nBins = 84;
maxKinEnergy = 10.0*TeV;
nBins = 77;
// default limit on polar angle
polarAngleLimit = 0.0;
@@ -135,6 +138,41 @@ G4VMultipleScattering::~G4VMultipleScattering()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::AddEmModel(G4int order, G4VEmModel* p,
const G4Region* region)
{
G4VEmFluctuationModel* fm = 0;
modelManager->AddEmModel(order, p, fm, region);
if(p) p->SetParticleChange(pParticleChange);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::SetModel(G4VMscModel* p, G4int index)
{
G4int n = mscModels.size();
if(index >= n) { for(G4int i=n; i<=index; ++i) {mscModels.push_back(0);} }
mscModels[index] = p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VMscModel* G4VMultipleScattering::Model(G4int index)
{
G4VMscModel* p = 0;
if(index >= 0 && index < G4int(mscModels.size())) { p = mscModels[index]; }
return p;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmModel*
G4VMultipleScattering::GetModelByIndex(G4int idx, G4bool ver) const
{
return modelManager->GetModel(idx, ver);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part)
{
G4String num = part.GetParticleName();
@@ -151,14 +189,27 @@ void G4VMultipleScattering::BuildPhysicsTable(const G4ParticleDefinition& part)
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
for (size_t i=0; i<numOfCouples; i++) {
G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag();
G4PhysicsLogVector* aVector = 0;
G4PhysicsLogVector* bVector = 0;
for (size_t i=0; i<numOfCouples; ++i) {
if (theLambdaTable->GetFlag(i)) {
// create physics vector and fill it
const G4MaterialCutsCouple* couple =
theCoupleTable->GetMaterialCutsCouple(i);
G4PhysicsVector* aVector = PhysicsVector(couple);
if(!bVector) {
aVector = static_cast<G4PhysicsLogVector*>(PhysicsVector(couple));
bVector = aVector;
} else {
aVector = new G4PhysicsLogVector(*bVector);
}
//G4PhysicsVector* aVector = PhysicsVector(couple);
aVector->SetSpline(splineFlag);
modelManager->FillLambdaVector(aVector, couple, false);
if(splineFlag) aVector->FillSecondDerivatives();
G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
}
}
@@ -193,10 +244,18 @@ void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part
if(part.GetParticleType() == "nucleus" &&
part.GetParticleSubType() == "generic") {
firstParticle = G4GenericIon::GenericIon();
isIon = true;
} else {
firstParticle = &part;
if(part.GetParticleType() == "nucleus" ||
part.GetPDGMass() > GeV) {isIon = true;}
}
// limitations for ions
if(isIon) {
SetStepLimitType(fMinimal);
SetLateralDisplasmentFlag(false);
SetBuildLambdaTable(false);
}
currentParticle = &part;
}
@@ -208,18 +267,40 @@ void G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part
<< G4endl;
}
(G4LossTableManager::Instance())->EmConfigurator()->AddModels();
if(firstParticle == &part) {
InitialiseProcess(firstParticle);
if(buildLambdaTable)
// initialisation of models
G4int nmod = modelManager->NumberOfModels();
for(G4int i=0; i<nmod; ++i) {
G4VMscModel* msc = static_cast<G4VMscModel*>(modelManager->GetModel(i));
if(isIon) {
msc->SetStepLimitType(fMinimal);
msc->SetLateralDisplasmentFlag(false);
msc->SetRangeFactor(0.2);
} else {
msc->SetStepLimitType(StepLimitType());
msc->SetLateralDisplasmentFlag(LateralDisplasmentFlag());
msc->SetSkin(Skin());
msc->SetRangeFactor(RangeFactor());
msc->SetGeomFactor(GeomFactor());
}
msc->SetPolarAngleLimit(polarAngleLimit);
if(msc->HighEnergyLimit() > maxKinEnergy) {
msc->SetHighEnergyLimit(maxKinEnergy);
}
}
modelManager->Initialise(firstParticle, G4Electron::Electron(),
10.0, verboseLevel);
// prepare tables
if(buildLambdaTable) {
theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
const G4DataVector* theCuts =
modelManager->Initialise(firstParticle,
G4Electron::Electron(),
10.0, verboseLevel);
if(2 < verboseLevel) G4cout << theCuts << G4endl;
}
}
}
@@ -256,28 +337,26 @@ G4double G4VMultipleScattering::AlongStepGetPhysicalInteractionLength(
const G4Track& track,
G4double,
G4double currentMinimalStep,
G4double& currentSafety,
G4double&,
G4GPILSelection* selection)
{
// get Step limit proposed by the process
valueGPILSelectionMSC = NotCandidateForSelection;
G4double steplength = GetMscContinuousStepLimit(track,
track.GetKineticEnergy(),
currentMinimalStep,
currentSafety);
// G4cout << "StepLimit= " << steplength << G4endl;
// set return value for G4GPILSelection
*selection = valueGPILSelectionMSC;
return steplength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VMultipleScattering::PostStepGetPhysicalInteractionLength(
const G4Track&, G4double, G4ForceCondition* condition)
{
*condition = Forced;
return DBL_MAX;
*selection = NotCandidateForSelection;
G4double x = currentMinimalStep;
DefineMaterial(track.GetMaterialCutsCouple());
G4double ekin = track.GetKineticEnergy();
if(isIon) { ekin *= proton_mass_c2/track.GetDefinition()->GetPDGMass(); }
currentModel = static_cast<G4VMscModel*>(SelectModel(ekin));
if(x > 0.0 && ekin > 0.0 && currentModel->IsActive(ekin)) {
G4double tPathLength =
currentModel->ComputeTruePathLengthLimit(track, theLambdaTable, x);
if (tPathLength < x) *selection = CandidateForSelection;
x = currentModel->ComputeGeomPathLength(tPathLength);
// G4cout << "tPathLength= " << tPathLength
// << " stepLimit= " << x
// << " currentMinimalStep= " << currentMinimalStep<< G4endl;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -288,8 +367,9 @@ G4double G4VMultipleScattering::GetContinuousStepLimit(
G4double currentMinimalStep,
G4double& currentSafety)
{
return GetMscContinuousStepLimit(track,previousStepSize,currentMinimalStep,
currentSafety);
G4GPILSelection* selection = 0;
return AlongStepGetPhysicalInteractionLength(track,previousStepSize,currentMinimalStep,
currentSafety, selection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -303,27 +383,6 @@ G4double G4VMultipleScattering::GetMeanFreePath(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VMultipleScattering::AlongStepDoIt(const G4Track&,
const G4Step& step)
{
fParticleChange.ProposeTrueStepLength(
currentModel->ComputeTrueStepLength(step.GetStepLength()));
return &fParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4VMultipleScattering::PostStepDoIt(const G4Track& track,
const G4Step& step)
{
fParticleChange.Initialize(track);
currentModel->SampleScattering(track.GetDynamicParticle(),
step.GetPostStepPoint()->GetSafety());
return &fParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PhysicsVector* G4VMultipleScattering::PhysicsVector(const G4MaterialCutsCouple* couple)
{
G4int nbins = 3;
@@ -363,12 +422,12 @@ G4bool G4VMultipleScattering::StorePhysicsTable(const G4ParticleDefinition* part
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
G4bool
G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* part,
const G4String& directory,
G4bool ascii)
{
if(0 < verboseLevel) {
// G4cout << "========================================================" << G4endl;
G4cout << "G4VMultipleScattering::RetrievePhysicsTable() for "
<< part->GetParticleName() << " and process "
<< GetProcessName() << G4endl;
@@ -380,20 +439,27 @@ G4bool G4VMultipleScattering::RetrievePhysicsTable(const G4ParticleDefinition* p
const G4String particleName = part->GetParticleName();
G4String filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
yes =
G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii);
if ( yes ) {
if (0 < verboseLevel) {
G4cout << "Lambda table for " << part->GetParticleName() << " is retrieved from <"
G4cout << "Lambda table for " << part->GetParticleName()
<< " is retrieved from <"
<< filename << ">"
<< G4endl;
}
if((G4LossTableManager::Instance())->SplineFlag()) {
size_t n = theLambdaTable->length();
for(size_t i=0; i<n; i++) {(* theLambdaTable)[i]->SetSpline(true);}
for(size_t i=0; i<n; ++i) {
if((* theLambdaTable)[i]) {
(* theLambdaTable)[i]->SetSpline(true);
}
}
}
} else {
if (1 < verboseLevel) {
G4cout << "Lambda table for " << part->GetParticleName() << " in file <"
G4cout << "Lambda table for " << part->GetParticleName()
<< " in file <"
<< filename << "> is not exist"
<< G4endl;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ionEffectiveCharge.cc,v 1.24 2008/12/18 13:01:46 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ionEffectiveCharge.cc,v 1.25 2009/10/29 16:57:39 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// -------------------------------------------------------------------
//
@@ -104,10 +104,13 @@ G4double G4ionEffectiveCharge::EffectiveCharge(const G4ParticleDefinition* p,
// Vol.1, Pergamon Press, 1985
// Fast ions or hadrons
G4double reducedEnergy = kineticEnergy * proton_mass_c2/mass ;
//G4cout << "e= " << reducedEnergy << " Zi= " << Zi << " " << material->GetName() << G4endl;
if( reducedEnergy > Zi*energyHighLimit || Zi < 1.5 || !material) return charge;
G4double z = material->GetIonisation()->GetZeffective();
// reducedEnergy = std::max(reducedEnergy,energyLowLimit);
reducedEnergy = std::max(reducedEnergy,energyLowLimit);
// Helium ion case
if( Zi < 2.5 ) {