File indexing completed on 2025-02-23 09:22:15
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 #include "MyKleinNishinaCompton.hh"
0034
0035 #include "DetectorConstruction.hh"
0036 #include "MyKleinNishinaMessenger.hh"
0037
0038 #include "G4DataVector.hh"
0039 #include "G4Electron.hh"
0040 #include "G4Gamma.hh"
0041 #include "G4ParticleChangeForGamma.hh"
0042 #include "G4PhysicalConstants.hh"
0043 #include "Randomize.hh"
0044
0045
0046
0047 using namespace std;
0048
0049 MyKleinNishinaCompton::MyKleinNishinaCompton(DetectorConstruction* det, const G4ParticleDefinition*,
0050 const G4String& nam)
0051 : G4KleinNishinaCompton(0, nam), fDetector(det), fMessenger(0)
0052 {
0053 fCrossSectionFactor = 1.;
0054 fMessenger = new MyKleinNishinaMessenger(this);
0055 }
0056
0057
0058
0059 MyKleinNishinaCompton::~MyKleinNishinaCompton()
0060 {
0061 delete fMessenger;
0062 }
0063
0064
0065
0066 G4double MyKleinNishinaCompton::CrossSectionPerVolume(const G4Material* mat,
0067 const G4ParticleDefinition* part,
0068 G4double GammaEnergy, G4double, G4double)
0069 {
0070 G4double xsection = G4VEmModel::CrossSectionPerVolume(mat, part, GammaEnergy);
0071
0072 return xsection * fCrossSectionFactor;
0073 }
0074
0075
0076 void MyKleinNishinaCompton::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect,
0077 const G4MaterialCutsCouple*,
0078 const G4DynamicParticle* aDynamicGamma, G4double,
0079 G4double)
0080 {
0081
0082
0083
0084
0085
0086 G4double gamEnergy0 = aDynamicGamma->GetKineticEnergy();
0087 G4double E0_m = gamEnergy0 / electron_mass_c2;
0088
0089 G4ThreeVector gamDirection0 = aDynamicGamma->GetMomentumDirection();
0090
0091
0092
0093
0094
0095 G4double epsilon, epsilonsq, onecost, sint2, greject;
0096
0097 G4double eps0 = 1. / (1. + 2. * E0_m);
0098 G4double eps0sq = eps0 * eps0;
0099 G4double alpha1 = -log(eps0);
0100 G4double alpha2 = 0.5 * (1. - eps0sq);
0101
0102 do {
0103 if (alpha1 / (alpha1 + alpha2) > G4UniformRand()) {
0104 epsilon = exp(-alpha1 * G4UniformRand());
0105 epsilonsq = epsilon * epsilon;
0106 }
0107 else {
0108 epsilonsq = eps0sq + (1. - eps0sq) * G4UniformRand();
0109 epsilon = sqrt(epsilonsq);
0110 };
0111
0112 onecost = (1. - epsilon) / (epsilon * E0_m);
0113 sint2 = onecost * (2. - onecost);
0114 greject = 1. - epsilon * sint2 / (1. + epsilonsq);
0115
0116 } while (greject < G4UniformRand());
0117
0118
0119
0120
0121
0122 G4double cosTeta = 1. - onecost;
0123 G4double sinTeta = sqrt(sint2);
0124 G4double Phi = twopi * G4UniformRand();
0125 G4double dirx = sinTeta * cos(Phi), diry = sinTeta * sin(Phi), dirz = cosTeta;
0126
0127
0128
0129
0130
0131
0132 G4ThreeVector gamDirection1(dirx, diry, dirz);
0133 gamDirection1.rotateUz(gamDirection0);
0134 G4double gamEnergy1 = epsilon * gamEnergy0;
0135 fParticleChange->SetProposedKineticEnergy(gamEnergy0);
0136 fParticleChange->ProposeMomentumDirection(gamDirection0);
0137
0138
0139
0140
0141
0142 G4double eKinEnergy = gamEnergy0 - gamEnergy1;
0143
0144 if (eKinEnergy > DBL_MIN) {
0145 G4ThreeVector eDirection = gamEnergy0 * gamDirection0 - gamEnergy1 * gamDirection1;
0146 eDirection = eDirection.unit();
0147
0148
0149 G4DynamicParticle* dp = new G4DynamicParticle(theElectron, eDirection, eKinEnergy);
0150 fvect->push_back(dp);
0151 }
0152 }
0153
0154