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

#include <G4ParticleHPElasticFS.hh>

+ Inheritance diagram for G4ParticleHPElasticFS:

Public Member Functions

 G4ParticleHPElasticFS ()
 
 ~G4ParticleHPElasticFS () override
 
void Init (G4double A, G4double Z, G4int M, G4String &dirName, G4String &aFSType, G4ParticleDefinition *) override
 
G4HadFinalStateApplyYourself (const G4HadProjectile &theTrack) override
 
G4ParticleHPFinalStateNew () override
 
void RegisterCrossSection (G4ParticleHPVector *vec)
 
- Public Member Functions inherited from G4ParticleHPFinalState
 G4ParticleHPFinalState ()
 
virtual ~G4ParticleHPFinalState ()
 
void Init (G4double A, G4double Z, G4String &dirName, G4String &aFSType, G4ParticleDefinition *p)
 
G4bool HasXsec ()
 
G4bool HasFSData ()
 
G4bool HasAnyData ()
 
virtual G4double GetXsec (G4double)
 
virtual G4ParticleHPVectorGetXsec ()
 
void SetA_Z (G4double anA, G4double aZ, G4int aM=0)
 
G4double GetZ ()
 
G4double GetN ()
 
G4double GetA ()
 
G4int GetM ()
 
void SetAZMs (G4ParticleHPDataUsed used)
 
void SetAZMs (G4double anA, G4double aZ, G4int aM, G4ParticleHPDataUsed used)
 
void SetProjectile (G4ParticleDefinition *projectile)
 
G4ParticleHPFinalStateoperator= (const G4ParticleHPFinalState &right)=delete
 
 G4ParticleHPFinalState (const G4ParticleHPFinalState &)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from G4ParticleHPFinalState
void adjust_final_state (G4LorentzVector)
 
- Protected Attributes inherited from G4ParticleHPFinalState
G4ParticleDefinitiontheProjectile {nullptr}
 
G4ParticleHPManagerfManager
 
G4IonTableionTable
 
G4int theBaseA {0}
 
G4int theBaseZ {0}
 
G4int theBaseM {0}
 
G4int theNDLDataZ {0}
 
G4int theNDLDataA {0}
 
G4int theNDLDataM {0}
 
G4int secID {-1}
 
G4bool hasXsec {true}
 
G4bool hasFSData {true}
 
G4bool hasAnyData {true}
 
G4ParticleHPNames theNames
 
G4Cache< G4HadFinalState * > theResult
 

Detailed Description

Definition at line 48 of file G4ParticleHPElasticFS.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPElasticFS()

G4ParticleHPElasticFS::G4ParticleHPElasticFS ( )

Definition at line 58 of file G4ParticleHPElasticFS.cc.

59{
60 svtEmax = 0.0;
61 dbrcEmax = 0.0;
62 dbrcEmin = 0.0;
63 dbrcAmin = 0.0;
64 dbrcUse = false;
65 xsForDBRC = nullptr;
66
67 secID = G4PhysicsModelCatalog::GetModelID("model_NeutronHPElastic");
68
69 hasXsec = false;
70 theCoefficients = nullptr;
71 theProbArray = nullptr;
72
73 repFlag = 0;
74 tE_of_repFlag3 = 0.0;
75 targetMass = 0.0;
76 frameFlag = 0;
77}
static G4int GetModelID(const G4int modelIndex)

Referenced by New().

◆ ~G4ParticleHPElasticFS()

G4ParticleHPElasticFS::~G4ParticleHPElasticFS ( )
inlineoverride

Definition at line 52 of file G4ParticleHPElasticFS.hh.

53 {
54 delete theCoefficients;
55 delete theProbArray;
56 }

Member Function Documentation

◆ ApplyYourself()

G4HadFinalState * G4ParticleHPElasticFS::ApplyYourself ( const G4HadProjectile & theTrack)
overridevirtual

Reimplemented from G4ParticleHPFinalState.

Definition at line 217 of file G4ParticleHPElasticFS.cc.

