File indexing completed on 2025-01-31 09:22:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 #include "G4RDGenerator2BS.hh"
0056 #include "Randomize.hh"
0057 #include "G4PhysicalConstants.hh"
0058
0059
0060 G4RDGenerator2BS::G4RDGenerator2BS(const G4String& name):G4RDVBremAngularDistribution(name)
0061 {;}
0062
0063
0064
0065 G4RDGenerator2BS::~G4RDGenerator2BS()
0066 {;}
0067
0068
0069
0070 G4double G4RDGenerator2BS::PolarAngle(const G4double initial_energy,
0071 const G4double final_energy,
0072 const G4int Z)
0073 {
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 G4double theta = 0;
0084
0085 G4double initialTotalEnergy = (initial_energy+electron_mass_c2)/electron_mass_c2;
0086 G4double finalTotalEnergy = (final_energy+electron_mass_c2)/electron_mass_c2;
0087 EnergyRatio = finalTotalEnergy/initialTotalEnergy;
0088 G4double gMaxEnergy = (pi*initialTotalEnergy)*(pi*initialTotalEnergy);
0089
0090 G4double Zeff = std::sqrt(static_cast<G4double>(Z) * (static_cast<G4double>(Z) + 1.0));
0091 z = (0.00008116224*(std::pow(Zeff,0.3333333)));
0092
0093
0094 rejection_argument1 = (1.0+EnergyRatio*EnergyRatio);
0095 rejection_argument2 = - 2.0*EnergyRatio + 3.0*rejection_argument1;
0096 rejection_argument3 = ((1-EnergyRatio)/(2.0*initialTotalEnergy*EnergyRatio))*
0097 ((1-EnergyRatio)/(2.0*initialTotalEnergy*EnergyRatio));
0098
0099
0100 G4double gfunction0 = RejectionFunction(0);
0101 G4double gfunction1 = RejectionFunction(1);
0102 G4double gfunctionEmax = RejectionFunction(gMaxEnergy);
0103
0104
0105
0106 G4double gMaximum = std::max(gfunction0,gfunction1);
0107 gMaximum = std::max(gMaximum,gfunctionEmax);
0108
0109 G4double rand, gfunctionTest, randTest;
0110
0111 do{
0112 rand = G4UniformRand();
0113 rand = rand/(1-rand+1.0/gMaxEnergy);
0114 gfunctionTest = RejectionFunction(rand);
0115 randTest = G4UniformRand();
0116
0117 }while(randTest > (gfunctionTest/gMaximum));
0118
0119 theta = std::sqrt(rand)/initialTotalEnergy;
0120
0121
0122 return theta;
0123 }
0124
0125
0126 G4double G4RDGenerator2BS::RejectionFunction(G4double value) const
0127 {
0128
0129 G4double argument = (1+value)*(1+value);
0130
0131 G4double gfunction = (4+std::log(rejection_argument3+(z/argument)))*
0132 ((4*EnergyRatio*value/argument)-rejection_argument1)+rejection_argument2;
0133
0134 return gfunction;
0135
0136 }
0137
0138 void G4RDGenerator2BS::PrintGeneratorInformation() const
0139 {
0140 G4cout << "\n" << G4endl;
0141 G4cout << "Bremsstrahlung Angular Generator is 2BS Generator from 2BS Koch & Motz distribution (Rev Mod Phys 31(4), 920 (1959))" << G4endl;
0142 G4cout << "Sampling algorithm adapted from PIRS-0203" << G4endl;
0143 G4cout << "\n" << G4endl;
0144 }
0145