Geant4
11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPList.cc
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
// neutron_hp -- source file
27
// J.P. Wellisch, Nov-1996
28
// A prototype of the low energy neutron transport model.
29
//
30
// P. Arce, June-2014 Conversion neutron_hp to particle_hp
31
//
32
#include "
G4ParticleHPList.hh
"
33
34
#include "
G4HadronicException.hh
"
35
36
#include <iomanip>
37
38
void
G4ParticleHPList::Check(
G4int
i)
39
{
40
if
(i < 0) {
41
throw
G4HadronicException
(__FILE__, __LINE__,
42
"G4ParticleHPList::Check(G4int) called with negative index"
);
43
}
44
if
(i > nEntries)
45
throw
G4HadronicException
(__FILE__, __LINE__,
"Skipped some index numbers in G4ParticleHPList"
);
46
if
(i == nPoints) {
47
nPoints =
static_cast<
G4int
>
(1.5 * nPoints);
48
auto
buff =
new
G4double
[nPoints];
49
for
(
G4int
j = 0; j < nEntries; j++)
50
buff[j] = theData[j];
51
delete
[] theData;
52
theData = buff;
53
}
54
if
(i == nEntries) nEntries++;
55
}
56
57
void
G4ParticleHPList::Init
(std::istream& aDataFile,
G4int
nPar,
G4double
unit)
58
{
59
G4int
i;
60
G4double
y;
61
for
(i = 0; i < nPar; i++) {
62
aDataFile >> y;
63
SetValue
(i, y * unit);
64
}
65
}
66
67
void
G4ParticleHPList::Init
(std::istream& aDataFile,
G4double
unit)
68
{
69
G4int
total, i;
70
aDataFile >> total;
71
G4double
y;
72
for
(i = 0; i < total; i++) {
73
aDataFile >> y;
74
SetValue
(i, y * unit);
75
}
76
}
77
78
G4double
G4ParticleHPList::GetValue
(
G4int
i)
79
{
80
// G4cout << "TestList "<<i<<" "<<nEntries<<G4endl;
81
if
(nEntries < 0) {
82
// G4cout <<nPoints<<" "<<nEntries<<" "<<theData<<G4endl;
83
// for(G4int ii=0; ii<2; ii++) G4cout << theData[ii]<<" ";
84
// G4cout << G4endl;
85
}
86
if
(i < 0) i = 0;
87
if
(i >=
GetListLength
()) i =
GetListLength
() - 1;
88
return
theData[i];
89
}
90
91
void
G4ParticleHPList::Dump
()
92
{
93
// store orginal precision
94
std::ios::fmtflags oldform =
G4cout
.flags();
95
G4cout
<< std::setprecision(7) << std::setw(9) << theLabel <<
" "
<< theData[0] <<
" "
96
<< theData[1] <<
G4endl
;
97
// restore orginal precision
98
G4cout
.flags(oldform);
99
}
G4HadronicException.hh
G4ParticleHPList.hh
G4double
double G4double
Definition
G4Types.hh:83
G4int
int G4int
Definition
G4Types.hh:85
G4endl
#define G4endl
Definition
G4ios.hh:67
G4cout
G4GLOB_DLL std::ostream G4cout
G4HadronicException
Definition
G4HadronicException.hh:32
G4ParticleHPList::Dump
void Dump()
Definition
G4ParticleHPList.cc:91
G4ParticleHPList::SetValue
void SetValue(G4int i, G4double y)
Definition
G4ParticleHPList.hh:50
G4ParticleHPList::Init
void Init(std::istream &aDataFile, G4int nPar, G4double unit=1.)
Definition
G4ParticleHPList.cc:57
G4ParticleHPList::GetListLength
G4int GetListLength()
Definition
G4ParticleHPList.hh:57
G4ParticleHPList::GetValue
G4double GetValue(G4int i)
Definition
G4ParticleHPList.cc:78
geant4-v11.2.2
source
processes
hadronic
models
particle_hp
src
G4ParticleHPList.cc
Generated by
1.12.0