9 #include "Pythia8/GammaKinematics.h"
22 bool GammaKinematics::init(Info* infoPtrIn, Settings* settingsPtrIn,
23 Rndm* rndmPtrIn, BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn){
27 settingsPtr = settingsPtrIn;
29 beamAPtr = beamAPtrIn;
30 beamBPtr = beamBPtrIn;
33 bool rejectTheta = settingsPtr->mode(
"Beams:frameType") == 1;
36 Q2maxGamma = settingsPtr->parm(
"Photon:Q2max");
37 Wmin = settingsPtr->parm(
"Photon:Wmin");
38 Wmax = settingsPtr->parm(
"Photon:Wmax");
39 theta1Max = rejectTheta ? settingsPtr->parm(
"Photon:thetaAMax") : -1.0;
40 theta2Max = rejectTheta ? settingsPtr->parm(
"Photon:thetaBMax") : -1.0;
43 gammaMode = settingsPtr->mode(
"Photon:ProcessType");
44 externalFlux = settingsPtr->mode(
"PDF:lepton2gammaSet") == 2;
47 sampleQ2 = settingsPtr->flag(
"Photon:sampleQ2");
50 hasGammaA = beamAPtr->isLepton();
51 hasGammaB = beamBPtr->isLepton();
56 m2BeamA = pow2( beamAPtr->m() );
57 m2BeamB = pow2( beamBPtr->m() );
61 eCM2A = 0.25 * pow2( sCM + m2BeamA - m2BeamB ) / sCM;
62 eCM2B = 0.25 * pow2( sCM - m2BeamA + m2BeamB ) / sCM;
65 m2eA = m2BeamA / eCM2A;
66 m2eB = m2BeamB / eCM2B;
69 xGammaMax1 = 2. * ( 1. - 0.25 * Q2maxGamma / eCM2A - m2eA)
70 / ( 1. + sqrt((1. + 4. * m2BeamA / Q2maxGamma) * (1. - m2eA)) );
71 xGammaMax2 = 2. * ( 1. - 0.25 * Q2maxGamma / eCM2B - m2eB)
72 / ( 1. + sqrt((1. + 4. * m2BeamB / Q2maxGamma) * (1. - m2eB)) );
81 if ( Wmax < Wmin ) Wmax = eCM;
91 bool GammaKinematics::sampleKTgamma(
bool nonDiff){
94 xGamma1 = beamAPtr->xGamma();
95 xGamma2 = beamBPtr->xGamma();
98 gammaMode = infoPtr->photonMode();
101 if ( hasGammaA && (!externalFlux || ( externalFlux
102 && (gammaMode == 3 || gammaMode == 4) ) ) && (xGamma1 > xGammaMax1) )
104 if ( hasGammaB && (!externalFlux || ( externalFlux
105 && (gammaMode == 2 || gammaMode == 4) ) ) && (xGamma2 > xGammaMax2) )
112 if ( externalFlux && (gammaMode == 1 || gammaMode == 2) ) {
113 double xMinA = nonDiff ? -1. : beamAPtr->xGammaHadr();
114 xGamma1 = beamAPtr->sampleXgamma(xMinA);
115 if ( xGamma1 > xGammaMax1 )
return false;
119 Q2min1 = 2. * m2BeamA * pow2(xGamma1) / ( 1. - xGamma1 - m2eA
120 + sqrt(1. - m2eA) * sqrt( pow2(1. - xGamma1) - m2eA ) );
123 if (sampleQ2) Q2gamma1 = beamAPtr->sampleQ2gamma(Q2min1);
127 if ( sampleQ2 && (Q2gamma1 < Q2min1) )
return false;
134 if ( externalFlux && (gammaMode == 1 || gammaMode == 3) ) {
135 double xMinB = nonDiff ? -1. : beamBPtr->xGammaHadr();
136 xGamma2 = beamBPtr->sampleXgamma(xMinB);
137 if ( xGamma2 > xGammaMax2 )
return false;
141 Q2min2 = 2. * m2BeamB * pow2(xGamma2) / ( 1. - xGamma2 - m2eB
142 + sqrt(1. - m2eB) * sqrt( pow2(1. - xGamma2) - m2eB ) );
145 if (sampleQ2) Q2gamma2 = beamBPtr->sampleQ2gamma(Q2min2);
149 if ( sampleQ2 && (Q2gamma2 < Q2min2) )
return false;
154 if ( !deriveKin(xGamma1, Q2gamma1, m2BeamA, eCM2A) )
return false;
161 if ( theta1Max > 0 && ( theta1 > theta1Max ) )
return false;
164 if ( !deriveKin(xGamma2, Q2gamma2, m2BeamB, eCM2B) )
return false;
171 if ( theta2Max > 0 && ( theta2 > theta2Max ) )
return false;
175 if ( hasGammaA && hasGammaB) {
178 double cosPhi12 = cos(phi1 - phi2);
179 m2GmGm = 2. * sqrt(eCM2A * eCM2B) * xGamma1 * xGamma2 - Q2gamma1 - Q2gamma2
180 + 2. * kz1 * kz2 - 2. * kT1 * kT2 * cosPhi12;
183 if ( ( m2GmGm < pow2(Wmin) ) || ( m2GmGm > pow2(Wmax) ) )
return false;
186 mGmGm = sqrt(m2GmGm);
191 }
else if (hasGammaA || hasGammaB) {
195 double pz2 = ( pow2(sCM - m2BeamA - m2BeamB) - 4. * m2BeamA * m2BeamB )
197 double pz = sqrtpos( pz2);
200 double m2Beam = hasGammaA ? m2BeamB : m2BeamA;
201 double xGamma = hasGammaA ? xGamma1 : xGamma2;
202 double Q2gamma = hasGammaA ? Q2gamma1 : Q2gamma2;
205 m2GmGm = m2Beam - Q2gamma + 2. * ( xGamma * sqrt(eCM2A) * sqrt(eCM2B)
207 if ( ( m2GmGm < pow2(Wmin) ) || ( m2GmGm > pow2(Wmax) ) )
return false;
208 mGmGm = sqrt(m2GmGm);
222 bool GammaKinematics::deriveKin(
double xGamma,
double Q2gamma,
223 double m2Beam,
double eCM2) {
226 phi = 2. * M_PI * rndmPtr->flat();
229 double kT2gamma = ( ( 1. - xGamma - 0.25 * Q2gamma / eCM2 ) * Q2gamma
230 - m2Beam * ( Q2gamma / eCM2 + pow2(xGamma) ) ) / (1.- m2Beam / eCM2);
233 if ( !sampleQ2 ) kT2gamma = 0.;
237 if ( kT2gamma < 0. ) {
238 infoPtr->errorMsg(
"Error in gammaKinematics::sampleKTgamma: "
239 "unphysical kT value.");
245 kT = sqrt( kT2gamma );
246 theta = atan( sqrt( eCM2 * ( Q2gamma * ( 1. - xGamma )
247 - m2Beam * pow2(xGamma) ) - m2Beam * Q2gamma - pow2( 0.5 * Q2gamma) )
248 / ( eCM2 * ( 1. - xGamma) - m2Beam - 0.5 * Q2gamma ) );
249 kz = (xGamma * eCM2 + 0.5 * Q2gamma) / ( sqrt(eCM2 - m2Beam) );
259 double GammaKinematics::calcNewSHat(
double sHatOld){
262 if ( hasGammaA && hasGammaB) {
265 gammaMode = infoPtr->photonMode();
266 if (gammaMode == 4) sHatNew = m2GmGm;
267 else if (gammaMode == 2 || gammaMode == 3)
268 sHatNew = sHatOld * m2GmGm / ( xGamma1 * xGamma2 * sCM);
272 else sHatNew = sHatOld;
281 double GammaKinematics::fluxWeight() {
288 if (hasGammaA) wt *= beamAPtr->xfFlux(22, xGamma1, Q2gamma1) /
289 beamAPtr->xfApprox(22, xGamma1, Q2gamma1);
290 if (hasGammaB) wt *= beamBPtr->xfFlux(22, xGamma2, Q2gamma2) /
291 beamBPtr->xfApprox(22, xGamma2, Q2gamma2);
295 if (hasGammaA) wt *= beamAPtr->xfFlux(22, xGamma1, Q2gamma1) /
296 beamAPtr->xf(22, xGamma1, Q2gamma1);
297 if (hasGammaB) wt *= beamBPtr->xfFlux(22, xGamma2, Q2gamma2) /
298 beamBPtr->xf(22, xGamma2, Q2gamma2);
309 bool GammaKinematics::finalize(){
312 beamAPtr->newGammaKTPhi(kT1, phi1);
313 beamBPtr->newGammaKTPhi(kT2, phi2);
314 beamAPtr->Q2Gamma(Q2gamma1);
315 beamBPtr->Q2Gamma(Q2gamma2);
318 infoPtr->setQ2Gamma1(Q2gamma1);
319 infoPtr->setQ2Gamma2(Q2gamma2);
320 infoPtr->setX1Gamma(xGamma1);
321 infoPtr->setX2Gamma(xGamma2);
324 if ( (infoPtr->nFinal() > 1) || (gammaMode != 4)) {
325 infoPtr->setTheta1(theta1);
326 infoPtr->setTheta2(theta2);
327 infoPtr->setECMsub(mGmGm);
328 infoPtr->setsHatNew(sHatNew);