Geant4-11
Public Member Functions | Private Attributes
G4EmModelManager Class Reference

#include <G4EmModelManager.hh>

Public Member Functions

void AddEmModel (G4int, G4VEmModel *, G4VEmFluctuationModel *fm, const G4Region *r)
 
void Clear ()
 
const G4DataVectorCuts () const
 
void DumpModelList (std::ostream &out, G4int verb)
 
void FillDEDXVector (G4PhysicsVector *, const G4MaterialCutsCouple *, G4EmTableType t=fRestricted)
 
void FillLambdaVector (G4PhysicsVector *, const G4MaterialCutsCouple *, G4bool startFromNull=true, G4EmTableType t=fRestricted)
 
 G4EmModelManager ()
 
 G4EmModelManager (G4EmModelManager &)=delete
 
G4VEmModelGetModel (G4int idx, G4bool ver=false)
 
G4VEmModelGetRegionModel (G4int idx, size_t index_couple)
 
const G4DataVectorInitialise (const G4ParticleDefinition *part, const G4ParticleDefinition *secPart, G4double, G4int verb)
 
G4int NumberOfModels () const
 
G4int NumberOfRegionModels (size_t index_couple) const
 
G4EmModelManageroperator= (const G4EmModelManager &right)=delete
 
G4VEmModelSelectModel (G4double energy, size_t index)
 
void SetFluoFlag (G4bool val)
 
void UpdateEmModel (const G4String &model_name, G4double emin, G4double emax)
 
 ~G4EmModelManager ()
 

Private Attributes

G4VEmModelcurrModel = nullptr
 
G4RegionModelscurrRegionModel = nullptr
 
std::vector< G4VEmFluctuationModel * > flucModels
 
G4bool fluoFlag = false
 
std::vector< G4intidxOfRegionModels
 
std::vector< G4intisUsed
 
std::vector< G4VEmModel * > models
 
G4int nEmModels = 0
 
G4int nRegions = 0
 
std::vector< G4intorderOfModels
 
const G4ParticleDefinitionparticle = nullptr
 
std::vector< const G4Region * > regions
 
std::vector< G4RegionModels * > setOfRegionModels
 
G4bool severalModels = true
 
const G4DataVectortheCuts = nullptr
 
G4DataVectortheCutsNew = nullptr
 
G4int verboseLevel = 0
 

Detailed Description

Definition at line 142 of file G4EmModelManager.hh.

Constructor & Destructor Documentation

◆ G4EmModelManager() [1/2]

G4EmModelManager::G4EmModelManager ( )

Definition at line 97 of file G4EmModelManager.cc.

98{
99 models.reserve(4);
100 flucModels.reserve(4);
101 regions.reserve(4);
102 orderOfModels.reserve(4);
103 isUsed.reserve(4);
104}
std::vector< G4int > orderOfModels
std::vector< G4VEmFluctuationModel * > flucModels
std::vector< const G4Region * > regions
std::vector< G4int > isUsed
std::vector< G4VEmModel * > models

References flucModels, isUsed, models, orderOfModels, and regions.

◆ ~G4EmModelManager()

G4EmModelManager::~G4EmModelManager ( )

Definition at line 108 of file G4EmModelManager.cc.

109{
110 verboseLevel = 0; // no verbosity at destruction
111 Clear();
112 delete theCutsNew;
113}
G4DataVector * theCutsNew

References Clear(), theCutsNew, and verboseLevel.

◆ G4EmModelManager() [2/2]

G4EmModelManager::G4EmModelManager ( G4EmModelManager )
delete

Member Function Documentation

◆ AddEmModel()

void G4EmModelManager::AddEmModel ( G4int  num,
G4VEmModel p,
G4VEmFluctuationModel fm,
const G4Region r 
)

Definition at line 131 of file G4EmModelManager.cc.

133{
134 if(nullptr == p) {
135 G4cout << "G4EmModelManager::AddEmModel WARNING: no model defined."
136 << G4endl;
137 return;
138 }
139 models.push_back(p);
140 flucModels.push_back(fm);
141 regions.push_back(r);
142 orderOfModels.push_back(num);
143 isUsed.push_back(0);
144 p->DefineForRegion(r);
145 ++nEmModels;
146}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual void DefineForRegion(const G4Region *)
Definition: G4VEmModel.cc:360

References G4VEmModel::DefineForRegion(), flucModels, G4cout, G4endl, isUsed, models, nEmModels, orderOfModels, and regions.

Referenced by G4VMultipleScattering::AddEmModel(), G4VEmProcess::AddEmModel(), G4VEnergyLossProcess::AddEmModel(), and G4AdjointBremsstrahlungModel::Initialize().

◆ Clear()

void G4EmModelManager::Clear ( )

Definition at line 117 of file G4EmModelManager.cc.

