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

#include <G4EnergyRangeManager.hh>

Public Member Functions

void BuildPhysicsTable (const G4ParticleDefinition &)
 
void Dump (G4int verbose=0)
 
 G4EnergyRangeManager ()
 
G4HadronicInteractionGetHadronicInteraction (const G4HadProjectile &aHadProjectile, G4Nucleus &aTargetNucleus, const G4Material *aMaterial, const G4Element *anElement) const
 
std::vector< G4HadronicInteraction * > & GetHadronicInteractionList ()
 
void RegisterMe (G4HadronicInteraction *a)
 
 ~G4EnergyRangeManager ()
 

Private Member Functions

 G4EnergyRangeManager (const G4EnergyRangeManager &right)
 
G4bool operator!= (const G4EnergyRangeManager &right) const
 
G4EnergyRangeManageroperator= (const G4EnergyRangeManager &right)
 
G4bool operator== (const G4EnergyRangeManager &right) const
 

Private Attributes

std::vector< G4HadronicInteraction * > theHadronicInteraction
 
G4int theHadronicInteractionCounter
 

Detailed Description

Definition at line 39 of file G4EnergyRangeManager.hh.

Constructor & Destructor Documentation

◆ G4EnergyRangeManager() [1/2]

G4EnergyRangeManager::G4EnergyRangeManager ( )
explicit

Definition at line 39 of file G4EnergyRangeManager.cc.

◆ ~G4EnergyRangeManager()

G4EnergyRangeManager::~G4EnergyRangeManager ( )

Definition at line 43 of file G4EnergyRangeManager.cc.

44{}

◆ G4EnergyRangeManager() [2/2]

G4EnergyRangeManager::G4EnergyRangeManager ( const G4EnergyRangeManager right)
private

Member Function Documentation

◆ BuildPhysicsTable()

void G4EnergyRangeManager::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 178 of file G4EnergyRangeManager.cc.

179{
180 for (auto & hadi : theHadronicInteraction) {
181 hadi->BuildPhysicsTable( aParticleType );
182 }
183}
std::vector< G4HadronicInteraction * > theHadronicInteraction

References theHadronicInteraction.

Referenced by G4HadronicProcess::BuildPhysicsTable().

◆ Dump()

void G4EnergyRangeManager::Dump ( G4int  verbose = 0)

Definition at line 161 of file G4EnergyRangeManager.cc.

162{
163 G4cout << "G4EnergyRangeManager " << this << G4endl;
164 for (G4int i = 0 ; i < theHadronicInteractionCounter; i++) {
165 G4cout << " HadronicModel " << i <<":"
166 << theHadronicInteraction[i]->GetModelName() << G4endl;
167 if (verbose > 0) {
168 G4cout << " Minimum Energy "
169 << theHadronicInteraction[i]->GetMinEnergy()/GeV << " [GeV], "
170 << "Maximum Energy "
171 << theHadronicInteraction[i]->GetMaxEnergy()/GeV << " [GeV]"
172 << G4endl;
173 }
174 }
175}
static constexpr double GeV
Definition: G4SIunits.hh:203
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References G4cout, G4endl, GeV, theHadronicInteraction, and theHadronicInteractionCounter.

◆ GetHadronicInteraction()

G4HadronicInteraction * G4EnergyRangeManager::GetHadronicInteraction ( const G4HadProjectile aHadProjectile,
G4Nucleus aTargetNucleus,
const G4Material aMaterial,
const G4Element anElement 
) const

Definition at line 59 of file G4EnergyRangeManager.cc.

