Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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 
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 }
void Init(std::istream &aDataFile, G4int nPar, G4double unit=1.)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void SetValue(G4int i, G4double y)
G4double total(Particle const *const p1, Particle const *const p2)
G4double GetValue(G4int i)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76