63{
64 const G4double PositronMass = CLHEP::electron_mass_c2;
67
68 CLHEP::HepRandomEngine* rndmEngine = G4Random::getTheEngine();
69
70
71
72
73 G4int mPos =
static_cast<G4int>(std::floor(3.0 * rndmEngine->
flat()) - 1.0);
74
76
77
78
80
81 if (mPos == 0) {
82 uz = 1.;
83 uy = 0.;
84 ux = 0.;
85 }
86 else if (mPos == 1) {
87 uz = 0.;
88 uy = iComplex / sq2;
89 ux = 1. / sq2;
90 }
91 else if (mPos == -1) {
92 uz = 0.;
93 uy = -iComplex / sq2;
94 ux = 1. / sq2;
95 }
96
100
103
106
107
109
110 do {
111 rndmv1 = rndmEngine->
flat();
112
113 do {
115
116 r1 = rndmv2[0];
117 r2 = rndmv2[1];
118
119
120 r3 = 2.0 - (r1 + r2);
121
122 cos12 = (r3 * r3 - r1 * r1 - r2 * r2) / (2 * r1 * r2);
123 cos13 = (r2 * r2 - r1 * r1 - r3 * r3) / (2 * r1 * r3);
124
125 } while (std::abs(cos12) > 1 || std::abs(cos13) > 1);
126
127 G4double sin12 = std::sqrt((1 + cos12)*(1 - cos12));
128 G4double sin13 = -std::sqrt((1 + cos13)*(1 - cos13));
129
130
131 PhotonDir1 = {0., 0., 1.};
132 PhotonDir2 = {0., sin12, cos12};
133 PhotonDir3 = {0., sin13, cos13};
134
135
136
137
141
143
144
146 PhotonPol1 = std::cos(eta1) * PhotonPerp1 + std::sin(eta1) * xDir;
147
149 PhotonPol2 = std::cos(eta2) * PhotonPerp2 + std::sin(eta2) * xDir;
150
152 PhotonPol3 = std::cos(eta3) * PhotonPerp3 + std::sin(eta3) * xDir;
153
154
158
159
161 + PhotonPol1 * (PhotonPrime2.
dot(PhotonPrime3))
162 - PhotonPrime2 * (PhotonPrime3.
dot(PhotonPol1))
163 - PhotonPrime3 * (PhotonPol1.
dot(PhotonPrime2)));
165 + PhotonPol2 * (PhotonPrime3.
dot(PhotonPrime1))
166 - PhotonPrime3 * (PhotonPrime1.
dot(PhotonPol2))
167 - PhotonPrime1 * (PhotonPol2.
dot(PhotonPrime3)));
169 + PhotonPol3 * (PhotonPrime1.
dot(PhotonPrime2))
170 - PhotonPrime1 * (PhotonPrime2.
dot(PhotonPol3))
171 - PhotonPrime2 * (PhotonPol3.
dot(PhotonPrime1)));
172
173
174
179
181
182
183
186
187 G4complex H = t(0) * ux + t(1) * uy + t(2) * uz;
188 pdf = std::abs(conj(H) * H);
189 } while (pdf < ymax * rndmv1);
190
191
195
199
200 auto aGamma1 =
new G4DynamicParticle(
G4Gamma::Gamma(), PhotonDir1, r1 * PositronMass);
201 aGamma1->SetPolarization(PhotonPol1);
202 secParticles.push_back(aGamma1);
203
204 auto aGamma2 =
new G4DynamicParticle(
G4Gamma::Gamma(), PhotonDir2, r2 * PositronMass);
205 aGamma2->SetPolarization(PhotonPol2);
206 secParticles.push_back(aGamma2);
207
208 auto aGamma3 =
new G4DynamicParticle(
G4Gamma::Gamma(), PhotonDir3, r3 * PositronMass);
209 aGamma3->SetPolarization(PhotonPol3);
210 secParticles.push_back(aGamma3);
211}
G4ThreeVector G4RandomDirection()
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
std::complex< G4double > G4complex
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
Hep3Vector & transform(const HepRotation &)
virtual void flatArray(const int size, double *vect)=0