Import Geant4 9.4.0 source tree
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4EmConfigurator.cc,v 1.6 2009/11/22 19:48:30 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
// $Id: G4EmConfigurator.cc,v 1.9 2010/07/29 11:13:28 vnivanch Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
@@ -60,11 +60,9 @@
|
||||
#include "G4VEmProcess.hh"
|
||||
#include "G4VMultipleScattering.hh"
|
||||
|
||||
enum PType {unknown=0, eloss, discrete, msc};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4EmConfigurator::G4EmConfigurator()
|
||||
G4EmConfigurator::G4EmConfigurator(G4int val):verbose(val)
|
||||
{
|
||||
index = -10;
|
||||
}
|
||||
@@ -76,35 +74,6 @@ G4EmConfigurator::~G4EmConfigurator()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::AddExtraEmModel(const G4String& particleName,
|
||||
G4VEmModel* em,
|
||||
G4VEmFluctuationModel* fm)
|
||||
{
|
||||
particleList.push_back(particleName);
|
||||
modelList.push_back(em);
|
||||
flucModelList.push_back(fm);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::AddModelForRegion(const G4String& particleName,
|
||||
const G4String& processName,
|
||||
const G4String& modelName,
|
||||
const G4String& regionName,
|
||||
G4double emin, G4double emax,
|
||||
const G4String& flucModelName)
|
||||
{
|
||||
particles.push_back(particleName);
|
||||
processes.push_back(processName);
|
||||
models.push_back(modelName);
|
||||
regions.push_back(regionName);
|
||||
flucModels.push_back(flucModelName);
|
||||
lowEnergy.push_back(emin);
|
||||
highEnergy.push_back(emax);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::SetExtraEmModel(const G4String& particleName,
|
||||
const G4String& processName,
|
||||
G4VEmModel* mod,
|
||||
@@ -113,27 +82,275 @@ void G4EmConfigurator::SetExtraEmModel(const G4String& particleName,
|
||||
G4double emax,
|
||||
G4VEmFluctuationModel* fm)
|
||||
{
|
||||
AddExtraEmModel(particleName, mod, fm);
|
||||
G4String fname = "";
|
||||
if(fm) fname = fm->GetName();
|
||||
G4String mname = "";
|
||||
if(mod) mname = mod->GetName();
|
||||
AddModelForRegion(particleName, processName, mname, regionName,
|
||||
emin, emax, fname);
|
||||
if(1 < verbose) {
|
||||
G4cout << " G4EmConfigurator::SetExtraEmModel " << mod->GetName()
|
||||
<< " for " << particleName
|
||||
<< " and " << processName
|
||||
<< " in the region <" << regionName
|
||||
<< "> Emin(MeV)= " << emin/MeV
|
||||
<< " Emax(MeV)= " << emax/MeV
|
||||
<< G4endl;
|
||||
}
|
||||
if(mod || fm) {
|
||||
models.push_back(mod);
|
||||
flucModels.push_back(fm);
|
||||
} else {
|
||||
models.push_back(new G4DummyModel());
|
||||
flucModels.push_back(0);
|
||||
}
|
||||
|
||||
particles.push_back(particleName);
|
||||
processes.push_back(processName);
|
||||
regions.push_back(regionName);
|
||||
lowEnergy.push_back(emin);
|
||||
highEnergy.push_back(emax);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::AddModels()
|
||||
{
|
||||
size_t n = particles.size();
|
||||
//G4cout << " G4EmConfigurator::AddModels n= " << n << G4endl;
|
||||
size_t n = models.size();
|
||||
if(0 < verbose) {
|
||||
G4cout << "### G4EmConfigurator::AddModels n= " << n << G4endl;
|
||||
}
|
||||
if(n > 0) {
|
||||
for(size_t i=0; i<n; i++) {
|
||||
SetModelForRegion(particles[i],processes[i],models[i],regions[i],
|
||||
flucModels[i],lowEnergy[i],highEnergy[i]);
|
||||
for(size_t i=0; i<n; ++i) {
|
||||
if(models[i]) {
|
||||
G4Region* reg = FindRegion(regions[i]);
|
||||
if(reg) {
|
||||
--index;
|
||||
SetModelForRegion(models[i],flucModels[i],reg,
|
||||
particles[i],processes[i],
|
||||
lowEnergy[i],highEnergy[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Clear();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::SetModelForRegion(G4VEmModel* mod,
|
||||
G4VEmFluctuationModel* fm,
|
||||
G4Region* reg,
|
||||
const G4String& particleName,
|
||||
const G4String& processName,
|
||||
G4double emin, G4double emax)
|
||||
{
|
||||
if(1 < verbose) {
|
||||
G4cout << " G4EmConfigurator::SetModelForRegion: " << mod->GetName()
|
||||
<< G4endl;
|
||||
G4cout << " For " << particleName
|
||||
<< " and " << processName
|
||||
<< " in the region <" << reg->GetName()
|
||||
<< " Emin(MeV)= " << emin/MeV
|
||||
<< " Emax(MeV)= " << emax/MeV;
|
||||
if(fm) { G4cout << " FLmodel " << fm->GetName(); }
|
||||
G4cout << G4endl;
|
||||
}
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
|
||||
G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ) {
|
||||
const G4ParticleDefinition* part = theParticleIterator->value();
|
||||
|
||||
//G4cout << particleName << " " << part->GetParticleName() << G4endl;
|
||||
|
||||
if((part->GetParticleName() == particleName) ||
|
||||
(particleName == "all") ||
|
||||
(particleName == "charged" && part->GetPDGCharge() != 0.0)) {
|
||||
|
||||
// search for process
|
||||
G4ProcessManager* pmanager = part->GetProcessManager();
|
||||
G4ProcessVector* plist = pmanager->GetProcessList();
|
||||
G4int np = pmanager->GetProcessListLength();
|
||||
|
||||
//G4cout << processName << " in list of " << np << G4endl;
|
||||
|
||||
G4VProcess* proc = 0;
|
||||
for(G4int i=0; i<np; ++i) {
|
||||
if(processName == (*plist)[i]->GetProcessName()) {
|
||||
proc = (*plist)[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!proc) {
|
||||
G4cout << "### G4EmConfigurator WARNING: fails to find a process <"
|
||||
<< processName << "> for " << particleName << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(mod) {
|
||||
if(!UpdateModelEnergyRange(mod, emin, emax)) { return; }
|
||||
}
|
||||
// classify process
|
||||
G4int ii = proc->GetProcessSubType();
|
||||
if(10 == ii && mod) {
|
||||
G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
|
||||
p->AddEmModel(index,mod,reg);
|
||||
if(1 < verbose) {
|
||||
G4cout << "### Added msc model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
return;
|
||||
} else if(2 <= ii && 4 >= ii) {
|
||||
G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
|
||||
if(!mod && fm) {
|
||||
p->SetFluctModel(fm);
|
||||
} else {
|
||||
p->AddEmModel(index,mod,fm,reg);
|
||||
if(1 < verbose) {
|
||||
G4cout << "### Added eloss model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if(mod) {
|
||||
G4VEmProcess* p = static_cast<G4VEmProcess*>(proc);
|
||||
p->AddEmModel(index,mod,reg);
|
||||
if(1 < verbose) {
|
||||
G4cout << "### Added em model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void
|
||||
G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
|
||||
G4VEnergyLossProcess* p)
|
||||
{
|
||||
size_t n = particles.size();
|
||||
if(1 < verbose) {
|
||||
G4cout << " G4EmConfigurator::PrepareModels for EnergyLoss n= "
|
||||
<< n << G4endl;
|
||||
}
|
||||
if(n > 0) {
|
||||
G4String particleName = aParticle->GetParticleName();
|
||||
G4String processName = p->GetProcessName();
|
||||
//G4cout << particleName << " " << processName << G4endl;
|
||||
for(size_t i=0; i<n; ++i) {
|
||||
//G4cout << particles[i] << " " << processes[i] << G4endl;
|
||||
if(processName == processes[i]) {
|
||||
if((particleName == particles[i]) ||
|
||||
(particles[i] == "all") ||
|
||||
(particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
|
||||
G4Region* reg = FindRegion(regions[i]);
|
||||
//G4cout << "Region " << reg << G4endl;
|
||||
if(reg) {
|
||||
--index;
|
||||
G4VEmModel* mod = models[i];
|
||||
G4VEmFluctuationModel* fm = flucModels[i];
|
||||
if(mod) {
|
||||
if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
|
||||
p->AddEmModel(index,mod,fm,reg);
|
||||
if(1 < verbose) {
|
||||
G4cout << "### Added eloss model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
}
|
||||
} else if(fm) {
|
||||
p->SetFluctModel(fm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void
|
||||
G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
|
||||
G4VEmProcess* p)
|
||||
{
|
||||
size_t n = particles.size();
|
||||
if(1 < verbose) {
|
||||
G4cout << " G4EmConfigurator::PrepareModels for EM process n= "
|
||||
<< n << G4endl;
|
||||
}
|
||||
if(n > 0) {
|
||||
G4String particleName = aParticle->GetParticleName();
|
||||
G4String processName = p->GetProcessName();
|
||||
//G4cout << particleName << " " << particleName << G4endl;
|
||||
for(size_t i=0; i<n; ++i) {
|
||||
if(processName == processes[i]) {
|
||||
if((particleName == particles[i]) ||
|
||||
(particles[i] == "all") ||
|
||||
(particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
|
||||
G4Region* reg = FindRegion(regions[i]);
|
||||
//G4cout << "Region " << reg << G4endl;
|
||||
if(reg) {
|
||||
--index;
|
||||
G4VEmModel* mod = models[i];
|
||||
if(mod) {
|
||||
if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
|
||||
p->AddEmModel(index,mod,reg);
|
||||
if(1 < verbose) {
|
||||
G4cout << "### Added em model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void
|
||||
G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
|
||||
G4VMultipleScattering* p)
|
||||
{
|
||||
size_t n = particles.size();
|
||||
if(1 < verbose) {
|
||||
G4cout << " G4EmConfigurator::PrepareModels for MSC process n= "
|
||||
<< n << G4endl;
|
||||
}
|
||||
|
||||
if(n > 0) {
|
||||
G4String particleName = aParticle->GetParticleName();
|
||||
G4String processName = p->GetProcessName();
|
||||
for(size_t i=0; i<n; ++i) {
|
||||
if(processName == processes[i]) {
|
||||
if((particleName == particles[i]) ||
|
||||
(particles[i] == "all") ||
|
||||
(particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
|
||||
G4Region* reg = FindRegion(regions[i]);
|
||||
if(reg) {
|
||||
--index;
|
||||
G4VEmModel* mod = models[i];
|
||||
if(mod) {
|
||||
if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
|
||||
p->AddEmModel(index,mod,reg);
|
||||
G4cout << "### Added msc model order= " << index << " for "
|
||||
<< particleName << " and " << processName << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::Clear()
|
||||
{
|
||||
particles.clear();
|
||||
processes.clear();
|
||||
models.clear();
|
||||
@@ -145,147 +362,50 @@ void G4EmConfigurator::AddModels()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void G4EmConfigurator::SetModelForRegion(const G4String& particleName,
|
||||
const G4String& processName,
|
||||
const G4String& modelName,
|
||||
const G4String& regionName,
|
||||
const G4String& flucModelName,
|
||||
G4double emin, G4double emax)
|
||||
G4Region* G4EmConfigurator::FindRegion(const G4String& regionName)
|
||||
{
|
||||
//G4cout << " G4EmConfigurator::SetModelForRegion" << G4endl;
|
||||
|
||||
// new set
|
||||
--index;
|
||||
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
|
||||
G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ) {
|
||||
const G4ParticleDefinition* part = theParticleIterator->value();
|
||||
|
||||
//G4cout << particleName << " " << part->GetParticleName() << G4endl;
|
||||
|
||||
if(particleName == part->GetParticleName() ||
|
||||
(particleName == "charged" && part->GetPDGCharge() != 0.0) ) {
|
||||
|
||||
|
||||
// search for process
|
||||
G4ProcessManager* pmanager = part->GetProcessManager();
|
||||
G4ProcessVector* plist = pmanager->GetProcessList();
|
||||
G4int np = pmanager->GetProcessListLength();
|
||||
|
||||
//G4cout << processName << " in list of " << np << G4endl;
|
||||
|
||||
G4VProcess* proc = 0;
|
||||
for(G4int i=0; i<np; i++) {
|
||||
if(processName == (*plist)[i]->GetProcessName()) {
|
||||
proc = (*plist)[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!proc) {
|
||||
G4cout << "### G4EmConfigurator WARNING: fails to find a process <"
|
||||
<< processName << "> for " << particleName << G4endl;
|
||||
|
||||
} else {
|
||||
|
||||
// classify process
|
||||
PType ptype = discrete;
|
||||
G4int ii = proc->GetProcessSubType();
|
||||
if(10 == ii) ptype = msc;
|
||||
else if(2 <= ii && 4 >= ii) ptype = eloss;
|
||||
|
||||
// find out model
|
||||
G4VEmModel* mod = 0;
|
||||
G4VEmFluctuationModel* fluc = 0;
|
||||
|
||||
G4int nm = modelList.size();
|
||||
//G4cout << "Search model " << modelName << " in " << nm << G4endl;
|
||||
|
||||
for(G4int i=0; i<nm; i++) {
|
||||
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];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if("dummy" == modelName) mod = new G4DummyModel();
|
||||
|
||||
if(!mod) {
|
||||
|
||||
// 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
|
||||
G4Region* reg = 0;
|
||||
G4RegionStore* regStore = G4RegionStore::GetInstance();
|
||||
G4String r = regionName;
|
||||
if(r == "" || r == "world" || r == "World") r = "DefaultRegionForTheWorld";
|
||||
reg = regStore->GetRegion(r, true);
|
||||
if(!reg) {
|
||||
G4cout << "### G4EmConfigurator WARNING: fails to find a region <"
|
||||
<< r << "> for model <" << modelName << "> of the process "
|
||||
<< processName << " and " << particleName << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// energy limits
|
||||
G4double e1 = std::max(emin,mod->LowEnergyLimit());
|
||||
G4double e2 = std::min(emax,mod->HighEnergyLimit());
|
||||
if(e2 < e1) e2 = e1;
|
||||
mod->SetLowEnergyLimit(e1);
|
||||
mod->SetHighEnergyLimit(e2);
|
||||
|
||||
//G4cout << "index= " << index << " e1= " << e1 << " e2= " << e2 << G4endl;
|
||||
|
||||
// added model
|
||||
if(ptype == eloss) {
|
||||
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 = static_cast<G4VEmProcess*>(proc);
|
||||
p->AddEmModel(index,mod,reg);
|
||||
} else if(ptype == msc) {
|
||||
//G4cout << "### Added msc model order= " << index << " for "
|
||||
// << particleName << " and " << processName << " " << mod << G4endl;
|
||||
G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
|
||||
p->AddEmModel(index,mod,reg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// search for region
|
||||
G4Region* reg = 0;
|
||||
G4RegionStore* regStore = G4RegionStore::GetInstance();
|
||||
G4String r = regionName;
|
||||
if(r == "" || r == "world" || r == "World") {
|
||||
r = "DefaultRegionForTheWorld";
|
||||
}
|
||||
reg = regStore->GetRegion(r, true);
|
||||
if(!reg) {
|
||||
G4cout << "### G4EmConfigurator WARNING: fails to find a region <"
|
||||
<< r << G4endl;
|
||||
} else if(verbose > 1) {
|
||||
G4cout << "### G4EmConfigurator finds out G4Region <" << r << ">"
|
||||
<< G4endl;
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool G4EmConfigurator::UpdateModelEnergyRange(G4VEmModel* mod,
|
||||
G4double emin, G4double emax)
|
||||
{
|
||||
// energy limits
|
||||
G4double e1 = std::max(emin,mod->LowEnergyLimit());
|
||||
G4double e2 = std::min(emax,mod->HighEnergyLimit());
|
||||
if(e2 <= e1) {
|
||||
G4cout << "### G4EmConfigurator WARNING: empty energy interval"
|
||||
<< " for <" << mod->GetName()
|
||||
<< "> Emin(MeV)= " << e1/CLHEP::MeV
|
||||
<< "> Emax(MeV)= " << e2/CLHEP::MeV
|
||||
<< G4endl;
|
||||
return false;
|
||||
}
|
||||
mod->SetLowEnergyLimit(e1);
|
||||
mod->SetHighEnergyLimit(e2);
|
||||
if(verbose > 1) {
|
||||
G4cout << "### G4EmConfigurator for " << mod->GetName()
|
||||
<< " Emin(MeV)= " << e1/MeV << " Emax(MeV)= " << e2/MeV
|
||||
<< G4endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user