Geant4-11
Public Member Functions | Protected Member Functions | Private Attributes
G4ParticleHPLabAngularEnergy Class Reference

#include <G4ParticleHPLabAngularEnergy.hh>

Inheritance diagram for G4ParticleHPLabAngularEnergy:
G4VParticleHPEnergyAngular

Public Member Functions

virtual void ClearHistories ()
 
 G4ParticleHPLabAngularEnergy ()
 
G4ReactionProductGetCMS ()
 
G4ReactionProductGetProjectileRP ()
 
G4ReactionProductGetTarget ()
 
void Init (std::istream &aDataFile)
 
G4double MeanEnergyOfThisInteraction ()
 
G4ReactionProductSample (G4double anEnergy, G4double massCode, G4double mass)
 
void SetProjectileRP (G4ReactionProduct *aIncidentParticleRP)
 
void SetQValue (G4double aValue)
 
void SetTarget (G4ReactionProduct *aTarget)
 
 ~G4ParticleHPLabAngularEnergy ()
 

Protected Member Functions

G4double GetQValue ()
 

Private Attributes

G4double currentMeanEnergy
 
G4Cache< toBeCachedfCache
 
G4intnCosTh
 
G4int nEnergies
 
G4ParticleHPVector ** theData
 
G4doubletheEnergies
 
G4ParticleHPInterpolator theInt
 
G4InterpolationManager theManager
 
G4double theQValue
 
G4InterpolationManagertheSecondManager
 

Detailed Description

Definition at line 42 of file G4ParticleHPLabAngularEnergy.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPLabAngularEnergy()

G4ParticleHPLabAngularEnergy::G4ParticleHPLabAngularEnergy ( )
inline

◆ ~G4ParticleHPLabAngularEnergy()

G4ParticleHPLabAngularEnergy::~G4ParticleHPLabAngularEnergy ( )
inline

Definition at line 55 of file G4ParticleHPLabAngularEnergy.hh.

56 {
57 if(theEnergies != 0) delete [] theEnergies;
58 if(nCosTh != 0) delete [] nCosTh;
59 if(theData != 0)
60 {
61 for(G4int i=0; i<nEnergies; i++)
62 delete [] theData[i];
63 delete [] theData;
64 }
65 if(theSecondManager != 0) delete [] theSecondManager;
66 }
int G4int
Definition: G4Types.hh:85

References nCosTh, nEnergies, theData, theEnergies, and theSecondManager.

Member Function Documentation

◆ ClearHistories()

virtual void G4VParticleHPEnergyAngular::ClearHistories ( )
inlinevirtualinherited

Reimplemented in G4ParticleHPContEnergyAngular.

Definition at line 106 of file G4VParticleHPEnergyAngular.hh.

107 {
108 }

Referenced by G4ParticleHPProduct::Sample().

◆ GetCMS()

G4ReactionProduct * G4VParticleHPEnergyAngular::GetCMS ( )
inlineinherited

Definition at line 94 of file G4VParticleHPEnergyAngular.hh.

95 {
96 *fCache.Get().theCMS = *fCache.Get().theProjectileRP
97 + *fCache.Get().theTarget;
98 return fCache.Get().theCMS;
99 }

References G4VParticleHPEnergyAngular::fCache.

◆ GetProjectileRP()

G4ReactionProduct * G4VParticleHPEnergyAngular::GetProjectileRP ( )
inlineinherited

◆ GetQValue()

G4double G4VParticleHPEnergyAngular::GetQValue ( )
inlineprotectedinherited

◆ GetTarget()

G4ReactionProduct * G4VParticleHPEnergyAngular::GetTarget ( void  )
inlineinherited

◆ Init()

void G4ParticleHPLabAngularEnergy::Init ( std::istream &  aDataFile)
virtual

Implements G4VParticleHPEnergyAngular.

Definition at line 50 of file G4ParticleHPLabAngularEnergy.cc.

51{
52 aDataFile >> nEnergies;
53 theManager.Init(aDataFile);
55 nCosTh = new G4int[nEnergies];
58 for(G4int i=0; i<nEnergies; i++)
59 {
60 aDataFile >> theEnergies[i];
61 theEnergies[i]*=eV;
62 aDataFile >> nCosTh[i];
63 theSecondManager[i].Init(aDataFile);
65 G4double label;
66 for(G4int ii=0; ii<nCosTh[i]; ii++)
67 {
68 aDataFile >> label;
69 theData[i][ii].SetLabel(label);
70 theData[i][ii].Init(aDataFile, eV);
71 }
72 }
73}
static constexpr double eV
Definition: G4SIunits.hh:201
double G4double
Definition: G4Types.hh:83
void Init(G4int aScheme, G4int aRange)
void SetLabel(G4double aLabel)
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)

