Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4DeltaAngle Class Reference

#include <G4DeltaAngle.hh>

Inheritance diagram for G4DeltaAngle:
Collaboration diagram for G4DeltaAngle:

Public Member Functions

 G4DeltaAngle (const G4String &name="")
 
virtual ~G4DeltaAngle ()
 
virtual G4ThreeVectorSampleDirection (const G4DynamicParticle *dp, G4double kinEnergyFinal, G4int Z, const G4Material *mat=nullptr) final
 
virtual G4ThreeVectorSampleDirectionForShell (const G4DynamicParticle *dp, G4double kinEnergyFinal, G4int Z, G4int shellIdx, const G4Material *mat=nullptr) final
 
virtual void PrintGeneratorInformation () const final
 
- Public Member Functions inherited from G4VEmAngularDistribution
 G4VEmAngularDistribution (const G4String &name)
 
virtual ~G4VEmAngularDistribution ()
 
const G4StringGetName () const
 

Additional Inherited Members

- Protected Attributes inherited from G4VEmAngularDistribution
G4ThreeVector fLocalDirection
 

Detailed Description

Definition at line 57 of file G4DeltaAngle.hh.

Constructor & Destructor Documentation

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

Definition at line 61 of file G4DeltaAngle.cc.

62  : G4VEmAngularDistribution("deltaVI")
63 {
64  fElectron = G4Electron::Electron();
65  nprob = 26;
66  prob.resize(nprob,0.0);
67  fShellIdx = -1;
68 }
G4VEmAngularDistribution(const G4String &name)
static G4Electron * Electron()
Definition: G4Electron.cc:94

Here is the call graph for this function:

G4DeltaAngle::~G4DeltaAngle ( )
virtual

Definition at line 70 of file G4DeltaAngle.cc.

71 {}

Member Function Documentation

void G4DeltaAngle::PrintGeneratorInformation ( ) const
finalvirtual

Definition at line 196 of file G4DeltaAngle.cc.

197 {}
G4ThreeVector & G4DeltaAngle::SampleDirection ( const G4DynamicParticle dp,
G4double  kinEnergyFinal,
G4int  Z,
const G4Material mat = nullptr 
)
finalvirtual

Implements G4VEmAngularDistribution.

Definition at line 83 of file G4DeltaAngle.cc.

86 {
88  G4int idx = fShellIdx;
89 
90  // if idx is not properly defined sample shell index
91  if(idx < 0 || idx >= nShells) {
92  if(nShells> nprob) {
93  nprob = nShells;
94  prob.resize(nprob,0.0);
95  }
96  G4double sum = 0.0;
97  for(idx=0; idx<nShells; ++idx) {
100  prob[idx] = sum;
101  }
102  sum *= G4UniformRand();
103  for(idx=0; idx<nShells; ++idx) {
104  if(sum <= prob[idx]) { break; }
105  }
106  }
108  G4double cost;
109  /*
110  G4cout << "E(keV)= " << kinEnergyFinal/keV
111  << " Ebind(keV)= " << bindingEnergy
112  << " idx= " << idx << " nShells= " << nShells << G4endl;
113  */
114  G4int n = 0;
115  G4bool isOK = false;
116  static const G4int nmax = 100;
117  do {
118  ++n;
119  // the atomic electron
120  G4double x = -G4Log(G4UniformRand());
121  G4double eKinEnergy = bindingEnergy*x;
122  G4double ePotEnergy = bindingEnergy*(1.0 + x);
123  G4double e = kinEnergyFinal + ePotEnergy + electron_mass_c2;
124  G4double p = sqrt((e + electron_mass_c2)*(e - electron_mass_c2));
125 
126  G4double totEnergy = dp->GetTotalEnergy();
127  G4double totMomentum = dp->GetTotalMomentum();
128  if(dp->GetParticleDefinition() == fElectron) {
129  totEnergy += ePotEnergy;
130  totMomentum = sqrt((totEnergy + electron_mass_c2)
131  *(totEnergy - electron_mass_c2));
132  }
133 
134  G4double eTotEnergy = eKinEnergy + electron_mass_c2;
135  G4double eTotMomentum = sqrt(eKinEnergy*(eTotEnergy + electron_mass_c2));
136  G4double costet = 2*G4UniformRand() - 1;
137  G4double sintet = sqrt((1 - costet)*(1 + costet));
138 
139  cost = 1.0;
140  if(n >= nmax) {
141  /*
142  G4ExceptionDescription ed;
143  ed << "### G4DeltaAngle Warning: " << n
144  << " iterations - stop the loop with cost= 1.0 "
145  << " for " << dp->GetDefinition()->GetParticleName() << "\n"
146  << " Ekin(MeV)= " << dp->GetKineticEnergy()/MeV
147  << " Efinal(MeV)= " << kinEnergyFinal/MeV
148  << " Ebinding(MeV)= " << bindingEnergy/MeV;
149  G4Exception("G4DeltaAngle::SampleDirection","em0044",
150  JustWarning, ed,"");
151  */
152  if(0.0 == bindingEnergy) { isOK = true; }
153  bindingEnergy = 0.0;
154  }
155 
156  G4double x0 = p*(totMomentum + eTotMomentum*costet);
157  /*
158  G4cout << " x0= " << x0 << " p= " << p
159  << " ptot= " << totMomentum << " pe= " << eTotMomentum
160  << " e= " << e << " totMom= " << totMomentum
161  << G4endl;
162  */
163  if(x0 > 0.0) {
164  G4double x1 = p*eTotMomentum*sintet;
165  G4double x2 = totEnergy*(eTotEnergy - e) - e*eTotEnergy
166  - totMomentum*eTotMomentum*costet + electron_mass_c2*electron_mass_c2;
167  G4double y = -x2/x0;
168  if(std::abs(y) <= 1.0) {
169  cost = -(x2 + x1*sqrt(1. - y*y))/x0;
170  if(std::abs(cost) <= 1.0) { isOK = true; }
171  else { cost = 1.0; }
172  }
173 
174  /*
175  G4cout << " Ekin(MeV)= " << dp->GetKineticEnergy()
176  << " e1(keV)= " << eKinEnergy/keV
177  << " e2(keV)= " << (e - electron_mass_c2)/keV
178  << " 1-cost= " << 1-cost
179  << " x0= " << x0 << " x1= " << x1 << " x2= " << x2
180  << G4endl;
181  */
182  }
183 
184  // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
185  } while(!isOK);
186 
187  G4double sint = sqrt((1 - cost)*(1 + cost));
188  G4double phi = twopi*G4UniformRand();
189 
190  fLocalDirection.set(sint*cos(phi), sint*sin(phi), cost);
192 
193  return fLocalDirection;
194 }
void set(double x, double y, double z)
G4double GetTotalEnergy() const
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
static constexpr double twopi
Definition: G4SIunits.hh:76
static constexpr double electron_mass_c2
G4double GetTotalMomentum() const
#define G4UniformRand()
Definition: Randomize.hh:97
bool G4bool
Definition: G4Types.hh:79
static G4double GetBindingEnergy(G4int Z, G4int SubshellNb)
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:38
const G4ParticleDefinition * GetParticleDefinition() const
G4double G4Log(G4double x)
Definition: G4Log.hh:230
static G4int GetNumberOfElectrons(G4int Z, G4int SubshellNb)
double G4double
Definition: G4Types.hh:76
G4double bindingEnergy(G4int A, G4int Z)
static G4int GetNumberOfShells(G4int Z)

Here is the call graph for this function:

Here is the caller graph for this function:

G4ThreeVector & G4DeltaAngle::SampleDirectionForShell ( const G4DynamicParticle dp,
G4double  kinEnergyFinal,
G4int  Z,
G4int  shellIdx,
const G4Material mat = nullptr 
)
finalvirtual

Reimplemented from G4VEmAngularDistribution.

Definition at line 74 of file G4DeltaAngle.cc.

77 {
78  fShellIdx = idx;
79  return SampleDirection(dp, kinEnergyFinal,Z, mat);
80 }
virtual G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double kinEnergyFinal, G4int Z, const G4Material *mat=nullptr) final
Definition: G4DeltaAngle.cc:83

Here is the call graph for this function:


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