118{
119 if(1 < verboseLevel) {
120 G4cout << "G4EmModelManager::Clear()" << G4endl;
121 }
122 size_t n = setOfRegionModels.size();
123 for(size_t i=0; i<n; ++i) {
124 delete setOfRegionModels[i];
125 setOfRegionModels[i] = nullptr;
126 }
127}
std::vector< G4RegionModels * > setOfRegionModels

References G4cout, G4endl, CLHEP::detail::n, setOfRegionModels, and verboseLevel.

Referenced by Initialise(), and ~G4EmModelManager().

◆ Cuts()

const G4DataVector * G4EmModelManager::Cuts ( ) const
inline

Definition at line 242 of file G4EmModelManager.hh.

243{
244 return theCuts;
245}
const G4DataVector * theCuts

References theCuts.

◆ DumpModelList()

void G4EmModelManager::DumpModelList ( std::ostream &  out,
G4int  verb 
)

Definition at line 718 of file G4EmModelManager.cc.

719{
720 if(verb == 0) { return; }
721 for(G4int i=0; i<nRegions; ++i) {
723 const G4Region* reg = r->Region();
724 G4int n = r->NumberOfModels();
725 if(n > 0) {
726 out << " ===== EM models for the G4Region " << reg->GetName()
727 << " ======" << G4endl;
728 for(G4int j=0; j<n; ++j) {
729 G4VEmModel* model = models[r->ModelIndex(j)];
730 G4double emin =
732 G4double emax =
734 if(emax > emin) {
735 out << std::setw(20);
736 out << model->GetName() << " : Emin="
737 << std::setw(5) << G4BestUnit(emin,"Energy")
738 << " Emax="
739 << std::setw(5) << G4BestUnit(emax,"Energy");
740 G4PhysicsTable* table = model->GetCrossSectionTable();
741 if(table) {
742 size_t kk = table->size();
743 for(size_t k=0; k<kk; ++k) {
744 const G4PhysicsVector* v = (*table)[k];
745 if(v) {
746 G4int nn = v->GetVectorLength() - 1;
747 out << " Nbins=" << nn << " "
748 << std::setw(3) << G4BestUnit(v->Energy(0),"Energy")
749 << " - "
750 << std::setw(3) << G4BestUnit(v->Energy(nn),"Energy");
751 break;
752 }
753 }
754 }
756 if(an) { out << " " << an->GetName(); }
757 if(fluoFlag && model->DeexcitationFlag()) {
758 out << " Fluo";
759 }
760 out << G4endl;
761 G4VMscModel* msc = dynamic_cast<G4VMscModel*>(model);
762 if(msc != nullptr) msc->DumpParameters(out);
763 }
764 }
765 }
766 if(1 == nEmModels) { break; }
767 }
768 if(theCutsNew) {
769 out << " ===== Limit on energy threshold has been applied " << G4endl;
770 }
771}
static const G4double emax
static const G4double reg
#define G4BestUnit(a, b)
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4double Energy(const std::size_t index) const
std::size_t GetVectorLength() const
const G4Region * Region() const
G4int ModelIndex(G4int n) const
G4int NumberOfModels() const
G4double LowEdgeEnergy(G4int n) const
G4VEmAngularDistribution * GetAngularDistribution()
Definition: G4VEmModel.hh:621
G4double HighEnergyActivationLimit() const
Definition: G4VEmModel.hh:669
G4bool DeexcitationFlag() const
Definition: G4VEmModel.hh:704
const G4String & GetName() const
Definition: G4VEmModel.hh:837
G4PhysicsTable * GetCrossSectionTable()
Definition: G4VEmModel.hh:870
G4double LowEnergyActivationLimit() const
Definition: G4VEmModel.hh:676
void DumpParameters(std::ostream &out) const
Definition: G4VMscModel.cc:137
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

References G4InuclParticleNames::an, G4VEmModel::DeexcitationFlag(), G4VMscModel::DumpParameters(), emax, G4PhysicsVector::Energy(), fluoFlag, G4BestUnit, G4endl, G4VEmModel::GetAngularDistribution(), G4VEmModel::GetCrossSectionTable(), G4VEmModel::GetName(), G4PhysicsVector::GetVectorLength(), G4VEmModel::HighEnergyActivationLimit(), G4RegionModels::LowEdgeEnergy(), G4VEmModel::LowEnergyActivationLimit(), G4INCL::Math::max(), G4INCL::Math::min(), G4RegionModels::ModelIndex(), models, CLHEP::detail::n, nEmModels, G4InuclParticleNames::nn, nRegions, G4RegionModels::NumberOfModels(), reg, G4RegionModels::Region(), setOfRegionModels, and theCutsNew.

Referenced by G4VEnergyLossProcess::StreamInfo(), G4VEmProcess::StreamInfo(), and G4VMultipleScattering::StreamInfo().

◆ FillDEDXVector()

void G4EmModelManager::FillDEDXVector ( G4PhysicsVector aVector,
const G4MaterialCutsCouple couple,
G4EmTableType  t = fRestricted 
)

Definition at line 581 of file G4EmModelManager.cc.