218{
219 if (theResult.Get() == nullptr) theResult.Put(new G4HadFinalState);
220 theResult.Get()->Clear();
221 G4double eKinetic = theTrack.GetKineticEnergy();
222 const G4HadProjectile* incidentParticle = &theTrack;
223 G4ReactionProduct theNeutron(
224 const_cast<G4ParticleDefinition*>(incidentParticle->GetDefinition()));
225 theNeutron.SetMomentum(incidentParticle->Get4Momentum().vect());
226 theNeutron.SetKineticEnergy(eKinetic);
227
228 G4ThreeVector neuVelo =
229 (1. / incidentParticle->GetDefinition()->GetPDGMass()) * theNeutron.GetMomentum();
230 G4ReactionProduct theTarget =
231 GetBiasedThermalNucleus(targetMass, neuVelo, theTrack.GetMaterial()->GetTemperature());
232
233 // Neutron and target defined as G4ReactionProducts
234 // Prepare Lorentz transformation to lab
235
236 G4ThreeVector the3Neutron = theNeutron.GetMomentum();
237 G4double nEnergy = theNeutron.GetTotalEnergy();
238 G4ThreeVector the3Target = theTarget.GetMomentum();
239 G4double tEnergy = theTarget.GetTotalEnergy();
240 G4ReactionProduct theCMS;
241 G4double totE = nEnergy + tEnergy;
242 G4ThreeVector the3CMS = the3Target + the3Neutron;
243 theCMS.SetMomentum(the3CMS);
244 G4double cmsMom = std::sqrt(the3CMS * the3CMS);
245 G4double sqrts = std::sqrt((totE - cmsMom) * (totE + cmsMom));
246 theCMS.SetMass(sqrts);
247 theCMS.SetTotalEnergy(totE);
248
249 // Data come as function of n-energy in nuclear rest frame
250 G4ReactionProduct boosted;
251 boosted.Lorentz(theNeutron, theTarget);
252 eKinetic = boosted.GetKineticEnergy(); // get kinetic energy for scattering
253 G4double cosTh = -2;
254
255 if (repFlag == 1) {
256 cosTh = theCoefficients->SampleElastic(eKinetic);
257 }
258 else if (repFlag == 2) {
259 cosTh = theProbArray->Sample(eKinetic);
260 }
261 else if (repFlag == 3) {
262 if (eKinetic <= tE_of_repFlag3) {
263 cosTh = theCoefficients->SampleElastic(eKinetic);
264 }
265 else {
266 cosTh = theProbArray->Sample(eKinetic);
267 }
268 }
269 else if (repFlag == 0) {
270 cosTh = 2. * G4UniformRand() - 1.;
271 }
272 else {
273 G4cout << "Unusable number for repFlag: repFlag=" << repFlag << G4endl;
274 throw G4HadronicException(__FILE__, __LINE__,
275 "G4ParticleHPElasticFS::Init -- unusable number for repFlag");
276 }
277
278 if (cosTh < -1.1) {
279 return nullptr;
280 }
281
282 G4double phi = twopi * G4UniformRand();
283 G4double cosPhi = std::cos(phi);
284 G4double sinPhi = std::sin(phi);
285 G4double theta = std::acos(cosTh);
286 G4double sinth = std::sin(theta);
287
288 if (frameFlag == 1) {
289 // Projectile scattering values cosTh are in target rest frame
290 // In this frame, do relativistic calculation of scattered projectile and
291 // target 4-momenta
292
293 theNeutron.Lorentz(theNeutron, theTarget);
294 G4double mN = theNeutron.GetMass();
295 G4double Pinit = theNeutron.GetTotalMomentum(); // Incident momentum
296 G4double Einit = theNeutron.GetTotalEnergy(); // Incident energy
297 G4double mT = theTarget.GetMass();
298
299 G4double ratio = mT / mN;
300 G4double sqt = std::sqrt(ratio * ratio - 1.0 + cosTh * cosTh);
301 G4double beta = Pinit / (mT + Einit); // CMS beta
302 G4double denom = 1. - beta * beta * cosTh * cosTh;
303 G4double term1 = cosTh * (Einit * ratio + mN) / (mN * ratio + Einit);
304 G4double pN = beta * mN * (term1 + sqt) / denom;
305
306 // Get the scattered momentum and rotate it in theta and phi
307 G4ThreeVector pDir = theNeutron.GetMomentum() / Pinit;
308 G4double px = pN * pDir.x();
309 G4double py = pN * pDir.y();
310 G4double pz = pN * pDir.z();
311
312 G4ThreeVector pcmRot;
313 pcmRot.setX(px * cosTh * cosPhi - py * sinPhi + pz * sinth * cosPhi);
314 pcmRot.setY(px * cosTh * sinPhi + py * cosPhi + pz * sinth * sinPhi);
315 pcmRot.setZ(-px * sinth + pz * cosTh);
316 theNeutron.SetMomentum(pcmRot);
317 G4double eN = std::sqrt(pN * pN + mN * mN); // Scattered neutron energy
318 theNeutron.SetTotalEnergy(eN);
319
320 // Get the scattered target momentum
321 G4ReactionProduct toLab(-1. * theTarget);
322 theTarget.SetMomentum(pDir * Pinit - pcmRot);
323 G4double eT = Einit - eN + mT;
324 theTarget.SetTotalEnergy(eT);
325
326 // Now back to lab frame
327 theNeutron.Lorentz(theNeutron, toLab);
328 theTarget.Lorentz(theTarget, toLab);
329
330 // 111005 Protection for not producing 0 kinetic energy target
331 if (theNeutron.GetKineticEnergy() <= 0)
332 theNeutron.SetTotalEnergy(theNeutron.GetMass()
333 * (1. + G4Pow::GetInstance()->powA(10, -15.65)));
334 if (theTarget.GetKineticEnergy() <= 0)
335 theTarget.SetTotalEnergy(theTarget.GetMass() * (1. + G4Pow::GetInstance()->powA(10, -15.65)));
336 }
337 else if (frameFlag == 2) {
338 // Projectile scattering values cosTh taken from center of mass tabulation
339
340 G4LorentzVector proj(nEnergy, the3Neutron);
341 G4LorentzVector targ(tEnergy, the3Target);
342 G4ThreeVector boostToCM = proj.findBoostToCM(targ);
343 proj.boost(boostToCM);
344 targ.boost(boostToCM);
345
346 // Rotate projectile and target momenta by CM scattering angle
347 // Note: at this point collision axis is not along z axis, due to
348 // momentum given target nucleus by thermal process
349 G4double px = proj.px();
350 G4double py = proj.py();
351 G4double pz = proj.pz();
352
353 G4ThreeVector pcmRot;
354 pcmRot.setX(px * cosTh * cosPhi - py * sinPhi + pz * sinth * cosPhi);
355 pcmRot.setY(px * cosTh * sinPhi + py * cosPhi + pz * sinth * sinPhi);
356 pcmRot.setZ(-px * sinth + pz * cosTh);
357 proj.setVect(pcmRot);
358 targ.setVect(-pcmRot);
359
360 // Back to lab frame
361 proj.boost(-boostToCM);
362 targ.boost(-boostToCM);
363
364 theNeutron.SetMomentum(proj.vect());
365 theNeutron.SetTotalEnergy(proj.e());
366
367 theTarget.SetMomentum(targ.vect());
368 theTarget.SetTotalEnergy(targ.e());
369
370 // 080904 Add Protection for very low energy (1e-6eV) scattering
371 if (theNeutron.GetKineticEnergy() <= 0) {
372 theNeutron.SetTotalEnergy(theNeutron.GetMass()
373 * (1. + G4Pow::GetInstance()->powA(10, -15.65)));
374 }
375
376 // 080904 Add Protection for very low energy (1e-6eV) scattering
377 if (theTarget.GetKineticEnergy() <= 0) {
378 theTarget.SetTotalEnergy(theTarget.GetMass() * (1. + G4Pow::GetInstance()->powA(10, -15.65)));
379 }
380 }
381 else {
382 G4cout << "Value of frameFlag (1=LAB, 2=CMS): " << frameFlag;
383 throw G4HadronicException(__FILE__, __LINE__,
384 "G4ParticleHPElasticFS::ApplyYourSelf frameflag incorrect");
385 }
386
387 // Everything is now in the lab frame
388 // Set energy change and momentum change
389 theResult.Get()->SetEnergyChange(theNeutron.GetKineticEnergy());
390 theResult.Get()->SetMomentumChange(theNeutron.GetMomentum().unit());
391
392 // Make recoil a G4DynamicParticle
393 auto theRecoil = new G4DynamicParticle;
394 theRecoil->SetDefinition(G4IonTable::GetIonTable()->GetIon(static_cast<G4int>(theBaseZ),
395 static_cast<G4int>(theBaseA), 0));
396 theRecoil->SetMomentum(theTarget.GetMomentum());
397 theResult.Get()->AddSecondary(theRecoil, secID);
398
399 // Postpone the tracking of the primary neutron
401 return theResult.Get();
402}
@ suspend
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition Randomize.hh:52
double x() const
void setY(double)
void setZ(double)
void setX(double)
Hep3Vector vect() const
value_type & Get() const
Definition G4Cache.hh:315
void Put(const value_type &val) const
Definition G4Cache.hh:321
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetStatusChange(G4HadFinalStateStatus aS)
void AddSecondary(G4DynamicParticle *aP, G4int mod=-1)
void SetEnergyChange(G4double anEnergy)
void SetMomentumChange(const G4ThreeVector &aV)
const G4Material * GetMaterial() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
static G4IonTable * GetIonTable()
G4double GetTemperature() const
G4Cache< G4HadFinalState * > theResult
G4double SampleElastic(G4double anEnergy)
G4double Sample(G4double x)
static G4Pow * GetInstance()
Definition G4Pow.cc:41
G4double powA(G4double A, G4double y) const
Definition G4Pow.hh:230
void SetMomentum(const G4double x, const G4double y, const G4double z)
void SetTotalEnergy(const G4double en)
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
G4ThreeVector GetMomentum() const
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
G4double GetMass() const
void SetMass(const G4double mas)

