250 G4String partname =
p->GetParticleName();
251 if(1 < verboseLevel) {
252 G4cout <<
"G4EmModelManager::Initialise() for "
253 << partname <<
" Nmodels= " << nEmModels <<
G4endl;
258 ed <<
"No models found out for " <<
p->GetParticleName()
260 G4Exception(
"G4EmModelManager::Initialise",
"em0002",
269 regionStore->
GetRegion(
"DefaultRegionForTheWorld",
false);
273 std::vector<const G4Region*> setr;
274 setr.push_back(world);
277 for (
G4int ii=0; ii<nEmModels; ++ii) {
279 if ( r == 0 || r == world) {
285 for (
G4int j=1; j<nRegions; ++j) {
286 if ( r == setr[j] ) { newRegion =
false; }
298 ed <<
"No models defined for the World volume for "
299 <<
p->GetParticleName() <<
" !";
300 G4Exception(
"G4EmModelManager::Initialise",
"em0002",
310 if(nRegions > 1 && nEmModels > 1) {
311 idxOfRegionModels.resize(numOfCouples,0);
312 setOfRegionModels.resize((
size_t)nRegions,0);
314 idxOfRegionModels.resize(1,0);
315 setOfRegionModels.resize(1,0);
318 std::vector<G4int> modelAtRegion(nEmModels);
319 std::vector<G4int> modelOrd(nEmModels);
323 if(1 < verboseLevel) {
324 G4cout <<
" Nregions= " << nRegions
325 <<
" Nmodels= " << nEmModels <<
G4endl;
333 for (
G4int ii=0; ii<nEmModels; ++ii) {
336 if ( region == regions[ii] ) {
340 G4int ord = orderOfModels[ii];
345 if(1 < verboseLevel) {
347 <<
" <" << model->
GetName() <<
"> for region <";
350 <<
" tmin(MeV)= " << tmin/
MeV
351 <<
"; tmax(MeV)= " << tmax/
MeV
352 <<
"; order= " << ord
367 if( tmax - tmin <= limitdelta) { push =
false; }
369 else if (tmax == eLow[0]) {
374 }
else if(tmin < eHigh[n-1]) {
376 for(
G4int k=0; k<
n; ++k) {
380 if(ord >= modelOrd[k]) {
381 if(tmin < eHigh[k] && tmin >= eLow[k]) { tmin = eHigh[k]; }
382 if(tmax <= eHigh[k] && tmax > eLow[k]) { tmax = eLow[k]; }
383 if(tmax > eHigh[k] && tmin < eLow[k]) {
384 if(tmax - eHigh[k] > eLow[k] - tmin) { tmin = eHigh[k]; }
385 else { tmax = eLow[k]; }
387 if( tmax - tmin <= limitdelta) {
402 if (tmax <= eLow[0]) {
407 }
else if(tmin < eHigh[n-1]) {
409 if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
412 }
else if(tmin <= eLow[0] && tmax < eHigh[0]) {
419 for(
G4int k=n-1; k>=0; --k) {
420 if(tmin <= eLow[k] && tmax >= eHigh[k]) {
422 isUsed[modelAtRegion[k]] = 0;
426 for(
G4int kk=k; kk<n-1; ++kk) {
427 modelAtRegion[kk] = modelAtRegion[kk+1];
428 modelOrd[kk] = modelOrd[kk+1];
429 eLow[kk] = eLow[kk+1];
430 eHigh[kk] = eHigh[kk+1];
437 if(tmin <= eLow[k] && tmax > eLow[k]) {
442 }
else if(tmin < eHigh[k] && tmax >= eHigh[k]) {
449 }
else if(tmin > eLow[k] && tmax < eHigh[k]) {
450 if(eHigh[k] - tmax > tmin - eLow[k]) {
472 for(
G4int k=n-1; k>=idx; --k) {
473 modelAtRegion[k+1] = modelAtRegion[k];
474 modelOrd[k+1] = modelOrd[k];
476 eHigh[k+1] = eHigh[k];
482 if (push || insert) {
484 modelAtRegion[idx] = ii;
491 for(
G4int k=n-1; k>=0; --k) {
492 if(eHigh[k] - eLow[k] <= limitdelta) {
493 isUsed[modelAtRegion[k]] = 0;
495 for(
G4int kk=k; kk<n-1; ++kk) {
496 modelAtRegion[kk] = modelAtRegion[kk+1];
497 modelOrd[kk] = modelOrd[kk+1];
498 eLow[kk] = eLow[kk+1];
499 eHigh[kk] = eHigh[kk+1];
508 eLow[
n] = eHigh[n-1];
510 if(1 < verboseLevel) {
511 G4cout <<
"### New G4RegionModels set with " << n <<
" models for region <";
513 G4cout <<
"> Elow(MeV)= ";
518 setOfRegionModels[
reg] = rm;
520 if(1 == nEmModels) {
break; }
523 currRegionModel = setOfRegionModels[0];
524 currModel = models[0];
528 if(secondaryParticle) {
539 if(theCutsNew) { *theCutsNew = *theCuts; }
541 if(minSubRange < 1.0) {
543 theSubCuts->resize(numOfCouples,
DBL_MAX);
548 for(
size_t i=0; i<numOfCouples; ++i) {
556 if(nRegions > 1 && nEmModels > 1) {
559 do {--
reg;}
while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
560 idxOfRegionModels[i] =
reg;
562 if(1 < verboseLevel) {
563 G4cout <<
"G4EmModelManager::Initialise() for "
565 <<
" indexOfCouple= " << i
566 <<
" indexOfRegion= " << reg
571 if(secondaryParticle) {
574 if( cut <
DBL_MAX && minSubRange < 1.0) {
581 if(tcutmax < subcut) { subcut = tcutmax; }
582 (*theSubCuts)[i] = subcut;
588 if(nRegions > 1 && nEmModels > 1) {
589 inn = idxOfRegionModels[i];
593 currRegionModel = setOfRegionModels[inn];
594 nnm = currRegionModel->NumberOfModels();
598 for(
G4int jj=0; jj<nnm; ++jj) {
601 currModel = models[currRegionModel->ModelIndex(jj)];
604 if(!theCutsNew) { theCutsNew =
new G4DataVector(*theCuts); }
605 (*theCutsNew)[i] = cutlim;
617 if(theCutsNew) { theCuts = theCutsNew; }
621 severalModels =
true;
622 for(
G4int jj=0; jj<nEmModels; ++jj) {
623 if(1 == isUsed[jj]) {
625 currModel = models[jj];
627 if(flucModels[jj]) { flucModels[jj]->InitialiseMe(particle); }
630 if(1 == nn) { severalModels =
false; }
632 if(1 < verboseLevel) {
633 G4cout <<
"G4EmModelManager for " << partname
634 <<
" is initialised; nRegions= " << nRegions
635 <<
" severalModels: " << severalModels
G4double LowEnergyActivationLimit() const
G4double HighEnergyActivationLimit() const
G4double LowEnergyLimit() const
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
std::ostringstream G4ExceptionDescription
G4double HighEnergyLimit() const
G4double GetProductionCut(G4int index) const
const G4String & GetName() const
virtual G4double MinEnergyCut(const G4ParticleDefinition *, const G4MaterialCutsCouple *)
static const G4double reg
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)=0
static G4RegionStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
size_t GetTableSize() const
static constexpr double eV
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ProductionCutsTable * GetProductionCutsTable()
static G4Positron * Positron()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static G4Electron * Electron()
static constexpr double MeV
const G4String & GetName() const
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
G4ProductionCuts * GetProductionCuts() const
const XML_Char XML_Content * model
const G4Material * GetMaterial() const