584{
585 size_t i = couple->GetIndex();
586 G4double cut = (fTotal == tType) ? DBL_MAX : (*theCuts)[i];
587
588 if(1 < verboseLevel) {
589 G4cout << "G4EmModelManager::FillDEDXVector() for "
590 << couple->GetMaterial()->GetName()
591 << " cut(MeV)= " << cut
592 << " Type " << tType
593 << " for " << particle->GetParticleName()
594 << G4endl;
595 }
596
597 G4int reg = 0;
598 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; }
599 const G4RegionModels* regModels = setOfRegionModels[reg];
600 G4int nmod = regModels->NumberOfModels();
601
602 // Calculate energy losses vector
603 size_t totBinsLoss = aVector->GetVectorLength();
604 G4double del = 0.0;
605 G4int k0 = 0;
606
607 for(size_t j=0; j<totBinsLoss; ++j) {
608 G4double e = aVector->Energy(j);
609
610 // Choose a model of energy losses
611 G4int k = 0;
612 if (nmod > 1) {
613 k = nmod;
614 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
615 do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
616 //G4cout << "k= " << k << G4endl;
617 if(k > 0 && k != k0) {
618 k0 = k;
619 G4double elow = regModels->LowEdgeEnergy(k);
620 G4double dedx1 =
621 models[regModels->ModelIndex(k-1)]->ComputeDEDX(couple, particle, elow, cut);
622 G4double dedx2 =
623 models[regModels->ModelIndex(k)]->ComputeDEDX(couple, particle, elow, cut);
624 del = (dedx2 > 0.0) ? (dedx1/dedx2 - 1.0)*elow : 0.0;
625 //G4cout << "elow= " << elow
626 // << " dedx1= " << dedx1 << " dedx2= " << dedx2 << G4endl;
627 }
628 }
629 G4double dedx = (1.0 + del/e)*
630 models[regModels->ModelIndex(k)]->ComputeDEDX(couple, particle, e, cut);
631
632 if(2 < verboseLevel) {
633 G4cout << "Material= " << couple->GetMaterial()->GetName()
634 << " E(MeV)= " << e/MeV
635 << " dEdx(MeV/mm)= " << dedx*mm/MeV
636 << " del= " << del*mm/MeV<< " k= " << k
637 << " modelIdx= " << regModels->ModelIndex(k)
638 << G4endl;
639 }
640 dedx = std::max(dedx, 0.0);
641 aVector->PutValue(j, dedx);
642 }
643}
@ fTotal
static constexpr double mm
Definition: G4SIunits.hh:95
static constexpr double MeV
Definition: G4SIunits.hh:200
std::vector< G4int > idxOfRegionModels
const G4ParticleDefinition * particle
const G4Material * GetMaterial() const
const G4String & GetName() const
Definition: G4Material.hh:173
const G4String & GetParticleName() const
void PutValue(const std::size_t index, const G4double value)
#define DBL_MAX
Definition: templates.hh:62

References DBL_MAX, G4PhysicsVector::Energy(), fTotal, G4cout, G4endl, G4MaterialCutsCouple::GetIndex(), G4MaterialCutsCouple::GetMaterial(), G4Material::GetName(), G4ParticleDefinition::GetParticleName(), G4PhysicsVector::GetVectorLength(), idxOfRegionModels, G4InuclParticleNames::k0, G4RegionModels::LowEdgeEnergy(), G4INCL::Math::max(), MeV, mm, G4RegionModels::ModelIndex(), models, nEmModels, nRegions, G4RegionModels::NumberOfModels(), particle, G4PhysicsVector::PutValue(), reg, setOfRegionModels, theCuts, and verboseLevel.

Referenced by G4VEnergyLossProcess::BuildDEDXTable().

◆ FillLambdaVector()

void G4EmModelManager::FillLambdaVector ( G4PhysicsVector aVector,
const G4MaterialCutsCouple couple,
G4bool  startFromNull = true,
G4EmTableType  t = fRestricted 
)

Definition at line 647 of file G4EmModelManager.cc.

