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

#include <G4Generator2BS.hh>

+ Inheritance diagram for G4Generator2BS:

Public Member Functions

 G4Generator2BS (const G4String &name="")
 
virtual ~G4Generator2BS ()
 
virtual G4ThreeVectorSampleDirection (const G4DynamicParticle *dp, G4double out_energy, G4int Z, const G4Material *mat=nullptr)
 
void PrintGeneratorInformation () const
 
- Public Member Functions inherited from G4VEmAngularDistribution
 G4VEmAngularDistribution (const G4String &name)
 
virtual ~G4VEmAngularDistribution ()
 
virtual G4ThreeVectorSampleDirection (const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, const G4Material *)=0
 
virtual G4ThreeVectorSampleDirectionForShell (const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, G4int shellID, const G4Material *)
 
virtual void SamplePairDirections (const G4DynamicParticle *dp, G4double elecKinEnergy, G4double posiKinEnergy, G4ThreeVector &dirElectron, G4ThreeVector &dirPositron, G4int Z=0, const G4Material *mat=nullptr)
 
const G4StringGetName () const
 
G4VEmAngularDistributionoperator= (const G4VEmAngularDistribution &right)=delete
 
 G4VEmAngularDistribution (const G4VEmAngularDistribution &)=delete
 

Protected Member Functions

G4double RejectionFunction (G4double value) const
 

Additional Inherited Members

- Protected Attributes inherited from G4VEmAngularDistribution
G4ThreeVector fLocalDirection
 
G4bool fPolarisation
 

Detailed Description

Definition at line 64 of file G4Generator2BS.hh.

Constructor & Destructor Documentation

◆ G4Generator2BS()

G4Generator2BS::G4Generator2BS ( const G4String name = "")
explicit

Definition at line 63 of file G4Generator2BS.cc.

64 : G4VEmAngularDistribution("AngularGen2BS"),fz(1),ratio(1),
65 ratio1(1),ratio2(1),delta(0)
66{
67 g4pow = G4Pow::GetInstance();
68 nwarn = 0;
69}
static G4Pow * GetInstance()
Definition: G4Pow.cc:41

◆ ~G4Generator2BS()

G4Generator2BS::~G4Generator2BS ( )
virtual

Definition at line 71 of file G4Generator2BS.cc.

72{}

Member Function Documentation

◆ PrintGeneratorInformation()

void G4Generator2BS::PrintGeneratorInformation ( ) const

Definition at line 136 of file G4Generator2BS.cc.

137{
138 G4cout << "\n" << G4endl;
139 G4cout << "Bremsstrahlung Angular Generator is 2BS Generator "
140 << "from 2BS Koch & Motz distribution (Rev Mod Phys 31(4), 920 (1959))" << G4endl;
141 G4cout << "Sampling algorithm adapted from PIRS-0203" << G4endl;
142 G4cout << "\n" << G4endl;
143}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

◆ RejectionFunction()

G4double G4Generator2BS::RejectionFunction ( G4double  value) const
inlineprotected

Definition at line 101 of file G4Generator2BS.hh.

102{
103 G4double y2 = (1 + y)*(1 + y);
104 G4double x = 4*y*ratio/y2;
105 return 4*x - ratio1 - (ratio2 - x)*G4Log(delta + fz/y2);
106}
G4double G4Log(G4double x)
Definition: G4Log.hh:226
double G4double
Definition: G4Types.hh:83

Referenced by SampleDirection().

◆ SampleDirection()

G4ThreeVector & G4Generator2BS::SampleDirection ( const G4DynamicParticle dp,
G4double  out_energy,
G4int  Z,
const G4Material mat = nullptr 
)
virtual

Implements G4VEmAngularDistribution.

Definition at line 74 of file G4Generator2BS.cc.

78{
79
80 // Adapted from "Improved bremsstrahlung photon angular sampling in the EGS4 code system"
81 // by Alex F. Bielajew, Rahde Mohan anc Chen-Shou Chui, PIRS-0203
82 // Ionizing Radiation Standards
83 // Institute for National Measurement Standards
84 // National Research Council of Canada
85 // Departement of Medical Physics, Memorial Sloan-Kettering Cancer Center, New York
86
88 ratio = final_energy/energy;
89 ratio1 = (1 + ratio)*(1 + ratio);
90 ratio2 = 1 + ratio*ratio;
91
92 G4double gamma = energy/electron_mass_c2;
93 G4double beta = std::sqrt((gamma - 1)*(gamma + 1))/gamma;
94
95 // VI speadup
96 fz = 0.00008116224*g4pow->Z13(Z)*g4pow->Z13(Z+1);
97
98 // majoranta
99 G4double ymax = 2*beta*(1 + beta)*gamma*gamma;
100 G4double gMax = RejectionFunction(0.0);
101 gMax = std::max(gMax,RejectionFunction(ymax));
102
103 G4double y, gfun;
104
105 do{
107 y = q*ymax/(1 + ymax*(1 - q));
108 gfun = RejectionFunction(y);
109
110 // violation point
111 if(gfun > gMax && nwarn >= 20) {
112 ++nwarn;
113 G4cout << "### WARNING in G4Generator2BS: Etot(MeV)= " << energy/MeV
114 << " Egamma(MeV)" << (energy - final_energy)/MeV
115 << " gMax= " << gMax << " < " << gfun
116 << " results are not reliable!"
117 << G4endl;
118 if(20 == nwarn) {
119 G4cout << " WARNING in G4Generator2BS is closed" << G4endl;
120 }
121 }
122
123 } while(G4UniformRand()*gMax > gfun || y > ymax);
124
125
126 G4double cost = 1 - 2*y/ymax;
127 G4double sint = std::sqrt((1 - cost)*(1 + cost));
128 G4double phi = twopi*G4UniformRand();
129
130 fLocalDirection.set(sint*std::cos(phi), sint*std::sin(phi),cost);
132
133 return fLocalDirection;
134}
#define G4UniformRand()
Definition: Randomize.hh:52
void set(double x, double y, double z)
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:33
const G4ThreeVector & GetMomentumDirection() const
G4double GetTotalEnergy() const
G4double RejectionFunction(G4double value) const
G4double Z13(G4int Z) const
Definition: G4Pow.hh:123
G4double energy(const ThreeVector &p, const G4double m)

Referenced by G4Generator2BN::SampleDirection().


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