101 #include "Pythia8/Pythia.h"
104 #if PYTHIA_VERSION_INTEGER >= 8310
108 # include "Pythia8/Plugins.h"
109 # undef PYTHIA8_PLUGIN_CLASS
110 # undef PYTHIA8_PLUGIN_VERSIONS
111 # define PYTHIA8_PLUGIN_CLASS(BASE, CLASS, PYTHIA, SETTINGS, LOGGER)
112 # define PYTHIA8_PLUGIN_VERSIONS(...)
114 #include "Pythia8Plugins/PowhegHooks.h"
126 namespace Pythia8 {
class PowhegBB4Ldlsl; }
138 : m_debug(
"Powheg:bb4l:DEBUG", false),
139 m_vetoFSREmission(
"Powheg:bb4l:FSREmission:veto", true),
140 m_vetoQED(
"Powheg:bb4l:vetoQED", false),
141 m_topresscale(-1.), m_atopresscale(-1.),
142 m_wpresscale(-1.),m_wmresscale(-1.),
143 m_nInResonanceFSRveto(0),
144 m_pTmin(
"Powheg:bb4l:pTminVeto", 0.5),
145 m_vetoProduction(
"Powheg:veto", 1),
146 m_pTpythiaVeto(
"Powheg:bb4l:pTpythiaVeto", 0),
147 m_vetoDipoleFrame(
"Powheg:bb4l:FSREmission:vetoDipoleFrame", 0),
148 m_scaleResonanceVeto(
"Powheg:bb4l:ScaleResonance:veto", 0.)
150 std::cout <<
"**********************************************************" << std::endl;
151 std::cout <<
"* *" << std::endl;
152 std::cout <<
"* Applying Powheg BB4L UserHook (PowhegBB4Ldlsl)! *" << std::endl;
153 std::cout <<
"* Must run on dedicated Powheg LHE input file *" << std::endl;
154 std::cout <<
"* (on your own responsibility) *" << std::endl;
155 std::cout <<
"* *" << std::endl;
156 std::cout <<
"**********************************************************" << std::endl;
165 PowhegHooks::initAfterBeams();
178 ss << infoPtr->getEventComments();
181 assert (
temp ==
"#rwgt");
185 if (
radtype_.radtype==2)
return false;
187 int i_top = -1, i_atop = -1, i_wp = -1, i_wm = -1;
188 for (
int i = 0;
i <
e.size();
i++) {
189 if (
e[
i].
id() == 6) i_top =
i;
190 if (
e[
i].
id() == -6) i_atop =
i;
191 if (
e[
i].
id() == 24) i_wp =
i;
192 if (
e[
i].
id() == -24) i_wm =
i;
195 m_topresscale = findresscale(i_top,
e);
197 m_atopresscale = findresscale(i_atop,
e);
199 m_wpresscale = findresscale(i_wp,
e);
200 m_wmresscale = findresscale(i_wm,
e);
214 inline virtual bool canVetoFSREmission()
override {
return m_vetoFSREmission(settingsPtr) || m_vetoProduction(settingsPtr); }
218 if (inResonance && m_vetoFSREmission(settingsPtr)) {
221 int iRecAft =
e.size() - 1;
222 int iEmt =
e.size() - 2;
223 int iRadAft =
e.size() - 3;
224 int iRadBef =
e[iEmt].mother1();
227 int iRes =
e[iRadBef].mother1();
228 while ( iRes > 0 && (abs(
e[iRes].
id()) !=6 && abs(
e[iRes].
id()) != 24) ) {
229 iRes =
e[iRes].mother1();
232 #if PYTHIA_VERSION_INTEGER >= 8310
233 loggerPtr->ERROR_MSG(
"Warning in PowhegHooksBB4L::doVetoFSREmission: emission in resonance not from the top quark or from the W boson, not vetoing");
235 infoPtr->errorMsg(
"Warning in PowhegHooksBB4L::doVetoFSREmission: emission in resonance not from the top quark or from the W boson, not vetoing");
237 return doVetoFSR(
false);
239 int iResId =
e[iRes].id();
244 if(m_pTpythiaVeto(settingsPtr))
245 scale = pTpythia(
e, iRadAft, iEmt, iRecAft);
248 Vec4
pr(
e[iRadAft].
p()),
pe(
e[iEmt].
p()), pres(
e[iRes].
p()),
prec(
e[iRecAft].
p()), psystem;
252 if(m_vetoDipoleFrame(settingsPtr))
258 if (
e[iRadBef].
id() == 21)
259 scale = gSplittingScale(psystem,
pr,
pe);
261 else if (abs(
e[iRadBef].
id()) <= 5 && ((
e[iEmt].
id() == 21) && ! m_vetoQED(settingsPtr)) )
262 scale = qSplittingScale(psystem,
pr,
pe);
271 if ( m_debug(settingsPtr) &&
scale > m_topresscale)
272 cout << iResId <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << endl;
273 return doVetoFSR(
scale > m_topresscale);
275 else if (iResId == -6){
276 if ( m_debug(settingsPtr) &&
scale > m_atopresscale)
277 cout << iResId <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << endl;
278 return doVetoFSR(
scale > m_atopresscale);
280 else if (iResId == 24) {
281 if ( m_debug(settingsPtr) &&
scale > m_wpresscale)
282 cout << iResId <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << endl;
283 return doVetoFSR(
scale > m_wpresscale);
285 else if (iResId == -24){
286 if ( m_debug(settingsPtr) &&
scale > m_wmresscale)
287 cout << iResId <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << endl;
288 return doVetoFSR(
scale > m_wmresscale);
291 #if PYTHIA_VERSION_INTEGER >= 8310
292 loggerPtr->ERROR_MSG(
"Error in PowhegHooksBB4L::doVetoFSREmission: unimplemented case");
294 infoPtr->errorMsg(
"Error in PowhegHooksBB4L::doVetoFSREmission: unimplemented case");
300 else if(!inResonance && m_vetoProduction(settingsPtr)){
301 return PowhegHooks::doVetoFSREmission(sizeOld,
e, iSys, inResonance);
310 if (
radtype_.radtype==2)
return false;
312 m_nInResonanceFSRveto++;
329 return sqrt(
e[iRes].m2Calc());
331 if (
e[iRes].
id() == 6)
332 return m_topresscale;
333 else if (
e[iRes].
id() == -6)
334 return m_atopresscale;
335 else if (
e[iRes].
id() == 24)
337 else if (
e[iRes].
id() == -24)
350 if (iRes < 0)
return 1e30;
353 int nDau =
event[iRes].daughterList().size();
363 return m_pTmin(settingsPtr);
366 else if (abs(
event[iRes].
id()) == 6) {
368 int idw = -1,
idb = -1, idg = -1;
369 for (
int i = 0;
i < nDau;
i++) {
370 int iDau =
event[iRes].daughterList()[
i];
371 if (abs(
event[iDau].
id()) == 24) idw = iDau;
372 if (abs(
event[iDau].
id()) == 5)
idb = iDau;
373 if (abs(
event[iDau].
id()) == 21) idg = iDau;
378 pw.bstback(
event[iRes].
p());
388 else if (abs(
event[iRes].
id()) == 24) {
390 int idq = -1, ida = -1, idg = -1;
391 for (
int i = 0;
i < nDau;
i++) {
392 int iDau =
event[iRes].daughterList()[
i];
393 if (
event[iDau].
id() == 21) idg = iDau;
394 else if (
event[iDau].
id() > 0) idq = iDau;
395 else if (
event[iDau].
id() < 0) ida = iDau;
397 if (idq<0 or ida <0){
398 throw std::out_of_range(
"idq or ida out of range in PowhegHooksBB4Ldlsl.cxx");
402 pq.bstback(
event[iRes].
p());
404 pa.bstback(
event[iRes].
p());
409 Vec4 pw = pq + pa +
pg;
411 double csi = 2*
pg.e()/sqrt(q2);
412 double yq = 1 -
pg*pq/(
pg.e()*pq.e());
413 double ya = 1 -
pg*pa/(
pg.e()*pa.e());
415 return sqrt(
min(1-yq,1-ya)*pow2(csi)*q2/2);
426 inline bool match_decay(
int iparticle,
const Event &
e,
const vector<int> &
ids, vector<int> &positions, vector<Vec4> &momenta,
bool exitOnExtraLegs =
true){
428 if (
e[iparticle].daughterList().
size() !=
ids.size()) {
429 if (exitOnExtraLegs &&
e[iparticle].daughterList().
size() >
ids.size()) {
430 cout <<
"extra leg" << endl;
436 for (
long unsigned int i = 0;
i <
e[iparticle].daughterList().
size();
i++) {
437 int di =
e[iparticle].daughterList()[
i];
445 for (
long unsigned int i = 0;
i <
e[iparticle].daughterList().
size();
i++) {
446 int di =
e[iparticle].daughterList()[
i];
447 positions.push_back(di);
448 momenta.push_back(
e[di].
p());
456 return sqrt( 2*
p1*
p2*
p2.e()/
p1.e() );
474 Vec4 radVec =
e[RadAfterBranch].p();
475 Vec4 emtVec =
e[EmtAfterBranch].p();
476 Vec4 recVec =
e[RecAfterBranch].p();
477 int radID =
e[RadAfterBranch].id();
480 Vec4 Q(radVec + emtVec);
481 double Qsq = Q.m2Calc();
484 double m2Rad = (abs(radID) >= 4 && abs(radID) < 7) ?
485 pow2(particleDataPtr->m0(radID)) : 0.;
490 Vec4
sum = radVec + recVec + emtVec;
491 double m2Dip =
sum.m2Calc();
493 double x1 = 2. * (
sum * radVec) / m2Dip;
494 double x3 = 2. * (
sum * emtVec) / m2Dip;
496 pTnow =
z * (1. -
z);
500 pTnow *= (Qsq - m2Rad);
503 cout <<
"Warning: pTpythia was negative" << endl;