651{
652 size_t i = couple->GetIndex();
653 G4double cut = (*theCuts)[i];
654 G4double tmax = DBL_MAX;
655
656 G4int reg = 0;
657 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; }
658 const G4RegionModels* regModels = setOfRegionModels[reg];
659 G4int nmod = regModels->NumberOfModels();
660 if(1 < verboseLevel) {
661 G4cout << "G4EmModelManager::FillLambdaVector() for "
663 << " in " << couple->GetMaterial()->GetName()
664 << " Emin(MeV)= " << aVector->Energy(0)
665 << " Emax(MeV)= " << aVector->GetMaxEnergy()
666 << " cut= " << cut
667 << " Type " << tType
668 << " nmod= " << nmod
669 << G4endl;
670 }
671
672 // Calculate lambda vector
673 size_t totBinsLambda = aVector->GetVectorLength();
674 G4double del = 0.0;
675 G4int k0 = 0;
676 G4int k = 0;
677 G4VEmModel* mod = models[regModels->ModelIndex(0)];
678 for(size_t j=0; j<totBinsLambda; ++j) {
679
680 G4double e = aVector->Energy(j);
681
682 // Choose a model
683 if (nmod > 1) {
684 k = nmod;
685 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
686 do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
687 if(k > 0 && k != k0) {
688 k0 = k;
689 G4double elow = regModels->LowEdgeEnergy(k);
690 G4VEmModel* mod1 = models[regModels->ModelIndex(k-1)];
691 G4double xs1 = mod1->CrossSection(couple,particle,elow,cut,tmax);
692 mod = models[regModels->ModelIndex(k)];
693 G4double xs2 = mod->CrossSection(couple,particle,elow,cut,tmax);
694 del = (xs2 > 0.0) ? (xs1/xs2 - 1.0)*elow : 0.0;
695 //G4cout << "New model k=" << k << " E(MeV)= " << e/MeV
696 // << " Elow(MeV)= " << elow/MeV << " del= " << del << G4endl;
697 }
698 }
699 G4double cross = (1.0 + del/e)*mod->CrossSection(couple,particle,e,cut,tmax);
700 if(fIsCrossSectionPrim == tType) { cross *= e; }
701
702 if(j==0 && startFromNull) { cross = 0.0; }
703
704 if(2 < verboseLevel) {
705 G4cout << "FillLambdaVector: " << j << ". e(MeV)= " << e/MeV
706 << " cross(1/mm)= " << cross*mm
707 << " del= " << del*mm << " k= " << k
708 << " modelIdx= " << regModels->ModelIndex(k)
709 << G4endl;
710 }
711 cross = std::max(cross, 0.0);
712 aVector->PutValue(j, cross);
713 }
714}
@ fIsCrossSectionPrim
G4double GetMaxEnergy() const
G4double CrossSection(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.hh:539

References G4VEmModel::CrossSection(), DBL_MAX, G4PhysicsVector::Energy(), fIsCrossSectionPrim, G4cout, G4endl, G4MaterialCutsCouple::GetIndex(), G4MaterialCutsCouple::GetMaterial(), G4PhysicsVector::GetMaxEnergy(), G4Material::GetName(), G4ParticleDefinition::GetParticleName(), G4PhysicsVector::GetVectorLength(), idxOfRegionModels, G4InuclParticleNames::k0, G4RegionModels::LowEdgeEnergy(), G4INCL::Math::max(), MeV, mm, G4RegionModels::ModelIndex(), models, nEmModels, nRegions, G4RegionModels::NumberOfModels(), particle, G4PhysicsVector::PutValue(), reg, setOfRegionModels, and verboseLevel.

Referenced by G4VEmProcess::BuildLambdaTable(), and G4VEnergyLossProcess::BuildLambdaTable().

◆ GetModel()

G4VEmModel * G4EmModelManager::GetModel ( G4int  idx,
G4bool  ver = false 
)

Definition at line 169 of file G4EmModelManager.cc.

170{
171 G4VEmModel* model = nullptr;
172 if(i < nEmModels) { model = models[i]; }
173 else if(verboseLevel > 0 && ver) {
174 G4cout << "G4EmModelManager::GetModel WARNING: "
175 << "index " << i << " is wrong Nmodels= "
176 << nEmModels;
177 if(nullptr != particle) {
178 G4cout << " for " << particle->GetParticleName();
179 }
180 G4cout<< G4endl;
181 }
182 return model;
183}

References G4cout, G4endl, G4ParticleDefinition::GetParticleName(), models, nEmModels, particle, and verboseLevel.

Referenced by G4VEmProcess::GetModelByIndex(), G4VMultipleScattering::GetModelByIndex(), G4VEnergyLossProcess::GetModelByIndex(), G4VEmProcess::PreparePhysicsTable(), G4VEnergyLossProcess::PreparePhysicsTable(), and G4VMultipleScattering::StorePhysicsTable().

◆ GetRegionModel()

G4VEmModel * G4EmModelManager::GetRegionModel ( G4int  idx,
size_t  index_couple 
)

Definition at line 187 of file G4EmModelManager.cc.

188{
190 return (k < rm->NumberOfModels()) ? models[rm->ModelIndex(k)] : nullptr;
191}
G4int NumberOfModels() const

References idxOfRegionModels, G4RegionModels::ModelIndex(), models, NumberOfModels(), and setOfRegionModels.

◆ Initialise()

const G4DataVector * G4EmModelManager::Initialise ( const G4ParticleDefinition part,
const G4ParticleDefinition secPart,
G4double  ,
G4int  verb 
)

Definition at line 204 of file G4EmModelManager.cc.

207{
208 verboseLevel = verb;
209 if(1 < verboseLevel) {
210 G4cout << "G4EmModelManager::Initialise() for "
211 << p->GetParticleName() << " Nmodels= " << nEmModels << G4endl;
212 }
213 // Are models defined?
214 if(nEmModels < 1) {
216 ed << "No models found out for " << p->GetParticleName()
217 << " !";
218 G4Exception("G4EmModelManager::Initialise","em0002",
219 FatalException, ed);
220 }
221
222 particle = p;
223 Clear(); // needed if run is not first
224
226 const G4Region* world =
227 regionStore->GetRegion("DefaultRegionForTheWorld", false);
228
229 // Identify the list of regions with different set of models
230 nRegions = 1;
231 std::vector<const G4Region*> setr;
232 setr.push_back(world);
233 G4bool isWorld = false;
234
235 for (G4int ii=0; ii<nEmModels; ++ii) {
236 const G4Region* r = regions[ii];
237 if ( r == nullptr || r == world) {
238 isWorld = true;
239 regions[ii] = world;
240 } else {
241 G4bool newRegion = true;
242 if (nRegions>1) {
243 for (G4int j=1; j<nRegions; ++j) {
244 if ( r == setr[j] ) { newRegion = false; }
245 }
246 }
247 if (newRegion) {
248 setr.push_back(r);
249 ++nRegions;
250 }
251 }
252 }
253 // Are models defined?
254 if(!isWorld) {
256 ed << "No models defined for the World volume for "
257 << p->GetParticleName() << " !";
258 G4Exception("G4EmModelManager::Initialise","em0002",
259 FatalException, ed);
260 }
261
262 G4ProductionCutsTable* theCoupleTable=
264 size_t numOfCouples = theCoupleTable->GetTableSize();
265
266 // prepare vectors, shortcut for the case of only 1 model
267 // or only one region
268 if(nRegions > 1 && nEmModels > 1) {
269 idxOfRegionModels.resize(numOfCouples,0);
270 setOfRegionModels.resize((size_t)nRegions,0);
271 } else {
272 idxOfRegionModels.resize(1,0);
273 setOfRegionModels.resize(1,0);
274 }
275
276 std::vector<G4int> modelAtRegion(nEmModels);
277 std::vector<G4int> modelOrd(nEmModels);
278 G4DataVector eLow(nEmModels+1);
279 G4DataVector eHigh(nEmModels);
280
281 if(1 < verboseLevel) {
282 G4cout << " Nregions= " << nRegions
283 << " Nmodels= " << nEmModels << G4endl;
284 }
285
286 // Order models for regions
287 for (G4int reg=0; reg<nRegions; ++reg) {
288 const G4Region* region = setr[reg];
289 G4int n = 0;
290
291 for (G4int ii=0; ii<nEmModels; ++ii) {
292
293 G4VEmModel* model = models[ii];
294 if ( region == regions[ii] ) {
295
296 G4double tmin = model->LowEnergyLimit();
297 G4double tmax = model->HighEnergyLimit();
298 G4int ord = orderOfModels[ii];
299 G4bool push = true;
300 G4bool insert = false;
301 G4int idx = n;
302
303 if(1 < verboseLevel) {
304 G4cout << "Model #" << ii
305 << " <" << model->GetName() << "> for region <";
306 if (region) G4cout << region->GetName();
307 G4cout << "> "
308 << " tmin(MeV)= " << tmin/MeV
309 << "; tmax(MeV)= " << tmax/MeV
310 << "; order= " << ord
311 << "; tminAct= " << model->LowEnergyActivationLimit()/MeV
312 << "; tmaxAct= " << model->HighEnergyActivationLimit()/MeV
313 << G4endl;
314 }
315
316 static const G4double limitdelta = 0.01*eV;
317 if(n > 0) {
318
319 // extend energy range to previous models
320 tmin = std::min(tmin, eHigh[n-1]);
321 tmax = std::max(tmax, eLow[0]);
322 //G4cout << "tmin= " << tmin << " tmax= "
323 // << tmax << " ord= " << ord <<G4endl;
324 // empty energy range
325 if( tmax - tmin <= limitdelta) { push = false; }
326 // low-energy model
327 else if (tmax == eLow[0]) {
328 push = false;
329 insert = true;
330 idx = 0;
331 // resolve intersections
332 } else if(tmin < eHigh[n-1]) {
333 // compare order
334 for(G4int k=0; k<n; ++k) {
335 // new model has higher order parameter,
336 // so, its application area may be reduced
337 // to avoid intersections
338 if(ord >= modelOrd[k]) {
339 if(tmin < eHigh[k] && tmin >= eLow[k]) { tmin = eHigh[k]; }
340 if(tmax <= eHigh[k] && tmax > eLow[k]) { tmax = eLow[k]; }
341 if(tmax > eHigh[k] && tmin < eLow[k]) {
342 if(tmax - eHigh[k] > eLow[k] - tmin) { tmin = eHigh[k]; }
343 else { tmax = eLow[k]; }
344 }
345 if( tmax - tmin <= limitdelta) {
346 push = false;
347 break;
348 }
349 }
350 }
351 // this model has lower order parameter than possible
352 // other models, with which there may be intersections
353 // so, appliction area of such models may be reduced
354
355 // insert below the first model
356 if (tmax <= eLow[0]) {
357 push = false;
358 insert = true;
359 idx = 0;
360 // resolve intersections
361 } else if(tmin < eHigh[n-1]) {
362 // last energy interval
363 if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
364 eHigh[n-1] = tmin;
365 // first energy interval
366 } else if(tmin <= eLow[0] && tmax < eHigh[0]) {
367 eLow[0] = tmax;
368 push = false;
369 insert = true;
370 idx = 0;
371 // loop over all models
372 } else {
373 for(G4int k=n-1; k>=0; --k) {
374 if(tmin <= eLow[k] && tmax >= eHigh[k]) {
375 // full overlap exclude previous model
376 isUsed[modelAtRegion[k]] = 0;
377 idx = k;
378 if(k < n-1) {
379 // shift upper models and change index
380 for(G4int kk=k; kk<n-1; ++kk) {
381 modelAtRegion[kk] = modelAtRegion[kk+1];
382 modelOrd[kk] = modelOrd[kk+1];
383 eLow[kk] = eLow[kk+1];
384 eHigh[kk] = eHigh[kk+1];
385 }
386 ++k;
387 }
388 --n;
389 } else {
390 // partially reduce previous model area
391 if(tmin <= eLow[k] && tmax > eLow[k]) {
392 eLow[k] = tmax;
393 idx = k;
394 insert = true;
395 push = false;
396 } else if(tmin < eHigh[k] && tmax >= eHigh[k]) {
397 eHigh[k] = tmin;
398 idx = k + 1;
399 if(idx < n) {
400 insert = true;
401 push = false;
402 }
403 } else if(tmin > eLow[k] && tmax < eHigh[k]) {
404 if(eHigh[k] - tmax > tmin - eLow[k]) {
405 eLow[k] = tmax;
406 idx = k;
407 insert = true;
408 push = false;
409 } else {
410 eHigh[k] = tmin;
411 idx = k + 1;
412 if(idx < n) {
413 insert = true;
414 push = false;
415 }
416 }
417 }
418 }
419 }
420 }
421 }
422 }
423 }
424 // provide space for the new model
425 if(insert) {
426 for(G4int k=n-1; k>=idx; --k) {
427 modelAtRegion[k+1] = modelAtRegion[k];
428 modelOrd[k+1] = modelOrd[k];
429 eLow[k+1] = eLow[k];
430 eHigh[k+1] = eHigh[k];
431 }
432 }
433 //G4cout << "push= " << push << " insert= " << insert
434 // << " idx= " << idx <<G4endl;
435 // the model is added
436 if (push || insert) {
437 ++n;
438 modelAtRegion[idx] = ii;
439 modelOrd[idx] = ord;
440 eLow[idx] = tmin;
441 eHigh[idx] = tmax;
442 isUsed[ii] = 1;
443 }
444 // exclude models with zero energy range
445 for(G4int k=n-1; k>=0; --k) {
446 if(eHigh[k] - eLow[k] <= limitdelta) {
447 isUsed[modelAtRegion[k]] = 0;
448 if(k < n-1) {
449 for(G4int kk=k; kk<n-1; ++kk) {
450 modelAtRegion[kk] = modelAtRegion[kk+1];
451 modelOrd[kk] = modelOrd[kk+1];
452 eLow[kk] = eLow[kk+1];
453 eHigh[kk] = eHigh[kk+1];
454 }
455 }
456 --n;
457 }
458 }
459 }
460 }
461 eLow[0] = 0.0;
462 eLow[n] = eHigh[n-1];
463
464 if(1 < verboseLevel) {
465 G4cout << "### New G4RegionModels set with " << n
466 << " models for region <";
467 if (region) { G4cout << region->GetName(); }
468 G4cout << "> Elow(MeV)= ";
469 for(G4int iii=0; iii<=n; ++iii) {G4cout << eLow[iii]/MeV << " ";}
470 G4cout << G4endl;
471 }
472 G4RegionModels* rm = new G4RegionModels(n, modelAtRegion, eLow, region);
474 // shortcut
475 if(1 == nEmModels) { break; }
476 }
477
479 currModel = models[0];
480
481 // Access to materials and build cuts
482 size_t idx = 1;
483 if(nullptr != secondaryParticle) {
484 if( secondaryParticle == G4Gamma::Gamma() ) { idx = 0; }
485 else if( secondaryParticle == G4Electron::Electron()) { idx = 1; }
486 else if( secondaryParticle == G4Positron::Positron()) { idx = 2; }
487 else { idx = 3; }
488 }
489
490 theCuts =
491 static_cast<const G4DataVector*>(theCoupleTable->GetEnergyCutsVector(idx));
492
493 // for the second run the check on cuts should be repeated
494 if(nullptr != theCutsNew) { *theCutsNew = *theCuts; }
495
496 // G4cout << "========Start define cuts" << G4endl;
497 // define cut values
498 for(size_t i=0; i<numOfCouples; ++i) {
499
500 const G4MaterialCutsCouple* couple =
501 theCoupleTable->GetMaterialCutsCouple(i);
502 const G4Material* material = couple->GetMaterial();
503 const G4ProductionCuts* pcuts = couple->GetProductionCuts();
504
505 G4int reg = 0;
506 if(nRegions > 1 && nEmModels > 1) {
507 reg = nRegions;
508 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
509 do {--reg;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
511 }
512 if(1 < verboseLevel) {
513 G4cout << "G4EmModelManager::Initialise() for "
514 << material->GetName()
515 << " indexOfCouple= " << i
516 << " indexOfRegion= " << reg
517 << G4endl;
518 }
519
520 G4double cut = (*theCuts)[i];
521 if(nullptr != secondaryParticle) {
522
523 // note that idxOfRegionModels[] not always filled
524 G4int inn = 0;
525 G4int nnm = 1;
526 if(nRegions > 1 && nEmModels > 1) {
527 inn = idxOfRegionModels[i];
528 }
529 // check cuts and introduce upper limits
530 //G4cout << "idx= " << i << " cut(keV)= " << cut/keV << G4endl;
533
534 //G4cout << "idx= " << i << " Nmod= " << nnm << G4endl;
535
536 for(G4int jj=0; jj<nnm; ++jj) {
537 //G4cout << "jj= " << jj << " modidx= "
538 // << currRegionModel->ModelIndex(jj) << G4endl;
540 G4double cutlim = currModel->MinEnergyCut(particle,couple);
541 if(cutlim > cut) {
542 if(nullptr == theCutsNew) { theCutsNew = new G4DataVector(*theCuts); }
543 (*theCutsNew)[i] = cutlim;
544 /*
545 G4cout << "### " << partname << " energy loss model in "
546 << material->GetName()
547 << " Cut was changed from " << cut/keV << " keV to "
548 << cutlim/keV << " keV " << " due to "
549 << currModel->GetName() << G4endl;
550 */
551 }
552 }
553 }
554 }
555 if(nullptr != theCutsNew) { theCuts = theCutsNew; }
556
557 // initialize models
558 G4int nn = 0;
559 severalModels = true;
560 for(G4int jj=0; jj<nEmModels; ++jj) {
561 if(1 == isUsed[jj]) {
562 ++nn;
563 currModel = models[jj];
565 if(nullptr != flucModels[jj]) { flucModels[jj]->InitialiseMe(particle); }
566 }
567 }
568 if(1 == nn) { severalModels = false; }
569
570 if(1 < verboseLevel) {
571 G4cout << "G4EmModelManager for " << particle->GetParticleName()
572 << " is initialised; nRegions= " << nRegions
573 << " severalModels: " << severalModels
574 << G4endl;
575 }
576 return theCuts;
577}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static constexpr double eV
Definition: G4SIunits.hh:201
bool G4bool
Definition: G4Types.hh:86
static G4Electron * Electron()
Definition: G4Electron.cc:93
G4RegionModels * currRegionModel
G4VEmModel * currModel
static G4Gamma * Gamma()
Definition: G4Gamma.cc:85
G4ProductionCuts * GetProductionCuts() const
static G4Positron * Positron()
Definition: G4Positron.cc:93
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
const std::vector< G4double > * GetEnergyCutsVector(std::size_t pcIdx) const
static G4ProductionCutsTable * GetProductionCutsTable()
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:662
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:655
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)=0
virtual G4double MinEnergyCut(const G4ParticleDefinition *, const G4MaterialCutsCouple *)
Definition: G4VEmModel.cc:424
string material
Definition: eplot.py:19

