Geant4
11.1.1
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
#include "
G4HadronicException.hh
"
34
#include <iomanip>
35
36
void
G4ParticleHPList::Check(
G4int
i)
37
{
38
if
(i<0)
39
{
40
throw
G4HadronicException
(__FILE__, __LINE__,
"G4ParticleHPList::Check(G4int) called with negative index"
);
41
}
42
if
(i>nEntries)
throw
G4HadronicException
(__FILE__, __LINE__,
"Skipped some index numbers in G4ParticleHPList"
);
43
if
(i==nPoints)
44
{
45
nPoints =
static_cast<
G4int
>
(1.5*nPoints);
46
G4double
* buff =
new
G4double
[nPoints];
47
for
(
G4int
j=0; j<nEntries; j++) buff[j] = theData[j];
48
delete
[] theData;
49
theData = buff;
50
}
51
if
(i==nEntries) nEntries++;
52
}
53
54
void
G4ParticleHPList::Init
(std::istream & aDataFile,
G4int
nPar,
G4double
unit)
55
{
56
G4int
i;
57
G4double
y;
58
for
(i=0; i<nPar; i++)
59
{
60
aDataFile >> y;
61
SetValue
(i,y*unit);
62
}
63
}
64
65
void
G4ParticleHPList::Init
(std::istream & aDataFile,
G4double
unit)
66
{
67
G4int
total, i;
68
aDataFile >> total;
69
G4double
y;
70
for
(i=0;i<total;i++)
71
{
72
aDataFile >>y;
73
SetValue
(i,y*unit);
74
}
75
}
76
77
G4double
G4ParticleHPList::GetValue
(
G4int
i)
78
{
79
// G4cout << "TestList "<<i<<" "<<nEntries<<G4endl;
80
if
(nEntries<0)
81
{
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
92
void
G4ParticleHPList::Dump
()
93
{
94
//store orginal precision
95
std::ios::fmtflags oldform =
G4cout
.flags();
96
G4cout
<< std::setprecision(7) << std::setw(9) << theLabel <<
" "
<< theData[0] <<
" "
<< 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:57
G4cout
G4GLOB_DLL std::ostream G4cout
G4HadronicException
Definition:
G4HadronicException.hh:32
G4ParticleHPList::Dump
void Dump()
Definition:
G4ParticleHPList.cc:92
G4ParticleHPList::SetValue
void SetValue(G4int i, G4double y)
Definition:
G4ParticleHPList.hh:53
G4ParticleHPList::Init
void Init(std::istream &aDataFile, G4int nPar, G4double unit=1.)
Definition:
G4ParticleHPList.cc:54
G4ParticleHPList::GetListLength
G4int GetListLength()
Definition:
G4ParticleHPList.hh:60
G4ParticleHPList::GetValue
G4double GetValue(G4int i)
Definition:
G4ParticleHPList.cc:77
geant4-v11.1.1
source
processes
hadronic
models
particle_hp
src
G4ParticleHPList.cc
Generated by
1.9.6