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

#include <G4ParticleHPEnergyDistribution.hh>

Public Member Functions

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

Detailed Description

Definition at line 47 of file G4ParticleHPEnergyDistribution.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPEnergyDistribution()

G4ParticleHPEnergyDistribution::G4ParticleHPEnergyDistribution ( )
inline

Definition at line 50 of file G4ParticleHPEnergyDistribution.hh.

51 {
52 theEnergyDistribution = 0;
53 theNumberOfPartials = 0;
54 theRepresentationType = 0;
55 }

◆ ~G4ParticleHPEnergyDistribution()

G4ParticleHPEnergyDistribution::~G4ParticleHPEnergyDistribution ( )
inline

Definition at line 56 of file G4ParticleHPEnergyDistribution.hh.

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

Member Function Documentation

◆ Init()

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

Definition at line 68 of file G4ParticleHPEnergyDistribution.hh.

69 {
70 G4double dummy;
71 theData >> dummy >> theNumberOfPartials;
72 theEnergyDistribution = new G4VParticleHPEDis * [theNumberOfPartials];
73 for(G4int i=0; i<theNumberOfPartials; i++)
74 {
75 theData >> theRepresentationType;
76 switch(theRepresentationType)
77 {
78 case 1:
79 theEnergyDistribution[i] = new G4ParticleHPArbitaryTab;
80 break;
81 case 5:
82 theEnergyDistribution[i] = new G4ParticleHPEvapSpectrum;
83 break;
84 case 7:
85 theEnergyDistribution[i] = new G4ParticleHPFissionSpectrum;
86 break;
87 case 9:
88 theEnergyDistribution[i] = new G4ParticleHPSimpleEvapSpectrum;
89 break;
90 case 11:
91 theEnergyDistribution[i] = new G4ParticleHPWattSpectrum;
92 break;
93 case 12:
94 theEnergyDistribution[i] = new G4ParticleHPMadlandNixSpectrum;
95 break;
96 }
97 theEnergyDistribution[i]->Init(theData);
98 }
99 }
double G4double
Definition: G4Types.hh:83
virtual void Init(std::istream &theData)=0

Referenced by G4FissionLibrary::Init(), G4ParticleHPFSFissionFS::Init(), G4ParticleHPInelasticCompFS::Init(), G4ParticleHPFissionBaseFS::Init(), and G4ParticleHPInelasticBaseFS::Init().

◆ Sample()

G4double G4ParticleHPEnergyDistribution::Sample ( G4double  anEnergy,
G4int it 
)
inline

Definition at line 101 of file G4ParticleHPEnergyDistribution.hh.

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

Referenced by G4ParticleHPFissionBaseFS::ApplyYourself(), G4ParticleHPFSFissionFS::ApplyYourself(), G4ParticleHPInelasticBaseFS::BaseApply(), and G4ParticleHPInelasticCompFS::CompositeApply().


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