21 #define MAGENTA "\033[35m"
32 JSDEBUG <<
"Initialize epemGun";
36 readString(
"Init:showProcesses = off");
37 readString(
"Init:showChangedSettings = off");
38 readString(
"Init:showMultipartonInteractions = off");
39 readString(
"Init:showChangedParticleData = off");
40 if (JetScapeLogger::Instance()->GetInfo()) {
41 readString(
"Init:showProcesses = on");
42 readString(
"Init:showChangedSettings = on");
43 readString(
"Init:showMultipartonInteractions = on");
44 readString(
"Init:showChangedParticleData = on");
48 readString(
"Next:numberShowInfo = 0");
49 readString(
"Next:numberShowProcess = 0");
50 readString(
"Next:numberShowEvent = 0");
53 readString(
"HadronLevel:all = off");
56 readString(
"PartonLevel:FSR = off");
58 readString(
"PDF:lepton = off");
59 readString(
"WeakSingleBoson:ffbar2gmz=on");
60 readString(
"WeakDoubleBoson:all=on");
61 readString(
"WeakBosonExchange:all=on");
64 readString(
"23:onMode = off");
65 readString(
"23:onIfAny = 1 2 3 4 5");
69 numbf.setf(ios::fixed, ios::floatfield);
70 numbf.setf(ios::showpoint);
74 std::string s = GetXMLElementText({
"Hard",
"epemGun",
"name"});
102 readString(
"Random:setSeed = on");
103 numbi.str(
"Random:seed = ");
104 unsigned int seed = 0;
105 if (RandomXmlDescription) {
109 throw std::runtime_error(
"Cannot parse xml");
112 JSWARN <<
"No <Random> element found in xml, seeding to 0";
116 readString(numbi.str());
119 readString(
"Beams:idA = 11");
120 readString(
"Beams:idB = -11");
123 eCM = GetXMLElementDouble({
"Hard",
"epemGun",
"eCM"});
124 numbf.str(
"Beams:eCM = ");
126 readString(numbf.str());
128 std::stringstream
lines;
129 lines << GetXMLElementText({
"Hard",
"epemGun",
"LinesToRead"},
false);
131 while (std::getline(lines, s,
'\n')) {
132 if (s.find_first_not_of(
" \t\v\f\r") == s.npos)
134 VERBOSE(7) <<
"Also reading in: " <<
s;
140 throw std::runtime_error(
"Pythia init() failed.");
144 ZeroOneDistribution = uniform_real_distribution<double>{0.0, 1.0};
149 VERBOSE(1) <<
"Run Hard Process : " << GetId() <<
" ...";
150 VERBOSE(8) <<
"Current Event #" << GetCurrentEvent();
152 double vir_factor = GetXMLElementDouble({
"Eloss",
"Matter",
"vir_factor"});
155 vector<Pythia8::Particle> p62;
158 struct greater_than_pt {
159 inline bool operator()(
const Pythia8::Particle &p1,
160 const Pythia8::Particle &p2) {
161 return (p1.pT() > p2.pT());
170 for (
int parid = 0; parid <
event.size(); parid++) {
173 Pythia8::Particle &
particle =
event[parid];
179 if( (std::abs(particle.id()) > 1100) && (std::abs(particle.id()) < 6000) && ((std::abs(particle.id())/10)%10 == 0) ){
182 particle.id( -1*particle.id()/1000 );
188 if ( particle.status()<0 ) {
continue;}
191 if (fabs(particle.id()) > 6 && (particle.id() != 21 && particle.id() != 22)) {
206 p62.push_back(particle);
216 std::sort(p62.begin(), p62.end(), greater_than_pt());
224 double p[4], xLoc[4];
227 for (
int i = 0;
i <= 3;
i++) {
234 if(p62.size() == 2 && std::abs(p62[0].
e() - 0.5*eCM) < 0.001 && std::abs(p62[1].
e() - 0.5*eCM) < 0.001 && std::abs(p62[0].
id()) < 6 && std::abs(p62[1].
id()) < 6){
239 const double QS = 0.9;
242 for(
int pass=0; pass<2; ++pass){
244 double mass = p62[pass].m0();
249 double max_vir = (0.25*eCM*eCM - mass*
mass) * std::abs(vir_factor);
250 double min_vir = (0.5 * QS *
QS ) * (1.0 + std::sqrt(1.0 + 4.0 * mass*mass / (QS*QS)));
254 if (max_vir <= QS * QS){
256 }
else if(max_vir < min_vir){
261 double random = ZeroOneDistribution(*GetMt19937Generator());
265 diff = (ratio - random) / random;
268 if(max_vir >= (QS*QS / 2.) * (1.0 + std::sqrt(1.0 + 2.0 * mass * mass / (QS*QS / 2.)))){
269 double g = (QS*QS / 2.) * (1.0 + std::sqrt(1.0 + 2.0 * mass * mass / (QS*QS / 2.)));
270 numer = exp(-1.0 * (
Cf / 2.0 /
pi) * sud_val_QG_w_M(mass,(QS*QS / 2.), g, max_vir, 0.5*eCM));
273 if (numer > random){tQ2 = min_vir;}
276 double t_hi = max_vir;
277 double t_low = min_vir;
278 double t_mid = t_low;
283 t_mid = 0.5*(t_low + t_hi);
285 if (t_mid < (QS*QS / 2.) * (1.0 + std::sqrt(1.0 + 2.0 * mass * mass / (QS*QS / 2.)))){
288 double g = (QS*QS / 2.) * (1.0 + std::sqrt(1.0 + 2.0 * mass * mass / (QS*QS / 2.)));
289 denom = exp(-1.0 * (
Cf / 2.0 /
pi) * sud_val_QG_w_M(mass,(QS*QS / 2.), g, t_mid, 0.5*eCM));
292 ratio = numer / denom;
294 diff = (ratio - random) / random;
296 if (diff < 0.0){t_low = t_mid;}
299 }
while((abs(diff) >
s_approx) && (abs(t_hi - t_low) / t_hi >
s_error));
306 if(pass==0){q1=sqrt(tQ2);}
307 else if(pass==1){q2=sqrt(tQ2);}
310 double modm_sq1 = q1*q1 + p62[0].m0()*p62[0].m0();
311 double modm_sq2 = q2*q2 + p62[1].m0()*p62[1].m0();
313 if(eCM > sqrt(modm_sq1)+sqrt(modm_sq2)){
315 double pnew = 0.5*sqrt((eCM*eCM-modm_sq1-modm_sq2)*(eCM*eCM-modm_sq1-modm_sq2)-4.*modm_sq1*modm_sq2)/eCM;
317 auto magnitude = [](
const Pythia8::Particle &
p) {
318 return std::sqrt(p.px() * p.px() + p.py() * p.py() + p.pz() * p.pz());
321 double scale1 = pnew/magnitude(p62[0]);
322 double scale2 = pnew/magnitude(p62[1]);
323 double e1new = sqrt(pnew*pnew + modm_sq1);
324 double e2new = sqrt(pnew*pnew + modm_sq2);
326 p62[0].px(p62[0].px()*scale1);
327 p62[0].py(p62[0].py()*scale1);
328 p62[0].pz(p62[0].pz()*scale1);
330 p62[1].px(p62[1].px()*scale2);
331 p62[1].py(p62[1].py()*scale2);
332 p62[1].pz(p62[1].pz()*scale2);
337 for (
int np = 0; np < p62.size(); ++np) {
338 Pythia8::Particle &
particle = p62.at(np);
340 VERBOSE(7) <<
"Adding particle with pid = " << particle.id()
341 <<
" at x=" << xLoc[1] <<
", y=" << xLoc[2] <<
", z=" << xLoc[3];
343 VERBOSE(7) <<
"Adding particle with pid = " << particle.id()
344 <<
", pT = " << particle.pT() <<
", eta = " << particle.eta()
345 <<
", phi = " << particle.phi() <<
", e = " << particle.e();
347 VERBOSE(7) <<
" at x=" << xLoc[1] <<
", y=" << xLoc[2] <<
", z=" << xLoc[3];
349 auto ptn = make_shared<Parton>(0, particle.id(), 0, particle.pT(), particle.eta(), particle.phi(), particle.e(), xLoc);
350 ptn->set_color(particle.col());
351 ptn->set_anti_color(particle.acol());
352 ptn->set_max_color(1000 * (np + 1));
354 if(p62.size() == 2 && std::abs(particle.id()) < 6){
355 double mean_form_time = (2.*ptn->e()) / (ptn->e()*ptn->e()
356 - ptn->px()*ptn->px() - ptn->py()*ptn->py()
357 - ptn->pz()*ptn->pz() - ptn->restmass()*ptn->restmass()
359 ptn->set_form_time(mean_form_time);
360 ptn->set_mean_form_time();
364 for (
int j = 1;
j <= 3;
j++) {
365 velocity[
j] = ptn->p(
j) / ptn->e();
367 ptn->set_jet_v(velocity);
374 VERBOSE(8) << GetNHardPartons();
378 double val,
h, intg, hL, hR, diff, intg_L, intg_R, span;
384 span = (h2 -
h1) / h2;
386 val = alpha_s(h) * sud_z_QG_w_M(M, h0, h, E1);
388 intg = val * (h2 -
h1);
392 intg_L = alpha_s(hL) * sud_z_QG_w_M(M, h0, hL, E1) * (h -
h1);
396 intg_R = alpha_s(hR) * sud_z_QG_w_M(M, h0, hR, E1) * (h2 -
h);
398 diff = std::abs((intg_L + intg_R - intg) / intg);
401 intg = sud_val_QG_w_M(M, h0, h1, h, E1) +
402 sud_val_QG_w_M(M, h0, h, h2, E1);
428 if (cg1 < 2.0 * cg + M * M / (1.0 + M * M / cg1)) {
429 JSINFO <<
MAGENTA <<
" returning with cg, cg1 = " << cg <<
" " << cg1
434 double t1 = 1.0 / cg1;
436 double t4 = std::pow(1.0 - t2, 2.0);
437 double t7 = std::log(t2);
439 double t10 = t1 * t9;
440 double t13 = 1.0 / (t10 + 1.0) * t10;
441 double t15 = std::pow(t2 + t13, 2.0);
442 double t18 = std::log(1.0 - t2 - t13);
443 double t21 = t1 * (-t4 / 2.0 - 1.0 + 2.0 * t2 - 2.0 * t7 + t15 / 2.0 + t13 +
447 cerr <<
"ERROR: t21 negative in sud_z_QG_w_M = " << t21 << endl;
448 throw std::runtime_error(
"ERROR: medium contribution negative in sud_z_QG_w_M");
455 double a, L2, q24, c_nf;
472 a = 12.0 *
pi / (11.0 *
Nc - 2.0 * c_nf) / std::log(q24 / L2);
474 JSWARN <<
" alpha too large ";