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 (nMPI > 1)
return false;
263 int count = 0, inonfinal = 0;
264 double pT1 = 0., pTsum = 0.;
268 for (
int i = e.size() - 1;
i > 0;
i--) {
270 if (e[
i].isFinal()) {
279 if (nFinalMode == 2) {
280 if ((
abs(e[
i].
id()) < 6 || e[
i].
id() == 21) &&
281 (
abs(e[e[
i].mother1()].
id()) < 6 || e[e[
i].mother1()].
id() == 21)) {
290 if (nFinal < 0 || nFinalMode == 1) {
291 int first = -1, myid;
293 for(
int ip = 2; ip < e.size(); ip++) {
295 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
299 if(first < 0) fatalEmissionVeto(
std::string(
"signal particles not found"));
300 for(
int ip = first; ip < e.size(); ip++) {
302 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
305 nFinal = last - inonfinal;
309 if (nFinalMode != 2) {
311 if (count != nFinal && count != nFinal + 1)
312 fatalEmissionVeto(
std::string(
"Wrong number of final state particles in event"));
314 if (count == nFinal + 1) isEmt =
true;
315 if (isEmt) iEmt = e.size() - 1;
319 if (!isEmt || pThardMode == 0) {
320 pThard = infoPtr->QRen();
324 }
else if (pThardMode == 1) {
325 pThard = pTcalc(e, -1, iEmt, -1, -1, -1);
330 }
else if (pThardMode == 2) {
331 pThard = pTcalc(e, -1, -1, -1, -1, -1);
337 pTMPI = (isEmt) ? pTsum / 2. : pT1;
341 std::cout <<
"doVetoMPIStep: QFac = " << infoPtr->QFac()
342 <<
", QRen = " << infoPtr->QRen()
343 <<
", pThard = " << pThard << std::endl << std::endl;
359 if (iSys != 0)
return false;
362 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
365 int iRadAft = -1, iEmt = -1, iRecAft = -1;
366 for (
int i = e.size() - 1;
i > 0;
i--) {
367 if (iRadAft == -1 && e[
i].
status() == -41) iRadAft =
i;
368 else if (iEmt == -1 && e[
i].
status() == 43) iEmt =
i;
369 else if (iRecAft == -1 && e[
i].
status() == -42) iRecAft =
i;
370 if (iRadAft != -1 && iEmt != -1 && iRecAft != -1)
break;
372 if (iRadAft == -1 || iEmt == -1 || iRecAft == -1) {
374 fatalEmissionVeto(
std::string(
"Couldn't find Pythia ISR emission"));
380 int xSR = (pTemtMode == 0) ? 0 : -1;
381 int i = (pTemtMode == 0) ? iRadAft : -1;
382 int j = (pTemtMode != 2) ? iEmt : -1;
384 int r = (pTemtMode == 0) ? iRecAft : -1;
385 double pTemt = pTcalc(e, i, j, k, r, xSR);
388 std::cout <<
"doVetoISREmission: pTemt = " << pTemt << std::endl << std::endl;
393 bool vetoParton = (!isEmt && e[iEmt].colType()==0 && QEDvetoMode==2)
397 if (pTemt > pThard) {
400 nAcceptSeq = vetoCount-1;
421 if (iSys != 0)
return false;
424 if (!inResonance && settingsPtr->flag(
"POWHEG:bb4l:FSREmission:veto")==1)
return false;
427 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
430 int iRecAft = e.size() - 1;
431 int iEmt = e.size() - 2;
432 int iRadAft = e.size() - 3;
433 int iRadBef = e[iEmt].mother1();
434 if ( (e[iRecAft].
status() != 52 && e[iRecAft].
status() != -53) ||
437 fatalEmissionVeto(
std::string(
"Couldn't find Pythia FSR emission"));
444 int xSR = (pTemtMode == 0) ? 1 : -1;
445 int i = (pTemtMode == 0) ? iRadBef : -1;
446 int k = (pTemtMode == 0) ? iRadAft : -1;
447 int r = (pTemtMode == 0) ? iRecAft : -1;
451 if (pTemtMode == 0 || pTemtMode == 1) {
458 if (emittedMode == 0 || (emittedMode == 2 && rndmPtr->flat() < 0.5)) j++;
460 for (
int jLoop = 0; jLoop < 2; jLoop++) {
461 if (jLoop == 0) pTemt = pTcalc(e, i, j, k, r, xSR);
462 else if (jLoop == 1) pTemt =
std::min(pTemt, pTcalc(e, i, j, k, r, xSR));
465 if (emittedMode != 3)
break;
466 if (k != -1)
std::swap(j, k);
else j = iEmt;
470 }
else if (pTemtMode == 2) {
471 pTemt = pTcalc(e, i, -1, k, r, xSR);
476 std::cout <<
"doVetoFSREmission: pTemt = " << pTemt << std::endl << std::endl;
481 bool vetoParton = (!isEmt && e[iEmt].colType()==0 && QEDvetoMode==2)
485 if (pTemt > pThard) {
488 nAcceptSeq = vetoCount-1;
508 if (e[e.size() - 1].pT() > pTMPI) {
510 std::cout <<
"doVetoMPIEmission: pTnow = " << e[e.size() - 1].pT()
511 <<
", 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)
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