References eV, G4InterpolationManager::Init(), G4ParticleHPVector::Init(), nCosTh, nEnergies, G4ParticleHPVector::SetLabel(), theData, theEnergies, theManager, and theSecondManager.

◆ MeanEnergyOfThisInteraction()

G4double G4ParticleHPLabAngularEnergy::MeanEnergyOfThisInteraction ( )
inlinevirtual

Implements G4VParticleHPEnergyAngular.

Definition at line 72 of file G4ParticleHPLabAngularEnergy.hh.

73 {
74 return currentMeanEnergy;
75 }

References currentMeanEnergy.

◆ Sample()

G4ReactionProduct * G4ParticleHPLabAngularEnergy::Sample ( G4double  anEnergy,
G4double  massCode,
G4double  mass 
)
virtual

Implements G4VParticleHPEnergyAngular.

Definition at line 75 of file G4ParticleHPLabAngularEnergy.cc.

76{
78 G4int Z = static_cast<G4int>(massCode/1000);
79 G4int A = static_cast<G4int>(massCode-1000*Z);
80
81 if(massCode==0)
82 {
84 }
85 else if(A==0)
86 {
88 if(Z==1) result->SetDefinition(G4Positron::Positron());
89 }
90 else if(A==1)
91 {
93 if(Z==1) result->SetDefinition(G4Proton::Proton());
94 }
95 else if(A==2)
96 {
98 }
99 else if(A==3)
100 {
102 if(Z==2) result->SetDefinition(G4He3::He3());
103 }
104 else if(A==4)
105 {
106 result->SetDefinition(G4Alpha::Alpha());
107 if(Z!=2) throw G4HadronicException(__FILE__, __LINE__, "Unknown ion case 1");
108 }
109 else
110 {
111 throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPLabAngularEnergy: Unknown ion case 2");
112 }
113
114 // get theta, E
115 G4double cosTh, secEnergy;
116 G4int i, it(0);
117 // find the energy bin
118 for(i=0; i<nEnergies; i++)
119 {
120 it = i;
121 if ( anEnergy < theEnergies[i] ) break;
122 }
123
124 if ( it == 0 ) // it marks the energy bin --> we do not extrapolate to low energies, we extrapolate to high energies (??)
125 {
126 //Do not sample between incident neutron energies:
127 //---------------------------------------------------------
128 //CosTheta:
129 G4ParticleHPVector theThVec;
131 for(i=0; i<nCosTh[it]; i++)
132 {
133 theThVec.SetX(i, theData[it][i].GetLabel());
134 theThVec.SetY(i, theData[it][i].GetIntegral());
135 }
136 cosTh=theThVec.Sample();
137 //---------------------------------------------------------
138
139 //---------------------------------------------------------
140 //Now the secondary energy:
141 G4double x, x1, x2, y1, y2, y, E;
142 G4int i1(0);
143 for(i=1; i<nCosTh[it]; i++)
144 {
145 i1 = i;
146 if(cosTh<theData[it][i].GetLabel()) break;
147 }
148 // now get the prob at this energy for the right theta value
149 x = cosTh;
150 x1 = theData[it][i1-1].GetLabel();
151 x2 = theData[it][i1].GetLabel();
152 G4ParticleHPVector theBuff1a;
153 theBuff1a.SetInterpolationManager(theData[it][i1-1].GetInterpolationManager());
154 for(i=0;i<theData[it][i1-1].GetVectorLength(); i++)
155 {
156 E = theData[it][i1-1].GetX(i);
157 y1 = theData[it][i1-1].GetY(i);
158 y2 = theData[it][i1].GetY(E);
159 y = theInt.Interpolate(theSecondManager[it].GetScheme(i1), x, x1,x2,y1,y2);
160 theBuff1a.SetData(i, E, y);
161 }
162 G4ParticleHPVector theBuff2a;
163 theBuff2a.SetInterpolationManager(theData[it][i1].GetInterpolationManager());
164 for(i=0;i<theData[it][i1].GetVectorLength(); i++)
165 {
166 E = theData[it][i1].GetX(i);
167 y1 = theData[it][i1-1].GetY(E);
168 y2 = theData[it][i1].GetY(i);
169 y = theInt.Interpolate(theSecondManager[it].GetScheme(i1), x, x1,x2,y1,y2);
170 theBuff2a.SetData(i, E, y); // wrong E, right theta.
171 }
172 G4ParticleHPVector theStore;
173 theStore.Merge(&theBuff1a, &theBuff2a);
174 secEnergy = theStore.Sample();
175 currentMeanEnergy = theStore.GetMeanX();
176 //---------------------------------------------------------
177 }
178 else // this is the small big else.
179 {
180 G4double x, x1, x2, y1, y2, y, tmp, E;
181 // integrate the prob for each costh, and select theta.
183 for(i=0;i<nCosTh[it-1]; i++)
184 {
185 run1.SetX(i, theData[it-1][i].GetLabel());
186 run1.SetY(i,theData[it-1][i].GetIntegral());
187 }
189 for(i=0;i<nCosTh[it]; i++)
190 {
191 run2.SetX(i, theData[it][i].GetLabel());
192 run2.SetY(i, theData[it][i].GetIntegral());
193 }
194 // get the distributions for the correct neutron energy
195 x = anEnergy;
196 x1 = theEnergies[it-1];
197 x2 = theEnergies[it];
198 G4ParticleHPVector thBuff1; // to be interpolated as run1.
200 for(i=0; i<run1.GetVectorLength(); i++)
201 {
202 tmp = run1.GetX(i); //theta
203 y1 = run1.GetY(i); // integral
204 y2 = run2.GetY(tmp);
205 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
206 thBuff1.SetData(i, tmp, y);
207 }
208 G4ParticleHPVector thBuff2;
210 for(i=0; i<run2.GetVectorLength(); i++)
211 {
212 tmp = run2.GetX(i); //theta
213 y1 = run1.GetY(tmp); // integral
214 y2 = run2.GetY(i);
215 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
216 thBuff2.SetData(i, tmp, y);
217 }
218 G4ParticleHPVector theThVec;
219 theThVec.Merge(&thBuff1 ,&thBuff2); // takes care of interpolation
220 cosTh=theThVec.Sample();
221 /*
222 if(massCode>0.99 && massCode<1.01){theThVec.Dump();}
223 G4double random = (theThVec.GetY(theThVec.GetVectorLength()-1)
224 -theThVec.GetY(0)) *G4UniformRand();
225 G4cout<<" -- "<<theThVec.GetY(theThVec.GetVectorLength()-1)<<" "<<theThVec.GetY(0)<<" ----> "<<random<<G4endl;
226 G4int ith(0);
227 for(i=1;i<theThVec.GetVectorLength(); i++)
228 {
229 ith = i;
230 if(random<theThVec.GetY(i)-theThVec.GetY(0)) break;
231 }
232 {
233 // calculate theta
234 G4double xx, xx1, xx2, yy1, yy2;
235 xx = random;
236 xx1 = theThVec.GetY(ith-1)-theThVec.GetY(0); // integrals
237 xx2 = theThVec.GetY(ith)-theThVec.GetY(0);
238 yy1 = theThVec.GetX(ith-1); // std::cos(theta)
239 yy2 = theThVec.GetX(ith);
240 cosTh = theInt.Interpolate(theSecondManager[it].GetScheme(ith),
241 xx, xx1,xx2,yy1,yy2);
242 }
243 */
244 G4int i1(0), i2(0);
245 // get the indixes of the vectors close to theta for low energy
246 // first it-1 !!!! i.e. low in energy
247 for(i=1; i<nCosTh[it-1]; i++)
248 {
249 i1 = i;
250 if(cosTh<theData[it-1][i].GetLabel()) break;
251 }
252 // now get the prob at this energy for the right theta value
253 x = cosTh;
254 x1 = theData[it-1][i1-1].GetLabel();
255 x2 = theData[it-1][i1].GetLabel();
256 G4ParticleHPVector theBuff1a;
257 theBuff1a.SetInterpolationManager(theData[it-1][i1-1].GetInterpolationManager());
258 for(i=0;i<theData[it-1][i1-1].GetVectorLength(); i++)
259 {
260 E = theData[it-1][i1-1].GetX(i);
261 y1 = theData[it-1][i1-1].GetY(i);
262 y2 = theData[it-1][i1].GetY(E);
263 y = theInt.Interpolate(theSecondManager[it-1].GetScheme(i1), x, x1,x2,y1,y2);
264 theBuff1a.SetData(i, E, y); // wrong E, right theta.
265 }
266 G4ParticleHPVector theBuff2a;
267 theBuff2a.SetInterpolationManager(theData[it-1][i1].GetInterpolationManager());
268 for(i=0;i<theData[it-1][i1].GetVectorLength(); i++)
269 {
270 E = theData[it-1][i1].GetX(i);
271 y1 = theData[it-1][i1-1].GetY(E);
272 y2 = theData[it-1][i1].GetY(i);
273 y = theInt.Interpolate(theSecondManager[it-1].GetScheme(i1), x, x1,x2,y1,y2);
274 theBuff2a.SetData(i, E, y); // wrong E, right theta.
275 }
276 G4ParticleHPVector theStore1;
277 theStore1.Merge(&theBuff1a, &theBuff2a); // wrong E, right theta, complete binning
278
279 // get the indixes of the vectors close to theta for high energy
280 // then it !!!! i.e. high in energy
281 for(i=1; i<nCosTh[it]; i++)
282 {
283 i2 = i;
284 if(cosTh<theData[it][i2].GetLabel()) break;
285 } // sonderfaelle mit i1 oder i2 head on fehlen. @@@@@
286 x1 = theData[it][i2-1].GetLabel();
287 x2 = theData[it][i2].GetLabel();
288 G4ParticleHPVector theBuff1b;
289 theBuff1b.SetInterpolationManager(theData[it][i2-1].GetInterpolationManager());
290 for(i=0;i<theData[it][i2-1].GetVectorLength(); i++)
291 {
292 E = theData[it][i2-1].GetX(i);
293 y1 = theData[it][i2-1].GetY(i);
294 y2 = theData[it][i2].GetY(E);
295 y = theInt.Interpolate(theSecondManager[it].GetScheme(i2), x, x1,x2,y1,y2);
296 theBuff1b.SetData(i, E, y); // wrong E, right theta.
297 }
298 G4ParticleHPVector theBuff2b;
299 theBuff2b.SetInterpolationManager(theData[it][i2].GetInterpolationManager());
300 //080808 i1 -> i2
301 //for(i=0;i<theData[it][i1].GetVectorLength(); i++)
302 for(i=0;i<theData[it][i2].GetVectorLength(); i++)
303 {
304 //E = theData[it][i1].GetX(i);
305 //y1 = theData[it][i1-1].GetY(E);
306 //y2 = theData[it][i1].GetY(i);
307 E = theData[it][i2].GetX(i);
308 y1 = theData[it][i2-1].GetY(E);
309 y2 = theData[it][i2].GetY(i);
310 y = theInt.Interpolate(theSecondManager[it].GetScheme(i2), x, x1,x2,y1,y2);
311 theBuff2b.SetData(i, E, y); // wrong E, right theta.
312 }
313 G4ParticleHPVector theStore2;
314 theStore2.Merge(&theBuff1b, &theBuff2b); // wrong E, right theta, complete binning
315 // now get to the right energy.
316
317 x = anEnergy;
318 x1 = theEnergies[it-1];
319 x2 = theEnergies[it];
320 G4ParticleHPVector theOne1;
322 for(i=0; i<theStore1.GetVectorLength(); i++)
323 {
324 E = theStore1.GetX(i);
325 y1 = theStore1.GetY(i);
326 y2 = theStore2.GetY(E);
327 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
328 theOne1.SetData(i, E, y); // both correct
329 }
330 G4ParticleHPVector theOne2;
332 for(i=0; i<theStore2.GetVectorLength(); i++)
333 {
334 E = theStore2.GetX(i);
335 y1 = theStore1.GetY(E);
336 y2 = theStore2.GetY(i);
337 y = theInt.Interpolate(theManager.GetScheme(it), x, x1,x2,y1,y2);
338 theOne2.SetData(i, E, y); // both correct
339 }
340 G4ParticleHPVector theOne;
341 theOne.Merge(&theOne1, &theOne2); // both correct, complete binning
342
343 secEnergy = theOne.Sample();
344 currentMeanEnergy = theOne.GetMeanX();
345 }
346
347// now do random direction in phi, and fill the result.
348
349 result->SetKineticEnergy(secEnergy);
350
352 G4double theta = std::acos(cosTh);
353 G4double sinth = std::sin(theta);
354 G4double mtot = result->GetTotalMomentum();
355 G4ThreeVector tempVector(mtot*sinth*std::cos(phi), mtot*sinth*std::sin(phi), mtot*std::cos(theta) );
356 result->SetMomentum(tempVector);
357
358 return result;
359}
static constexpr double twopi
Definition: G4SIunits.hh:56
const G4int Z[17]
const G4double A[17]
#define G4UniformRand()
Definition: Randomize.hh:52
static G4Alpha * Alpha()
Definition: G4Alpha.cc:88
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:93
static G4Electron * Electron()
Definition: G4Electron.cc:93
static G4Gamma * Gamma()
Definition: G4Gamma.cc:85
static G4He3 * He3()
Definition: G4He3.cc:93
G4InterpolationScheme GetScheme(G4int index) const
static G4Neutron * Neutron()
Definition: G4Neutron.cc:103
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
void SetY(G4int i, G4double x)
void SetX(G4int i, G4double e)
void SetData(G4int i, G4double x, G4double y)
const G4InterpolationManager & GetInterpolationManager() const
void SetInterpolationManager(const G4InterpolationManager &aManager)
G4double GetY(G4double x)
G4double GetX(G4int i) const
void Merge(G4ParticleHPVector *active, G4ParticleHPVector *passive)
G4int GetVectorLength() const
static G4Positron * Positron()
Definition: G4Positron.cc:93
static G4Proton * Proton()
Definition: G4Proton.cc:92
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4double GetTotalMomentum() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetKineticEnergy(const G4double en)
static G4Triton * Triton()
Definition: G4Triton.cc:93

