10 #include "Pythia8/Pythia.h"
13 #if PYTHIA_VERSION_INTEGER >= 8310
17 # include "Pythia8/Plugins.h"
18 # undef PYTHIA8_PLUGIN_CLASS
19 # undef PYTHIA8_PLUGIN_VERSIONS
20 # define PYTHIA8_PLUGIN_CLASS(BASE, CLASS, PYTHIA, SETTINGS, LOGGER)
21 # define PYTHIA8_PLUGIN_VERSIONS(...)
23 #include "Pythia8Plugins/PowhegHooks.h"
36 namespace Pythia8 {
class PowhegBB4Ltms; }
51 : m_debug(
"Powheg:bb4l:DEBUG", false),
52 m_vetoFSREmission(
"Powheg:bb4l:FSREmission:veto", true),
53 m_dryRunFSR(
"Powheg:bb4l:dryRunFSR", false),
54 m_onlyDistance1(
"Powheg:bb4l:onlyDistance1", false),
55 m_vetoAtPL(
"Powheg:bb4l:vetoAtPL", false),
56 m_vetoQED(
"Powheg:bb4l:vetoQED", false),
57 m_vetoPartonLevel(
"Powheg:bb4l:PartonLevel:veto", 0),
58 m_wouldVetoFsr(false),
59 m_topresscale(-1.), m_vetoDecScale(-1.), m_atopresscale(-1.),
61 m_pTmin(
"Powheg:bb4l:pTminVeto", 0.5),
63 m_vetoProduction(
"Powheg:veto", 0),
64 m_pTpythiaVeto(
"Powheg:bb4l:pTpythiaVeto", 0),
65 m_vetoDipoleFrame(
"Powheg:bb4l:FSREmission:vetoDipoleFrame", 0),
66 m_scaleResonanceVeto(
"Powheg:bb4l:ScaleResonance:veto", 0.)
68 std::cout <<
"**********************************************************" << std::endl;
69 std::cout <<
"* *" << std::endl;
70 std::cout <<
"* Applying Powheg BB4L UserHook! *" << std::endl;
71 std::cout <<
"* Must run on dedicated Powheg LHE input file *" << std::endl;
72 std::cout <<
"* (on your own responsibility) *" << std::endl;
73 std::cout <<
"* *" << std::endl;
74 std::cout <<
"**********************************************************" << std::endl;
79 ~PowhegBB4Ltms()
override { std::cout <<
"Number of FSR vetoed in BB4l = " << m_nFSRvetoBB4l << std::endl; }
85 PowhegHooks::initAfterBeams();
115 ss << infoPtr->getEventComments();
118 assert (
temp ==
"#rwgt");
121 int i_top = -1, i_atop = -1;
122 for (
int i = 0;
i <
e.size();
i++) {
123 if (
e[
i].
id() == 6) i_top =
i;
124 if (
e[
i].
id() == -6) i_atop =
i;
127 m_topresscale = findresscale(i_top,
e);
129 m_topresscale = 1e30;
131 m_atopresscale = findresscale(i_atop,
e);
133 m_atopresscale = 1e30;
143 virtual bool retryPartonLevel()
override {
return m_vetoPartonLevel(settingsPtr) || m_vetoAtPL(settingsPtr); }
144 inline virtual bool canVetoPartonLevel()
override {
return m_vetoPartonLevel(settingsPtr) || m_vetoAtPL(settingsPtr); }
148 if(m_debug(settingsPtr)){
149 if (m_dryRunFSR(settingsPtr) && m_wouldVetoFsr) {
150 double scale = getdechardness(m_vetoTopCharge,
e);
151 std::cout <<
"FSRdecScale = " << m_vetoDecScale <<
", PLdecScale = " <<
scale <<
", ratio = " << m_vetoDecScale/
scale << std::endl;
154 if (m_vetoPartonLevel(settingsPtr)) {
155 double topdecscale = getdechardness(1,
e);
156 double atopdecscale = getdechardness(-1,
e);
157 if ((topdecscale > m_topresscale) || (atopdecscale > m_atopresscale)) {
163 if (m_vetoAtPL(settingsPtr)) {
164 if (m_dryRunFSR(settingsPtr) && m_wouldVetoFsr)
return true;
178 int nDau =
event[iRes].daughterList().size();
187 scale = m_pTmin(settingsPtr);
189 else if (std::abs(
event[iRes].
id()) == 6) {
191 int idw = -1,
idb = -1, idg = -1;
193 for (
int i = 0;
i < nDau;
i++) {
194 int iDau =
event[iRes].daughterList()[
i];
195 if (std::abs(
event[iDau].
id()) == 24) idw = iDau;
196 if (std::abs(
event[iDau].
id()) == 5)
idb = iDau;
197 if (std::abs(
event[iDau].
id()) == 21) idg = iDau;
202 pw.bstback(
event[iRes].
p());
226 vector<int> &positions, vector<Vec4> &momenta,
bool exitOnExtraLegs =
true){
228 if (
e[iparticle].daughterList().
size() !=
ids.size()) {
229 if (exitOnExtraLegs &&
e[iparticle].daughterList().
size() >
ids.size()) {
230 std::cout <<
"extra leg" << std::endl;
237 for (
unsigned int i = 0;
i <
e[iparticle].daughterList().
size();
i++) {
238 int di =
e[iparticle].daughterList()[
i];
246 for (
unsigned int i = 0;
i <
e[iparticle].daughterList().
size();
i++) {
247 int di =
e[iparticle].daughterList()[
i];
248 positions.push_back(di);
249 momenta.push_back(
e[di].
p());
257 return std::sqrt( 2*
p1*
p2*
p2.e()/
p1.e() );
274 Vec4 radVec =
e[RadAfterBranch].p();
275 Vec4 emtVec =
e[EmtAfterBranch].p();
276 Vec4 recVec =
e[RecAfterBranch].p();
277 int radID =
e[RadAfterBranch].id();
280 Vec4 Q(radVec + emtVec);
281 double Qsq = Q.m2Calc();
285 double m2Rad = (std::abs(radID) >= 4 && std::abs(radID) < 7) ?
286 pow2(particleDataPtr->m0(radID)) : 0.;
291 Vec4
sum = radVec + recVec + emtVec;
292 double m2Dip =
sum.m2Calc();
293 double x1 = 2. * (
sum * radVec) / m2Dip;
294 double x3 = 2. * (
sum * emtVec) / m2Dip;
296 pTnow =
z * (1. -
z);
299 pTnow *= (Qsq - m2Rad);
302 #if PYTHIA_VERSION_INTEGER >= 8310
303 loggerPtr->ERROR_MSG(
"Warning: pTpythia was negative");
305 infoPtr->errorMsg(
"Warning: pTpythia was negative");
310 return(std::sqrt(pTnow));
315 int tid = 6*topcharge, wid = 24*topcharge, bid = 5*topcharge,
gid = 21,
wildcard = 0;
318 Vec4 p_top, p_b, p_g, p_g1, p_g2;
319 for (
int i = 0;
i <
e.size();
i++)
320 if (
e[
i].
id() == tid) {
324 if (i_top == -1)
return -1.0;
342 vector<Vec4> momenta;
343 vector<int> positions;
346 if ( match_decay(i_top,
e, vector<int> {wid, bid}, positions, momenta,
false) ) {
348 int i_b = positions[1];
350 if ( match_decay(i_b,
e, vector<int> {bid,
gid}, positions, momenta) )
351 h = qSplittingScale(
e[i_top].
p(), momenta[0], momenta[1]);
358 else if ( match_decay(i_top,
e, vector<int> {wid, bid,
gid}, positions, momenta,
false) ) {
360 int i_b = positions[1], i_g = positions[2];
362 if ( match_decay(i_b,
e, vector<int> {bid,
gid}, positions, momenta) )
363 h1 = qSplittingScale(
e[i_top].
p(), momenta[0], momenta[1]);
369 h2 = gSplittingScale(
e[i_top].
p(), momenta[0], momenta[1]);
377 std::cout <<
"getdechardness" << std::endl;
378 std::cout <<
"top at position " << i_top << std::endl;
379 std::cout <<
"with " <<
e[i_top].daughterList().size() <<
" daughters " << std::endl;
380 for (
unsigned int i = 0;
i <
e[i_top].daughterList().
size();
i++) {
381 int di =
e[i_top].daughterList()[
i];
382 std::cout <<
"with daughter " << di <<
": " <<
e[di].id() << std::endl;
398 if (
e[iRes].
id() == 6){
400 return std::sqrt(
e[iRes].m2Calc());
402 return m_topresscale;
404 else if (
e[iRes].
id() == -6){
406 return std::sqrt(
e[iRes].m2Calc());
408 return m_atopresscale;
423 virtual inline bool canVetoFSREmission()
override {
return m_vetoFSREmission(settingsPtr) || m_vetoProduction(settingsPtr); }
428 if (inResonance && m_vetoFSREmission(settingsPtr)) {
431 int iRecAft =
e.size() - 1;
432 int iEmt =
e.size() - 2;
433 int iRadAft =
e.size() - 3;
434 int iRadBef =
e[iEmt].mother1();
437 int iTop =
e[iRadBef].mother1();
439 while (std::abs(
e[iTop].
id()) != 6 && iTop > 0) {
440 iTop =
e[iTop].mother1();
444 #if PYTHIA_VERSION_INTEGER >= 8310
445 loggerPtr->ERROR_MSG(
"Warning in PowhegHooksBB4L::doVetoFSREmission: emission in resonance not from top quark, not vetoing");
447 infoPtr->errorMsg(
"Warning in PowhegHooksBB4L::doVetoFSREmission: emission in resonance not from top quark, not vetoing");
449 return doVetoFSR(
false,0,0);
451 int iTopCharge = (
e[iTop].id()>0)?1:-1;
456 if(m_pTpythiaVeto(settingsPtr))
457 scale = pTpythia(
e, iRadAft, iEmt, iRecAft);
459 Vec4
pr(
e[iRadAft].
p()),
pe(
e[iEmt].
p()),
pt(
e[iTop].
p()),
prec(
e[iRecAft].
p()), psystem;
463 if(m_vetoDipoleFrame(settingsPtr))
469 if (
e[iRadBef].
id() == 21)
470 scale = gSplittingScale(psystem,
pr,
pe);
472 else if (std::abs(
e[iRadBef].
id()) == 5 && ((
e[iEmt].
id() == 21) && ! m_vetoQED(settingsPtr)) )
473 scale = qSplittingScale(psystem,
pr,
pe);
480 if (iTopCharge > 0) {
481 if (m_onlyDistance1(settingsPtr)) {
482 if ( m_debug(settingsPtr) && (
distance == 1) &&
scale > m_topresscale && ! m_wouldVetoFsr)
483 std::cout <<
e[iTop].id() <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << std::endl;
487 if ( m_debug(settingsPtr) &&
scale > m_topresscale && ! m_wouldVetoFsr)
488 std::cout <<
e[iTop].id() <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << std::endl;
489 return doVetoFSR(
scale > m_topresscale,
scale,iTopCharge);
492 else if (iTopCharge < 0){
493 if (m_onlyDistance1(settingsPtr)){
494 if ( m_debug(settingsPtr) && (
distance == 1) &&
scale > m_atopresscale && ! m_wouldVetoFsr)
495 std::cout <<
e[iTop].id() <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << std::endl;
499 if ( m_debug(settingsPtr) &&
scale > m_topresscale && ! m_wouldVetoFsr)
500 std::cout <<
e[iTop].id() <<
": " <<
e[iRadBef].id() <<
" > " <<
e[iRadAft].id() <<
" + " <<
e[iEmt].id() <<
"; " <<
scale << std::endl;
501 return doVetoFSR(
scale > m_atopresscale,
scale,iTopCharge);
505 std::cout <<
"Bug in PohwgeHooksBB4l" << std::endl;
512 else if(!inResonance && m_vetoProduction(settingsPtr)){
513 return PowhegHooks::doVetoFSREmission(sizeOld,
e, iSys, inResonance);
524 if (!m_wouldVetoFsr) {
525 m_wouldVetoFsr =
true;
526 m_vetoDecScale =
scale;
527 m_vetoTopCharge = iTopCharge;
529 if (m_dryRunFSR(settingsPtr))
return false;
539 m_wouldVetoFsr =
false;