Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronHPPartial Class Reference

#include <G4NeutronHPPartial.hh>

Public Member Functions

 G4NeutronHPPartial (G4int n)
 
 G4NeutronHPPartial (G4int n1, G4int n2)
 
void InitInterpolation (G4int i, std::ifstream &aDataFile)
 
void InitInterpolation (std::ifstream &aDataFile)
 
void Init (std::ifstream &aDataFile)
 
void InitData (G4int i, std::ifstream &aDataFile, G4double unit=1.)
 
 ~G4NeutronHPPartial ()
 
G4int GetNumberOfEnergies ()
 
void SetX (G4int i, G4double x)
 
void SetT (G4int i, G4double x)
 
void SetX (G4int i, G4int j, G4double x)
 
void SetY (G4int i, G4int j, G4double y)
 
G4double GetX (G4int i)
 
G4double GetT (G4int i)
 
G4double GetX (G4int i, G4int j)
 
G4double GetY (G4int i, G4int j)
 
G4double GetY (G4int i, G4double e)
 
G4int GetNEntries (G4int i)
 
G4NeutronHPVectorGetY (G4double e1)
 
G4double Sample (G4double x)
 

Detailed Description

Definition at line 41 of file G4NeutronHPPartial.hh.

Constructor & Destructor Documentation

◆ G4NeutronHPPartial() [1/2]

G4NeutronHPPartial::G4NeutronHPPartial ( G4int  n)
inline

Definition at line 45 of file G4NeutronHPPartial.hh.

46 {
47 X = new G4double[n];
48 data = new G4NeutronHPVector[n];
49 nData = n;
50 T=0;
51 }
double G4double
Definition: G4Types.hh:64

◆ G4NeutronHPPartial() [2/2]

G4NeutronHPPartial::G4NeutronHPPartial ( G4int  n1,
G4int  n2 
)
inline

Definition at line 53 of file G4NeutronHPPartial.hh.

54 {
55 T = new G4double[n2];
56 X = new G4double[n1];
57 data = new G4NeutronHPVector[n1];
58 nData = std::max(n1,n2);
59 }

◆ ~G4NeutronHPPartial()

G4NeutronHPPartial::~G4NeutronHPPartial ( )
inline

Definition at line 100 of file G4NeutronHPPartial.hh.

101 {
102 delete [] X;
103 if(T!=0) delete [] T;
104 delete [] data;
105 }

Member Function Documentation

◆ GetNEntries()

G4int G4NeutronHPPartial::GetNEntries ( G4int  i)
inline

Definition at line 118 of file G4NeutronHPPartial.hh.

118{return data[i].GetVectorLength();}
G4int GetVectorLength() const

Referenced by Sample().

◆ GetNumberOfEnergies()

G4int G4NeutronHPPartial::GetNumberOfEnergies ( )
inline

Definition at line 106 of file G4NeutronHPPartial.hh.

106{return nData;}

◆ GetT()

G4double G4NeutronHPPartial::GetT ( G4int  i)
inline

Definition at line 114 of file G4NeutronHPPartial.hh.

114{return T[i];}

◆ GetX() [1/2]

G4double G4NeutronHPPartial::GetX ( G4int  i)
inline

Definition at line 113 of file G4NeutronHPPartial.hh.

113{return X[i];}

Referenced by GetY(), and Sample().

◆ GetX() [2/2]

G4double G4NeutronHPPartial::GetX ( G4int  i,
G4int  j 
)
inline

Definition at line 115 of file G4NeutronHPPartial.hh.

115{return data[i].GetX(j);}
G4double GetX(G4int i) const

◆ GetY() [1/3]

G4NeutronHPVector * G4NeutronHPPartial::GetY ( G4double  e1)

Definition at line 36 of file G4NeutronHPPartial.cc.

