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

#include <G4ParticleHPPartial.hh>

Public Member Functions

 G4ParticleHPPartial (G4int n)
 
 G4ParticleHPPartial (G4int n1, G4int n2)
 
void InitInterpolation (G4int i, std::istream &aDataFile)
 
void InitInterpolation (std::istream &aDataFile)
 
void Init (std::istream &aDataFile)
 
void InitData (G4int i, std::istream &aDataFile, G4double unit=1.)
 
 ~G4ParticleHPPartial ()
 
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)
 
void DoneSetXY (G4int i)
 
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)
 
G4ParticleHPVectorGetY (G4double e1)
 
G4double Sample (G4double x)
 

Detailed Description

Definition at line 41 of file G4ParticleHPPartial.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPPartial() [1/2]

G4ParticleHPPartial::G4ParticleHPPartial ( G4int  n)
inline

Definition at line 45 of file G4ParticleHPPartial.hh.

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

◆ G4ParticleHPPartial() [2/2]

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

Definition at line 53 of file G4ParticleHPPartial.hh.

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

◆ ~G4ParticleHPPartial()

G4ParticleHPPartial::~G4ParticleHPPartial ( )
inline

Definition at line 101 of file G4ParticleHPPartial.hh.

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

Member Function Documentation

◆ DoneSetXY()

void G4ParticleHPPartial::DoneSetXY ( G4int  i)
inline

Definition at line 113 of file G4ParticleHPPartial.hh.

113{ data[i].Hash(); }

Referenced by G4ParticleHPElasticFS::Init().

◆ GetNEntries()

G4int G4ParticleHPPartial::GetNEntries ( G4int  i)
inline

Definition at line 120 of file G4ParticleHPPartial.hh.

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

Referenced by Sample().

◆ GetNumberOfEnergies()

G4int G4ParticleHPPartial::GetNumberOfEnergies ( )
inline

Definition at line 107 of file G4ParticleHPPartial.hh.

107{return nData;}

◆ GetT()

G4double G4ParticleHPPartial::GetT ( G4int  i)
inline

Definition at line 116 of file G4ParticleHPPartial.hh.

116{return T[i];}

◆ GetX() [1/2]

G4double G4ParticleHPPartial::GetX ( G4int  i)
inline

Definition at line 115 of file G4ParticleHPPartial.hh.

115{return X[i];}

Referenced by GetY(), and Sample().

◆ GetX() [2/2]

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

Definition at line 117 of file G4ParticleHPPartial.hh.

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

◆ GetY() [1/3]

G4ParticleHPVector * G4ParticleHPPartial::GetY ( G4double  e1)

Definition at line 38 of file G4ParticleHPPartial.cc.

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

◆ GetY() [2/3]

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

Definition at line 119 of file G4ParticleHPPartial.hh.

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

◆ GetY() [3/3]

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

Definition at line 118 of file G4ParticleHPPartial.hh.

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

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

◆ Init()

void G4ParticleHPPartial::Init ( std::istream &  aDataFile)
inline

Definition at line 71 of file G4ParticleHPPartial.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 SetX(G4int i, G4double x)
void InitData(G4int i, std::istream &aDataFile, G4double unit=1.)

Referenced by G4ParticleHPPhotonDist::InitEnergies().

◆ InitData()

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

Definition at line 84 of file G4ParticleHPPartial.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 data[i].Hash();
99 }
void SetY(G4int i, G4int j, G4double y)
void InitInterpolation(std::istream &aDataFile)

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

◆ InitInterpolation() [1/2]

void G4ParticleHPPartial::InitInterpolation ( G4int  i,
std::istream &  aDataFile 
)
inline

◆ InitInterpolation() [2/2]

void G4ParticleHPPartial::InitInterpolation ( std::istream &  aDataFile)
inline

Definition at line 66 of file G4ParticleHPPartial.hh.

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

◆ Sample()

G4double G4ParticleHPPartial::Sample ( G4double  x)

Definition at line 105 of file G4ParticleHPPartial.cc.

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

Referenced by G4ParticleHPElasticFS::ApplyYourself(), and G4ParticleHPAngular::SampleAndUpdate().

◆ SetT()

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

Definition at line 110 of file G4ParticleHPPartial.hh.

110{T[i]=x;}

Referenced by G4ParticleHPElasticFS::Init(), and G4ParticleHPAngular::Init().

◆ SetX() [1/2]

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

Definition at line 109 of file G4ParticleHPPartial.hh.

109{X[i]=x;}

Referenced by G4ParticleHPElasticFS::Init(), G4ParticleHPAngular::Init(), Init(), and InitData().

◆ SetX() [2/2]

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

Definition at line 111 of file G4ParticleHPPartial.hh.

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

◆ SetY()

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

Definition at line 112 of file G4ParticleHPPartial.hh.

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

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


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