85G4RegionModels::G4RegionModels(
G4int nMod, std::vector<G4int>& indx,
88 nModelsForRegion = nMod;
89 theListOfModelIndexes =
new G4int [nModelsForRegion];
90 lowKineticEnergy =
new G4double [nModelsForRegion+1];
91 for (
G4int i=0; i<nModelsForRegion; ++i) {
92 theListOfModelIndexes[i] = indx[i];
93 lowKineticEnergy[i] = lowE[i];
95 lowKineticEnergy[nModelsForRegion] = lowE[nModelsForRegion];
101G4RegionModels::~G4RegionModels()
103 delete [] theListOfModelIndexes;
104 delete [] lowKineticEnergy;
130 maxSubCutInRange = 0.7*mm;
132 flucModels.reserve(4);
134 orderOfModels.reserve(4);
136 severalModels =
true;
157 if(1 < verboseLevel) {
160 size_t n = setOfRegionModels.size();
162 for(
size_t i=0; i<n; ++i) {
163 delete setOfRegionModels[i];
164 setOfRegionModels[i] = 0;
175 G4cout <<
"G4EmModelManager::AddEmModel WARNING: no model defined."
180 flucModels.push_back(fm);
181 regions.push_back(r);
182 orderOfModels.push_back(num);
194 for(
G4int i=0; i<nEmModels; ++i) {
195 if(nam == models[i]->GetName()) {
196 models[i]->SetLowEnergyLimit(emin);
197 models[i]->SetHighEnergyLimit(emax);
202 G4cout <<
"G4EmModelManager::UpdateEmModel WARNING: no model <"
203 << nam <<
"> is found out"
212 if(i >= 0 && i < nEmModels) { model = models[i]; }
213 else if(verboseLevel > 0 && ver) {
214 G4cout <<
"G4EmModelManager::GetModel WARNING: "
215 <<
"index " << i <<
" is wrong Nmodels= "
233 if(1 < verboseLevel) {
234 G4cout <<
"G4EmModelManager::Initialise() for "
242 G4Exception(
"G4EmModelManager::Initialise",
"em0002",
251 regionStore->
GetRegion(
"DefaultRegionForTheWorld",
false);
255 std::vector<const G4Region*> setr;
256 setr.push_back(world);
259 for (
G4int ii=0; ii<nEmModels; ++ii) {
261 if ( r == 0 || r == world) {
267 for (
G4int j=1; j<nRegions; ++j) {
268 if ( r == setr[j] ) newRegion =
false;
280 ed <<
"No models defined for the World volume for " << p->
GetParticleName()
282 G4Exception(
"G4EmModelManager::Initialise",
"em0002",
291 if(nRegions > 1 && nEmModels > 1) {
292 if(numOfCouples > idxOfRegionModels.size()) {
293 idxOfRegionModels.resize(numOfCouples);
297 if(nEmModels > 1) { nr = nRegions; }
298 if(nr > setOfRegionModels.size()) { setOfRegionModels.resize(nr); }
300 std::vector<G4int> modelAtRegion(nEmModels);
301 std::vector<G4int> modelOrd(nEmModels);
306 for (
G4int reg=0; reg<nRegions; ++reg) {
310 for (
G4int ii=0; ii<nEmModels; ++ii) {
313 if ( region == regions[ii] ) {
317 G4int ord = orderOfModels[ii];
322 if(1 < verboseLevel) {
324 <<
" <" << model->
GetName() <<
"> for region <";
327 <<
" tmin(MeV)= " << tmin/MeV
328 <<
"; tmax(MeV)= " << tmax/MeV
329 <<
"; order= " << ord
336 tmin = std::min(tmin, eHigh[n-1]);
337 tmax = std::max(tmax, eLow[0]);
341 if( tmax - tmin <= eV) push =
false;
343 else if (tmax == eLow[0]) {
348 }
else if(tmin < eHigh[n-1]) {
350 for(
G4int k=0; k<n; ++k) {
352 if(ord >= modelOrd[k]) {
353 if(tmin < eHigh[k] && tmin >= eLow[k]) tmin = eHigh[k];
354 if(tmax <= eHigh[k] && tmax > eLow[k]) tmax = eLow[k];
355 if(tmax > eHigh[k] && tmin < eLow[k]) {
356 if(tmax - eHigh[k] > eLow[k] - tmin) tmin = eHigh[k];
359 if( tmax - tmin <= eV) {
368 if (tmax == eLow[0]) {
373 }
else if(tmin < eHigh[n-1]) {
375 if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
378 }
else if(tmin <= eLow[0] && tmax < eHigh[0]) {
385 for(
G4int k=0; k<n; ++k) {
386 if(tmin <= eLow[k] && tmax >= eHigh[k]) {
388 modelAtRegion[k] = ii;
399 for(
G4int k=n-1; k>=idx; --k) {
400 modelAtRegion[k+1] = modelAtRegion[k];
401 modelOrd[k+1] = modelOrd[k];
403 eHigh[k+1] = eHigh[k];
408 if (push || insert) {
410 modelAtRegion[idx] = ii;
419 eLow[n] = eHigh[n-1];
421 if(1 < verboseLevel) {
422 G4cout <<
"New G4RegionModels set with " << n <<
" models for region <";
424 G4cout <<
"> Elow(MeV)= ";
425 for(
G4int ii=0; ii<=n; ++ii) {
G4cout << eLow[ii]/MeV <<
" ";}
429 setOfRegionModels[reg] = rm;
430 if(1 == nEmModels) {
break; }
433 currRegionModel = setOfRegionModels[0];
437 if(secondaryParticle) {
445 if(minSubRange < 1.0) {
447 theSubCuts->resize(numOfCouples,
DBL_MAX);
449 for(
size_t i=0; i<numOfCouples; ++i) {
457 if(nRegions > 1 && nEmModels > 1) {
459 do {--reg;}
while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
460 idxOfRegionModels[i] = reg;
462 if(1 < verboseLevel) {
463 G4cout <<
"G4EmModelManager::Initialise() for "
465 <<
" indexOfCouple= " << i
466 <<
" indexOfRegion= " << reg
471 if(secondaryParticle) {
474 if( cut <
DBL_MAX && minSubRange < 1.0) {
480 if(tcutmax < subcut) { subcut = tcutmax; }
481 (*theSubCuts)[i] = subcut;
488 severalModels =
true;
489 for(
G4int jj=0; jj<nEmModels; ++jj) {
490 if(1 == isUsed[jj]) {
492 currModel = models[jj];
494 if(flucModels[jj]) { flucModels[jj]->InitialiseMe(particle); }
497 if(1 == nn) { severalModels =
false; }
499 if(1 < verboseLevel) {
501 <<
" is initialised; nRegions= " << nRegions
521 if(theSubCuts) { emin = (*theSubCuts)[i]; }
524 if(1 < verboseLevel) {
525 G4cout <<
"G4EmModelManager::FillDEDXVector() for "
527 <<
" cut(MeV)= " << cut
528 <<
" emin(MeV)= " << emin
535 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; }
537 G4int nmod = regModels->NumberOfModels();
546 for(
size_t j=0; j<totBinsLoss; ++j) {
554 do {--k;}
while (k>0 && e <= regModels->LowEdgeEnergy(k));
556 if(k > 0 && k != k0) {
558 G4double elow = regModels->LowEdgeEnergy(k);
559 G4double dedx1 = ComputeDEDX(models[regModels->ModelIndex(k-1)],
560 couple,elow,cut,emin);
561 G4double dedx2 = ComputeDEDX(models[regModels->ModelIndex(k)],
562 couple,elow,cut,emin);
564 if(dedx2 > 0.0) { del = (dedx1/dedx2 - 1.0)*elow; }
570 ComputeDEDX(models[regModels->ModelIndex(k)],couple,e,cut,emin);
571 dedx *= (1.0 + del/e);
573 if(2 < verboseLevel) {
575 <<
" E(MeV)= " << e/MeV
576 <<
" dEdx(MeV/mm)= " << dedx*mm/MeV
577 <<
" del= " << del*mm/MeV<<
" k= " << k
578 <<
" modelIdx= " << regModels->ModelIndex(k)
581 if(dedx < 0.0) { dedx = 0.0; }
598 if(theSubCuts) { cut = (*theSubCuts)[i]; }
602 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; }
604 G4int nmod = regModels->NumberOfModels();
605 if(1 < verboseLevel) {
606 G4cout <<
"G4EmModelManager::FillLambdaVector() for "
609 <<
" Ecut(MeV)= " << cut
610 <<
" Emax(MeV)= " << tmax
621 G4VEmModel* mod = models[regModels->ModelIndex(0)];
622 for(
size_t j=0; j<totBinsLambda; ++j) {
629 do {--k;}
while (k>0 && e <= regModels->LowEdgeEnergy(k));
630 if(k > 0 && k != k0) {
632 G4double elow = regModels->LowEdgeEnergy(k);
633 G4VEmModel* mod1 = models[regModels->ModelIndex(k-1)];
635 mod = models[regModels->ModelIndex(k)];
638 if(xs2 > 0.0) { del = (xs1/xs2 - 1.0)*elow; }
644 cross *= (1.0 + del/e);
647 if(j==0 && startFromNull) { cross = 0.0; }
649 if(2 < verboseLevel) {
650 G4cout <<
"FillLambdaVector: " << j <<
". e(MeV)= " << e/MeV
651 <<
" cross(1/mm)= " << cross*mm
652 <<
" del= " << del*mm <<
" k= " << k
653 <<
" modelIdx= " << regModels->ModelIndex(k)
656 if(cross < 0.0) { cross = 0.0; }
665 if(verb == 0) {
return; }
666 for(
G4int i=0; i<nRegions; ++i) {
669 G4int n = r->NumberOfModels();
671 G4cout <<
" ===== EM models for the G4Region " << reg->
GetName()
673 for(
G4int j=0; j<n; ++j) {
686 size_t kk = table->size();
687 for(
size_t k=0; k<kk; ++k) {
691 G4cout <<
" Table with " << nn <<
" bins Emin= "
700 if(an) {
G4cout <<
" " << an->GetName(); }
705 if(1 == nEmModels) {
break; }
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4DLLIMPORT std::ostream G4cout
void UpdateEmModel(const G4String &, G4double, G4double)
void AddEmModel(G4int, G4VEmModel *, G4VEmFluctuationModel *, const G4Region *)
void DumpModelList(G4int verb)
G4VEmModel * GetModel(G4int, G4bool ver=false)
void FillLambdaVector(G4PhysicsVector *, const G4MaterialCutsCouple *, G4bool startFromNull=true, G4EmTableType t=fRestricted)
void FillDEDXVector(G4PhysicsVector *, const G4MaterialCutsCouple *, G4EmTableType t=fRestricted)
const G4DataVector * Initialise(const G4ParticleDefinition *, const G4ParticleDefinition *, G4double, G4int)
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
const G4String & GetName() const
const G4String & GetParticleName() const
size_t GetVectorLength() const
G4double Energy(size_t index) const
void PutValue(size_t index, G4double theValue)
static G4Positron * Positron()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
size_t GetTableSize() const
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
G4double GetProductionCut(G4int index) const
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
G4VEmAngularDistribution * GetAngularDistribution()
G4double LowEnergyLimit() const
G4double HighEnergyLimit() const
virtual void DefineForRegion(const G4Region *)
G4double HighEnergyActivationLimit() const
G4double CrossSection(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4bool DeexcitationFlag() const
const G4String & GetName() const
G4PhysicsTable * GetCrossSectionTable()
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)=0
G4double LowEnergyActivationLimit() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription