1 #include "Pythia8/Pythia.h" 10 <<
"EmissionVeto: " << message << std::endl;
22 int EmtAfterBranch,
int RecAfterBranch,
bool FSR) {
28 int radID = e[RadAfterBranch].id();
31 double sign = (FSR) ? 1. : -1.;
33 double Qsq = sign * Q.m2Calc();
36 double m2Rad = (
abs(radID) >= 4 &&
abs(radID) < 7) ?
37 Pythia8::pow2(particleDataPtr->m0(radID)) : 0.;
44 double m2Dip = sum.m2Calc();
45 double x1 = 2. * (sum * radVec) / m2Dip;
46 double x3 = 2. * (sum * emtVec) / m2Dip;
54 z = qBR.m2Calc() / qAR.m2Calc();
59 pTnow *= (Qsq - sign * m2Rad);
63 std::cout <<
"Warning: pTpythia was negative" << std::endl;
68 std::cout <<
"pTpythia: rad = " << RadAfterBranch <<
", emt = " 69 << EmtAfterBranch <<
", rec = " << RecAfterBranch
70 <<
", pTnow = " <<
sqrt(pTnow) << std::endl;
86 int iInA = partonSystemsPtr->getInA(0);
87 int iInB = partonSystemsPtr->getInB(0);
88 double betaZ = - ( e[iInA].pz() + e[iInB].pz() ) /
89 ( e[iInA].
e() + e[iInB].e() );
91 iVecBst.bst(0., 0., betaZ);
92 jVecBst.bst(0., 0., betaZ);
93 pTnow =
sqrt( (iVecBst + jVecBst).m2Calc() *
94 iVecBst.e() * jVecBst.e() /
95 Pythia8::pow2(iVecBst.e() + jVecBst.e()) );
104 std::cout <<
"Warning: pTpowheg was negative" << std::endl;
109 std::cout <<
"pTpowheg: i = " << i <<
", j = " << j
110 <<
", pTnow = " << pTnow << std::endl;
124 double pTemt = -1., pTnow;
125 int xSR1 = (xSRin == -1) ? 0 : xSRin;
126 int xSR2 = (xSRin == -1) ? 2 : xSRin + 1;
127 for (
int xSR = xSR1; xSR < xSR2; xSR++) {
129 bool FSR = (xSR == 0) ?
false :
true;
133 if ((pTdefMode == 0 || pTdefMode == 1) && i > 0 && j > 0) {
134 pTemt = pTpowheg(e, i, j, (pTdefMode == 0) ?
false : FSR);
137 }
else if (!FSR && pTdefMode == 2 && i > 0 && j > 0 && r > 0) {
138 pTemt = pTpythia(e, i, j, r, FSR);
141 }
else if (FSR && pTdefMode == 2 && j > 0 && k > 0 && r > 0) {
142 pTemt = pTpythia(e, k, j, r, FSR);
150 int iInA = partonSystemsPtr->getInA(0);
151 int iInB = partonSystemsPtr->getInB(0);
152 while (e[iInA].mother1() != 1) { iInA = e[iInA].mother1(); }
153 while (e[iInB].mother1() != 2) { iInB = e[iInB].mother1(); }
156 int jNow = (j > 0) ? j : 0;
157 int jMax = (j > 0) ? j + 1 : e.size();
158 for (; jNow < jMax; jNow++) {
161 if (!e[jNow].isFinal())
continue;
163 if (QEDvetoMode==0 && e[jNow].colType() == 0)
continue;
166 if (pTdefMode == 0 || pTdefMode == 1) {
170 pTnow = pTpowheg(e, iInA, jNow, (pTdefMode == 0) ?
false : FSR);
171 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
178 int outSize = partonSystemsPtr->sizeOut(0);
179 for (
int iMem = 0; iMem < outSize; iMem++) {
180 int iNow = partonSystemsPtr->getOut(0, iMem);
183 if (iNow == jNow)
continue;
185 if (QEDvetoMode==0 && e[iNow].colType() == 0)
continue;
186 if (jNow == e[iNow].daughter1()
187 && jNow == e[iNow].daughter2())
continue;
189 pTnow = pTpowheg(e, iNow, jNow, (pTdefMode == 0)
191 if (pTnow > 0.) pTemt = (pTemt < 0)
198 }
else if (pTdefMode == 2) {
202 pTnow = pTpythia(e, iInA, jNow, iInB, FSR);
203 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
204 pTnow = pTpythia(e, iInB, jNow, iInA, FSR);
205 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
210 for (
int kNow = 0; kNow < e.size(); kNow++) {
211 if (kNow == jNow || !e[kNow].isFinal())
continue;
212 if (QEDvetoMode==0 && e[kNow].colType() == 0)
continue;
216 pTnow = pTpythia(e, kNow, jNow, iInA, FSR);
217 if (pTnow > 0.) pTemt = (pTemt < 0)
219 pTnow = pTpythia(e, kNow, jNow, iInB, FSR);
220 if (pTnow > 0.) pTemt = (pTemt < 0)
224 for (
int rNow = 0; rNow < e.size(); rNow++) {
225 if (rNow == kNow || rNow == jNow ||
226 !e[rNow].isFinal())
continue;
227 if(QEDvetoMode==0 && e[rNow].colType() == 0)
continue;
228 pTnow = pTpythia(e, kNow, jNow, rNow, FSR);
229 if (pTnow > 0.) pTemt = (pTemt < 0)
241 std::cout <<
"pTcalc: i = " << i <<
", j = " << j <<
", k = " << k
242 <<
", r = " << r <<
", xSR = " << xSRin
243 <<
", pTemt = " << pTemt << std::endl;
257 if(nFinalMode == 3 && pThardMode != 0)
258 fatalEmissionVeto(
std::string(
"When nFinalMode is set to 3, ptHardMode should be set to 0, since the emission variables in doVetoMPIStep are not set correctly case when there are three possible particle Born particle counts."));
261 if (nMPI > 1)
return false;
267 int count = 0, inonfinal = 0;
268 double pT1 = 0., pTsum = 0.;
272 for (
int i = e.size() - 1;
i > 0;
i--) {
274 if (e[
i].isFinal()) {
283 if (nFinalMode == 2) {
284 if ((
abs(e[
i].
id()) < 6 || e[
i].
id() == 21) &&
285 (
abs(e[e[
i].mother1()].
id()) < 6 || e[e[
i].mother1()].
id() == 21)) {
294 if (nFinal < 0 || nFinalMode == 1) {
295 int first = -1, myid;
297 for(
int ip = 2; ip < e.size(); ip++) {
299 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
303 if(first < 0) fatalEmissionVeto(
std::string(
"signal particles not found"));
304 for(
int ip = first; ip < e.size(); ip++) {
306 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
309 nFinal = last - inonfinal;
313 if (nFinalMode != 2) {
319 if (count != nFinal && count != nFinal + 1 && count != nFinal - 1)
320 fatalEmissionVeto(
std::string(
"Wrong number of final state particles in event"));
322 if (count != nFinal && count != nFinal + 1)
323 fatalEmissionVeto(
std::string(
"Wrong number of final state particles in event"));
326 if (count == nFinal + 1) isEmt =
true;
327 if (isEmt) iEmt = e.size() - 1;
331 if (!isEmt || pThardMode == 0) {
332 pThard = infoPtr->QRen();
336 }
else if (pThardMode == 1) {
337 pThard = pTcalc(e, -1, iEmt, -1, -1, -1);
342 }
else if (pThardMode == 2) {
343 pThard = pTcalc(e, -1, -1, -1, -1, -1);
349 pTMPI = (isEmt) ? pTsum / 2. : pT1;
353 std::cout <<
"doVetoMPIStep: QFac = " << infoPtr->QFac()
354 <<
", QRen = " << infoPtr->QRen()
355 <<
", pThard = " << pThard << std::endl << std::endl;
371 if (iSys != 0)
return false;
374 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
377 int iRadAft = -1, iEmt = -1, iRecAft = -1;
378 for (
int i = e.size() - 1;
i > 0;
i--) {
379 if (iRadAft == -1 && e[
i].
status() == -41) iRadAft =
i;
380 else if (iEmt == -1 && e[
i].
status() == 43) iEmt =
i;
381 else if (iRecAft == -1 && e[
i].
status() == -42) iRecAft =
i;
382 if (iRadAft != -1 && iEmt != -1 && iRecAft != -1)
break;
384 if (iRadAft == -1 || iEmt == -1 || iRecAft == -1) {
386 fatalEmissionVeto(
std::string(
"Couldn't find Pythia ISR emission"));
392 int xSR = (pTemtMode == 0) ? 0 : -1;
393 int i = (pTemtMode == 0) ? iRadAft : -1;
394 int j = (pTemtMode != 2) ? iEmt : -1;
396 int r = (pTemtMode == 0) ? iRecAft : -1;
397 double pTemt = pTcalc(e, i, j, k, r, xSR);
400 std::cout <<
"doVetoISREmission: pTemt = " << pTemt << std::endl << std::endl;
405 bool vetoParton = (!isEmt && e[iEmt].colType()==0 && QEDvetoMode==2)
409 if (pTemt > pThard) {
412 nAcceptSeq = vetoCount-1;
433 if (iSys != 0)
return false;
436 if (!inResonance && settingsPtr->flag(
"POWHEG:bb4l:FSREmission:veto")==1)
return false;
439 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
442 int iRecAft = e.size() - 1;
443 int iEmt = e.size() - 2;
444 int iRadAft = e.size() - 3;
445 int iRadBef = e[iEmt].mother1();
446 if ( (e[iRecAft].
status() != 52 && e[iRecAft].
status() != -53) ||
449 fatalEmissionVeto(
std::string(
"Couldn't find Pythia FSR emission"));
456 int xSR = (pTemtMode == 0) ? 1 : -1;
457 int i = (pTemtMode == 0) ? iRadBef : -1;
458 int k = (pTemtMode == 0) ? iRadAft : -1;
459 int r = (pTemtMode == 0) ? iRecAft : -1;
463 if (pTemtMode == 0 || pTemtMode == 1) {
470 if (emittedMode == 0 || (emittedMode == 2 && rndmPtr->flat() < 0.5)) j++;
472 for (
int jLoop = 0; jLoop < 2; jLoop++) {
473 if (jLoop == 0) pTemt = pTcalc(e, i, j, k, r, xSR);
474 else if (jLoop == 1) pTemt =
std::min(pTemt, pTcalc(e, i, j, k, r, xSR));
477 if (emittedMode != 3)
break;
478 if (k != -1)
std::swap(j, k);
else j = iEmt;
482 }
else if (pTemtMode == 2) {
483 pTemt = pTcalc(e, i, -1, k, r, xSR);
488 std::cout <<
"doVetoFSREmission: pTemt = " << pTemt << std::endl << std::endl;
493 bool vetoParton = (!isEmt && e[iEmt].colType()==0 && QEDvetoMode==2)
497 if (pTemt > pThard) {
500 nAcceptSeq = vetoCount-1;
520 if (e[e.size() - 1].pT() > pTMPI) {
522 std::cout <<
"doVetoMPIEmission: pTnow = " << e[e.size() - 1].pT()
523 <<
", pTMPI = " << pTMPI << std::endl << std::endl;
bool doVetoFSREmission(int, const Pythia8::Event &e, int iSys, bool) override
bool doVetoISREmission(int, const Pythia8::Event &e, int iSys) override
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Abs< T >::type abs(const T &t)
double pTpowheg(const Pythia8::Event &e, int i, int j, bool FSR)
bool doVetoMPIStep(int nMPI, const Pythia8::Event &e) override
double pTcalc(const Pythia8::Event &e, int i, int j, int k, int r, int xSRin)
bool accepted(std::vector< std::string_view > const &, std::string_view)
double pTpythia(const Pythia8::Event &e, int RadAfterBranch, int EmtAfterBranch, int RecAfterBranch, bool FSR)
void fatalEmissionVeto(std::string message)
bool doVetoMPIEmission(int, const Pythia8::Event &e) override