37 {
38 G4NeutronHPVector * aBuffer = new G4NeutronHPVector();
39 G4int i;
40 if(nData==1)
41 {
42 for(i=0; i<data[0].GetVectorLength(); i++)
43 {
44 aBuffer->SetInterpolationManager(data[0].GetInterpolationManager());
45 aBuffer->SetData(i , data[0].GetX(i), data[0].GetY(i));
46 }
47 return aBuffer;
48 }
49 for (i=0; i<nData; i++)
50 {
51 if(X[i]>e1) break;
52 }
53 if(i==nData) i--;
54 if(0==i) i=1;
55 G4double x1,x2,y1,y2,y;
56 G4int i1=0, ib=0;
57 G4double E1 = X[i-1];
58 G4double E2 = X[i];
59 for(G4int ii=0; ii<data[i].GetVectorLength(); ii++)
60 {
61 x1 = data[i-1].GetX(std::min(i1, data[i-1].GetVectorLength()-1));
62 x2 = data[i].GetX(ii);
63 if(x1<x2&&i1<data[i-1].GetVectorLength())
64 {
65 y1 = data[i-1].GetY(i1);
66 y2 = data[i].GetY(x1);
67 if(E2-E1!=0)
68 {
69 y = theInt.Interpolate(theManager.GetScheme(i), e1, E1, E2, y1, y2);
70 }
71 else
72 {
73 y = 0.5*(y1+y2);
74 }
75 aBuffer->SetData(ib, x1, y);
76 aBuffer->SetScheme(ib++, data[i-1].GetScheme(i1));
77 i1++;
78 if(x2-x1>0.001*x1)
79 {
80 ii--;
81 }
82 }
83 else
84 {
85 y1 = data[i-1].GetY(x2);
86 y2 = data[i].GetY(ii);
87 if(E2-E1!=0)
88 {
89 y = theInt.Interpolate(theManager.GetScheme(i), e1, E1, E2, y1, y2);
90 }
91 else
92 {
93 y = 0.5*(y1+y2);
94 }
95 aBuffer->SetData(ib, x2, y);
96 aBuffer->SetScheme(ib++, data[i].GetScheme(ii));
97 if(x1-x2<0.001*x2) i1++;
98 }
99 }
100 return aBuffer;
101 }
int G4int
Definition: G4Types.hh:66
G4InterpolationScheme GetScheme(G4int index) const
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4double GetX(G4int i)
G4double GetY(G4int i, G4int j)
void SetScheme(G4int aPoint, const G4InterpolationScheme &aScheme)
G4double GetY(G4double x)
void SetData(G4int i, G4double x, G4double y)
void SetInterpolationManager(const G4InterpolationManager &aManager)

◆ GetY() [2/3]

G4double G4NeutronHPPartial::GetY ( G4int  i,
G4double  e 
)
inline

Definition at line 117 of file G4NeutronHPPartial.hh.

117{return data[i].GetY(e);}

◆ GetY() [3/3]

G4double G4NeutronHPPartial::GetY ( G4int  i,
G4int  j 
)
inline

Definition at line 116 of file G4NeutronHPPartial.hh.

116{return data[i].GetY(j);}

Referenced by G4NeutronHPPhotonDist::GetPhotons(), GetY(), and Sample().

◆ Init()

void G4NeutronHPPartial::Init ( std::ifstream &  aDataFile)
inline

Definition at line 71 of file G4NeutronHPPartial.hh.

72 {
73 G4int i;
74 G4double e;
75 for( i=0; i<nData; i++)
76 {
77 aDataFile >> e;
78 e *= CLHEP::eV;
79 SetX(i,e);
80 InitData(i, aDataFile, CLHEP::eV); // energy and probability for gammas
81 }
82 }
void InitData(G4int i, std::ifstream &aDataFile, G4double unit=1.)
void SetX(G4int i, G4double x)

Referenced by G4NeutronHPPhotonDist::InitEnergies().

◆ InitData()

void G4NeutronHPPartial::InitData ( G4int  i,
std::ifstream &  aDataFile,
G4double  unit = 1. 
)
inline

Definition at line 84 of file G4NeutronHPPartial.hh.

85 {
86 G4int ii;
87 G4double eg, pg;
88 G4int neg;
89 aDataFile >> neg;
90 data[i].InitInterpolation(aDataFile);
91 for (ii=0; ii<neg; ii++)
92 {
93 aDataFile >> eg >> pg;
94 eg *= unit;
95 SetX(i,ii,eg);
96 SetY(i,ii,pg);
97 }
98 }
void SetY(G4int i, G4int j, G4double y)
void InitInterpolation(std::ifstream &aDataFile)

Referenced by G4NeutronHPAngular::Init(), and Init().

◆ InitInterpolation() [1/2]

void G4NeutronHPPartial::InitInterpolation ( G4int  i,
std::ifstream &  aDataFile 
)
inline

Definition at line 61 of file G4NeutronHPPartial.hh.

62 {
63 data[i].InitInterpolation(aDataFile);
64 }

Referenced by G4NeutronHPElasticFS::Init(), G4NeutronHPAngular::Init(), and G4NeutronHPPhotonDist::InitEnergies().

◆ InitInterpolation() [2/2]

void G4NeutronHPPartial::InitInterpolation ( std::ifstream &  aDataFile)
inline

Definition at line 66 of file G4NeutronHPPartial.hh.

