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

#include <G4ParticleHPNBodyPhaseSpace.hh>

+ Inheritance diagram for G4ParticleHPNBodyPhaseSpace:

Public Member Functions

 G4ParticleHPNBodyPhaseSpace ()
 
 ~G4ParticleHPNBodyPhaseSpace () override=default
 
void Init (G4double aMass, G4int aCount)
 
void Init (std::istream &aDataFile) override
 
G4ReactionProductSample (G4double anEnergy, G4double massCode, G4double mass) override
 
- Public Member Functions inherited from G4VParticleHPEnergyAngular
 G4VParticleHPEnergyAngular ()
 
virtual ~G4VParticleHPEnergyAngular ()=default
 
void SetProjectileRP (G4ReactionProduct *aIncidentParticleRP)
 
void SetTarget (G4ReactionProduct *aTarget)
 
G4ReactionProductGetTarget () const
 
G4ReactionProductGetProjectileRP () const
 
G4ReactionProductGetCMS ()
 
void SetQValue (G4double aValue)
 
virtual void ClearHistories ()
 
 G4VParticleHPEnergyAngular (G4VParticleHPEnergyAngular &)=delete
 
G4VParticleHPEnergyAngularoperator= (const G4VParticleHPEnergyAngular &right)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from G4VParticleHPEnergyAngular
G4double GetQValue () const
 

Detailed Description

Definition at line 43 of file G4ParticleHPNBodyPhaseSpace.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPNBodyPhaseSpace()

G4ParticleHPNBodyPhaseSpace::G4ParticleHPNBodyPhaseSpace ( )
inline

Definition at line 46 of file G4ParticleHPNBodyPhaseSpace.hh.

47 {
48 theTotalMass = 0.0;
49 theTotalCount = 0;
50 }

◆ ~G4ParticleHPNBodyPhaseSpace()

G4ParticleHPNBodyPhaseSpace::~G4ParticleHPNBodyPhaseSpace ( )
overridedefault

Member Function Documentation

◆ Init() [1/2]

void G4ParticleHPNBodyPhaseSpace::Init ( G4double aMass,
G4int aCount )
inline

Definition at line 54 of file G4ParticleHPNBodyPhaseSpace.hh.

55 {
56 theTotalMass = aMass;
57 theTotalCount = aCount;
58 }

Referenced by G4ParticleHPInelasticBaseFS::BaseApply().

◆ Init() [2/2]

void G4ParticleHPNBodyPhaseSpace::Init ( std::istream & aDataFile)
inlineoverridevirtual

Implements G4VParticleHPEnergyAngular.

Definition at line 60 of file G4ParticleHPNBodyPhaseSpace.hh.

61 {
62 aDataFile >> theTotalMass >> theTotalCount;
63 theTotalMass *= G4Neutron::Neutron()->GetPDGMass();
64 }
static G4Neutron * Neutron()
Definition G4Neutron.cc:101

◆ Sample()

G4ReactionProduct * G4ParticleHPNBodyPhaseSpace::Sample ( G4double anEnergy,
G4double massCode,
G4double mass )
overridevirtual

Implements G4VParticleHPEnergyAngular.

Definition at line 45 of file G4ParticleHPNBodyPhaseSpace.cc.

47{
48 auto result = new G4ReactionProduct;
49 auto Z = static_cast<G4int>(massCode / 1000);
50 auto A = static_cast<G4int>(massCode - 1000 * Z);
51
52 if (massCode == 0) {
53 result->SetDefinition(G4Gamma::Gamma());
54 }
55 else if (A == 0) {
56 result->SetDefinition(G4Electron::Electron());
57 if (Z == 1) result->SetDefinition(G4Positron::Positron());
58 }
59 else if (A == 1) {
60 result->SetDefinition(G4Neutron::Neutron());
61 if (Z == 1) result->SetDefinition(G4Proton::Proton());
62 }
63 else if (A == 2) {
64 result->SetDefinition(G4Deuteron::Deuteron());
65 }
66 else if (A == 3) {
67 result->SetDefinition(G4Triton::Triton());
68 if (Z == 2) result->SetDefinition(G4He3::He3());
69 }
70 else if (A == 4) {
71 result->SetDefinition(G4Alpha::Alpha());
72 if (Z != 2) throw G4HadronicException(__FILE__, __LINE__, "Unknown ion case 1");
73 }
74 else {
75 throw G4HadronicException(__FILE__, __LINE__,
76 "G4ParticleHPNBodyPhaseSpace: Unknown ion case 2");
77 }
78
79 // Get the energy from phase-space distribution
80 // in CMS
81 // P = Cn*std::sqrt(E')*(Emax-E')**(3*n/2-4)
82 G4double maxE = GetEmax(anEnergy, result->GetMass());
83 if (maxE <= 0) {
84 maxE = 1. * CLHEP::eV;
85 }
86 G4double energy = 0.;
87 G4double max(0);
88 if (theTotalCount <= 3) {
89 max = maxE / 2.;
90 }
91 else if (theTotalCount == 4) {
92 max = maxE / 5.;
93 }
94 else if (theTotalCount == 5) {
95 max = maxE / 8.;
96 }
97 else {
99 __FILE__, __LINE__,
100 "NeutronHP Phase-space distribution cannot cope with this number of particles");
101 }
102 G4double testit;
103 G4double rand0 = Prob(max, maxE, theTotalCount);
104 G4double rand;
105
106 G4int icounter = 0;
107 G4int icounter_max = 1024;
108 do {
109 icounter++;
110 if (icounter > icounter_max) {
111 G4cout << "Loop-counter exceeded the threshold value at " << __LINE__ << "th line of "
112 << __FILE__ << "." << G4endl;
113 break;
114 }
115 rand = rand0 * G4UniformRand();
116 energy = maxE * G4UniformRand();
117 testit = Prob(energy, maxE, theTotalCount);
118 } while (rand > testit); // Loop checking, 11.05.2015, T. Koi
119 result->SetKineticEnergy(energy);
120
121 // now do random direction
122 G4double cosTh = 2. * G4UniformRand() - 1.;
123 G4double phi = twopi * G4UniformRand();
124 G4double theta = std::acos(cosTh);
125 G4double sinth = std::sin(theta);
126 G4double mtot = result->GetTotalMomentum();
127 G4ThreeVector tempVector(mtot * sinth * std::cos(phi), mtot * sinth * std::sin(phi),
128 mtot * std::cos(theta));
129 result->SetMomentum(tempVector);
131 result->Lorentz(*result, -1. * aCMS);
132 return result;
133}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
const G4double A[17]
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition Randomize.hh:52
static G4Alpha * Alpha()
Definition G4Alpha.cc:83
static G4Deuteron * Deuteron()
Definition G4Deuteron.cc:90
static G4Electron * Electron()
Definition G4Electron.cc:91
static G4Gamma * Gamma()
Definition G4Gamma.cc:81
static G4He3 * He3()
Definition G4He3.cc:90
static G4Positron * Positron()
Definition G4Positron.cc:90
static G4Proton * Proton()
Definition G4Proton.cc:90
static G4Triton * Triton()
Definition G4Triton.cc:90
G4ReactionProduct * GetTarget() const
G4ReactionProduct * GetProjectileRP() const
G4double energy(const ThreeVector &p, const G4double m)
T max(const T t1, const T t2)
brief Return the largest of the two arguments

Referenced by G4ParticleHPInelasticBaseFS::BaseApply().


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