References Clear(), currModel, currRegionModel, G4Electron::Electron(), eV, FatalException, flucModels, G4cout, G4endl, G4Exception(), G4Gamma::Gamma(), G4ProductionCutsTable::GetEnergyCutsVector(), G4RegionStore::GetInstance(), G4MaterialCutsCouple::GetMaterial(), G4ProductionCutsTable::GetMaterialCutsCouple(), G4Region::GetName(), G4VEmModel::GetName(), G4ParticleDefinition::GetParticleName(), G4MaterialCutsCouple::GetProductionCuts(), G4ProductionCutsTable::GetProductionCutsTable(), G4RegionStore::GetRegion(), G4ProductionCutsTable::GetTableSize(), G4VEmModel::HighEnergyActivationLimit(), G4VEmModel::HighEnergyLimit(), idxOfRegionModels, G4VEmModel::Initialise(), isUsed, G4VEmModel::LowEnergyActivationLimit(), G4VEmModel::LowEnergyLimit(), eplot::material, G4INCL::Math::max(), MeV, G4INCL::Math::min(), G4VEmModel::MinEnergyCut(), G4RegionModels::ModelIndex(), models, CLHEP::detail::n, nEmModels, G4InuclParticleNames::nn, nRegions, G4RegionModels::NumberOfModels(), orderOfModels, particle, G4Positron::Positron(), reg, regions, setOfRegionModels, severalModels, theCuts, theCutsNew, and verboseLevel.

