Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4EnergyRangeManager Class Reference

#include <G4EnergyRangeManager.hh>

Public Member Functions

 G4EnergyRangeManager ()
 
 ~G4EnergyRangeManager ()
 
 G4EnergyRangeManager (const G4EnergyRangeManager &right)
 
G4EnergyRangeManageroperator= (const G4EnergyRangeManager &right)
 
G4bool operator== (const G4EnergyRangeManager &right) const
 
G4bool operator!= (const G4EnergyRangeManager &right) const
 
void RegisterMe (G4HadronicInteraction *a)
 
G4HadronicInteractionGetHadronicInteraction (const G4double kineticEnergy, const G4Material *aMaterial, const G4Element *anElement) const
 
G4int GetHadronicInteractionCounter () const
 

Detailed Description

Definition at line 39 of file G4EnergyRangeManager.hh.

Constructor & Destructor Documentation

◆ G4EnergyRangeManager() [1/2]

G4EnergyRangeManager::G4EnergyRangeManager ( )

Definition at line 41 of file G4EnergyRangeManager.cc.

42 : theHadronicInteractionCounter(0)
43{
44 for (G4int i = 0; i < G4EnergyRangeManager::MAX_NUMBER_OF_MODELS; i++)
45 theHadronicInteraction[i] = 0;
46}
int G4int
Definition: G4Types.hh:66

◆ ~G4EnergyRangeManager()

G4EnergyRangeManager::~G4EnergyRangeManager ( )
inline

Definition at line 46 of file G4EnergyRangeManager.hh.

47 { }

◆ G4EnergyRangeManager() [2/2]

G4EnergyRangeManager::G4EnergyRangeManager ( const G4EnergyRangeManager right)

Definition at line 49 of file G4EnergyRangeManager.cc.

50{
51 if (this != &right) {
52 for (G4int i=0; i<theHadronicInteractionCounter; ++i)
53 theHadronicInteraction[i] = right.theHadronicInteraction[i];
54 theHadronicInteractionCounter = right.theHadronicInteractionCounter;
55 }
56}

Member Function Documentation

◆ GetHadronicInteraction()

G4HadronicInteraction * G4EnergyRangeManager::GetHadronicInteraction ( const G4double  kineticEnergy,
const G4Material aMaterial,
const G4Element anElement 
) const

Definition at line 82 of file G4EnergyRangeManager.cc.

86 {
88 if( counter == 0 )
89 throw G4HadronicException(__FILE__, __LINE__,
90 "GetHadronicInteraction: NO MODELS STORED");
91
92 G4int cou = 0, memory = 0, memor2 = 0;
93 G4double emi1 = 0.0, ema1 = 0.0, emi2 = 0.0, ema2 = 0.0;
94 for( G4int i=0; i<counter; i++ )
95 {
96 G4double low = theHadronicInteraction[i]->GetMinEnergy( aMaterial, anElement );
97 // Work-around for particles with 0 kinetic energy, which still
98 // require a model to return a ParticleChange
99 if (low == 0.) low = -DBL_MIN;
100 G4double high = theHadronicInteraction[i]->GetMaxEnergy( aMaterial, anElement );
101 if( low < kineticEnergy && high >= kineticEnergy )
102 {
103 ++cou;
104 emi2 = emi1;
105 ema2 = ema1;
106 emi1 = low;
107 ema1 = high;
108 memor2 = memory;
109 memory = i;
110 }
111 }
112 G4int mem=-1;
113 G4double rand;
114 switch ( cou )
115 {
116 case 0:
117 G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="<<counter<<", Ek="
118 <<kineticEnergy<<", Material = "<<aMaterial->GetName()<<", Element = "
119 <<anElement->GetName()<<G4endl;
120 for( G4int j=0; j<counter; j++ )
121 {
122 G4HadronicInteraction* HInt=theHadronicInteraction[j];
123 G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
124 <<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
125 }
126 throw G4HadronicException(__FILE__, __LINE__,
127 "GetHadronicInteraction: No Model found");
128 return 0;
129 case 1:
130 mem = memory;
131 break;
132 case 2:
133 if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) )
134 {
135 G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="<<counter<<", Ek="
136 <<kineticEnergy<<", Material = "<<aMaterial->GetName()<<", Element = "
137 <<anElement->GetName()<<G4endl;
138 if(counter) for( G4int j=0; j<counter; j++ )
139 {
140 G4HadronicInteraction* HInt=theHadronicInteraction[j];
141 G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
142 <<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
143 }
144 throw G4HadronicException(__FILE__, __LINE__,
145 "GetHadronicInteraction: Energy ranges of two models fully overlapping");
146 }
147 rand = G4UniformRand();
148 if( emi1 < emi2 )
149 {
150 if( (ema1-kineticEnergy)/(ema1-emi2)<rand )
151 mem = memor2;
152 else
153 mem = memory;
154 } else {
155 if( (ema2-kineticEnergy)/(ema2-emi1)<rand )
156 mem = memory;
157 else
158 mem = memor2;
159 }
160 break;
161 default:
162 throw G4HadronicException(__FILE__, __LINE__,
163 "GetHadronicInteraction: More than two competing models in this energy range");
164 }
165 return theHadronicInteraction[mem];
166 }
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:53
const G4String & GetName() const
Definition: G4Element.hh:127
G4int GetHadronicInteractionCounter() const
const G4String & GetName() const
Definition: G4Material.hh:177
#define DBL_MIN
Definition: templates.hh:75

Referenced by G4HadronicProcess::ChooseHadronicInteraction().

◆ GetHadronicInteractionCounter()

G4int G4EnergyRangeManager::GetHadronicInteractionCounter ( ) const
inline

Definition at line 70 of file G4EnergyRangeManager.hh.

71 { return theHadronicInteractionCounter; }

Referenced by GetHadronicInteraction().

◆ operator!=()

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

Definition at line 58 of file G4EnergyRangeManager.hh.

59 { return ( this != (G4EnergyRangeManager *) &right ); }

◆ operator=()

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

Definition at line 59 of file G4EnergyRangeManager.cc.

61{
62 if (this != &right) {
63 for (G4int i=0; i<theHadronicInteractionCounter; ++i)
64 theHadronicInteraction[i] = right.theHadronicInteraction[i];
65 theHadronicInteractionCounter = right.theHadronicInteractionCounter;
66 }
67 return *this;
68}

◆ operator==()

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

Definition at line 55 of file G4EnergyRangeManager.hh.

56 { return ( this == (G4EnergyRangeManager *) &right ); }

◆ RegisterMe()

void G4EnergyRangeManager::RegisterMe ( G4HadronicInteraction a)

Definition at line 71 of file G4EnergyRangeManager.cc.

72{
73 if( theHadronicInteractionCounter+1 > MAX_NUMBER_OF_MODELS )
74 {
75 throw G4HadronicException(__FILE__, __LINE__,"RegisterMe: TOO MANY MODELS");
76 }
77 theHadronicInteraction[ theHadronicInteractionCounter++ ] = a;
78}

Referenced by G4HadronicProcess::RegisterMe().


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