63{
64 // VI shortcut: if only one interaction is registered skip all checks
66 else if(0 == theHadronicInteractionCounter) {
67 G4cout << "G4EnergyRangeManager::GetHadronicInteraction: "
68 << "no models defined for a process" << G4endl;
69 return nullptr;
70 }
71
72 G4double kineticEnergy = aHadProjectile.GetKineticEnergy();
73 // For ions, get kinetic energy per nucleon
74 if ( std::abs( aHadProjectile.GetDefinition()->GetBaryonNumber() ) > 1 ) {
75 kineticEnergy /= static_cast< G4double >( std::abs( aHadProjectile.GetDefinition()->GetBaryonNumber() ) );
76 }
77
78 G4int cou = 0, memory = 0, memor2 = 0;
79 G4double emi1 = 0.0, ema1 = 0.0, emi2 = 0.0, ema2 = 0.0;
80
81 for (G4int i = 0; i<theHadronicInteractionCounter; ++i) {
82 if ( theHadronicInteraction[i]->IsApplicable( aHadProjectile, aTargetNucleus ) ) {
83 G4double low = theHadronicInteraction[i]->GetMinEnergy( aMaterial, anElement );
84 G4double high = theHadronicInteraction[i]->GetMaxEnergy( aMaterial, anElement );
85 if (low <= kineticEnergy && high >= kineticEnergy) {
86 ++cou;
87 emi2 = emi1;
88 ema2 = ema1;
89 emi1 = low;
90 ema1 = high;
91 memor2 = memory;
92 memory = i;
93 }
94 }
95 }
96
97 G4HadronicInteraction* hi = nullptr;
98 switch (cou) {
99 case 0:
100 G4cout << "No model found out of " << theHadronicInteractionCounter << G4endl;
101 for( G4int j=0; j<theHadronicInteractionCounter; ++j) {
103 G4cout << " "<< j << ". Elow= " << hint->GetMinEnergy(aMaterial,anElement)
104 <<", Ehigh= " << hint->GetMaxEnergy(aMaterial,anElement)
105 <<" " << hint->GetModelName() << G4endl;
106 }
107 break;
108
109 case 1:
110 hi = theHadronicInteraction[memory];
111 break;
112
113 case 2:
114 if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) ) {
115 G4cout << "Energy ranges of two models fully overlapping " << G4endl;
116 for( G4int j=0; j<theHadronicInteractionCounter; ++j) {
118 G4cout << " "<< j << ". Elow= " << hint->GetMinEnergy(aMaterial,anElement)
119 <<", Ehigh= " << hint->GetMaxEnergy(aMaterial,anElement)
120 <<" " << hint->GetModelName() << G4endl;
121 }
122 } else {
123 G4double rand = G4UniformRand();
124 G4int mem;
125 if( emi1 < emi2 ) {
126 if( (ema1-kineticEnergy) < rand*(ema1-emi2) ) {
127 mem = memor2;
128 } else {
129 mem = memory;
130 }
131 } else {
132 if( (ema2-kineticEnergy) < rand*(ema2-emi1) ) {
133 mem = memory;
134 } else {
135 mem = memor2;
136 }
137 }
138 hi = theHadronicInteraction[mem];
139 }
140 break;
141
142 default:
143 G4cout << "More than two competing models for this energy" << G4endl;
144 for( G4int j=0; j<theHadronicInteractionCounter; ++j) {
146 G4cout << " "<< j << ". Elow= " << hint->GetMinEnergy(aMaterial,anElement)
147 <<", Ehigh= " << hint->GetMaxEnergy(aMaterial,anElement)
148 <<" " << hint->GetModelName() << G4endl;
149 }
150 break;
151 }
152 return hi;
153}
double G4double
Definition: G4Types.hh:83
#define G4UniformRand()
Definition: Randomize.hh:52
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4String & GetModelName() const

References G4cout, G4endl, G4UniformRand, G4ParticleDefinition::GetBaryonNumber(), G4HadProjectile::GetDefinition(), G4HadProjectile::GetKineticEnergy(), G4HadronicInteraction::GetMaxEnergy(), G4HadronicInteraction::GetMinEnergy(), G4HadronicInteraction::GetModelName(), theHadronicInteraction, and theHadronicInteractionCounter.

Referenced by G4HadronicProcess::ChooseHadronicInteraction().

◆ GetHadronicInteractionList()

std::vector< G4HadronicInteraction * > & G4EnergyRangeManager::GetHadronicInteractionList ( )

◆ operator!=()

G4bool G4EnergyRangeManager::operator!= ( const G4EnergyRangeManager right) const
private

◆ operator=()

G4EnergyRangeManager & G4EnergyRangeManager::operator= ( const G4EnergyRangeManager right)
private

◆ operator==()

G4bool G4EnergyRangeManager::operator== ( const G4EnergyRangeManager right) const
private

◆ RegisterMe()

void G4EnergyRangeManager::RegisterMe ( G4HadronicInteraction a)

Definition at line 46 of file G4EnergyRangeManager.cc.

47{
48 if(!a) { return; }
50 for(G4int i=0; i<theHadronicInteractionCounter; ++i) {
51 if(a == theHadronicInteraction[i]) { return; }
52 }
53 }
54 theHadronicInteraction.push_back(a);
56}

References theHadronicInteraction, and theHadronicInteractionCounter.

Referenced by G4HadronicProcess::RegisterMe().

Field Documentation

◆ theHadronicInteraction

std::vector<G4HadronicInteraction*> G4EnergyRangeManager::theHadronicInteraction
private

◆ theHadronicInteractionCounter

G4int G4EnergyRangeManager::theHadronicInteractionCounter
private

Definition at line 67 of file G4EnergyRangeManager.hh.

Referenced by Dump(), GetHadronicInteraction(), and RegisterMe().


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