Referenced by G4AdjointBremsstrahlungModel::AdjointCrossSection(), G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond(), G4VEmProcess::PreparePhysicsTable(), G4VEnergyLossProcess::PreparePhysicsTable(), and G4VMultipleScattering::PreparePhysicsTable().

◆ NumberOfModels()

G4int G4EmModelManager::NumberOfModels ( ) const
inline

◆ NumberOfRegionModels()

G4int G4EmModelManager::NumberOfRegionModels ( size_t  index_couple) const

Definition at line 195 of file G4EmModelManager.cc.

196{
198 return rm->NumberOfModels();
199}

References idxOfRegionModels, G4RegionModels::NumberOfModels(), and setOfRegionModels.

◆ operator=()

G4EmModelManager & G4EmModelManager::operator= ( const G4EmModelManager right)
delete

◆ SelectModel()

G4VEmModel * G4EmModelManager::SelectModel ( G4double  energy,
size_t  index 
)
inline

◆ SetFluoFlag()

void G4EmModelManager::SetFluoFlag ( G4bool  val)
inline

Definition at line 249 of file G4EmModelManager.hh.

250{
251 fluoFlag = val;
252}

References fluoFlag.

Referenced by G4VEmProcess::PreparePhysicsTable().

◆ UpdateEmModel()