References A, G4Alpha::Alpha(), currentMeanEnergy, G4Deuteron::Deuteron(), G4Electron::Electron(), G4UniformRand, G4Gamma::Gamma(), G4ParticleHPVector::GetInterpolationManager(), G4ParticleHPVector::GetLabel(), G4ParticleHPVector::GetMeanX(), G4InterpolationManager::GetScheme(), G4ReactionProduct::GetTotalMomentum(), G4ParticleHPVector::GetVectorLength(), G4ParticleHPVector::GetX(), G4ParticleHPVector::GetY(), G4He3::He3(), G4ParticleHPInterpolator::Interpolate(), G4ParticleHPVector::Merge(), nCosTh, nEnergies, G4Neutron::Neutron(), G4Positron::Positron(), G4Proton::Proton(), G4ParticleHPVector::Sample(), G4ParticleHPVector::SetData(), G4ReactionProduct::SetDefinition(), G4ParticleHPVector::SetInterpolationManager(), G4ReactionProduct::SetKineticEnergy(), G4ReactionProduct::SetMomentum(), G4ParticleHPVector::SetX(), G4ParticleHPVector::SetY(), theData, theEnergies, theInt, theManager, theSecondManager, G4Triton::Triton(), twopi, and Z.

◆ SetProjectileRP()

