Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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
 
void Dump (G4int verbose=0)
 

Detailed Description

Definition at line 40 of file G4EnergyRangeManager.hh.

Constructor & Destructor Documentation

G4EnergyRangeManager::G4EnergyRangeManager ( )

Definition at line 40 of file G4EnergyRangeManager.cc.

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

Definition at line 47 of file G4EnergyRangeManager.hh.

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

Definition at line 48 of file G4EnergyRangeManager.cc.

49 {
50  if (this != &right) {
51  theHadronicInteractionCounter = right.theHadronicInteractionCounter;
52  for (G4int i = 0; i < theHadronicInteractionCounter; ++i)
53  theHadronicInteraction[i] = right.theHadronicInteraction[i];
54  }
55 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

void G4EnergyRangeManager::Dump ( G4int  verbose = 0)

Definition at line 166 of file G4EnergyRangeManager.cc.

References G4cout, G4endl, G4HadronicInteraction::GetMaxEnergy(), G4HadronicInteraction::GetMinEnergy(), G4HadronicInteraction::GetModelName(), and python.hepunit::GeV.

167 {
168  G4cout << "G4EnergyRangeManager " << this << G4endl;
169  for (G4int i = 0 ; i < theHadronicInteractionCounter; i++) {
170  G4cout << " HadronicModel " << i <<":"
171  << theHadronicInteraction[i]->GetModelName() << G4endl;
172  if (verbose > 0) {
173  G4cout << " Minimum Energy " << theHadronicInteraction[i]->GetMinEnergy()/GeV << " [GeV], "
174  << "Maximum Energy " << theHadronicInteraction[i]->GetMaxEnergy()/GeV << " [GeV]"
175  << G4endl;
176  }
177  }
178 }
G4double GetMinEnergy() const
G4double GetMaxEnergy() const
const G4String & GetModelName() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4HadronicInteraction * G4EnergyRangeManager::GetHadronicInteraction ( const G4double  kineticEnergy,
const G4Material aMaterial,
const G4Element anElement 
) const

Definition at line 80 of file G4EnergyRangeManager.cc.

References DBL_MIN, G4cout, G4endl, G4UniformRand, GetHadronicInteractionCounter(), G4HadronicInteraction::GetMaxEnergy(), G4HadronicInteraction::GetMinEnergy(), G4Element::GetName(), and G4Material::GetName().

Referenced by G4HadronicProcess::ChooseHadronicInteraction().

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

Definition at line 70 of file G4EnergyRangeManager.hh.

Referenced by GetHadronicInteraction().

71  { return theHadronicInteractionCounter; }
G4bool G4EnergyRangeManager::operator!= ( const G4EnergyRangeManager right) const
inline

Definition at line 58 of file G4EnergyRangeManager.hh.

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

Definition at line 58 of file G4EnergyRangeManager.cc.

60 {
61  if (this != &right) {
62  theHadronicInteractionCounter = right.theHadronicInteractionCounter;
63  for (G4int i=0; i<theHadronicInteractionCounter; ++i)
64  theHadronicInteraction[i] = right.theHadronicInteraction[i];
65  }
66  return *this;
67 }
int G4int
Definition: G4Types.hh:78
G4bool G4EnergyRangeManager::operator== ( const G4EnergyRangeManager right) const
inline

Definition at line 55 of file G4EnergyRangeManager.hh.

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

Definition at line 70 of file G4EnergyRangeManager.cc.

References test::a.

Referenced by G4HadronicProcess::RegisterMe().

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

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