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;
162 if (e[jNow].colType() == 0 && e[jNow].
id() != 22)
continue;
165 if (pTdefMode == 0 || pTdefMode == 1) {
169 pTnow = pTpowheg(e, iInA, jNow, (pTdefMode == 0) ?
false : FSR);
170 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
177 int outSize = partonSystemsPtr->sizeOut(0);
178 for (
int iMem = 0; iMem < outSize; iMem++) {
179 int iNow = partonSystemsPtr->getOut(0, iMem);
182 if (iNow == jNow || e[iNow].colType() == 0)
continue;
183 if (jNow == e[iNow].daughter1()
184 && jNow == e[iNow].daughter2())
continue;
186 pTnow = pTpowheg(e, iNow, jNow, (pTdefMode == 0)
188 if (pTnow > 0.) pTemt = (pTemt < 0)
195 }
else if (pTdefMode == 2) {
199 pTnow = pTpythia(e, iInA, jNow, iInB, FSR);
200 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
201 pTnow = pTpythia(e, iInB, jNow, iInA, FSR);
202 if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow :
std::min(pTemt, pTnow);
207 for (
int kNow = 0; kNow < e.size(); kNow++) {
208 if (kNow == jNow || !e[kNow].isFinal() ||
209 e[kNow].colType() == 0)
continue;
213 pTnow = pTpythia(e, kNow, jNow, iInA, FSR);
214 if (pTnow > 0.) pTemt = (pTemt < 0)
216 pTnow = pTpythia(e, kNow, jNow, iInB, FSR);
217 if (pTnow > 0.) pTemt = (pTemt < 0)
221 for (
int rNow = 0; rNow < e.size(); rNow++) {
222 if (rNow == kNow || rNow == jNow ||
223 !e[rNow].isFinal() || e[rNow].colType() == 0)
continue;
224 pTnow = pTpythia(e, kNow, jNow, rNow, FSR);
225 if (pTnow > 0.) pTemt = (pTemt < 0)
237 std::cout <<
"pTcalc: i = " << i <<
", j = " << j <<
", k = " << k
238 <<
", r = " << r <<
", xSR = " << xSRin
239 <<
", pTemt = " << pTemt << std::endl;
254 if (nMPI > 1)
return false;
259 int count = 0, inonfinal = 0;
260 double pT1 = 0., pTsum = 0.;
261 for (
int i = e.size() - 1;
i > 0;
i--) {
263 if (e[
i].isFinal()) {
273 int first = -1, myid;
275 for(
int ip = 2; ip < e.size(); ip++) {
277 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
281 if(first < 0) fatalEmissionVeto(
std::string(
"signal particles not found"));
282 for(
int ip = first; ip < e.size(); ip++) {
284 if(
abs(myid) < 6 ||
abs(myid) == 21)
continue;
287 nFinal = last - inonfinal;
291 if (count != nFinal && count != nFinal + 1)
292 fatalEmissionVeto(
std::string(
"Wrong number of final state particles in event"));
295 bool isEmt = (count == nFinal) ?
false :
true;
296 int iEmt = (isEmt) ? e.size() - 1 : -1;
299 if (!isEmt || pThardMode == 0) {
300 pThard = infoPtr->QRen();
304 }
else if (pThardMode == 1) {
305 pThard = pTcalc(e, -1, iEmt, -1, -1, -1);
310 }
else if (pThardMode == 2) {
311 pThard = pTcalc(e, -1, -1, -1, -1, -1);
317 pTMPI = (isEmt) ? pTsum / 2. : pT1;
321 std::cout <<
"doVetoMPIStep: QFac = " << infoPtr->QFac()
322 <<
", QRen = " << infoPtr->QRen()
323 <<
", pThard = " << pThard << std::endl << std::endl;
339 if (iSys != 0)
return false;
342 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
345 int iRadAft = -1, iEmt = -1, iRecAft = -1;
346 for (
int i = e.size() - 1;
i > 0;
i--) {
347 if (iRadAft == -1 && e[
i].
status() == -41) iRadAft =
i;
348 else if (iEmt == -1 && e[
i].
status() == 43) iEmt =
i;
349 else if (iRecAft == -1 && e[
i].
status() == -42) iRecAft =
i;
350 if (iRadAft != -1 && iEmt != -1 && iRecAft != -1)
break;
352 if (iRadAft == -1 || iEmt == -1 || iRecAft == -1) {
354 fatalEmissionVeto(
std::string(
"Couldn't find Pythia ISR emission"));
360 int xSR = (pTemtMode == 0) ? 0 : -1;
361 int i = (pTemtMode == 0) ? iRadAft : -1;
362 int j = (pTemtMode != 2) ? iEmt : -1;
364 int r = (pTemtMode == 0) ? iRecAft : -1;
365 double pTemt = pTcalc(e, i, j, k, r, xSR);
368 std::cout <<
"doVetoISREmission: pTemt = " << pTemt << std::endl << std::endl;
372 if (pTemt > pThard) {
390 if (iSys != 0)
return false;
393 if (vetoOn && nAcceptSeq >= vetoCount)
return false;
396 int iRecAft = e.size() - 1;
397 int iEmt = e.size() - 2;
398 int iRadAft = e.size() - 3;
399 int iRadBef = e[iEmt].mother1();
400 if ( (e[iRecAft].
status() != 52 && e[iRecAft].
status() != -53) ||
403 fatalEmissionVeto(
std::string(
"Couldn't find Pythia FSR emission"));
410 int xSR = (pTemtMode == 0) ? 1 : -1;
411 int i = (pTemtMode == 0) ? iRadBef : -1;
412 int k = (pTemtMode == 0) ? iRadAft : -1;
413 int r = (pTemtMode == 0) ? iRecAft : -1;
417 if (pTemtMode == 0 || pTemtMode == 1) {
424 if (emittedMode == 0 || (emittedMode == 2 && rndmPtr->flat() < 0.5)) j++;
426 for (
int jLoop = 0; jLoop < 2; jLoop++) {
427 if (jLoop == 0) pTemt = pTcalc(e, i, j, k, r, xSR);
428 else if (jLoop == 1) pTemt =
std::min(pTemt, pTcalc(e, i, j, k, r, xSR));
431 if (emittedMode != 3)
break;
432 if (k != -1)
std::swap(j, k);
else j = iEmt;
436 }
else if (pTemtMode == 2) {
437 pTemt = pTcalc(e, i, -1, k, r, xSR);
442 std::cout <<
"doVetoFSREmission: pTemt = " << pTemt << std::endl << std::endl;
446 if (pTemt > pThard) {
464 if (e[e.size() - 1].pT() > pTMPI) {
466 std::cout <<
"doVetoMPIEmission: pTnow = " << e[e.size() - 1].pT()
467 <<
", pTMPI = " << pTMPI << std::endl << std::endl;
bool doVetoMPIEmission(int, const Pythia8::Event &e)
bool doVetoISREmission(int, const Pythia8::Event &e, int iSys)
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)
double pTcalc(const Pythia8::Event &e, int i, int j, int k, int r, int xSRin)
bool doVetoMPIStep(int nMPI, const Pythia8::Event &e)
double pTpythia(const Pythia8::Event &e, int RadAfterBranch, int EmtAfterBranch, int RecAfterBranch, bool FSR)
bool doVetoFSREmission(int, const Pythia8::Event &e, int iSys, bool)
void fatalEmissionVeto(std::string message)