void G4VParticleHPEnergyAngular::SetProjectileRP ( G4ReactionProduct aIncidentParticleRP)
inlineinherited

Definition at line 74 of file G4VParticleHPEnergyAngular.hh.

75 {
76 fCache.Get().theProjectileRP = aIncidentParticleRP;
77 }

References G4VParticleHPEnergyAngular::fCache.

Referenced by G4ParticleHPInelasticBaseFS::BaseApply(), and G4ParticleHPProduct::Sample().

◆ SetQValue()

void G4VParticleHPEnergyAngular::SetQValue ( G4double  aValue)
inlineinherited

◆ SetTarget()

void G4VParticleHPEnergyAngular::SetTarget ( G4ReactionProduct aTarget)
inlineinherited

Definition at line 79 of file G4VParticleHPEnergyAngular.hh.

80 {
81 fCache.Get().theTarget = aTarget;
82 }

References G4VParticleHPEnergyAngular::fCache.

Referenced by G4ParticleHPInelasticBaseFS::BaseApply(), and G4ParticleHPProduct::Sample().

Field Documentation

◆ currentMeanEnergy

G4double G4ParticleHPLabAngularEnergy::currentMeanEnergy
private

◆ fCache

G4Cache<toBeCached> G4VParticleHPEnergyAngular::fCache
privateinherited

◆ nCosTh

G4int* G4ParticleHPLabAngularEnergy::nCosTh
private

◆ nEnergies

G4int G4ParticleHPLabAngularEnergy::nEnergies
private

◆ theData

G4ParticleHPVector** G4ParticleHPLabAngularEnergy::theData
private

◆ theEnergies

G4double* G4ParticleHPLabAngularEnergy::theEnergies
private

◆ theInt

G4ParticleHPInterpolator G4ParticleHPLabAngularEnergy::theInt
private

Definition at line 94 of file G4ParticleHPLabAngularEnergy.hh.

Referenced by Sample().

◆ theManager

G4InterpolationManager G4ParticleHPLabAngularEnergy::theManager
private

Definition at line 83 of file G4ParticleHPLabAngularEnergy.hh.

Referenced by Init(), and Sample().

◆ theQValue

G4double G4VParticleHPEnergyAngular::theQValue
privateinherited

◆ theSecondManager

G4InterpolationManager* G4ParticleHPLabAngularEnergy::theSecondManager
private

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