67 {
68 theManager.Init(aDataFile);
69 }
void Init(G4int aScheme, G4int aRange)

◆ Sample()

G4double G4NeutronHPPartial::Sample ( G4double  x)

Definition at line 103 of file G4NeutronHPPartial.cc.

104 {
105 G4int i;
106 for (i=0; i<nData; i++)
107 {
108 if(x<X[i]) break;
109 }
110 G4NeutronHPVector theBuff;
111 if(i==0)
112 {
113 theBuff.SetInterpolationManager(data[0].GetInterpolationManager());
114 for(G4int ii=0;ii<GetNEntries(0);ii++)
115 {
116 theBuff.SetX(ii, GetX(0,ii));
117 theBuff.SetY(ii, GetY(0,ii));
118 }
119 }
120 //else if(i==nData-1) this line will be delete
121 else if ( i == nData )
122 {
123 for(i=0;i<GetNEntries(nData-1);i++)
124 {
125 theBuff.SetX(i, GetX(nData-1,i));
126 theBuff.SetY(i, GetY(nData-1,i));
127 theBuff.SetInterpolationManager(data[nData-1].GetInterpolationManager());
128 }
129 }
130 else
131 {
132 G4int low = i-1;
133 G4int high = low+1;
134 G4double x1,x2,y1,y2;
135 G4int i1=0, i2=0, ii=0;
136 x1 = X[low];
137 x2 = X[high];
138 while(i1<GetNEntries(low)||i2<GetNEntries(high))
139 {
140 if( (GetX(low,i1)<GetX(high,i2) && i1<GetNEntries(low))
141 ||(i2==GetNEntries(high)) )
142 {
143 theBuff.SetX(ii, GetX(low,i1));
144 y1 = GetY(low,i1);
145 y2 = GetY(high, GetX(low,i1)); //prob at ident theta
146 theBuff.SetY(ii, theInt.Interpolate(theManager.GetScheme(high),
147 x, x1, x2, y1, y2)); //energy interpol
148 theBuff.SetScheme(ii, data[low].GetScheme(i1));
149 if(std::abs(GetX(low,i1)-GetX(high,i2))<0.001) i2++;
150 i1++;
151 ii++;
152 }
153 else
154 {
155 theBuff.SetX(ii, GetX(high,i2));
156 //*******************************************************************************
157 //Change by E.Mendoza and D.Cano (CIEMAT):
158 //y1 = GetY(high,i2);
159 //y2 = GetY(low, GetX(high,i2)); //prob at ident theta
160 y2 = GetY(high,i2);
161 y1 = GetY(low, GetX(high,i2)); //prob at ident theta
162 //*******************************************************************************
163 theBuff.SetY(ii, theInt.Interpolate(theManager.GetScheme(high),
164 x, x1, x2, y1, y2)); //energy interpol
165 theBuff.SetScheme(ii, data[high].GetScheme(i2));
166 if(std::abs(GetX(low,i1)-GetX(high,i2))<0.001) i1++;
167 i2++;
168 ii++;
169 }
170 }
171 }
172 //buff is full, now sample.
173 return theBuff.Sample();
174 }
G4int GetNEntries(G4int i)
void SetX(G4int i, G4double e)
void SetY(G4int i, G4double x)

Referenced by G4NeutronHPElasticFS::ApplyYourself(), and G4NeutronHPAngular::SampleAndUpdate().

◆ SetT()

void G4NeutronHPPartial::SetT ( G4int  i,
G4double  x 
)
inline

Definition at line 109 of file G4NeutronHPPartial.hh.

109{T[i]=x;}

Referenced by G4NeutronHPElasticFS::Init(), and G4NeutronHPAngular::Init().

◆ SetX() [1/2]

void G4NeutronHPPartial::SetX ( G4int  i,
G4double  x 
)
inline

Definition at line 108 of file G4NeutronHPPartial.hh.

108{X[i]=x;}

Referenced by G4NeutronHPElasticFS::Init(), G4NeutronHPAngular::Init(), Init(), and InitData().

◆ SetX() [2/2]

void G4NeutronHPPartial::SetX ( G4int  i,
G4int  j,
G4double  x 
)
inline

Definition at line 110 of file G4NeutronHPPartial.hh.

110{data[i].SetX(j,x);}

◆ SetY()

void G4NeutronHPPartial::SetY ( G4int  i,
G4int  j,
G4double  y 
)
inline

Definition at line 111 of file G4NeutronHPPartial.hh.

111{data[i].SetY(j,y);}

Referenced by G4NeutronHPElasticFS::Init(), and InitData().


The documentation for this class was generated from the following files: