Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4NeutronHPEnergyDistribution Class Reference

#include <G4NeutronHPEnergyDistribution.hh>

Public Member Functions

 G4NeutronHPEnergyDistribution ()
 
 ~G4NeutronHPEnergyDistribution ()
 
void Init (std::istream &theData)
 
G4double Sample (G4double anEnergy, G4int &it)
 

Detailed Description

Definition at line 46 of file G4NeutronHPEnergyDistribution.hh.

Constructor & Destructor Documentation

G4NeutronHPEnergyDistribution::G4NeutronHPEnergyDistribution ( )
inline

Definition at line 49 of file G4NeutronHPEnergyDistribution.hh.

50  {
51  theEnergyDistribution = 0;
52  theNumberOfPartials = 0;
53  theRepresentationType = 0;
54  }
G4NeutronHPEnergyDistribution::~G4NeutronHPEnergyDistribution ( )
inline

Definition at line 55 of file G4NeutronHPEnergyDistribution.hh.

56  {
57  if(theEnergyDistribution != 0)
58  {
59  for(G4int i=0; i<theNumberOfPartials; i++)
60  {
61  delete theEnergyDistribution[i];
62  }
63  delete [] theEnergyDistribution;
64  }
65  }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

void G4NeutronHPEnergyDistribution::Init ( std::istream &  theData)
inline

Definition at line 67 of file G4NeutronHPEnergyDistribution.hh.

References G4VNeutronHPEDis::Init().

Referenced by G4NeutronHPFSFissionFS::Init(), G4NeutronHPFissionBaseFS::Init(), G4NeutronHPInelasticBaseFS::Init(), G4NeutronHPInelasticCompFS::Init(), and G4FissionLibrary::Init().

68  {
69  G4double dummy;
70  theData >> dummy >> theNumberOfPartials;
71  theEnergyDistribution = new G4VNeutronHPEDis * [theNumberOfPartials];
72  for(G4int i=0; i<theNumberOfPartials; i++)
73  {
74  theData >> theRepresentationType;
75  switch(theRepresentationType)
76  {
77  case 1:
78  theEnergyDistribution[i] = new G4NeutronHPArbitaryTab;
79  break;
80  case 5:
81  theEnergyDistribution[i] = new G4NeutronHPEvapSpectrum;
82  break;
83  case 7:
84  theEnergyDistribution[i] = new G4NeutronHPFissionSpectrum;
85  break;
86  case 9:
87  theEnergyDistribution[i] = new G4NeutronHPSimpleEvapSpectrum;
88  break;
89  case 11:
90  theEnergyDistribution[i] = new G4NeutronHPWattSpectrum;
91  break;
92  case 12:
93  theEnergyDistribution[i] = new G4NeutronHPMadlandNixSpectrum;
94  break;
95  }
96  theEnergyDistribution[i]->Init(theData);
97  }
98  }
int G4int
Definition: G4Types.hh:78
virtual void Init(std::istream &theData)=0
double G4double
Definition: G4Types.hh:76
G4double G4NeutronHPEnergyDistribution::Sample ( G4double  anEnergy,
G4int it 
)
inline

Definition at line 100 of file G4NeutronHPEnergyDistribution.hh.

References G4UniformRand, G4VNeutronHPEDis::GetFractionalProbability(), and G4VNeutronHPEDis::Sample().

Referenced by G4NeutronHPFSFissionFS::ApplyYourself(), G4NeutronHPFissionBaseFS::ApplyYourself(), G4NeutronHPInelasticBaseFS::BaseApply(), and G4NeutronHPInelasticCompFS::CompositeApply().

101  {
102  G4double result = 0;
103  it = 0;
104  if (theNumberOfPartials != 0)
105  {
106  G4double sum=0;
107  G4double * running = new G4double[theNumberOfPartials];
108  running[0] = 0;
109  G4int i;
110  for (i=0; i<theNumberOfPartials; i++)
111  {
112  if (i!=0) running[i]=running[i-1];
113  running[i]+=theEnergyDistribution[i]->GetFractionalProbability(anEnergy);
114  }
115  sum = running[theNumberOfPartials-1];
116  G4double random = G4UniformRand();
117  for(i=0; i<theNumberOfPartials; i++)
118  {
119  it = i;
120  if(running[i]/sum>random) break;
121  }
122  delete [] running;
123  if(it==theNumberOfPartials) it--;
124  result = theEnergyDistribution[it]->Sample(anEnergy);
125  }
126  return result;
127  }
int G4int
Definition: G4Types.hh:78
virtual G4double GetFractionalProbability(G4double anEnergy)=0
virtual G4double Sample(G4double anEnergy)=0
#define G4UniformRand()
Definition: Randomize.hh:87
double G4double
Definition: G4Types.hh:76

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