Geant4 11.2.2
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 = nullptr;
53 theNumberOfPartials = 0;
54 theRepresentationType = 0;
55 }

◆ ~G4ParticleHPEnergyDistribution()

G4ParticleHPEnergyDistribution::~G4ParticleHPEnergyDistribution ( )
inline

Definition at line 56 of file G4ParticleHPEnergyDistribution.hh.

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

Member Function Documentation

◆ Init()

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

Definition at line 66 of file G4ParticleHPEnergyDistribution.hh.

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

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

◆ Sample()

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

Definition at line 99 of file G4ParticleHPEnergyDistribution.hh.

100 {
101 G4double result = 0;
102 it = 0;
103 if (theNumberOfPartials != 0) {
104 G4double sum = 0;
105 auto running = new G4double[theNumberOfPartials];
106 running[0] = 0;
107 G4int i;
108 for (i = 0; i < theNumberOfPartials; i++) {
109 if (i != 0) running[i] = running[i - 1];
110 running[i] += theEnergyDistribution[i]->GetFractionalProbability(anEnergy);
111 }
112 sum = running[theNumberOfPartials - 1];
113 G4double random = G4UniformRand();
114 for (i = 0; i < theNumberOfPartials; i++) {
115 it = i;
116 if (running[i] / sum > random) break;
117 }
118 delete[] running;
119 if (it == theNumberOfPartials) it--;
120 result = theEnergyDistribution[it]->Sample(anEnergy);
121 }
122 return result;
123 }
#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: