13 #include "Pythia8/Pythia.h"
54 std::cout<<
"**********************************************************"<<std::endl;
55 std::cout<<
"* *"<<std::endl;
56 std::cout<<
"* SI: Defining custom UserHook needed *"<<std::endl;
57 std::cout<<
"* to veto QED radiation (ptmaxmatch = 1) *"<<std::endl;
58 std::cout<<
"* *"<<std::endl;
59 std::cout<<
"* WARNING: This code is unvalidated!!! *"<<std::endl;
60 std::cout<<
"* *"<<std::endl;
61 std::cout<<
"**********************************************************"<<std::endl;
64 Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()[
"m_si_data_.vetoqed"]=
true;
65 Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()[
"m_si_data_.py8veto"]=
true;
66 Pythia8_UserHooks::UserHooksFactory::userSettings<double>()[
"m_si_event_info_.vetoscale_fsr"]=10.0;
87 std::cout <<
"**** SI: Allow to set scale to veto QED emissions in PYTHIA" << std::endl;
92 using UserHooks::scaleResonance;
125 std::cout<<
"**********************************************************"<<std::endl;
126 std::cout<<
"* *"<<std::endl;
127 std::cout<<
"* SI: Defining modified PowhegHook to perform *"<<std::endl;
128 std::cout<<
"* the matching (ptmaxmatch = 2) *"<<std::endl;
129 std::cout<<
"* *"<<std::endl;
130 std::cout<<
"**********************************************************"<<std::endl;
132 Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()[
"m_si_data_.vetoqed"]=
true;
133 Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()[
"m_si_data_.py8veto"]=
true;
134 Pythia8_UserHooks::UserHooksFactory::userSettings<double>()[
"m_si_event_info_.vetoscale_fsr"]=10.0;
135 Pythia8_UserHooks::UserHooksFactory::userSettings<double>()[
"m_si_event_info_.vetoscale_isr"]=10.0;
143 m_nFinal = settingsPtr->mode(
"POWHEG:nFinal");
144 m_vetoMode = settingsPtr->mode(
"POWHEG:veto");
145 m_vetoCount = settingsPtr->mode(
"POWHEG:vetoCount");
169 int RecAfterBranch,
bool FSR) {
172 Vec4 radVec =
e[RadAfterBranch].p();
173 Vec4 emtVec =
e[EmtAfterBranch].p();
174 Vec4 recVec =
e[RecAfterBranch].p();
175 int radID =
e[RadAfterBranch].id();
178 double sign = (
FSR) ? 1. : -1.;
179 Vec4 Q(radVec +
sign * emtVec);
180 double Qsq =
sign * Q.m2Calc();
183 double m2Rad = (std::abs(radID) >= 4 && std::abs(radID) < 7) ?
184 pow2(particleDataPtr->m0(radID)) : 0.;
190 Vec4
sum = radVec + recVec + emtVec;
191 double m2Dip =
sum.m2Calc();
192 double x1 = 2. * (
sum * radVec) / m2Dip;
193 double x3 = 2. * (
sum * emtVec) / m2Dip;
195 pTnow =
z * (1. -
z);
199 Vec4 qBR(radVec - emtVec + recVec);
200 Vec4 qAR(radVec + recVec);
201 z = qBR.m2Calc() / qAR.m2Calc();
206 pTnow *= (Qsq -
sign * m2Rad);
210 std::cout <<
"Warning: pTpythia was negative" << std::endl;
215 std::cout <<
"pTpythia: rad = " << RadAfterBranch <<
", emt = "
216 << EmtAfterBranch <<
", rec = " << RecAfterBranch
217 <<
", pTnow = " << std::sqrt(pTnow) << std::endl;
221 return std::sqrt(pTnow);
235 int iInA = partonSystemsPtr->getInA(0);
236 int iInB = partonSystemsPtr->getInB(0);
237 double betaZ = - (
e[iInA].pz() +
e[iInB].pz() ) /
238 (
e[iInA].
e() +
e[iInB].e() );
239 Vec4 iVecBst(
e[
i].
p()), jVecBst(
e[j].
p());
240 iVecBst.bst(0., 0., betaZ);
241 jVecBst.bst(0., 0., betaZ);
243 if (
e[
i].
id() == 21 &&
e[j].
id() == 21) {
244 pTnow = std::sqrt( (iVecBst + jVecBst).m2Calc() *
245 iVecBst.e() * jVecBst.e() /
246 pow2(iVecBst.e() + jVecBst.e()) );
248 pTnow = std::sqrt( (iVecBst + jVecBst).m2Calc() *
249 jVecBst.e() / iVecBst.e() );
259 std::cout <<
"Warning: pTpowheg was negative" << std::endl;
264 std::cout <<
"pTpowheg: i = " <<
i <<
", j = " << j
265 <<
", pTnow = " << pTnow << std::endl;
280 double pTemt = -1., pTnow;
281 int xSR1 = (xSRin == -1) ? 0 : xSRin;
282 int xSR2 = (xSRin == -1) ? 2 : xSRin + 1;
283 for (
int xSR = xSR1; xSR < xSR2; xSR++) {
285 bool FSR = (xSR == 0) ?
false :
true;
306 int iInA = partonSystemsPtr->getInA(0);
307 int iInB = partonSystemsPtr->getInB(0);
308 while (
e[iInA].mother1() != 1) { iInA =
e[iInA].mother1(); }
309 while (
e[iInB].mother1() != 2) { iInB =
e[iInB].mother1(); }
312 int jNow = (j > 0) ? j : 0;
313 int jMax = (j > 0) ? j + 1 :
e.size();
314 for (; jNow < jMax; jNow++) {
317 if ( !
e[jNow].isFinal() )
continue;
325 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
min(pTemt, pTnow);
332 int outSize = partonSystemsPtr->sizeOut(0);
333 for (
int iMem = 0; iMem < outSize; iMem++) {
334 int iNow = partonSystemsPtr->getOut(0, iMem);
337 if (iNow == jNow)
continue;
338 if (jNow ==
e[iNow].daughter1()
339 && jNow ==
e[iNow].daughter2())
continue;
343 if (pTnow > 0.) pTemt = (pTemt < 0)
344 ? pTnow :
min(pTemt, pTnow);
355 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
min(pTemt, pTnow);
357 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
min(pTemt, pTnow);
362 for (
int kNow = 0; kNow <
e.size(); kNow++) {
363 if (kNow == jNow || !
e[kNow].isFinal())
continue;
368 if (pTnow > 0.) pTemt = (pTemt < 0)
369 ? pTnow :
min(pTemt, pTnow);
371 if (pTnow > 0.) pTemt = (pTemt < 0)
372 ? pTnow :
min(pTemt, pTnow);
375 for (
int rNow = 0; rNow <
e.size(); rNow++) {
376 if (rNow == kNow || rNow == jNow ||
377 !
e[rNow].isFinal())
continue;
379 if (pTnow > 0.) pTemt = (pTemt < 0)
380 ? pTnow :
min(pTemt, pTnow);
391 std::cout <<
"pTcalc: i = " <<
i <<
", j = " << j <<
", k = " <<
k
392 <<
", r = " <<
r <<
", xSR = " << xSRin
393 <<
", pTemt = " << pTemt << std::endl;
410 if (nMPI > 1)
return false;
416 double pT1 = 0., pTsum = 0.;
417 for (
int i =
e.size() - 1;
i > 0;
i--) {
418 if (
e[
i].isFinal()) {
426 std::cout <<
"Error: wrong number of final state particles in event" << std::endl;
431 int iEmt = (isEmt) ?
e.size() - 1 : -1;
456 m_pTMPI = (isEmt) ? pTsum / 2. : pT1;
460 std::cout <<
"doVetoMPIStep: Qfac = " << infoPtr->scalup()
461 <<
", pThard = " <<
m_pThard << std::endl;
470 std::cout <<
"something wrong with pThard = " <<
m_pThard << std::endl;
486 if (iSys != 0)
return false;
493 int iRadAft = -1, iEmt = -1, iRecAft = -1;
494 for (
int i =
e.size() - 1;
i > 0;
i--) {
495 if (iRadAft == -1 &&
e[
i].
status() == -41) iRadAft =
i;
496 else if (iEmt == -1 &&
e[
i].
status() == 43) iEmt =
i;
497 else if (iRecAft == -1 &&
e[
i].
status() == -42) iRecAft =
i;
498 if (iRadAft != -1 && iEmt != -1 && iRecAft != -1)
break;
500 if (iRadAft == -1 || iEmt == -1 || iRecAft == -1) {
502 std::cout <<
"Error: couldn't find Pythia ISR emission" << std::endl;
517 std::cout <<
"doVetoISREmission: pTemt = " << pTemt << std::endl;
547 if (iSys != 0 && inr != 1)
return false;
569 int iRecAft =
e.size() - 1;
570 int iEmt =
e.size() - 2;
571 int iRadAft =
e.size() - 3;
572 int iRadBef =
e[iEmt].mother1();
576 std::cout <<
"Error: couldn't find Pythia FSR emission" << std::endl;
607 for (
int jLoop = 0; jLoop < 2; jLoop++) {
608 if (jLoop == 0) pTemt =
pTcalc(
e,
i, j,
k,
r, xSR);
609 else if (jLoop == 1) pTemt =
min(pTemt,
pTcalc(
e,
i, j,
k,
r, xSR));
613 if (
k != -1)
swap(j,
k);
else j = iEmt;
622 std::cout <<
"doVetoFSREmission: pTemt = " << pTemt << std::endl;
648 std::cout <<
"doVetoMPIEmission: pTnow = " <<
e[
e.size() - 1].pT()
649 <<
", pTMPI = " <<
m_pTMPI << std::endl;