void G4EmModelManager::UpdateEmModel ( const G4String model_name,
G4double  emin,
G4double  emax 
)

Definition at line 150 of file G4EmModelManager.cc.

152{
153 if (nEmModels > 0) {
154 for(G4int i=0; i<nEmModels; ++i) {
155 if(nam == models[i]->GetName()) {
156 models[i]->SetLowEnergyLimit(emin);
157 models[i]->SetHighEnergyLimit(emax);
158 return;
159 }
160 }
161 }
162 G4cout << "G4EmModelManager::UpdateEmModel WARNING: no model <"
163 << nam << "> is found out"
164 << G4endl;
165}

References emax, G4cout, G4endl, models, and nEmModels.

Field Documentation

◆ currModel

G4VEmModel* G4EmModelManager::currModel = nullptr
private

Definition at line 206 of file G4EmModelManager.hh.

Referenced by Initialise(), and SelectModel().

◆ currRegionModel

G4RegionModels* G4EmModelManager::currRegionModel = nullptr
private

Definition at line 205 of file G4EmModelManager.hh.

Referenced by Initialise(), and SelectModel().

◆ flucModels

std::vector<G4VEmFluctuationModel*> G4EmModelManager::flucModels
private

Definition at line 216 of file G4EmModelManager.hh.

