Geant4
11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPEnergyDistribution.hh
Go to the documentation of this file.
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
// P. Arce, June-2014 Conversion neutron_hp to particle_hp
28
//
29
#ifndef G4ParticleHPEnergyDistribution_h
30
#define G4ParticleHPEnergyDistribution_h 1
31
32
#include "
G4ParticleHPArbitaryTab.hh
"
33
#include "
G4ParticleHPEvapSpectrum.hh
"
34
#include "
G4ParticleHPFissionSpectrum.hh
"
35
#include "
G4ParticleHPMadlandNixSpectrum.hh
"
36
#include "
G4ParticleHPSimpleEvapSpectrum.hh
"
37
#include "
G4ParticleHPWattSpectrum.hh
"
38
#include "
G4VParticleHPEDis.hh
"
39
#include "
G4ios.hh
"
40
#include "
Randomize.hh
"
41
#include "
globals.hh
"
42
43
#include <fstream>
44
45
// we will need a List of these .... one per term.
46
47
class
G4ParticleHPEnergyDistribution
48
{
49
public
:
50
G4ParticleHPEnergyDistribution
()
51
{
52
theEnergyDistribution =
nullptr
;
53
theNumberOfPartials = 0;
54
theRepresentationType = 0;
55
}
56
~G4ParticleHPEnergyDistribution
()
57
{
58
if
(theEnergyDistribution !=
nullptr
) {
59
for
(
G4int
i = 0; i < theNumberOfPartials; i++) {
60
delete
theEnergyDistribution[i];
61
}
62
delete
[] theEnergyDistribution;
63
}
64
}
65
66
inline
void
Init
(std::istream& theData)
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
}
98
99
inline
G4double
Sample
(
G4double
anEnergy,
G4int
& it)
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
}
124
125
private
:
126
G4int
theNumberOfPartials;
127
G4int
theRepresentationType;
128
G4VParticleHPEDis
** theEnergyDistribution;
129
};
130
131
#endif
G4ParticleHPArbitaryTab.hh
G4ParticleHPEvapSpectrum.hh
G4ParticleHPFissionSpectrum.hh
G4ParticleHPMadlandNixSpectrum.hh
G4ParticleHPSimpleEvapSpectrum.hh
G4ParticleHPWattSpectrum.hh
G4double
double G4double
Definition
G4Types.hh:83
G4int
int G4int
Definition
G4Types.hh:85
G4VParticleHPEDis.hh
G4ios.hh
Randomize.hh
G4UniformRand
#define G4UniformRand()
Definition
Randomize.hh:52
G4ParticleHPArbitaryTab
Definition
G4ParticleHPArbitaryTab.hh:47
G4ParticleHPEnergyDistribution
Definition
G4ParticleHPEnergyDistribution.hh:48
G4ParticleHPEnergyDistribution::~G4ParticleHPEnergyDistribution
~G4ParticleHPEnergyDistribution()
Definition
G4ParticleHPEnergyDistribution.hh:56
G4ParticleHPEnergyDistribution::Init
void Init(std::istream &theData)
Definition
G4ParticleHPEnergyDistribution.hh:66
G4ParticleHPEnergyDistribution::G4ParticleHPEnergyDistribution
G4ParticleHPEnergyDistribution()
Definition
G4ParticleHPEnergyDistribution.hh:50
G4ParticleHPEnergyDistribution::Sample
G4double Sample(G4double anEnergy, G4int &it)
Definition
G4ParticleHPEnergyDistribution.hh:99
G4ParticleHPEvapSpectrum
Definition
G4ParticleHPEvapSpectrum.hh:45
G4ParticleHPFissionSpectrum
Definition
G4ParticleHPFissionSpectrum.hh:46
G4ParticleHPMadlandNixSpectrum
Definition
G4ParticleHPMadlandNixSpectrum.hh:52
G4ParticleHPSimpleEvapSpectrum
Definition
G4ParticleHPSimpleEvapSpectrum.hh:47
G4ParticleHPWattSpectrum
Definition
G4ParticleHPWattSpectrum.hh:46
G4VParticleHPEDis
Definition
G4VParticleHPEDis.hh:40
G4VParticleHPEDis::Init
virtual void Init(std::istream &theData)=0
G4VParticleHPEDis::GetFractionalProbability
virtual G4double GetFractionalProbability(G4double anEnergy)=0
G4VParticleHPEDis::Sample
virtual G4double Sample(G4double anEnergy)=0
globals.hh
geant4-v11.2.2
source
processes
hadronic
models
particle_hp
include
G4ParticleHPEnergyDistribution.hh
Generated by
1.12.0