Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 G4HadProjectile &aHadProjectile, G4Nucleus &aTargetNucleus, const G4Material *aMaterial, const G4Element *anElement) const
 
G4HadronicInteractionGetHadronicInteraction (const G4double kineticEnergy, const G4Material *aMaterial, const G4Element *anElement) const
 
std::vector
< G4HadronicInteraction * > & 
GetHadronicInteractionList ()
 
void Dump (G4int verbose=0)
 
void BuildPhysicsTable (const G4ParticleDefinition &)
 

Detailed Description

Definition at line 40 of file G4EnergyRangeManager.hh.

Constructor & Destructor Documentation

G4EnergyRangeManager::G4EnergyRangeManager ( )
explicit

Definition at line 39 of file G4EnergyRangeManager.cc.

40  : theHadronicInteractionCounter(0)
41 {}
G4EnergyRangeManager::~G4EnergyRangeManager ( )

Definition at line 43 of file G4EnergyRangeManager.cc.

44 {}
G4EnergyRangeManager::G4EnergyRangeManager ( const G4EnergyRangeManager right)

Definition at line 46 of file G4EnergyRangeManager.cc.

47 {
48  theHadronicInteractionCounter = right.theHadronicInteractionCounter;
49  theHadronicInteraction = right.theHadronicInteraction;
50 }

Member Function Documentation

void G4EnergyRangeManager::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 292 of file G4EnergyRangeManager.cc.

293 {
294  for ( std::vector<G4HadronicInteraction*>::iterator
295  it = theHadronicInteraction.begin() ; it != theHadronicInteraction.end() ; it++ ) {
296  (*it)->BuildPhysicsTable( aParticleType );
297  }
298 }

Here is the caller graph for this function:

void G4EnergyRangeManager::Dump ( G4int  verbose = 0)

Definition at line 275 of file G4EnergyRangeManager.cc.

276 {
277  G4cout << "G4EnergyRangeManager " << this << G4endl;
278  for (G4int i = 0 ; i < theHadronicInteractionCounter; i++) {
279  G4cout << " HadronicModel " << i <<":"
280  << theHadronicInteraction[i]->GetModelName() << G4endl;
281  if (verbose > 0) {
282  G4cout << " Minimum Energy "
283  << theHadronicInteraction[i]->GetMinEnergy()/GeV << " [GeV], "
284  << "Maximum Energy "
285  << theHadronicInteraction[i]->GetMaxEnergy()/GeV << " [GeV]"
286  << G4endl;
287  }
288  }
289 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static constexpr double GeV
Definition: G4SIunits.hh:217
#define G4endl
Definition: G4ios.hh:61
G4HadronicInteraction * G4EnergyRangeManager::GetHadronicInteraction ( const G4HadProjectile aHadProjectile,
G4Nucleus aTargetNucleus,
const G4Material aMaterial,
const G4Element anElement 
) const

Definition at line 76 of file G4EnergyRangeManager.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 178 of file G4EnergyRangeManager.cc.

181 {
182  if(0 == theHadronicInteractionCounter) {
183  throw G4HadronicException(__FILE__, __LINE__,
184  "GetHadronicInteraction: NO MODELS STORED");
185  }
186  G4int cou = 0, memory = 0, memor2 = 0;
187  G4double emi1 = 0.0, ema1 = 0.0, emi2 = 0.0, ema2 = 0.0;
188 
189  for (G4int i = 0; i<theHadronicInteractionCounter; ++i) {
190  G4double low = theHadronicInteraction[i]->GetMinEnergy( aMaterial, anElement );
191  // Work-around for particles with 0 kinetic energy, which still
192  // require a model to return a ParticleChange
193  //if (low == 0.) low = -DBL_MIN;
194  G4double high = theHadronicInteraction[i]->GetMaxEnergy( aMaterial, anElement );
195  if (low <= kineticEnergy && high > kineticEnergy) {
196  ++cou;
197  emi2 = emi1;
198  ema2 = ema1;
199  emi1 = low;
200  ema1 = high;
201  memor2 = memory;
202  memory = i;
203  }
204  }
205 
206  G4int mem = -1;
207  G4double rand;
208  switch (cou) {
209  case 0:
210  G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
211  <<theHadronicInteractionCounter<<", Ek="
212  <<kineticEnergy<<", Material = "<<aMaterial->GetName()
213  <<", Element = "
214  <<anElement->GetName()<<G4endl;
215  for( G4int j=0; j<theHadronicInteractionCounter; ++j)
216  {
217  G4HadronicInteraction* HInt=theHadronicInteraction[j];
218  G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
219  <<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
220  }
221  throw G4HadronicException(__FILE__, __LINE__,
222  "GetHadronicInteraction: No Model found");
223  return 0;
224  case 1:
225  mem = memory;
226  break;
227  case 2:
228  if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) )
229  {
230  G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
231  <<theHadronicInteractionCounter<<", Ek="
232  <<kineticEnergy<<", Material = "<<aMaterial->GetName()
233  <<", Element = "
234  <<anElement->GetName()<<G4endl;
235  for( G4int j=0; j<theHadronicInteractionCounter; ++j)
236  {
237  G4HadronicInteraction* HInt=theHadronicInteraction[j];
238  G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
239  <<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
240  }
241  throw G4HadronicException(__FILE__, __LINE__,
242  "GetHadronicInteraction: Energy ranges of two models fully overlapping");
243  }
244  rand = G4UniformRand();
245  if( emi1 < emi2 )
246  {
247  if( (ema1-kineticEnergy) < rand*(ema1-emi2) ) {
248  mem = memor2;
249  } else {
250  mem = memory;
251  }
252  } else {
253  if( (ema2-kineticEnergy) < rand*(ema2-emi1) ) {
254  mem = memory;
255  } else {
256  mem = memor2;
257  }
258  }
259  break;
260  default:
261  throw G4HadronicException(__FILE__, __LINE__,
262  "GetHadronicInteraction: More than two competing models in this energy range");
263  }
264 
265  return theHadronicInteraction[mem];
266 }
G4double GetMinEnergy() const
G4double GetMaxEnergy() const
const G4String & GetName() const
Definition: G4Material.hh:178
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Element.hh:127

Here is the call graph for this function:

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

Definition at line 269 of file G4EnergyRangeManager.cc.

270 {
271  return theHadronicInteraction;
272 }

Here is the caller graph for this function:

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

Definition at line 55 of file G4EnergyRangeManager.hh.

56  { return ( this != (G4EnergyRangeManager *) &right ); }
G4EnergyRangeManager & G4EnergyRangeManager::operator= ( const G4EnergyRangeManager right)

Definition at line 52 of file G4EnergyRangeManager.cc.

54 {
55  if (this != &right) {
56  theHadronicInteractionCounter = right.theHadronicInteractionCounter;
57  theHadronicInteraction = right.theHadronicInteraction;
58  }
59  return *this;
60 }
G4bool G4EnergyRangeManager::operator== ( const G4EnergyRangeManager right) const
inline

Definition at line 52 of file G4EnergyRangeManager.hh.

53  { return ( this == (G4EnergyRangeManager *) &right ); }
void G4EnergyRangeManager::RegisterMe ( G4HadronicInteraction a)

Definition at line 62 of file G4EnergyRangeManager.cc.

63 {
64  if(!a) { return; }
65  if(0 < theHadronicInteractionCounter) {
66  for(G4int i=0; i<theHadronicInteractionCounter; ++i) {
67  if(a == theHadronicInteraction[i]) { return; }
68  }
69  }
70  theHadronicInteraction.push_back(a);
71  ++theHadronicInteractionCounter;
72 }
int G4int
Definition: G4Types.hh:78

Here is the caller graph for this function:


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