StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DireSplittingsQCD.cc
1 // DireSplittingsQCD.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Stefan Prestel, Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Function definitions (not found in the header) for the
7 // DireSplittingQCD and derived classes.
8 
9 #include "Pythia8/DireSplittingsQCD.h"
10 #include "Pythia8/DireSpace.h"
11 #include "Pythia8/DireTimes.h"
12 
13 namespace Pythia8 {
14 
15 //==========================================================================
16 
17 // The SplittingQCD class.
18 
19 const double DireSplittingQCD::SMALL_TEVOL = 2.0;
20 
21 //-------------------------------------------------------------------------
22 
23 void DireSplittingQCD::init() {
24 
25  // Colour factors.
26  CA = settingsPtr->parm("DireColorQCD:CA") > 0.0
27  ? settingsPtr->parm("DireColorQCD:CA") : 3.0;
28  CF = settingsPtr->parm("DireColorQCD:CF") > 0.0
29  ? settingsPtr->parm("DireColorQCD:CF") : 4./3.;
30  TR = settingsPtr->parm("DireColorQCD:TR") > 0.
31  ? settingsPtr->parm("DireColorQCD:TR") : 0.5;
32 
33  NF_qcd_fsr = settingsPtr->mode("TimeShower:nGluonToQuark");
34 
35  // Parameters of alphaS.
36  double alphaSvalue = settingsPtr->parm("SpaceShower:alphaSvalue");
37  alphaSorder = settingsPtr->mode("SpaceShower:alphaSorder");
38  int alphaSnfmax = settingsPtr->mode("StandardModel:alphaSnfmax");
39  bool alphaSuseCMW = settingsPtr->flag("SpaceShower:alphaSuseCMW");
40  // Initialize alphaS.
41  alphaS.init( alphaSvalue, alphaSorder, alphaSnfmax, alphaSuseCMW);
42 
43  // Set up alphaS
44  pTmin = settingsPtr->parm("SpaceShower:pTmin");
45  pTmin = min(pTmin,settingsPtr->parm("TimeShower:pTmin"));
46  usePDFalphas = settingsPtr->flag("ShowerPDF:usePDFalphas");
47  pT2minVariations = pow2(max(0.,settingsPtr->parm("Variations:pTmin")));
48 
49  BeamParticle* beam = NULL;
50  if (beamAPtr != NULL || beamBPtr != NULL) {
51  beam = (beamAPtr != NULL && particleDataPtr->isHadron(beamAPtr->id())) ?
52  beamAPtr
53  : (beamBPtr != NULL && particleDataPtr->isHadron(beamBPtr->id())) ?
54  beamBPtr : NULL;
55  if (beam == NULL && beamAPtr != 0) beam = beamAPtr;
56  if (beam == NULL && beamBPtr != 0) beam = beamBPtr;
57  }
58  alphaS2pi = (usePDFalphas && beam != NULL)
59  ? beam->alphaS(pTmin*pTmin) * 0.5/M_PI
60  : (alphaSorder > 0)
61  ? alphaS.alphaS(pTmin*pTmin) *0.5/M_PI
62  : 0.5 * 0.5/M_PI;
63 
64  if (!usePDFalphas && alphaSorder == 0) alphaS2pi = alphaSvalue*0.5/M_PI;
65 
66  doVariations = settingsPtr->flag("Variations:doVariations");
67  doCorrelations = settingsPtr->mode("DireTimes:kernelOrder") == 4
68  || settingsPtr->mode("DireSpace:kernelOrder") == 4;
69 
70  orderSave = (is_fsr) ? settingsPtr->mode("DireTimes:kernelOrder")
71  : settingsPtr->mode("DireSpace:kernelOrder");
72 
73  doGeneralizedKernel = (is_fsr)
74  ? settingsPtr->flag("DireTimes:doGeneralizedKernel") : false;
75 
76  useBackboneGluons = (is_fsr)
77  ? settingsPtr->flag("DireTimes:useBackboneGluons") : false;
78 
79  doMECs = settingsPtr->flag("Dire:doMECs")
80  || settingsPtr->flag("Dire:doMOPS")
81  || settingsPtr->flag("Dire:doMEM");
82 
83 }
84 
85 bool DireSplittingQCD::hasMECBef(const Event& state, double pT2) {
86  if (!doMECs) return false;
87  vector <int> in, out;
88  for (int i=0; i < state.size(); ++i) {
89  if (i == splitInfo.iRadBef) continue;
90  if (state[i].isFinal()) out.push_back(state[i].id());
91  if (state[i].mother1() == 1 && state[i].mother2() == 0)
92  in.push_back(state[i].id());
93  if (state[i].mother1() == 2 && state[i].mother2() == 0)
94  in.push_back(state[i].id());
95  }
96  int idRad = splitInfo.radBef()->id;
97  int colType = (idRad!=21) ? idRad/abs(idRad) : 2;
98  vector<int> re = radAndEmt( idRad, colType);
99  if (is_isr) in.push_back(re[0]);
100  else out.push_back(re[0]);
101  for (size_t i=1; i < re.size(); ++i) out.push_back(re[i]);
102  bool aboveCut = doMECs &&
103  pT2 > pow2(max(0.,settingsPtr->parm("Dire:pTminMECs")));
104  bool hasMEcode = (is_isr)
105  ? isr->weights->hasME(in,out) : fsr->weights->hasME(in,out);
106  return aboveCut && hasMEcode;
107 }
108 
109 bool DireSplittingQCD::hasMECAft(const Event& state, double pT2) {
110  if (!doMECs) return false;
111  vector <int> in, out;
112  for (int i=0; i < state.size(); ++i) {
113  if (state[i].isFinal()) out.push_back(state[i].id());
114  if (state[i].mother1() == 1 && state[i].mother2() == 0)
115  in.push_back(state[i].id());
116  if (state[i].mother1() == 2 && state[i].mother2() == 0)
117  in.push_back(state[i].id());
118  }
119  bool aboveCut = doMECs &&
120  pT2 > pow2(max(0.,settingsPtr->parm("Dire:pTminMECs")));
121  bool hasMEcode = (is_isr)
122  ? isr->weights->hasME(in,out) : fsr->weights->hasME(in,out);
123  return aboveCut && hasMEcode;
124 }
125 
126 
127 //-------------------------------------------------------------------------
128 
129 // Auxiliary function to get number of flavours.
130 
131 double DireSplittingQCD::getNF(double pT2) {
132  double NF = 6.;
133 
134  pT2 = max( pT2, pow2(pTmin) );
135 
136  BeamParticle* beam = NULL;
137  if (beamAPtr != NULL || beamBPtr != NULL) {
138  beam = (beamAPtr != NULL && particleDataPtr->isHadron(beamAPtr->id())) ?
139  beamAPtr
140  : (beamBPtr != NULL && particleDataPtr->isHadron(beamBPtr->id())) ?
141  beamBPtr : NULL;
142  if (beam == NULL && beamAPtr != 0) beam = beamAPtr;
143  if (beam == NULL && beamBPtr != 0) beam = beamBPtr;
144  }
145 
146  // Get current number of flavours.
147  if ( !usePDFalphas || beam == NULL) {
148  if ( pT2 > pow2( max(0., particleDataPtr->m0(5) ) )
149  && pT2 < pow2( particleDataPtr->m0(6)) ) NF = 5.;
150  else if ( pT2 > pow2( max( 0., particleDataPtr->m0(4)) ) ) NF = 4.;
151  else if ( pT2 > pow2( max( 0., particleDataPtr->m0(3)) ) ) NF = 3.;
152  } else {
153  if ( pT2 > pow2( max(0., beam->mQuarkPDF(5) ) )
154  && pT2 < pow2( particleDataPtr->m0(6)) ) NF = 5.;
155  else if ( pT2 > pow2( max( 0., beam->mQuarkPDF(4)) ) ) NF = 4.;
156  else if ( pT2 > pow2( max( 0., beam->mQuarkPDF(3)) ) ) NF = 3.;
157  }
158  return NF;
159 }
160 
161 //--------------------------------------------------------------------------
162 
163 double DireSplittingQCD::GammaQCD2 (double NF) {
164  return (67./18.-pow2(M_PI)/6.)*CA - 10./9.*NF*TR;
165 }
166 
167 //--------------------------------------------------------------------------
168 
169 double DireSplittingQCD::GammaQCD3 (double NF) {
170  return 1./4.* (CA*CA*(245./6.-134./27.*pow2(M_PI)+11./45.*pow(M_PI,4)
171  +22./3.*ZETA3)
172  +CA*NF*TR*(-418./27.+40./27.*pow2(M_PI)-56./3.*ZETA3)
173  +CF*NF*TR*(-55./3.+16.*ZETA3)-16./27.*pow2(NF*TR));
174 }
175 
176 //--------------------------------------------------------------------------
177 
178 double DireSplittingQCD::betaQCD0 (double NF)
179  { return 11./6.*CA - 2./3.*NF*TR;}
180 
181 //--------------------------------------------------------------------------
182 
183 double DireSplittingQCD::betaQCD1 (double NF)
184  { return 17./6.*pow2(CA) - (5./3.*CA+CF)*NF*TR;}
185 
186 //--------------------------------------------------------------------------
187 
188 double DireSplittingQCD::betaQCD2 (double NF)
189  { return 2857./432.*pow(CA,3)
190  + (-1415./216.*pow2(CA) - 205./72.*CA*CF + pow2(CF)/4.) *TR*NF
191  + ( 79.*CA + 66.*CF)/108.*pow2(TR*NF); }
192 
193 //--------------------------------------------------------------------------
194 
195 // Function to calculate the correct alphaS/2*Pi value, including
196 // renormalisation scale variations + threshold matching.
197 
198 double DireSplittingQCD::as2Pi( double pT2, int orderNow,
199  double renormMultFacNow) {
200 
201  // Get beam for PDF alphaS, if necessary.
202  BeamParticle* beam = NULL;
203  if (beamAPtr != NULL || beamBPtr != NULL) {
204  beam = (beamAPtr != NULL && particleDataPtr->isHadron(beamAPtr->id())) ?
205  beamAPtr
206  : (beamBPtr != NULL && particleDataPtr->isHadron(beamBPtr->id())) ?
207  beamBPtr : NULL;
208  if (beam == NULL && beamAPtr != 0) beam = beamAPtr;
209  if (beam == NULL && beamBPtr != 0) beam = beamBPtr;
210  }
211  double scale = pT2 * ( (renormMultFacNow > 0.)
212  ? renormMultFacNow : renormMultFac);
213  scale = max(scale, pow2(pTmin) );
214 
215  // Get alphaS(k*pT^2) and subtractions.
216  double asPT2pi = (usePDFalphas && beam != NULL)
217  ? beam->alphaS(scale) / (2.*M_PI)
218  : alphaS.alphaS(scale) / (2.*M_PI);
219  int order = (orderNow > -1) ? orderNow : correctionOrder;
220  order -= 1;
221 
222  // Now find the necessary thresholds so that alphaS can be matched
223  // correctly.
224  double m2cPhys = (usePDFalphas && beam != NULL)
225  ? pow2(max(0.,beam->mQuarkPDF(4)))
226  : alphaS.muThres2(4);
227  if ( !( (scale > m2cPhys && pT2 < m2cPhys)
228  || (scale < m2cPhys && pT2 > m2cPhys) ) ) m2cPhys = -1.;
229  double m2bPhys = (usePDFalphas && beam != NULL)
230  ? pow2(max(0.,beam->mQuarkPDF(5)))
231  : alphaS.muThres2(5);
232  if ( !( (scale > m2bPhys && pT2 < m2bPhys)
233  || (scale < m2bPhys && pT2 > m2bPhys) ) ) m2bPhys = -1.;
234  vector<double> scales;
235  scales.push_back(scale);
236  scales.push_back(pT2);
237  if (m2cPhys > 0.) scales.push_back(m2cPhys);
238  if (m2bPhys > 0.) scales.push_back(m2bPhys);
239  sort( scales.begin(), scales.end());
240  if (scale > pT2) reverse(scales.begin(), scales.end());
241 
242  double asPT2piCorr = asPT2pi;
243  for ( int i = 1; i< int(scales.size()); ++i) {
244  double NF = getNF( 0.5*(scales[i]+scales[i-1]) );
245  double L = log( scales[i]/scales[i-1] );
246  double subt = 0.;
247  if (order > 0) subt += asPT2piCorr * betaQCD0(NF) * L;
248  if (order > 2) subt += pow2( asPT2piCorr ) * ( betaQCD1(NF)*L
249  - pow2(betaQCD0(NF)*L) );
250  if (order > 4) subt += pow( asPT2piCorr, 3) * ( betaQCD2(NF)*L
251  - 2.5 * betaQCD0(NF)*betaQCD1(NF)*L*L
252  + pow( betaQCD0(NF)*L, 3) );
253  asPT2piCorr *= 1.0 - subt;
254  }
255 
256  // Done.
257  return asPT2piCorr;
258 
259 }
260 
261 //--------------------------------------------------------------------------
262 
263 // Helper function to calculate dilogarithm.
264 
265 double DireSplittingQCD::polevl(double x,double* coef,int N ) {
266  double ans;
267  int i;
268  double *p;
269 
270  p = coef;
271  ans = *p++;
272  i = N;
273 
274  do
275  ans = ans * x + *p++;
276  while( --i );
277 
278  return ans;
279 }
280 
281 //--------------------------------------------------------------------------
282 
283 // Function to calculate dilogarithm.
284 
285 double DireSplittingQCD::DiLog(double x) {
286 
287  static double cof_A[8] = {
288  4.65128586073990045278E-5,
289  7.31589045238094711071E-3,
290  1.33847639578309018650E-1,
291  8.79691311754530315341E-1,
292  2.71149851196553469920E0,
293  4.25697156008121755724E0,
294  3.29771340985225106936E0,
295  1.00000000000000000126E0,
296  };
297  static double cof_B[8] = {
298  6.90990488912553276999E-4,
299  2.54043763932544379113E-2,
300  2.82974860602568089943E-1,
301  1.41172597751831069617E0,
302  3.63800533345137075418E0,
303  5.03278880143316990390E0,
304  3.54771340985225096217E0,
305  9.99999999999999998740E-1,
306  };
307 
308  if( x >1. ) {
309  return -DiLog(1./x)+M_PI*M_PI/3.-0.5*pow2(log(x));
310  }
311 
312  x = 1.-x;
313  double w, y, z;
314  int flag;
315  if( x == 1.0 )
316  return( 0.0 );
317  if( x == 0.0 )
318  return( M_PI*M_PI/6.0 );
319 
320  flag = 0;
321 
322  if( x > 2.0 ) {
323  x = 1.0/x;
324  flag |= 2;
325  }
326 
327  if( x > 1.5 ) {
328  w = (1.0/x) - 1.0;
329  flag |= 2;
330  }
331 
332  else if( x < 0.5 ) {
333  w = -x;
334  flag |= 1;
335  }
336 
337  else
338  w = x - 1.0;
339 
340  y = -w * polevl( w, cof_A, 7) / polevl( w, cof_B, 7 );
341 
342  if( flag & 1 )
343  y = (M_PI * M_PI)/6.0 - log(x) * log(1.0-x) - y;
344 
345  if( flag & 2 ) {
346  z = log(x);
347  y = -0.5 * z * z - y;
348  }
349 
350  return y;
351 
352 }
353 
354 //--------------------------------------------------------------------------
355 
356 double DireSplittingQCD::softRescaleInt(int order) {
357  double rescale = 1.;
358 
359  // No inclusive cusp rescaling for differential NLO.
360  if (order > 3) return 1.;
361 
362  if (order > 0) rescale += alphaS2pi*GammaQCD2(3.);
363  if (order > 1) rescale += pow2(alphaS2pi)*GammaQCD3(3.);
364  return rescale;
365 }
366 
367 //--------------------------------------------------------------------------
368 
369 double DireSplittingQCD::softRescaleDiff(int order, double pT2,
370  double renormMultFacNow) {
371  double rescale = 1.;
372  // Get alphaS and number of flavours, attach cusp factors.
373  double NF = getNF(pT2 * ( (renormMultFacNow > 0.)
374  ? renormMultFacNow : renormMultFac) );
375  double asPT2pi = as2Pi(pT2, order, renormMultFacNow);
376 
377  // No inclusive cusp rescaling for differential NLO.
378  if (order > 3) return 1.;
379 
380  if (order > 0) rescale += asPT2pi * GammaQCD2(NF);
381  if (order > 1) rescale += pow2(asPT2pi) * GammaQCD3(NF);
382  return rescale;
383 }
384 
385 //--------------------------------------------------------------------------
386 
387 double DireSplittingQCD::beta0Endpoint(int order, double m2dip,
388  double pT2, double z, double renormMultFacNow) {
389 
390  // No explicit beta0-endpoint for inclusive NLO.
391  if (order < 4) return 0.;
392 
393  double ycs = pT2/m2dip/(1.-z);
394  double siq = ycs*m2dip;
395  double sjq = (1.-z)*m2dip;
396  double sij = m2dip - siq - sjq;
397  double as = as2Pi(pT2, order, renormMultFacNow);
398  double mu2 = pT2*((renormMultFacNow >0.) ? renormMultFacNow : renormMultFac);
399  double add = as * 2.*sij/(siq*sjq)
400  * log( (mu2*sij)/(siq*sjq) ) * betaQCD0(pT2);
401  return add;
402 }
403 
404 //--------------------------------------------------------------------------
405 
406 bool DireSplittingQCD::hasSharedColor(const Event& event, int iRad,
407  int iRec) {
408  int radCol(event[iRad].col()), radAcl(event[iRad].acol()),
409  recCol(event[iRec].col()), recAcl(event[iRec].acol());
410  if ( event[iRad].isFinal() && event[iRec].isFinal() ) {
411  if (radCol != 0 && radCol == recAcl) return true;
412  if (radAcl != 0 && radAcl == recCol) return true;
413  } else if ( event[iRad].isFinal() && !event[iRec].isFinal() ) {
414  if (radCol != 0 && radCol == recCol) return true;
415  if (radAcl != 0 && radAcl == recAcl) return true;
416  } else if (!event[iRad].isFinal() && event[iRec].isFinal() ) {
417  if (radCol != 0 && radCol == recCol) return true;
418  if (radAcl != 0 && radAcl == recAcl) return true;
419  } else if (!event[iRad].isFinal() && !event[iRec].isFinal() ) {
420  if (radCol != 0 && radCol == recAcl) return true;
421  if (radAcl != 0 && radAcl == recCol) return true;
422  }
423  return false;
424 }
425 
426 //--------------------------------------------------------------------------
427 
428 vector<int> DireSplittingQCD::sharedColor(const Event& event, int iRad,
429  int iRec) {
430  vector<int> ret;
431  int radCol(event[iRad].col()), radAcl(event[iRad].acol()),
432  recCol(event[iRec].col()), recAcl(event[iRec].acol());
433  if ( event[iRad].isFinal() && event[iRec].isFinal() ) {
434  if (radCol != 0 && radCol == recAcl) ret.push_back(radCol);
435  if (radAcl != 0 && radAcl == recCol) ret.push_back(radAcl);
436  } else if ( event[iRad].isFinal() && !event[iRec].isFinal() ) {
437  if (radCol != 0 && radCol == recCol) ret.push_back(radCol);
438  if (radAcl != 0 && radAcl == recAcl) ret.push_back(radAcl);
439  } else if (!event[iRad].isFinal() && event[iRec].isFinal() ) {
440  if (radCol != 0 && radCol == recCol) ret.push_back(radCol);
441  if (radAcl != 0 && radAcl == recAcl) ret.push_back(radAcl);
442  } else if (!event[iRad].isFinal() && !event[iRec].isFinal() ) {
443  if (radCol != 0 && radCol == recAcl) ret.push_back(radCol);
444  if (radAcl != 0 && radAcl == recCol) ret.push_back(radAcl);
445  }
446  return ret;
447 }
448 
449 //--------------------------------------------------------------------------
450 
451 int DireSplittingQCD::findCol(int col, vector<int> iExc, const Event& event,
452  int type) {
453 
454  int index = 0;
455 
456  int inA = 0, inB = 0;
457  for (int i=event.size()-1; i > 0; --i) {
458  if ( event[i].mother1() == 1 && event[i].status() != -31
459  && event[i].status() != -34) { if (inA == 0) inA = i; }
460  if ( event[i].mother1() == 2 && event[i].status() != -31
461  && event[i].status() != -34) { if (inB == 0) inB = i; }
462  }
463 
464  // Search event record for matching colour & anticolour
465  for(int n = 0; n < event.size(); ++n) {
466  // Skip if this index is excluded.
467  if ( find(iExc.begin(), iExc.end(), n) != iExc.end() ) continue;
468  if ( event[n].colType() != 0 && event[n].status() > 0 ) {
469  if ( event[n].acol() == col ) {
470  index = -n;
471  break;
472  }
473  if ( event[n].col() == col ) {
474  index = n;
475  break;
476  }
477  }
478  }
479  // Search event record for matching colour & anticolour
480  for(int n = event.size()-1; n > 0; --n) {
481  // Skip if this index is excluded.
482  if ( find(iExc.begin(), iExc.end(), n) != iExc.end() ) continue;
483  if ( index == 0 && event[n].colType() != 0
484  && ( n == inA || n == inB) ) { // Check incoming
485  if ( event[n].acol() == col ) {
486  index = -n;
487  break;
488  }
489  if ( event[n].col() == col ) {
490  index = n;
491  break;
492  }
493  }
494  }
495  // if no matching colour / anticolour has been found, return false
496  if ( type == 1 && index < 0) return abs(index);
497  if ( type == 2 && index > 0) return abs(index);
498  return 0;
499 
500 }
501 //--------------------------------------------------------------------------
502 
503 // Function to convert ordering variables etc. to the phase space variables
504 // pT2 (in Dire default definition), z (in Dire default definition),
505 // sai (in Dire default definition) and xa (in Dire default definition).
506 
507 unordered_map<string,double> DireSplittingQCD::getPhasespaceVars(
508  const Event& state, PartonSystems*) {
509 
510  // Read all splitting variables.
511  unordered_map<string,double> ret(splitInfo.getKinInfo());
512 
513  // Now construct Bjorken-x of initial-state after branching, as is necessary
514  // to attach PDF ratios.
515  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
516  m2dip(splitInfo.kinematics()->m2Dip),
517  m2RadBef(splitInfo.kinematics()->m2RadBef),
518  m2Rad(splitInfo.kinematics()->m2RadAft),
519  m2Rec(splitInfo.kinematics()->m2Rec),
520  m2Emt(splitInfo.kinematics()->m2EmtAft),
521  m2Emt2(splitInfo.kinematics()->m2EmtAft2),
522  sai(splitInfo.kinematics()->sai), xa(splitInfo.kinematics()->xa);
523 
524  double xNew(-1.0);
525  // Final-initial
526  if (splitInfo.radBef()->isFinal && !splitInfo.recBef()->isFinal ) {
527 
528  double xRecBef = 2.* state[splitInfo.iRecBef].e()
529  / (beamAPtr->e() + beamBPtr->e());
530 
531  double q2 = (state[splitInfo.iRecBef].p()
532  -state[splitInfo.iRadBef].p()).m2Calc();
533  // Recalculate the kinematicaly available dipole mass.
534  double Q2 = m2dip;
535 
536  // Recalculate the kinematicaly available dipole mass.
537  // Calculate CS variables.
538  double kappa2 = pT2/Q2;
539  double xCS = 1 - kappa2/(1.-z);
540  double xCDST = xCS*( 1. + (m2RadBef-m2Rad-m2Emt)/Q2 );
541  xNew = xRecBef / xCDST;
542 
543  double m2a(m2Emt), m2i(m2Emt), m2j(m2Emt2), m2aij(m2RadBef), m2k(0.0);
544  if ( nEmissions() == 2 ) {
545  double m2ai = sai + m2a + m2i;
546  xCS = (q2 - m2ai - m2a - m2i)
547  / (q2 - m2ai - m2a - m2i - pT2 * xa/z);
548  xCDST = xCS * ( 1. - (m2aij-m2ai-m2j)/ (q2-m2ai-m2j-m2k) );
549  xNew = xRecBef / xCDST;
550  }
551 
552  // Initial-final
553  } else if (!splitInfo.radBef()->isFinal && splitInfo.recBef()->isFinal ) {
554 
555  double xRadBef = 2.* state[splitInfo.iRadBef].e()
556  / (beamAPtr->e() + beamBPtr->e());
557  // Calculate CS variables.
558  double xCS = z;
559  xNew = xRadBef/xCS;
560 
561  // Initial-initial
562  } else if (!splitInfo.radBef()->isFinal && !splitInfo.recBef()->isFinal ) {
563 
564  double xRadBef = 2.* state[splitInfo.iRadBef].e()
565  / (beamAPtr->e() + beamBPtr->e());
566  // Adjust the dipole kinematical mass to accomodate masses after branching.
567  double m2DipCorr = m2dip;
568  // Calculate CS variables.
569  double kappa2 = pT2 / m2DipCorr;
570  double xCS = (z*(1-z)- kappa2)/(1-z);
571 
572  // 1->3 splittings, in CS variables.
573  double q2 = (state[splitInfo.iRadBef].p()
574  +state[splitInfo.iRecBef].p()).m2Calc();
575 
576  // Pick remaining variables for 1->3 splitting.
577  double m2a(m2Rad), m2i(m2Emt), m2j(m2Emt2), m2k(m2Rec);
578  if ( nEmissions() == 2 ) {
579  xCS = z * (q2 - m2a - m2i - m2j - m2k) / q2;
580  }
581  xNew = xRadBef/xCS;
582  }
583 
584  // Done.
585  ret.insert(make_pair("xInAft", xNew));
586  return ret;
587 }
588 
589 //--------------------------------------------------------------------------
590 
591 double DireSplittingQCD::getJacobian( const Event& state, PartonSystems*
592  partonSystems) {
593 
594  // Read all splitting variables.
595  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
596  m2dip(splitInfo.kinematics()->m2Dip),
597  m2RadBef(splitInfo.kinematics()->m2RadBef),
598  m2Rad(splitInfo.kinematics()->m2RadAft),
599  m2Rec(splitInfo.kinematics()->m2Rec),
600  m2Emt(splitInfo.kinematics()->m2EmtAft),
601  m2Emt2(splitInfo.kinematics()->m2EmtAft2),
602  sai(splitInfo.kinematics()->sai), xa(splitInfo.kinematics()->xa),
603  phi(splitInfo.kinematics()->phi);
604 
605  double jacobian = 0.0;
606  // Final-final jacobian.
607  if ( splitInfo.radBef()->isFinal && splitInfo.recBef()->isFinal ) {
608 
609  // Recalculate the kinematicaly available dipole mass.
610  double Q2 = m2dip;
611  double q2 = (state[splitInfo.iRadBef].p()
612  + state[splitInfo.iRecBef].p()).m2Calc();
613 
614  // Pick remaining variables for 1->3 splitting.
615  double m2aij(m2RadBef), m2a(m2Emt), m2i(m2Emt), m2j(m2Emt2), m2k(m2Rec);
616 
617  // Calculate CS variables and scaled masses.
618  double yCS = pT2/Q2 / (1. - z);
619 
620  double mu2RadBef = m2RadBef/ q2;
621  double mu2Rad = m2Rad/ q2;
622  double mu2Rec = m2Rec/ q2;
623  double mu2Emt = m2Emt/ q2;
624  // Calculate Jacobian.
625  double jac1 = ( 1. - mu2Rad - mu2Rec - mu2Emt)
626  / sqrt(lABC(1.,mu2RadBef,mu2Rec));
627  double jac2 = 1. + ( mu2Rad + mu2Emt - mu2RadBef)
628  /( yCS*(1. - mu2Rad - mu2Rec - mu2Emt));
629 
630  // Jacobian for 1->3 splittings, in CS variables.
631  if (nEmissions() == 2) {
632 
633  // Jacobian for competing steps, i.e. applied to over-all splitting rate.
634  jac1 = (q2 - m2aij - m2k) / sqrt( lABC(q2, m2aij, m2k) );
635 
636  // Additional jacobian for non-competing steps.
637  double m2ai = sai + m2a + m2i;
638  double m2aik = (sai + m2a + m2i) + m2k + z/xa * (q2 - m2RadBef - m2k);
639  jac1 *= (m2aik - m2ai - m2k) / sqrt( lABC(m2aik, m2ai, m2k) );
640 
641  // Additional factor from massive propagator.
642  jac2 = 1 + (m2ai + m2j - m2aij) / (pT2*xa/z);
643 
644  }
645 
646  // Done.
647  jacobian = jac1/jac2;
648 
649  // Final-initial jacobian
650  } else if (splitInfo.radBef()->isFinal && !splitInfo.recBef()->isFinal ) {
651  double q2 = (state[splitInfo.iRecBef].p()
652  -state[splitInfo.iRadBef].p()).m2Calc();
653  // Recalculate the kinematicaly available dipole mass.
654  double Q2 = m2dip;
655 
656  double m2a(m2Emt), m2i(m2Emt), m2j(m2Emt2), m2aij(m2RadBef), m2k(0.0);
657 
658  // Get momentum of other beam, since this might be needed to calculate
659  // the Jacobian.
660  int iOther = (state[splitInfo.iRecBef].mother1() == 1)
661  ? partonSystems->getInB(splitInfo.systemRec)
662  : partonSystems->getInA(splitInfo.systemRec);
663  Vec4 pOther(state[iOther].p());
664 
665  // Recalculate the kinematicaly available dipole mass.
666  // Calculate CS variables.
667  double kappa2 = pT2/Q2;
668  double xCS = 1 - kappa2/(1.-z);
669  double xCDST = xCS*( 1. + (m2RadBef-m2Rad-m2Emt)/Q2 );
670 
671  // Jacobian for 1->2 splittings, in CS variables.
672  if ( nEmissions() != 2 )
673  jacobian = ( 1.- xCS) / ( 1. - xCDST);
674 
675  // Jacobian for 1->3 splittings, in CS variables.
676  if ( nEmissions() == 2 ) {
677 
678  double m2ai = sai + m2a + m2i;
679  xCS = (q2 - m2ai - m2a - m2i)
680  / (q2 - m2ai - m2a - m2i - pT2 * xa/z);
681 
682  // Jacobian for competing steps, i.e. applied to over-all splitting rate.
683  double saij = (xCS - 1.)/xCS * (q2 - m2a) + (m2ai + m2j)/xCS;
684  double xbar = (q2 - m2aij - m2k) / (q2 - saij - m2k);
685 
686  // Calculate the partonic eCM before the splitting.
687  double sHatBefore = (state[splitInfo.iRecBef].p() + pOther).m2Calc();
688  double m2OtherBeam = 0.;
689 
690  // Now construct the new recoiler momentum.
691  Vec4 q(state[splitInfo.iRecBef].p()-state[splitInfo.iRadBef].p());
692  Vec4 pRadBef(state[splitInfo.iRadBef].p());
693  Vec4 pRecBef(state[splitInfo.iRecBef].p());
694  Vec4 qpar(q.px()+pRadBef.px(), q.py()+pRadBef.py(), q.pz(), q.e());
695  double qpar2 = qpar.m2Calc();
696  double pT2ijt = pow2(pRadBef.px()) + pow2(pRadBef.py());
697  Vec4 pRec( (pRecBef - (qpar*pRecBef)/qpar2 * qpar)
698  * sqrt( (lABC(q2,saij,m2k) - 4.*m2k*pT2ijt)
699  /(lABC(q2,m2aij,m2k) - 4.*m2k*pT2ijt))
700  + qpar * (q2+m2k-saij)/(2.*qpar2) );
701  // Calculate the partonic eCM after the splitting.
702  double sHatAfter = (pOther + pRec).m2Calc();
703 
704  // Calculate Jacobian.
705  double rho_bai = sqrt( lABC(sHatBefore, m2k, m2OtherBeam)
706  / lABC(sHatAfter, m2k, m2OtherBeam) );
707  jacobian = rho_bai/xbar
708  * (saij + m2k - q2) / sqrt( lABC(saij, m2k, q2) );
709 
710  // Additional jacobian for non-competing steps.
711  double saib = m2ai + m2k
712  + z/xa * (q2 - m2k - m2ai - m2j - pT2*xa/z);
713  jacobian *= (m2ai + m2k - saib) / sqrt( lABC(m2ai, m2k, saib) );
714 
715  xCDST = xCS * ( 1. - (m2aij-m2ai-m2j)/ (q2-m2ai-m2j-m2k) );
716  // Extra correction from massless to massive propagator.
717  jacobian *= ( 1.- xCS) / ( 1. - xCDST);
718  }
719  // Initial-final jacobian
720  } else if (!splitInfo.radBef()->isFinal && splitInfo.recBef()->isFinal ) {
721  // Pick remaining variables for 1->3 splitting.
722  double jac(1.), m2aij(m2RadBef), m2ai(0.), m2a(m2Rad), m2i(m2Emt),
723  m2j(m2Emt2), m2k(m2Rec);
724  m2ai = -sai + m2a + m2i;
725  double q2 = (state[splitInfo.iRadBef].p()
726  -state[splitInfo.iRecBef].p()).m2Calc();
727  // Get momentum of other beam, since this might be needed to calculate
728  // the Jacobian.
729  int iOther = state[splitInfo.iRadBef].mother1() == 1
730  ? partonSystems->getInB(splitInfo.system)
731  : partonSystems->getInA(splitInfo.system);
732  Vec4 pOther(state[iOther].p());
733 
734  // Jacobian for 1->3 splittings, in CS variables.
735  if ( nEmissions() == 2 ) {
736 
737  // Construnct the new initial state momentum, as needed to
738  // calculate the Jacobian.
739  double m2jk = pT2/xa + q2*( 1. - xa/z) - m2ai;
740  double uCS = z*(m2ai-m2a-m2i)/q2;
741  double xCS = uCS + xa - (pT2*z)/(q2*xa);
742  Vec4 q( state[splitInfo.iRadBef].p() - state[splitInfo.iRecBef].p() );
743  double sHatBef = (state[splitInfo.iRadBef].p() + pOther).m2Calc();
744  double sijk = q2*(1.-1./z) - m2a;
745 
746  // sHat after emission depends on the recoil scheme if the incoming
747  // particles have non-zero mass.
748  // Local scheme.
749  double sHatAft(0.);
750  if (!settingsPtr->flag("DireSpace:useGlobalMapIF")) {
751 
752  // Get transverse and parallel vectors.
753  Vec4 pTk_tilde( state[splitInfo.iRecBef].p().px(),
754  state[splitInfo.iRecBef].p().py(), 0., 0.);
755  Vec4 qpar( q + pTk_tilde );
756  // Calculate derived variables.
757  double q2par = qpar.m2Calc();
758  double pT2k = -pTk_tilde.m2Calc();
759  double s_i_jk = (1. - 1./xCS)*(q2 - m2a) + (m2i + m2jk) / xCS;
760  // Construct radiator after branching.
761  Vec4 pa( ( state[splitInfo.iRadBef].p() - 0.5*(q2-m2aij-m2k)/q2par
762  * qpar )
763  * sqrt( (lABC(q2,s_i_jk,m2a) - 4.*m2a*pT2k)
764  / (lABC(q2,m2k,m2aij) - 4.*m2aij*pT2k))
765  + qpar * 0.5 * (q2 + m2a - s_i_jk) / q2par);
766  // Now get changed eCM.
767  sHatAft = (pa + pOther).m2Calc();
768 
769  // Global scheme.
770  } else {
771 
772  // Construct radiator after branching.
773  // Simple massless case.
774  Vec4 pa;
775 
776  // Get dipole 4-momentum.
777  Vec4 pb_tilde( state[splitInfo.iRecBef].p() );
778  Vec4 pa12_tilde( state[splitInfo.iRadBef].p() );
779  q.p(pb_tilde-pa12_tilde);
780 
781  // Calculate derived variables.
782  double zbar = (q2-m2ai-m2jk) / bABC(q2,m2ai,m2jk)
783  *( (xCS - 1)/(xCS-uCS) - m2jk / gABC(q2,m2ai,m2jk)
784  * (m2ai + m2i - m2a) / (q2 - m2ai - m2jk));
785  double kT2 = zbar*(1.-zbar)*m2ai - (1-zbar)*m2i - zbar*m2a;
786 
787  // Now construct recoiler in lab frame.
788  Vec4 pjk( (pb_tilde - q*pb_tilde/q2*q)
789  *sqrt(lABC(q2,m2ai,m2jk)/lABC(q2,m2aij,m2k))
790  + 0.5*(q2+m2jk-m2ai)/q2*q );
791 
792  // Construct left-over dipole momentum by momentum conservation.
793  Vec4 pai(-q+pjk);
794 
795  // Set up kT vector by using two perpendicular four-vectors.
796  pair<Vec4, Vec4> pTvecs = getTwoPerpendicular(pai, pjk);
797  Vec4 kTmom( sqrt(kT2)*sin(phi)*pTvecs.first
798  + sqrt(kT2)*cos(phi)*pTvecs.second);
799 
800  // Construct new emission momentum.
801  Vec4 pi( - zbar *(gABC(q2,m2ai,m2jk)*pai + m2ai*pjk)
802  / bABC(q2,m2ai,m2jk)
803  + ( (1.-zbar)*m2ai + m2i - m2a) / bABC(q2,m2ai,m2jk)
804  * (pjk + m2jk/gABC(q2,m2ai,m2jk)*pai)
805  + kTmom);
806 
807  // Contruct radiator momentum by momentum conservation.
808  pa.p(-q+pjk+pi);
809 
810  // Now get changed eCM.
811  sHatAft = (pa + pOther).m2Calc();
812 
813  }
814 
815  // Now calculate Jacobian.
816  double m2Other = pOther.m2Calc();
817  double rho_aij = sqrt( lABC(sHatBef, m2a, m2Other)
818  /lABC(sHatAft, m2a, m2Other));
819  jac = rho_aij / z * (sijk + m2a - q2) / sqrt(lABC(sijk, m2a, q2));
820 
821  // Additional jacobian for non-competing steps.
822  jac *= -q2 * xa / z / sqrt(lABC(m2jk, m2ai, q2));
823 
824  // Additional factor from massive propagator.
825  jac *= 1. / (1. - (m2ai + m2j - m2aij) / (pT2/xa)) ;
826 
827  }
828 
829  // Multiply with Jacobian.
830  jacobian = jac;
831 
832  // Initial-initial jacobian
833  } else if (!splitInfo.radBef()->isFinal && !splitInfo.recBef()->isFinal ) {
834 
835  double q2 = (state[splitInfo.iRadBef].p()
836  +state[splitInfo.iRecBef].p()).m2Calc();
837 
838  // Pick remaining variables for 1->3 splitting.
839  double m2a(m2Rad), m2i(m2Emt), m2j(m2Emt2), m2aij(m2RadBef), m2k(m2Rec);
840 
841  // Jacobian for 1->3 splittings, in CS variables.
842  jacobian = 1.0;
843  if ( nEmissions() == 2 ) {
844  // Calculate Jacobian.
845  double sab = q2/z + m2a + m2k;
846  jacobian = (sab-m2a-m2k) / sqrt(lABC(sab, m2a, m2k) );
847  double m2ai = -sai + m2a + m2i;
848  double sjq = q2*xa/z + m2ai + m2k;
849  jacobian *= (sjq-m2ai-m2k) / sqrt(lABC(sjq, m2ai, m2k) );
850 
851  // Additional factor from massive propagator.
852  jacobian *= 1. / (1. - (m2ai + m2j - m2aij) / (pT2/xa)) ;
853 
854  }
855  }
856 
857  return jacobian;
858 }
859 
860 //==========================================================================
861 
862 // Return true if this kernel should partake in the evolution.
863 bool Dire_fsr_qcd_Q2QGG::canRadiate (const Event& state, pair<int,int> ints,
864  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
865  if (orderSave != 4) return false;
866  return ( state[ints.first].isFinal()
867  && state[ints.second].colType() != 0
868  && hasSharedColor(state, ints.first, ints.second)
869  && state[ints.first].isQuark() );
870 }
871 
872 bool Dire_fsr_qcd_Q2QGG::canRadiate (const Event& state, int iRadBef,
873  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
874  if (orderSave != 4) return false;
875  return ( state[iRadBef].isFinal()
876  && state[iRecBef].colType() != 0
877  && hasSharedColor(state, iRadBef, iRecBef)
878  && state[iRadBef].isQuark() );
879 }
880 
881 double Dire_fsr_qcd_Q2QGG::gaugeFactor ( int, int ) { return 1.;}
882 double Dire_fsr_qcd_Q2QGG::symmetryFactor ( int, int ) { return 1.;}
883 
884 vector<pair<int,int> > Dire_fsr_qcd_Q2QGG::radAndEmtCols(int iRad, int colType,
885  Event state) {
886  int newCol1 = state.nextColTag();
887  int newCol2 = state.nextColTag();
888  int colEmtAft1, acolEmtAft1, colRadAft, acolRadAft, colEmtAft2, acolEmtAft2;
889  if (colType > 0) {
890  colEmtAft1 = state[iRad].col();
891  acolEmtAft1 = newCol2;
892  colRadAft = newCol1;
893  acolRadAft = 0;
894  colEmtAft2 = newCol2;
895  acolEmtAft2 = newCol1;
896  } else {
897  colEmtAft1 = newCol1;
898  acolEmtAft1 = newCol2;
899  colRadAft = 0;
900  acolRadAft = newCol1;
901  colEmtAft2 = newCol2;
902  acolEmtAft2 = state[iRad].acol();
903  }
904 
905  // Also remember colors for "intermediate" particles in 1->3 splitting.
906  if ( colType > 0) {
907  splitInfo.addExtra("colEmtInt", newCol1);
908  splitInfo.addExtra("acolEmtInt", state[iRad].acol());
909  splitInfo.addExtra("colRadInt", state[iRad].col());
910  splitInfo.addExtra("acolRadInt", newCol1);
911  } else {
912  splitInfo.addExtra("colEmtInt", state[iRad].col());
913  splitInfo.addExtra("acolEmtInt", newCol1);
914  splitInfo.addExtra("colRadInt", newCol1);
915  splitInfo.addExtra("acolRadInt", state[iRad].acol());
916  }
917 
918  return createvector<pair<int,int> >
919  (make_pair(colRadAft, acolRadAft))
920  (make_pair(colEmtAft1, acolEmtAft1))
921  (make_pair(colEmtAft2, acolEmtAft2));
922 }
923 
924 int Dire_fsr_qcd_Q2QGG::radBefID(int idRA, int) {
925  if (particleDataPtr->isQuark(idRA)) return idRA;
926  return 0;
927 }
928 
929 pair<int,int> Dire_fsr_qcd_Q2QGG::radBefCols(
930  int, int,
931  int, int) {
932  return make_pair(0,0);
933 }
934 
935 // Pick z for new splitting.
936 double Dire_fsr_qcd_Q2QGG::zSplit(double, double, double m2dip) {
937  double R = rndmPtr->flat();
938  // Pick according to soft + 1/(z+kappa2)
939  double a = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
940  double z1 = pow((1+a)/a,-R)*(1+a) - a;
941  return z1;
942 
943 }
944 
945 // New overestimates, z-integrated versions.
946 double Dire_fsr_qcd_Q2QGG::overestimateInt(double, double,
947  double, double m2dip, int) {
948  double wt = 0.;
949  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
950  // Overestimate by soft + 1/(z+kappa2)
951  wt = 16*CF*log( (kappa2 + 1)/kappa2);
952  return wt;
953 }
954 
955 // Return overestimate for new splitting.
956 double Dire_fsr_qcd_Q2QGG::overestimateDiff(double z, double m2dip, int) {
957  double wt = 0.;
958  double kappaOld2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
959  // Overestimate by soft + 1/(z+kappa2)
960  wt = 16*CF / (z + kappaOld2);
961  return wt;
962 }
963 
964 double Dire_fsr_qcd_Q2QGG::counterTerm(double si1, double si2, double sj1,
965  double sj2, double sij, double s12) {
966 
967  // Counter-term is zero in unordered phase space.
968  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)
969  / (si1+si2+sj1+sj2+sij+s12);
970  double kTi12 = (si1*s12)/(si1+si2+s12);
971  double kTi1j = (si1*sj1)/(si1+sj1+sij);
972  if ( kTi12 > kT12
973  && kTi1j > pow2(settingsPtr->parm("TimeShower:pTmin"))) return 0.;
974 
975  // Multiplicative weight factor to force first eikonal to current
976  // outgoing momenta.
977  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
978  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
979  / (si1*sj1 + si2*sj2);
980  double ct2 = pow2(si1*sj2-si2*sj1)/(s12*sij*(si1+si2)*(sj1+sj2));
981 
982  // Quark kernel.
983  double qqSoft = 2.*CF/CA * (2.*si2/(si1+s12) * (wij12+wij12bar)/2.);
984  double qqColl = 0.;
985  double qqColorCorr = (CA - 2.*CF)/CA * (2.*si2/(si1+s12) - 2.*sij/(si1+sj1))
986  * (wij12 + wij12bar) / 2.;
987  // Gluon kernel.
988  double ggSoft = 2. * si2/(si1+s12) * (wij12+wij12bar)/2.;
989  double ggColl = (-1. + ct2/2.0) * wij12;
990 
991  // If this is an ordered region, only the subleading color dipoles remain.
992  if (kTi12 > kT12) {
993  qqSoft = qqColl = ggSoft = ggColl = 0.;
994  qqColorCorr = (CA - 2.*CF)/CA * (- 2.*sij/(si1+sj1))
995  * (wij12 + wij12bar) / 2.;
996  }
997 
998  // Full counter-term
999  double ct = 2. * ((qqSoft+qqColl+qqColorCorr) / si1 +(ggSoft+ggColl) / s12)
1000  * sij / ((si1+si2)*(sj1+sj2)-sij*s12);
1001 
1002  // Done.
1003  return ct;
1004 
1005 }
1006 
1007 // Return kernel for new splitting.
1008 bool Dire_fsr_qcd_Q2QGG::calc(const Event& state, int orderNow) {
1009 
1010  // Dummy statement to avoid compiler warnings.
1011  if (false) cout << state[0].e() << orderNow << endl;
1012 
1013  // Read all splitting variables.
1014  double z(splitInfo.kinematics()->z),
1015  pT2(splitInfo.kinematics()->pT2),
1016  m2dip(splitInfo.kinematics()->m2Dip),
1017  xa(splitInfo.kinematics()->xa),
1018  sai(splitInfo.kinematics()->sai),
1019  m2i12(splitInfo.kinematics()->m2RadBef),
1020  m2i(splitInfo.kinematics()->m2RadAft),
1021  m21(splitInfo.kinematics()->m2EmtAft),
1022  m22(splitInfo.kinematics()->m2EmtAft2),
1023  m2j(splitInfo.kinematics()->m2Rec);
1024 
1025  splitInfo.addExtra("idRadInt",21);
1026  splitInfo.addExtra("idEmtInt",state[splitInfo.iRadBef].id());
1027  splitInfo.addExtra("swapped",1);
1028 
1029  // Calculate argument of alphaS.
1030  double scale2 = couplingScale2 ( z, pT2, m2dip,
1031  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
1032  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
1033  if (scale2 < 0.) scale2 = pT2;
1034 
1035  // Do nothing without other NLO kernels!
1036  unordered_map<string,double> wts;
1037  int order = (orderNow > -1) ? orderNow : correctionOrder;
1038  if ( order != 4 || m2i12 > 0. || m2i > 0. || m21 > 0. || m22 > 0.
1039  || m2j > 0.){
1040  wts.insert( make_pair("base", 0.) );
1041  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1042  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1043  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1044  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1045  clearKernels();
1046  for ( unordered_map<string,double>::iterator it = wts.begin();
1047  it != wts.end(); ++it )
1048  kernelVals.insert(make_pair( it->first, it->second ));
1049  return true;
1050  }
1051 
1052  // Generate state after branching to extract momenta.
1053  Event trialEvent(state);
1054  bool physical = false;
1055  if (splitInfo.recBef()->isFinal)
1056  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
1057  else
1058  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
1059  // Get invariants.
1060  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
1061  Vec4 pj(trialEvent[splitInfo.iRecAft].p());
1062  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
1063  Vec4 p2(trialEvent[splitInfo.iEmtAft2].p());
1064 
1065  // Use only massless for now!
1066  if ( sai > 0.
1067  && ( abs(pi.m2Calc()-m2i) > sai || abs(p1.m2Calc()-m21) > sai
1068  || abs(p2.m2Calc()-m22) > sai || abs(pj.m2Calc()-m2j) > sai))
1069  physical = false;
1070 
1071  if (!physical) {
1072  wts.insert( make_pair("base", 0.) );
1073  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1074  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1075  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1076  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1077  clearKernels();
1078  for ( unordered_map<string,double>::iterator it = wts.begin();
1079  it != wts.end(); ++it )
1080  kernelVals.insert(make_pair( it->first, it->second ));
1081  return true;
1082  }
1083 
1084  // Get invariants.
1085  double sij(2.*pi*pj), si1(2.*pi*p1), si2(2.*pi*p2),
1086  sj1(2.*pj*p1), sj2(2.*pj*p2), s12(2.*p1*p2);
1087  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
1088  double p2i1(sai + m2i + m21);
1089  double q2 = sign*(pi+p1+p2+sign*pj).m2Calc();
1090  double si12 = (pi+p1+p2).m2Calc();
1091  double yi12 = (splitInfo.recBef()->isFinal) ? si12 / q2 : 0.;
1092  double z1(z/(1.-yi12)), z2( z/xa/(1-yi12) - z1 ), z3(1-z1-z2);
1093 
1094  double prob = 0.0;
1095  // Endpoint
1096  if (is_sai_endpoint()) {
1097 
1098  double x = z1/(z1+z2);
1099  // Gluon contribution to cusp terms.
1100  prob = 2.0*CA*(log(x)/(1.0-x)+log(1.0-x)/x+(-2.0+x*(1.-x))*log(x*(1.-x)));
1101  // Additional contribution from si1 = 0.
1102  // (might want separate endpoint eventually).
1103  prob += -2.0*CA/2.0*(log(x)/(1.0-x)+log(1.0-x)/x);
1104 
1105  // Multiply with LO kernel.
1106  prob *= CF * (2.0/(1.0-z3*(1.0-yi12))-2.0);
1107 
1108  // Spectrum.
1109  } else {
1110 
1111  // Do nothing below PS cut-off on kT of intermediate gluon, since
1112  // never produced by PS, hence no underlying Born to correct.
1113  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)/(si1+si2+sj1+sj2+sij+s12);
1114 
1115  if ( abs(sai) < 1e-10 || splitInfo.terminateEvolution == true
1116  || kT12 < pow2(settingsPtr->parm("TimeShower:pTmin"))) {
1117  wts.insert( make_pair("base", 0.) );
1118  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1119  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1120  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1121  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1122  clearKernels();
1123  for ( unordered_map<string,double>::iterator it = wts.begin();
1124  it != wts.end();
1125  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
1126  return true;
1127  }
1128 
1129  // Multiplicative weight factor to force first eikonal to current
1130  // outgoing momenta.
1131  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
1132  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
1133  / (si1*sj1 + si2*sj2);
1134  double w = (1+wij12/wij12bar)/2.;
1135 
1136  // Short-hands.
1137  double strongOrder = (1. * ( sij/(si1*s12*sj2)
1138  + sij/(sj1*s12*si2)
1139  - sij*sij/(si1*sj1*si2*sj2)));
1140  double collB = sij/((si1+si2)*(sj1+sj2)) * 1./s12;
1141  double ct2 = pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
1142  double collA = ct2*collB;
1143  double loSquare = 2.0*CF/CA * w * pow2(sij)/(si1*sj1*si2*sj2);
1144 
1145  // Unsubtracted kernel.
1146  prob = w * strongOrder - 2.0*collB + collA + loSquare;
1147 
1148  // Subtractions for all possible histories.
1149  double subtTot(0.), subt(0.);
1150  int ncounter(0);
1151  subt = 0.25*counterTerm(si1,si2,sj1,sj2,sij,s12);
1152  if (subt != 0.) { ncounter++; subtTot += subt; }
1153  subt = 0.25*counterTerm(si2,si1,sj2,sj1,sij,s12);
1154  if (subt != 0.) { ncounter++; subtTot += subt; }
1155  subt = 0.25*counterTerm(sj1,sj2,si1,si2,sij,s12);
1156  if (subt != 0.) { ncounter++; subtTot += subt; }
1157  subt = 0.25*counterTerm(sj2,sj1,si2,si1,sij,s12);
1158  if (subt != 0.) { ncounter++; subtTot += subt; }
1159  prob -= subtTot;
1160 
1161  // Avoid numerical issues if all subtractions are active (->
1162  // integrand should be exactly zero)
1163  if (ncounter==4) prob = 0.;
1164 
1165  // Overall color factor.
1166  prob *= CF*CA*pow2(si1+si2+s12);
1167 
1168  }
1169 
1170  // From xa integration volume.
1171  prob *= log(1/z1);
1172  // Multiply by 2 since we randomly chose endpoint or fully differential.
1173  prob *= 2.0;
1174  // Weight of sai-selection.
1175  prob *= 1. / (1.-p2i1/si12);
1176 
1177  // Remember that this might be an endpoint with vanishing sai.
1178  if (is_sai_endpoint()) { splitInfo.set_sai(0.0); }
1179 
1180  // Insert value of kernel into kernel list.
1181  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
1182  if (doVariations) {
1183  // Create muR-variations.
1184  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
1185  wts.insert( make_pair("Variations:muRfsrDown", prob
1186  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1187  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
1188  renormMultFac) ));
1189  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
1190  wts.insert( make_pair("Variations:muRfsrUp", prob
1191  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1192  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
1193  renormMultFac) ));
1194  }
1195 
1196  // Multiply with z to project out part where emitted gluon pair is soft,
1197  // and quark is identified.
1198  for ( unordered_map<string,double>::iterator it = wts.begin();
1199  it != wts.end(); ++it )
1200  it->second *= z2/(1.-z3);
1201 
1202  // Store higher order correction separately.
1203  wts.insert( make_pair("base_order_as2", wts["base"] ));
1204 
1205  // Store kernel values.
1206  clearKernels();
1207  for ( unordered_map<string,double>::iterator it = wts.begin();
1208  it != wts.end(); ++it )
1209  kernelVals.insert(make_pair( it->first, it->second ));
1210 
1211  return true;
1212 
1213 }
1214 
1215 //==========================================================================
1216 
1217 // Return true if this kernel should partake in the evolution.
1218 bool Dire_fsr_qcd_G2GGG::canRadiate (const Event& state, pair<int,int> ints,
1219  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
1220  if (orderSave != 4) return false;
1221  return ( state[ints.first].isFinal()
1222  && state[ints.second].colType() != 0
1223  && hasSharedColor(state, ints.first, ints.second)
1224  && state[ints.first].id() == 21);
1225 }
1226 
1227 bool Dire_fsr_qcd_G2GGG::canRadiate (const Event& state, int iRadBef,
1228  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
1229  if (orderSave != 4) return false;
1230  return ( state[iRadBef].isFinal()
1231  && state[iRecBef].colType() != 0
1232  && hasSharedColor(state, iRadBef, iRecBef)
1233  && state[iRadBef].id() == 21);
1234 }
1235 
1236 // Dummy values, since not used!
1237 double Dire_fsr_qcd_G2GGG::gaugeFactor ( int, int ) { return 1.;}
1238 double Dire_fsr_qcd_G2GGG::symmetryFactor ( int, int ) { return 1.;}
1239 
1240 vector<pair<int,int> > Dire_fsr_qcd_G2GGG::radAndEmtCols(int iRad, int colType,
1241  Event state) {
1242 
1243  int newCol1 = state.nextColTag();
1244  int newCol2 = state.nextColTag();
1245  int colRadAft(0), acolRadAft(0), colEmtAft1(0), acolEmtAft1(0),
1246  colEmtAft2(0), acolEmtAft2(0);
1247  if (colType > 0) {
1248  colRadAft = newCol1;
1249  acolRadAft = 0;
1250  colEmtAft1 = state[iRad].col();
1251  acolEmtAft1 = newCol2;
1252  colEmtAft2 = newCol2;
1253  acolEmtAft2 = newCol1;
1254  } else {
1255  colRadAft = 0;
1256  acolRadAft = newCol1;
1257  colEmtAft1 = newCol2;
1258  acolEmtAft1 = state[iRad].acol();
1259  colEmtAft2 = newCol1;
1260  acolEmtAft2 = newCol2;
1261  }
1262 
1263  // Also remember colors for "intermediate" particles in 1->3 splitting.
1264  if ( colType > 0) {
1265  splitInfo.addExtra("colEmtInt", newCol1);
1266  splitInfo.addExtra("acolEmtInt", state[iRad].acol());
1267  splitInfo.addExtra("colRadInt", state[iRad].col());
1268  splitInfo.addExtra("acolRadInt", newCol1);
1269  } else {
1270  splitInfo.addExtra("colEmtInt", state[iRad].col());
1271  splitInfo.addExtra("acolEmtInt", newCol1);
1272  splitInfo.addExtra("colRadInt", newCol1);
1273  splitInfo.addExtra("acolRadInt", state[iRad].acol());
1274  }
1275 
1276  return createvector<pair<int,int> >
1277  (make_pair(colRadAft, acolRadAft))
1278  (make_pair(colEmtAft1, acolEmtAft1))
1279  (make_pair(colEmtAft2, acolEmtAft2));
1280 
1281 }
1282 
1283 int Dire_fsr_qcd_G2GGG::radBefID(int, int) {
1284  return 21;
1285 }
1286 
1287 pair<int,int> Dire_fsr_qcd_G2GGG::radBefCols(
1288  int, int,
1289  int, int) {
1290  return make_pair(0,0);
1291 }
1292 
1293 // Pick z for new splitting.
1294 double Dire_fsr_qcd_G2GGG::zSplit(double zMinAbs, double, double m2dip) {
1295  double R = rndmPtr->flat();
1296  // Pick according to soft + 1/(z+kappa2)
1297  double a = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1298 
1299 double zmin = zMinAbs;
1300 
1301 double z1 = (2*pow(a,R) + 4*pow(a,1 + R) + 2*pow(a,2 + R) +
1302  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1303  *pow(1/(a + zmin) + a/(a + zmin),2*R) -
1304  sqrt(pow(-2*pow(a,R) - 4*pow(a,1 + R) - 2*pow(a,2 + R) -
1305  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1306  *pow(1/(a + zmin) + a/(a + zmin),2*R),2) -
1307  4*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
1308  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
1309  *pow(1/(a + zmin) + a/(a + zmin),2*R))*
1310  (pow(a,R) + 3*pow(a,1 + R) + 3*pow(a,2 + R) + pow(a,3 + R) -
1311  pow(a,3)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1312  *pow(1/(a + zmin) + a/(a + zmin),2*R))))/
1313  (2.*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
1314  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
1315  *pow(1/(a + zmin) + a/(a + zmin),2*R)));
1316 
1317  return z1;
1318 
1319 }
1320 
1321 // New overestimates, z-integrated versions.
1322 double Dire_fsr_qcd_G2GGG::overestimateInt(double zMinAbs, double zMaxAbs,
1323  double, double m2dip, int orderNow) {
1324  double wt = 0.;
1325  int order = (orderNow > -1) ? orderNow : correctionOrder;
1326  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1327  // Overestimate by soft + 1/(z+kappa2)
1328  wt = CA/2.*CA * softRescaleInt(order) * 2.
1329  * 0.5 * ( log( (kappa2 + pow2(1-zMinAbs)) / (kappa2 + pow2(1-zMaxAbs)))
1330  + 2.*log( (kappa2+zMaxAbs)/(kappa2+zMinAbs)) );
1331 
1332  return wt;
1333 }
1334 
1335 // Return overestimate for new splitting.
1336 double Dire_fsr_qcd_G2GGG::overestimateDiff(double z, double m2dip,
1337  int orderNow) {
1338  double wt = 0.;
1339  int order = (orderNow > -1) ? orderNow : correctionOrder;
1340  double kappaOld2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1341  // Overestimate by soft + 1/(z+kappa2)
1342  wt = CA/2.*CA * softRescaleInt(order)
1343  * 2.* ((1.-z) / ( pow2(1.-z) + kappaOld2) + 1./(z+kappaOld2));
1344  return wt;
1345 }
1346 
1347 double Dire_fsr_qcd_G2GGG::counterTerm(double si1, double si2, double sj1,
1348  double sj2, double sij, double s12) {
1349 
1350  // Counter-term is zero in unordered phase space.
1351  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)
1352  / (si1+si2+sj1+sj2+sij+s12);
1353  double kTi12 = (si1*s12)/(si1+si2+s12);
1354  if (kTi12>kT12) return 0.0;
1355 
1356  // Multiplicative weight factor to force first eikonal to current
1357  // outgoing momenta.
1358  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
1359  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
1360  / (si1*sj1 + si2*sj2);
1361  double ct2 = pow2(si1*sj2-si2*sj1)/(s12*sij*(si1+si2)*(sj1+sj2));
1362 
1363  // Quark kernel.
1364  double gg1Soft = 2.*CA/2./CA * (2.*si2/(si1+s12) * (wij12+wij12bar)/2.);
1365  double gg1Coll = 0.;
1366  double gg1ColorCorr = 0.;
1367  // Gluon kernel.
1368  double gg2Soft = 2. * si2/(si1+s12) * (wij12+wij12bar)/2.;
1369  double gg2Coll = (-1. + ct2/2.0) * wij12;
1370  // Full counter-term
1371  double ct = 2.0 * ((gg1Soft+gg1Coll+gg1ColorCorr) / si1 +(gg2Soft+gg2Coll)
1372  / s12)
1373  * sij / ((si1+si2)*(sj1+sj2)-sij*s12);
1374 
1375  // Done.
1376  return ct;
1377 
1378 }
1379 
1380 // Return kernel for new splitting.
1381 bool Dire_fsr_qcd_G2GGG::calc(const Event& state, int orderNow) {
1382 
1383  // Dummy statement to avoid compiler warnings.
1384  if (false) cout << state[0].e() << orderNow << endl;
1385 
1386  // Read all splitting variables.
1387  double z(splitInfo.kinematics()->z),
1388  pT2(splitInfo.kinematics()->pT2),
1389  m2dip(splitInfo.kinematics()->m2Dip),
1390  xa(splitInfo.kinematics()->xa),
1391  sai(splitInfo.kinematics()->sai),
1392  m2i12(splitInfo.kinematics()->m2RadBef),
1393  m2i(splitInfo.kinematics()->m2RadAft),
1394  m21(splitInfo.kinematics()->m2EmtAft),
1395  m22(splitInfo.kinematics()->m2EmtAft2),
1396  m2j(splitInfo.kinematics()->m2Rec);
1397 
1398  splitInfo.addExtra("idRadInt",21);
1399  splitInfo.addExtra("idEmtInt",state[splitInfo.iRadBef].id());
1400  splitInfo.addExtra("swapped",1);
1401 
1402  // Calculate argument of alphaS.
1403  double scale2 = couplingScale2 ( z, pT2, m2dip,
1404  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
1405  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
1406  if (scale2 < 0.) scale2 = pT2;
1407 
1408  // Do nothing without other NLO kernels!
1409  unordered_map<string,double> wts;
1410  int order = (orderNow > -1) ? orderNow : correctionOrder;
1411  if ( order != 4 || m2i12 > 0. || m2i > 0. || m21 > 0. || m22 > 0.
1412  || m2j > 0.){
1413  wts.insert( make_pair("base", 0.) );
1414  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1415  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1416  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1417  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1418  clearKernels();
1419  for ( unordered_map<string,double>::iterator it = wts.begin();
1420  it != wts.end(); ++it )
1421  kernelVals.insert(make_pair( it->first, it->second ));
1422  return true;
1423  }
1424 
1425  // Generate state after branching to extract momenta.
1426  Event trialEvent(state);
1427  bool physical = false;
1428  if (splitInfo.recBef()->isFinal)
1429  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
1430  else
1431  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
1432  // Get invariants.
1433  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
1434  Vec4 pj(trialEvent[splitInfo.iRecAft].p());
1435  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
1436  Vec4 p2(trialEvent[splitInfo.iEmtAft2].p());
1437 
1438  // Use only massless for now!
1439  if ( sai > 0.
1440  && ( abs(pi.m2Calc()-m2i) > sai || abs(p1.m2Calc()-m21) > sai
1441  || abs(p2.m2Calc()-m22) > sai || abs(pj.m2Calc()-m2j) > sai))
1442  physical = false;
1443 
1444  if (!physical) {
1445  wts.insert( make_pair("base", 0.) );
1446  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1447  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1448  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1449  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1450  clearKernels();
1451  for ( unordered_map<string,double>::iterator it = wts.begin();
1452  it != wts.end(); ++it )
1453  kernelVals.insert(make_pair( it->first, it->second ));
1454  return true;
1455  }
1456 
1457  // Get invariants.
1458  double sij(2.*pi*pj), si1(2.*pi*p1), si2(2.*pi*p2),
1459  sj1(2.*pj*p1), sj2(2.*pj*p2), s12(2.*p1*p2);
1460 
1461  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
1462  double p2i1(sai + m2i + m21);
1463  double q2 = sign*(pi+p1+p2+sign*pj).m2Calc();
1464  double si12 = (pi+p1+p2).m2Calc();
1465  double yi12 = (splitInfo.recBef()->isFinal) ? si12 / q2 : 0.;
1466  double z1(z/(1.-yi12)), z2( z/xa/(1-yi12) - z1 ), z3(1-z1-z2);
1467 
1468  double prob = 0.0;
1469  // Endpoint
1470  if (is_sai_endpoint()) {
1471 
1472  double x(z1/(z1+z2));
1473  // Gluon contribution to cusp terms.
1474  prob = 2.0*CA*(log(x)/(1.0-x)+log(1.0-x)/x+(-2.0+x*(1.-x))*log(x*(1.-x)));
1475  // Additional contribution from si1 = 0.
1476  // (might want separate endpoint eventually).
1477  prob += -2.0*CA/2.0*(log(x)/(1.0-x)+log(1.0-x)/x);
1478 
1479  // Multiply with LO kernel.
1480  prob *= CA/2. * (2.0/(1.0-z3*(1.0-yi12))-2.0);
1481 
1482  // Spectrum.
1483  } else {
1484 
1485  // Do nothing below PS cut-off on kT of intermediate gluon, since
1486  // never produced by PS, hence no underlying Born to correct.
1487  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)/(si1+si2+sj1+sj2+sij+s12);
1488  if ( abs(sai) < 1e-10 || splitInfo.terminateEvolution == true
1489  || kT12 < pow2(settingsPtr->parm("TimeShower:pTmin"))) {
1490  wts.insert( make_pair("base", 0.) );
1491  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1492  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1493  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1494  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1495  clearKernels();
1496  for ( unordered_map<string,double>::iterator it = wts.begin();
1497  it != wts.end();
1498  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
1499  return true;
1500  }
1501 
1502  // Multiplicative weight factor to force first eikonal to current
1503  // outgoing momenta.
1504  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
1505  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
1506  / (si1*sj1 + si2*sj2);
1507  double w = (1+wij12/wij12bar)/2.;
1508 
1509  // Short-hands.
1510  double strongOrder = (1. * ( sij/(si1*s12*sj2)
1511  + sij/(sj1*s12*si2)
1512  - sij*sij/(si1*sj1*si2*sj2)));
1513  double collB = sij/((si1+si2)*(sj1+sj2)) * 1./s12;
1514  double ct2 = pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
1515  double collA = ct2*collB;
1516  double loSquare = 2.0*CA/2./CA * w * pow2(sij)/(si1*sj1*si2*sj2);
1517 
1518  // Unsubtracted kernel.
1519  prob = w * strongOrder - 2.0*collB + collA + loSquare;
1520 
1521  // Subtractions for all possible histories.
1522  double subtTot(0.), subt(0.);
1523  int ncounter(0);
1524  subt = 0.25*counterTerm(si1,si2,sj1,sj2,sij,s12);
1525  if (subt != 0.) { ncounter++; subtTot += subt; }
1526  subt = 0.25*counterTerm(si2,si1,sj2,sj1,sij,s12);
1527  if (subt != 0.) { ncounter++; subtTot += subt; }
1528  subt = 0.25*counterTerm(sj1,sj2,si1,si2,sij,s12);
1529  if (subt != 0.) { ncounter++; subtTot += subt; }
1530  subt = 0.25*counterTerm(sj2,sj1,si2,si1,sij,s12);
1531  if (subt != 0.) { ncounter++; subtTot += subt; }
1532  prob -= subtTot;
1533 
1534  // Avoid numerical issues if all subtractions are active (->
1535  // integrand should be exactly zero)
1536  if (ncounter==4) prob = 0.;
1537 
1538  // Overall color factor.
1539  prob *= CA/2.*CA*pow2(si1+si2+s12);
1540 
1541  // Kernel.
1542  }
1543 
1544  // From xa integration volume.
1545  prob *= log(1/z1);
1546  // Multiply by 2 since we randomly chose endpoint or fully differential.
1547  prob *= 2.0;
1548  // Weight of sai-selection.
1549  prob *= 1. / (1.-p2i1/si12);
1550 
1551  // Remember that this might be an endpoint with vanishing sai.
1552  if (is_sai_endpoint()) { splitInfo.set_sai(0.0); }
1553 
1554  // Insert value of kernel into kernel list.
1555  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
1556  if (doVariations) {
1557  // Create muR-variations.
1558  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
1559  wts.insert( make_pair("Variations:muRfsrDown", prob
1560  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1561  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
1562  renormMultFac) ));
1563  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
1564  wts.insert( make_pair("Variations:muRfsrUp", prob
1565  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1566  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
1567  renormMultFac) ));
1568  }
1569 
1570  // Multiply with z to project out part where emitted gluon pair is soft,
1571  // and quark is identified.
1572  for ( unordered_map<string,double>::iterator it = wts.begin();
1573  it != wts.end(); ++it )
1574  it->second *= z2/(1.-z3);
1575 
1576  // Store higher order correction separately.
1577  wts.insert( make_pair("base_order_as2", wts["base"] ));
1578 
1579  // Store kernel values and return.
1580  clearKernels();
1581  for (unordered_map<string,double>::iterator it = wts.begin();
1582  it != wts.end(); ++it)
1583  kernelVals.insert(make_pair( it->first, it->second));
1584  return true;
1585 
1586 }
1587 
1588 //==========================================================================
1589 
1590 // Return true if this kernel should partake in the evolution.
1591 bool Dire_fsr_qcd_Q2Qqqbar::canRadiate (const Event& state, pair<int,int> ints,
1592  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
1593  if (orderSave != 4) return false;
1594  return ( state[ints.first].isFinal()
1595  && state[ints.second].colType() != 0
1596  && hasSharedColor(state, ints.first, ints.second)
1597  && state[ints.first].isQuark() );
1598 }
1599 
1600 bool Dire_fsr_qcd_Q2Qqqbar::canRadiate (const Event& state, int iRadBef,
1601  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
1602  if (orderSave != 4) return false;
1603  return ( state[iRadBef].isFinal()
1604  && state[iRecBef].colType() != 0
1605  && hasSharedColor(state, iRadBef, iRecBef)
1606  && state[iRadBef].isQuark());
1607 }
1608 
1609 // Dummy values, since not used!
1610 double Dire_fsr_qcd_Q2Qqqbar::gaugeFactor ( int, int ) { return 1.;}
1611 double Dire_fsr_qcd_Q2Qqqbar::symmetryFactor ( int, int ) { return 1.;}
1612 
1613 vector<pair<int,int> > Dire_fsr_qcd_Q2Qqqbar::radAndEmtCols(int iRad,
1614  int colType, Event state) {
1615 
1616  int typeEmt = (idEmtAfterSave > 0) ? 1 : -1;
1617  int newCol1 = state.nextColTag();
1618  int colRadAft(0), acolRadAft(0), colEmtAft1(0), acolEmtAft1(0),
1619  colEmtAft2(0), acolEmtAft2(0);
1620  if (colType > 0) {
1621  colRadAft = newCol1;
1622  acolRadAft = 0;
1623  colEmtAft1 = (typeEmt > 0) ? state[iRad].col() : 0;
1624  acolEmtAft1 = (typeEmt > 0) ? 0 : newCol1;
1625  colEmtAft2 = (typeEmt > 0) ? 0 : state[iRad].col();
1626  acolEmtAft2 = (typeEmt > 0) ? newCol1 : 0;
1627  } else {
1628  colRadAft = 0;
1629  acolRadAft = newCol1;
1630  colEmtAft1 = (typeEmt < 0) ? 0 : newCol1;
1631  acolEmtAft1 = (typeEmt < 0) ? state[iRad].acol() : 0;
1632  colEmtAft2 = (typeEmt < 0) ? newCol1 : 0;
1633  acolEmtAft2 = (typeEmt < 0) ? 0 : state[iRad].acol();
1634  }
1635 
1636  // Also remember colors for "intermediate" particles in 1->3 splitting.
1637  if ( colType > 0) {
1638  splitInfo.addExtra("colEmtInt", newCol1);
1639  splitInfo.addExtra("acolEmtInt", state[iRad].acol());
1640  splitInfo.addExtra("colRadInt", state[iRad].col());
1641  splitInfo.addExtra("acolRadInt", newCol1);
1642  } else {
1643  splitInfo.addExtra("colEmtInt", state[iRad].col());
1644  splitInfo.addExtra("acolEmtInt", newCol1);
1645  splitInfo.addExtra("colRadInt", newCol1);
1646  splitInfo.addExtra("acolRadInt", state[iRad].acol());
1647  }
1648 
1649  return createvector<pair<int,int> >
1650  (make_pair(colRadAft, acolRadAft))
1651  (make_pair(colEmtAft1, acolEmtAft1))
1652  (make_pair(colEmtAft2, acolEmtAft2));
1653 
1654 }
1655 
1656 int Dire_fsr_qcd_Q2Qqqbar::radBefID(int idRA, int) {
1657  if (particleDataPtr->isQuark(idRA)) return idRA;
1658  return 0;
1659 }
1660 
1661 pair<int,int> Dire_fsr_qcd_Q2Qqqbar::radBefCols(
1662  int, int,
1663  int, int) {
1664  return make_pair(0,0);
1665 }
1666 
1667 // Pick z for new splitting.
1668 double Dire_fsr_qcd_Q2Qqqbar::zSplit(double zMinAbs, double, double m2dip) {
1669  double R = rndmPtr->flat();
1670  // Pick according to soft + 1/(z+kappa2)
1671  double a = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1672 
1673 double zmin = zMinAbs;
1674 
1675 double z1 = (2*pow(a,R) + 4*pow(a,1 + R) + 2*pow(a,2 + R) +
1676  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1677  *pow(1/(a + zmin) + a/(a + zmin),2*R) -
1678  sqrt(pow(-2*pow(a,R) - 4*pow(a,1 + R) - 2*pow(a,2 + R) -
1679  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1680  *pow(1/(a + zmin) + a/(a + zmin),2*R),2) -
1681  4*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
1682  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
1683  *pow(1/(a + zmin) + a/(a + zmin),2*R))*
1684  (pow(a,R) + 3*pow(a,1 + R) + 3*pow(a,2 + R) + pow(a,3 + R) -
1685  pow(a,3)*pow(1 + a - 2*zmin + pow(zmin,2),R)
1686  *pow(1/(a + zmin) + a/(a + zmin),2*R))))/
1687  (2.*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
1688  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
1689  *pow(1/(a + zmin) + a/(a + zmin),2*R)));
1690 
1691  return z1;
1692 
1693 }
1694 
1695 // New overestimates, z-integrated versions.
1696 double Dire_fsr_qcd_Q2Qqqbar::overestimateInt(double zMinAbs, double zMaxAbs,
1697  double, double m2dip, int orderNow) {
1698  double wt = 0.;
1699  int order = (orderNow > -1) ? orderNow : correctionOrder;
1700  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1701  // Overestimate by soft + 1/(z+kappa2)
1702  wt = CF*TR * softRescaleInt(order) * 2.
1703  * 0.5 * ( log( (kappa2 + pow2(1-zMinAbs)) / (kappa2 + pow2(1-zMaxAbs)))
1704  + 2.*log( (kappa2+zMaxAbs)/(kappa2+zMinAbs)) );
1705 
1706  return wt;
1707 }
1708 
1709 // Return overestimate for new splitting.
1710 double Dire_fsr_qcd_Q2Qqqbar::overestimateDiff(double z, double m2dip,
1711  int orderNow) {
1712  double wt = 0.;
1713  int order = (orderNow > -1) ? orderNow : correctionOrder;
1714  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
1715  // Overestimate by soft + 1/(z+kappa2)
1716  wt = CF*TR * softRescaleInt(order)
1717  * 2.* ((1.-z) / ( pow2(1.-z) + kappa2) + 1./(z+kappa2));
1718  return wt;
1719 }
1720 
1721 double Dire_fsr_qcd_Q2Qqqbar::counterTerm(double si1, double si2, double sj1,
1722  double sj2, double sij, double s12) {
1723 
1724  // Counter-term is zero in unordered phase space.
1725  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)
1726  / (si1+si2+sj1+sj2+sij+s12);
1727  double kTi12 = (si1*s12)/(si1+si2+s12);
1728  if (kTi12>kT12) return 0.0;
1729 
1730  // Multiplicative weight factor to force first eikonal to current
1731  // outgoing momenta.
1732  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
1733  double ct2 = pow2(si1*sj2-si2*sj1)/(s12*sij*(si1+si2)*(sj1+sj2));
1734 
1735  // Gluon kernel.
1736  double gqColl = (1. - ct2) * wij12;
1737  // Full counter-term
1738  double ct = 2. * gqColl / s12 * sij / ((si1+si2)*(sj1+sj2)-sij*s12);
1739 
1740  return ct;
1741 
1742 }
1743 
1744 // Return kernel for new splitting.
1745 bool Dire_fsr_qcd_Q2Qqqbar::calc(const Event& state, int orderNow) {
1746 
1747  // Dummy statement to avoid compiler warnings.
1748  if (false) cout << state[0].e() << orderNow << endl;
1749 
1750  // Read all splitting variables.
1751  double z(splitInfo.kinematics()->z),
1752  pT2(splitInfo.kinematics()->pT2),
1753  m2dip(splitInfo.kinematics()->m2Dip),
1754  xa(splitInfo.kinematics()->xa),
1755  sai(splitInfo.kinematics()->sai),
1756  m2i12(splitInfo.kinematics()->m2RadBef),
1757  m2i(splitInfo.kinematics()->m2RadAft),
1758  m21(splitInfo.kinematics()->m2EmtAft),
1759  m22(splitInfo.kinematics()->m2EmtAft2),
1760  m2j(splitInfo.kinematics()->m2Rec);
1761 
1762  splitInfo.addExtra("idRadInt",21);
1763  splitInfo.addExtra("idEmtInt",state[splitInfo.iRadBef].id());
1764  splitInfo.addExtra("swapped",1);
1765 
1766  // Calculate argument of alphaS.
1767  double scale2 = couplingScale2 ( z, pT2, m2dip,
1768  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
1769  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
1770  if (scale2 < 0.) scale2 = pT2;
1771 
1772  // Do nothing without other NLO kernels!
1773  unordered_map<string,double> wts;
1774  int order = (orderNow > -1) ? orderNow : correctionOrder;
1775  if ( order!= 4 || m2i12 > 0. || m2i > 0. || m21 > 0. || m22 > 0.
1776  || m2j > 0.){
1777  wts.insert( make_pair("base", 0.) );
1778  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1779  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1780  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1781  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1782  clearKernels();
1783  for ( unordered_map<string,double>::iterator it = wts.begin();
1784  it != wts.end(); ++it )
1785  kernelVals.insert(make_pair( it->first, it->second ));
1786  return true;
1787  }
1788 
1789  // Generate state after branching to extract momenta.
1790  Event trialEvent(state);
1791  bool physical = false;
1792  if (splitInfo.recBef()->isFinal)
1793  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
1794  else
1795  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
1796  // Get invariants.
1797  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
1798  Vec4 pj(trialEvent[splitInfo.iRecAft].p());
1799  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
1800  Vec4 p2(trialEvent[splitInfo.iEmtAft2].p());
1801 
1802  // Use only massless for now!
1803  if ( sai > 0.
1804  && ( abs(pi.m2Calc()-m2i) > sai || abs(p1.m2Calc()-m21) > sai
1805  || abs(p2.m2Calc()-m22) > sai || abs(pj.m2Calc()-m2j) > sai))
1806  physical = false;
1807 
1808  if (!physical) {
1809  wts.insert( make_pair("base", 0.) );
1810  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1811  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1812  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1813  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1814  clearKernels();
1815  for ( unordered_map<string,double>::iterator it = wts.begin();
1816  it != wts.end(); ++it )
1817  kernelVals.insert(make_pair( it->first, it->second ));
1818  return true;
1819  }
1820 
1821  // Get invariants.
1822  double sij(2.*pi*pj), si1(2.*pi*p1), si2(2.*pi*p2),
1823  sj1(2.*pj*p1), sj2(2.*pj*p2), s12(2.*p1*p2);
1824 
1825  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
1826  double p2i1(sai + m2i + m21);
1827  double q2 = sign*(pi+p1+p2+sign*pj).m2Calc();
1828  double si12 = (pi+p1+p2).m2Calc();
1829  double yi12 = (splitInfo.recBef()->isFinal) ? si12 / q2 : 0.;
1830  double z1(z/(1.-yi12)), z2( z/xa/(1-yi12) - z1 ), z3(1-z1-z2);
1831 
1832  double prob = 0.0;
1833  // Endpoint
1834  if (is_sai_endpoint()) {
1835 
1836  double x = z1/(z1+z2);
1837  // Quark contribution to cusp terms.
1838  prob = TR*(2.0*x*(1.-x)+(1.0-2.0*x*(1.-x))*log(x*(1.-x)));
1839 
1840  // Multiply with LO kernel.
1841  prob *= CF * (2.0/(1.0-z3*(1.0-yi12))-2.0);
1842 
1843  // Endpoint contribution zero below kinematical threshold.
1844  if (getNF(pT2) < abs(idEmtAfterSave)) prob = 0.;
1845 
1846  // Spectrum.
1847  } else {
1848 
1849  // Do nothing below PS cut-off on kT of intermediate gluon, since
1850  // never produced by PS, hence no underlying Born to correct.
1851  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)/(si1+si2+sj1+sj2+sij+s12);
1852  if ( abs(sai) < 1e-10
1853  || kT12 < pow2(settingsPtr->parm("TimeShower:pTmin")) ) {
1854  wts.insert( make_pair("base", 0.) );
1855  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
1856  wts.insert( make_pair("Variations:muRfsrDown", 0.));
1857  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
1858  wts.insert( make_pair("Variations:muRfsrUp", 0.));
1859  clearKernels();
1860  for ( unordered_map<string,double>::iterator it = wts.begin();
1861  it != wts.end();
1862  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
1863  return true;
1864  }
1865 
1866  // Unsubtracted kernel.
1867  prob = 2.0*sij/(s12*(si1+si2)*(sj1+sj2))
1868  - 2.0*pow2(sj1*si2-sj2*si1)/pow2(s12*(si1+si2)*(sj1+sj2));
1869 
1870  // Subtractions for all possible histories.
1871  double subt = 0.;
1872  subt += 0.25*counterTerm(si1,si2,sj1,sj2,sij,s12);
1873  subt += 0.25*counterTerm(si2,si1,sj2,sj1,sij,s12);
1874  subt += 0.25*counterTerm(sj1,sj2,si1,si2,sij,s12);
1875  subt += 0.25*counterTerm(sj2,sj1,si2,si1,sij,s12);
1876  prob -= subt;
1877 
1878  // Overall color factor.
1879  prob *= CF*TR*pow2(si1+si2+s12);
1880 
1881  }
1882 
1883  // From xa integration volume.
1884  prob *= log(1/z1);
1885  // Multiply by 2 since we randomly chose endpoint or fully differential.
1886  prob *= 2.0;
1887  // Weight of sai-selection.
1888  prob *= 1. / (1.-p2i1/si12);
1889 
1890  // Remember that this might be an endpoint with vanishing sai.
1891  if (is_sai_endpoint()) { splitInfo.set_sai(0.0); }
1892 
1893  // Insert value of kernel into kernel list.
1894  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
1895  if (doVariations) {
1896  // Create muR-variations.
1897  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
1898  wts.insert( make_pair("Variations:muRfsrDown", prob
1899  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1900  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
1901  renormMultFac) ));
1902  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
1903  wts.insert( make_pair("Variations:muRfsrUp", prob
1904  * as2Pi(scale2, order, (scale2 > pT2minVariations)
1905  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
1906  renormMultFac) ));
1907  }
1908 
1909  // Multiply with z to project out part where emitted gluon pair is soft,
1910  // and quark is identified.
1911  for ( unordered_map<string,double>::iterator it = wts.begin();
1912  it != wts.end(); ++it )
1913  it->second *= z2/(1.-z3);
1914 
1915  // Store higher order correction separately.
1916  wts.insert( make_pair("base_order_as2", wts["base"] ));
1917 
1918  // Store kernel values and return.
1919  clearKernels();
1920  for (unordered_map<string,double>::iterator it = wts.begin();
1921  it != wts.end(); ++it)
1922  kernelVals.insert(make_pair( it->first, it->second));
1923 
1924  return true;
1925 
1926 }
1927 
1928 //==========================================================================
1929 
1930 // Return true if this kernel should partake in the evolution.
1931 bool Dire_fsr_qcd_G2Gqqbar::canRadiate (const Event& state, pair<int,int> ints,
1932  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
1933  if (orderSave != 4) return false;
1934  return ( state[ints.first].isFinal()
1935  && state[ints.second].colType() != 0
1936  && hasSharedColor(state, ints.first, ints.second)
1937  && state[ints.first].id() == 21);
1938 }
1939 
1940 bool Dire_fsr_qcd_G2Gqqbar::canRadiate (const Event& state, int iRadBef,
1941  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
1942  if (orderSave != 4) return false;
1943  return ( state[iRadBef].isFinal()
1944  && state[iRecBef].colType() != 0
1945  && hasSharedColor(state, iRadBef, iRecBef)
1946  && state[iRadBef].id() == 21);
1947 }
1948 
1949 // Dummy values, since not used!
1950 double Dire_fsr_qcd_G2Gqqbar::gaugeFactor ( int, int ) { return 1.;}
1951 double Dire_fsr_qcd_G2Gqqbar::symmetryFactor ( int, int ) { return 1.;}
1952 
1953 vector<pair<int,int> > Dire_fsr_qcd_G2Gqqbar::radAndEmtCols(int iRad,
1954  int colType, Event state) {
1955 
1956  int typeEmt = (idEmtAfterSave > 0) ? 1 : -1;
1957  int newCol1 = state.nextColTag();
1958  int colRadAft(0), acolRadAft(0), colEmtAft1(0), acolEmtAft1(0),
1959  colEmtAft2(0), acolEmtAft2(0);
1960  if (colType > 0) {
1961  colRadAft = newCol1;
1962  acolRadAft = 0;
1963  colEmtAft1 = (typeEmt > 0) ? state[iRad].col() : 0;
1964  acolEmtAft1 = (typeEmt > 0) ? 0 : newCol1;
1965  colEmtAft2 = (typeEmt > 0) ? 0 : state[iRad].col();
1966  acolEmtAft2 = (typeEmt > 0) ? newCol1 : 0;
1967  } else {
1968  colRadAft = 0;
1969  acolRadAft = newCol1;
1970  colEmtAft1 = (typeEmt < 0) ? newCol1 : 0;
1971  acolEmtAft1 = (typeEmt < 0) ? 0 : state[iRad].acol();
1972  colEmtAft2 = (typeEmt < 0) ? 0 : newCol1;
1973  acolEmtAft2 = (typeEmt < 0) ? state[iRad].acol() : 0;
1974  }
1975 
1976  // Also remember colors for "intermediate" particles in 1->3 splitting.
1977  if ( colType > 0) {
1978  splitInfo.addExtra("colEmtInt", newCol1);
1979  splitInfo.addExtra("acolEmtInt", state[iRad].acol());
1980  splitInfo.addExtra("colRadInt", state[iRad].col());
1981  splitInfo.addExtra("acolRadInt", newCol1);
1982  } else {
1983  splitInfo.addExtra("colEmtInt", state[iRad].col());
1984  splitInfo.addExtra("acolEmtInt", newCol1);
1985  splitInfo.addExtra("colRadInt", newCol1);
1986  splitInfo.addExtra("acolRadInt", state[iRad].acol());
1987  }
1988 
1989  return createvector<pair<int,int> >
1990  (make_pair(colRadAft, acolRadAft))
1991  (make_pair(colEmtAft1, acolEmtAft1))
1992  (make_pair(colEmtAft2, acolEmtAft2));
1993 
1994 }
1995 
1996 int Dire_fsr_qcd_G2Gqqbar::radBefID(int, int) {
1997  return 21;
1998 }
1999 
2000 pair<int,int> Dire_fsr_qcd_G2Gqqbar::radBefCols(
2001  int, int,
2002  int, int) {
2003  return make_pair(0,0);
2004 }
2005 
2006 
2007 // Pick z for new splitting.
2008 double Dire_fsr_qcd_G2Gqqbar::zSplit(double zMinAbs, double, double m2dip) {
2009  double R = rndmPtr->flat();
2010  // Pick according to soft + 1/(z+kappa2)
2011  double a = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2012 double zmin = zMinAbs;
2013 double z1 = (2*pow(a,R) + 4*pow(a,1 + R) + 2*pow(a,2 + R) +
2014  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
2015  *pow(1/(a + zmin) + a/(a + zmin),2*R) -
2016  sqrt(pow(-2*pow(a,R) - 4*pow(a,1 + R) - 2*pow(a,2 + R) -
2017  2*pow(a,2)*pow(1 + a - 2*zmin + pow(zmin,2),R)
2018  *pow(1/(a + zmin) + a/(a + zmin),2*R),2) -
2019  4*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
2020  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
2021  *pow(1/(a + zmin) + a/(a + zmin),2*R))*
2022  (pow(a,R) + 3*pow(a,1 + R) + 3*pow(a,2 + R) + pow(a,3 + R) -
2023  pow(a,3)*pow(1 + a - 2*zmin + pow(zmin,2),R)
2024  *pow(1/(a + zmin) + a/(a + zmin),2*R))))/
2025  (2.*(pow(a,R) + 2*pow(a,1 + R) + pow(a,2 + R) -
2026  a*pow(1 + a - 2*zmin + pow(zmin,2),R)
2027  *pow(1/(a + zmin) + a/(a + zmin),2*R)));
2028 
2029  return z1;
2030 }
2031 
2032 // New overestimates, z-integrated versions.
2033 double Dire_fsr_qcd_G2Gqqbar::overestimateInt(double zMinAbs, double zMaxAbs,
2034  double, double m2dip, int orderNow) {
2035  double wt = 0.;
2036  int order = (orderNow > -1) ? orderNow : correctionOrder;
2037  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2038  // Overestimate by soft + 1/(z+kappa2)
2039  wt = CA/2.*TR * softRescaleInt(order) * 2.
2040  * 0.5 * ( log( (kappa2 + pow2(1-zMinAbs)) / (kappa2 + pow2(1-zMaxAbs)))
2041  + 2.*log( (kappa2+zMaxAbs)/(kappa2+zMinAbs)) );
2042 
2043  return wt;
2044 
2045 }
2046 
2047 // Return overestimate for new splitting.
2048 double Dire_fsr_qcd_G2Gqqbar::overestimateDiff(double z, double m2dip,
2049  int orderNow) {
2050  double wt = 0.;
2051  int order = (orderNow > -1) ? orderNow : correctionOrder;
2052  double kappa2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2053  // Overestimate by soft + 1/(z+kappa2)
2054  wt = CA/2.*TR * softRescaleInt(order)
2055  * 2.* ((1.-z) / ( pow2(1.-z) + kappa2) + 1./(z+kappa2));
2056  return wt;
2057 }
2058 
2059 double Dire_fsr_qcd_G2Gqqbar::counterTerm(double si1, double si2, double sj1,
2060  double sj2, double sij, double s12) {
2061 
2062  // Counter-term is zero in unordered phase space.
2063  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)
2064  / (si1+si2+sj1+sj2+sij+s12);
2065  double kTi12 = (si1*s12)/(si1+si2+s12);
2066  if (kTi12>kT12) return 0.0;
2067 
2068  // Multiplicative weight factor to force first eikonal to current
2069  // outgoing momenta.
2070  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
2071  double ct2 = pow2(si1*sj2-si2*sj1)/(s12*sij*(si1+si2)*(sj1+sj2));
2072 
2073  // Gluon kernel.
2074  double gqColl = (1. - ct2) * wij12;
2075  // Full counter-term
2076  double ct = 2. * gqColl / s12 * sij / ((si1+si2)*(sj1+sj2)-sij*s12);
2077 
2078  return ct;
2079 
2080 }
2081 
2082 // Return kernel for new splitting.
2083 bool Dire_fsr_qcd_G2Gqqbar::calc(const Event& state, int orderNow) {
2084 
2085  // Dummy statement to avoid compiler warnings.
2086  if (false) cout << state[0].e() << orderNow << endl;
2087 
2088  // Read all splitting variables.
2089  double z(splitInfo.kinematics()->z),
2090  pT2(splitInfo.kinematics()->pT2),
2091  m2dip(splitInfo.kinematics()->m2Dip),
2092  xa(splitInfo.kinematics()->xa),
2093  sai(splitInfo.kinematics()->sai),
2094  m2i12(splitInfo.kinematics()->m2RadBef),
2095  m2i(splitInfo.kinematics()->m2RadAft),
2096  m21(splitInfo.kinematics()->m2EmtAft),
2097  m22(splitInfo.kinematics()->m2EmtAft2),
2098  m2j(splitInfo.kinematics()->m2Rec);
2099 
2100  splitInfo.addExtra("idRadInt",21);
2101  splitInfo.addExtra("idEmtInt",state[splitInfo.iRadBef].id());
2102  splitInfo.addExtra("swapped",1);
2103 
2104  // Calculate argument of alphaS.
2105  double scale2 = couplingScale2 ( z, pT2, m2dip,
2106  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
2107  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
2108  if (scale2 < 0.) scale2 = pT2;
2109 
2110  // Do nothing without other NLO kernels!
2111  unordered_map<string,double> wts;
2112  int order = (orderNow > -1) ? orderNow : correctionOrder;
2113  if ( order != 4 || m2i12 > 0. || m2i > 0. || m21 > 0. || m22 > 0.
2114  || m2j > 0.){
2115  wts.insert( make_pair("base", 0.) );
2116  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
2117  wts.insert( make_pair("Variations:muRfsrDown", 0.));
2118  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
2119  wts.insert( make_pair("Variations:muRfsrUp", 0.));
2120  clearKernels();
2121  for ( unordered_map<string,double>::iterator it = wts.begin();
2122  it != wts.end(); ++it )
2123  kernelVals.insert(make_pair( it->first, it->second ));
2124  return true;
2125  }
2126 
2127  // Generate state after branching to extract momenta.
2128  Event trialEvent(state);
2129  bool physical = false;
2130  if (splitInfo.recBef()->isFinal)
2131  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
2132  else
2133  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
2134  // Get invariants.
2135  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
2136  Vec4 pj(trialEvent[splitInfo.iRecAft].p());
2137  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
2138  Vec4 p2(trialEvent[splitInfo.iEmtAft2].p());
2139 
2140  // Use only massless for now!
2141  if ( sai > 0.
2142  && ( abs(pi.m2Calc()-m2i) > sai || abs(p1.m2Calc()-m21) > sai
2143  || abs(p2.m2Calc()-m22) > sai || abs(pj.m2Calc()-m2j) > sai))
2144  physical = false;
2145 
2146  if (!physical) {
2147  wts.insert( make_pair("base", 0.) );
2148  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
2149  wts.insert( make_pair("Variations:muRfsrDown", 0.));
2150  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
2151  wts.insert( make_pair("Variations:muRfsrUp", 0.));
2152  clearKernels();
2153  for ( unordered_map<string,double>::iterator it = wts.begin();
2154  it != wts.end(); ++it )
2155  kernelVals.insert(make_pair( it->first, it->second ));
2156  return true;
2157  }
2158 
2159  // Get invariants.
2160  double sij(2.*pi*pj), si1(2.*pi*p1), si2(2.*pi*p2),
2161  sj1(2.*pj*p1), sj2(2.*pj*p2), s12(2.*p1*p2);
2162 
2163  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
2164  double p2i1(sai + m2i + m21);
2165  double q2 = sign*(pi+p1+p2+sign*pj).m2Calc();
2166  double si12 = (pi+p1+p2).m2Calc();
2167  double yi12 = (splitInfo.recBef()->isFinal) ? si12 / q2 : 0.;
2168  double z1(z/(1.-yi12)), z2( z/xa/(1-yi12) - z1 ), z3(1-z1-z2);
2169 
2170  double prob = 0.0;
2171  // Endpoint
2172  if (is_sai_endpoint()) {
2173 
2174  double x = z1/(z1+z2);
2175  // Quark contribution to cusp terms.
2176  prob = TR*(2.0*x*(1.-x)+(1.0-2.0*x*(1.-x))*log(x*(1.-x)));
2177 
2178  // Multiply with LO kernel.
2179  prob *= CA/2. * (2.0/(1.0-z3*(1.0-yi12))-2.0);
2180 
2181  // Endpoint contribution zero below kinematical threshold.
2182  if (getNF(pT2) < abs(idEmtAfterSave)) prob = 0.;
2183 
2184  // Spectrum.
2185  } else {
2186 
2187  // Do nothing below PS cut-off on kT of intermediate gluon, since
2188  // never produced by PS, hence no underlying Born to correct.
2189  double kT12 = ((si1+si2)*(sj1+sj2)-sij*s12)/(si1+si2+sj1+sj2+sij+s12);
2190  if ( abs(sai) < 1e-10
2191  || kT12 < pow2(settingsPtr->parm("TimeShower:pTmin")) ) {
2192  wts.insert( make_pair("base", 0.) );
2193  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
2194  wts.insert( make_pair("Variations:muRfsrDown", 0.));
2195  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
2196  wts.insert( make_pair("Variations:muRfsrUp", 0.));
2197  clearKernels();
2198  for ( unordered_map<string,double>::iterator it = wts.begin();
2199  it != wts.end();
2200  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
2201  return true;
2202  }
2203 
2204  // Unsubtracted kernel.
2205  prob = 2.0*sij/(s12*(si1+si2)*(sj1+sj2))
2206  - 2.0*pow2(sj1*si2-sj2*si1)/pow2(s12*(si1+si2)*(sj1+sj2));
2207 
2208  // Subtractions for all possible histories.
2209  double subt = 0.;
2210  subt += 0.25*counterTerm(si1,si2,sj1,sj2,sij,s12);
2211  subt += 0.25*counterTerm(si2,si1,sj2,sj1,sij,s12);
2212  subt += 0.25*counterTerm(sj1,sj2,si1,si2,sij,s12);
2213  subt += 0.25*counterTerm(sj2,sj1,si2,si1,sij,s12);
2214  prob -= subt;
2215 
2216  // Overall color factor.
2217  prob *= CA/2.*TR*pow2(si1+si2+s12);
2218 
2219  // Kernel.
2220  }
2221 
2222  // From xa integration volume.
2223  prob *= log(1/z1);
2224  // Multiply by 2 since we randomly chose endpoint or fully differential.
2225  prob *= 2.0;
2226  // Weight of sai-selection.
2227  prob *= 1. / (1.-p2i1/si12);
2228 
2229  // Remember that this might be an endpoint with vanishing sai.
2230  if (is_sai_endpoint()) { splitInfo.set_sai(0.0); }
2231 
2232  // Insert value of kernel into kernel list.
2233  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
2234  if (doVariations) {
2235  // Create muR-variations.
2236  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
2237  wts.insert( make_pair("Variations:muRfsrDown", prob
2238  * as2Pi(scale2, order, (scale2 > pT2minVariations)
2239  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
2240  renormMultFac) ));
2241  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
2242  wts.insert( make_pair("Variations:muRfsrUp", prob
2243  * as2Pi(scale2, order, (scale2 > pT2minVariations)
2244  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
2245  renormMultFac) ));
2246  }
2247 
2248  // Multiply with z to project out part where emitted gluon pair is soft,
2249  // and quark is identified.
2250  for ( unordered_map<string,double>::iterator it = wts.begin();
2251  it != wts.end(); ++it )
2252  it->second *= z2/(1.-z3);
2253 
2254  // Store higher order correction separately.
2255  wts.insert( make_pair("base_order_as2", wts["base"] ));
2256 
2257  // Store kernel values and return.
2258  clearKernels();
2259  for (unordered_map<string,double>::iterator it = wts.begin();
2260  it != wts.end(); ++it)
2261  kernelVals.insert(make_pair( it->first, it->second));
2262 
2263  return true;
2264 
2265 }
2266 
2267 //==========================================================================
2268 
2269 // Class inheriting from SplittingQCD class.
2270 
2271 // SplittingQCD function Q->QG (FSR)
2272 
2273 // Return true if this kernel should partake in the evolution.
2274 bool Dire_fsr_qcd_Q2QG::canRadiate ( const Event& state, pair<int,int> ints,
2275  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
2276  return ( state[ints.first].isFinal()
2277  && state[ints.second].colType() != 0
2278  && hasSharedColor(state, ints.first, ints.second)
2279  && state[ints.first].isQuark() );
2280 }
2281 
2282 bool Dire_fsr_qcd_Q2QG::canRadiate (const Event& state, int iRadBef,
2283  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
2284  return ( state[iRadBef].isFinal()
2285  && state[iRecBef].colType() != 0
2286  && hasSharedColor(state, iRadBef, iRecBef)
2287  && state[iRadBef].isQuark());
2288 }
2289 
2290 int Dire_fsr_qcd_Q2QG::kinMap() { return 1;}
2291 int Dire_fsr_qcd_Q2QG::motherID(int idDaughter) { return idDaughter;}
2292 int Dire_fsr_qcd_Q2QG::sisterID(int) { return 21;}
2293 double Dire_fsr_qcd_Q2QG::gaugeFactor ( int, int ) { return CF;}
2294 double Dire_fsr_qcd_Q2QG::symmetryFactor ( int, int ) { return 1.;}
2295 
2296 int Dire_fsr_qcd_Q2QG::radBefID(int idRA, int) {
2297  if (particleDataPtr->isQuark(idRA)) return idRA;
2298  return 0;
2299 }
2300 
2301 pair<int,int> Dire_fsr_qcd_Q2QG::radBefCols(
2302  int colRadAfter, int,
2303  int colEmtAfter, int acolEmtAfter) {
2304  bool isQuark = (colRadAfter > 0);
2305  if (isQuark) return make_pair(colEmtAfter,0);
2306  return make_pair(0,acolEmtAfter);
2307 }
2308 
2309 vector <int> Dire_fsr_qcd_Q2QG::recPositions( const Event& state, int iRad,
2310  int iEmt) {
2311 
2312  int colRad = state[iRad].col();
2313  int acolRad = state[iRad].acol();
2314  int colEmt = state[iEmt].col();
2315  int acolEmt = state[iEmt].acol();
2316  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
2317  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
2318  // Particles to exclude from colour tracing.
2319  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
2320 
2321  // Find partons connected via emitted colour line.
2322  vector<int> recs;
2323  if ( colEmt != 0 && colEmt != colShared) {
2324  int acolF = findCol(colEmt, iExc, state, 1);
2325  int colI = findCol(colEmt, iExc, state, 2);
2326  if (acolF > 0 && colI == 0) recs.push_back (acolF);
2327  if (acolF == 0 && colI > 0) recs.push_back (colI);
2328  }
2329  // Find partons connected via emitted anticolour line.
2330  if ( acolEmt != 0 && acolEmt != colShared) {
2331  int colF = findCol(acolEmt, iExc, state, 2);
2332  int acolI = findCol(acolEmt, iExc, state, 1);
2333  if ( colF > 0 && acolI == 0) recs.push_back (colF);
2334  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
2335  }
2336  // Done.
2337  return recs;
2338 }
2339 
2340 // Pick z for new splitting.
2341 double Dire_fsr_qcd_Q2QG::zSplit(double zMinAbs, double, double m2dip) {
2342  double Rz = rndmPtr->flat();
2343  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2344  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin2, Rz );
2345  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin2);
2346  return res;
2347 }
2348 
2349 // New overestimates, z-integrated versions.
2350 double Dire_fsr_qcd_Q2QG::overestimateInt(double zMinAbs, double,
2351  double, double m2dip, int orderNow) {
2352  // Q -> QG, soft part (currently also used for collinear part).
2353  double preFac = symmetryFactor() * gaugeFactor();
2354  int order = (orderNow > -1) ? orderNow : correctionOrder;
2355  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2356  double wt = preFac * softRescaleInt(order)
2357  *2. * 0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin2);
2358  return wt;
2359 }
2360 
2361 // Return overestimate for new splitting.
2362 double Dire_fsr_qcd_Q2QG::overestimateDiff(double z, double m2dip,
2363  int orderNow) {
2364  double preFac = symmetryFactor() * gaugeFactor();
2365  int order = (orderNow > -1) ? orderNow : correctionOrder;
2366  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2367  double wt = preFac * softRescaleInt(order)
2368  *2. * (1.-z) / ( pow2(1.-z) + kappaMin2);
2369  return wt;
2370 }
2371 
2372 // Return kernel for new splitting.
2373 bool Dire_fsr_qcd_Q2QG::calc(const Event& state, int orderNow) {
2374 
2375  // Dummy statement to avoid compiler warnings.
2376  if (false) cout << state[0].e() << orderNow << endl;
2377 
2378  // Read all splitting variables.
2379  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
2380  m2dip(splitInfo.kinematics()->m2Dip),
2381  m2RadBef(splitInfo.kinematics()->m2RadBef),
2382  m2Rad(splitInfo.kinematics()->m2RadAft),
2383  m2Rec(splitInfo.kinematics()->m2Rec),
2384  m2Emt(splitInfo.kinematics()->m2EmtAft);
2385  int splitType(splitInfo.type);
2386 
2387  // Corrections for correlated splittings.
2388  bool doMultiPole = (doCorrelations
2389  && !direInfoPtr->isSoft(splitInfo.iRadBef)
2390  && direInfoPtr->isSoft(splitInfo.iRecBef));
2391 
2392  // Correction for massive splittings.
2393  bool doMassive = (abs(splitType) == 2);
2394 
2395  // Calculate kernel.
2396  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
2397  // and later multiply with z to project out Q->QQ,
2398  // i.e. the gluon is soft and the quark is identified.
2399  double preFac = symmetryFactor() * gaugeFactor();
2400  int order = (orderNow > -1) ? orderNow : correctionOrder;
2401  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
2402  /m2dip, pT2/m2dip);
2403 
2404  // Calculate argument of alphaS.
2405  double scale2 = couplingScale2 ( z, pT2, m2dip,
2406  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
2407  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
2408  if (scale2 < 0.) scale2 = pT2;
2409 
2410  unordered_map<string,double> wts;
2411  double wt_base_as1 = 0.;
2412 
2413  if (!doMultiPole) {
2414 
2415  //wt_base_as1 = preFac * ( 2.* (1.-z) / ( pow2(1.-z) + kappa2) );
2416  if (doGeneralizedKernel) {
2417  wt_base_as1 = preFac * 2.* (1.-z) / ( pow2(1.-z) + kappa2)
2418  * ( 1./z*sCoef(-1) + sCoef(0) + z*sCoef(1) + z*z*sCoef(2))
2419  * exp(1./z*sExp(-1) + sExp(0) + z*sExp(1) + z*z*sExp(2));
2420  wt_base_as1 += preFac * 2.* kappa2 / ( pow2(1.-z) + kappa2)
2421  * ( 1./z*kCoef(-1) + kCoef(0) + z*kCoef(1) + z*z*kCoef(2))
2422  * exp(1./z*kExp(-1) + kExp(0) + z*kExp(1) + z*z*kExp(2));
2423  } else
2424  wt_base_as1 = preFac * ( 2.* (1.-z) / ( pow2(1.-z) + kappa2) );
2425 
2426  wts.insert( make_pair("base", softRescaleDiff(order, scale2, renormMultFac)
2427  * wt_base_as1 ) );
2428  if (doVariations) {
2429  // Create muR-variations.
2430  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
2431  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1
2432  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
2433  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
2434  renormMultFac) ));
2435  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
2436  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1
2437  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
2438  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
2439  renormMultFac ) ));
2440  }
2441 
2442  // Add collinear term for massless splittings.
2443  if (!doMassive && order >= 0) {
2444  if (doGeneralizedKernel) {
2445  double tmp = preFac * (1.-z)
2446  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
2447  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
2448  + preFac * fCoef();
2449  wt_base_as1 += tmp;
2450  for ( unordered_map<string,double>::iterator it = wts.begin();
2451  it != wts.end(); ++it)
2452  it->second += tmp;
2453  } else {
2454  wt_base_as1 += -preFac * ( 1.+z );
2455  for ( unordered_map<string,double>::iterator it = wts.begin();
2456  it != wts.end(); ++it)
2457  it->second += -preFac * ( 1.+z );
2458  }
2459  }
2460 
2461  // Additional subleading color correction if this hard line had previously
2462  // emitted a soft gluon.
2463  } else {
2464 
2465  // Eikonal piece.
2466  double loEikonal = preFac * ( 2.* (1.-z) / ( pow2(1.-z) + kappa2) - 2.);
2467  // Add collinear term for massless splittings.
2468  double loColl = (!doMassive && order >= 0) ? preFac * ( 1. - z) : 0.;
2469 
2470  Event trialEvent(state);
2471  bool physical = false;
2472  if (splitInfo.recBef()->isFinal)
2473  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
2474  else
2475  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
2476 
2477  if (!physical) {
2478  wts.insert( make_pair("base", 0.) );
2479  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
2480  wts.insert( make_pair("Variations:muRfsrDown", 0.));
2481  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
2482  wts.insert( make_pair("Variations:muRfsrUp", 0.));
2483  clearKernels();
2484  for ( unordered_map<string,double>::iterator it = wts.begin();
2485  it != wts.end();
2486  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
2487  return true;
2488  }
2489 
2490  // Get momenta.
2491  Vec4 pi(trialEvent[splitInfo.iRadAft].p());
2492  Vec4 p2(trialEvent[splitInfo.iRecAft].p());
2493  Vec4 p1(trialEvent[splitInfo.iEmtAft].p());
2494  // Get other sibling momentum.
2495  int size = splitInfo.iSiblings.size();
2496  int iOther = 0;
2497  for (int i = 0; i < size; ++i) {
2498  if (splitInfo.iSiblings[i].first == splitInfo.iRadBef) continue;
2499  if (splitInfo.iSiblings[i].first == splitInfo.iRecBef) continue;
2500  iOther = splitInfo.iSiblings[i].first;
2501  }
2502  Vec4 pj(state[iOther].p());
2503  // Get invariants.
2504  double si1= 2.*pi*p1, sj1=2.*pj*p1, s12=2.*p1*p2;
2505  double si2= 2.*pi*p2, sj2=2.*pj*p2, sij=2.*pi*pj;
2506 
2507  // Multiplicative weight factor to force first eikonal to current
2508  // outgoing momenta.
2509  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
2510  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
2511  / (si1*sj1 + si2*sj2);
2512  double fullSoft = loEikonal * 0.5 * (wij12 + wij12bar);
2513  double fullColl = loColl;
2514  double colorCorrection = (CA - 2.*CF) * (si2/(si1+s12) - sij/(si1+sj1))
2515  * 0.5 * (wij12 + wij12bar);
2516 
2517  // Full result.
2518  wt_base_as1 = fullSoft + fullColl + colorCorrection;
2519  wts.insert( make_pair("base",
2520  softRescaleDiff( order, scale2, renormMultFac) * fullSoft
2521  + fullColl + colorCorrection ) );
2522  if (doVariations) {
2523  // Create muR-variations.
2524  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
2525  wts.insert( make_pair("Variations:muRfsrDown",
2526  softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
2527  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
2528  renormMultFac)*fullSoft
2529  + fullColl + colorCorrection));
2530  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
2531  wts.insert( make_pair("Variations:muRfsrUp",
2532  softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
2533  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
2534  renormMultFac)*fullSoft
2535  + fullColl + colorCorrection));
2536  }
2537 
2538  }
2539 
2540  // Differential as-running endpoint.
2541  if (order == 4) {
2542  double ep = beta0Endpoint(order, m2dip, pT2, z, renormMultFac);
2543  for ( unordered_map<string,double>::iterator it = wts.begin();
2544  it != wts.end(); ++it)
2545  it->second += CF*ep;
2546  }
2547 
2548  // Add collinear term for massive splittings.
2549  if (doMassive && order >= 0) {
2550 
2551  double pipj = 0., vijkt = 1., vijk = 1.;
2552 
2553  // splitType == 2 -> Massive FF
2554  if (splitType == 2) {
2555 
2556  // Calculate CS variables.
2557  double yCS = kappa2 / (1.-z);
2558  double nu2RadBef = m2RadBef/m2dip;
2559  double nu2Rad = m2Rad/m2dip;
2560  double nu2Emt = m2Emt/m2dip;
2561  double nu2Rec = m2Rec/m2dip;
2562  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
2563  double Q2mass = m2dip + m2Rad + m2Rec + m2Emt;
2564  vijkt = pow2(Q2mass/m2dip - nu2RadBef - nu2Rec)
2565  - 4.*nu2RadBef*nu2Rec;
2566  vijk = sqrt(vijk) / (1-yCS);
2567  vijkt = sqrt(vijkt)/ (Q2mass/m2dip - nu2RadBef - nu2Rec);
2568  pipj = m2dip * yCS/2.;
2569 
2570  // splitType ==-2 -> Massive FI
2571  } else if (splitType ==-2) {
2572 
2573  // Calculate CS variables.
2574  double xCS = 1 - kappa2/(1.-z);
2575  vijk = 1.;
2576  vijkt = 1.;
2577  pipj = m2dip/2. * (1-xCS)/xCS;
2578  }
2579 
2580  // Add collinear term for massive splittings.
2581  double massCorr = -1.*preFac*vijkt/vijk*m2RadBef/pipj;
2582  if (doGeneralizedKernel) {
2583  massCorr += preFac * vijkt/vijk * (1.-z)
2584  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
2585  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
2586  + preFac * vijkt/vijk * fCoef();
2587  } else {
2588  massCorr += -1.*preFac*vijkt/vijk*( 1. + z);
2589  }
2590 
2591  wt_base_as1 += massCorr;
2592  for ( unordered_map<string,double>::iterator it = wts.begin();
2593  it != wts.end(); ++it)
2594  it->second += massCorr;
2595 
2596  }
2597 
2598  // Add NLO term.
2599  if (!doMassive && order == 3) {
2600  for ( unordered_map<string,double>::iterator it = wts.begin();
2601  it !=wts.end(); ++it){
2602 
2603  double mukf = 1.;
2604  if (it->first == "base")
2605  mukf = renormMultFac;
2606  else if (it->first == "Variations:muRfsrDown")
2607  mukf = settingsPtr->parm("Variations:muRfsrDown");
2608  else if (it->first == "Variations:muRfsrUp")
2609  mukf = settingsPtr->parm("Variations:muRfsrUp");
2610  else continue;
2611 
2612  // Do not perform variations below a small pT cut.
2613  if (scale2 < pT2minVariations) mukf = renormMultFac;
2614 
2615  double NF = getNF(scale2 * mukf);
2616  double alphasPT2pi = as2Pi(scale2, order, mukf);
2617  double TF = TR*NF;
2618  double pqq1 = preFac / (18*(z-1)) * (
2619  ((-1 + z)*(4*TF*(-10 + z*(-37 + z*(29 + 28*z))) + z
2620  *(90*CF*(-1 + z) + CA*(53 - 187*z + 3*(1 + z)*pow2(M_PI)))) +
2621  3*z*log(z)*(34*TF + 12*(CF - CF*z + 2*TF*z) - 2
2622  *(9*CF + TF*(17 + 8*z))*pow2(z) - 12*CF*log(1 - z)*(1 + pow2(z)) -
2623  CA*(17 + 5*pow2(z)) - 3*log(z)*(CA - 3*CF + 2*TF + (CA - 5*CF - 2*TF)
2624  *pow2(z))))/z
2625  );
2626  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
2627  pqq1 += - preFac * 0.5 * 40./9. * TF * ( z /(z*z + kappa2) - 1./z);
2628  // Add NLO term.
2629  it->second += alphasPT2pi*pqq1;
2630 
2631  }
2632  }
2633 
2634  // Now multiply with z to project out Q->QG,
2635  // i.e. the gluon is soft and the quark is identified.
2636  for ( unordered_map<string,double>::iterator it = wts.begin();
2637  it != wts.end(); ++it )
2638  it->second *= z;
2639 
2640  wt_base_as1 *= z;
2641  // Store higher order correction separately.
2642  if (order > 0) wts.insert( make_pair("base_order_as2",
2643  wts["base"] - wt_base_as1 ));
2644 
2645  // Store kernel values.
2646  clearKernels();
2647  for ( unordered_map<string,double>::iterator it = wts.begin();
2648  it != wts.end(); ++it )
2649  kernelVals.insert(make_pair( it->first, it->second ));
2650 
2651  return true;
2652 
2653 }
2654 
2655 //==========================================================================
2656 
2657 // Class inheriting from SplittingQCD class.
2658 
2659 // SplittingQCD function Q->GQ (FSR)
2660 // At leading order, this can be combined with Q->QG because of symmetry. Since
2661 // this is no longer possible at NLO, we keep the kernels separately.
2662 
2663 // Return true if this kernel should partake in the evolution.
2664 bool Dire_fsr_qcd_Q2GQ::canRadiate ( const Event& state, pair<int,int> ints,
2665  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
2666  return ( state[ints.first].isFinal()
2667  && state[ints.second].colType() != 0
2668  && hasSharedColor(state, ints.first, ints.second)
2669  && state[ints.first].isQuark() );
2670 }
2671 
2672 bool Dire_fsr_qcd_Q2GQ::canRadiate (const Event& state, int iRadBef,
2673  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
2674  return ( state[iRadBef].isFinal()
2675  && state[iRecBef].colType() != 0
2676  && hasSharedColor(state, iRadBef, iRecBef)
2677  && state[iRadBef].isQuark());
2678 }
2679 
2680 int Dire_fsr_qcd_Q2GQ::kinMap() { return 1;}
2681 int Dire_fsr_qcd_Q2GQ::motherID(int idDaughter) { return idDaughter;}
2682 int Dire_fsr_qcd_Q2GQ::sisterID(int) { return 21;}
2683 double Dire_fsr_qcd_Q2GQ::gaugeFactor ( int, int ) { return CF;}
2684 double Dire_fsr_qcd_Q2GQ::symmetryFactor ( int, int ) { return 1.;}
2685 
2686 int Dire_fsr_qcd_Q2GQ::radBefID(int idRad, int idEmt) {
2687  if (idRad == 21 && particleDataPtr->isQuark(idEmt)) return idEmt;
2688  if (idEmt == 21 && particleDataPtr->isQuark(idRad)) return idRad;
2689  return 0;
2690 }
2691 
2692 pair<int,int> Dire_fsr_qcd_Q2GQ::radBefCols(
2693  int colRadAfter, int acolRadAfter,
2694  int colEmtAfter, int acolEmtAfter) {
2695  int colE = (colEmtAfter*acolEmtAfter == 0 && colRadAfter*acolRadAfter != 0)
2696  ? colEmtAfter : colRadAfter;
2697  int colR = (colEmtAfter*acolEmtAfter == 0 && colRadAfter*acolRadAfter != 0)
2698  ? colRadAfter : colEmtAfter;
2699  int acolR = (colEmtAfter*acolEmtAfter == 0 && colRadAfter*acolRadAfter != 0)
2700  ? acolRadAfter : acolEmtAfter;
2701 
2702  bool isQuark = (colE > 0);
2703  if (isQuark) return make_pair(colR,0);
2704  return make_pair(0,acolR);
2705 }
2706 
2707 vector <int> Dire_fsr_qcd_Q2GQ::recPositions( const Event& state, int iRad,
2708  int iEmt) {
2709 
2710  // For Q->GQ, swap radiator and emitted, since we now have to trace the
2711  // radiator's colour connections.
2712  if ( state[iEmt].idAbs() < 20 && state[iRad].id() == 21) swap( iRad, iEmt);
2713 
2714  int colRad = state[iRad].col();
2715  int acolRad = state[iRad].acol();
2716  int colEmt = state[iEmt].col();
2717  int acolEmt = state[iEmt].acol();
2718  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
2719  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
2720  // Particles to exclude from colour tracing.
2721  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
2722 
2723  // Find partons connected via emitted colour line.
2724  vector<int> recs;
2725  if ( colEmt != 0 && colEmt != colShared) {
2726  int acolF = findCol(colEmt, iExc, state, 1);
2727  int colI = findCol(colEmt, iExc, state, 2);
2728  if (acolF > 0 && colI == 0) recs.push_back (acolF);
2729  if (acolF == 0 && colI > 0) recs.push_back (colI);
2730  }
2731  // Find partons connected via emitted anticolour line.
2732  if ( acolEmt != 0 && acolEmt != colShared) {
2733  int colF = findCol(acolEmt, iExc, state, 2);
2734  int acolI = findCol(acolEmt, iExc, state, 1);
2735  if ( colF > 0 && acolI == 0) recs.push_back (colF);
2736  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
2737  }
2738  // Done.
2739  return recs;
2740 }
2741 
2742 // Pick z for new splitting.
2743 double Dire_fsr_qcd_Q2GQ::zSplit(double zMinAbs, double, double m2dip) {
2744  double Rz = rndmPtr->flat();
2745  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2746  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin2, Rz );
2747  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin2);
2748  return res;
2749 }
2750 
2751 // New overestimates, z-integrated versions.
2752 double Dire_fsr_qcd_Q2GQ::overestimateInt(double zMinAbs, double,
2753  double, double m2dip, int orderNow) {
2754  // Q -> QG, soft part (currently also used for collinear part).
2755  double preFac = symmetryFactor() * gaugeFactor();
2756  int order = (orderNow > -1) ? orderNow : correctionOrder;
2757  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2758  double wt = preFac * 2. * 0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin2);
2759 
2760  // Rescale with soft cusp term only if NLO corrections are absent.
2761  // This choice is purely heuristical to improve LEP description.
2762  if ( ( correctionOrder > 0 && correctionOrder <= 2 )
2763  || ( orderNow > -1 && orderNow <= 2 ) )
2764  wt *= softRescaleInt(order);
2765 
2766  return wt;
2767 }
2768 
2769 // Return overestimate for new splitting.
2770 double Dire_fsr_qcd_Q2GQ::overestimateDiff(double z, double m2dip,
2771  int orderNow) {
2772  double preFac = symmetryFactor() * gaugeFactor();
2773  int order = (orderNow > -1) ? orderNow : correctionOrder;
2774  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
2775  double wt = preFac * 2.* (1.-z) / ( pow2(1.-z) + kappaMin2);
2776  // Rescale with soft cusp term only if NLO corrections are absent.
2777  // This choice is purely heuristical to improve LEP description.
2778  if ( ( correctionOrder > 0 && correctionOrder <= 2 )
2779  || ( orderNow > -1 && orderNow <= 2 ) )
2780  wt *= softRescaleInt(order);
2781  return wt;
2782 }
2783 
2784 // Return kernel for new splitting.
2785 bool Dire_fsr_qcd_Q2GQ::calc(const Event& state, int orderNow) {
2786 
2787  // Dummy statement to avoid compiler warnings.
2788  if (false) cout << state[0].e() << orderNow << endl;
2789 
2790  // Read all splitting variables.
2791  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
2792  m2dip(splitInfo.kinematics()->m2Dip),
2793  m2RadBef(splitInfo.kinematics()->m2RadBef),
2794  m2Rad(splitInfo.kinematics()->m2RadAft),
2795  m2Rec(splitInfo.kinematics()->m2Rec),
2796  m2Emt(splitInfo.kinematics()->m2EmtAft);
2797  int splitType(splitInfo.type);
2798 
2799  // Calculate kernel.
2800  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
2801  // and later multiply with 1-z to project out Q->GQ,
2802  // i.e. the quark is soft and the gluon is identified.
2803  double preFac = symmetryFactor() * gaugeFactor();
2804  int order = (orderNow > -1) ? orderNow : correctionOrder;
2805  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
2806  /m2dip, pT2/m2dip);
2807 
2808  unordered_map<string,double> wts;
2809  double wt_base_as1 = 0.;
2810  if (doGeneralizedKernel) {
2811  wt_base_as1 = preFac * 2.* (1.-z) / ( pow2(1.-z) + kappa2)
2812  * ( 1./z*sCoef(-1) + sCoef(0) + z*sCoef(1) + z*z*sCoef(2))
2813  * exp(1./z*sExp(-1) + sExp(0) + z*sExp(1) + z*z*sExp(2));
2814  wt_base_as1 += preFac * 2.* kappa2 / ( pow2(1.-z) + kappa2)
2815  * ( 1./z*kCoef(-1) + kCoef(0) + z*kCoef(1) + z*z*kCoef(2))
2816  * exp(1./z*kExp(-1) + kExp(0) + z*kExp(1) + z*z*kExp(2));
2817  } else
2818  wt_base_as1 = preFac * ( 2.* (1.-z) / ( pow2(1.-z) + kappa2) );
2819 
2820  wts.insert( make_pair("base", wt_base_as1 ));
2821  if (doVariations) {
2822  // Create muR-variations.
2823  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
2824  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
2825  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
2826  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
2827  }
2828 
2829  // Calculate argument of alphaS.
2830  double scale2 = couplingScale2 ( z, pT2, m2dip,
2831  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
2832  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
2833  if (scale2 < 0.) scale2 = pT2;
2834 
2835  // Rescale with soft cusp term only if NLO corrections are absent.
2836  // This choice is purely heuristical to improve LEP description.
2837  bool doRescale = ( ( correctionOrder > 0 && correctionOrder <= 2 )
2838  || ( orderNow > -1 && orderNow <= 2 ) );
2839  if (doRescale) {
2840  wts["base"] *= softRescaleDiff( order, scale2, renormMultFac);
2841  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
2842  wts["Variations:muRfsrDown"] *= softRescaleDiff( order, scale2,
2843  (scale2 > pT2minVariations) ? settingsPtr->parm("Variations:muRfsrDown")
2844  *renormMultFac
2845  : renormMultFac);
2846  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
2847  wts["Variations:muRfsrUp"] *= softRescaleDiff( order, scale2,
2848  (scale2 > pT2minVariations) ? settingsPtr->parm("Variations:muRfsrUp")
2849  *renormMultFac
2850  : renormMultFac);
2851  }
2852 
2853  // Correction for massive splittings.
2854  bool doMassive = (abs(splitType) == 2);
2855 
2856  // Add collinear term for massless splittings.
2857  if (!doMassive && order >= 0) {
2858  if (doGeneralizedKernel) {
2859  double tmp = preFac * (1.-z)
2860  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
2861  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
2862  + preFac * fCoef();
2863  wt_base_as1 += tmp;
2864  for ( unordered_map<string,double>::iterator it = wts.begin();
2865  it != wts.end(); ++it)
2866  it->second += tmp;
2867  } else {
2868  wt_base_as1 += -preFac * ( 1.+z );
2869  for ( unordered_map<string,double>::iterator it = wts.begin();
2870  it != wts.end(); ++it)
2871  it->second += -preFac * ( 1.+z );
2872  }
2873  }
2874 
2875  // Add collinear term for massive splittings.
2876  if (doMassive && order >= 0) {
2877 
2878  double pipj = 0., vijkt = 1., vijk = 1.;
2879 
2880  // splitType == 2 -> Massive FF
2881  if (splitType == 2) {
2882 
2883  // Calculate CS variables.
2884  double yCS = kappa2 / (1.-z);
2885  double nu2RadBef = m2RadBef/m2dip;
2886  double nu2Rad = m2Rad/m2dip;
2887  double nu2Emt = m2Emt/m2dip;
2888  double nu2Rec = m2Rec/m2dip;
2889  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
2890  double Q2mass = m2dip + m2Rad + m2Rec + m2Emt;
2891  vijkt = pow2(Q2mass/m2dip - nu2RadBef - nu2Rec)
2892  - 4.*nu2RadBef*nu2Rec;
2893  vijk = sqrt(vijk) / (1-yCS);
2894  vijkt = sqrt(vijkt)/ (Q2mass/m2dip - nu2RadBef - nu2Rec);
2895  pipj = m2dip * yCS/2.;
2896  // splitType ==-2 -> Massive FI
2897  } else if (splitType ==-2) {
2898 
2899  // Calculate CS variables.
2900  double xCS = 1 - kappa2/(1.-z);
2901  vijk = 1.;
2902  vijkt = 1.;
2903  pipj = m2dip/2. * (1-xCS)/xCS;
2904  }
2905 
2906  // Add collinear term for massive splittings.
2907  double massCorr = -1.*preFac*vijkt/vijk*m2RadBef/pipj;
2908  if (doGeneralizedKernel) {
2909  massCorr += preFac * vijkt/vijk * (1.-z)
2910  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
2911  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
2912  + preFac * vijkt/vijk * fCoef();
2913  } else {
2914  massCorr += -1.*preFac*vijkt/vijk*( 1. + z);
2915  }
2916 
2917  wt_base_as1 += massCorr;
2918  for ( unordered_map<string,double>::iterator it = wts.begin();
2919  it != wts.end(); ++it)
2920  it->second += massCorr;
2921 
2922  }
2923 
2924  // Add NLO term.
2925  if (!doMassive && order == 3){
2926  for ( unordered_map<string,double>::iterator it = wts.begin();
2927  it !=wts.end(); ++it) {
2928  double mukf = 1.;
2929  if (it->first == "base")
2930  mukf = renormMultFac;
2931  else if (it->first == "Variations:muRfsrDown")
2932  mukf = settingsPtr->parm("Variations:muRfsrDown");
2933  else if (it->first == "Variations:muRfsrUp")
2934  mukf = settingsPtr->parm("Variations:muRfsrUp");
2935  else continue;
2936 
2937  // Do not perform variations below a small pT cut.
2938  if (scale2 < pT2minVariations) mukf = renormMultFac;
2939 
2940  // Evaluate kernel copied from Mathematica with 1-z!
2941  double x = 1.-z;
2942  double NF = getNF(scale2 * mukf);
2943  double alphasPT2pi = as2Pi(scale2, order, mukf);
2944  double TF = TR*NF;
2945  double pqg1 = preFac * (
2946  (9*CF*x*(-1 + 9*x) + 144*(CA - CF)*(2 + (-2 + x)*x)
2947  *DiLog(x) + 36*CA*(2 + x*(2 + x))*DiLog(1/(1 + x)) -
2948  2*CA*(-17 + 9*(-5 + x)*x + 44*pow(x,3) + 3*pow2(M_PI)*(2 + pow2(x))) +
2949  3*(12*log(1 - x)*((3*CA - 2*CF)*(2 + (-2 + x)*x)*log(x) + (-CA + CF)
2950  *pow2(x)) +
2951  log(x)*(3*CF*(-16 + x)*x + 2*CA*(-18 + x*(24 + x*(27 + 8*x))) - 3
2952  *log(x)*(CF*(-2 + x)*x + CA*(8 + 4*x + 6*pow2(x)))) -
2953  6*(CA - CF)*(2 + (-2 + x)*x)*pow2(log(1 - x)) + 6*CA*(2 + x*(2 + x))
2954  *pow2(log(1 + x))))/(18.*x)
2955  );
2956  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
2957  pqg1 += preFac * 0.5 * 40./9. * TF * ( x /(x*x + kappa2) - 1./x);
2958  // Add NLO term.
2959  it->second += alphasPT2pi*pqg1;
2960  }
2961  }
2962 
2963  // Now multiply with (1-z) to project out Q->GQ,
2964  // i.e. the quark is soft and the gluon is identified.
2965  for ( unordered_map<string,double>::iterator it = wts.begin();
2966  it != wts.end(); ++it )
2967  it->second *= (1-z);
2968 
2969  wt_base_as1 *= (1-z);
2970  // Store higher order correction separately.
2971  if (order > 0) wts.insert( make_pair("base_order_as2",
2972  wts["base"] - wt_base_as1 ));
2973 
2974  // Store kernel values.
2975  clearKernels();
2976  for ( unordered_map<string,double>::iterator it = wts.begin();
2977  it != wts.end(); ++it )
2978  kernelVals.insert(make_pair( it->first, it->second ));
2979 
2980  return true;
2981 
2982 }
2983 
2984 //==========================================================================
2985 
2986 // Class inheriting from SplittingQCD class.
2987 
2988 // SplittingQCD function G->GG (FSR)
2989 // We now split this kernel into two pieces, as the soft emitted gluon
2990 // is identified as NLO. Thus, it is good to have two kernels for g -> g1 g2,
2991 // one where g1 is soft, and one where g2 is soft.
2992 
2993 // Return true if this kernel should partake in the evolution.
2994 bool Dire_fsr_qcd_G2GG1::canRadiate ( const Event& state, pair<int,int> ints,
2995  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
2996  return ( state[ints.first].isFinal()
2997  && state[ints.second].colType() != 0
2998  && hasSharedColor(state, ints.first, ints.second)
2999  && state[ints.first].id() == 21 );
3000 }
3001 
3002 bool Dire_fsr_qcd_G2GG1::canRadiate (const Event& state, int iRadBef,
3003  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
3004  return ( state[iRadBef].isFinal()
3005  && state[iRecBef].colType() != 0
3006  && hasSharedColor(state, iRadBef, iRecBef)
3007  && state[iRadBef].id() == 21);
3008 }
3009 
3010 int Dire_fsr_qcd_G2GG1::kinMap() { return 1;}
3011 int Dire_fsr_qcd_G2GG1::motherID(int) { return 21;}
3012 int Dire_fsr_qcd_G2GG1::sisterID(int) { return 21;}
3013 double Dire_fsr_qcd_G2GG1::gaugeFactor ( int, int ) { return 2.*CA;}
3014 double Dire_fsr_qcd_G2GG1::symmetryFactor ( int, int ) { return 0.5;}
3015 
3016 int Dire_fsr_qcd_G2GG1::radBefID(int, int){ return 21;}
3017 pair<int,int> Dire_fsr_qcd_G2GG1::radBefCols(
3018  int colRadAfter, int acolRadAfter,
3019  int colEmtAfter, int acolEmtAfter) {
3020  int colRemove = (colRadAfter == acolEmtAfter)
3021  ? colRadAfter : acolRadAfter;
3022  int col = (colRadAfter == colRemove)
3023  ? colEmtAfter : colRadAfter;
3024  int acol = (acolRadAfter == colRemove)
3025  ? acolEmtAfter : acolRadAfter;
3026  return make_pair(col,acol);
3027 }
3028 
3029 vector <int> Dire_fsr_qcd_G2GG1::recPositions( const Event& state, int iRad,
3030  int iEmt) {
3031 
3032  int colRad = state[iRad].col();
3033  int acolRad = state[iRad].acol();
3034  int colEmt = state[iEmt].col();
3035  int acolEmt = state[iEmt].acol();
3036  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
3037  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
3038  // Particles to exclude from colour tracing.
3039  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
3040 
3041  // Find partons connected via emitted colour line.
3042  vector<int> recs;
3043  if ( colEmt != 0 && colEmt != colShared) {
3044  int acolF = findCol(colEmt, iExc, state, 1);
3045  int colI = findCol(colEmt, iExc, state, 2);
3046  if (acolF > 0 && colI == 0) recs.push_back (acolF);
3047  if (acolF == 0 && colI > 0) recs.push_back (colI);
3048  }
3049  // Find partons connected via emitted anticolour line.
3050  if ( acolEmt != 0 && acolEmt != colShared) {
3051  int colF = findCol(acolEmt, iExc, state, 2);
3052  int acolI = findCol(acolEmt, iExc, state, 1);
3053  if ( colF > 0 && acolI == 0) recs.push_back (colF);
3054  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
3055  }
3056  // Done.
3057  return recs;
3058 }
3059 
3060 // Pick z for new splitting.
3061 double Dire_fsr_qcd_G2GG1::zSplit(double zMinAbs, double, double m2dip) {
3062  // Just pick according to soft.
3063  double R = rndmPtr->flat();
3064  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3065  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin2, R );
3066  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin2);
3067  return res;
3068 }
3069 
3070 // New overestimates, z-integrated versions.
3071 double Dire_fsr_qcd_G2GG1::overestimateInt(double zMinAbs, double,
3072  double, double m2dip, int orderNow) {
3073 
3074  // Overestimate by soft
3075  double preFac = symmetryFactor() * gaugeFactor();
3076  int order = (orderNow > -1) ? orderNow : correctionOrder;
3077  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3078  double wt = preFac * softRescaleInt(order)
3079  *0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin2);
3080  if (useBackboneGluons) wt *= 2.;
3081  return wt;
3082 }
3083 
3084 // Return overestimate for new splitting.
3085 double Dire_fsr_qcd_G2GG1::overestimateDiff(double z, double m2dip,
3086  int orderNow) {
3087  // Overestimate by soft
3088  double preFac = symmetryFactor() * gaugeFactor();
3089  int order = (orderNow > -1) ? orderNow : correctionOrder;
3090  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3091  double wt = preFac * softRescaleInt(order)
3092  *(1.-z) / ( pow2(1.-z) + kappaMin2);
3093  if (useBackboneGluons) wt *= 2.;
3094  return wt;
3095 }
3096 
3097 // Return kernel for new splitting.
3098 bool Dire_fsr_qcd_G2GG1::calc(const Event& state, int orderNow) {
3099 
3100  // Dummy statement to avoid compiler warnings.
3101  if (false) cout << state[0].e() << orderNow << endl;
3102 
3103  // Read all splitting variables.
3104  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
3105  m2dip(splitInfo.kinematics()->m2Dip),
3106  m2Rad(splitInfo.kinematics()->m2RadAft),
3107  m2Rec(splitInfo.kinematics()->m2Rec),
3108  m2Emt(splitInfo.kinematics()->m2EmtAft);
3109  int splitType(splitInfo.type);
3110 
3111  // Corrections for correlated splittings.
3112  bool doMultiPole = (doCorrelations
3113  && direInfoPtr->isSoft(splitInfo.iRadBef));
3114 
3115  // Correction for massive splittings.
3116  bool doMassive = (abs(splitType) == 2);
3117 
3118  double preFac = symmetryFactor() * gaugeFactor();
3119 
3120  int nFinal = 0;
3121  for (int i=0; i < state.size(); ++i) if (state[i].isFinal()) nFinal++;
3122  if (useBackboneGluons && nFinal > 2) {
3123  vector<int> cols = sharedColor(state,splitInfo.iRadBef,splitInfo.iRecBef);
3124  vector<int> bcols = fsrDec->bornColors;
3125  if ( cols.size()==1
3126  && find(bcols.begin(), bcols.end(), cols.front()) != bcols.end())
3127  preFac = 0.;
3128  else if (cols.size()==1) {
3129  int colNow = cols.front();
3130  int colRad = state[splitInfo.iRadBef].col();
3131  int acolRad = state[splitInfo.iRadBef].acol();
3132  if ( colNow == colRad
3133  && find(bcols.begin(), bcols.end(), acolRad) != bcols.end())
3134  preFac *= 2.;
3135  else if (colNow == acolRad
3136  && find(bcols.begin(), bcols.end(), colRad) != bcols.end())
3137  preFac *= 2.;
3138  }
3139  }
3140 
3141  int order = (orderNow > -1) ? orderNow : correctionOrder;
3142  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
3143  /m2dip, pT2/m2dip);
3144 
3145  // Calculate kernel.
3146  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3147  // and later multiply with z to project out one part.
3148  unordered_map<string,double> wts;
3149  double wt_base_as1 = 0.;
3150 
3151  // Calculate argument of alphaS.
3152  double scale2 = couplingScale2 ( z, pT2, m2dip,
3153  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
3154  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
3155  if (scale2 < 0.) scale2 = pT2;
3156 
3157  if (!doMultiPole) {
3158  // Calculate kernel.
3159  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3160  // and later multiply with z to project out one part.
3161  if (doGeneralizedKernel) {
3162  wt_base_as1 = preFac * (1.-z) / ( pow2(1.-z) + kappa2)
3163  * ( 1./z*sCoef(-1) + sCoef(0) + z*sCoef(1) + z*z*sCoef(2))
3164  * exp(1./z*sExp(-1) + sExp(0) + z*sExp(1) + z*z*sExp(2));
3165  wt_base_as1 += preFac * kappa2 / ( pow2(1.-z) + kappa2)
3166  * ( 1./z*kCoef(-1) + kCoef(0) + z*kCoef(1) + z*z*kCoef(2))
3167  * exp(1./z*kExp(-1) + kExp(0) + z*kExp(1) + z*z*kExp(2));
3168  } else
3169  wt_base_as1 = preFac * (1.-z) / ( pow2(1.-z) + kappa2);
3170 
3171  wts.insert( make_pair("base", wt_base_as1
3172  * softRescaleDiff( order, scale2, renormMultFac) ));
3173  if (doVariations) {
3174  // Create muR-variations.
3175  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
3176  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1
3177  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3178  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
3179  renormMultFac) ));
3180  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
3181  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1
3182  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3183  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
3184  renormMultFac) ));
3185  }
3186 
3187  // Add collinear term for massless splittings.
3188  double coll = 0.;
3189  if (!doMassive && order >= 0) {
3190  if (doGeneralizedKernel) {
3191  coll = preFac * 0.5 * z*(1.-z)
3192  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
3193  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
3194  + preFac * 0.5 * fCoef();
3195  } else {
3196  coll = preFac * ( -1. + 0.5*z*(1.-z) );
3197  }
3198  }
3199  for ( unordered_map<string,double>::iterator it = wts.begin();
3200  it != wts.end(); ++it)
3201  it->second += coll;
3202  wt_base_as1 += coll;
3203 
3204  // Differential as-running endpoint.
3205  if (order == 4) {
3206  double ep = beta0Endpoint(order, m2dip, pT2, z, renormMultFac);
3207  for ( unordered_map<string,double>::iterator it = wts.begin();
3208  it != wts.end(); ++it)
3209  it->second += CA/2.*ep;
3210  }
3211 
3212  } else {
3213 
3214  // Eikonal piece.
3215  double loEikonal = preFac * ((1.-z) / (pow2(1.-z) + kappa2)-1.);
3216 
3217  // Get additional invariants.
3218  Event trialEvent(state);
3219  bool physical = false;
3220  if (splitInfo.recBef()->isFinal)
3221  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
3222  else
3223  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
3224 
3225  if (!physical) {
3226  wts.insert( make_pair("base", 0.) );
3227  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
3228  wts.insert( make_pair("Variations:muRfsrDown", 0.));
3229  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
3230  wts.insert( make_pair("Variations:muRfsrUp", 0.));
3231  clearKernels();
3232  for ( unordered_map<string,double>::iterator it = wts.begin();
3233  it != wts.end();
3234  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
3235  return true;
3236  }
3237 
3238  // Get momenta.
3239  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
3240  Vec4 pi(trialEvent[splitInfo.iRecAft].p());
3241  Vec4 p2(trialEvent[splitInfo.iEmtAft].p());
3242  // Get other sibling momentum.
3243  int size = splitInfo.iSiblings.size();
3244  int iOther = 0;
3245  for (int i = 0; i < size; ++i) {
3246  if (splitInfo.iSiblings[i].first == splitInfo.iRadBef) continue;
3247  if (splitInfo.iSiblings[i].first == splitInfo.iRecBef) continue;
3248  iOther = splitInfo.iSiblings[i].first;
3249  }
3250  Vec4 pj(state[iOther].p());
3251  // Get invariants.
3252  double si1= 2.*pi*p1, sj1=2.*pj*p1, s12=2.*p1*p2;
3253  double si2= 2.*pi*p2, sj2=2.*pj*p2, sij=2.*pi*pj;
3254 
3255  // Multiplicative weight factor to force first eikonal to current
3256  // outgoing momenta.
3257  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
3258  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
3259  / (si1*sj1 + si2*sj2);
3260 
3261  // If this is a branching of a previous emission, correlate spin with
3262  // mother dipole.
3263  double ct2= pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
3264  double fullColl = (!doMassive && order >= 0)
3265  ? preFac * 0.5*( -1. + ct2/2.0) * wij12 : 0.;
3266  double fullSoft = loEikonal * 0.5 * (wij12 + wij12bar);
3267 
3268  // Calculate kernel.
3269  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3270  // and later multiply with z to project out one part.
3271  wt_base_as1 = fullSoft + fullColl;
3272  wts.insert( make_pair("base", fullSoft
3273  * softRescaleDiff( order, scale2, renormMultFac) ));
3274  if (doVariations) {
3275  // Create muR-variations.
3276  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
3277  wts.insert( make_pair("Variations:muRfsrDown", fullSoft
3278  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3279  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
3280  renormMultFac) ));
3281  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
3282  wts.insert( make_pair("Variations:muRfsrUp", fullSoft
3283  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3284  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
3285  renormMultFac) ));
3286  }
3287 
3288  // Add collinear and correction terms.
3289  for ( unordered_map<string,double>::iterator it = wts.begin();
3290  it != wts.end(); ++it)
3291  it->second += fullColl;
3292  }
3293 
3294  // Add collinear term for massive splittings.
3295  if (doMassive && order >= 0) {
3296 
3297  double vijk = 1.;
3298 
3299  // splitType == 2 -> Massive FF
3300  if (splitType == 2) {
3301  // Calculate CS variables.
3302  double yCS = kappa2 / (1.-z);
3303  double nu2Rad = m2Rad/m2dip;
3304  double nu2Emt = m2Emt/m2dip;
3305  double nu2Rec = m2Rec/m2dip;
3306  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
3307  vijk = sqrt(vijk) / (1-yCS);
3308 
3309  // splitType ==-2 -> Massive FI
3310  } else if (splitType ==-2) {
3311  // No changes, as initial recoiler is massless!
3312  vijk = 1.;
3313  }
3314 
3315  // Add collinear term for massive splittings.
3316  double coll = 0.;
3317  if (doGeneralizedKernel) {
3318  coll = preFac * 0.5 * 1./vijk * z*(1.-z)
3319  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
3320  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
3321  + preFac * 0.5 * 1./vijk * fCoef();
3322  //coll *= as2Pi(pT2/(1.-z)) / as2Pi(pT2);
3323  } else {
3324  coll = preFac * 1./ vijk * ( -1. + 0.5 * z*(1.-z) );
3325  }
3326  wt_base_as1 += coll;
3327  for ( unordered_map<string,double>::iterator it = wts.begin();
3328  it != wts.end(); ++it)
3329  it->second += coll;
3330 
3331  }
3332 
3333  // Add NLO term.
3334  if (!doMassive && order == 3 ) {
3335  for ( unordered_map<string,double>::iterator it = wts.begin();
3336  it !=wts.end(); ++it){
3337  double mukf = 1.;
3338  if (it->first == "base")
3339  mukf = renormMultFac;
3340  else if (it->first == "Variations:muRfsrDown")
3341  mukf = settingsPtr->parm("Variations:muRfsrDown");
3342  else if (it->first == "Variations:muRfsrUp")
3343  mukf = settingsPtr->parm("Variations:muRfsrUp");
3344  else continue;
3345 
3346  // Do not perform variations below a small pT cut.
3347  if (scale2 < pT2minVariations) mukf = renormMultFac;
3348 
3349  double NF = getNF(scale2 * mukf);
3350  double alphasPT2pi = as2Pi(scale2, order, mukf);
3351  double TF = TR*NF;
3352  // Anatomy of factors of two:
3353  // One factor of 0.5 since LO kernel is split into "z" and "1-z" parts,
3354  // while the NLO kernel is NOT split into these structures.
3355  // Another factor of 0.5 enters because the LO kernel above does not
3356  // include a "2" (this "2" is in preFac), while the NLO kernel in the
3357  // Mathematica file does include the factor of "2".
3358  double x=z;
3359  double pgg1 = preFac * 0.5 * 0.5 / ( 18*x*(pow2(x)-1) ) * (
3360  TF*(4*(-1 + x)*(-23 + x*(6 + x*(10 + x*(4 + 23*x)))) + 24*(1 + x)
3361  *(2 + (-1 + x)*x*(3 + x*(-3 + 2*x)))*log(x)) +
3362  (CF*TF*(-12*(1 + x)*(8 + x*(7 - x*(2 + x)*(-3 + 8*x)))*log(x) - 8
3363  *(1 + x)*(23 + x*(14 + 41*x))*pow2(-1 + x) +
3364  36*(-1 + x)*x*pow2(1 + x)*pow2(log(x))))/CA + 72*CA*(-1 + x)
3365  *DiLog(1/(1 + x))*pow2(1 + x + pow2(x)) +
3366  CA*(-6*(1 + x)*(-22 + x*(11 + x*(30 + x*(-19 + 22*x))))*log(x) +
3367  (1 - x)*(x*(1 + x)*(25 + 109*x) + 6*(2 + x*(1 + 2*x*(1 + x)))
3368  *pow2(M_PI)) - 72*(1 + x)*log(1 - x)*log(x)*pow2(1 + (-1 + x)*x) +
3369  36*(2 + x*(1 + (-4 + x)*(-1 + x)*x*(1 + x)))*pow2(log(x)) + 36*(-1 + x)
3370  *pow2(log(1 + x))*pow2(1 + x + pow2(x)))
3371  );
3372  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
3373  // Note: Colour factor is CA, not CF!
3374  pgg1 += preFac * 0.5 * 0.5 * 40./9. * TF * ( x /(x*x + kappa2) - 1./x);
3375  // Add NLO term.
3376  it->second += alphasPT2pi*pgg1;
3377  }
3378  }
3379 
3380  // Multiply with z to project out part where emitted gluon is soft.
3381  // (the radiator is identified)
3382  for ( unordered_map<string,double>::iterator it = wts.begin();
3383  it != wts.end(); ++it)
3384  it->second *= z;
3385 
3386  wt_base_as1 *= z;
3387  // Store higher order correction separately.
3388  if (order > 0) wts.insert( make_pair("base_order_as2",
3389  wts["base"] - wt_base_as1 ));
3390 
3391  // Store kernel values.
3392  clearKernels();
3393  for ( unordered_map<string,double>::iterator it = wts.begin();
3394  it != wts.end(); ++it)
3395  kernelVals.insert(make_pair( it->first, it->second ));
3396 
3397  return true;
3398 
3399 }
3400 
3401 //==========================================================================
3402 
3403 // Class inheriting from SplittingQCD class.
3404 
3405 // SplittingQCD function G->GG (FSR)
3406 // We now split this kernel into two pieces, as the soft emitted gluon
3407 // is identified as NLO. Thus, it is good to have two kernels for g -> g1 g2,
3408 // one where g1 is soft, and one where g2 is soft.
3409 
3410 // Return true if this kernel should partake in the evolution.
3411 bool Dire_fsr_qcd_G2GG2::canRadiate ( const Event& state, pair<int,int> ints,
3412  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
3413  return ( state[ints.first].isFinal()
3414  && state[ints.second].colType() != 0
3415  && hasSharedColor(state, ints.first, ints.second)
3416  && state[ints.first].id() == 21 );
3417 }
3418 
3419 bool Dire_fsr_qcd_G2GG2::canRadiate (const Event& state, int iRadBef,
3420  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
3421  return ( state[iRadBef].isFinal()
3422  && state[iRecBef].colType() != 0
3423  && hasSharedColor(state, iRadBef, iRecBef)
3424  && state[iRadBef].id() == 21);
3425 }
3426 
3427 int Dire_fsr_qcd_G2GG2::kinMap() { return 1;}
3428 int Dire_fsr_qcd_G2GG2::motherID(int) { return 21;}
3429 int Dire_fsr_qcd_G2GG2::sisterID(int) { return 21;}
3430 double Dire_fsr_qcd_G2GG2::gaugeFactor ( int, int ) { return 2.*CA;}
3431 double Dire_fsr_qcd_G2GG2::symmetryFactor ( int, int ) { return 0.5;}
3432 
3433 int Dire_fsr_qcd_G2GG2::radBefID(int, int){ return 21;}
3434 pair<int,int> Dire_fsr_qcd_G2GG2::radBefCols(
3435  int colRadAfter, int acolRadAfter,
3436  int colEmtAfter, int acolEmtAfter) {
3437  int colRemove = (colRadAfter == acolEmtAfter)
3438  ? colRadAfter : acolRadAfter;
3439  int col = (colRadAfter == colRemove)
3440  ? colEmtAfter : colRadAfter;
3441  int acol = (acolRadAfter == colRemove)
3442  ? acolEmtAfter : acolRadAfter;
3443  return make_pair(col,acol);
3444 }
3445 
3446 vector <int> Dire_fsr_qcd_G2GG2::recPositions( const Event& state, int iRad,
3447  int iEmt) {
3448 
3449  int colRad = state[iRad].col();
3450  int acolRad = state[iRad].acol();
3451  int colEmt = state[iEmt].col();
3452  int acolEmt = state[iEmt].acol();
3453  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
3454  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
3455  // Particles to exclude from colour tracing.
3456  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
3457 
3458  // Find partons connected via emitted colour line.
3459  vector<int> recs;
3460  // Find partons connected via radiator colour line.
3461  if ( colRad != 0 && colRad != colShared) {
3462  int acolF = findCol(colRad, iExc, state, 1);
3463  int colI = findCol(colRad, iExc, state, 2);
3464  if (acolF > 0 && colI == 0) recs.push_back (acolF);
3465  if (acolF == 0 && colI > 0) recs.push_back (colI);
3466  }
3467 
3468  // Find partons connected via radiator anticolour line.
3469  if ( acolRad != 0 && acolRad != colShared) {
3470  int colF = findCol(acolRad, iExc, state, 2);
3471  int acolI = findCol(acolRad, iExc, state, 1);
3472  if ( colF > 0 && acolI == 0) recs.push_back (colF);
3473  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
3474  }
3475 
3476  // Done.
3477  return recs;
3478 }
3479 
3480 // Pick z for new splitting.
3481 double Dire_fsr_qcd_G2GG2::zSplit(double zMinAbs, double, double m2dip) {
3482  // Just pick according to soft.
3483  double R = rndmPtr->flat();
3484  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3485  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin2, R );
3486  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin2);
3487  return res;
3488 }
3489 
3490 // New overestimates, z-integrated versions.
3491 double Dire_fsr_qcd_G2GG2::overestimateInt(double zMinAbs, double,
3492  double, double m2dip, int orderNow) {
3493  // Overestimate by soft
3494  double preFac = symmetryFactor() * gaugeFactor();
3495  //int order = (orderNow > 0) ? orderNow : correctionOrder;
3496  int order = (orderNow > -1) ? orderNow : correctionOrder;
3497  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3498  double wt = preFac * softRescaleInt(order)
3499  *0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin2);
3500  if (useBackboneGluons) wt *= 2.;
3501  return wt;
3502 }
3503 
3504 // Return overestimate for new splitting.
3505 double Dire_fsr_qcd_G2GG2::overestimateDiff(double z, double m2dip,
3506  int orderNow) {
3507  // Overestimate by soft
3508  double preFac = symmetryFactor() * gaugeFactor();
3509  int order = (orderNow > -1) ? orderNow : correctionOrder;
3510  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
3511  double wt = preFac * softRescaleInt(order)
3512  *(1.-z) / ( pow2(1.-z) + kappaMin2);
3513  if (useBackboneGluons) wt *= 2.;
3514  return wt;
3515 }
3516 
3517 // Return kernel for new splitting.
3518 bool Dire_fsr_qcd_G2GG2::calc(const Event& state, int orderNow) {
3519 
3520  // Dummy statement to avoid compiler warnings.
3521  if (false) cout << state[0].e() << orderNow << endl;
3522 
3523  // Read all splitting variables.
3524  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
3525  m2dip(splitInfo.kinematics()->m2Dip),
3526  m2Rad(splitInfo.kinematics()->m2RadAft),
3527  m2Rec(splitInfo.kinematics()->m2Rec),
3528  m2Emt(splitInfo.kinematics()->m2EmtAft);
3529  int splitType(splitInfo.type);
3530 
3531  // Corrections for correlated splittings.
3532  bool doMultiPole =
3533  (doCorrelations && direInfoPtr->isSoft(splitInfo.iRadBef));
3534 
3535  // Correction for massive splittings.
3536  bool doMassive = (abs(splitType) == 2);
3537 
3538  double preFac = symmetryFactor() * gaugeFactor();
3539 
3540  int nFinal = 0;
3541  for (int i=0; i < state.size(); ++i) if (state[i].isFinal()) nFinal++;
3542  if (useBackboneGluons && nFinal > 2) {
3543  vector<int> cols = sharedColor(state,splitInfo.iRadBef,splitInfo.iRecBef);
3544  vector<int> bcols = fsrDec->bornColors;
3545  if ( cols.size()==1
3546  && find(bcols.begin(), bcols.end(), cols.front()) != bcols.end())
3547  preFac = 0.;
3548  else if (cols.size()==1) {
3549  int colNow = cols.front();
3550  int colRad = state[splitInfo.iRadBef].col();
3551  int acolRad = state[splitInfo.iRadBef].acol();
3552  if ( colNow == colRad
3553  && find(bcols.begin(), bcols.end(), acolRad) != bcols.end())
3554  preFac *= 2.;
3555  else if (colNow == acolRad
3556  && find(bcols.begin(), bcols.end(), colRad) != bcols.end())
3557  preFac *= 2.;
3558  }
3559  }
3560 
3561  int order = (orderNow > -1) ? orderNow : correctionOrder;
3562  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
3563  /m2dip, pT2/m2dip);
3564 
3565  // Calculate kernel.
3566  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3567  // and later multiply with z to project out one part.
3568  unordered_map<string,double> wts;
3569  double wt_base_as1 = 0.;
3570 
3571  // Calculate argument of alphaS.
3572  double scale2 = couplingScale2 ( z, pT2, m2dip,
3573  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
3574  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
3575  if (scale2 < 0.) scale2 = pT2;
3576 
3577  if (!doMultiPole) {
3578  // Calculate kernel.
3579  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3580  // and later multiply with z to project out one part.
3581  if (doGeneralizedKernel) {
3582  wt_base_as1 = preFac * (1.-z) / ( pow2(1.-z) + kappa2)
3583  * ( 1./z*sCoef(-1) + sCoef(0) + z*sCoef(1) + z*z*sCoef(2))
3584  * exp(1./z*sExp(-1) + sExp(0) + z*sExp(1) + z*z*sExp(2));
3585  wt_base_as1 += preFac * kappa2 / ( pow2(1.-z) + kappa2)
3586  * ( 1./z*kCoef(-1) + kCoef(0) + z*kCoef(1) + z*z*kCoef(2))
3587  * exp(1./z*kExp(-1) + kExp(0) + z*kExp(1) + z*z*kExp(2));
3588  } else
3589  wt_base_as1 = preFac * (1.-z) / ( pow2(1.-z) + kappa2);
3590 
3591  wts.insert( make_pair("base", wt_base_as1
3592  * softRescaleDiff( order, scale2, renormMultFac) ));
3593  if (doVariations) {
3594  // Create muR-variations.
3595  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
3596  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1
3597  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3598  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
3599  renormMultFac) ));
3600  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
3601  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1
3602  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3603  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
3604  renormMultFac) ));
3605  }
3606 
3607  // Add collinear term for massless splittings.
3608  double coll = 0.;
3609  if (!doMassive && order >= 0) {
3610  if (doGeneralizedKernel) {
3611  coll = preFac * 0.5 * z*(1.-z)
3612  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
3613  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
3614  + preFac * 0.5 * fCoef();
3615  } else {
3616  coll = preFac * ( -1. + 0.5*z*(1.-z) );
3617  }
3618  }
3619  for ( unordered_map<string,double>::iterator it = wts.begin();
3620  it != wts.end(); ++it)
3621  it->second += coll;
3622  wt_base_as1 += coll;
3623 
3624  // Differential as-running endpoint.
3625  if (order == 4) {
3626  double ep = beta0Endpoint(order, m2dip, pT2, z, renormMultFac);
3627  for ( unordered_map<string,double>::iterator it = wts.begin();
3628  it != wts.end(); ++it)
3629  it->second += CA/2.*ep;
3630  }
3631 
3632  } else {
3633 
3634  // Eikonal piece.
3635  double loEikonal = preFac * ((1.-z) / (pow2(1.-z) + kappa2) -1.);
3636 
3637  // Get additional invariants.
3638  Event trialEvent(state);
3639  bool physical = false;
3640  if (splitInfo.recBef()->isFinal)
3641  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
3642  else
3643  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
3644 
3645  if (!physical) {
3646  wts.insert( make_pair("base", 0.) );
3647  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
3648  wts.insert( make_pair("Variations:muRfsrDown", 0.));
3649  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
3650  wts.insert( make_pair("Variations:muRfsrUp", 0.));
3651  clearKernels();
3652  for ( unordered_map<string,double>::iterator it = wts.begin();
3653  it != wts.end();
3654  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
3655  return true;
3656  }
3657 
3658  // Get momenta.
3659  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
3660  Vec4 pi(trialEvent[splitInfo.iRecAft].p());
3661  Vec4 p2(trialEvent[splitInfo.iEmtAft].p());
3662  // Get other sibling momentum.
3663  int size = splitInfo.iSiblings.size();
3664  int iOther = 0;
3665  for (int i = 0; i < size; ++i) {
3666  if (splitInfo.iSiblings[i].first == splitInfo.iRadBef) continue;
3667  if (splitInfo.iSiblings[i].first == splitInfo.iRecBef) continue;
3668  iOther = splitInfo.iSiblings[i].first;
3669  }
3670  Vec4 pj(state[iOther].p());
3671  // Get invariants.
3672  double si1= 2.*pi*p1, sj1=2.*pj*p1, s12=2.*p1*p2;
3673  double si2= 2.*pi*p2, sj2=2.*pj*p2, sij=2.*pi*pj;
3674 
3675  // Multiplicative weight factor to force first eikonal to current
3676  // outgoing momenta.
3677  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
3678  double wij12bar = ((si1 + si2)*(sj1 + sj2) - sij*s12)
3679  / (si1*sj1 + si2*sj2);
3680 
3681  // If this is a branching of a previous emission, correlate spin with
3682  // mother dipole.
3683  double ct2 = pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
3684  double fullColl = (!doMassive && order >= 0)
3685  ? preFac * 0.5*( -1. + ct2/2.0) * wij12 : 0.;
3686  double fullSoft = loEikonal * 0.5 * (wij12 + wij12bar);
3687 
3688  // Calculate kernel.
3689  // Note: We are calculating the z <--> 1-z symmetrised kernel here,
3690  // and later multiply with z to project out one part.
3691  wt_base_as1 = fullSoft + fullColl;
3692  wts.insert( make_pair("base", fullSoft
3693  * softRescaleDiff( order, scale2, renormMultFac) ));
3694  if (doVariations) {
3695  // Create muR-variations.
3696  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
3697  wts.insert( make_pair("Variations:muRfsrDown", fullSoft
3698  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3699  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
3700  renormMultFac) ));
3701  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
3702  wts.insert( make_pair("Variations:muRfsrUp", fullSoft
3703  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
3704  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
3705  renormMultFac) ));
3706  }
3707 
3708  // Add collinear and correction terms.
3709  for ( unordered_map<string,double>::iterator it = wts.begin();
3710  it != wts.end(); ++it)
3711  it->second += fullColl;
3712  }
3713 
3714  // Add collinear term for massive splittings.
3715  if (doMassive && order >= 0) {
3716 
3717  double vijk = 1.;
3718 
3719  // splitType == 2 -> Massive FF
3720  if (splitType == 2) {
3721  // Calculate CS variables.
3722  double yCS = kappa2 / (1.-z);
3723  double nu2Rad = m2Rad/m2dip;
3724  double nu2Emt = m2Emt/m2dip;
3725  double nu2Rec = m2Rec/m2dip;
3726  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
3727  vijk = sqrt(vijk) / (1-yCS);
3728 
3729  // splitType ==-2 -> Massive FI
3730  } else if (splitType ==-2) {
3731  // No changes, as initial recoiler is massless!
3732  vijk = 1.;
3733  }
3734 
3735  // Add collinear term for massive splittings.
3736  double coll = 0.;
3737  if (doGeneralizedKernel) {
3738  coll = preFac * 0.5 * 1./vijk * z*(1.-z)
3739  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
3740  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
3741  + preFac * 0.5 * 1./vijk * fCoef();
3742  } else {
3743  coll = preFac * 1./ vijk * ( -1. + 0.5 * z*(1.-z) );
3744  }
3745  wt_base_as1 += coll;
3746  for ( unordered_map<string,double>::iterator it = wts.begin();
3747  it != wts.end(); ++it)
3748  it->second += coll;
3749 
3750  }
3751 
3752  // Add NLO term.
3753  if (!doMassive && order == 3) {
3754  for ( unordered_map<string,double>::iterator it = wts.begin();
3755  it !=wts.end(); ++it) {
3756  double mukf = 1.;
3757  if (it->first == "base")
3758  mukf = renormMultFac;
3759  else if (it->first == "Variations:muRfsrDown")
3760  mukf = settingsPtr->parm("Variations:muRfsrDown");
3761  else if (it->first == "Variations:muRfsrUp")
3762  mukf = settingsPtr->parm("Variations:muRfsrUp");
3763  else continue;
3764 
3765  // Do not perform variations below a small pT cut.
3766  if (scale2 < pT2minVariations) mukf = renormMultFac;
3767 
3768  double NF = getNF(scale2 * mukf);
3769  double alphasPT2pi = as2Pi(scale2, order, mukf);
3770  double TF = TR*NF;
3771  // Evaluate everything at x = 1-z, because this is the kernel where
3772  // the radiating gluon becomes soft and the emission is identified.
3773  double x = 1.-z;
3774  // Anatomy of factors of two:
3775  // One factor of 0.5 since LO kernel is split into "z" and "1-z" parts,
3776  // while the NLO kernel is NOT split into these structures.
3777  // Another factor of 0.5 enters because the LO kernel above does not
3778  // include a "2" (this "2" is in preFac), while the NLO kernel in the
3779  // Mathematica file does include the factor of "2".
3780  double pgg1 = preFac * 0.5 * 0.5 / ( 18*x*(pow2(x)-1) ) * (
3781  TF*(4*(-1 + x)*(-23 + x*(6 + x*(10 + x*(4 + 23*x)))) + 24*(1 + x)
3782  *(2 + (-1 + x)*x*(3 + x*(-3 + 2*x)))*log(x)) +
3783  (CF*TF*(-12*(1 + x)*(8 + x*(7 - x*(2 + x)*(-3 + 8*x)))*log(x) - 8
3784  *(1 + x)*(23 + x*(14 + 41*x))*pow2(-1 + x) +
3785  36*(-1 + x)*x*pow2(1 + x)*pow2(log(x))))/CA + 72*CA*(-1 + x)
3786  *DiLog(1/(1 + x))*pow2(1 + x + pow2(x)) +
3787  CA*(-6*(1 + x)*(-22 + x*(11 + x*(30 + x*(-19 + 22*x))))*log(x) +
3788  (1 - x)*(x*(1 + x)*(25 + 109*x) + 6*(2 + x*(1 + 2*x*(1 + x)))
3789  *pow2(M_PI)) - 72*(1 + x)*log(1 - x)*log(x)*pow2(1 + (-1 + x)*x) +
3790  36*(2 + x*(1 + (-4 + x)*(-1 + x)*x*(1 + x)))*pow2(log(x)) + 36
3791  *(-1 + x)*pow2(log(1 + x))*pow2(1 + x + pow2(x)))
3792  );
3793  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
3794  // Note: Colour factor is CA, not CF!
3795  pgg1 += preFac * 0.5 * 0.5 * 40./9. * TF * ( x /(x*x + kappa2) - 1./x);
3796  // Add NLO term.
3797  it->second += alphasPT2pi*pgg1;
3798  }
3799  }
3800 
3801  // Multiply with 1-z to project out part where radiating gluon is soft.
3802  // (the emission is identified)
3803  for ( unordered_map<string,double>::iterator it = wts.begin();
3804  it != wts.end(); ++it )
3805  it->second *= (1-z);
3806 
3807  wt_base_as1 *= (1-z);
3808  // Store higher order correction separately.
3809  if (order > 0) wts.insert( make_pair("base_order_as2",
3810  wts["base"] - wt_base_as1 ));
3811 
3812  // Store kernel values.
3813  clearKernels();
3814  for ( unordered_map<string,double>::iterator it = wts.begin();
3815  it != wts.end(); ++it )
3816  kernelVals.insert(make_pair( it->first, it->second ));
3817 
3818  return true;
3819 
3820 }
3821 
3822 //==========================================================================
3823 
3824 // Class inheriting from SplittingQCD class.
3825 
3826 // SplittingQCD function G->QQ (FSR)
3827 
3828 // Return true if this kernel should partake in the evolution.
3829 bool Dire_fsr_qcd_G2QQ1::canRadiate ( const Event& state, pair<int,int> ints,
3830  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
3831  return ( state[ints.first].isFinal()
3832  && state[ints.second].colType() != 0
3833  && hasSharedColor(state, ints.first, ints.second)
3834  && state[ints.first].id() == 21 );
3835 }
3836 
3837 bool Dire_fsr_qcd_G2QQ1::canRadiate (const Event& state, int iRadBef,
3838  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
3839  return ( state[iRadBef].isFinal()
3840  && state[iRecBef].colType() != 0
3841  && hasSharedColor(state, iRadBef, iRecBef)
3842  && state[iRadBef].id() == 21);
3843 }
3844 
3845 int Dire_fsr_qcd_G2QQ1::kinMap() { return 1;}
3846 int Dire_fsr_qcd_G2QQ1::motherID(int) { return 1;} // Use 1 as dummy variable.
3847 int Dire_fsr_qcd_G2QQ1::sisterID(int) { return 1;} // Use 1 as dummy variable.
3848 double Dire_fsr_qcd_G2QQ1::gaugeFactor ( int, int ) { return NF_qcd_fsr*TR;}
3849 double Dire_fsr_qcd_G2QQ1::symmetryFactor ( int, int ) { return 0.5;}
3850 
3851 int Dire_fsr_qcd_G2QQ1::radBefID(int, int){ return 21;}
3852 pair<int,int> Dire_fsr_qcd_G2QQ1::radBefCols(
3853  int colRadAfter, int acolRadAfter,
3854  int colEmtAfter, int acolEmtAfter) {
3855  int col = (colRadAfter > 0) ? colRadAfter : colEmtAfter;
3856  int acol = (acolRadAfter > 0) ? acolRadAfter : acolEmtAfter;
3857  return make_pair(col,acol);
3858 }
3859 
3860 vector <int> Dire_fsr_qcd_G2QQ1::recPositions( const Event& state, int iRad,
3861  int iEmt) {
3862 
3863  int colRad = state[iRad].col();
3864  int acolRad = state[iRad].acol();
3865  int colEmt = state[iEmt].col();
3866  int acolEmt = state[iEmt].acol();
3867  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
3868  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
3869  // Particles to exclude from colour tracing.
3870  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
3871 
3872  // Find partons connected via emitted colour line.
3873  vector<int> recs;
3874 
3875  // Find partons connected via emitted colour line.
3876  if ( colEmt != 0 && colEmt != colShared) {
3877  int acolF = findCol(colEmt, iExc, state, 1);
3878  int colI = findCol(colEmt, iExc, state, 2);
3879  if (acolF > 0 && colI == 0) recs.push_back (acolF);
3880  if (acolF == 0 && colI > 0) recs.push_back (colI);
3881  }
3882  // Find partons connected via emitted anticolour line.
3883  if ( acolEmt != 0 && acolEmt != colShared) {
3884  int colF = findCol(acolEmt, iExc, state, 2);
3885  int acolI = findCol(acolEmt, iExc, state, 1);
3886  if ( colF > 0 && acolI == 0) recs.push_back (colF);
3887  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
3888  }
3889 
3890  // Done.
3891  return recs;
3892 }
3893 
3894 // Pick z for new splitting.
3895 double Dire_fsr_qcd_G2QQ1::zSplit(double zMinAbs, double zMaxAbs, double) {
3896  return (zMinAbs + rndmPtr->flat() * (zMaxAbs - zMinAbs));
3897 }
3898 
3899 // New overestimates, z-integrated versions.
3900 double Dire_fsr_qcd_G2QQ1::overestimateInt(double zMinAbs,double zMaxAbs,
3901  double, double, int) {
3902  double wt = 0.;
3903  double preFac = symmetryFactor() * gaugeFactor();
3904  wt = 2.*preFac * 0.5 * ( zMaxAbs - zMinAbs);
3905  return wt;
3906 }
3907 
3908 // Return overestimate for new splitting.
3909 double Dire_fsr_qcd_G2QQ1::overestimateDiff(double, double, int) {
3910  double wt = 0.;
3911  double preFac = symmetryFactor() * gaugeFactor();
3912  wt = 2.*preFac * 0.5;
3913  return wt;
3914 }
3915 
3916 // Return kernel for new splitting.
3917 bool Dire_fsr_qcd_G2QQ1::calc(const Event& state, int orderNow) {
3918 
3919  // Dummy statement to avoid compiler warnings.
3920  if (false) cout << state[0].e() << orderNow << endl;
3921 
3922  // Read all splitting variables.
3923  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
3924  m2dip(splitInfo.kinematics()->m2Dip),
3925  m2Rad(splitInfo.kinematics()->m2RadAft),
3926  m2Rec(splitInfo.kinematics()->m2Rec),
3927  m2Emt(splitInfo.kinematics()->m2EmtAft);
3928  int splitType(splitInfo.type);
3929 
3930  double preFac = symmetryFactor() * gaugeFactor();
3931  int order = (orderNow > -1) ? orderNow : correctionOrder;
3932  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
3933  /m2dip, pT2/m2dip);
3934 
3935  unordered_map<string,double> wts;
3936  double wt_base_as1 = 0.;
3937 
3938  // If this is a branching of a previous emission, correlate with mother
3939  // dipole.
3940  if ( doCorrelations && direInfoPtr->isSoft(splitInfo.iRadBef)) {
3941  Event trialEvent(state);
3942  bool physical = false;
3943  if (splitInfo.recBef()->isFinal)
3944  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
3945  else
3946  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
3947 
3948  if (!physical) {
3949  wts.insert( make_pair("base", 0.) );
3950  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
3951  wts.insert( make_pair("Variations:muRfsrDown", 0.));
3952  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
3953  wts.insert( make_pair("Variations:muRfsrUp", 0.));
3954  clearKernels();
3955  for ( unordered_map<string,double>::iterator it = wts.begin();
3956  it != wts.end();
3957  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
3958  return true;
3959  }
3960 
3961  // Get momenta.
3962  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
3963  Vec4 pi(trialEvent[splitInfo.iRecAft].p());
3964  Vec4 p2(trialEvent[splitInfo.iEmtAft].p());
3965  // Get other sibling momentum.
3966  int size = splitInfo.iSiblings.size();
3967  int iOther = 0;
3968  for (int i = 0; i < size; ++i) {
3969  if (splitInfo.iSiblings[i].first == splitInfo.iRadBef) continue;
3970  if (splitInfo.iSiblings[i].first == splitInfo.iRecBef) continue;
3971  iOther = splitInfo.iSiblings[i].first;
3972  }
3973  Vec4 pj(state[iOther].p());
3974  // Get invariants.
3975  double si1= 2.*pi*p1, sj1=2.*pj*p1, s12=2.*p1*p2;
3976  double si2= 2.*pi*p2, sj2=2.*pj*p2, sij=2.*pi*pj;
3977  double ct2= pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
3978 
3979  // Multiplicative weight factor to force first eikonal to current
3980  // outgoing momenta.
3981  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
3982  wt_base_as1 = preFac*(1.- ct2)*wij12;
3983 
3984  // Uncorrelated g->qq splitting.
3985  } else {
3986  if (doGeneralizedKernel) {
3987  wt_base_as1 = preFac * ( pow(1.-z,2.) + pow(z,2.) )
3988  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
3989  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
3990  + preFac * fCoef();
3991  } else {
3992  wt_base_as1 = preFac * ( pow(1.-z,2.) + pow(z,2.) );
3993  }
3994  }
3995 
3996  // Switch off splitting when only considering double log contributions.
3997  if (order == -1) wt_base_as1 = 0.0;
3998 
3999  // Calculate argument of alphaS.
4000  double scale2 = couplingScale2 ( z, pT2, m2dip,
4001  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
4002  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
4003  if (scale2 < 0.) scale2 = pT2;
4004 
4005  wts.insert( make_pair("base", wt_base_as1 ));
4006  if (doVariations) {
4007  // Create muR-variations.
4008  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
4009  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
4010  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
4011  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
4012  }
4013 
4014  // Correction for massive splittings.
4015  bool doMassive = (abs(splitType) == 2);
4016 
4017  if (doMassive) {
4018 
4019  double vijk = 1., pipj = 0.;
4020 
4021  // splitType == 2 -> Massive FF
4022  if (splitType == 2) {
4023  // Calculate CS variables.
4024  double yCS = kappa2 / (1.-z);
4025  double nu2Rad = m2Rad/m2dip;
4026  double nu2Emt = m2Emt/m2dip;
4027  double nu2Rec = m2Rec/m2dip;
4028  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
4029  vijk = sqrt(vijk) / (1-yCS);
4030  pipj = m2dip * yCS /2.;
4031 
4032  // splitType ==-2 -> Massive FI
4033  } else if (splitType ==-2) {
4034  // Calculate CS variables.
4035  double xCS = 1 - kappa2/(1.-z);
4036  vijk = 1.;
4037  pipj = m2dip/2. * (1-xCS)/xCS;
4038  }
4039 
4040  wt_base_as1 = preFac * 1. / vijk * m2Emt / (pipj + m2Emt);
4041  if (doGeneralizedKernel) {
4042  wt_base_as1 += preFac * 1. / vijk * ( pow(1.-z,2.) + pow(z,2.) )
4043  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
4044  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
4045  + preFac * fCoef();
4046  } else {
4047  wt_base_as1 += preFac * 1. / vijk * (pow(1.-z,2.) + pow(z,2.));
4048  }
4049 
4050  // Switch off splitting when only considering double log contributions.
4051  if (order == -1) wt_base_as1 = 0.0;
4052 
4053  // Reset kernel for massive splittings.
4054  for ( unordered_map<string,double>::iterator it = wts.begin();
4055  it != wts.end(); ++it)
4056  it->second = wt_base_as1;
4057 
4058  }
4059 
4060  // Add NLO term.
4061  if (!doMassive && order == 3) {
4062  for ( unordered_map<string,double>::iterator it = wts.begin();
4063  it !=wts.end(); ++it) {
4064  double mukf = 1.;
4065  if (it->first == "base")
4066  mukf = renormMultFac;
4067  else if (it->first == "Variations:muRfsrDown")
4068  mukf = settingsPtr->parm("Variations:muRfsrDown");
4069  else if (it->first == "Variations:muRfsrUp")
4070  mukf = settingsPtr->parm("Variations:muRfsrUp");
4071  else continue;
4072 
4073  // Do not perform variations below a small pT cut.
4074  if (scale2 < pT2minVariations) mukf = renormMultFac;
4075 
4076  double NF = getNF(scale2 * mukf);
4077  double alphasPT2pi = as2Pi(scale2, order, mukf);
4078  double TF = TR*NF;
4079  double pgq1 = preFac * (
4080  (TF*(-8./3. - (8*(1 + 2*(-1 + z)*z)*(2 + 3*log(1 - z) + 3*log(z)))/9.)
4081  + CF*(-2 + 3*z - 4*log(1 - z) + (-7 + 8*z)*log(z) + (1 - 2*z)
4082  *pow2(log(z)) -
4083  (2*(1 + 2*(-1 + z)*z)*(15 - 24*DiLog(z) + 3*log(-1 + 1/z) -
4084  24*log(1 - z)*log(z) + pow2(M_PI) + 3*pow2(log(-((-1 + z)*z)))))/3.) +
4085  (CA*(-152 - 40/z + 166*z + 36*log(1 - z) - 12*(1 + 19*z)*log(z) +
4086  (1 + 2*(-1 + z)*z)*(178 - 144*DiLog(z) + log(1 - z)*(30 - 72*log(z)) -
4087  3*log(z)*(4 + 3*log(z)) + 3*pow2(M_PI) +
4088  18*pow2(log(1 - z))) + 9*(2 + 8*z)*pow2(log(z)) +
4089  3*(1 + 2*z*(1 + z))*(-12*DiLog(1/(1 + z)) + pow2(M_PI) +
4090  3*pow2(log(z)) - 6*pow2(log(1 + z)))))/9.)/2.
4091  );
4092  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
4093  // Include additional factor of 0.5 as we have two g->qq kernels.
4094  pgq1 += - preFac * 0.5 * 40./9. * CA * ( z /(z*z + kappa2) - 1./z);
4095  // Add NLO term.
4096  it->second += alphasPT2pi*pgq1;
4097  }
4098  }
4099 
4100  // Multiply with z to project out part where emitted quark is soft,
4101  // and antiquark is identified.
4102  for ( unordered_map<string,double>::iterator it = wts.begin();
4103  it != wts.end(); ++it )
4104  it->second *= z;
4105 
4106  wt_base_as1 *= z;
4107  // Store higher order correction separately.
4108  if (order > 0) wts.insert( make_pair("base_order_as2",
4109  wts["base"] - wt_base_as1 ));
4110 
4111  // Store kernel values.
4112  clearKernels();
4113  for ( unordered_map<string,double>::iterator it = wts.begin();
4114  it != wts.end(); ++it )
4115  kernelVals.insert(make_pair( it->first, it->second ));
4116 
4117  return true;
4118 
4119 }
4120 
4121 //==========================================================================
4122 
4123 // Class inheriting from SplittingQCD class.
4124 
4125 // SplittingQCD function G->QQ (FSR)
4126 
4127 // Return true if this kernel should partake in the evolution.
4128 bool Dire_fsr_qcd_G2QQ2::canRadiate ( const Event& state, pair<int,int> ints,
4129  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
4130  return ( state[ints.first].isFinal()
4131  && state[ints.second].colType() != 0
4132  && hasSharedColor(state, ints.first, ints.second)
4133  && state[ints.first].id() == 21 );
4134 }
4135 
4136 bool Dire_fsr_qcd_G2QQ2::canRadiate (const Event& state, int iRadBef,
4137  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
4138  return ( state[iRadBef].isFinal()
4139  && state[iRecBef].colType() != 0
4140  && hasSharedColor(state, iRadBef, iRecBef)
4141  && state[iRadBef].id() == 21);
4142 }
4143 
4144 int Dire_fsr_qcd_G2QQ2::kinMap() {return 1;}
4145 int Dire_fsr_qcd_G2QQ2::motherID(int) {return -1;} // Use -1 as dummy variable.
4146 int Dire_fsr_qcd_G2QQ2::sisterID(int) {return -1;} // Use -1 as dummy variable.
4147 double Dire_fsr_qcd_G2QQ2::gaugeFactor ( int, int ) { return NF_qcd_fsr*TR;}
4148 double Dire_fsr_qcd_G2QQ2::symmetryFactor ( int, int ) { return 0.5;}
4149 
4150 int Dire_fsr_qcd_G2QQ2::radBefID(int, int){ return 21;}
4151 pair<int,int> Dire_fsr_qcd_G2QQ2::radBefCols(
4152  int colRadAfter, int acolRadAfter,
4153  int colEmtAfter, int acolEmtAfter) {
4154  int col = (colRadAfter > 0) ? colRadAfter : colEmtAfter;
4155  int acol = (acolRadAfter > 0) ? acolRadAfter : acolEmtAfter;
4156  return make_pair(col,acol);
4157 }
4158 
4159 vector <int> Dire_fsr_qcd_G2QQ2::recPositions( const Event& state, int iRad,
4160  int iEmt) {
4161 
4162  int colRad = state[iRad].col();
4163  int acolRad = state[iRad].acol();
4164  int colEmt = state[iEmt].col();
4165  int acolEmt = state[iEmt].acol();
4166  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
4167  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
4168  // Particles to exclude from colour tracing.
4169  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
4170 
4171  // Find partons connected via emitted colour line.
4172  vector<int> recs;
4173 
4174  // Find partons connected via radiator colour line.
4175  if ( colRad != 0 && colRad != colShared) {
4176  int acolF = findCol(colRad, iExc, state, 1);
4177  int colI = findCol(colRad, iExc, state, 2);
4178  if (acolF > 0 && colI == 0) recs.push_back (acolF);
4179  if (acolF == 0 && colI > 0) recs.push_back (colI);
4180  }
4181  // Find partons connected via radiator anticolour line.
4182  if ( acolRad != 0 && acolRad != colShared) {
4183  int colF = findCol(acolRad, iExc, state, 2);
4184  int acolI = findCol(acolRad, iExc, state, 1);
4185  if ( colF > 0 && acolI == 0) recs.push_back (colF);
4186  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
4187  }
4188 
4189  // Done.
4190  return recs;
4191 }
4192 
4193 // Pick z for new splitting.
4194 double Dire_fsr_qcd_G2QQ2::zSplit(double zMinAbs, double zMaxAbs, double) {
4195  return (zMinAbs + rndmPtr->flat() * (zMaxAbs - zMinAbs));
4196 }
4197 
4198 // New overestimates, z-integrated versions.
4199 double Dire_fsr_qcd_G2QQ2::overestimateInt(double zMinAbs,double zMaxAbs,
4200  double, double, int) {
4201  double wt = 0.;
4202  double preFac = symmetryFactor() * gaugeFactor();
4203  wt = 2.*preFac * 0.5 * ( zMaxAbs - zMinAbs);
4204  return wt;
4205 }
4206 
4207 // Return overestimate for new splitting.
4208 double Dire_fsr_qcd_G2QQ2::overestimateDiff(double, double, int) {
4209  double wt = 0.;
4210  double preFac = symmetryFactor() * gaugeFactor();
4211  wt = 2.*preFac * 0.5;
4212  return wt;
4213 }
4214 
4215 // Return kernel for new splitting.
4216 bool Dire_fsr_qcd_G2QQ2::calc(const Event& state, int orderNow) {
4217 
4218  // Dummy statement to avoid compiler warnings.
4219  if (false) cout << state[0].e() << orderNow << endl;
4220 
4221  // Read all splitting variables.
4222  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
4223  m2dip(splitInfo.kinematics()->m2Dip),
4224  m2Rad(splitInfo.kinematics()->m2RadAft),
4225  m2Rec(splitInfo.kinematics()->m2Rec),
4226  m2Emt(splitInfo.kinematics()->m2EmtAft);
4227  int splitType(splitInfo.type);
4228 
4229  double preFac = symmetryFactor() * gaugeFactor();
4230  int order = (orderNow > -1) ? orderNow : correctionOrder;
4231  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
4232  /m2dip, pT2/m2dip);
4233 
4234  unordered_map<string,double> wts;
4235  double wt_base_as1 = 0.;
4236 
4237  // If this is a branching of a previous emission, correlate with mother
4238  // dipole.
4239  if ( doCorrelations && direInfoPtr->isSoft(splitInfo.iRadBef)) {
4240  Event trialEvent(state);
4241  bool physical = false;
4242  if (splitInfo.recBef()->isFinal)
4243  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
4244  else
4245  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
4246 
4247  if (!physical) {
4248  wts.insert( make_pair("base", 0.) );
4249  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
4250  wts.insert( make_pair("Variations:muRfsrDown", 0.));
4251  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
4252  wts.insert( make_pair("Variations:muRfsrUp", 0.));
4253  clearKernels();
4254  for ( unordered_map<string,double>::iterator it = wts.begin();
4255  it != wts.end();
4256  ++it ) kernelVals.insert(make_pair( it->first, it->second ));
4257  return true;
4258  }
4259 
4260  // Get momenta.
4261  Vec4 p1(trialEvent[splitInfo.iRadAft].p());
4262  Vec4 pi(trialEvent[splitInfo.iRecAft].p());
4263  Vec4 p2(trialEvent[splitInfo.iEmtAft].p());
4264  // Get other sibling momentum.
4265  int size = splitInfo.iSiblings.size();
4266  int iOther = 0;
4267  for (int i = 0; i < size; ++i) {
4268  if (splitInfo.iSiblings[i].first == splitInfo.iRadBef) continue;
4269  if (splitInfo.iSiblings[i].first == splitInfo.iRecBef) continue;
4270  iOther = splitInfo.iSiblings[i].first;
4271  }
4272  Vec4 pj(state[iOther].p());
4273  // Get invariants.
4274  double si1= 2.*pi*p1, sj1=2.*pj*p1, s12=2.*p1*p2;
4275  double si2= 2.*pi*p2, sj2=2.*pj*p2, sij=2.*pi*pj;
4276  double ct2= pow2(si1*sj2-si2*sj1) / (s12*sij*(si1+si2)*(sj1+sj2));
4277 
4278  // Multiplicative weight factor to force first eikonal to current
4279  // outgoing momenta.
4280  double wij12 = 1. - (sij*s12) / ((si1 + si2)*(sj1 + sj2));
4281  wt_base_as1 = preFac*(1.- ct2)*wij12;
4282 
4283  // Uncorrelated g->qq splitting.
4284  } else {
4285  if (doGeneralizedKernel) {
4286  wt_base_as1 = preFac * ( pow(1.-z,2.) + pow(z,2.) )
4287  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
4288  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
4289  + preFac * fCoef();
4290  } else {
4291  wt_base_as1 = preFac * ( pow(1.-z,2.) + pow(z,2.) );
4292  }
4293  }
4294 
4295  // Switch off splitting when only considering double log contributions.
4296  if (order == -1) wt_base_as1 = 0.0;
4297 
4298  // Calculate argument of alphaS.
4299  double scale2 = couplingScale2 ( z, pT2, m2dip,
4300  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
4301  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
4302  if (scale2 < 0.) scale2 = pT2;
4303 
4304  wts.insert( make_pair("base", wt_base_as1 ));
4305  if (doVariations) {
4306  // Create muR-variations.
4307  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
4308  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
4309  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
4310  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
4311  }
4312  // Correction for massive splittings.
4313  bool doMassive = (abs(splitType) == 2);
4314 
4315  if (doMassive) {
4316 
4317  double vijk = 1., pipj = 0.;
4318 
4319  // splitType == 2 -> Massive FF
4320  if (splitType == 2) {
4321  // Calculate CS variables.
4322  double yCS = kappa2 / (1.-z);
4323  double nu2Rad = m2Rad/m2dip;
4324  double nu2Emt = m2Emt/m2dip;
4325  double nu2Rec = m2Rec/m2dip;
4326  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
4327  vijk = sqrt(vijk) / (1-yCS);
4328  pipj = m2dip * yCS /2.;
4329 
4330  // splitType ==-2 -> Massive FI
4331  } else if (splitType ==-2) {
4332  // Calculate CS variables.
4333  double xCS = 1 - kappa2/(1.-z);
4334  vijk = 1.;
4335  pipj = m2dip/2. * (1-xCS)/xCS;
4336  }
4337 
4338  wt_base_as1 = preFac * 1. / vijk * m2Emt / (pipj + m2Emt);
4339  if (doGeneralizedKernel) {
4340  wt_base_as1 += preFac * 1. / vijk * ( pow(1.-z,2.) + pow(z,2.) )
4341  * ( 1./z*cCoef(-1) + cCoef(0) + z*cCoef(1) + z*z*cCoef(2))
4342  * exp(1./z*cExp(-1) + cExp(0) + z*cExp(1) + z*z*cExp(2))
4343  + preFac * fCoef();
4344  } else {
4345  wt_base_as1 += preFac * 1. / vijk * (pow(1.-z,2.) + pow(z,2.));
4346  }
4347 
4348  // Switch off splitting when only considering double log contributions.
4349  if (order == -1) wt_base_as1 = 0.0;
4350 
4351  // Reset kernel for massive splittings.
4352  for ( unordered_map<string,double>::iterator it = wts.begin();
4353  it != wts.end(); ++it)
4354  it->second = wt_base_as1;
4355 
4356  }
4357 
4358  // Add NLO term.
4359  if (!doMassive && order == 3) {
4360  for ( unordered_map<string,double>::iterator it = wts.begin();
4361  it !=wts.end(); ++it){
4362  double mukf = 1.;
4363  if (it->first == "base")
4364  mukf = renormMultFac;
4365  else if (it->first == "Variations:muRfsrDown")
4366  mukf = settingsPtr->parm("Variations:muRfsrDown");
4367  else if (it->first == "Variations:muRfsrUp")
4368  mukf = settingsPtr->parm("Variations:muRfsrUp");
4369  else continue;
4370 
4371  // Do not perform variations below a small pT cut.
4372  if (scale2 < pT2minVariations) mukf = renormMultFac;
4373 
4374  double NF = getNF(scale2 * mukf);
4375  double alphasPT2pi = as2Pi(scale2, order, mukf);
4376  double TF = TR*NF;
4377  double x = 1-z;
4378  double pgq1 = preFac * (
4379  (TF*(-8./3. - (8*(1 + 2*(-1 + x)*x)*(2 + 3*log(1 - x) + 3*log(x)))/9.)
4380  + CF*(-2 + 3*x - 4*log(1 - x) + (-7 + 8*x)*log(x) + (1 - 2*x)
4381  *pow2(log(x)) -
4382  (2*(1 + 2*(-1 + x)*x)*(15 - 24*DiLog(x) + 3*log(-1 + 1/x) - 24
4383  *log(1 - x)*log(x) + pow2(M_PI) + 3*pow2(log(-((-1 + x)*x)))))/3.) +
4384  (CA*(-152 - 40/x + 166*x + 36*log(1 - x) - 12*(1 + 19*x)*log(x) +
4385  (1 + 2*(-1 + x)*x)*(178 - 144*DiLog(x) + log(1 - x)*(30 - 72*log(x)) -
4386  3*log(x)*(4 + 3*log(x)) + 3*pow2(M_PI) +
4387  18*pow2(log(1 - x))) + 9*(2 + 8*x)*pow2(log(x)) +
4388  3*(1 + 2*x*(1 + x))*(-12*DiLog(1/(1 + x)) + pow2(M_PI) +
4389  3*pow2(log(x)) - 6*pow2(log(1 + x)))))/9.)/2.
4390  );
4391  // Replace 1/z in NLO kernel with z/(z*z+kappa2) to restore sum rule.
4392  // Include additional factor of 0.5 as we have two g->qq kernels.
4393  pgq1 += - preFac * 0.5 * 40./9. * CA * ( x /(x*x + kappa2) - 1./x);
4394  // Add NLO term.
4395  it->second += alphasPT2pi*pgq1;
4396  }
4397  }
4398 
4399  // Multiply with z to project out part where emitted antiquark is soft,
4400  // and quark is identified.
4401  for ( unordered_map<string,double>::iterator it = wts.begin();
4402  it != wts.end(); ++it )
4403  it->second *= (1-z);
4404 
4405  wt_base_as1 *= (1-z);
4406  // Store higher order correction separately.
4407  if (order > 0) wts.insert( make_pair("base_order_as2",
4408  wts["base"] - wt_base_as1 ));
4409 
4410  // Store kernel values.
4411  clearKernels();
4412  for ( unordered_map<string,double>::iterator it = wts.begin();
4413  it != wts.end(); ++it )
4414  kernelVals.insert(make_pair( it->first, it->second ));
4415 
4416  return true;
4417 
4418 }
4419 
4420 //==========================================================================
4421 
4422 // Class inheriting from SplittingQCD class.
4423 
4424 // SplittingQCD function Q-> q Q qbar (FSR)
4425 
4426 // Return true if this kernel should partake in the evolution.
4427 bool Dire_fsr_qcd_Q2qQqbarDist::canRadiate ( const Event& state,
4428  pair<int,int> ints, unordered_map<string,bool>, Settings*, PartonSystems*,
4429  BeamParticle*) {
4430  return ( state[ints.first].isFinal()
4431  && state[ints.second].colType() != 0
4432  && hasSharedColor(state, ints.first, ints.second)
4433  && state[ints.first].isQuark() );
4434 }
4435 
4436 bool Dire_fsr_qcd_Q2qQqbarDist::canRadiate (const Event& state, int iRadBef,
4437  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
4438  if (orderSave < 3) return false;
4439  return ( state[iRadBef].isFinal()
4440  && state[iRecBef].colType() != 0
4441  && hasSharedColor(state, iRadBef, iRecBef)
4442  && state[iRadBef].isQuark());
4443 }
4444 
4445 int Dire_fsr_qcd_Q2qQqbarDist::kinMap() { return 2;}
4446 int Dire_fsr_qcd_Q2qQqbarDist::motherID(int idDaughter) { return idDaughter;}
4447 int Dire_fsr_qcd_Q2qQqbarDist::sisterID(int) { return 1;}
4448 double Dire_fsr_qcd_Q2qQqbarDist::gaugeFactor ( int, int ) { return CF;}
4449 double Dire_fsr_qcd_Q2qQqbarDist::symmetryFactor ( int, int ) { return 1.;}
4450 
4451 int Dire_fsr_qcd_Q2qQqbarDist::radBefID(int idRA, int) {
4452  if (particleDataPtr->isQuark(idRA)) return idRA;
4453  return 0;
4454 }
4455 pair<int,int> Dire_fsr_qcd_Q2qQqbarDist::radBefCols(
4456  int colRadAfter, int,
4457  int colEmtAfter, int acolEmtAfter) {
4458  bool isQuark = (colRadAfter > 0);
4459  if (isQuark) return make_pair(colEmtAfter,0);
4460  return make_pair(0,acolEmtAfter);
4461 }
4462 
4463 // Pick z for new splitting.
4464 double Dire_fsr_qcd_Q2qQqbarDist::zSplit(double zMinAbs, double zMaxAbs,
4465  double m2dip) {
4466 
4467  double Rz = rndmPtr->flat();
4468  double kappa4 = pow(settingsPtr->parm("TimeShower:pTmin"), 4) / pow2(m2dip);
4469  double res = 1.;
4470  // z est from 1/(z + kappa^4)
4471  res = pow( (kappa4 + zMaxAbs)/(kappa4 + zMinAbs), -Rz )
4472  * (kappa4 + zMaxAbs - kappa4
4473  *pow((kappa4 + zMaxAbs)/(kappa4 + zMinAbs), Rz));
4474 
4475  return res;
4476 
4477 }
4478 
4479 // New overestimates, z-integrated versions.
4480 double Dire_fsr_qcd_Q2qQqbarDist::overestimateInt(double zMinAbs,
4481  double zMaxAbs, double, double m2dip, int orderNow) {
4482 
4483  // Do nothing without other NLO kernels!
4484  int order = (orderNow > -1) ? orderNow : correctionOrder;
4485  if (order != 3) return 0.0;
4486 
4487  double preFac = symmetryFactor() * gaugeFactor();
4488  double pT2min = pow2(settingsPtr->parm("TimeShower:pTmin"));
4489  double kappa4 = pow2(pT2min/m2dip);
4490  // Overestimate chosen to have accept weights below one for kappa~0.1
4491  // z est from 1/(z + kappa^4)
4492  double wt = preFac * TR * 2. * ( NF_qcd_fsr - 1. ) * 20./9.
4493  * log( ( kappa4 + zMaxAbs) / ( kappa4 + zMinAbs) );
4494 
4495  // This splitting is down by one power of alphaS !
4496  wt *= as2Pi(pT2min);
4497 
4498  return wt;
4499 
4500 }
4501 
4502 // Return overestimate for new splitting.
4503 double Dire_fsr_qcd_Q2qQqbarDist::overestimateDiff(double z, double m2dip,
4504  int orderNow) {
4505 
4506  // Do nothing without other NLO kernels!
4507  int order = (orderNow > -1) ? orderNow : correctionOrder;
4508  if (order < 3) return 0.0;
4509 
4510  double preFac = symmetryFactor() * gaugeFactor();
4511  double pT2min = pow2(settingsPtr->parm("TimeShower:pTmin"));
4512  double kappa4 = pow2(pT2min/m2dip);
4513  // Overestimate chosen to have accept weights below one for kappa~0.1
4514  double wt = preFac * TR * 2. * ( NF_qcd_fsr - 1. ) * 20./ 9. * 1
4515  / (z + kappa4);
4516 
4517  // This splitting is down by one power of alphaS !
4518  wt *= as2Pi(pT2min);
4519 
4520  return wt;
4521 
4522 }
4523 
4524 // Return kernel for new splitting.
4525 bool Dire_fsr_qcd_Q2qQqbarDist::calc(const Event& state, int orderNow) {
4526 
4527  // Dummy statement to avoid compiler warnings.
4528  if (false) cout << state[0].e() << orderNow << endl;
4529 
4530  // Read all splitting variables.
4531  double z(splitInfo.kinematics()->z),
4532  pT2(splitInfo.kinematics()->pT2),
4533  m2dip(splitInfo.kinematics()->m2Dip),
4534  xa(splitInfo.kinematics()->xa),
4535  sai(splitInfo.kinematics()->sai),
4536  m2aij(splitInfo.kinematics()->m2RadBef),
4537  m2a(splitInfo.kinematics()->m2RadAft),
4538  m2i(splitInfo.kinematics()->m2EmtAft),
4539  m2j(splitInfo.kinematics()->m2EmtAft2),
4540  m2k(splitInfo.kinematics()->m2Rec);
4541 
4542  // Calculate argument of alphaS.
4543  double scale2 = couplingScale2 ( z, pT2, m2dip,
4544  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
4545  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
4546  if (scale2 < 0.) scale2 = pT2;
4547 
4548  // Do nothing without other NLO kernels!
4549  unordered_map<string,double> wts;
4550  int order = (orderNow > -1) ? orderNow : correctionOrder;
4551  if (order < 3 || m2aij > 0. || m2a > 0. || m2i > 0. || m2j > 0. || m2k > 0.){
4552  wts.insert( make_pair("base", 0.) );
4553  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
4554  wts.insert( make_pair("Variations:muRfsrDown", 0.));
4555  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
4556  wts.insert( make_pair("Variations:muRfsrUp", 0.));
4557  clearKernels();
4558  for ( unordered_map<string,double>::iterator it = wts.begin();
4559  it != wts.end(); ++it )
4560  kernelVals.insert(make_pair( it->first, it->second ));
4561  return true;
4562  }
4563 
4564  // Choose if simulating endpoint or differential 1->3 (latter containing
4565  // both sai=0 and sai !=0). For choice of endpoint, set sai=0 later.
4566  bool isEndpoint = (rndmPtr->flat() < 0.5);
4567 
4568  Event trialEvent(state);
4569  bool physical = false;
4570  if (splitInfo.recBef()->isFinal)
4571  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
4572  else
4573  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
4574 
4575  // Get invariants.
4576  Vec4 pa(trialEvent[splitInfo.iRadAft].p());
4577  Vec4 pk(trialEvent[splitInfo.iRecAft].p());
4578  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
4579  Vec4 pj(trialEvent[splitInfo.iEmtAft2].p());
4580 
4581  // Use only massless for now!
4582  if ( abs(pa.m2Calc()-m2a) > sai || abs(pi.m2Calc()-m2i) > sai
4583  || abs(pj.m2Calc()-m2j) > sai || abs(pk.m2Calc()-m2k) > sai)
4584  physical = false;
4585 
4586  if (!physical) {
4587  wts.insert( make_pair("base", 0.) );
4588  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
4589  wts.insert( make_pair("Variations:muRfsrDown", 0.));
4590  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
4591  wts.insert( make_pair("Variations:muRfsrUp", 0.));
4592  clearKernels();
4593  for ( unordered_map<string,double>::iterator it = wts.begin();
4594  it != wts.end(); ++it )
4595  kernelVals.insert(make_pair( it->first, it->second ));
4596  return true;
4597  }
4598 
4599  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
4600  double p2ai(sai + m2a + m2i),
4601  p2aj((pa+pj).m2Calc()),
4602  p2ak(sign*(pa+sign*pk).m2Calc()),
4603  p2ij((pi+pj).m2Calc()),
4604  p2ik(sign*(pi+sign*pk).m2Calc()),
4605  p2jk(sign*(pj+sign*pk).m2Calc());
4606  double q2 = sign*(pa+pi+pj+sign*pk).m2Calc();
4607  double saij = (pa+pi+pj).m2Calc();
4608  double yaij = (splitInfo.recBef()->isFinal) ? saij / q2 : 0.;
4609 
4610  double prob = 0.0;
4611  double z1(z/(1.-yaij)), z2( z/xa/(1-yaij) - z1 ), z3(1-z1-z2);
4612 
4613  if (isEndpoint) {
4614 
4615  prob = CF*TR*((1.0+z3*z3)/(1.0-z3)
4616  +(1.0-2.0*z1*z2/pow2(z1+z2))*(1.0-z3+(1.0+z3*z3)/(1.0-z3)
4617  *(log(z1*z2*z3)-1.0)));
4618  prob-= CF*TR*2.0*((1.0+z3*z3)/(1.0-z3)*log(z3*(1.0-z3)) +1.0-z3)
4619  *(1.0-2.0*z1*z2/pow2(z1+z2));
4620 
4621  // there are 2nf-2 such kernels.
4622  prob *= 2. * ( NF_qcd_fsr - 1. );
4623  // From xa integration volume.
4624  prob *= log(1/z1);
4625  // Multiply by 2 since we randomly chose endpoint or fully differential.
4626  prob *= 2.0;
4627  // Weight of sai-selection. Note: Use non-zero sai here!
4628  prob *= 1. / (1.-p2ai/saij);
4629 
4630  } else {
4631 
4632  double s12(p2ai), s13(p2aj), s23(p2ij), s123(saij);
4633  double t123 = 2.*(z1*s23 - z2*s13)/(z1+z2) + (z1-z2)/(z1+z2)*s12;
4634  double CG = 0.5*CF*TR*s123/s12
4635  *( - pow2(t123)/ (s12*s123)
4636  + (4.*z3 + pow2(z1-z2))/(z1+z2) + z1 + z2 - s12/s123 );
4637  double cosPhiKT1KT3 = pow2(p2ij*p2ak - p2aj*p2ik + p2ai*p2jk)
4638  / (4.*p2ai*p2ij*p2ak*p2jk);
4639  double subt = CF*TR*s123/s12
4640  * ( (1.+z3*z3) / (1.-z3) * (1.-2.*z1*z2/pow2(1-z3))
4641  + 4.*z1*z2*z3 / pow(1.-z3,3) * (1-2.*cosPhiKT1KT3) );
4642  prob = CG - subt;
4643 
4644  if ( abs(s12) < 1e-10) prob = 0.0;
4645 
4646  // there are 2nf-2 such kernels.
4647  prob *= 2. * ( NF_qcd_fsr - 1. );
4648  // From xa integration volume.
4649  prob *= log(1/z1);
4650  // Multiply by 2 since we randomly chose endpoint or fully differential.
4651  prob *= 2.0;
4652  // Weight of sai-selection.
4653  prob *= 1. / (1.-p2ai/saij);
4654 
4655  }
4656 
4657  // Remember that this might be an endpoint with vanishing sai.
4658  if (isEndpoint) { splitInfo.set_sai(0.0); }
4659 
4660  // Insert value of kernel into kernel list.
4661  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
4662  if (doVariations) {
4663  // Create muR-variations.
4664  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
4665  wts.insert( make_pair("Variations:muRfsrDown", prob
4666  * as2Pi(scale2, order, (scale2 > pT2minVariations)
4667  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
4668  renormMultFac) ));
4669  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
4670  wts.insert( make_pair("Variations:muRfsrUp", prob
4671  * as2Pi(scale2, order, (scale2 > pT2minVariations)
4672  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
4673  renormMultFac) ));
4674  }
4675 
4676  // Multiply with z to project out part where emitted antiquark is soft,
4677  // and quark is identified.
4678  for ( unordered_map<string,double>::iterator it = wts.begin();
4679  it != wts.end(); ++it )
4680  it->second *= z;
4681 
4682  // Store higher order correction separately.
4683  wts.insert( make_pair("base_order_as2", wts["base"] ));
4684 
4685  // Store kernel values.
4686  clearKernels();
4687  for ( unordered_map<string,double>::iterator it = wts.begin();
4688  it != wts.end(); ++it )
4689  kernelVals.insert(make_pair( it->first, it->second ));
4690 
4691  return true;
4692 }
4693 
4694 //==========================================================================
4695 
4696 // Class inheriting from SplittingQCD class.
4697 
4698 // SplittingQCD function Q-> Qbar Q Q (FSR)
4699 
4700 // Return true if this kernel should partake in the evolution.
4701 bool Dire_fsr_qcd_Q2QbarQQId::canRadiate ( const Event& state,
4702  pair<int,int> ints,
4703  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
4704  return ( state[ints.first].isFinal()
4705  && state[ints.second].colType() != 0
4706  && hasSharedColor(state, ints.first, ints.second)
4707  && state[ints.first].isQuark() );
4708 }
4709 
4710 bool Dire_fsr_qcd_Q2QbarQQId::canRadiate (const Event& state, int iRadBef,
4711  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
4712  if (orderSave < 3) return false;
4713  return ( state[iRadBef].isFinal()
4714  && state[iRecBef].colType() != 0
4715  && hasSharedColor(state, iRadBef, iRecBef)
4716  && state[iRadBef].isQuark());
4717 }
4718 
4719 int Dire_fsr_qcd_Q2QbarQQId::kinMap() { return 2;}
4720 int Dire_fsr_qcd_Q2QbarQQId::motherID(int idDaughter) { return idDaughter;}
4721 int Dire_fsr_qcd_Q2QbarQQId::sisterID(int) { return 1;}
4722 double Dire_fsr_qcd_Q2QbarQQId::gaugeFactor ( int, int ) { return CF;}
4723 double Dire_fsr_qcd_Q2QbarQQId::symmetryFactor ( int, int ) { return 1.;}
4724 
4725 int Dire_fsr_qcd_Q2QbarQQId::radBefID(int idRA, int) {
4726  if (particleDataPtr->isQuark(idRA)) return idRA;
4727  return 0;
4728 }
4729 pair<int,int> Dire_fsr_qcd_Q2QbarQQId::radBefCols(
4730  int colRadAfter, int,
4731  int colEmtAfter, int acolEmtAfter) {
4732  bool isQuark = (colRadAfter > 0);
4733  if (isQuark) return make_pair(colEmtAfter,0);
4734  return make_pair(0,acolEmtAfter);
4735 }
4736 
4737 // Pick z for new splitting.
4738 double Dire_fsr_qcd_Q2QbarQQId::zSplit(double zMinAbs, double zMaxAbs,
4739  double m2dip) {
4740 
4741  // z est from 1/4 z/(z^2 + kappa^2)
4742  double Rz = rndmPtr->flat();
4743  double kappaMin2 = pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip;
4744  double p = (kappaMin2 + zMaxAbs*zMaxAbs)
4745  / (kappaMin2 + zMinAbs*zMinAbs);
4746  double res = sqrt( (kappaMin2 + zMaxAbs*zMaxAbs - kappaMin2*pow(p,Rz))
4747  /pow(p,Rz) );
4748  return res;
4749 
4750 }
4751 
4752 // New overestimates, z-integrated versions.
4753 double Dire_fsr_qcd_Q2QbarQQId::overestimateInt(double zMinAbs, double zMaxAbs,
4754  double, double m2dip, int orderNow) {
4755 
4756  // Do nothing without other NLO kernels!
4757  int order = (orderNow > -1) ? orderNow : correctionOrder;
4758  if (order != 3) return 0.0;
4759 
4760  // z est from 1/4 z/(z^2 + kappa^2)
4761  double preFac = symmetryFactor() * gaugeFactor();
4762  double pT2min = pow2(settingsPtr->parm("TimeShower:pTmin"));
4763  double kappaMin2 = pT2min/m2dip;
4764  double wt = preFac * TR * 20./9.
4765  * 0.5 * log( ( kappaMin2 + zMaxAbs*zMaxAbs)
4766  / ( kappaMin2 + zMinAbs*zMinAbs) );
4767  // This splitting is down by one power of alphaS !
4768  wt *= as2Pi(pT2min);
4769  return wt;
4770 
4771 }
4772 
4773 // Return overestimate for new splitting.
4774 double Dire_fsr_qcd_Q2QbarQQId::overestimateDiff(double z, double m2dip,
4775  int orderNow) {
4776 
4777  // Do nothing without other NLO kernels!
4778  int order = (orderNow > -1) ? orderNow : correctionOrder;
4779  if (order < 3) return 0.0;
4780 
4781  double preFac = symmetryFactor() * gaugeFactor();
4782  double pT2min = pow2(settingsPtr->parm("TimeShower:pTmin"));
4783  double kappaMin2 = pT2min/m2dip;
4784  double wt = preFac * TR * 20./ 9. * z / (z*z + kappaMin2);
4785  // This splitting is down by one power of alphaS !
4786  wt *= as2Pi(pT2min);
4787  return wt;
4788 
4789 }
4790 
4791 // Return kernel for new splitting.
4792 bool Dire_fsr_qcd_Q2QbarQQId::calc(const Event& state, int orderNow) {
4793 
4794  // Dummy statement to avoid compiler warnings.
4795  if (false) cout << state[0].e() << orderNow << endl;
4796 
4797  // Read all splitting variables.
4798  double z(splitInfo.kinematics()->z),
4799  pT2(splitInfo.kinematics()->pT2),
4800  m2dip(splitInfo.kinematics()->m2Dip),
4801  xa(splitInfo.kinematics()->xa),
4802  sai(splitInfo.kinematics()->sai),
4803  m2aij(splitInfo.kinematics()->m2RadBef),
4804  m2a(splitInfo.kinematics()->m2RadAft),
4805  m2i(splitInfo.kinematics()->m2EmtAft),
4806  m2j(splitInfo.kinematics()->m2EmtAft2),
4807  m2k(splitInfo.kinematics()->m2Rec);
4808 
4809  // Calculate argument of alphaS.
4810  double scale2 = couplingScale2 ( z, pT2, m2dip,
4811  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
4812  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
4813  if (scale2 < 0.) scale2 = pT2;
4814 
4815  unordered_map<string,double> wts;
4816  int order = (orderNow > -1) ? orderNow : correctionOrder;
4817  // Do nothing without other NLO kernels!
4818  if (order < 3 || m2aij > 0. || m2a > 0. || m2i > 0. || m2j > 0. || m2k > 0.){
4819  wts.insert( make_pair("base", 0.) );
4820  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
4821  wts.insert( make_pair("Variations:muRfsrDown", 0.));
4822  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
4823  wts.insert( make_pair("Variations:muRfsrUp", 0.));
4824  clearKernels();
4825  for ( unordered_map<string,double>::iterator it = wts.begin();
4826  it != wts.end(); ++it )
4827  kernelVals.insert(make_pair( it->first, it->second ));
4828  return true;
4829  }
4830 
4831  // Choose if simulating endpoint or differential 1->3 (latter containing
4832  // both sai=0 and sai !=0). For choice of endpoint, set sai=0 later.
4833  bool isEndpoint = (rndmPtr->flat() < 0.5);
4834 
4835  Event trialEvent(state);
4836  bool physical = false;
4837  if (splitInfo.recBef()->isFinal)
4838  physical = fsr->branch_FF(trialEvent, true, &splitInfo);
4839  else
4840  physical = fsr->branch_FI(trialEvent, true, &splitInfo);
4841 
4842  // Get invariants.
4843  Vec4 pa(trialEvent[splitInfo.iRadAft].p());
4844  Vec4 pk(trialEvent[splitInfo.iRecAft].p());
4845  Vec4 pi(trialEvent[splitInfo.iEmtAft].p());
4846  Vec4 pj(trialEvent[splitInfo.iEmtAft2].p());
4847 
4848  // Use only massless for now!
4849  if ( abs(pa.m2Calc()-m2a) > sai || abs(pi.m2Calc()-m2i) > sai
4850  || abs(pj.m2Calc()-m2j) > sai || abs(pk.m2Calc()-m2k) > sai)
4851  physical = false;
4852 
4853  if (!physical) {
4854  wts.insert( make_pair("base", 0.) );
4855  if (doVariations && settingsPtr->parm("Variations:muRfsrDown") != 1.)
4856  wts.insert( make_pair("Variations:muRfsrDown", 0.));
4857  if (doVariations && settingsPtr->parm("Variations:muRfsrUp") != 1.)
4858  wts.insert( make_pair("Variations:muRfsrUp", 0.));
4859  clearKernels();
4860  for ( unordered_map<string,double>::iterator it = wts.begin();
4861  it != wts.end(); ++it )
4862  kernelVals.insert(make_pair( it->first, it->second ));
4863  return true;
4864  }
4865 
4866  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
4867  double p2ai(sai + m2a + m2i),
4868  p2aj((pa+pj).m2Calc()),
4869  p2ak(sign*(pa+sign*pk).m2Calc()),
4870  p2ij((pi+pj).m2Calc()),
4871  p2ik(sign*(pi+sign*pk).m2Calc()),
4872  p2jk(sign*(pj+sign*pk).m2Calc());
4873  double q2 = sign*(pa+pi+pj+sign*pk).m2Calc();
4874  double saij = (pa+pi+pj).m2Calc();
4875  double yaij = (splitInfo.recBef()->isFinal) ? saij / q2 : 0.;
4876 
4877  double prob = 0.0;
4878  double z1(z/(1.-yaij)), z2( z/xa/(1-yaij) - z1 ), z3(1-z1-z2);
4879 
4880  if (isEndpoint) {
4881 
4882  prob = CF*TR*((1.0+z3*z3)/(1.0-z3)
4883  +(1.0-2.0*z1*z2/pow2(z1+z2))*(1.0-z3+(1.0+z3*z3)/(1.0-z3)
4884  *(log(z1*z2*z3)-1.0)));
4885  // Swapped contribution.
4886  prob+= CF*TR*((1.0+z2*z2)/(1.0-z2)
4887  +(1.0-2.0*z1*z3/pow2(z1+z3))*(1.0-z2+(1.0+z2*z2)/(1.0-z2)
4888  *(log(z1*z3*z2)-1.0)));
4889  // Subtraction.
4890  prob-= CF*TR*2.0*((1.0+z3*z3)/(1.0-z3)*log(z3*(1.0-z3)) +1.0-z3)
4891  *(1.0-2.0*z1*z2/pow2(z1+z2));
4892  // Swapped subtraction.
4893  prob-= CF*TR*2.0*((1.0+z2*z2)/(1.0-z2)*log(z2*(1.0-z2)) +1.0-z2)
4894  *(1.0-2.0*z1*z3/pow2(z1+z3));
4895 
4896  // From xa integration volume.
4897  prob *= log(1/z1);
4898  // Multiply by 2 since we randomly chose endpoint or fully differential.
4899  prob *= 2.0;
4900  // Weight of sai-selection. Note: Use non-zero sai here!
4901  prob *= 1. / (1.-p2ai/saij);
4902 
4903  } else {
4904 
4905  double s12(p2ai), s13(p2aj), s23(p2ij), s123(saij);
4906  double t123 = 2.*(z1*s23 - z2*s13)/(z1+z2) + (z1-z2)/(z1+z2)*s12;
4907  double CG = 0.5*CF*TR*s123/s12
4908  *( - pow2(t123)/ (s12*s123)
4909  + (4.*z3 + pow2(z1-z2))/(z1+z2) + z1 + z2 - s12/s123 );
4910  // Swapped kernel.
4911  double t132 = 2.*(z1*s23 - z3*s12)/(z1+z3) + (z1-z3)/(z1+z3)*s13;
4912  CG += 0.5*CF*TR*s123/s13
4913  *( - pow2(t132)/ (s13*s123)
4914  + (4.*z2 + pow2(z1-z3))/(z1+z3) + z1 + z3 - s13/s123 );
4915  // Interference term.
4916  CG += CF*(CF-0.5*CA)
4917  * ( 2.*s23/s12
4918  + s123/s12 * ( (1.+z1*z1)/(1-z2) - 2.*z2/(1.-z3) )
4919  - s123*s123/(s12*s13) * 0.5*z1*(1.+z1*z1) / ((1.-z2)*(1.-z3)));
4920  // Swapped interference term.
4921  CG += CF*(CF-0.5*CA)
4922  * ( 2.*s23/s13
4923  + s123/s13 * ( (1.+z1*z1)/(1-z3) - 2.*z3/(1.-z2) )
4924  - s123*s123/(s13*s12) * 0.5*z1*(1.+z1*z1) / ((1.-z3)*(1.-z2)));
4925  // Subtraction.
4926  double cosPhiKT1KT3 = pow2(p2ij*p2ak - p2aj*p2ik + p2ai*p2jk)
4927  / (4.*p2ai*p2ij*p2ak*p2jk);
4928  double subt = CF*TR*s123/s12
4929  * ( (1.+z3*z3) / (1.-z3) * (1.-2.*z1*z2/pow2(1-z3))
4930  + 4.*z1*z2*z3 / pow(1.-z3,3) * (1-2.*cosPhiKT1KT3) );
4931  // Swapped subtraction.
4932  double cosPhiKT1KT2 = pow2(p2ij*p2ak + p2aj*p2ik - p2ai*p2jk)
4933  / (4.*p2aj*p2ij*p2ak*p2ik);
4934  subt += CF*TR*s123/s13
4935  * ( (1.+z2*z2) / (1.-z2) * (1.-2.*z1*z3/pow2(1-z2))
4936  + 4.*z1*z3*z2 / pow(1.-z2,3) * (1-2.*cosPhiKT1KT2) );
4937  prob = CG - subt;
4938 
4939  if ( abs(s12) < 1e-10) prob = 0.0;
4940 
4941  // From xa integration volume.
4942  prob *= log(1/z1);
4943  // Multiply by 2 since we randomly chose endpoint or fully differential.
4944  prob *= 2.0;
4945  // Weight of sai-selection.
4946  prob *= 1. / (1.-p2ai/saij);
4947 
4948  }
4949 
4950  // Desymmetrize in i and j.
4951  prob *= (z/xa - z) / ( 1- z);
4952 
4953  // Remember that this might be an endpoint with vanishing sai.
4954  if (isEndpoint) { splitInfo.set_sai(0.0); }
4955 
4956  wts.insert( make_pair("base", prob*as2Pi(scale2, order, renormMultFac) ));
4957 
4958  if (doVariations) {
4959  // Create muR-variations.
4960  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
4961  wts.insert( make_pair("Variations:muRfsrDown", prob
4962  * as2Pi(scale2, order, (scale2 > pT2minVariations)
4963  ? settingsPtr->parm("Variations:muRfsrDown")*renormMultFac :
4964  renormMultFac) ));
4965  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
4966  wts.insert( make_pair("Variations:muRfsrUp", prob
4967  * as2Pi(scale2, order, (scale2 > pT2minVariations)
4968  ? settingsPtr->parm("Variations:muRfsrUp")*renormMultFac :
4969  renormMultFac) ));
4970  }
4971 
4972  // Multiply with z to project out part where emitted antiquark is soft,
4973  // and quark is identified.
4974  for ( unordered_map<string,double>::iterator it = wts.begin();
4975  it != wts.end(); ++it )
4976  it->second *= z;
4977 
4978  // Store higher order correction separately.
4979  wts.insert( make_pair("base_order_as2", wts["base"] ));
4980 
4981  // Store kernel values.
4982  clearKernels();
4983  for ( unordered_map<string,double>::iterator it = wts.begin();
4984  it != wts.end(); ++it )
4985  kernelVals.insert(make_pair( it->first, it->second ));
4986 
4987  return true;
4988 
4989 }
4990 
4991 //==========================================================================
4992 
4993 // Class inheriting from SplittingQCD class.
4994 
4995 // SplittingQCD function Q->QG (ISR)
4996 
4997 // Return true if this kernel should partake in the evolution.
4998 bool Dire_isr_qcd_Q2QG::canRadiate ( const Event& state, pair<int,int> ints,
4999  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
5000  return (!state[ints.first].isFinal()
5001  && state[ints.second].colType() != 0
5002  && hasSharedColor(state, ints.first, ints.second)
5003  && state[ints.first].isQuark() );
5004 }
5005 
5006 bool Dire_isr_qcd_Q2QG::canRadiate (const Event& state, int iRadBef,
5007  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
5008  return ( !state[iRadBef].isFinal()
5009  && state[iRecBef].colType() != 0
5010  && hasSharedColor(state, iRadBef, iRecBef)
5011  && state[iRadBef].isQuark());
5012 }
5013 
5014 int Dire_isr_qcd_Q2QG::kinMap() { return 1;}
5015 int Dire_isr_qcd_Q2QG::motherID(int idDaughter) { return idDaughter;}
5016 int Dire_isr_qcd_Q2QG::sisterID(int) { return 21;}
5017 double Dire_isr_qcd_Q2QG::gaugeFactor ( int, int ) { return CF;}
5018 double Dire_isr_qcd_Q2QG::symmetryFactor ( int, int ) { return 1.;}
5019 
5020 int Dire_isr_qcd_Q2QG::radBefID(int idRA, int) {
5021  if (particleDataPtr->isQuark(idRA)) return idRA;
5022  return 0;
5023 }
5024 pair<int,int> Dire_isr_qcd_Q2QG::radBefCols(
5025  int colRadAfter, int acolRadAfter,
5026  int colEmtAfter, int acolEmtAfter) {
5027  bool isQuark = (colRadAfter > 0);
5028  int colRemove = (colRadAfter == colEmtAfter)
5029  ? colRadAfter : 0;
5030  int col = (colRadAfter == colRemove)
5031  ? acolEmtAfter : colRadAfter;
5032  if (isQuark) return make_pair(col,0);
5033  colRemove = (acolRadAfter == acolEmtAfter)
5034  ? acolRadAfter : 0;
5035  int acol = (acolRadAfter == colRemove)
5036  ? colEmtAfter : acolRadAfter;
5037  return make_pair(0,acol);
5038 }
5039 
5040 vector <int> Dire_isr_qcd_Q2QG::recPositions( const Event& state, int iRad,
5041  int iEmt) {
5042 
5043  int colRad = state[iRad].col();
5044  int acolRad = state[iRad].acol();
5045  int colEmt = state[iEmt].col();
5046  int acolEmt = state[iEmt].acol();
5047  int colShared = (colRad > 0 && colRad == colEmt) ? colEmt
5048  : (acolRad > 0 && acolEmt == acolRad) ? acolEmt : 0;
5049  // Particles to exclude from colour tracing.
5050  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
5051 
5052  // Find partons connected via emitted colour line.
5053  vector<int> recs;
5054  if ( colEmt != 0 && colEmt != colShared) {
5055  int acolF = findCol(colEmt, iExc, state, 1);
5056  int colI = findCol(colEmt, iExc, state, 2);
5057  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5058  if (acolF == 0 && colI > 0) recs.push_back (colI);
5059  }
5060  // Find partons connected via emitted anticolour line.
5061  if ( acolEmt != 0 && acolEmt != colShared) {
5062  int colF = findCol(acolEmt, iExc, state, 2);
5063  int acolI = findCol(acolEmt, iExc, state, 1);
5064  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5065  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5066  }
5067  // Done.
5068  return recs;
5069 }
5070 
5071 // Pick z for new splitting.
5072 double Dire_isr_qcd_Q2QG::zSplit(double zMinAbs, double, double m2dip) {
5073  double Rz = rndmPtr->flat();
5074  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5075  double p = pow( 1. + pow2(1-zMinAbs)/kappa2, Rz );
5076  double res = 1. - sqrt( p - 1. )*sqrt(kappa2);
5077  return res;
5078 }
5079 
5080 // New overestimates, z-integrated versions.
5081 double Dire_isr_qcd_Q2QG::overestimateInt(double zMinAbs, double,
5082  double, double m2dip, int orderNow) {
5083  double wt = 0.;
5084  double preFac = symmetryFactor() * gaugeFactor();
5085  int order = (orderNow > -1) ? orderNow : correctionOrder;
5086  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5087  wt = preFac * softRescaleInt(order)
5088  * 2. * 0.5 * log( 1. + pow2(1.-zMinAbs)/kappa2);
5089  return wt;
5090 }
5091 
5092 // Return overestimate for new splitting.
5093 double Dire_isr_qcd_Q2QG::overestimateDiff(double z, double m2dip,
5094  int orderNow) {
5095  double wt = 0.;
5096  double preFac = symmetryFactor() * gaugeFactor();
5097  int order = (orderNow > -1) ? orderNow : correctionOrder;
5098  double kappaOld2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5099  wt = preFac * softRescaleInt(order)
5100  * 2.* (1.-z) / ( pow2(1.-z) + kappaOld2);
5101  return wt;
5102 }
5103 
5104 // Return kernel for new splitting.
5105 bool Dire_isr_qcd_Q2QG::calc(const Event& state, int orderNow) {
5106 
5107  // Dummy statement to avoid compiler warnings.
5108  if (false) cout << state[0].e() << orderNow << endl;
5109 
5110  // Read all splitting variables.
5111  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
5112  m2dip(splitInfo.kinematics()->m2Dip);
5113 
5114  double preFac = symmetryFactor() * gaugeFactor();
5115  int order = (orderNow > -1) ? orderNow : correctionOrder;
5116  double kappa2 = max(pow2(settingsPtr->parm("SpaceShower:pTmin"))
5117  /m2dip, pT2/m2dip);
5118 
5119  unordered_map<string,double> wts;
5120  double wt_base_as1 = preFac * 2.*(1.-z)/(pow2(1.-z) + kappa2);
5121 
5122  if (order >= 0) wt_base_as1 += -preFac*(1.+z);
5123 
5124  // Calculate argument of alphaS.
5125  double scale2 = couplingScale2 ( z, pT2, m2dip,
5126  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
5127  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
5128  if (scale2 < 0.) scale2 = pT2;
5129 
5130  wts.insert( make_pair("base", wt_base_as1
5131  * softRescaleDiff( order, scale2, renormMultFac) ));
5132  if (doVariations) {
5133  // Create muR-variations.
5134  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
5135  wts.insert( make_pair("Variations:muRisrDown", wt_base_as1
5136  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
5137  ? settingsPtr->parm("Variations:muRisrDown")*renormMultFac :
5138  renormMultFac) ));
5139  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
5140  wts.insert( make_pair("Variations:muRisrUp", wt_base_as1
5141  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
5142  ? settingsPtr->parm("Variations:muRisrUp")*renormMultFac :
5143  renormMultFac) ));
5144  }
5145 
5146  // Add NLO term, subtracted by ~ 1/(1-z)*Gamma2,
5147  // since latter already present in soft rescaling term.
5148  if (order == 3) {
5149  for ( unordered_map<string,double>::iterator it = wts.begin();
5150  it !=wts.end(); ++it) {
5151 
5152  double mukf = 1.;
5153  if (it->first == "base")
5154  mukf = renormMultFac;
5155  else if (it->first == "Variations:muRisrDown")
5156  mukf = settingsPtr->parm("Variations:muRisrDown");
5157  else if (it->first == "Variations:muRisrUp")
5158  mukf = settingsPtr->parm("Variations:muRisrUp");
5159  else continue;
5160 
5161  // Do not perform variations below a small pT cut.
5162  if (scale2 < pT2minVariations) mukf = renormMultFac;
5163 
5164  double NF = getNF(scale2 * mukf);
5165  double alphasPT2pi = as2Pi(scale2, order, mukf);
5166  double TF = TR*NF;
5167  double pqq1 = preFac * 1 / ( 18*z*(z-1) ) * (
5168  (-1 + z)*(-8*TF*(-5 + (-1 + z)*z*(-5 + 14*z))
5169  + z*(90*CF*(-1 + z) + CA*(53 - 187*z + 3*(1 + z)*pow2(M_PI))))
5170  +3*z*log(z)*(-2*(TF + CF*(-9 + 6*(-1 + z)*z) + TF*z*(12 - z*(9 + 8*z)))
5171  + 12*CF*log(1 - z)*(1 + pow2(z)) - CA*(17 + 5*pow2(z)))
5172  -9*z*(CA - CF - 2*TF + (CA + CF + 2*TF)*pow2(z))*pow2(log(z)));
5173  // replace 1/z term in NLO kernel with z/(z^2+kappa^2)
5174  pqq1 += preFac * 20./9.*TF * ( z/(pow2(z)+kappa2) - 1./z);
5175  // Add NLO term.
5176  it->second += alphasPT2pi*pqq1;
5177  }
5178  }
5179 
5180  // Store higher order correction separately.
5181  if (order > 0) wts.insert( make_pair("base_order_as2",
5182  wts["base"] - wt_base_as1 ));
5183 
5184  // Store kernel values.
5185  clearKernels();
5186  for ( unordered_map<string,double>::iterator it = wts.begin();
5187  it != wts.end(); ++it )
5188  kernelVals.insert(make_pair( it->first, it->second ));
5189 
5190  return true;
5191 
5192 }
5193 
5194 //==========================================================================
5195 
5196 // Class inheriting from SplittingQCD class.
5197 
5198 // SplittingQCD function G->GG (ISR)
5199 
5200 // Return true if this kernel should partake in the evolution.
5201 bool Dire_isr_qcd_G2GG1::canRadiate ( const Event& state, pair<int,int> ints,
5202  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
5203  return (!state[ints.first].isFinal()
5204  && state[ints.second].colType() != 0
5205  && hasSharedColor(state, ints.first, ints.second)
5206  && state[ints.first].id() == 21 );
5207 }
5208 
5209 bool Dire_isr_qcd_G2GG1::canRadiate (const Event& state, int iRadBef,
5210  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
5211  return ( !state[iRadBef].isFinal()
5212  && state[iRecBef].colType() != 0
5213  && hasSharedColor(state, iRadBef, iRecBef)
5214  && state[iRadBef].id() == 21);
5215 }
5216 
5217 int Dire_isr_qcd_G2GG1::kinMap() { return 1;}
5218 int Dire_isr_qcd_G2GG1::motherID(int) { return 21;}
5219 int Dire_isr_qcd_G2GG1::sisterID(int) { return 21;}
5220 double Dire_isr_qcd_G2GG1::gaugeFactor ( int, int ) { return 2.*CA;}
5221 double Dire_isr_qcd_G2GG1::symmetryFactor ( int, int ) { return 0.5;}
5222 
5223 int Dire_isr_qcd_G2GG1::radBefID(int idRA, int){
5224  if (idRA == 21) return 21;
5225  return 0;
5226 }
5227 pair<int,int> Dire_isr_qcd_G2GG1::radBefCols(
5228  int colRadAfter, int acolRadAfter,
5229  int colEmtAfter, int acolEmtAfter) {
5230  int colRemove = (colRadAfter == colEmtAfter)
5231  ? colRadAfter : acolRadAfter;
5232  int col = (colRadAfter == colRemove)
5233  ? acolEmtAfter : colRadAfter;
5234  int acol = (acolRadAfter == colRemove)
5235  ? colEmtAfter : acolRadAfter;
5236  return make_pair(col,acol);
5237 }
5238 
5239 vector <int> Dire_isr_qcd_G2GG1::recPositions( const Event& state, int iRad,
5240  int iEmt) {
5241 
5242  int colRad = state[iRad].col();
5243  int acolRad = state[iRad].acol();
5244  int colEmt = state[iEmt].col();
5245  int acolEmt = state[iEmt].acol();
5246  int colShared = (colRad > 0 && colRad == colEmt) ? colEmt
5247  : (acolRad > 0 && acolEmt == acolRad) ? acolEmt : 0;
5248  // Particles to exclude from colour tracing.
5249  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
5250 
5251  // Find partons connected via emitted colour line.
5252  vector<int> recs;
5253  if ( colEmt != 0 && colEmt != colShared) {
5254  int acolF = findCol(colEmt, iExc, state, 1);
5255  int colI = findCol(colEmt, iExc, state, 2);
5256  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5257  if (acolF == 0 && colI > 0) recs.push_back (colI);
5258  }
5259  // Find partons connected via emitted anticolour line.
5260  if ( acolEmt != 0 && acolEmt != colShared) {
5261  int colF = findCol(acolEmt, iExc, state, 2);
5262  int acolI = findCol(acolEmt, iExc, state, 1);
5263  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5264  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5265  }
5266  // Done.
5267  return recs;
5268 }
5269 
5270 // Pick z for new splitting.
5271 double Dire_isr_qcd_G2GG1::zSplit(double zMinAbs, double, double m2dip) {
5272  double R = rndmPtr->flat();
5273  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5274  // Pick according to soft + 1/z
5275  double res = (-2.*pow(kappa2,R)*pow(zMinAbs,2.*R) +
5276  sqrt(4.*pow(kappa2,2.*R)
5277  *pow(zMinAbs,4.*R)
5278  + 4.*(pow(kappa2,R) + pow(kappa2,1. + R))
5279  *pow(zMinAbs,2.*R)
5280  *(-(pow(kappa2,R)*pow(zMinAbs,2.*R))
5281  + kappa2
5282  *pow(1. + kappa2 - 2.*zMinAbs + pow(zMinAbs,2.),R))))
5283  / (2.*(-(pow(kappa2,R)*pow(zMinAbs,2.*R))
5284  + kappa2
5285  *pow(1. + kappa2 - 2.*zMinAbs + pow(zMinAbs,2.),R)));
5286  return res;
5287 }
5288 
5289 // New overestimates, z-integrated versions.
5290 double Dire_isr_qcd_G2GG1::overestimateInt(double zMinAbs, double,
5291  double, double m2dip, int orderNow) {
5292  double wt = 0.;
5293  double preFac = symmetryFactor() * gaugeFactor();
5294  int order = (orderNow > -1) ? orderNow : correctionOrder;
5295  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5296  // Overestimate by soft + 1/z
5297  wt = preFac * softRescaleInt(order)
5298  *0.5*( log(1./pow2(zMinAbs) + pow2(1.-zMinAbs)/(kappa2*pow2(zMinAbs))));
5299 
5300  return wt;
5301 }
5302 
5303 // Return overestimate for new splitting.
5304 double Dire_isr_qcd_G2GG1::overestimateDiff(double z, double m2dip,
5305  int orderNow) {
5306  double wt = 0.;
5307  double preFac = symmetryFactor() * gaugeFactor();
5308  int order = (orderNow > -1) ? orderNow : correctionOrder;
5309  double kappaOld2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5310  // Overestimate by soft + 1/z
5311  wt = preFac * softRescaleInt(order)
5312  * ((1.-z) / ( pow2(1.-z) + kappaOld2) + 1./z);
5313  return wt;
5314 }
5315 
5316 // Return kernel for new splitting.
5317 bool Dire_isr_qcd_G2GG1::calc(const Event& state, int orderNow) {
5318 
5319  // Dummy statement to avoid compiler warnings.
5320  if (false) cout << state[0].e() << orderNow << endl;
5321 
5322  // Read all splitting variables.
5323  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
5324  m2dip(splitInfo.kinematics()->m2Dip),
5325  m2Rec(splitInfo.kinematics()->m2Rec);
5326  int splitType(splitInfo.type);
5327 
5328  double preFac = symmetryFactor() * gaugeFactor();
5329  int order = (orderNow > -1) ? orderNow : correctionOrder;
5330  double kappa2 = max(pow2(settingsPtr->parm("SpaceShower:pTmin"))
5331  /m2dip, pT2/m2dip);
5332 
5333  unordered_map<string,double> wts;
5334  double wt_base_as1 = preFac * ( (1.-z) / (pow2(1.-z)+kappa2) );
5335 
5336  // Calculate argument of alphaS.
5337  double scale2 = couplingScale2 ( z, pT2, m2dip,
5338  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
5339  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
5340  if (scale2 < 0.) scale2 = pT2;
5341 
5342  wts.insert( make_pair("base", wt_base_as1
5343  * softRescaleDiff( order, scale2, renormMultFac) ));
5344  if (doVariations) {
5345  // Create muR-variations.
5346  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
5347  wts.insert( make_pair("Variations:muRisrDown", wt_base_as1
5348  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
5349  ? settingsPtr->parm("Variations:muRisrDown")*renormMultFac :
5350  renormMultFac) ));
5351  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
5352  wts.insert( make_pair("Variations:muRisrUp", wt_base_as1
5353  * softRescaleDiff( order, scale2, (scale2 > pT2minVariations)
5354  ? settingsPtr->parm("Variations:muRisrUp")*renormMultFac :
5355  renormMultFac) ));
5356  }
5357 
5358  if (order >= 0) {
5359  for ( unordered_map<string,double>::iterator it = wts.begin();
5360  it != wts.end(); ++it)
5361  it->second += preFac * 0.5 * ( z / ( pow2(z) + kappa2) - 1. ) - preFac;
5362  wt_base_as1 += preFac * 0.5 * ( z / ( pow2(z) + kappa2) - 1. ) - preFac;
5363  }
5364 
5365  // Correction for massive IF splittings.
5366  bool doMassive = ( m2Rec > 0. && splitType == 2);
5367 
5368  if (doMassive && order >= 0) {
5369  // Construct CS variables.
5370  double uCS = kappa2 / (1-z);
5371  double massCorr = - m2Rec / m2dip * uCS / (1.-uCS);
5372  // Mass correction shared in equal parts between both g->gg kernels.
5373  for ( unordered_map<string,double>::iterator it = wts.begin();
5374  it != wts.end(); ++it)
5375  it->second += preFac * 0.5 * massCorr;
5376 
5377  wt_base_as1 += preFac * 0.5 * massCorr;
5378 
5379  }
5380 
5381  // Add NLO term, subtracted by 1/(1-z)*(Gamma2+beta0*log(z)),
5382  // since latter already present in soft rescaling term.
5383  if (!doMassive && order == 3) {
5384  for ( unordered_map<string,double>::iterator it = wts.begin();
5385  it !=wts.end(); ++it){
5386 
5387  double mukf = 1.;
5388  if (it->first == "base")
5389  mukf = renormMultFac;
5390  else if (it->first == "Variations:muRisrDown")
5391  mukf = settingsPtr->parm("Variations:muRisrDown");
5392  else if (it->first == "Variations:muRisrUp")
5393  mukf = settingsPtr->parm("Variations:muRisrUp");
5394  else continue;
5395 
5396  // Do not perform variations below a small pT cut.
5397  if (scale2 < pT2minVariations) mukf = renormMultFac;
5398 
5399  double NF = getNF(scale2 * mukf);
5400  double alphasPT2pi = as2Pi(scale2, order, mukf);
5401  double TF = TR*NF;
5402  // SplittingQCD function directly taken from Mathematica file.
5403  // Note: After removal of the cusp anomalous dimensions, the NLO
5404  // kernel is a purely collinear term. As such, it should not
5405  // distinguish between colour structures, and hence should
5406  // contribute equally to Dire_isr_qcd_G2GG1 and
5407  // Dire_isr_qcd_G2GG2. Hence one factor of 0.5 . Then, another
5408  // factor of 0.5 is necessary, since the NLO kernel in the
5409  // Mathematica file is normalised to CA, and not 2*CA (as is the
5410  // case for the LO kernel above).
5411  double pgg1 = preFac * 0.5 / ( 18*z*(pow2(z)-1) ) * 0.5 * (
5412  TF*(-1 + pow2(z))*((4*(-1 + z)*(-23 + z*(6 + z*(10 + z*(4 + 23*z)))))/
5413  (-1 + pow2(z)) + (24*(1 - z)*z*log(z)*pow2(1 + z))/(-1 + pow2(z)))
5414  + (CF*TF*(-1 + pow2(z))*((36*(1 - z)*z*(1 + z)*(3 + 5*z)*log(z))
5415  /(-1 + pow2(z)) + (24*(1 + z)*(-1 + z*(11 + 5*z))*pow2(-1 + z))
5416  /(-1 + pow2(z)) - (36*(-1 + z)*z*pow2(1 + z)*pow2(log(z)))
5417  /(-1 + pow2(z))))/CA - 72*CA*(-1 + z)*DiLog(1/(1 + z))
5418  *pow2(1 + z + pow2(z))
5419  + CA*(-1 + pow2(z))*((6*(1 - z)*z*(1 + z)*(25 + 11*z*(-1 + 4*z))
5420  *log(z))/(-1 + pow2(z))
5421  + ((1 - z)*(z*(1 + z)*(25 + 109*z) + 6*(2 + z*(1 + 2*z*(1 + z)))
5422  *pow2(M_PI)))/(-1 + pow2(z))
5423  + (72*(1 + z)*log(1 - z)*log(z)*pow2(1 + (-1 + z)*z))/(-1 + pow2(z))
5424  - (36*z*pow2(log(z))*pow2(1 + z - pow2(z)))/(-1 + pow2(z))
5425  + (144*DiLog(1/(1 + z))*pow2(1 + z + pow2(z)))/(1 + z)
5426  + (36*(-1 + z)*pow2(log(1 + z))*pow2(1 + z + pow2(z)))
5427  /(-1 + pow2(z))) );
5428 
5429  // replace 1/x term in NLO kernel with x/(x^2+kappa^2)
5430  pgg1 += -preFac * 0.5 * 40./9.*TF * 0.5 * ( z/(pow2(z)+kappa2) - 1./z);
5431  // Add NLO term.
5432  it->second += alphasPT2pi*pgg1;
5433  }
5434  }
5435 
5436  // Store higher order correction separately.
5437  if (order > 0) wts.insert( make_pair("base_order_as2",
5438  wts["base"] - wt_base_as1 ));
5439 
5440  // Store kernel values.
5441  clearKernels();
5442  for ( unordered_map<string,double>::iterator it = wts.begin();
5443  it != wts.end(); ++it )
5444  kernelVals.insert(make_pair( it->first, it->second ));
5445 
5446  return true;
5447 
5448 }
5449 
5450 //==========================================================================
5451 
5452 // Class inheriting from SplittingQCD class.
5453 
5454 // SplittingQCD function G->GG (ISR)
5455 
5456 // Return true if this kernel should partake in the evolution.
5457 bool Dire_isr_qcd_G2GG2::canRadiate ( const Event& state, pair<int,int> ints,
5458  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
5459  return (!state[ints.first].isFinal()
5460  && state[ints.second].colType() != 0
5461  && hasSharedColor(state, ints.first, ints.second)
5462  && state[ints.first].id() == 21 );
5463 }
5464 
5465 bool Dire_isr_qcd_G2GG2::canRadiate (const Event& state, int iRadBef,
5466  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
5467  return ( !state[iRadBef].isFinal()
5468  && state[iRecBef].colType() != 0
5469  && hasSharedColor(state, iRadBef, iRecBef)
5470  && state[iRadBef].id() == 21);
5471 }
5472 
5473 int Dire_isr_qcd_G2GG2::kinMap() { return 1;}
5474 int Dire_isr_qcd_G2GG2::motherID(int) { return 21;}
5475 int Dire_isr_qcd_G2GG2::sisterID(int) { return 21;}
5476 double Dire_isr_qcd_G2GG2::gaugeFactor ( int, int ) { return 2.*CA;}
5477 double Dire_isr_qcd_G2GG2::symmetryFactor ( int, int ) { return 0.5;}
5478 
5479 int Dire_isr_qcd_G2GG2::radBefID(int idRA, int){
5480  if (idRA==21) return 21;
5481  return 0;
5482 }
5483 pair<int,int> Dire_isr_qcd_G2GG2::radBefCols(
5484  int colRadAfter, int acolRadAfter,
5485  int colEmtAfter, int acolEmtAfter) {
5486  int colRemove = (colRadAfter == colEmtAfter)
5487  ? colRadAfter : acolRadAfter;
5488  int col = (colRadAfter == colRemove)
5489  ? acolEmtAfter : colRadAfter;
5490  int acol = (acolRadAfter == colRemove)
5491  ? colEmtAfter : acolRadAfter;
5492  return make_pair(col,acol);
5493 }
5494 
5495 vector <int> Dire_isr_qcd_G2GG2::recPositions( const Event& state, int iRad,
5496  int iEmt) {
5497 
5498  int colRad = state[iRad].col();
5499  int acolRad = state[iRad].acol();
5500  int colEmt = state[iEmt].col();
5501  int acolEmt = state[iEmt].acol();
5502  int colShared = (colRad > 0 && colRad == colEmt) ? colEmt
5503  : (acolRad > 0 && acolEmt == acolRad) ? acolEmt : 0;
5504  // Particles to exclude from colour tracing.
5505  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
5506 
5507  // Find partons connected via emitted colour line.
5508  vector<int> recs;
5509  if ( colRad != 0 && colRad != colShared) {
5510  int acolF = findCol(colRad, iExc, state, 1);
5511  int colI = findCol(colRad, iExc, state, 2);
5512  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5513  if (acolF == 0 && colI > 0) recs.push_back (colI);
5514  }
5515  // Find partons connected via emitted anticolour line.
5516  if ( acolRad != 0 && acolRad != colShared) {
5517  int colF = findCol(acolRad, iExc, state, 2);
5518  int acolI = findCol(acolRad, iExc, state, 1);
5519  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5520  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5521  }
5522 
5523  // Done.
5524  return recs;
5525 }
5526 
5527 // Pick z for new splitting.
5528 double Dire_isr_qcd_G2GG2::zSplit(double zMinAbs, double, double m2dip) {
5529  double R = rndmPtr->flat();
5530  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5531 
5532  // Pick according to soft + 1/z
5533  double res = (-2.*pow(kappa2,R)*pow(zMinAbs,2.*R) +
5534  sqrt(4.*pow(kappa2,2.*R)
5535  *pow(zMinAbs,4.*R)
5536  + 4.*(pow(kappa2,R) + pow(kappa2,1. + R))
5537  *pow(zMinAbs,2.*R)
5538  *(-(pow(kappa2,R)*pow(zMinAbs,2.*R))
5539  + kappa2
5540  *pow(1. + kappa2 - 2.*zMinAbs + pow(zMinAbs,2.),R))))
5541  / (2.*(-(pow(kappa2,R)*pow(zMinAbs,2.*R))
5542  + kappa2
5543  *pow(1. + kappa2 - 2.*zMinAbs + pow(zMinAbs,2.),R)));
5544  return res;
5545 }
5546 
5547 // New overestimates, z-integrated versions.
5548 double Dire_isr_qcd_G2GG2::overestimateInt(double zMinAbs, double,
5549  double, double m2dip, int) {
5550  double wt = 0.;
5551  double preFac = symmetryFactor() * gaugeFactor();
5552  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5553 
5554  // Overestimate by soft + 1/z
5555  wt = preFac
5556  *0.5*( log(1./pow2(zMinAbs) + pow2(1.-zMinAbs)/(kappa2*pow2(zMinAbs))));
5557 
5558  return wt;
5559 }
5560 
5561 // Return overestimate for new splitting.
5562 double Dire_isr_qcd_G2GG2::overestimateDiff(double z, double m2dip, int) {
5563  double wt = 0.;
5564  double preFac = symmetryFactor() * gaugeFactor();
5565  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
5566 
5567  // Overestimate by soft + 1/z
5568  wt = preFac
5569  * ((1.-z) / ( pow2(1.-z) + kappa2) + 1./z);
5570  return wt;
5571 }
5572 
5573 // Return kernel for new splitting.
5574 bool Dire_isr_qcd_G2GG2::calc(const Event& state, int orderNow) {
5575 
5576  // Dummy statement to avoid compiler warnings.
5577  if (false) cout << state[0].e() << orderNow << endl;
5578 
5579  // Read all splitting variables.
5580  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
5581  m2dip(splitInfo.kinematics()->m2Dip),
5582  m2Rec(splitInfo.kinematics()->m2Rec);
5583  int splitType(splitInfo.type);
5584 
5585  double preFac = symmetryFactor() * gaugeFactor();
5586  int order = (orderNow > -1) ? orderNow : correctionOrder;
5587  double kappa2 = max(pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip,
5588  pT2/m2dip);
5589 
5590  unordered_map<string,double> wts;
5591  double wt_base_as1 = preFac * 0.5 * z / ( pow2(z) + kappa2);
5592 
5593  if (order >= 0) wt_base_as1 += -preFac*0.5 + preFac*z*(1.-z);
5594 
5595  // Calculate argument of alphaS.
5596  double scale2 = couplingScale2 ( z, pT2, m2dip,
5597  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
5598  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
5599  if (scale2 < 0.) scale2 = pT2;
5600 
5601  wts.insert( make_pair("base", wt_base_as1 ));
5602  if (doVariations) {
5603  // Create muR-variations.
5604  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
5605  wts.insert( make_pair("Variations:muRisrDown", wt_base_as1 ));
5606  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
5607  wts.insert( make_pair("Variations:muRisrUp", wt_base_as1 ));
5608  }
5609 
5610  // Correction for massive IF splittings.
5611  bool doMassive = ( m2Rec > 0. && splitType == 2);
5612 
5613  if (doMassive && order >= 0) {
5614  // Construct CS variables.
5615  double uCS = kappa2 / (1-z);
5616  double massCorr = - m2Rec / m2dip * uCS / (1.-uCS);
5617  // Mass correction shared in equal parts between both g->gg kernels.
5618  for ( unordered_map<string,double>::iterator it = wts.begin();
5619  it != wts.end(); ++it)
5620  it->second += preFac * 0.5 * massCorr;
5621 
5622  wt_base_as1 += preFac * 0.5 * massCorr;
5623  }
5624 
5625  // Add NLO term, subtracted by 1/(1-z)*(Gamma2+beta0*log(z)),
5626  // since latter already present in soft rescaling term.
5627  if (!doMassive && order == 3) {
5628  for ( unordered_map<string,double>::iterator it = wts.begin();
5629  it !=wts.end(); ++it){
5630 
5631  double mukf = 1.;
5632  if (it->first == "base")
5633  mukf = renormMultFac;
5634  else if (it->first == "Variations:muRisrDown")
5635  mukf = settingsPtr->parm("Variations:muRisrDown");
5636  else if (it->first == "Variations:muRisrUp")
5637  mukf = settingsPtr->parm("Variations:muRisrUp");
5638  else continue;
5639 
5640  // Do not perform variations below a small pT cut.
5641  if (scale2 < pT2minVariations) mukf = renormMultFac;
5642 
5643  double NF = getNF(scale2 * mukf);
5644  double alphasPT2pi = as2Pi(scale2, order, mukf);
5645  double TF = TR*NF;
5646  // SplittingQCD function directly taken from Mathematica file.
5647  // Note: After removal of the cusp anomalous dimensions, the NLO
5648  // kernel is a purely collinear term. As such, it should not
5649  // distinguish between colour structures, and hence should
5650  // contribute equally to Dire_isr_qcd_G2GG1 and
5651  // Dire_isr_qcd_G2GG2. Hence one factor of 0.5 . Then, another
5652  // factor of 0.5 is necessary, since the NLO kernel in the
5653  // Mathematica file is normalised to CA, and not 2*CA (as is the
5654  // case for the LO kernel above).
5655  double pgg1 = preFac * 0.5 / ( 18*z*(pow2(z)-1) ) * 0.5 * (
5656  TF*(-1 + pow2(z))*((4*(-1 + z)*(-23 + z*(6 + z*(10 + z*(4 + 23*z)))))
5657  /(-1 + pow2(z))
5658  +(24*(1 - z)*z*log(z)*pow2(1 + z))/(-1 + pow2(z)))
5659  +(CF*TF*(-1 + pow2(z))*((36*(1 - z)*z*(1 + z)*(3 + 5*z)*log(z))
5660  /(-1 + pow2(z))
5661  +(24*(1 + z)*(-1 + z*(11 + 5*z))*pow2(-1 + z))/(-1 + pow2(z))
5662  -(36*(-1 + z)*z*pow2(1 + z)*pow2(log(z)))/(-1 + pow2(z))))/CA
5663  -72*CA*(-1 + z)*DiLog(1/(1 + z))*pow2(1 + z + pow2(z))
5664  +CA*(-1 + pow2(z))*((6*(1 - z)*z*(1 + z)*(25 + 11*z*(-1 + 4*z))
5665  *log(z))/(-1 + pow2(z))
5666  +((1 - z)*(z*(1 + z)*(25 + 109*z) + 6*(2 + z*(1 + 2*z*(1 + z)))
5667  *pow2(M_PI)))/(-1 + pow2(z))
5668  +(72*(1 + z)*log(1 - z)*log(z)*pow2(1 + (-1 + z)*z))/(-1 + pow2(z))
5669  -(36*z*pow2(log(z))*pow2(1 + z - pow2(z)))/(-1 + pow2(z))
5670  +(144*DiLog(1/(1 + z))*pow2(1 + z + pow2(z)))/(1 + z)
5671  +(36*(-1 + z)*pow2(log(1 + z))*pow2(1 + z + pow2(z)))/(-1 + pow2(z))));
5672  // replace 1/z term in NLO kernel with z/(z^2+kappa^2)
5673  pgg1 += -preFac * 0.5 * 40./9.*TF * 0.5 * ( z/(pow2(z)+kappa2) - 1./z);
5674  // Add NLO term.
5675  it->second += alphasPT2pi*pgg1;
5676  }
5677  }
5678 
5679  // Store higher order correction separately.
5680  if (order > 0) wts.insert( make_pair("base_order_as2",
5681  wts["base"] - wt_base_as1 ));
5682 
5683  // Store kernel values.
5684  clearKernels();
5685  for ( unordered_map<string,double>::iterator it = wts.begin();
5686  it != wts.end(); ++it )
5687  kernelVals.insert(make_pair( it->first, it->second ));
5688 
5689  return true;
5690 
5691 }
5692 
5693 //==========================================================================
5694 
5695 // Class inheriting from SplittingQCD class.
5696 
5697 // SplittingQCD function G->QQ (ISR)
5698 
5699 // Return true if this kernel should partake in the evolution.
5700 bool Dire_isr_qcd_G2QQ::canRadiate ( const Event& state, pair<int,int> ints,
5701  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
5702  return (!state[ints.first].isFinal()
5703  && state[ints.second].colType() != 0
5704  && hasSharedColor(state, ints.first, ints.second)
5705  && state[ints.first].isQuark() );
5706 }
5707 
5708 bool Dire_isr_qcd_G2QQ::canRadiate (const Event& state, int iRadBef,
5709  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
5710  return ( !state[iRadBef].isFinal()
5711  && state[iRecBef].colType() != 0
5712  && hasSharedColor(state, iRadBef, iRecBef)
5713  && state[iRadBef].isQuark());
5714 }
5715 
5716 int Dire_isr_qcd_G2QQ::kinMap() { return 1;}
5717 int Dire_isr_qcd_G2QQ::motherID(int) { return 21;}
5718 int Dire_isr_qcd_G2QQ::sisterID(int idDaughter) { return -idDaughter;}
5719 double Dire_isr_qcd_G2QQ::gaugeFactor ( int, int ) { return TR;}
5720 double Dire_isr_qcd_G2QQ::symmetryFactor ( int, int ) { return 1.0;}
5721 
5722 int Dire_isr_qcd_G2QQ::radBefID(int, int idEA){
5723  if (particleDataPtr->isQuark(idEA)) return -idEA;
5724  return 0;
5725 }
5726 pair<int,int> Dire_isr_qcd_G2QQ::radBefCols(
5727  int colRadAfter, int acolRadAfter,
5728  int colEmtAfter, int acolEmtAfter) {
5729  bool isQuark = (acolEmtAfter > 0);
5730  int colRemove = (colRadAfter == colEmtAfter)
5731  ? colRadAfter : 0;
5732  int col = (colRadAfter == colRemove)
5733  ? acolEmtAfter : colRadAfter;
5734  if (isQuark) return make_pair(col,0);
5735  colRemove = (acolRadAfter == acolEmtAfter)
5736  ? acolRadAfter : 0;
5737  int acol = (acolRadAfter == colRemove)
5738  ? colEmtAfter : acolRadAfter;
5739  return make_pair(0,acol);
5740 }
5741 
5742 vector <int> Dire_isr_qcd_G2QQ::recPositions( const Event& state, int iRad,
5743  int iEmt) {
5744 
5745  int colRad = state[iRad].col();
5746  int acolRad = state[iRad].acol();
5747  int colEmt = state[iEmt].col();
5748  int acolEmt = state[iEmt].acol();
5749  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
5750  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
5751  // Particles to exclude from colour tracing.
5752  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
5753 
5754  // Find partons connected via emitted colour line.
5755  vector<int> recs;
5756  if ( colRad != 0 && colRad != colShared) {
5757  int acolF = findCol(colRad, iExc, state, 1);
5758  int colI = findCol(colRad, iExc, state, 2);
5759  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5760  if (acolF == 0 && colI > 0) recs.push_back (colI);
5761  }
5762  // Find partons connected via emitted anticolour line.
5763  if ( acolRad != 0 && acolRad != colShared) {
5764  int colF = findCol(acolRad, iExc, state, 2);
5765  int acolI = findCol(acolRad, iExc, state, 1);
5766  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5767  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5768  }
5769  // Done.
5770  return recs;
5771 }
5772 
5773 // Pick z for new splitting.
5774 double Dire_isr_qcd_G2QQ::zSplit(double zMinAbs, double zMaxAbs, double) {
5775  // Note: Combined with PDF ratio, flat overestimate performs
5776  // better than using the full splitting kernel as overestimate.
5777  double res = zMinAbs + rndmPtr->flat() * (zMaxAbs - zMinAbs);
5778  return res;
5779 }
5780 
5781 // New overestimates, z-integrated versions.
5782 double Dire_isr_qcd_G2QQ::overestimateInt(double zMinAbs, double zMaxAbs,
5783  double, double, int) {
5784  double wt = 0.;
5785  double preFac = symmetryFactor() * gaugeFactor();
5786  // Note: Combined with PDF ratio, flat overestimate performs
5787  // better than using the full splitting kernel as overestimate.
5788  wt = preFac
5789  * 2. * ( zMaxAbs - zMinAbs);
5790  return wt;
5791 }
5792 
5793 // Return overestimate for new splitting.
5794 double Dire_isr_qcd_G2QQ::overestimateDiff(double, double, int) {
5795  double wt = 0.;
5796  double preFac = symmetryFactor() * gaugeFactor();
5797  // Note: Combined with PDF ratio, flat overestimate performs
5798  // better than using the full splitting kernel as overestimate.
5799  wt = preFac
5800  * 2.;
5801  return wt;
5802 }
5803 
5804 // Return kernel for new splitting.
5805 bool Dire_isr_qcd_G2QQ::calc(const Event& state, int orderNow) {
5806 
5807  // Dummy statement to avoid compiler warnings.
5808  if (false) cout << state[0].e() << orderNow << endl;
5809 
5810  // Read all splitting variables.
5811  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
5812  m2dip(splitInfo.kinematics()->m2Dip);
5813 
5814  double preFac = symmetryFactor() * gaugeFactor();
5815  int order = (orderNow > -1) ? orderNow : correctionOrder;
5816  double kappa2 = max(pow2(settingsPtr->parm("SpaceShower:pTmin"))
5817  /m2dip, pT2/m2dip);;
5818 
5819  unordered_map<string,double> wts;
5820  double wt_base_as1 = preFac * (pow(1.-z,2.) + pow(z,2.));
5821 
5822  if (order == -1) wt_base_as1 = 0.0;
5823 
5824  // Calculate argument of alphaS.
5825  double scale2 = couplingScale2 ( z, pT2, m2dip,
5826  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
5827  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
5828  if (scale2 < 0.) scale2 = pT2;
5829 
5830  wts.insert( make_pair("base", wt_base_as1 ));
5831  if (doVariations) {
5832  // Create muR-variations.
5833  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
5834  wts.insert( make_pair("Variations:muRisrDown", wt_base_as1 ));
5835  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
5836  wts.insert( make_pair("Variations:muRisrUp", wt_base_as1 ));
5837  }
5838 
5839  if (order == 3) {
5840  for ( unordered_map<string,double>::iterator it = wts.begin();
5841  it !=wts.end(); ++it){
5842 
5843  double mukf = 1.;
5844  if (it->first == "base")
5845  mukf = renormMultFac;
5846  else if (it->first == "Variations:muRisrDown")
5847  mukf = settingsPtr->parm("Variations:muRisrDown");
5848  else if (it->first == "Variations:muRisrUp")
5849  mukf = settingsPtr->parm("Variations:muRisrUp");
5850  else continue;
5851 
5852  // Do not perform variations below a small pT cut.
5853  if (scale2 < pT2minVariations) mukf = renormMultFac;
5854 
5855  double alphasPT2pi = as2Pi(scale2, order, mukf);
5856  // SplittingQCD function directly taken from Mathematica file.
5857  double pgq1 = preFac * (
5858  (CF*(4 - 9*z + 4*log(1 - z) + (-1 + 4*z)*log(z)
5859  -(2*(1 + 2*(-1 + z)*z)*(-15 - 3*(-2 + log(-1 + 1/z))*log(-1 + 1/z) +
5860  pow2(M_PI)))/3.
5861  +(-1 + 2*z)*pow2(log(z)))
5862  +(2*CA*(20 - 18*z*(1 + 2*z*(1 + z))*DiLog(1/(1 + z))
5863  +z*(-18 + (225 - 218*z)*z + pow2(M_PI)*(3 + 6*pow2(z)))
5864  +3*z*(12*(-1 + z)*z*log(1 - z)
5865  +log(z)*(3 + 4*z*(6 + 11*z) - 3*(1 + 2*z)*log(z))
5866  +(-3 - 6*(-1 + z)*z)*pow2(log(1 - z))
5867  -3*(1 + 2*z*(1 + z))*pow2(log(1 + z)))))/(9.*z))/2. );
5868  // replace 1/z term in NLO kernel with z/(z^2+kappa^2)
5869  pgq1 += preFac * 20./9.*CA * ( z/(pow2(z)+kappa2) - 1./z);
5870  // Add NLO term.
5871  it->second += alphasPT2pi*pgq1;
5872  }
5873  }
5874 
5875  // Store higher order correction separately.
5876  if (order > 0) wts.insert( make_pair("base_order_as2",
5877  wts["base"] - wt_base_as1 ));
5878 
5879  // Store kernel values.
5880  clearKernels();
5881  for ( unordered_map<string,double>::iterator it = wts.begin();
5882  it != wts.end(); ++it )
5883  kernelVals.insert(make_pair( it->first, it->second ));
5884 
5885  return true;
5886 
5887 }
5888 
5889 //==========================================================================
5890 
5891 // Class inheriting from SplittingQCD class.
5892 
5893 // SplittingQCD function Q->GQ (ISR)
5894 
5895 // Return true if this kernel should partake in the evolution.
5896 bool Dire_isr_qcd_Q2GQ::canRadiate ( const Event& state, pair<int,int> ints,
5897  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
5898  return (!state[ints.first].isFinal()
5899  && state[ints.second].colType() != 0
5900  && hasSharedColor(state, ints.first, ints.second)
5901  && state[ints.first].id() == 21 );
5902 }
5903 
5904 bool Dire_isr_qcd_Q2GQ::canRadiate (const Event& state, int iRadBef,
5905  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
5906  return ( !state[iRadBef].isFinal()
5907  && state[iRecBef].colType() != 0
5908  && hasSharedColor(state, iRadBef, iRecBef)
5909  && state[iRadBef].id() == 21);
5910 }
5911 
5912 int Dire_isr_qcd_Q2GQ::kinMap() { return 1;}
5913 int Dire_isr_qcd_Q2GQ::motherID(int) { return 1;} // Use 1 as dummy
5914 int Dire_isr_qcd_Q2GQ::sisterID(int) { return 1;} // Use 1 as dummy
5915 double Dire_isr_qcd_Q2GQ::gaugeFactor ( int, int ) { return CF;}
5916 double Dire_isr_qcd_Q2GQ::symmetryFactor ( int, int ) { return 0.5;}
5917 
5918 int Dire_isr_qcd_Q2GQ::radBefID(int idRA, int){
5919  if (particleDataPtr->isQuark(idRA)) return 21;
5920  return 0;
5921 }
5922 pair<int,int> Dire_isr_qcd_Q2GQ::radBefCols(
5923  int colRadAfter, int acolRadAfter,
5924  int colEmtAfter, int acolEmtAfter) {
5925  int col = (colRadAfter > 0) ? colRadAfter : acolEmtAfter;
5926  int acol = (acolRadAfter > 0) ? acolRadAfter : colEmtAfter;
5927  return make_pair(col,acol);
5928 }
5929 
5930 vector <int> Dire_isr_qcd_Q2GQ::recPositions( const Event& state, int iRad,
5931  int iEmt) {
5932 
5933  // For Q->GQ, swap radiator and emitted, since we now have to trace the
5934  // radiator's colour connections.
5935  int colRad = state[iRad].col();
5936  int acolRad = state[iRad].acol();
5937  int colEmt = state[iEmt].col();
5938  int acolEmt = state[iEmt].acol();
5939  int colShared = (colRad > 0 && colRad == acolEmt) ? colRad
5940  : (acolRad > 0 && colEmt == acolRad) ? colEmt : 0;
5941  // Particles to exclude from colour tracing.
5942  vector<int> iExc(1,iRad); iExc.push_back(iEmt);
5943 
5944  // Find partons connected via emitted colour line.
5945  vector<int> recs;
5946  if ( colEmt != 0 && colEmt != colShared) {
5947  int acolF = findCol(colEmt, iExc, state, 1);
5948  int colI = findCol(colEmt, iExc, state, 2);
5949  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5950  if (acolF == 0 && colI > 0) recs.push_back (colI);
5951  }
5952  iExc.insert(iExc.end(), recs.begin(), recs.end());
5953  // Find partons connected via emitted anticolour line.
5954  if ( acolEmt != 0 && acolEmt != colShared) {
5955  int colF = findCol(acolEmt, iExc, state, 2);
5956  int acolI = findCol(acolEmt, iExc, state, 1);
5957  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5958  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5959  }
5960  iExc.insert(iExc.end(), recs.begin(), recs.end());
5961  // Find partons connected via radiator colour line.
5962  if ( colRad != 0 && colRad != colShared) {
5963  int acolF = findCol(colRad, iExc, state, 1);
5964  int colI = findCol(colRad, iExc, state, 2);
5965  if (acolF > 0 && colI == 0) recs.push_back (acolF);
5966  if (acolF == 0 && colI > 0) recs.push_back (colI);
5967  }
5968  iExc.insert(iExc.end(), recs.begin(), recs.end());
5969  // Find partons connected via radiator anticolour line.
5970  if ( acolRad != 0 && acolRad != colShared) {
5971  int colF = findCol(acolRad, iExc, state, 2);
5972  int acolI = findCol(acolRad, iExc, state, 1);
5973  if ( colF > 0 && acolI == 0) recs.push_back (colF);
5974  if ( colF == 0 && acolI > 0) recs.push_back (acolI);
5975  }
5976  iExc.insert(iExc.end(), recs.begin(), recs.end());
5977 
5978  // Done.
5979  return recs;
5980 }
5981 
5982 // Pick z for new splitting.
5983 double Dire_isr_qcd_Q2GQ::zSplit(double zMinAbs, double, double) {
5984  double R = rndmPtr->flat();
5985  double res = pow(zMinAbs,3./4.)
5986  / ( pow(1. + R*(-1. + pow(zMinAbs,-3./8.)),2./3.)
5987  *pow(R - (-1. + R)*pow(zMinAbs,3./8.),2.));
5988  return res;
5989 }
5990 
5991 // New overestimates, z-integrated versions.
5992 double Dire_isr_qcd_Q2GQ::overestimateInt(double zMinAbs, double,
5993  double, double, int) {
5994  double wt = 0.;
5995  double preFac = symmetryFactor() * gaugeFactor();
5996  wt = preFac * 2./3. * (8.*(-1. + pow(zMinAbs,-3./8.)));
5997 
5998  return wt;
5999 }
6000 
6001 // Return overestimate for new splitting.
6002 double Dire_isr_qcd_Q2GQ::overestimateDiff(double z, double, int) {
6003  double wt = 0.;
6004  double preFac = symmetryFactor() * gaugeFactor();
6005  wt = preFac * 2. / pow(z,11./8.);
6006  return wt;
6007 }
6008 
6009 // Return kernel for new splitting.
6010 bool Dire_isr_qcd_Q2GQ::calc(const Event& state, int orderNow) {
6011 
6012  // Dummy statement to avoid compiler warnings.
6013  if (false) cout << state[0].e() << orderNow << endl;
6014 
6015  // Read all splitting variables.
6016  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
6017  m2dip(splitInfo.kinematics()->m2Dip),
6018  m2Rec(splitInfo.kinematics()->m2Rec);
6019  int splitType(splitInfo.type);
6020 
6021  double preFac = symmetryFactor() * gaugeFactor();
6022  int order = (orderNow > -1) ? orderNow : correctionOrder;
6023  double kappa2 = max(pow2(settingsPtr->parm("SpaceShower:pTmin"))
6024  /m2dip, pT2/m2dip);;
6025 
6026  unordered_map<string,double> wts;
6027  double wt_base_as1 = preFac * 2.*z/(pow2(z)+kappa2);
6028 
6029  if (order >= 0) wt_base_as1 += preFac*(z-2.);
6030 
6031  // Calculate argument of alphaS.
6032  double scale2 = couplingScale2 ( z, pT2, m2dip,
6033  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
6034  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
6035  if (scale2 < 0.) scale2 = pT2;
6036 
6037  wts.insert( make_pair("base", wt_base_as1 ));
6038  if (doVariations) {
6039  // Create muR-variations.
6040  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
6041  wts.insert( make_pair("Variations:muRisrDown", wt_base_as1 ));
6042  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
6043  wts.insert( make_pair("Variations:muRisrUp", wt_base_as1 ));
6044  }
6045 
6046  // Correction for massive IF splittings.
6047  bool doMassive = ( m2Rec > 0. && splitType == 2);
6048 
6049  //if (doMassive) {
6050  if (doMassive && order >= 0) {
6051  // Construct CS variables.
6052  double uCS = kappa2 / (1-z);
6053 
6054  double massCorr = -2. * m2Rec / m2dip * uCS / (1.-uCS);
6055  // Add correction.
6056  for ( unordered_map<string,double>::iterator it = wts.begin();
6057  it != wts.end(); ++it)
6058  it->second += preFac * massCorr;
6059  wt_base_as1 += preFac * massCorr;
6060  }
6061 
6062  if (!doMassive && order == 3) {
6063  for ( unordered_map<string,double>::iterator it = wts.begin();
6064  it !=wts.end(); ++it){
6065 
6066  double mukf = 1.;
6067  if (it->first == "base")
6068  mukf = renormMultFac;
6069  else if (it->first == "Variations:muRisrDown")
6070  mukf = settingsPtr->parm("Variations:muRisrDown");
6071  else if (it->first == "Variations:muRisrUp")
6072  mukf = settingsPtr->parm("Variations:muRisrUp");
6073  else continue;
6074 
6075  // Do not perform variations below a small pT cut.
6076  if (scale2 < pT2minVariations) mukf = renormMultFac;
6077 
6078  double NF = getNF(scale2 * mukf);
6079  double alphasPT2pi = as2Pi(scale2, order, mukf);
6080  // SplittingQCD function directly taken from Mathematica file.
6081  double TF = TR*NF;
6082  double pqg1 = preFac * (
6083  (-9*CF*z*(5 + 7*z) - 16*TF*(5 + z*(-5 + 4*z))
6084  +36*CA*(2 + z*(2 + z))*DiLog(1/(1 + z))
6085  +2*CA*(9 + z*(19 + z*(37 + 44*z)) - 3*pow2(M_PI)*(2 + pow2(z)))
6086  +3*(-2*log(1 - z)*(CA*(-22 + (22 - 17*z)*z)
6087  +4*TF*(2 + (-2 + z)*z) + 3*CF*(6 + z*(-6 + 5*z))
6088  +6*CA*(2 + (-2 + z)*z)*log(z))
6089  +z*log(z)*(3*CF*(4 + 7*z) - 2*CA*(36 + z*(15 + 8*z))
6090  +3*(CF*(-2 + z) + 2*CA*(2 + z))*log(z))
6091  +6*(CA - CF)*(2 + (-2 + z)*z)*pow2(log(1 - z))
6092  +6*CA*(2 + z*(2 + z))*pow2(log(1 + z))))/(18.*z) );
6093  // replace 1/z term in NLO kernel with z/(z^2+kappa^2)
6094  pqg1 += - preFac * 40./9.*TF * ( z/(pow2(z)+kappa2) - 1./z);
6095  // Add NLO term.
6096  it->second += alphasPT2pi*pqg1;
6097  }
6098  }
6099 
6100  // Store higher order correction separately.
6101  if (order > 0) wts.insert( make_pair("base_order_as2",
6102  wts["base"] - wt_base_as1 ));
6103 
6104  // Store kernel values.
6105  clearKernels();
6106  for ( unordered_map<string,double>::iterator it = wts.begin();
6107  it != wts.end(); ++it )
6108  kernelVals.insert(make_pair( it->first, it->second ));
6109 
6110  return true;
6111 
6112 }
6113 
6114 //==========================================================================
6115 
6116 // Class inheriting from SplittingQCD class.
6117 
6118 // SplittingQCD function Q->QG (ISR)
6119 
6120 // Return true if this kernel should partake in the evolution.
6121 bool Dire_isr_qcd_Q2qQqbarDist::canRadiate ( const Event& state,
6122  pair<int,int> ints, unordered_map<string,bool>, Settings*, PartonSystems*,
6123  BeamParticle*) {
6124  return (!state[ints.first].isFinal()
6125  && state[ints.second].colType() != 0
6126  && hasSharedColor(state, ints.first, ints.second)
6127  && state[ints.first].isQuark() );
6128 }
6129 
6130 bool Dire_isr_qcd_Q2qQqbarDist::canRadiate (const Event& state, int iRadBef,
6131  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
6132  if (orderSave < 3) return false;
6133  return ( !state[iRadBef].isFinal()
6134  && state[iRecBef].colType() != 0
6135  && hasSharedColor(state, iRadBef, iRecBef)
6136  && state[iRadBef].isQuark());
6137 }
6138 
6139 int Dire_isr_qcd_Q2qQqbarDist::kinMap() { return 2;}
6140 int Dire_isr_qcd_Q2qQqbarDist::motherID(int idDaughter) { return idDaughter;}
6141 int Dire_isr_qcd_Q2qQqbarDist::sisterID(int) { return 1;}
6142 double Dire_isr_qcd_Q2qQqbarDist::gaugeFactor ( int, int ) { return CF;}
6143 double Dire_isr_qcd_Q2qQqbarDist::symmetryFactor ( int, int ) { return 1.;}
6144 
6145 int Dire_isr_qcd_Q2qQqbarDist::radBefID(int idRA, int) {
6146  if (particleDataPtr->isQuark(idRA)) return idRA;
6147  return 0;
6148  return idRA;
6149 }
6150 pair<int,int> Dire_isr_qcd_Q2qQqbarDist::radBefCols(
6151  int colRadAfter, int acolRadAfter,
6152  int colEmtAfter, int acolEmtAfter) {
6153  bool isQuark = (colRadAfter > 0);
6154  int colRemove = (colRadAfter == colEmtAfter)
6155  ? colRadAfter : 0;
6156  int col = (colRadAfter == colRemove)
6157  ? acolEmtAfter : colRadAfter;
6158  if (isQuark) return make_pair(col,0);
6159  colRemove = (acolRadAfter == acolEmtAfter)
6160  ? acolRadAfter : 0;
6161  int acol = (acolRadAfter == colRemove)
6162  ? colEmtAfter : acolRadAfter;
6163  return make_pair(0,acol);
6164 }
6165 
6166 // Pick z for new splitting.
6167 double Dire_isr_qcd_Q2qQqbarDist::zSplit(double zMinAbs, double zMaxAbs,
6168  double m2dip) {
6169  double Rz = rndmPtr->flat();
6170  double res = 1.;
6171  // z est from 1/(z + kappa^2)
6172  double kappa2 = pow(settingsPtr->parm("SpaceShower:pTmin"), 2) / m2dip;
6173 
6174  res = pow( (pow(kappa2,1) + zMaxAbs)/(pow(kappa2,1) + zMinAbs), -Rz )
6175  * (pow(kappa2,1) + zMaxAbs - pow(kappa2,1)
6176  *pow((pow(kappa2,1) + zMaxAbs)/(pow(kappa2,1)
6177  + zMinAbs), Rz));
6178 
6179  // Conversions to light flavours can have very large PDF
6180  // ratios at threshold. Thus, choose large overstimate a priori.
6181  if ( splitInfo.recBef()->isFinal
6182  && (splitInfo.radBef()->id < 0 || abs(splitInfo.radBef()->id) > 2) ) {
6183  double k = pow(kappa2,1);
6184  res = pow(k,0.5)
6185  * tan( Rz*atan(zMaxAbs*pow(k,-0.5))
6186  - (Rz-1.)*atan(zMinAbs*pow(k,-0.5)));
6187  }
6188 
6189  return res;
6190 
6191 }
6192 
6193 // New overestimates, z-integrated versions.
6194 double Dire_isr_qcd_Q2qQqbarDist::overestimateInt(double zMinAbs,
6195  double zMaxAbs, double, double m2dip, int orderNow) {
6196 
6197  // Do nothing without other NLO kernels!
6198  int order = (orderNow > -1) ? orderNow : correctionOrder;
6199  if (order < 3) return 0.0;
6200 
6201  double preFac = symmetryFactor() * gaugeFactor();
6202  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6203  // Overestimate chosen to have accept weights below one for kappa~0.1
6204  // z est from 1/(z + kappa^2)
6205  double kappa2 = pT2min/m2dip;
6206 
6207  double wt = preFac * TR * 20./9.
6208  * log( ( pow(kappa2,1) + zMaxAbs) / ( pow(kappa2,1) + zMinAbs) );
6209 
6210  // Conversions to light flavours can have very large PDF
6211  // ratios at threshold. Thus, choose large overstimate a priori.
6212  if ( splitInfo.recBef()->isFinal
6213  && (splitInfo.radBef()->id < 0 || abs(splitInfo.radBef()->id) > 2) ) {
6214  double k = pow(kappa2,1);
6215  wt = preFac * TR * 20./9.
6216  * ( atan(zMaxAbs*pow(k,-0.5))
6217  - atan(zMinAbs*pow(k,-0.5)))*pow(k,-0.5);
6218  }
6219 
6220  // This splitting is down by one power of alphaS !
6221  wt *= as2Pi(pT2min);
6222  return wt;
6223 
6224 }
6225 
6226 // Return overestimate for new splitting.
6227 double Dire_isr_qcd_Q2qQqbarDist::overestimateDiff(double z, double m2dip,
6228  int orderNow) {
6229 
6230  // Do nothing without other NLO kernels!
6231  int order = (orderNow > -1) ? orderNow : correctionOrder;
6232  if (order < 3) return 0.0;
6233 
6234  double preFac = symmetryFactor() * gaugeFactor();
6235  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6236  // Overestimate chosen to have accept weights below one for kappa~0.1
6237  double kappa2 = pT2min/m2dip;
6238 
6239  double wt = preFac * TR * 20./ 9. * 1 / (z + pow(kappa2,1));
6240 
6241  // Conversions to light flavours can have very large PDF
6242  // ratios at threshold. Thus, choose large overstimate a priori.
6243  if ( splitInfo.recBef()->isFinal
6244  && (splitInfo.radBef()->id < 0 || abs(splitInfo.radBef()->id) > 2) )
6245  wt = preFac * TR * 20./ 9. * 1. / (z*z + pow(kappa2,1));
6246 
6247  wt *= as2Pi(pT2min);
6248  return wt;
6249 
6250 }
6251 
6252 // Return kernel for new splitting.
6253 bool Dire_isr_qcd_Q2qQqbarDist::calc(const Event& state, int orderNow) {
6254 
6255  // Dummy statement to avoid compiler warnings.
6256  if (false) cout << state[0].e() << orderNow << endl;
6257 
6258  // Read all splitting variables.
6259  double z(splitInfo.kinematics()->z),
6260  m2dip(splitInfo.kinematics()->m2Dip),
6261  pT2(splitInfo.kinematics()->pT2),
6262  xa(splitInfo.kinematics()->xa),
6263  sai(splitInfo.kinematics()->sai),
6264  m2aij(splitInfo.kinematics()->m2RadBef),
6265  m2a(splitInfo.kinematics()->m2RadAft),
6266  m2i(splitInfo.kinematics()->m2EmtAft),
6267  m2j(splitInfo.kinematics()->m2EmtAft2),
6268  m2k(splitInfo.kinematics()->m2Rec);
6269 
6270  // Do nothing without other NLO kernels!
6271  unordered_map<string,double> wts;
6272  int order = (orderNow > -1) ? orderNow : correctionOrder;
6273  if (order < 3 || m2aij > 0. || m2a > 0. || m2i > 0. || m2j > 0. || m2k > 0.){
6274  wts.insert( make_pair("base", 0.) );
6275  if (doVariations && settingsPtr->parm("Variations:muRisrDown") != 1.)
6276  wts.insert( make_pair("Variations:muRisrDown", 0.));
6277  if (doVariations && settingsPtr->parm("Variations:muRisrUp") != 1.)
6278  wts.insert( make_pair("Variations:muRisrUp", 0.));
6279  clearKernels();
6280  for ( unordered_map<string,double>::iterator it = wts.begin();
6281  it != wts.end(); ++it )
6282  kernelVals.insert(make_pair( it->first, it->second ));
6283  return true;
6284  }
6285 
6286  // Choose if simulating endpoint or differential 1->3 (latter containing
6287  // both sai=0 and sai !=0). For choice of endpoint, set sai=0 later.
6288  bool isEndpoint = (rndmPtr->flat() < 0.5);
6289 
6290  Event trialEvent(state);
6291  bool physical = true;
6292  if (splitInfo.recBef()->isFinal)
6293  physical = isr->branch_IF(trialEvent, true, &splitInfo);
6294  else
6295  physical = isr->branch_II(trialEvent, true, &splitInfo);
6296 
6297  // Get invariants.
6298  Vec4 pa(trialEvent[splitInfo.iRadAft].p());
6299  Vec4 pk(trialEvent[splitInfo.iRecAft].p());
6300  Vec4 pj(trialEvent[splitInfo.iEmtAft].p());
6301  Vec4 pi(trialEvent[splitInfo.iEmtAft2].p());
6302 
6303  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
6304  double p2ai(-sai + m2a + m2i),
6305  p2aj( (-pa+pj).m2Calc()),
6306  p2ak( (-pa+sign*pk).m2Calc()),
6307  p2ij( (pi+pj).m2Calc()),
6308  p2ik( (pi+sign*pk).m2Calc()),
6309  p2jk( (pj+sign*pk).m2Calc());
6310  double saij = (-pa+pi+pj).m2Calc();
6311  double q2 = (-pa + sign*pk + pi + pj).m2Calc();
6312  double z1(-sign*pa*pk/(-sign*pk*(pa-pi-pj))),
6313  z2(sign*pi*pk/(-sign*pk*(pa-pi-pj))),
6314  z3(1-z1-z2);
6315  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6316  if ( z1< 1. || z2 > 0. || z3 > 0.)
6317  physical = false;
6318  if ( splitInfo.recBef()->isFinal && -(q2+pT2/xa-p2ai) < pT2min)
6319  physical = false;
6320 
6321  // Use only massless for now!
6322  if ( abs(pa.m2Calc()-m2a) > sai || abs(pi.m2Calc()-m2i) > sai
6323  || abs(pj.m2Calc()-m2j) > sai || abs(pk.m2Calc()-m2k) > sai)
6324  physical = false;
6325 
6326  // Discard splitting if not in allowed phase space.
6327  if (!physical) {
6328  wts.insert( make_pair("base", 0.) );
6329  if (doVariations && settingsPtr->parm("Variations:muRisrDown") != 1.)
6330  wts.insert( make_pair("Variations:muRisrDown", 0.));
6331  if (doVariations && settingsPtr->parm("Variations:muRisrUp") != 1.)
6332  wts.insert( make_pair("Variations:muRisrUp", 0.));
6333  clearKernels();
6334  for ( unordered_map<string,double>::iterator it = wts.begin();
6335  it != wts.end(); ++it )
6336  kernelVals.insert(make_pair( it->first, it->second ));
6337  return true;
6338  }
6339 
6340  // Calculate kernel.
6341  double prob = 0.0;
6342  if (isEndpoint) {
6343 
6344  prob = CF*TR*((1.0+z3*z3)/(1.0-z3)
6345  +(1.0-2.0*z1*z2/pow2(z1+z2))*(1.0-z3+(1.0+z3*z3)/(1.0-z3)
6346  *(log(z2/z1*z3/(1-z3))-1.0)));
6347  prob-= CF*TR*2.0*((1.0+z3*z3)/(1.0-z3)*log(-z3/(1.0-z3)) +1.0-z3)
6348  *(1.0-2.0*z1*z2/pow2(z1+z2));
6349 
6350  // From xa integration volume?
6351  prob *= log(1/z);
6352  // Multiply by 2 since we randomly chose endpoint or fully differential.
6353  prob *= 2.0;
6354  // Weight of sai-selection?
6355  prob *= z/xa * 1. / (1.-p2ai/saij);
6356 
6357  } else {
6358 
6359  double s12(p2ai), s13(p2aj), s23(p2ij), s123(saij);
6360  double t123 = 2.*(z1*s23 - z2*s13)/(z1+z2) + (z1-z2)/(z1+z2)*s12;
6361  double CG = 0.5*CF*TR*s123/s12
6362  *( - pow2(t123)/ (s12*s123)
6363  + (4.*z3 + pow2(z1-z2))/(z1+z2) + z1 + z2 - s12/s123 );
6364  double cosPhiKT1KT3 = pow2(p2ij*p2ak - p2aj*p2ik + p2ai*p2jk)
6365  / (4.*p2ai*p2ij*p2ak*p2jk);
6366  double subt = CF*TR*s123/s12
6367  * ( (1.+z3*z3) / (1.-z3) * (1.-2.*z1*z2/pow2(1-z3))
6368  + 4.*z1*z2*z3 / pow(1.-z3,3) * (1-2.*cosPhiKT1KT3) );
6369  prob = CG - subt;
6370 
6371  if ( abs(s12) < 1e-10) prob = 0.0;
6372 
6373  // From xa integration volume?
6374  prob *= log(1/z);
6375  // Multiply by 2 since we randomly chose endpoint or fully differential.
6376  prob *= 2.0;
6377  // Weight of sai-selection?
6378  prob *= z/xa * 1. / (1.-p2ai/saij);
6379 
6380  }
6381 
6382  // Remember that this might be an endpoint with vanishing sai.
6383  if (isEndpoint) { splitInfo.set_sai(0.0); }
6384 
6385  // Calculate argument of alphaS.
6386  double scale2 = couplingScale2 ( z, pT2, m2dip,
6387  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
6388  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
6389  if (scale2 < 0.) scale2 = pT2;
6390 
6391  // Insert value of kernel into kernel list.
6392  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
6393  if (doVariations) {
6394  // Create muR-variations.
6395  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
6396  wts.insert( make_pair("Variations:muRisrDown", prob
6397  * as2Pi(scale2, order, (scale2 > pT2minVariations)
6398  ? settingsPtr->parm("Variations:muRisrDown")*renormMultFac :
6399  renormMultFac) ));
6400  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
6401  wts.insert( make_pair("Variations:muRisrUp", prob
6402  * as2Pi(scale2, order, (scale2 > pT2minVariations)
6403  ? settingsPtr->parm("Variations:muRisrUp")*renormMultFac :
6404  renormMultFac) ));
6405  }
6406 
6407  // Multiply with z1 because of crossing.
6408  for ( unordered_map<string,double>::iterator it = wts.begin();
6409  it != wts.end(); ++it )
6410  it->second *= z;
6411 
6412  // Store higher order correction separately.
6413  wts.insert( make_pair("base_order_as2", wts["base"] ));
6414 
6415  // Store kernel values.
6416  clearKernels();
6417  for ( unordered_map<string,double>::iterator it = wts.begin();
6418  it != wts.end(); ++it )
6419  kernelVals.insert(make_pair( it->first, it->second ));
6420 
6421  return true;
6422 
6423 }
6424 
6425 //==========================================================================
6426 
6427 // Class inheriting from SplittingQCD class.
6428 
6429 // SplittingQCD function Q-> Qbar Q Q (FSR)
6430 
6431 // Return true if this kernel should partake in the evolution.
6432 bool Dire_isr_qcd_Q2QbarQQId::canRadiate ( const Event& state,
6433  pair<int,int> ints,
6434  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
6435  return (!state[ints.first].isFinal()
6436  && state[ints.second].colType() != 0
6437  && hasSharedColor(state, ints.first, ints.second)
6438  && state[ints.first].isQuark() );
6439 }
6440 
6441 bool Dire_isr_qcd_Q2QbarQQId::canRadiate (const Event& state, int iRadBef,
6442  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
6443  if (orderSave < 3) return false;
6444  return ( !state[iRadBef].isFinal()
6445  && state[iRecBef].colType() != 0
6446  && hasSharedColor(state, iRadBef, iRecBef)
6447  && state[iRadBef].isQuark());
6448 }
6449 
6450 int Dire_isr_qcd_Q2QbarQQId::kinMap() { return 2;}
6451 int Dire_isr_qcd_Q2QbarQQId::motherID(int idDaughter) { return -idDaughter;}
6452 int Dire_isr_qcd_Q2QbarQQId::sisterID(int) { return 1;}
6453 double Dire_isr_qcd_Q2QbarQQId::gaugeFactor ( int, int ) { return CF;}
6454 double Dire_isr_qcd_Q2QbarQQId::symmetryFactor ( int, int ) { return 1.;}
6455 
6456 int Dire_isr_qcd_Q2QbarQQId::radBefID(int idRA, int) {
6457  if (particleDataPtr->isQuark(idRA)) return idRA;
6458  return 0;
6459 }
6460 pair<int,int> Dire_isr_qcd_Q2QbarQQId::radBefCols(
6461  int colRadAfter, int,
6462  int colEmtAfter, int acolEmtAfter) {
6463  bool isQuark = (colRadAfter > 0);
6464  if (isQuark) return make_pair(colEmtAfter,0);
6465  return make_pair(0,acolEmtAfter);
6466 }
6467 
6468 // Pick z for new splitting.
6469 double Dire_isr_qcd_Q2QbarQQId::zSplit(double zMinAbs, double zMaxAbs,
6470  double m2dip) {
6471  double Rz = rndmPtr->flat();
6472  double kappa2 = pow2(settingsPtr->parm("SpaceShower:pTmin"))/m2dip;
6473 
6474  double res = pow( (pow(kappa2,1) + zMaxAbs)/(pow(kappa2,1) + zMinAbs), -Rz )
6475  * (pow(kappa2,1) + zMaxAbs - pow(kappa2,1)
6476  *pow((pow(kappa2,1) + zMaxAbs)/(pow(kappa2,1)
6477  + zMinAbs), Rz));
6478 
6479  // Conversions to light flavours can have very large PDF
6480  // ratios at threshold. Thus, choose large overstimate a priori.
6481  if ( splitInfo.recBef()->isFinal && splitInfo.radBef()->id < 0 ) {
6482  double k = pow(kappa2,1);
6483  res = pow(k,0.5)
6484  * tan( Rz*atan(zMaxAbs*pow(k,-0.5))
6485  - (Rz-1.)*atan(zMinAbs*pow(k,-0.5)));
6486  }
6487 
6488  return res;
6489 }
6490 
6491 // New overestimates, z-integrated versions.
6492 double Dire_isr_qcd_Q2QbarQQId::overestimateInt(double zMinAbs, double zMaxAbs,
6493  double, double m2dip, int orderNow) {
6494 
6495  // Do nothing without other NLO kernels!
6496  int order = (orderNow > -1) ? orderNow : correctionOrder;
6497  if (order < 3) return 0.0;
6498 
6499  double preFac = symmetryFactor() * gaugeFactor();
6500  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6501  double kappa2 = pT2min/m2dip;
6502 
6503  double wt = preFac * TR * 20./9.
6504  * log( ( pow(kappa2,1) + zMaxAbs) / ( pow(kappa2,1) + zMinAbs) );
6505 
6506  // Conversions to light flavours can have very large PDF
6507  // ratios at threshold. Thus, choose large overstimate a priori.
6508  if ( splitInfo.recBef()->isFinal && splitInfo.radBef()->id < 0 ) {
6509  double k = pow(kappa2,1);
6510  wt = preFac * TR * 20./9.
6511  * ( atan(zMaxAbs*pow(k,-0.5))
6512  - atan(zMinAbs*pow(k,-0.5)))*pow(k,-0.5);
6513  }
6514 
6515  // Multiply by number of channels.
6516  wt *= 2.;
6517 
6518  wt *= as2Pi(pT2min);
6519 
6520  return wt;
6521 }
6522 
6523 // Return overestimate for new splitting.
6524 double Dire_isr_qcd_Q2QbarQQId::overestimateDiff(double z, double m2dip,
6525  int orderNow) {
6526 
6527  // Do nothing without other NLO kernels!
6528  int order = (orderNow > -1) ? orderNow : correctionOrder;
6529  if (order < 3) return 0.0;
6530 
6531  double wt = 0.;
6532  double preFac = symmetryFactor() * gaugeFactor();
6533  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6534  double kappa2 = pT2min/m2dip;
6535 
6536  wt = preFac * TR * 20./9. * 1. / ( z + kappa2);
6537 
6538  // Conversions to light flavours can have very large PDF
6539  // ratios at threshold. Thus, choose large overstimate a priori.
6540  if ( splitInfo.recBef()->isFinal && splitInfo.radBef()->id < 0 )
6541  wt = preFac * TR * 20./ 9. * 1. / (z*z + pow(kappa2,1));
6542 
6543  // Multiply by number of channels.
6544  wt *= 2.;
6545 
6546  wt *= as2Pi(pT2min);
6547 
6548  return wt;
6549 }
6550 
6551 // Return kernel for new splitting.
6552 bool Dire_isr_qcd_Q2QbarQQId::calc(const Event& state, int orderNow) {
6553 
6554  // Dummy statement to avoid compiler warnings.
6555  if (false) cout << state[0].e() << orderNow << endl;
6556 
6557  // Read all splitting variables.
6558  double z(splitInfo.kinematics()->z),
6559  pT2(splitInfo.kinematics()->pT2),
6560  m2dip(splitInfo.kinematics()->m2Dip),
6561  xa(splitInfo.kinematics()->xa),
6562  sai(splitInfo.kinematics()->sai),
6563  m2aij(splitInfo.kinematics()->m2RadBef),
6564  m2a(splitInfo.kinematics()->m2RadAft),
6565  m2i(splitInfo.kinematics()->m2EmtAft),
6566  m2j(splitInfo.kinematics()->m2EmtAft2),
6567  m2k(splitInfo.kinematics()->m2Rec);
6568 
6569  // Do nothing without other NLO kernels!
6570  unordered_map<string,double> wts;
6571  int order = (orderNow > -1) ? orderNow : correctionOrder;
6572  if (order < 3 || m2aij > 0. || m2a > 0. || m2i > 0. || m2j > 0. || m2k > 0.){
6573  wts.insert( make_pair("base", 0.) );
6574  if (doVariations && settingsPtr->parm("Variations:muRisrDown") != 1.)
6575  wts.insert( make_pair("Variations:muRisrDown", 0.));
6576  if (doVariations && settingsPtr->parm("Variations:muRisrUp") != 1.)
6577  wts.insert( make_pair("Variations:muRisrUp", 0.));
6578  clearKernels();
6579  for ( unordered_map<string,double>::iterator it = wts.begin();
6580  it != wts.end(); ++it )
6581  kernelVals.insert(make_pair( it->first, it->second ));
6582  return true;
6583  }
6584 
6585  // Choose if simulating endpoint or differential 1->3 (latter containing
6586  // both sai=0 and sai !=0). For choice of endpoint, set sai=0 later.
6587  bool isEndpoint = (rndmPtr->flat() < 0.5);
6588 
6589  Event trialEvent(state);
6590  bool physical = true;
6591  if (splitInfo.recBef()->isFinal)
6592  physical = isr->branch_IF(trialEvent, true, &splitInfo);
6593  else
6594  physical = isr->branch_II(trialEvent, true, &splitInfo);
6595 
6596  // Get invariants.
6597  Vec4 pa(trialEvent[splitInfo.iRadAft].p());
6598  Vec4 pk(trialEvent[splitInfo.iRecAft].p());
6599  Vec4 pj(trialEvent[splitInfo.iEmtAft].p());
6600  Vec4 pi(trialEvent[splitInfo.iEmtAft2].p());
6601  double sign = (splitInfo.recBef()->isFinal) ? 1. : -1.;
6602  double p2ai(-sai + m2a + m2i),
6603  p2aj( (-pa+pj).m2Calc()),
6604  p2ak( (-pa+sign*pk).m2Calc()),
6605  p2ij( (pi+pj).m2Calc()),
6606  p2ik( (pi+sign*pk).m2Calc()),
6607  p2jk( (pj+sign*pk).m2Calc());
6608  double saij = (-pa+pi+pj).m2Calc();
6609  double q2 = (-pa + sign*pk + pi + pj).m2Calc();
6610  double z1(-sign*pa*pk/(-sign*pk*(pa-pi-pj))),
6611  z2(sign*pi*pk/(-sign*pk*(pa-pi-pj))),
6612  z3(1-z1-z2);
6613  double pT2min = pow2(settingsPtr->parm("SpaceShower:pTmin"));
6614  if ( z1< 1. || z2 > 0. || z3 > 0.)
6615  physical = false;
6616  if ( splitInfo.recBef()->isFinal && -(q2+pT2/xa-p2ai) < pT2min)
6617  physical = false;
6618 
6619  // Use only massless for now!
6620  if ( abs(pa.m2Calc()-m2a) > sai || abs(pi.m2Calc()-m2i) > sai
6621  || abs(pj.m2Calc()-m2j) > sai || abs(pk.m2Calc()-m2k) > sai)
6622  physical = false;
6623 
6624  // Discard splitting if not in allowed phase space.
6625  if (!physical) {
6626  wts.insert( make_pair("base", 0.) );
6627  if (doVariations && settingsPtr->parm("Variations:muRisrDown") != 1.)
6628  wts.insert( make_pair("Variations:muRisrDown", 0.));
6629  if (doVariations && settingsPtr->parm("Variations:muRisrUp") != 1.)
6630  wts.insert( make_pair("Variations:muRisrUp", 0.));
6631  clearKernels();
6632  for ( unordered_map<string,double>::iterator it = wts.begin();
6633  it != wts.end(); ++it )
6634  kernelVals.insert(make_pair( it->first, it->second ));
6635  return true;
6636  }
6637 
6638  // Calculate kernel.
6639  double prob = 0.0;
6640  if (isEndpoint) {
6641 
6642  prob = CF*TR*((1.0+z3*z3)/(1.0-z3)
6643  +(1.0-2.0*z1*z2/pow2(z1+z2))*(1.0-z3+(1.0+z3*z3)/(1.0-z3)
6644  *(log(z2/z1*z3/(1-z3))-1.0)));
6645  // Swapped contribution.
6646  prob+= CF*TR*((1.0+z2*z2)/(1.0-z2)
6647  +(1.0-2.0*z1*z3/pow2(z1+z3))*(1.0-z2+(1.0+z2*z2)/(1.0-z2)
6648  *(log(z3/z1*z2/(1-z2))-1.0)));
6649  // Subtraction.
6650  prob-= CF*TR*2.0*((1.0+z3*z3)/(1.0-z3)*log(-z3/(1.0-z3)) +1.0-z3)
6651  *(1.0-2.0*z1*z2/pow2(z1+z2));
6652  // Swapped subtraction.
6653  prob-= CF*TR*2.0*((1.0+z2*z2)/(1.0-z2)*log(-z2/(1.0-z2)) +1.0-z2)
6654  *(1.0-2.0*z1*z3/pow2(z1+z3));
6655 
6656  // From xa integration volume?
6657  prob *= log(1/z);
6658  // Multiply by 2 since we randomly chose endpoint or fully differential.
6659  prob *= 2.0;
6660  // Weight of sai-selection?
6661  prob *= z/xa * 1. / (1.-p2ai/saij);
6662 
6663  } else {
6664 
6665  double s12(p2ai), s13(p2aj), s23(p2ij), s123(saij);
6666  double t123 = 2.*(z1*s23 - z2*s13)/(z1+z2) + (z1-z2)/(z1+z2)*s12;
6667  double CG = 0.5*CF*TR*s123/s12
6668  *( - pow2(t123)/ (s12*s123)
6669  + (4.*z3 + pow2(z1-z2))/(z1+z2) + z1 + z2 - s12/s123 );
6670  // Swapped kernel.
6671  double t132 = 2.*(z1*s23 - z3*s12)/(z1+z3) + (z1-z3)/(z1+z3)*s13;
6672  CG += 0.5*CF*TR*s123/s13
6673  *( - pow2(t132)/ (s13*s123)
6674  + (4.*z2 + pow2(z1-z3))/(z1+z3) + z1 + z3 - s13/s123 );
6675  // Interference term.
6676  CG += CF*(CF-0.5*CA)
6677  * ( 2.*s23/s12
6678  + s123/s12 * ( (1.+z1*z1)/(1-z2) - 2.*z2/(1.-z3) )
6679  - s123*s123/(s12*s13) * 0.5*z1*(1.+z1*z1) / ((1.-z2)*(1.-z3)));
6680  // Swapped interference term.
6681  CG += CF*(CF-0.5*CA)
6682  * ( 2.*s23/s13
6683  + s123/s13 * ( (1.+z1*z1)/(1-z3) - 2.*z3/(1.-z2) )
6684  - s123*s123/(s13*s12) * 0.5*z1*(1.+z1*z1) / ((1.-z3)*(1.-z2)));
6685  // Subtraction.
6686  double cosPhiKT1KT3 = pow2(p2ij*p2ak - p2aj*p2ik + p2ai*p2jk)
6687  / (4.*p2ai*p2ij*p2ak*p2jk);
6688  double subt = CF*TR*s123/s12
6689  * ( (1.+z3*z3) / (1.-z3) * (1.-2.*z1*z2/pow2(1-z3))
6690  + 4.*z1*z2*z3 / pow(1.-z3,3) * (1-2.*cosPhiKT1KT3) );
6691  // Swapped subtraction.
6692  double cosPhiKT1KT2 = pow2(p2ij*p2ak + p2aj*p2ik - p2ai*p2jk)
6693  / (4.*p2aj*p2ij*p2ak*p2ik);
6694  subt += CF*TR*s123/s13
6695  * ( (1.+z2*z2) / (1.-z2) * (1.-2.*z1*z3/pow2(1-z2))
6696  + 4.*z1*z3*z2 / pow(1.-z2,3) * (1-2.*cosPhiKT1KT2) );
6697  prob = CG - subt;
6698 
6699  if ( abs(s12) < 1e-10) prob = 0.0;
6700 
6701  // From xa integration volume?
6702  prob *= log(1/z);
6703  // Multiply by 2 since we randomly chose endpoint or fully differential.
6704  prob *= 2.0;
6705  // Weight of sai-selection?
6706  prob *= z/xa * 1. / (1.-p2ai/saij);
6707 
6708  }
6709 
6710  // Desymmetrize in i and j.
6711  prob *= (1.-xa) / (1-z);
6712 
6713  // Remember that this might be an endpoint with vanishing sai.
6714  if (isEndpoint) { splitInfo.set_sai(0.0); }
6715 
6716  // Calculate argument of alphaS.
6717  double scale2 = couplingScale2 ( z, pT2, m2dip,
6718  make_pair (splitInfo.radBef()->id, splitInfo.radBef()->isFinal),
6719  make_pair (splitInfo.recBef()->id, splitInfo.recBef()->isFinal));
6720  if (scale2 < 0.) scale2 = pT2;
6721 
6722  // Insert value of kernel into kernel list.
6723  wts.insert( make_pair("base", prob * as2Pi(scale2, order, renormMultFac) ));
6724  if (doVariations) {
6725  // Create muR-variations.
6726  if (settingsPtr->parm("Variations:muRisrDown") != 1.)
6727  wts.insert( make_pair("Variations:muRisrDown", prob
6728  * as2Pi(scale2, order, (scale2 > pT2minVariations)
6729  ? settingsPtr->parm("Variations:muRisrDown")*renormMultFac :
6730  renormMultFac) ));
6731  if (settingsPtr->parm("Variations:muRisrUp") != 1.)
6732  wts.insert( make_pair("Variations:muRisrUp", prob
6733  * as2Pi(scale2, order, (scale2 > pT2minVariations)
6734  ? settingsPtr->parm("Variations:muRisrUp")*renormMultFac :
6735  renormMultFac) ));
6736  }
6737 
6738  // Multiply with z1 because of crossing.
6739  for ( unordered_map<string,double>::iterator it = wts.begin();
6740  it != wts.end(); ++it )
6741  it->second *= z;
6742 
6743  // Store higher order correction separately.
6744  wts.insert( make_pair("base_order_as2", wts["base"] ));
6745 
6746  // Store kernel values.
6747  clearKernels();
6748  for ( unordered_map<string,double>::iterator it = wts.begin();
6749  it != wts.end(); ++it )
6750  kernelVals.insert(make_pair( it->first, it->second ));
6751 
6752  return true;
6753 
6754 }
6755 
6756 //==========================================================================
6757 
6758 // Return true if this kernel should partake in the evolution.
6759 bool Dire_fsr_qcd_Q2QG_notPartial::canRadiate ( const Event& state,
6760  pair<int,int> ints,
6761  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
6762  return ( state[ints.first].isFinal()
6763  && state[ints.second].colType() == 0
6764  && state[ints.first].isQuark() );
6765 }
6766 
6767 bool Dire_fsr_qcd_Q2QG_notPartial::canRadiate (const Event& state, int iRadBef,
6768  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
6769  return ( state[iRadBef].isFinal()
6770  && state[iRecBef].colType() == 0
6771  && state[iRadBef].isQuark());
6772 }
6773 
6774 int Dire_fsr_qcd_Q2QG_notPartial::kinMap() {return 1;}
6775 int Dire_fsr_qcd_Q2QG_notPartial::motherID(int idDaughter) {return idDaughter;}
6776 int Dire_fsr_qcd_Q2QG_notPartial::sisterID(int) {return 21;}
6777 double Dire_fsr_qcd_Q2QG_notPartial::gaugeFactor ( int, int ) { return CF;}
6778 double Dire_fsr_qcd_Q2QG_notPartial::symmetryFactor ( int, int ) { return 1.;}
6779 
6780 int Dire_fsr_qcd_Q2QG_notPartial::radBefID(int idRA, int) {
6781  if (particleDataPtr->isQuark(idRA)) return idRA;
6782  return 0;
6783 }
6784 
6785 vector<pair<int,int> > Dire_fsr_qcd_Q2QG_notPartial::radAndEmtCols(int iRad,
6786  int, Event state) {
6787  vector< pair<int,int> > ret;
6788  if (!state[iRad].isQuark() || state[splitInfo.iRecBef].colType() != 0)
6789  return ret;
6790 
6791  int colType = (state[iRad].id() > 0) ? 1 : -1;
6792  int newCol1 = state.nextColTag();
6793  int colRadAft = (colType > 0) ? newCol1 : state[iRad].col();
6794  int acolRadAft = (colType > 0) ? state[iRad].acol() : newCol1;
6795  int colEmtAft1 = (colType > 0) ? state[iRad].col() : newCol1;
6796  int acolEmtAft1 = (colType > 0) ? newCol1 : state[iRad].acol();
6797 
6798  ret = createvector<pair<int,int> >
6799  (make_pair(colRadAft, acolRadAft))
6800  (make_pair(colEmtAft1, acolEmtAft1));
6801 
6802  return ret;
6803 }
6804 
6805 pair<int,int> Dire_fsr_qcd_Q2QG_notPartial::radBefCols(
6806  int colRadAfter, int,
6807  int colEmtAfter, int acolEmtAfter) {
6808  bool isQuark = (colRadAfter > 0);
6809  if (isQuark) return make_pair(colEmtAfter,0);
6810  return make_pair(0,acolEmtAfter);
6811 }
6812 
6813 vector <int> Dire_fsr_qcd_Q2QG_notPartial::recPositions( const Event&,
6814  int, int) {
6815  return vector<int>();
6816 }
6817 
6818 // Pick z for new splitting.
6819 double Dire_fsr_qcd_Q2QG_notPartial::zSplit(double zMinAbs, double,
6820  double m2dip) {
6821  double Rz = rndmPtr->flat();
6822 
6823  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
6824  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin4, Rz );
6825  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin4);
6826  return res;
6827 }
6828 
6829 // New overestimates, z-integrated versions.
6830 double Dire_fsr_qcd_Q2QG_notPartial::overestimateInt(double zMinAbs, double,
6831  double, double m2dip, int) {
6832 
6833  // Q -> QG, soft part (currently also used for collinear part).
6834  double preFac = symmetryFactor() * gaugeFactor();
6835  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
6836  double wt = preFac
6837  *2. * 0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin4);
6838  return wt;
6839 }
6840 
6841 // Return overestimate for new splitting.
6842 double Dire_fsr_qcd_Q2QG_notPartial::overestimateDiff(double z, double m2dip,
6843  int) {
6844 
6845  double preFac = symmetryFactor() * gaugeFactor();
6846  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
6847  double wt = preFac
6848  *2. * (1.-z) / ( pow2(1.-z) + kappaMin4);
6849  return wt;
6850 }
6851 
6852 // Return kernel for new splitting.
6853 bool Dire_fsr_qcd_Q2QG_notPartial::calc(const Event& state, int) {
6854 
6855  // Dummy statement to avoid compiler warnings.
6856  if (false) cout << state[0].e() << endl;
6857 
6858  // Read all splitting variables.
6859  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
6860  m2dip(splitInfo.kinematics()->m2Dip),
6861  m2RadBef(splitInfo.kinematics()->m2RadBef),
6862  m2Rad(splitInfo.kinematics()->m2RadAft),
6863  m2Rec(splitInfo.kinematics()->m2Rec),
6864  m2Emt(splitInfo.kinematics()->m2EmtAft);
6865  int splitType(splitInfo.type);
6866 
6867  // Calculate kernel.
6868  // Note: We are calculating the z <--> 1-z symmetrised kernel here.
6869  double preFac = symmetryFactor() * gaugeFactor();
6870  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip,
6871  pT2/m2dip);
6872 
6873  unordered_map<string,double> wts;
6874  double wt_base_as1 = preFac * 2. / (1.-z);
6875 
6876  wts.insert( make_pair("base", wt_base_as1 ) );
6877  if (doVariations) {
6878  // Create muR-variations.
6879  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
6880  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
6881  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
6882  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
6883  }
6884 
6885  // Correction for massive splittings.
6886  bool doMassive = (abs(splitType) == 2);
6887 
6888  // Add collinear term for massless splittings.
6889  if (!doMassive) {
6890  wt_base_as1 += -preFac * ( 1.+z );
6891  for ( unordered_map<string,double>::iterator it = wts.begin();
6892  it != wts.end(); ++it)
6893  it->second += -preFac * ( 1.+z );
6894  }
6895 
6896  // Add collinear term for massive splittings.
6897  if (doMassive) {
6898 
6899  double pipj = 0., vijkt = 1., vijk = 1.;
6900 
6901  // splitType == 2 -> Massive FF
6902  if (splitType == 2) {
6903 
6904  // Calculate CS variables.
6905  double yCS = kappa2 / (1.-z);
6906  double nu2RadBef = m2RadBef/m2dip;
6907  double nu2Rad = m2Rad/m2dip;
6908  double nu2Emt = m2Emt/m2dip;
6909  double nu2Rec = m2Rec/m2dip;
6910  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
6911  double Q2mass = m2dip + m2Rad + m2Rec + m2Emt;
6912  vijkt = pow2(Q2mass/m2dip - nu2RadBef - nu2Rec)
6913  - 4.*nu2RadBef*nu2Rec;
6914  vijk = sqrt(vijk) / (1-yCS);
6915  vijkt = sqrt(vijkt)/ (Q2mass/m2dip - nu2RadBef - nu2Rec);
6916  pipj = m2dip * yCS/2.;
6917 
6918  // splitType ==-2 -> Massive FI
6919  } else if (splitType ==-2) {
6920 
6921  // Calculate CS variables.
6922  double xCS = 1 - kappa2/(1.-z);
6923  vijk = 1.;
6924  vijkt = 1.;
6925  pipj = m2dip/2. * (1-xCS)/xCS;
6926  }
6927 
6928  // Add B1 for massive splittings.
6929  double massCorr = -1.*vijkt/vijk*( 1. + z + m2RadBef/pipj);
6930  for ( unordered_map<string,double>::iterator it = wts.begin();
6931  it != wts.end(); ++it)
6932  it->second += preFac * massCorr;
6933 
6934  wt_base_as1 += preFac * massCorr;
6935  }
6936 
6937  // Store higher order correction separately.
6938  wts.insert( make_pair("base_order_as2", wts["base"] - wt_base_as1 ));
6939 
6940  // Store kernel values.
6941  clearKernels();
6942  for ( unordered_map<string,double>::iterator it = wts.begin();
6943  it != wts.end(); ++it )
6944  kernelVals.insert(make_pair( it->first, it->second ));
6945 
6946  return true;
6947 
6948 }
6949 
6950 //==========================================================================
6951 
6952 // Return true if this kernel should partake in the evolution.
6953 bool Dire_fsr_qcd_G2GG_notPartial::canRadiate ( const Event& state,
6954  pair<int,int> ints,
6955  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
6956  return ( state[ints.first].isFinal()
6957  && state[ints.second].colType() == 0
6958  && state[ints.first].id() == 21 );
6959 }
6960 
6961 bool Dire_fsr_qcd_G2GG_notPartial::canRadiate (const Event& state, int iRadBef,
6962  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
6963  return ( state[iRadBef].isFinal()
6964  && state[iRecBef].colType() == 0
6965  && state[iRadBef].id() == 21);
6966 }
6967 
6968 
6969 int Dire_fsr_qcd_G2GG_notPartial::kinMap() { return 1;}
6970 int Dire_fsr_qcd_G2GG_notPartial::motherID(int) { return 21;}
6971 int Dire_fsr_qcd_G2GG_notPartial::sisterID(int) { return 21;}
6972 double Dire_fsr_qcd_G2GG_notPartial::gaugeFactor ( int, int ) { return 2.*CA;}
6973 double Dire_fsr_qcd_G2GG_notPartial::symmetryFactor ( int, int ) { return 0.5;}
6974 int Dire_fsr_qcd_G2GG_notPartial::radBefID(int idRA, int) {
6975  if (idRA == 21) return idRA;
6976  return 0;
6977 }
6978 
6979 vector<pair<int,int> > Dire_fsr_qcd_G2GG_notPartial::radAndEmtCols(int iRad,
6980  int colType, Event state) {
6981  vector< pair<int,int> > ret;
6982  if (state[iRad].id() != 21 || state[splitInfo.iRecBef].colType() != 0)
6983  return ret;
6984 
6985  int newCol1 = state.nextColTag();
6986  int colRadAft = (colType > 0) ? newCol1 : state[iRad].col();
6987  int acolRadAft = (colType > 0) ? state[iRad].acol() : newCol1;
6988  int colEmtAft1 = (colType > 0) ? state[iRad].col() : newCol1;
6989  int acolEmtAft1 = (colType > 0) ? newCol1 : state[iRad].acol();
6990 
6991  ret = createvector<pair<int,int> >
6992  (make_pair(colRadAft, acolRadAft))
6993  (make_pair(colEmtAft1, acolEmtAft1));
6994 
6995  return ret;
6996 }
6997 
6998 pair<int,int> Dire_fsr_qcd_G2GG_notPartial::radBefCols(
6999  int colRadAfter, int acolRadAfter,
7000  int colEmtAfter, int acolEmtAfter) {
7001  int colRemove = (colRadAfter == acolEmtAfter)
7002  ? colRadAfter : acolRadAfter;
7003  int col = (colRadAfter == colRemove)
7004  ? colEmtAfter : colRadAfter;
7005  int acol = (acolRadAfter == colRemove)
7006  ? acolEmtAfter : acolRadAfter;
7007  return make_pair(col,acol);
7008 }
7009 
7010 vector <int> Dire_fsr_qcd_G2GG_notPartial::recPositions( const Event&, int,
7011  int) {
7012  return vector <int>();
7013 }
7014 
7015 // Pick z for new splitting.
7016 double Dire_fsr_qcd_G2GG_notPartial::zSplit(double zMinAbs, double,
7017  double m2dip) {
7018  // Just pick according to soft.
7019  double R = rndmPtr->flat();
7020  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
7021  double p = pow( 1. + pow2(1-zMinAbs)/kappaMin4, R );
7022  double res = 1. - sqrt( p - 1. )*sqrt(kappaMin4);
7023  return res;
7024 }
7025 
7026 // New overestimates, z-integrated versions.
7027 double Dire_fsr_qcd_G2GG_notPartial::overestimateInt(double zMinAbs, double,
7028  double, double m2dip, int) {
7029 
7030  // Overestimate by soft
7031  double preFac = symmetryFactor() * gaugeFactor();
7032  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
7033  double wt = preFac * 0.5 * log( 1. + pow2(1.-zMinAbs)/kappaMin4);
7034  return wt;
7035 }
7036 
7037 // Return overestimate for new splitting.
7038 double Dire_fsr_qcd_G2GG_notPartial::overestimateDiff(double z, double m2dip,
7039  int) {
7040  // Overestimate by soft
7041  double preFac = symmetryFactor() * gaugeFactor();
7042  double kappaMin4 = pow4(settingsPtr->parm("TimeShower:pTmin"))/pow2(m2dip);
7043  double wt = preFac * (1.-z) / ( pow2(1.-z) + kappaMin4);
7044  return wt;
7045 }
7046 
7047 // Return kernel for new splitting.
7048 bool Dire_fsr_qcd_G2GG_notPartial::calc(const Event& state, int) {
7049 
7050  // Dummy statement to avoid compiler warnings.
7051  if (false) cout << state[0].e() << endl;
7052 
7053  // Read all splitting variables.
7054  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
7055  m2dip(splitInfo.kinematics()->m2Dip),
7056  //m2RadBef(splitInfo.kinematics()->m2RadBef),
7057  m2Rad(splitInfo.kinematics()->m2RadAft),
7058  m2Rec(splitInfo.kinematics()->m2Rec),
7059  m2Emt(splitInfo.kinematics()->m2EmtAft);
7060  int splitType(splitInfo.type);
7061 
7062  double preFac = symmetryFactor() * gaugeFactor();
7063  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))/m2dip,
7064  pT2/m2dip);
7065 
7066  // Calculate kernel.
7067  // Note: We are calculating the z <--> 1-z symmetrised kernel here.
7068  unordered_map<string,double> wts;
7069  double wt_base_as1 = preFac * (1 / (1.-z) + 1/z);
7070 
7071  wts.insert( make_pair("base", wt_base_as1 ));
7072  if (doVariations) {
7073  // Create muR-variations.
7074  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
7075  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
7076  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
7077  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
7078  }
7079 
7080  // Correction for massive splittings.
7081  bool doMassive = (abs(splitType) == 2);
7082 
7083  // Add collinear term for massless splittings.
7084  if (!doMassive) {
7085  for ( unordered_map<string,double>::iterator it = wts.begin();
7086  it != wts.end(); ++it)
7087  it->second += preFac * ( -2. + z*(1.-z) );
7088  wt_base_as1 += preFac * ( -2. + z*(1.-z) );
7089  }
7090 
7091  // Add collinear term for massive splittings.
7092  if (doMassive) {
7093 
7094  double vijk = 1.;
7095 
7096  // splitType == 2 -> Massive FF
7097  if (splitType == 2) {
7098  // Calculate CS variables.
7099  double yCS = kappa2 / (1.-z);
7100  double nu2Rad = m2Rad/m2dip;
7101  double nu2Emt = m2Emt/m2dip;
7102  double nu2Rec = m2Rec/m2dip;
7103  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
7104  vijk = sqrt(vijk) / (1-yCS);
7105 
7106  // splitType ==-2 -> Massive FI
7107  } else if (splitType ==-2) {
7108  // No changes, as initial recoiler is massless!
7109  vijk = 1.;
7110  }
7111 
7112  // Add correction for massive splittings.
7113  for ( unordered_map<string,double>::iterator it = wts.begin();
7114  it != wts.end(); ++it)
7115  it->second += preFac * 1./ vijk * ( -2. + z*(1.-z) );
7116 
7117  wt_base_as1 += preFac * 1./ vijk * ( -2. + z*(1.-z) );
7118  }
7119 
7120  // Store higher order correction separately.
7121  wts.insert( make_pair("base_order_as2", wts["base"] - wt_base_as1 ));
7122 
7123  // Store kernel values.
7124  clearKernels();
7125  for ( unordered_map<string,double>::iterator it = wts.begin();
7126  it != wts.end(); ++it)
7127  kernelVals.insert(make_pair( it->first, it->second ));
7128 
7129  return true;
7130 
7131 }
7132 
7133 //==========================================================================
7134 
7135 // Class inheriting from SplittingQCD class.
7136 
7137 // SplittingQCD function G->QQ (FSR)
7138 
7139 // Return true if this kernel should partake in the evolution.
7140 bool Dire_fsr_qcd_G2QQ_notPartial::canRadiate ( const Event& state,
7141  pair<int,int> ints,
7142  unordered_map<string,bool>, Settings*, PartonSystems*, BeamParticle*) {
7143  return ( state[ints.first].isFinal()
7144  && state[ints.second].colType() == 0
7145  && state[ints.first].id() == 21 );
7146 }
7147 
7148 bool Dire_fsr_qcd_G2QQ_notPartial::canRadiate (const Event& state, int iRadBef,
7149  int iRecBef, Settings*, PartonSystems*, BeamParticle*) {
7150  return ( state[iRadBef].isFinal()
7151  && state[iRecBef].colType() == 0
7152  && state[iRadBef].id() == 21);
7153 }
7154 
7155 int Dire_fsr_qcd_G2QQ_notPartial::kinMap() { return 1;}
7156 int Dire_fsr_qcd_G2QQ_notPartial::motherID(int) { return 1;}
7157 int Dire_fsr_qcd_G2QQ_notPartial::sisterID(int) { return 1;}
7158 double Dire_fsr_qcd_G2QQ_notPartial::gaugeFactor ( int, int ) {
7159  return 2.*NF_qcd_fsr*TR;}
7160 double Dire_fsr_qcd_G2QQ_notPartial::symmetryFactor ( int, int ) { return 0.5;}
7161 
7162 int Dire_fsr_qcd_G2QQ_notPartial::radBefID(int idRA, int) {
7163  if (particleDataPtr->isQuark(idRA)) return 21;
7164  return 0;
7165 }
7166 
7167 vector<pair<int,int> > Dire_fsr_qcd_G2QQ_notPartial::radAndEmtCols(int iRad,
7168  int colType, Event state) {
7169  vector< pair<int,int> > ret;
7170  if ( !particleDataPtr->isQuark(state[iRad].id())
7171  || state[splitInfo.iRecBef].colType() != 0)
7172  return ret;
7173 
7174  int newCol1 = state.nextColTag();
7175  int colRadAft = (colType > 0) ? newCol1 : state[iRad].col();
7176  int acolRadAft = (colType > 0) ? state[iRad].acol() : newCol1;
7177  int colEmtAft1 = (colType > 0) ? state[iRad].col() : newCol1;
7178  int acolEmtAft1 = (colType > 0) ? newCol1 : state[iRad].acol();
7179 
7180  ret = createvector<pair<int,int> >
7181  (make_pair(colRadAft, acolRadAft))
7182  (make_pair(colEmtAft1, acolEmtAft1));
7183 
7184  return ret;
7185 }
7186 
7187 pair<int,int> Dire_fsr_qcd_G2QQ_notPartial::radBefCols(
7188  int colRadAfter, int acolRadAfter,
7189  int colEmtAfter, int acolEmtAfter) {
7190  int col = (colRadAfter > 0) ? colRadAfter : colEmtAfter;
7191  int acol = (acolRadAfter > 0) ? acolRadAfter : acolEmtAfter;
7192  return make_pair(col,acol);
7193 }
7194 
7195 vector <int> Dire_fsr_qcd_G2QQ_notPartial::recPositions( const Event&, int,
7196  int) {
7197  return vector <int>();
7198 }
7199 
7200 // Pick z for new splitting.
7201 double Dire_fsr_qcd_G2QQ_notPartial::zSplit(double zMinAbs, double zMaxAbs,
7202  double) {
7203  return (zMinAbs + rndmPtr->flat() * (zMaxAbs - zMinAbs));
7204 }
7205 
7206 // New overestimates, z-integrated versions.
7207 double Dire_fsr_qcd_G2QQ_notPartial::overestimateInt(double zMinAbs,
7208  double zMaxAbs, double, double, int) {
7209  double wt = 0.;
7210  double preFac = symmetryFactor() * gaugeFactor();
7211  wt = 2.*preFac * 0.5 * ( zMaxAbs - zMinAbs);
7212  return wt;
7213 }
7214 
7215 // Return overestimate for new splitting.
7216 double Dire_fsr_qcd_G2QQ_notPartial::overestimateDiff(double, double, int) {
7217  double wt = 0.;
7218  double preFac = symmetryFactor() * gaugeFactor();
7219  wt = 2.*preFac * 0.5;
7220  return wt;
7221 }
7222 
7223 // Return kernel for new splitting.
7224 bool Dire_fsr_qcd_G2QQ_notPartial::calc(const Event& state, int) {
7225 
7226  // Dummy statement to avoid compiler warnings.
7227  if (false) cout << state[0].e() << endl;
7228 
7229  // Read all splitting variables.
7230  double z(splitInfo.kinematics()->z), pT2(splitInfo.kinematics()->pT2),
7231  m2dip(splitInfo.kinematics()->m2Dip),
7232  m2Rad(splitInfo.kinematics()->m2RadAft),
7233  m2Rec(splitInfo.kinematics()->m2Rec),
7234  m2Emt(splitInfo.kinematics()->m2EmtAft);
7235  int splitType(splitInfo.type);
7236 
7237  double preFac = symmetryFactor() * gaugeFactor();
7238  double kappa2 = max(pow2(settingsPtr->parm("TimeShower:pTmin"))
7239  /m2dip, pT2/m2dip);
7240 
7241  unordered_map<string,double> wts;
7242  double wt_base_as1 = preFac * ( pow(1.-z,2.) + pow(z,2.) );
7243  wts.insert( make_pair("base", wt_base_as1 ));
7244  if (doVariations) {
7245  // Create muR-variations.
7246  if (settingsPtr->parm("Variations:muRfsrDown") != 1.)
7247  wts.insert( make_pair("Variations:muRfsrDown", wt_base_as1 ));
7248  if (settingsPtr->parm("Variations:muRfsrUp") != 1.)
7249  wts.insert( make_pair("Variations:muRfsrUp", wt_base_as1 ));
7250  }
7251 
7252  // Correction for massive splittings.
7253  bool doMassive = (abs(splitType) == 2);
7254 
7255  if (doMassive) {
7256 
7257  double vijk = 1., pipj = 0.;
7258 
7259  // splitType == 2 -> Massive FF
7260  if (splitType == 2) {
7261  // Calculate CS variables.
7262  double yCS = kappa2 / (1.-z);
7263  double nu2Rad = m2Rad/m2dip;
7264  double nu2Emt = m2Emt/m2dip;
7265  double nu2Rec = m2Rec/m2dip;
7266  vijk = pow2(1.-yCS) - 4.*(yCS+nu2Rad+nu2Emt)*nu2Rec;
7267  vijk = sqrt(vijk) / (1-yCS);
7268  pipj = m2dip * yCS /2.;
7269 
7270  // splitType ==-2 -> Massive FI
7271  } else if (splitType ==-2) {
7272  // Calculate CS variables.
7273  double xCS = 1 - kappa2/(1.-z);
7274  vijk = 1.;
7275  pipj = m2dip/2. * (1-xCS)/xCS;
7276  }
7277 
7278  // Reset kernel for massive splittings.
7279  for ( unordered_map<string,double>::iterator it = wts.begin();
7280  it != wts.end(); ++it)
7281  it->second = preFac * 1. / vijk * ( pow2(1.-z) + pow2(z)
7282  + m2Emt / ( pipj + m2Emt) );
7283 
7284  wt_base_as1 = preFac * 1. / vijk * ( pow2(1.-z) + pow2(z)
7285  + m2Emt / ( pipj + m2Emt) );
7286  }
7287 
7288  // Store higher order correction separately.
7289  wts.insert( make_pair("base_order_as2", wts["base"] - wt_base_as1 ));
7290 
7291  // Store kernel values.
7292  clearKernels();
7293  for ( unordered_map<string,double>::iterator it = wts.begin();
7294  it != wts.end(); ++it )
7295  kernelVals.insert(make_pair( it->first, it->second ));
7296 
7297  return true;
7298 
7299 }
7300 
7301 //==========================================================================
7302 
7303 } // end namespace Pythia8
Definition: beam.h:43
Definition: AgUStep.h:26