◆ Init()

void G4ParticleHPElasticFS::Init ( G4double A,
G4double Z,
G4int M,
G4String & dirName,
G4String & aFSType,
G4ParticleDefinition *  )
overridevirtual

Implements G4ParticleHPFinalState.

Definition at line 79 of file G4ParticleHPElasticFS.cc.

82{
83 G4String tString = "/FS";
84 G4bool dbool = true;
85 SetA_Z(A, Z, M);
87 theNames.GetName(theBaseA, theBaseZ, M, dirName, tString, dbool);
88 G4String filename = aFile.GetName();
89 SetAZMs(aFile);
90 if (!dbool) {
91 hasAnyData = false;
92 hasFSData = false;
93 hasXsec = false;
94 return;
95 }
96
97 // 130205 For compressed data files
98 std::istringstream theData(std::ios::in);
100 // 130205 END
101 theData >> repFlag >> targetMass >> frameFlag;
102
103 if (repFlag == 1) {
104 G4int nEnergy;
105 theData >> nEnergy;
106 theCoefficients = new G4ParticleHPLegendreStore(nEnergy);
107 theCoefficients->InitInterpolation(theData);
108 G4double temp, energy;
109 G4int tempdep, nLegendre;
110 G4int i, ii;
111 for (i = 0; i < nEnergy; i++) {
112 theData >> temp >> energy >> tempdep >> nLegendre;
113 energy *= eV;
114 theCoefficients->Init(i, energy, nLegendre);
115 theCoefficients->SetTemperature(i, temp);
116 G4double coeff = 0;
117 for (ii = 0; ii < nLegendre; ii++) {
118 // load legendre coefficients.
119 theData >> coeff;
120 theCoefficients->SetCoeff(i, ii + 1, coeff); // @@@HPW@@@
121 }
122 }
123 }
124 else if (repFlag == 2) {
125 G4int nEnergy;
126 theData >> nEnergy;
127 theProbArray = new G4ParticleHPPartial(nEnergy, nEnergy);
128 theProbArray->InitInterpolation(theData);
129 G4double temp, energy;
130 G4int tempdep, nPoints;
131 for (G4int i = 0; i < nEnergy; i++) {
132 theData >> temp >> energy >> tempdep >> nPoints;
133 energy *= eV;
134 theProbArray->InitInterpolation(i, theData);
135 theProbArray->SetT(i, temp);
136 theProbArray->SetX(i, energy);
137 G4double prob, costh;
138 for (G4int ii = 0; ii < nPoints; ii++) {
139 // fill probability arrays.
140 theData >> costh >> prob;
141 theProbArray->SetX(i, ii, costh);
142 theProbArray->SetY(i, ii, prob);
143 }
144 theProbArray->DoneSetXY(i);
145 }
146 }
147 else if (repFlag == 3) {
148 G4int nEnergy_Legendre;
149 theData >> nEnergy_Legendre;
150 if (nEnergy_Legendre <= 0) {
151 std::stringstream iss;
152 iss << "G4ParticleHPElasticFS::Init Data Error repFlag is 3 but nEnergy_Legendre <= 0";
153 iss << "Z, A and M of problematic file is " << theNDLDataZ << ", " << theNDLDataA << " and "
154 << theNDLDataM << " respectively.";
155 throw G4HadronicException(__FILE__, __LINE__, iss.str());
156 }
157 theCoefficients = new G4ParticleHPLegendreStore(nEnergy_Legendre);
158 theCoefficients->InitInterpolation(theData);
159 G4double temp, energy;
160 G4int tempdep, nLegendre;
161
162 for (G4int i = 0; i < nEnergy_Legendre; i++) {
163 theData >> temp >> energy >> tempdep >> nLegendre;
164 energy *= eV;
165 theCoefficients->Init(i, energy, nLegendre);
166 theCoefficients->SetTemperature(i, temp);
167 G4double coeff = 0;
168 for (G4int ii = 0; ii < nLegendre; ii++) {
169 // load legendre coefficients.
170 theData >> coeff;
171 theCoefficients->SetCoeff(i, ii + 1, coeff); // @@@HPW@@@
172 }
173 }
174
175 tE_of_repFlag3 = energy;
176
177 G4int nEnergy_Prob;
178 theData >> nEnergy_Prob;
179 theProbArray = new G4ParticleHPPartial(nEnergy_Prob, nEnergy_Prob);
180 theProbArray->InitInterpolation(theData);
181 G4int nPoints;
182 for (G4int i = 0; i < nEnergy_Prob; i++) {
183 theData >> temp >> energy >> tempdep >> nPoints;
184 energy *= eV;
185
186 // consistency check
187 if (i == 0)
188 // if ( energy != tE_of_repFlag3 ) //110620TK This is too tight for 32bit machines
189 if (std::abs(energy - tE_of_repFlag3) / tE_of_repFlag3 > 1.0e-15)
190 G4cout << "Warning Transition Energy of repFlag3 is not consistent." << G4endl;
191
192 theProbArray->InitInterpolation(i, theData);
193 theProbArray->SetT(i, temp);
194 theProbArray->SetX(i, energy);
195 G4double prob, costh;
196 for (G4int ii = 0; ii < nPoints; ii++) {
197 // fill probability arrays.
198 theData >> costh >> prob;
199 theProbArray->SetX(i, ii, costh);
200 theProbArray->SetY(i, ii, prob);
201 }
202 theProbArray->DoneSetXY(i);
203 }
204 }
205 else if (repFlag == 0) {
206 theData >> frameFlag;
207 }
208 else {
209 G4cout << "unusable number for repFlag: repFlag=" << repFlag << G4endl;
210 throw G4HadronicException(__FILE__, __LINE__,
211 "G4ParticleHPElasticFS::Init -- unusable number for repFlag");
212 }
213 // 130205 For compressed data files(theData changed from ifstream to istringstream)
214 // theData.close();
215}
#define M(row, col)
bool G4bool
Definition G4Types.hh:86
const G4double A[17]
void SetA_Z(G4double anA, G4double aZ, G4int aM=0)
void SetAZMs(G4ParticleHPDataUsed used)
void SetCoeff(G4int i, G4int l, G4double coeff)
void Init(G4int i, G4double e, G4int n)
void SetTemperature(G4int i, G4double temp)
void InitInterpolation(std::istream &aDataFile)
void GetDataStream(const G4String &, std::istringstream &iss)
static G4ParticleHPManager * GetInstance()
G4ParticleHPDataUsed GetName(G4int A, G4int Z, const G4String &base, const G4String &rest, G4bool &active)
void SetT(G4int i, G4double x)
void SetX(G4int i, G4double x)
void SetY(G4int i, G4int j, G4double y)
void InitInterpolation(G4int i, std::istream &aDataFile)
G4double energy(const ThreeVector &p, const G4double m)

◆ New()

G4ParticleHPFinalState * G4ParticleHPElasticFS::New ( )
inlineoverridevirtual

Implements G4ParticleHPFinalState.

Definition at line 60 of file G4ParticleHPElasticFS.hh.

61 {
62 auto theNew = new G4ParticleHPElasticFS;
63 return theNew;
64 }

◆ RegisterCrossSection()

void G4ParticleHPElasticFS::RegisterCrossSection ( G4ParticleHPVector * vec)
inline

Definition at line 67 of file G4ParticleHPElasticFS.hh.

67{ xsForDBRC = vec; }

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