Referenced by AddEmModel(), G4EmModelManager(), and Initialise().

◆ fluoFlag

G4bool G4EmModelManager::fluoFlag = false
private

Definition at line 213 of file G4EmModelManager.hh.

Referenced by DumpModelList(), and SetFluoFlag().

◆ idxOfRegionModels

std::vector<G4int> G4EmModelManager::idxOfRegionModels
private

◆ isUsed

std::vector<G4int> G4EmModelManager::isUsed
private

Definition at line 219 of file G4EmModelManager.hh.

Referenced by AddEmModel(), G4EmModelManager(), and Initialise().

◆ models

std::vector<G4VEmModel*> G4EmModelManager::models
private

◆ nEmModels

G4int G4EmModelManager::nEmModels = 0
private

◆ nRegions

G4int G4EmModelManager::nRegions = 0
private

◆ orderOfModels

std::vector<G4int> G4EmModelManager::orderOfModels
private

Definition at line 218 of file G4EmModelManager.hh.

Referenced by AddEmModel(), G4EmModelManager(), and Initialise().

◆ particle

const G4ParticleDefinition* G4EmModelManager::particle = nullptr
private

◆ regions

std::vector<const G4Region*> G4EmModelManager::regions
private

Definition at line 217 of file G4EmModelManager.hh.

Referenced by AddEmModel(), G4EmModelManager(), and Initialise().

◆ setOfRegionModels

std::vector<G4RegionModels*> G4EmModelManager::setOfRegionModels
private

◆ severalModels

G4bool G4EmModelManager::severalModels = true
private

Definition at line 212 of file G4EmModelManager.hh.

Referenced by Initialise(), and SelectModel().

◆ theCuts

const G4DataVector* G4EmModelManager::theCuts = nullptr
private

Definition at line 201 of file G4EmModelManager.hh.

Referenced by Cuts(), FillDEDXVector(), and Initialise().

◆ theCutsNew

G4DataVector* G4EmModelManager::theCutsNew = nullptr
private

Definition at line 202 of file G4EmModelManager.hh.

Referenced by DumpModelList(), Initialise(), and ~G4EmModelManager().

◆ verboseLevel

G4int G4EmModelManager::verboseLevel = 0
private

The documentation for this class was generated from the following files: