8 #include "TimeShower.h"
22 const double TimeShower::SIMPLIFYROOT = 1e-8;
27 const double TimeShower::XMARGIN = 1e-12;
28 const double TimeShower::XMARGINCOMB = 1e-4;
31 const double TimeShower::TINYPDF = 1e-10;
34 const double TimeShower::LARGEM2 = 1e20;
37 const double TimeShower::THRESHM2 = 4.004;
40 const double TimeShower::LAMBDA3MARGIN = 1.1;
45 const bool TimeShower::FIXRESCATTER =
true;
47 const bool TimeShower::VETONEGENERGY =
false;
49 const double TimeShower::MAXVIRTUALITYFRACTION = 0.5;
51 const double TimeShower::MAXNEGENERGYFRACTION = 0.7;
57 void TimeShower::init( BeamParticle* beamAPtrIn,
58 BeamParticle* beamBPtrIn) {
61 beamAPtr = beamAPtrIn;
62 beamBPtr = beamBPtrIn;
65 doQCDshower = settingsPtr->flag(
"TimeShower:QCDshower");
66 doQEDshowerByQ = settingsPtr->flag(
"TimeShower:QEDshowerByQ");
67 doQEDshowerByL = settingsPtr->flag(
"TimeShower:QEDshowerByL");
68 doQEDshowerByGamma = settingsPtr->flag(
"TimeShower:QEDshowerByGamma");
69 doMEcorrections = settingsPtr->flag(
"TimeShower:MEcorrections");
70 doMEafterFirst = settingsPtr->flag(
"TimeShower:MEafterFirst");
71 doPhiPolAsym = settingsPtr->flag(
"TimeShower:phiPolAsym");
72 doInterleave = settingsPtr->flag(
"TimeShower:interleave");
73 allowBeamRecoil = settingsPtr->flag(
"TimeShower:allowBeamRecoil");
74 dampenBeamRecoil = settingsPtr->flag(
"TimeShower:dampenBeamRecoil");
75 recoilToColoured = settingsPtr->flag(
"TimeShower:recoilToColoured");
78 pTmaxMatch = settingsPtr->mode(
"TimeShower:pTmaxMatch");
79 pTdampMatch = settingsPtr->mode(
"TimeShower:pTdampMatch");
80 pTmaxFudge = settingsPtr->parm(
"TimeShower:pTmaxFudge");
81 pTmaxFudgeMPI = settingsPtr->parm(
"TimeShower:pTmaxFudgeMPI");
82 pTdampFudge = settingsPtr->parm(
"TimeShower:pTdampFudge");
85 mc = particleDataPtr->m0(4);
86 mb = particleDataPtr->m0(5);
91 alphaSvalue = settingsPtr->parm(
"TimeShower:alphaSvalue");
92 alphaSorder = settingsPtr->mode(
"TimeShower:alphaSorder");
93 alphaS2pi = 0.5 * alphaSvalue / M_PI;
96 alphaS.init( alphaSvalue, alphaSorder);
99 Lambda3flav = alphaS.Lambda3();
100 Lambda4flav = alphaS.Lambda4();
101 Lambda5flav = alphaS.Lambda5();
102 Lambda5flav2 = pow2(Lambda5flav);
103 Lambda4flav2 = pow2(Lambda4flav);
104 Lambda3flav2 = pow2(Lambda3flav);
107 nGluonToQuark = settingsPtr->mode(
"TimeShower:nGluonToQuark");
108 pTcolCutMin = settingsPtr->parm(
"TimeShower:pTmin");
109 if (pTcolCutMin > LAMBDA3MARGIN * Lambda3flav)
110 pTcolCut = pTcolCutMin;
112 pTcolCut = LAMBDA3MARGIN * Lambda3flav;
113 ostringstream newPTcolCut;
114 newPTcolCut << fixed << setprecision(3) << pTcolCut;
115 infoPtr->errorMsg(
"Warning in TimeShower::init: pTmin too low",
116 ", raised to " + newPTcolCut.str() );
117 infoPtr->setTooLowPTmin(
true);
119 pT2colCut = pow2(pTcolCut);
122 alphaEMorder = settingsPtr->mode(
"TimeShower:alphaEMorder");
125 alphaEM.init( alphaEMorder, settingsPtr);
128 nGammaToQuark = settingsPtr->mode(
"TimeShower:nGammaToQuark");
129 nGammaToLepton = settingsPtr->mode(
"TimeShower:nGammaToLepton");
130 pTchgQCut = settingsPtr->parm(
"TimeShower:pTminChgQ");
131 pT2chgQCut = pow2(pTchgQCut);
132 pTchgLCut = settingsPtr->parm(
"TimeShower:pTminChgL");
133 pT2chgLCut = pow2(pTchgLCut);
134 mMaxGamma = settingsPtr->parm(
"TimeShower:mMaxGamma");
135 m2MaxGamma = pow2(mMaxGamma);
138 if (nGammaToQuark <= 0 && nGammaToLepton <= 0) doQEDshowerByGamma =
false;
141 globalRecoil = settingsPtr->flag(
"TimeShower:globalRecoil");
142 nMaxGlobalRecoil = settingsPtr->mode(
"TimeShower:nMaxGlobalRecoil");
145 octetOniumFraction = settingsPtr->parm(
"TimeShower:octetOniumFraction");
146 octetOniumColFac = settingsPtr->parm(
"TimeShower:octetOniumColFac");
149 mZ = particleDataPtr->m0(23);
150 gammaZ = particleDataPtr->mWidth(23);
151 thetaWRat = 1. / (16. * coupSMPtr->sin2thetaW()
152 * coupSMPtr->cos2thetaW());
155 allowRescatter = settingsPtr->flag(
"PartonLevel:MPI")
156 && settingsPtr->flag(
"MultipartonInteractions:allowRescatter");
159 doHVshower = settingsPtr->flag(
"HiddenValley:FSR");
160 nCHV = settingsPtr->mode(
"HiddenValley:Ngauge");
161 alphaHVfix = settingsPtr->parm(
"HiddenValley:alphaFSR");
162 pThvCut = settingsPtr->parm(
"HiddenValley:pTminFSR");
163 pT2hvCut = pThvCut * pThvCut;
164 CFHV = (nCHV == 1) ? 1. : (nCHV * nCHV - 1.)/(2. * nCHV);
165 idHV = (nCHV == 1) ? 4900022 : 4900021;
166 mHV = particleDataPtr->m0(idHV);
167 brokenHVsym = (nCHV == 1 && mHV > 0.);
170 canVetoEmission = (userHooksPtr > 0) ? userHooksPtr->canVetoFSREmission()
180 bool TimeShower::limitPTmax(
Event& event,
double Q2Fac,
double Q2Ren) {
183 bool dopTlimit =
false;
184 if (pTmaxMatch == 1) dopTlimit =
true;
185 else if (pTmaxMatch == 2) dopTlimit =
false;
189 for (
int i = 5; i <
event.size(); ++i)
190 if (event[i].status() != -21) {
191 int idAbs =
event[i].idAbs();
192 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit =
true;
199 if ( !dopTlimit && (pTdampMatch == 1 || pTdampMatch == 2) ) {
201 pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 1) ? Q2Fac : Q2Ren);
213 int TimeShower::shower(
int iBeg,
int iEnd,
Event& event,
double pTmax,
217 int iSys = partonSystemsPtr->addSys();
221 for (
int i = iBeg; i <= iEnd; ++i)
if (event[i].isFinal()) {
222 partonSystemsPtr->addOut( iSys, i);
223 pSum +=
event[i].p();
225 partonSystemsPtr->setSHat( iSys, pSum.m2Calc() );
228 prepare( iSys, event,
true);
234 double pTtimes = pTnext( event, pTmax, 0.);
238 if (branch( event)) {
240 pTLastBranch = pTtimes;
247 }
while (pTmax > 0. && (nBranchMax <= 0 || nBranch < nBranchMax));
258 void TimeShower::prepare(
int iSys,
Event& event,
bool limitPTmaxIn) {
261 int iInA = partonSystemsPtr->getInA(iSys);
262 int iInB = partonSystemsPtr->getInB(iSys);
263 if (iSys == 0 || iInA == 0) dipEnd.resize(0);
264 int dipEndSizeBeg = dipEnd.size();
267 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
268 int iRad = partonSystemsPtr->getOut( iSys, i);
269 if (event[iRad].isFinal() && event[iRad].scale() > 0.) {
272 int idRad =
event[iRad].id();
273 int idRadAbs = abs(idRad);
275 = ( idRad == 9900441 || idRad == 9900443 || idRad == 9910441
276 || idRad == 9900551 || idRad == 9900553 || idRad == 9910551 );
277 bool doQCD = doQCDshower;
278 if (doQCD && isOctetOnium)
279 doQCD = (rndmPtr->flat() < octetOniumFraction);
282 int colTag =
event[iRad].col();
283 if (doQCD && colTag > 0) setupQCDdip( iSys, i, colTag, 1, event,
284 isOctetOnium, limitPTmaxIn);
287 int acolTag =
event[iRad].acol();
288 if (doQCD && acolTag > 0) setupQCDdip( iSys, i, acolTag, -1, event,
289 isOctetOnium, limitPTmaxIn);
292 int chgType =
event[iRad].chargeType();
293 bool doChgDip = (chgType != 0)
294 && ( ( doQEDshowerByQ && event[iRad].isQuark() )
295 || ( doQEDshowerByL &&
event[iRad].isLepton() ) );
296 int gamType = (idRad == 22) ? 1 : 0;
297 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
298 if (doChgDip || doGamDip) setupQEDdip( iSys, i, chgType, gamType,
299 event, limitPTmaxIn);
302 bool isHVrad = (idRadAbs > 4900000 && idRadAbs < 4900007)
303 || (idRadAbs > 4900010 && idRadAbs < 4900017)
304 || idRadAbs == 4900101;
305 if (doHVshower && isHVrad) setupHVdip( iSys, i, event, limitPTmaxIn);
312 for (
int iDip = dipEndSizeBeg; iDip < int(dipEnd.size()); ++iDip)
313 findMEtype( event, dipEnd[iDip]);
316 if (iSys > 0 && ( (iInA > 0 && event[iInA].status() == -34)
317 || (iInB > 0 &&
event[iInB].status() == -34) ) )
318 rescatterUpdate( iSys, event);
325 void TimeShower::rescatterUpdate(
int iSys,
Event& event) {
329 for (
int iResc = 0; iResc < 2; ++iResc) {
330 int iIn = (iResc == 0) ? partonSystemsPtr->getInA(iSys)
331 : partonSystemsPtr->getInB(iSys);
332 if (iIn == 0 || event[iIn].status() != -34)
continue;
333 int iOut =
event[iIn].mother1();
336 int dipEndSize = dipEnd.size();
337 for (
int iDip = 0; iDip < dipEndSize; ++iDip) {
338 TimeDipoleEnd& dipNow = dipEnd[iDip];
341 if (dipNow.iRadiator == iOut) {
348 if (dipNow.iMEpartner == iOut) {
350 dipNow.iMEpartner = -1;
354 if (dipNow.iRecoiler == iOut) {
355 int iRad = dipNow.iRadiator;
358 if (dipNow.colType > 0) {
359 int colTag =
event[iRad].col();
361 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
362 int iRecNow = partonSystemsPtr->getOut( iSys, i);
363 if (event[iRecNow].acol() == colTag) {
364 dipNow.iRecoiler = iRecNow;
365 dipNow.systemRec = iSys;
372 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
373 : partonSystemsPtr->getInA(iSys);
374 if (event[iIn2].col() == colTag) {
375 dipNow.iRecoiler = iIn2;
376 dipNow.systemRec = iSys;
378 int isrType =
event[iIn2].mother1();
380 while (isrType > 2 + beamOffset)
381 isrType =
event[isrType].mother1();
382 if (isrType > 2) isrType -= beamOffset;
383 dipNow.isrType = isrType;
389 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
391 setupQCDdip(dipNow.system, iRadNow, event[iRad].col(), 1,
392 event, dipNow.isOctetOnium,
true);
394 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
395 "failed to locate radiator in system");
401 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
402 "failed to locate new recoiling colour partner");
406 }
else if (dipNow.colType < 0) {
407 int acolTag =
event[iRad].acol();
409 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
410 int iRecNow = partonSystemsPtr->getOut( iSys, i);
411 if (event[iRecNow].col() == acolTag) {
412 dipNow.iRecoiler = iRecNow;
413 dipNow.systemRec = iSys;
420 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
421 : partonSystemsPtr->getInA(iSys);
422 if (event[iIn2].acol() == acolTag) {
423 dipNow.iRecoiler = iIn2;
424 dipNow.systemRec = iSys;
426 int isrType =
event[iIn2].mother1();
428 while (isrType > 2 + beamOffset)
429 isrType =
event[isrType].mother1();
430 if (isrType > 2) isrType -= beamOffset;
431 dipNow.isrType = isrType;
437 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
439 setupQCDdip(dipNow.system, iRadNow, event[iRad].acol(), -1,
440 event, dipNow.isOctetOnium,
true);
442 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
443 "failed to locate radiator in system");
449 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
450 "failed to locate new recoiling colour partner");
454 }
else if (dipNow.chgType != 0 || dipNow.gamType != 0) {
455 int idTag =
event[dipNow.iRecoiler].id();
457 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
458 int iRecNow = partonSystemsPtr->getOut( iSys, i);
459 if (event[iRecNow].
id() == idTag) {
460 dipNow.iRecoiler = iRecNow;
461 dipNow.systemRec = iSys;
468 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
469 : partonSystemsPtr->getInA(iSys);
470 if (event[iIn2].
id() == -idTag) {
471 dipNow.iRecoiler = iIn2;
472 dipNow.systemRec = iSys;
474 int isrType =
event[iIn2].mother1();
476 while (isrType > 2 + beamOffset)
477 isrType =
event[isrType].mother1();
478 if (isrType > 2) isrType -= beamOffset;
479 dipNow.isrType = isrType;
485 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
487 setupQEDdip(dipNow.system, iRadNow, dipNow.chgType,
488 dipNow.gamType, event,
true);
490 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
491 "failed to locate radiator in system");
497 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
498 "failed to locate new recoiling charge partner");
513 void TimeShower::update(
int iSys,
Event& event) {
516 vector<int> iRescatterer;
519 vector<int> iNew, iOld;
520 iNew.push_back( partonSystemsPtr->getInA(iSys) );
521 iOld.push_back( event[iNew[0]].daughter2() );
522 iNew.push_back( partonSystemsPtr->getInB(iSys) );
523 iOld.push_back( event[iNew[1]].daughter2() );
526 int sizeOut = partonSystemsPtr->sizeOut(iSys) - 1;
527 for (
int i = 0; i < sizeOut; ++i) {
528 int iNow = partonSystemsPtr->getOut(iSys, i);
529 iNew.push_back( iNow );
530 iOld.push_back( event[iNow].mother1() );
532 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
534 int iNewNew = partonSystemsPtr->getOut(iSys, sizeOut);
537 if (event[iNew[0]].status() != -41) {
538 swap( iNew[0], iNew[1]);
539 swap( iOld[0], iOld[1]);
544 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
545 if (dipEnd[iDip].system == iSys || dipEnd[iDip].systemRec == iSys) {
546 TimeDipoleEnd& dipNow = dipEnd[iDip];
549 for (
int i = 2; i < 2 + sizeOut; ++i)
550 if (dipNow.iRadiator == iOld[i]) {
551 dipNow.iRadiator = iNew[i];
556 for (
int i = 2; i < 2 + sizeOut; ++i)
557 if (dipNow.iMEpartner == iOld[i]) {
558 dipNow.iMEpartner = iNew[i];
564 if (dipNow.systemRec == iSys) {
565 for (
int i = 1; i < 2 + sizeOut; ++i)
566 if (dipNow.iRecoiler == iOld[i]) {
572 if ( dipNow.colType > 0
573 && event[dipNow.iRadiator].col() ==
event[iNewNew].acol() ) {
577 if ( dipNow.colType < 0
578 && event[dipNow.iRadiator].acol() ==
event[iNewNew].col() ) {
584 if ( iRec == 0 && dipNow.colType > 0
585 && event[dipNow.iRadiator].col() ==
event[iNew[0]].col() )
587 if ( iRec == 0 && dipNow.colType < 0
588 && event[dipNow.iRadiator].acol() ==
event[iNew[0]].acol() )
592 if ( iRec == 0 && (dipNow.chgType != 0 || dipNow.gamType != 0) ) {
593 if ( event[iNew[0]].chargeType() == 0 ) {
602 }
else iRec = dipNow.iRecoiler;
605 dipNow.iRecoiler = iRec;
606 if ( iRec == 0 && (dipNow.colType != 0 || dipNow.chgType != 0
607 || dipNow.gamType != 0) ) {
611 infoPtr->errorMsg(
"Error in TimeShower::update: "
612 "failed to locate new recoiling partner");
617 int colTag =
event[iNewNew].col();
618 if (doQCDshower && colTag > 0)
619 setupQCDdip( iSys, sizeOut, colTag, 1, event,
false,
true);
622 int acolTag =
event[iNewNew].acol();
623 if (doQCDshower && acolTag > 0)
624 setupQCDdip( iSys, sizeOut, acolTag, -1, event,
false,
true);
627 int chgType =
event[iNewNew].chargeType();
628 bool doChgDip = (chgType != 0)
629 && ( ( doQEDshowerByQ && event[iNewNew].isQuark() )
630 || ( doQEDshowerByL &&
event[iNewNew].isLepton() ) );
631 int gamType = (
event[iNewNew].id() == 22) ? 1 : 0;
632 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
633 if (doChgDip || doGamDip)
634 setupQEDdip( iSys, sizeOut, chgType, gamType, event,
true);
638 while (++iRescNow <
int(iRescatterer.size())) {
641 int iOutNew = iRescatterer[iRescNow];
642 int iInNew =
event[iOutNew].daughter1();
643 int iSysResc = partonSystemsPtr->getSystemOf(iInNew,
true);
648 iNew.push_back( partonSystemsPtr->getInA(iSysResc) );
649 iOld.push_back( event[iNew[0]].daughter1() );
650 iNew.push_back( partonSystemsPtr->getInB(iSysResc) );
651 iOld.push_back( event[iNew[1]].daughter1() );
654 sizeOut = partonSystemsPtr->sizeOut(iSysResc);
655 for (
int i = 0; i < sizeOut; ++i) {
656 int iNow = partonSystemsPtr->getOut(iSysResc, i);
657 iNew.push_back( iNow );
658 iOld.push_back( event[iNow].mother1() );
660 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
665 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
666 if (dipEnd[iDip].system == iSysResc
667 || dipEnd[iDip].systemRec == iSysResc) {
668 TimeDipoleEnd& dipNow = dipEnd[iDip];
671 for (
int i = 2; i < 2 + sizeOut; ++i)
672 if (dipNow.iRadiator == iOld[i]) {
673 dipNow.iRadiator = iNew[i];
678 for (
int i = 2; i < 2 + sizeOut; ++i)
679 if (dipNow.iMEpartner == iOld[i]) {
680 dipNow.iMEpartner = iNew[i];
685 for (
int i = 0; i < 2 + sizeOut; ++i)
686 if (dipNow.iRecoiler == iOld[i]) {
687 dipNow.iRecoiler = iNew[i];
701 void TimeShower::setupQCDdip(
int iSys,
int i,
int colTag,
int colSign,
702 Event& event,
bool isOctetOnium,
bool limitPTmaxIn) {
705 int iRad = partonSystemsPtr->getOut(iSys, i);
707 int sizeAllA = partonSystemsPtr->sizeAll(iSys);
708 int sizeOut = partonSystemsPtr->sizeOut(iSys);
709 int sizeAll = ( allowBeamRecoil ) ? sizeAllA : sizeOut;
710 int sizeIn = sizeAll - sizeOut;
711 int sizeInA = sizeAllA - sizeIn - sizeOut;
712 int iOffset = i + sizeAllA - sizeOut;
713 bool otherSystemRec =
false;
714 bool allowInitial = (partonSystemsPtr->hasInAB(iSys)) ?
true :
false;
717 bool isFlexible =
false;
718 double flexFactor = 1.0;
719 vector<int> iRecVec(0);
724 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
725 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
726 if ( ( j < sizeIn && event[iRecNow].col() == colTag
727 && !event[iRecNow].isRescatteredIncoming() )
728 || ( j >= sizeIn && event[iRecNow].acol() == colTag
729 && event[iRecNow].isFinal() ) ) {
738 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
739 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
740 if ( ( j < sizeIn && event[iRecNow].acol() == colTag
741 && !event[iRecNow].isRescatteredIncoming() )
742 || ( j >= sizeIn && event[iRecNow].col() == colTag
743 && event[iRecNow].isFinal() ) ) {
753 bool hasJunction =
false;
754 if (iRec == 0 && !allowInitial) {
755 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
759 int iBeg = (
event.kindJunction(iJun)-1)/2;
760 for (
int iLeg = iBeg; iLeg < 3; ++iLeg)
761 if (event.endColJunction( iJun, iLeg) == colTag) hasJunction =
true;
763 double ppMin = LARGEM2;
764 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
765 int iRecNow = partonSystemsPtr->getOut(iSys, j);
766 if (!event[iRecNow].isFinal())
continue;
767 double ppNow =
event[iRecNow].p() *
event[iRad].p()
768 -
event[iRecNow].m() *
event[iRad].m();
777 if ( iRec == 0 || (!doInterleave && !event[iRec].isFinal()) ) {
779 for (
int j = 0; j <
event.size(); ++j)
if (event[j].isFinal())
780 if ( (colSign > 0 && event[j].acol() == colTag)
781 || (colSign < 0 &&
event[j].col() == colTag) ) {
783 otherSystemRec =
true;
788 if (iRec == 0 && allowInitial) {
789 for (
int iSysR = 0; iSysR < partonSystemsPtr->sizeSys(); ++iSysR)
791 int j = partonSystemsPtr->getInA(iSysR);
792 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
793 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
794 || (colSign < 0 && event[j].acol() == colTag) ) ) {
796 otherSystemRec =
true;
799 j = partonSystemsPtr->getInB(iSysR);
800 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
801 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
802 || (colSign < 0 && event[j].acol() == colTag) ) ) {
804 otherSystemRec =
true;
820 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
821 int kindJun =
event.kindJunction(iJun);
822 int iBeg = (kindJun-1)/2;
823 for (
int iLeg = iBeg; iLeg < 3; ++iLeg) {
824 if (event.endColJunction( iJun, iLeg) == colTag) {
832 if (sizeOut == 1)
return;
837 else if (kindJun >= 3) {
838 int iLegRec = 3-iLeg;
839 int colTagRec =
event.endColJunction( iJun, iLegRec);
840 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
841 int iRecNow = partonSystemsPtr->getOut(iSys, j);
842 if (!event[iRecNow].isFinal())
continue;
843 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
844 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
855 for (
int jLeg = 1; jLeg <= 2; jLeg++) {
856 int iLegRec = (iLeg + jLeg) % 3;
857 int colTagRec =
event.endColJunction( iJun, iLegRec);
858 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
859 int iRecNow = partonSystemsPtr->getOut(iSys, j);
860 if (!event[iRecNow].isFinal())
continue;
861 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
862 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
864 iRecVec.push_back(iRecNow);
882 double ppMin = LARGEM2;
883 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
884 int iRecNow = partonSystemsPtr->getOut(iSys, j);
885 if (!event[iRecNow].isFinal())
continue;
886 double ppNow =
event[iRecNow].p() *
event[iRad].p()
887 -
event[iRecNow].m() *
event[iRad].m();
898 double ppMin = LARGEM2;
899 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
900 if (iRecNow != iRad && event[iRecNow].isFinal()) {
901 double ppNow =
event[iRecNow].p() *
event[iRad].p()
902 -
event[iRecNow].m() *
event[iRad].m();
905 otherSystemRec =
true;
912 if (iRecVec.size() == 0 && iRec != 0) iRecVec.push_back(iRec);
915 int nRec = iRecVec.size();
916 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec)
917 if (iRecVec[mRec] <= 0) nRec--;
920 flexFactor = 1.0/nRec;
925 infoPtr->errorMsg(
"Error in TimeShower::setupQCDdip: "
926 "failed to locate any recoiling partner");
931 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec) {
932 iRec = iRecVec[mRec];
933 if (iRec <= 0)
continue;
935 double pTmax =
event[iRad].scale();
937 if (iSys == 0) pTmax *= pTmaxFudge;
938 if (iSys > 0 && sizeIn > 0) pTmax *= pTmaxFudgeMPI;
939 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
940 int colType = (
event[iRad].id() == 21) ? 2 * colSign : colSign;
941 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
943 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
944 if (isrType > 2) isrType -= beamOffset;
945 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax,
946 colType, 0, 0, isrType, iSys, -1, -1, isOctetOnium) );
949 if (otherSystemRec) {
950 int systemRec = partonSystemsPtr->getSystemOf(iRec,
true);
951 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
952 dipEnd.back().MEtype = 0;
958 dipEnd.back().isFlexible =
true;
959 dipEnd.back().flexFactor = flexFactor;
970 void TimeShower::setupQEDdip(
int iSys,
int i,
int chgType,
int gamType,
971 Event& event,
bool limitPTmaxIn) {
974 int iRad = partonSystemsPtr->getOut(iSys, i);
975 int idRad =
event[iRad].id();
977 int sizeAllA = partonSystemsPtr->sizeAll(iSys);
978 int sizeOut = partonSystemsPtr->sizeOut(iSys);
979 int sizeAll = ( allowBeamRecoil ) ? sizeAllA : sizeOut;
980 int sizeIn = sizeAll - sizeOut;
981 int sizeInA = sizeAllA - sizeIn - sizeOut;
982 int iOffset = i + sizeAllA - sizeOut;
983 double ppMin = LARGEM2;
984 bool hasRescattered =
false;
985 bool otherSystemRec =
false;
991 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
992 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
993 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
994 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
995 if ( (j < sizeIn && event[iRecNow].
id() == idRad)
996 || (j >= sizeIn && event[iRecNow].
id() == -idRad) ) {
997 double ppNow =
event[iRecNow].p() *
event[iRad].p()
998 -
event[iRecNow].m() *
event[iRad].m();
1004 }
else hasRescattered =
true;
1009 if (iRec == 0 && hasRescattered) {
1010 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1011 if (event[iRecNow].
id() == -idRad &&
event[iRecNow].isFinal()) {
1012 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1013 -
event[iRecNow].m() *
event[iRad].m();
1014 if (ppNow < ppMin) {
1017 otherSystemRec =
true;
1025 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1026 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1027 int chgTypeRecNow =
event[iRecNow].chargeType();
1028 if (chgTypeRecNow == 0)
continue;
1029 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
1030 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
1031 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1032 -
event[iRecNow].m() *
event[iRad].m())
1033 / pow2(chgTypeRecNow);
1034 if (ppNow < ppMin) {
1043 if (iRec == 0 && hasRescattered) {
1044 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1045 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1046 int chgTypeRecNow =
event[iRecNow].chargeType();
1047 if (chgTypeRecNow != 0 && event[iRecNow].isFinal()) {
1048 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1049 -
event[iRecNow].m() *
event[iRad].m())
1050 / pow2(chgTypeRecNow);
1051 if (ppNow < ppMin) {
1054 otherSystemRec =
true;
1062 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1063 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1064 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1065 -
event[iRecNow].m() *
event[iRad].m();
1066 if (ppNow < ppMin) {
1074 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1075 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1076 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1077 -
event[iRecNow].m() *
event[iRad].m();
1078 if (ppNow < ppMin) {
1081 otherSystemRec =
true;
1088 double pTmax =
event[iRad].scale();
1090 if (iSys == 0) pTmax *= pTmaxFudge;
1091 if (iSys > 0 && sizeIn > 0) pTmax *= pTmaxFudgeMPI;
1092 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1093 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1095 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1096 if (isrType > 2) isrType -= beamOffset;
1097 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1098 0, chgType, gamType, isrType, iSys, -1) );
1101 if (otherSystemRec) {
1102 int systemRec = partonSystemsPtr->getSystemOf(iRec);
1103 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1104 dipEnd.back().MEtype = 0;
1109 infoPtr->errorMsg(
"Error in TimeShower::setupQEDdip: "
1110 "failed to locate any recoiling partner");
1119 void TimeShower::setupHVdip(
int iSys,
int i,
Event& event,
1120 bool limitPTmaxIn) {
1123 int iRad = partonSystemsPtr->getOut(iSys, i);
1125 int idRad =
event[iRad].id();
1126 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1130 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1131 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1132 int idRec =
event[iRecNow].id();
1133 if ( (abs(idRec) > 4900000 && abs(idRec) < 4900017)
1134 && idRad * idRec < 0) {
1142 double mMax = -sqrt(LARGEM2);
1144 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1145 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1146 if (event[iRecNow].m() > mMax) {
1148 mMax =
event[iRecNow].m();
1155 double pTmax =
event[iRad].scale();
1157 if (iSys == 0) pTmax *= pTmaxFudge;
1158 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1159 int colvType = (
event[iRad].id() > 0) ? 1 : -1;
1160 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax, 0, 0, 0, 0,
1161 iSys, -1, -1,
false,
true, colvType) );
1162 }
else infoPtr->errorMsg(
"Error in TimeShower::setupHVdip: "
1163 "failed to locate any recoiling partner");
1171 double TimeShower::pTnext(
Event& event,
double pTbegAll,
double pTendAll) {
1176 double pT2sel = pTendAll * pTendAll;
1177 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
1178 TimeDipoleEnd& dip = dipEnd[iDip];
1181 useLocalRecoilNow = !(globalRecoil && dip.system == 0
1182 && partonSystemsPtr->sizeOut(0) <= nMaxGlobalRecoil);
1185 dip.mRad =
event[dip.iRadiator].m();
1186 if (useLocalRecoilNow) {
1187 dip.mRec =
event[dip.iRecoiler].m();
1188 dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
1193 for (
int i = 0; i < partonSystemsPtr->sizeOut( dip.system); ++i) {
1194 int ii = partonSystemsPtr->getOut( dip.system, i);
1195 if (ii != dip.iRadiator) pSumGlobal +=
event[ii].p();
1197 dip.mRec = pSumGlobal.mCalc();
1198 dip.mDip = m( event[dip.iRadiator].p(), pSumGlobal);
1200 dip.m2Rad = pow2(dip.mRad);
1201 dip.m2Rec = pow2(dip.mRec);
1202 dip.m2Dip = pow2(dip.mDip);
1205 dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
1206 double pTbegDip = min( pTbegAll, dip.pTmax );
1207 double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
1211 if (pT2begDip > pT2sel) {
1212 if (dip.colType != 0)
1213 pT2nextQCD(pT2begDip, pT2sel, dip, event);
1214 else if (dip.chgType != 0 || dip.gamType != 0)
1215 pT2nextQED(pT2begDip, pT2sel, dip, event);
1216 else if (dip.colvType != 0)
1217 pT2nextHV(pT2begDip, pT2sel, dip, event);
1220 if (dip.pT2 > pT2sel) {
1229 return (dipSel == 0) ? 0. : sqrt(pT2sel);
1237 void TimeShower::pT2nextQCD(
double pT2begDip,
double pT2sel,
1238 TimeDipoleEnd& dip,
Event& event) {
1241 double pT2endDip = max( pT2sel, pT2colCut );
1242 if (pT2begDip < pT2endDip)
return;
1247 int colTypeAbs = abs(dip.colType);
1248 double wtPSglue = 2.;
1249 double colFac = (colTypeAbs == 1) ? 4./3. : 3./2.;
1250 if (dip.MEgluinoRec) colFac = 3.;
1251 if (dip.isOctetOnium) colFac *= 0.5 * octetOniumColFac;
1254 if (dip.isFlexible) colFac *= dip.flexFactor;
1255 double wtPSqqbar = (colTypeAbs == 2) ? 0.25 * nGluonToQuark : 0.;
1258 dip.pT2 = pT2begDip;
1260 double zMinAbs = 0.5;
1261 double pT2min = pT2endDip;
1263 double Lambda2 = Lambda3flav2;
1264 double emitCoefGlue = 0.;
1265 double emitCoefQqbar = 0.;
1266 double emitCoefTot = 0.;
1268 bool mustFindRange =
true;
1275 if (mustFindRange) {
1278 if (dip.pT2 > m2b) {
1280 pT2min = max( m2b, pT2endDip);
1282 Lambda2 = Lambda5flav2;
1283 }
else if (dip.pT2 > m2c) {
1285 pT2min = max( m2c, pT2endDip);
1287 Lambda2 = Lambda4flav2;
1292 Lambda2 = Lambda3flav2;
1294 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2min / dip.m2DipCorr );
1295 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2min / dip.m2DipCorr;
1298 emitCoefGlue = wtPSglue * colFac * log(1. / zMinAbs - 1.);
1299 emitCoefTot = emitCoefGlue;
1300 if (colTypeAbs == 2 && event[dip.iRadiator].id() == 21) {
1301 emitCoefQqbar = wtPSqqbar * (1. - 2. * zMinAbs);
1302 emitCoefTot += emitCoefQqbar;
1306 mustFindRange =
false;
1310 if (alphaSorder == 0) {
1311 dip.pT2 = dip.pT2 * pow( rndmPtr->flat(),
1312 1. / (alphaS2pi * emitCoefTot) );
1315 }
else if (alphaSorder == 1) {
1316 dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
1317 pow( rndmPtr->flat(), b0 / emitCoefTot) );
1321 do dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
1322 pow( rndmPtr->flat(), b0 / emitCoefTot) );
1323 while (alphaS.alphaS2OrdCorr(dip.pT2) < rndmPtr->flat()
1324 && dip.pT2 > pT2min);
1329 if (nFlavour == 5 && dip.pT2 < m2b) {
1330 mustFindRange =
true;
1332 }
else if ( nFlavour == 4 && dip.pT2 < m2c) {
1333 mustFindRange =
true;
1338 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
1343 if (colTypeAbs == 2 && emitCoefQqbar > rndmPtr->flat()
1344 * emitCoefTot) dip.flavour = 0;
1347 if (dip.flavour == 21) {
1348 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
1350 dip.z = zMinAbs + (1. - 2. * zMinAbs) * rndmPtr->flat();
1354 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
1355 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
1356 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
1357 if (dip.z > zMin && dip.z < 1. - zMin
1358 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
1359 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
1362 if (dip.flavour == 0) {
1363 dip.flavour = min(5, 1 +
int(nGluonToQuark * rndmPtr->flat()));
1364 dip.mFlavour = particleDataPtr->m0(dip.flavour);
1368 if (dip.MEtype > 0) {
1370 if (dip.flavour < 10 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
1374 }
else if (dip.flavour == 21
1375 && (colTypeAbs == 1 || colTypeAbs == 3) ) {
1376 wt = (1. + pow2(dip.z)) / wtPSglue;
1377 }
else if (dip.flavour == 21) {
1378 wt = (1. + pow3(dip.z)) / wtPSglue;
1382 double beta = sqrtpos( 1. - 4. * pow2(dip.mFlavour) / dip.m2 );
1383 wt = beta * ( pow2(dip.z) + pow2(1. - dip.z) );
1387 if (dip.isrType != 0 && useLocalRecoilNow) {
1388 BeamParticle&
beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
1389 int iSysRec = dip.systemRec;
1390 double xOld = beam[iSysRec].x();
1391 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
1392 (dip.m2Dip - dip.m2Rad));
1393 double xMaxAbs = beam.xMax(iSysRec);
1395 infoPtr->errorMsg(
"Warning in TimeShower::pT2nextQCD: "
1396 "xMaxAbs negative");
1401 if (xNew > xMaxAbs) wt = 0.;
1403 int idRec =
event[dip.iRecoiler].id();
1404 double pdfOld = max ( TINYPDF,
1405 beam.xfISR( iSysRec, idRec, xOld, dip.pT2) );
1406 double pdfNew = beam.xfISR( iSysRec, idRec, xNew, dip.pT2);
1407 wt *= min( 1., pdfNew / pdfOld);
1411 if (dampenBeamRecoil) {
1412 double pTpT = sqrt(event[dip.iRadiator].pT2() * dip.pT2);
1413 wt *= pTpT / (pTpT + dip.m2);
1420 }
while (wt < rndmPtr->flat());
1428 void TimeShower::pT2nextQED(
double pT2begDip,
double pT2sel,
1429 TimeDipoleEnd& dip,
Event& event) {
1432 double pT2chgCut = (dip.chgType != 0 && abs(dip.chgType) != 3)
1433 ? pT2chgQCut : pT2chgLCut;
1434 double pT2endDip = max( pT2sel, pT2chgCut );
1435 if (pT2begDip < pT2endDip)
return;
1438 bool hasCharge = (dip.chgType != 0);
1441 double wtPSgam = 0.;
1442 double chg2Sum = 0.;
1443 double chg2SumL = 0.;
1444 double chg2SumQ = 0.;
1445 double zMinAbs = 0.;
1446 double emitCoefTot = 0.;
1449 double alphaEMmax = alphaEM.alphaEM(pT2begDip);
1450 double alphaEM2pi = alphaEMmax / (2. * M_PI);
1455 double chg2 = pow2(dip.chgType / 3.);
1458 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
1459 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
1460 emitCoefTot = alphaEM2pi * chg2 * wtPSgam * log(1. / zMinAbs - 1.);
1464 chg2SumL = max(0, min(3, nGammaToLepton));
1465 if (nGammaToQuark > 4) chg2SumQ = 11. / 9.;
1466 else if (nGammaToQuark > 3) chg2SumQ = 10. / 9.;
1467 else if (nGammaToQuark > 2) chg2SumQ = 6. / 9.;
1468 else if (nGammaToQuark > 1) chg2SumQ = 5. / 9.;
1469 else if (nGammaToQuark > 0) chg2SumQ = 1. / 9.;
1472 chg2Sum = chg2SumL + 3. * chg2SumQ;
1473 emitCoefTot = alphaEM2pi * chg2Sum;
1477 dip.pT2 = pT2begDip;
1484 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
1488 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
1491 if (hasCharge) dip.z = 1. - zMinAbs
1492 * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
1493 else dip.z = rndmPtr->flat();
1496 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
1497 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
1498 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
1499 if (dip.z > zMin && dip.z < 1. - zMin
1500 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
1501 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec)
1503 && (hasCharge || dip.m2 < m2MaxGamma) ) {
1512 if (rndmPtr->flat() * chg2Sum < chg2SumL)
1513 dip.flavour = 9 + 2 * min(3, 1 +
int(chg2SumL * rndmPtr->flat()));
1515 double rndmQ = 9. * chg2SumQ * rndmPtr->flat();
1516 if (rndmQ < 1.) dip.flavour = 1;
1517 else if (rndmQ < 5.) dip.flavour = 2;
1518 else if (rndmQ < 6.) dip.flavour = 3;
1519 else if (rndmQ < 10.) dip.flavour = 4;
1520 else dip.flavour = 5;
1522 dip.mFlavour = particleDataPtr->m0(dip.flavour);
1527 if (dip.MEtype > 0) {
1529 if (dip.flavour < 20 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
1533 }
else if (hasCharge) {
1534 wt = (1. + pow2(dip.z)) / wtPSgam;
1538 double beta = sqrtpos( 1. - 4. * pow2(dip.mFlavour) / dip.m2 );
1539 wt = beta * ( pow2(dip.z) + pow2(1. - dip.z) );
1543 double alphaEMnow = alphaEM.alphaEM(dip.pT2);
1544 wt *= (alphaEMnow / alphaEMmax);
1547 if (dip.isrType != 0 && useLocalRecoilNow) {
1548 BeamParticle& beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
1549 int iSys = dip.system;
1550 double xOld = beam[iSys].x();
1551 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
1552 (dip.m2Dip - dip.m2Rad));
1553 double xMaxAbs = beam.xMax(iSys);
1555 infoPtr->errorMsg(
"Warning in TimeShower::pT2nextQED: "
1556 "xMaxAbs negative");
1561 if (xNew > xMaxAbs) wt = 0.;
1563 int idRec =
event[dip.iRecoiler].id();
1564 double pdfOld = max ( TINYPDF,
1565 beam.xfISR( iSys, idRec, xOld, dip.pT2) );
1566 double pdfNew = beam.xfISR( iSys, idRec, xNew, dip.pT2);
1567 wt *= min( 1., pdfNew / pdfOld);
1571 if (dampenBeamRecoil) {
1572 double pT24 = 4. *
event[dip.iRadiator].pT2();
1573 wt *= pT24 / (pT24 + dip.m2);
1579 }
while (wt < rndmPtr->flat());
1587 void TimeShower::pT2nextHV(
double pT2begDip,
double pT2sel,
1588 TimeDipoleEnd& dip,
Event& ) {
1591 double pT2endDip = max( pT2sel, pT2hvCut );
1592 if (pT2begDip < pT2endDip)
return;
1595 int colvTypeAbs = abs(dip.colvType);
1596 double colvFac = (colvTypeAbs == 1) ? CFHV : 0.5 * nCHV;
1597 double alphaHV2pi = colvFac * (alphaHVfix / (2. * M_PI));
1600 double zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
1601 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
1602 double emitCoefTot = alphaHV2pi * 2. * log(1. / zMinAbs - 1.);
1605 dip.pT2 = pT2begDip;
1612 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
1616 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
1619 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
1622 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
1623 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
1624 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
1625 if (dip.z > zMin && dip.z < 1. - zMin
1626 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
1627 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
1634 if (dip.MEtype > 0) wt = 1.;
1637 else if (colvTypeAbs == 1) wt = (1. + pow2(dip.z)) / 2.;
1638 else wt = (1. + pow3(dip.z)) / 2.;
1642 }
while (wt < rndmPtr->flat());
1653 bool TimeShower::branch(
Event& event,
bool isInterleaved) {
1656 useLocalRecoilNow = !(globalRecoil && dipSel->system == 0
1657 && partonSystemsPtr->sizeOut(0) <= nMaxGlobalRecoil);
1660 int iRadBef = dipSel->iRadiator;
1661 int iRecBef = dipSel->iRecoiler;
1662 Particle& radBef =
event[iRadBef];
1663 Particle& recBef =
event[iRecBef];
1666 Vec4 pRadBef =
event[iRadBef].p();
1668 vector<int> iGRecBef, iGRec;
1669 if (useLocalRecoilNow) pRecBef =
event[iRecBef].p();
1671 for (
int i = 0; i < partonSystemsPtr->sizeOut( dipSel->system); ++i) {
1672 int iG = partonSystemsPtr->getOut( dipSel->system, i);
1673 if (iG != dipSel->iRadiator) {
1674 iGRecBef.push_back(iG);
1675 pRecBef +=
event[iG].p();
1681 int idRad = radBef.id();
1682 int idEmt = dipSel->flavour;
1683 int colRad = radBef.col();
1684 int acolRad = radBef.acol();
1687 iSysSel = dipSel->system;
1688 int iSysSelRec = dipSel->systemRec;
1691 if (dipSel->flavour == 22 || dipSel->flavour == idHV) {
1693 }
else if (dipSel->flavour == 21 && dipSel->colType > 0) {
1695 colRad =
event.nextColTag();
1697 }
else if (dipSel->flavour == 21) {
1699 acolRad =
event.nextColTag();
1702 }
else if (dipSel->colType > 0) {
1703 idEmt = dipSel->flavour ;
1707 }
else if (dipSel->colType < 0) {
1708 idEmt = -dipSel->flavour ;
1713 }
else if (dipSel->gamType == 1 && rndmPtr->flat() > 0.5) {
1714 idEmt = -dipSel->flavour ;
1716 if (idRad < 10) colRad =
event.nextColTag();
1718 }
else if (dipSel->gamType == 1) {
1719 idEmt = dipSel->flavour ;
1721 if (idEmt < 10) colEmt =
event.nextColTag();
1727 double pTorig = sqrt( dipSel->pT2);
1728 double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
1730 double e2RadPlusEmt = pow2(eRadPlusEmt);
1731 double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
1732 - dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
1733 double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z * (1. - dipSel->z)
1734 - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
1735 double pTcorr = sqrtpos( pT2corr );
1736 double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
1738 double pzEmt = (e2RadPlusEmt * (1. - dipSel->z) - 0.5 * dipSel->m2)
1740 double mRad = dipSel->mRad;
1744 if ( abs(dipSel->colvType) == 1 && dipSel->mFlavour > 0.) {
1745 mEmt = dipSel->mFlavour;
1746 if (pow2(mRad + mEmt) > dipSel->m2)
return false;
1747 double m2Emt = pow2(mEmt);
1748 double lambda = sqrtpos( pow2(dipSel->m2 - dipSel->m2Rad - m2Emt)
1749 - 4. * dipSel->m2Rad * m2Emt );
1750 kRad = 0.5 * (dipSel->m2 - lambda + m2Emt - dipSel->m2Rad)
1752 kEmt = 0.5 * (dipSel->m2 - lambda + dipSel->m2Rad - m2Emt)
1754 pTorig *= 1. - kRad - kEmt;
1755 pTcorr *= 1. - kRad - kEmt;
1756 double pzMove = kRad * pzRad - kEmt * pzEmt;
1761 }
else if (abs(dipSel->colType) == 1 || dipSel->chgType != 0
1762 || abs(dipSel->colvType) == 1) {
1763 pTorig *= 1. - dipSel->m2Rad / dipSel->m2;
1764 pTcorr *= 1. - dipSel->m2Rad / dipSel->m2;
1765 pzRad += pzEmt * dipSel->m2Rad / dipSel->m2;
1766 pzEmt *= 1. - dipSel->m2Rad / dipSel->m2;
1769 }
else if (abs(dipSel->flavour) < 20) {
1770 mEmt = dipSel->mFlavour;
1772 double beta = sqrtpos( 1. - 4. * pow2(mEmt) / dipSel->m2 );
1775 pzRad = 0.5 * ( (1. + beta) * pzRad + (1. - beta) * pzEmt );
1776 pzEmt = pzRadPlusEmt - pzRad;
1780 if (idEmt == 21 && pTorig < pTcolCut)
return false;
1784 M.fromCMframe(pRadBef, pRecBef);
1787 findAsymPol( event, dipSel);
1790 Vec4 pRad, pEmt, pRec;
1793 double phi = 2. * M_PI * rndmPtr->flat();
1796 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
1797 sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
1798 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
1799 sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
1800 pRec = Vec4( 0., 0., -pzRadPlusEmt, sqrt( pow2(pzRadPlusEmt)
1801 + dipSel->m2Rec ) );
1809 if (dipSel->asymPol != 0.) {
1810 Vec4 pAunt =
event[dipSel->iAunt].p();
1811 double cosPhi = cosphi( pRad, pAunt, pRadBef );
1812 wtPhi = ( 1. + dipSel->asymPol * (2. * pow2(cosPhi) - 1.) )
1813 / ( 1. + abs(dipSel->asymPol) );
1815 }
while (wtPhi < rndmPtr->flat()) ;
1818 int isrTypeNow = dipSel->isrType;
1819 int isrTypeSave = isrTypeNow;
1820 if (!useLocalRecoilNow) isrTypeNow = 0;
1821 if (isrTypeNow != 0) pRec = 2. * recBef.p() - pRec;
1824 bool isFlexible = dipSel->isFlexible;
1827 double pTsel = sqrt(dipSel->pT2);
1828 Particle rad = Particle(idRad, 51, iRadBef, 0, 0, 0,
1829 colRad, acolRad, pRad, mRad, pTsel);
1830 Particle emt = Particle(idEmt, 51, iRadBef, 0, 0, 0,
1831 colEmt, acolEmt, pEmt, mEmt, pTsel);
1834 Particle rec = (isrTypeNow == 0)
1835 ? Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
1836 recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel)
1837 : Particle(recBef.id(), -53, 0, 0, iRecBef, iRecBef,
1838 recBef.col(), recBef.acol(), pRec, 0., 0.);
1841 if (dipSel->MEtype > 0) {
1842 Particle& partner = (dipSel->iMEpartner == iRecBef)
1843 ? rec : event[dipSel->iMEpartner];
1844 if ( findMEcorr( dipSel, rad, partner, emt) < rndmPtr->flat() )
1851 if (allowRescatter && FIXRESCATTER && isInterleaved
1852 && iSysSel != iSysSelRec) {
1853 Vec4 pNew = rad.p() + emt.p();
1854 if (!rescatterPropagateRecoil(event, pNew))
return false;
1858 int eventSizeOld =
event.size();
1859 int iRadStatusV =
event[iRadBef].status();
1860 int iRadDau1V =
event[iRadBef].daughter1();
1861 int iRadDau2V =
event[iRadBef].daughter2();
1862 int iRecStatusV =
event[iRecBef].status();
1863 int iRecMot1V =
event[iRecBef].mother1();
1864 int iRecMot2V =
event[iRecBef].mother2();
1865 int iRecDau1V =
event[iRecBef].daughter1();
1866 int iRecDau2V =
event[iRecBef].daughter2();
1867 int beamOff1 = 1 + beamOffset;
1868 int beamOff2 = 2 + beamOffset;
1869 int ev1Dau1V =
event[beamOff1].daughter1();
1870 int ev2Dau1V =
event[beamOff2].daughter1();
1873 if (radBef.hasVertex()) {
1874 rad.vProd( radBef.vProd() );
1875 emt.vProd( radBef.vProd() );
1877 if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
1881 int iRad =
event.append(rad);
1882 int iEmt =
event.append(emt);
1883 event[iRadBef].statusNeg();
1884 event[iRadBef].daughters( iRad, iEmt);
1886 if (useLocalRecoilNow) {
1887 iRec =
event.append(rec);
1888 if (isrTypeNow == 0) {
1889 event[iRecBef].statusNeg();
1890 event[iRecBef].daughters( iRec, iRec);
1892 event[iRecBef].mothers( iRec, iRec);
1893 event[iRec].mothers( iRecMot1V, iRecMot2V);
1894 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( iRec);
1895 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( iRec);
1901 RotBstMatrix MG = M;
1903 double pzRecBef = -0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2Rad
1904 - dipSel->m2Rec) - 4. * dipSel->m2Rad * dipSel->m2Rec ) / dipSel->mDip;
1905 double eRecBef = sqrt( pow2(pzRecBef) + dipSel->m2Rec);
1906 double pzRecAft = -pzRadPlusEmt;
1907 double eRecAft = sqrt( pow2(pzRecAft) + dipSel->m2Rec);
1908 MG.bst( Vec4(0., 0., pzRecBef, eRecBef), Vec4(0., 0., pzRecAft, eRecAft) );
1912 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
1913 iRec =
event.copy( iGRecBef[iG], 52);
1914 iGRec.push_back( iRec);
1915 Vec4 pGRec =
event[iRec].p();
1917 event[iRec].p( pGRec);
1922 bool inResonance = (partonSystemsPtr->getInA(iSysSel) == 0) ?
true :
false;
1923 if ( canVetoEmission && userHooksPtr->doVetoFSREmission( eventSizeOld,
1924 event, iSysSel, inResonance) ) {
1925 event.popBack( event.size() - eventSizeOld);
1926 event[iRadBef].status( iRadStatusV);
1927 event[iRadBef].daughters( iRadDau1V, iRadDau2V);
1928 if (useLocalRecoilNow && isrTypeNow == 0) {
1929 event[iRecBef].status( iRecStatusV);
1930 event[iRecBef].daughters( iRecDau1V, iRecDau2V);
1931 }
else if (useLocalRecoilNow) {
1932 event[iRecBef].mothers( iRecMot1V, iRecMot2V);
1933 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( ev1Dau1V);
1934 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( ev2Dau1V);
1936 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
1937 event[iGRecBef[iG]].statusPos();
1938 event[iGRecBef[iG]].daughters( 0, 0);
1945 if (!useLocalRecoilNow) {
1947 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
1948 if (iGRecBef[iG] == iRecBef) iRec = iGRec[iG];
1952 if (isrTypeNow != 0) {
1953 BeamParticle& beamRec = (isrTypeNow == 1) ? *beamAPtr : *beamBPtr;
1954 double xOld = beamRec[iSysSelRec].x();
1955 double xRec = 2. * pRec.e() / (beamAPtr->e() + beamBPtr->e());
1956 beamRec[iSysSelRec].iPos( iRec);
1957 beamRec[iSysSelRec].x( xRec);
1958 partonSystemsPtr->setSHat( iSysSelRec,
1959 partonSystemsPtr->getSHat(iSysSelRec) * xRec / xOld);
1963 if (dipSel->flavour == 22) {
1964 dipSel->iRadiator = iRad;
1965 dipSel->iRecoiler = iRec;
1968 if (recoilToColoured && inResonance && event[iRec].chargeType() == 0)
1969 dipSel->iRecoiler = iEmt;
1970 dipSel->pTmax = pTsel;
1971 if (doQEDshowerByGamma) dipEnd.push_back( TimeDipoleEnd(iEmt, iRad,
1972 pTsel, 0, 0, 1, 0, iSysSel, 0));
1975 }
else if (dipSel->flavour == 21) {
1976 dipSel->iRadiator = iRad;
1977 dipSel->iRecoiler = iEmt;
1978 dipSel->systemRec = iSysSel;
1979 dipSel->isrType = 0;
1980 dipSel->pTmax = pTsel;
1982 if (!doMEafterFirst) dipSel->MEtype = 0;
1985 double flexFactor = (isFlexible) ? dipSel->flexFactor : 1.0;
1986 dipSel->isFlexible =
false;
1987 for (
int i = 0; i < int(dipEnd.size()); ++i) {
1988 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
1989 && dipEnd[i].colType != 0) {
1990 dipEnd[i].iRadiator = iRec;
1991 dipEnd[i].iRecoiler = iEmt;
1993 if (!doMEafterFirst) dipEnd[i].MEtype = 0;
1995 if ( !isFlexible && dipEnd[i].colType * dipSel->colType > 0)
1996 dipEnd[i].iRecoiler = iRad;
1997 dipEnd[i].pTmax = pTsel;
2003 int colType = (dipSel->colType > 0) ? 2 : -2 ;
2007 if (recoilToColoured && inResonance && event[iRec].col() == 0
2008 &&
event[iRec].acol() == 0) iRecMod = iRad;
2009 dipEnd.push_back( TimeDipoleEnd(iEmt, iRecMod, pTsel,
2010 colType, 0, 0, isrTypeSave, iSysSel, 0));
2011 dipEnd.back().systemRec = iSysSelRec;
2014 dipEnd.back().isFlexible =
true;
2015 dipEnd.back().flexFactor = flexFactor;
2017 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
2018 -colType, 0, 0, 0, iSysSel, 0));
2021 }
else if (dipSel->colType != 0) {
2022 for (
int i = 0; i < int(dipEnd.size()); ++i) {
2024 if ( !isFlexible && dipEnd[i].iRecoiler == iRadBef
2025 && dipEnd[i].colType * dipSel->colType < 0 )
2026 dipEnd[i].iRecoiler = iEmt;
2027 if (dipEnd[i].iRadiator == iRadBef && abs(dipEnd[i].colType) == 2) {
2028 dipEnd[i].colType /= 2;
2029 if (dipEnd[i].system != dipEnd[i].systemRec)
continue;
2033 dipEnd[i].MEtype = 66;
2034 if (&dipEnd[i] == dipSel) dipEnd[i].iMEpartner = iRad;
2035 else dipEnd[i].iMEpartner = iEmt;
2038 dipSel->iRadiator = iEmt;
2039 dipSel->iRecoiler = iRec;
2040 dipSel->pTmax = pTsel;
2045 if (doQEDshowerByQ) {
2046 int chgType =
event[iRad].chargeType();
2047 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
2048 0, chgType, 0, 0, iSysSel, 66, iEmt));
2049 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
2050 0, -chgType, 0, 0, iSysSel, 66, iRad));
2055 }
else if (dipSel->gamType != 0) {
2056 dipSel->gamType = 0;
2057 int chgType =
event[iRad].chargeType();
2058 int colType =
event[iRad].colType();
2060 if ( chgType != 0 && ( ( doQEDshowerByQ && colType != 0 )
2061 || ( doQEDshowerByL && colType == 0 ) ) ) {
2062 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
2063 0, chgType, 0, 0, iSysSel, 102, iEmt));
2064 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
2065 0, -chgType, 0, 0, iSysSel, 102, iRad));
2068 if (colType != 0 && doQCDshower) {
2069 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
2070 colType, 0, 0, 0, iSysSel, 11, iEmt));
2071 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
2072 -colType, 0, 0, 0, iSysSel, 11, iRad));
2076 }
else if (dipSel->flavour == 4900022) {
2077 dipSel->iRadiator = iRad;
2078 dipSel->iRecoiler = iRec;
2079 dipSel->pTmax = pTsel;
2082 }
else if (dipSel->flavour == 4900021) {
2083 dipSel->iRadiator = iRad;
2084 dipSel->iRecoiler = iEmt;
2085 dipSel->pTmax = pTsel;
2086 for (
int i = 0; i < int(dipEnd.size()); ++i)
2087 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
2088 && dipEnd[i].isHiddenValley) {
2089 dipEnd[i].iRadiator = iRec;
2090 dipEnd[i].iRecoiler = iEmt;
2091 dipEnd[i].pTmax = pTsel;
2093 int colvType = (dipSel->colvType > 0) ? 2 : -2 ;
2094 dipEnd.push_back( TimeDipoleEnd(iEmt, iRec, pTsel,
2095 0, 0, 0, isrTypeSave, iSysSel, 0, -1,
false,
true, colvType) );
2096 dipEnd.back().systemRec = iSysSelRec;
2097 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
2098 0, 0, 0, 0, iSysSel, 0, -1,
false,
true, -colvType) );
2102 if (event[iRad].
id() == event[iRadBef].
id()) {
2103 event[iRad].tau( event[iRadBef].tau() );
2105 event[iRad].tau( event[iRad].tau0() * rndmPtr->exp() );
2106 event[iEmt].tau( event[iEmt].tau0() * rndmPtr->exp() );
2108 event[iRec].tau( event[iRecBef].tau() );
2111 for (
int i = 0; i < int(dipEnd.size()); ++i) {
2114 if (isFlexible && !dipSel->isFlexible && dipEnd[i].isFlexible) {
2115 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iEmt;
2116 if (dipEnd[i].iRadiator == iRadBef) {
2117 dipEnd[i].iRadiator = iEmt;
2118 if (dipEnd[i].colType == 1 && dipSel->flavour == 21)
2119 dipEnd[i].colType = 2;
2120 if (dipEnd[i].colType ==-1 && dipSel->flavour == 21)
2121 dipEnd[i].colType =-2;
2124 if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
2125 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
2126 if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
2127 if (useLocalRecoilNow) {
2128 if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
2129 if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
2130 if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
2132 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
2133 if (dipEnd[i].iRadiator == iGRecBef[iG])
2134 dipEnd[i].iRadiator = iGRec[iG];
2135 if (dipEnd[i].iRecoiler == iGRecBef[iG])
2136 dipEnd[i].iRecoiler = iGRec[iG];
2137 if (dipEnd[i].iMEpartner == iGRecBef[iG])
2138 dipEnd[i].iMEpartner = iGRec[iG];
2147 for (
int iJun = 0; iJun <
event.sizeJunction(); iJun++) {
2149 int nIncoming = (
event.kindJunction(iJun)-1)/2;
2153 colChk = (
event.kindJunction(iJun) % 2 == 0 )
2154 ? event[iRadBef].col() :
event[iRadBef].acol();
2156 for (
int iCol = 0; iCol < nIncoming; iCol++) {
2157 int colJun =
event.colJunction( iJun, iCol);
2159 if (colJun == colChk) {
2161 if ( event.kindJunction(iJun) % 2 == 0 ) colNew = colRad;
2162 else colNew = acolRad;
2163 event.colJunction( iJun, iCol, colNew );
2169 partonSystemsPtr->replace(iSysSel, iRadBef, iRad);
2170 partonSystemsPtr->addOut(iSysSel, iEmt);
2171 if (useLocalRecoilNow)
2172 partonSystemsPtr->replace(iSysSelRec, iRecBef, iRec);
2174 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
2175 partonSystemsPtr->replace(iSysSel, iGRecBef[iG], iGRec[iG]);
2197 typedef pair < int, int > pairInt;
2198 typedef vector < pairInt > vectorPairInt;
2217 inline vectorPairInt findParentSystems(
const int sys,
2218 Event& event, PartonSystems* partonSystemsPtr,
bool forwards) {
2220 vectorPairInt parentSystems;
2221 parentSystems.reserve(10);
2226 int iInA = partonSystemsPtr->getInA(iSysCur);
2227 int iInB = partonSystemsPtr->getInB(iSysCur);
2231 if (event[iInA].isRescatteredIncoming()) iIn = iInA;
2232 if (event[iInB].isRescatteredIncoming()) iIn = -iInB;
2235 parentSystems.push_back( pairInt(-iSysCur, iIn) );
2236 if (iIn == 0)
break;
2238 int iInAbs = abs(iIn);
2239 int iMother =
event[iInAbs].mother1();
2240 iSysCur = partonSystemsPtr->getSystemOf(iMother);
2241 if (iSysCur == -1) {
2242 parentSystems.clear();
2250 vectorPairInt::reverse_iterator rit;
2251 for (rit = parentSystems.rbegin(); rit < (parentSystems.rend() - 1);
2253 pairInt &cur = *rit;
2254 pairInt &next = *(rit + 1);
2255 cur.first = -cur.first;
2256 cur.second = (next.second < 0) ? -event[abs(next.second)].mother1() :
2257 event[abs(next.second)].mother1();
2261 return parentSystems;
2272 bool TimeShower::rescatterPropagateRecoil(
Event& event, Vec4& pNew) {
2275 int iRadBef = dipSel->iRadiator;
2276 iSysSel = dipSel->system;
2277 int iSysSelRec = dipSel->systemRec;
2278 Vec4 pImbal = pNew -
event[iRadBef].p();
2282 vector < pair < int, Vec4 > > eventMod;
2283 eventMod.reserve(10);
2288 vectorPairInt systemMod;
2289 systemMod.reserve(10);
2292 vectorPairInt radParent = findParentSystems(iSysSel, event,
2293 partonSystemsPtr,
false);
2294 vectorPairInt recParent = findParentSystems(iSysSelRec, event,
2295 partonSystemsPtr,
true);
2296 if (radParent.size() == 0 || recParent.size() == 0) {
2298 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
2299 "couldn't find parent system; branching vetoed");
2303 bool foundPath =
false;
2304 unsigned int iRadP = 0;
2305 unsigned int iRecP = 0;
2306 for (iRadP = 0; iRadP < radParent.size(); iRadP++) {
2307 for (iRecP = 0; iRecP < recParent.size(); iRecP++)
2308 if (abs(radParent[iRadP].first) == abs(recParent[iRecP].first)) {
2312 if (foundPath)
break;
2317 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2318 "couldn't find recoil path; branching vetoed");
2325 if (radParent.size() > 1)
2326 path.assign(radParent.begin(), radParent.begin() + iRadP);
2327 if (recParent.size() > 1)
2328 path.insert(path.end(), recParent.rend() - iRecP - 1,
2329 recParent.rend() - 1);
2332 for (
unsigned int i = 0; i < path.size(); i++) {
2334 bool isIncoming = (path[i].first < 0) ?
true :
false;
2335 int iSysCur = abs(path[i].first);
2336 bool isIncomingA = (path[i].second > 0) ?
true :
false;
2337 int iLink = abs(path[i].second);
2340 if (isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
2343 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
2344 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
2348 if (iMemCur == -1) {
2350 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
2351 "couldn't find parton system; branching vetoed");
2356 Vec4 pMod = (isIncoming) ? event[iLink].p() + pImbal :
2357 event[iLink].p() - pImbal;
2358 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
2359 systemMod.push_back(pairInt(iSysCur, iMemCur));
2362 int iInCurA = partonSystemsPtr->getInA(iSysCur);
2363 int iInCurB = partonSystemsPtr->getInB(iSysCur);
2364 Vec4 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
2367 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
2368 double sHatCur = pTotCur.m2Calc();
2372 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
2373 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2374 "virtuality much larger than sHat; branching vetoed");
2380 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
2381 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2382 "rest frame energy too negative; branching vetoed");
2387 if (sHatCur < 0.0) {
2388 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2389 "sHat became negative; branching vetoed");
2394 iLink = (isIncoming) ? event[iLink].mother1() :
2395 event[iLink].daughter1();
2396 iSysCur = partonSystemsPtr->getSystemOf(iLink,
true);
2398 if (!isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
2401 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
2402 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
2406 if (iMemCur == -1) {
2408 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
2409 "couldn't find parton system; branching vetoed");
2414 pMod = (isIncoming) ? event[iLink].p() + pImbal :
2415 event[iLink].p() - pImbal;
2416 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
2417 systemMod.push_back(pairInt(iSysCur, iMemCur));
2420 iInCurA = partonSystemsPtr->getInA(iSysCur);
2421 iInCurB = partonSystemsPtr->getInB(iSysCur);
2422 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
2425 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
2426 sHatCur = pTotCur.m2Calc();
2430 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
2431 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2432 "virtuality much larger than sHat; branching vetoed");
2438 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
2439 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2440 "rest frame energy too negative; branching vetoed");
2445 if (sHatCur < 0.0) {
2446 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2447 "sHat became negative; branching vetoed");
2452 if (VETONEGENERGY && pMod.e() < 0.0) {
2453 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
2454 "energy became negative; branching vetoed");
2463 for (
unsigned int i = 0; i < eventMod.size(); i++) {
2464 int idx = eventMod[i].first;
2465 Vec4 &pMod = eventMod[i].second;
2466 int iSys = systemMod[i].first;
2467 int iMem = systemMod[i].second;
2470 if (event[idx].isRescatteredIncoming()) {
2471 int mother1 =
event[idx].mother1();
2472 idx =
event.copy(idx, -54);
2473 event[mother1].daughters(idx, idx);
2476 double eCM = sqrt(m2( beamAPtr->p(), beamBPtr->p()));
2478 partonSystemsPtr->setInA(iSys, idx);
2479 (*beamAPtr)[iSys].x((pMod.e() + pMod.pz()) / eCM);
2480 (*beamAPtr)[iSys].m(pMod.mCalc());
2481 (*beamAPtr)[iSys].p(pMod);
2482 (*beamAPtr)[iSys].iPos(idx);
2483 }
else if (iMem == -2) {
2484 partonSystemsPtr->setInB(iSys, idx);
2485 (*beamBPtr)[iSys].x((pMod.e() - pMod.pz()) / eCM);
2486 (*beamBPtr)[iSys].m(pMod.mCalc());
2487 (*beamBPtr)[iSys].p(pMod);
2488 (*beamBPtr)[iSys].iPos(idx);
2491 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
2492 "internal bookeeping error");
2497 int daughter1 =
event[idx].daughter1();
2498 idx =
event.copy(idx, 55);
2499 event[idx].statusNeg();
2500 event[daughter1].mothers(idx, idx);
2502 partonSystemsPtr->setOut(iSys, iMem, idx);
2505 event[idx].p( eventMod[i].second );
2506 event[idx].m( event[idx].mCalc() );
2521 void TimeShower::findMEtype(
Event& event, TimeDipoleEnd& dip) {
2525 if (!doMEcorrections) setME =
false;
2526 int iMother =
event[dip.iRadiator].mother1();
2527 int iMother2 =
event[dip.iRadiator].mother2();
2530 if (dip.isHiddenValley && event[dip.iRecoiler].id()
2531 == -
event[dip.iRadiator].id());
2535 if (iMother2 != iMother && iMother2 != 0) setME =
false;
2536 if (event[dip.iRecoiler].mother1() != iMother) setME =
false;
2537 if (event[dip.iRecoiler].mother2() != iMother2) setME =
false;
2541 if (event[dip.iRecoiler].status() < 0) setME =
false;
2544 if (dip.system != dip.systemRec) setME =
false;
2553 if (dip.iMEpartner < 0) dip.iMEpartner = dip.iRecoiler;
2556 if (dip.colType != 0 || dip.colvType != 0) {
2557 bool isHiddenColour = (dip.colvType != 0);
2560 int idDau1 =
event[dip.iRadiator].id();
2561 int idDau2 =
event[dip.iMEpartner].id();
2562 int dau1Type = findMEparticle(idDau1, isHiddenColour);
2563 int dau2Type = findMEparticle(idDau2, isHiddenColour);
2564 int minDauType = min(dau1Type, dau2Type);
2565 int maxDauType = max(dau1Type, dau2Type);
2568 dip.MEorder = (dau2Type >= dau1Type);
2569 dip.MEsplit = (maxDauType <= 6);
2570 dip.MEgluinoRec =
false;
2573 if (minDauType == 0 && dip.MEtype < 0) dip.MEtype = 0;
2574 if (dip.MEtype >= 0)
return;
2578 if (dau1Type == 4 && dau2Type == 4)
return;
2582 if ( event[dip.iRecoiler].mother1() == iMother && iMother >= 0)
2583 idMother = event[iMother].
id();
2584 int motherType = (idMother != 0)
2585 ? findMEparticle(idMother, isHiddenColour) : 0;
2588 if (motherType == 0) {
2589 int col1 =
event[dip.iRadiator].col();
2590 int acol1 =
event[dip.iRadiator].acol();
2591 int col2 =
event[dip.iMEpartner].col();
2592 int acol2 =
event[dip.iMEpartner].acol();
2594 int spinT = (
event[dip.iRadiator].spinType()
2595 +
event[dip.iMEpartner].spinType() )%2;
2597 if ( col1 == acol2 && acol1 == col2 )
2598 motherType = (spinT == 0) ? 7 : 9;
2600 else if ( (col1 == acol2 && acol1 != 0 && col2 != 0)
2601 || (acol1 == col2 && col1 != 0 && acol2 != 0) )
2602 motherType = (spinT == 0) ? 4 : 5;
2604 else if ( (col1 == acol2 && acol1 != col2)
2605 || (acol1 == col2 && col1 != acol2) )
2606 motherType = (spinT == 0) ? 2 : 1;
2618 if (isHiddenColour && brokenHVsym) {
2619 MEkind = (dau2Type == 0 || dau2Type > 6) ? 30 : 31;
2620 dip.MEtype = 5 * MEkind + 1;
2626 dip.MEgluinoRec = (dau1Type >= 1 && dau1Type <= 3 && dau2Type == 5);
2629 if (minDauType == 1 && maxDauType == 1 &&
2630 (motherType == 4 || motherType == 7) ) {
2632 if (idMother == 21 || idMother == 22) MEcombi = 1;
2633 else if (idMother == 23 || idDau1 + idDau2 == 0) {
2635 dip.MEmix = gammaZmix( event, iMother, dip.iRadiator, dip.iRecoiler );
2637 else if (idMother == 24) MEcombi = 4;
2640 else if (minDauType == 1 && maxDauType == 1 && motherType == 9)
2644 else if (minDauType == 1 && maxDauType == 7 && motherType == 1)
2646 if (idDau1 == 22 || idDau2 == 22) MEcombi = 1;
2649 else if (minDauType == 1 && maxDauType == 1 && motherType == 8) {
2651 if (idMother == 25 || idMother == 35 || idMother == 37) MEcombi = 1;
2652 else if (idMother == 36) MEcombi = 2;
2654 else if (minDauType == 1 && maxDauType == 8 && motherType == 1)
2658 else if (minDauType == 2 && maxDauType == 2 && (motherType == 4
2659 || motherType == 7) ) MEkind = 6;
2660 else if (minDauType == 2 && (maxDauType == 4 || maxDauType == 7)
2661 && motherType == 2) MEkind = 7;
2662 else if (minDauType == 2 && maxDauType == 2 && motherType == 8)
2664 else if (minDauType == 2 && maxDauType == 8 && motherType == 2)
2668 else if (minDauType == 1 && maxDauType == 2 && motherType == 9)
2670 else if (minDauType == 1 && maxDauType == 9 && motherType == 2)
2672 else if (minDauType == 2 && maxDauType == 9 && motherType == 1)
2676 else if (minDauType == 1 && maxDauType == 2 && motherType == 5)
2678 else if (minDauType == 1 && maxDauType == 5 && motherType == 2)
2680 else if (minDauType == 2 && maxDauType == 5 && motherType == 1)
2685 else if (minDauType == 1 && maxDauType == 9 && motherType == 3)
2688 else if (minDauType == 3 && maxDauType == 9 && motherType == 1)
2692 else if (minDauType == 5 && maxDauType == 5) MEkind = 16;
2695 dip.MEtype = 5 * MEkind + MEcombi;
2698 }
else if (dip.chgType != 0) {
2703 if (dip.MEtype >= 0)
return;
2706 int idDau1 =
event[dip.iRadiator].id();
2707 int idDau2 =
event[dip.iMEpartner].id();
2708 if (abs(idDau1) < 9 && abs(idDau2) < 9 && idDau1 * idDau2 < 0) ;
2709 else if (abs(idDau1) > 10 && abs(idDau1) < 19 && abs(idDau2) > 10
2710 && abs(idDau2) < 19 && idDau1 * idDau2 < 0) ;
2711 else { dip.MEtype = 0;
return; }
2715 if (idDau1 + idDau2 == 0) dip.MEtype = 102;
2727 int TimeShower::findMEparticle(
int id,
bool isHiddenColour) {
2731 int colType = abs(particleDataPtr->colType(
id));
2732 int spinType = particleDataPtr->spinType(
id);
2736 if (isHiddenColour) {
2738 int idAbs = abs(
id);
2739 if ( (idAbs > 4900000 && idAbs < 4900007)
2740 || (idAbs > 4900010 && idAbs < 4900017)
2741 || idAbs == 4900101) colType = 1;
2745 if (colType == 1 && spinType == 2) type = 1;
2746 else if (colType == 1 && spinType == 1) type = 2;
2747 else if (colType == 1) type = 3;
2748 else if (colType == 2 && spinType == 3) type = 4;
2749 else if (colType == 2 && spinType == 2) type = 5;
2750 else if (colType == 2) type = 6;
2751 else if (colType == 0 && spinType == 3) type = 7;
2752 else if (colType == 0 && spinType == 1) type = 8;
2753 else if (colType == 0 && spinType == 2) type = 9;
2764 double TimeShower::gammaZmix(
Event& event,
int iRes,
int iDau1,
int iDau2) {
2769 int iIn1 = (iRes >= 0) ? event[iRes].mother1() : -1;
2770 int iIn2 = (iRes >= 0) ? event[iRes].mother2() : -1;
2771 if (iIn1 >=0) idIn1 =
event[iIn1].id();
2772 if (iIn2 >=0) idIn2 =
event[iIn1].id();
2775 if (idIn1 == 21 || idIn1 == 22) idIn1 = -idIn2;
2776 if (idIn2 == 21 || idIn2 == 22) idIn2 = -idIn1;
2779 if (idIn1 + idIn2 != 0 )
return 0.5;
2780 int idInAbs = abs(idIn1);
2781 if (idInAbs == 0 || idInAbs > 18 )
return 0.5;
2782 double ei = coupSMPtr->ef(idInAbs);
2783 double vi = coupSMPtr->vf(idInAbs);
2784 double ai = coupSMPtr->af(idInAbs);
2787 if (event[iDau1].
id() + event[iDau2].
id() != 0)
return 0.5;
2788 int idOutAbs = abs(event[iDau1].
id());
2789 if (idOutAbs == 0 || idOutAbs >18 )
return 0.5;
2790 double ef = coupSMPtr->ef(idOutAbs);
2791 double vf = coupSMPtr->vf(idOutAbs);
2792 double af = coupSMPtr->af(idOutAbs);
2795 Vec4 psum =
event[iDau1].p() +
event[iDau2].p();
2796 double sH = psum.m2Calc();
2797 double intNorm = 2. * thetaWRat * sH * (sH - mZ*mZ)
2798 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
2799 double resNorm = pow2(thetaWRat * sH)
2800 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
2803 double vect = ei*ei * ef*ef + ei*vi * intNorm * ef*vf
2804 + (vi*vi + ai*ai) * resNorm * vf*vf;
2805 double axiv = (vi*vi + ai*ai) * resNorm * af*af;
2806 return vect / (vect + axiv);
2814 double TimeShower::findMEcorr(TimeDipoleEnd* dip, Particle& rad,
2815 Particle& partner, Particle& emt) {
2820 int MEkind = dip->MEtype / 5;
2821 int MEcombi = dip->MEtype % 5;
2824 Vec4 sum = rad.p() + partner.p() + emt.p();
2825 double eCMME = sum.mCalc();
2826 double x1 = 2. * (sum * rad.p()) / pow2(eCMME);
2827 double x2 = 2. * (sum * partner.p()) / pow2(eCMME);
2828 double r1 = rad.m() / eCMME;
2829 double r2 = partner.m() / eCMME;
2833 double gammavCorr = 1.;
2834 if (dip->colvType != 0 && brokenHVsym) {
2835 r3 = emt.m() / eCMME;
2836 double x3Tmp = 2. - x1 - x2;
2837 gammavCorr = x3Tmp / (x3Tmp - kRad * (x1 + x3Tmp));
2840 double m2Pair = (rad.p() + partner.p()).m2Calc();
2841 double m2Avg = 0.5 * (rad.m2() + partner.m2())
2842 - 0.25 * pow2(rad.m2() - partner.m2()) / m2Pair;
2843 r1 = sqrt(m2Avg) / eCMME;
2845 double xShift = 0.5 * (x1 + x2) * (partner.m2() - rad.m2()) / m2Pair;
2852 double x1minus = max(XMARGIN, 1. + r1*r1 - r2*r2 - x1);
2853 double x2minus = max(XMARGIN, 1. + r2*r2 - r1*r1 - x2) ;
2854 double x3 = max(XMARGIN, 2. - x1 - x2);
2857 if (dip->colType !=0 || dip->colvType != 0) {
2861 wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix, x1, x2, r1, r2, r3);
2862 else wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix, x2, x1, r2, r1, r3);
2865 if (dip->MEsplit) wtME = wtME * x1minus / x3;
2868 wtPS = 2. / ( x3 * x2minus );
2869 if (dip->MEgluinoRec) wtPS *= 9./4.;
2870 if (dip->colvType != 0 && brokenHVsym) wtPS *= gammavCorr;
2874 }
else if (dip->chgType !=0 && dip->MEtype == 101) {
2875 double chg1 = particleDataPtr->charge(rad.id());
2876 double chg2 = particleDataPtr->charge(partner.id());
2877 wtME = (x1*x1 + x2*x2) * pow2( chg1 * x1minus / x3
2878 - chg2 * x2minus / x3 );
2879 wtPS = 2. * ( chg1*chg1 * x1minus / x3 + chg2*chg2 * x2minus / x3 );
2882 }
else if (dip->chgType !=0 && dip->MEtype == 102) {
2883 wtME = calcMEcorr(2, 1, dip->MEmix, x1, x2, r1, r2) * x1minus / x3;
2884 wtPS = 2. / ( x3 * x2minus );
2886 if (wtME > wtPS) infoPtr->errorMsg(
"Warning in TimeShower::findMEcorr: "
2887 "ME weight above PS one");
2926 double TimeShower::calcMEcorr(
int kind,
int combiIn,
double mixIn,
2927 double x1,
double x2,
double r1,
double r2,
double r3) {
2930 double x3 = 2. - x1 - x2;
2931 double x1s = x1 * x1;
2932 double x2s = x2 * x2;
2933 double x3s = x3 * x3;
2934 double x1c = x1 * x1s;
2935 double x2c = x2 * x2s;
2936 double x3c = x3 * x3s;
2937 double r1s = r1 * r1;
2938 double r2s = r2 * r2;
2939 double r1c = r1 * r1s;
2940 double r2c = r2 * r2s;
2941 double r1q = r1s * r1s;
2942 double r2q = r2s * r2s;
2943 double prop1 = 1. + r1s - r2s - x1;
2944 double prop2 = 1. + r2s - r1s - x2;
2945 double prop1s = prop1 * prop1;
2946 double prop2s = prop2 * prop2;
2947 double prop12 = prop1 * prop2;
2948 double prop13 = prop1 * x3;
2949 double prop23 = prop2 * x3;
2952 double r3s = r3 * r3;
2953 double prop3 = r3s - x3;
2954 double prop3s = prop3 * prop3;
2955 if (kind == 30) prop13 = prop1 * prop3;
2958 if (x1 - 2.*r1 < XMARGIN || prop1 < XMARGIN)
return 0.;
2959 if (x2 - 2.*r2 < XMARGIN || prop2 < XMARGIN)
return 0.;
2961 if (kind != 30 && kind != 31) {
2962 if (x1 + x2 - 1. - pow2(r1+r2) < XMARGIN)
return 0.;
2966 if ( (x1s - 4.*r1s) * (x2s - 4.*r2s)
2967 - pow2( 2. * (1. - x1 - x2 + r1s + r2s) + x1*x2 )
2968 < XMARGIN * (XMARGINCOMB + r1 + r2) )
return 0.;
2972 int combi = max(1, min(4, combiIn) );
2973 double mix = max(0., min(1., mixIn) );
2974 bool isSet1 =
false;
2975 bool isSet2 =
false;
2976 bool isSet4 =
false;
2977 double ps = sqrtpos( pow2(1. - r1*r1 - r2*r2) - pow2(2. * r1 * r2) );
2978 double rLO = 0., rFO = 0., rLO1 = 0., rFO1 = 0., rLO2 = 0.,
2979 rFO2 = 0., rLO4 = 0., rFO4 = 0.;
2989 if (combi == 1 || combi == 3) {
2990 rLO1 = ps*(2.-r1s-r1q+6.*r1*r2-r2s+2.*r1s*r2s-r2q)/2.;
2991 rFO1 = -(3.+6.*r1s+r1q-6.*r1*r2+6.*r1c*r2-2.*r2s-6.*r1s*r2s
2992 +6.*r1*r2c+r2q-3.*x1+6.*r1*r2*x1+2.*r2s*x1+x1s-2.*r1s*x1s
2993 +3.*r1s*x3+6.*r1*r2*x3-r2s*x3-2.*x1*x3-5.*r1s*x1*x3
2994 +r2s*x1*x3+x1s*x3-3.*x3s-3.*r1s*x3s+r2s*x3s
2997 -2.*(-3.+r1s-6.*r1*r2+6.*r1c*r2+3.*r2s-4.*r1s*r2s
2998 +6.*r1*r2c+2.*x1+3.*r1s*x1+r2s*x1-x1s-r1s*x1s
2999 -r2s*x1s+4.*x3+2.*r1s*x3+3.*r1*r2*x3-r2s*x3-3.*x1*x3
3000 -2.*r1s*x1*x3+x1s*x3-x3s-r1s*x3s+r1*r2*x3s+x1*x3s)
3002 -(-1.+2.*r1s+r1q+6.*r1*r2+6.*r1c*r2-2.*r2s-6.*r1s*r2s
3003 +6.*r1*r2c+r2q-x1-2.*r1s*x1-6.*r1*r2*x1+8.*r2s*x1+x1s
3004 -2.*r2s*x1s-r1s*x3+r2s*x3-r1s*x1*x3+r2s*x1*x3+x1s*x3+x2)
3009 if (combi == 2 || combi == 3) {
3010 rLO2 = ps*(2.-r1s-r1q-6.*r1*r2-r2s+2.*r1s*r2s-r2q)/2.;
3011 rFO2 = -(3.+6.*r1s+r1q+6.*r1*r2-6.*r1c*r2-2.*r2s-6.*r1s*r2s
3012 -6.*r1*r2c+r2q-3.*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.*x2+3.*r1s*x2
3302 if (combi == 1 || combi == 3) {
3303 rLO1 = ps*(1.-pow2(r1+r2));
3304 rFO1 = (1.+r1s+2.*r1*r2+r2s-x1-x2)*(x1+x2)
3306 -(-1.+r1q-2.*r1*r2-2.*r1c*r2-6.*r1s*r2s-2.*r1*r2c+r2q+x1
3307 -r1s*x1+r2s*x1+x2+3.*r1s*x2+2.*r1*r2*x2-r2s*x2-x1*x2)
3309 +(-1.-2.*r1s-r1q-2.*r1*r2-2.*r1c*r2+2.*r1*r2c+r2q+x1+r1s*x1
3310 -2.*r1*r2*x1-3.*r2s*x1+2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
3314 if (combi == 2 || combi == 3) {
3315 rLO2 = ps*(1.-pow2(r1-r2));
3316 rFO2 = (1.+r1s-2.*r1*r2+r2s-x1-x2)*(x1+x2)
3318 -(-1.+r1q+2.*r1*r2+2.*r1c*r2-6.*r1s*r2s+2.*r1*r2c+r2q+x1
3319 -r1s*x1+r2s*x1+x2+3.*r1s*x2-2.*r1*r2*x2-r2s*x2-x1*x2)
3321 +(-1.-2.*r1s-r1q+2.*r1*r2+2.*r1c*r2-2.*r1*r2c+r2q+x1+r1s*x1
3322 +2.*r1*r2*x1-3.*r2s*x1+2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
3327 rLO4 = ps*(1.-r1s-r2s);
3328 rFO4 = (1.+r1s+r2s-x1-x2)*(x1+x2)
3330 -(-1.+r1q-6.*r1s*r2s+r2q+x1-r1s*x1+r2s*x1+x2
3331 +3.*r1s*x2-r2s*x2-x1*x2)
3333 +(-1.-2.*r1s-r1q+r2q+x1+r1s*x1-3.*r2s*x1
3334 +2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
3342 if (combi == 1 || combi == 3) {
3343 rLO1 = ps*(1.-r1s+r2s+2.*r2);
3344 rFO1 = (2.*r2+x2)*(-1.-r1s-r2s+x2)
3346 +(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1-2.*r2*x1+r2s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+2.*x2+r1s*x2
3564 rLO4 = ps*(1.-r1s+r2s);
3565 rFO4 = 64.*x2*(-1.-r1s-r2s+x2)
3567 +16.*(-1.-r1s-r2s+x1+r2s*x1+3.*x2*0.5-r1s*x2*0.5
3568 -r2s*x2*0.5-x1*x2*0.5)
3570 -16.*(3.+3.*r1s-5.*r2s-4.*x1-r1s*x1+2.*r2s*x1+x1s-2.*x2+r2s*x2
3573 +64.*(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1+r2s*x1+x1s-3.*x2
3574 -r1s*x2+r2s*x2+x1*x2)
3576 +16.*(2.+2.*r1s-6.*r2s-3.*x1-r1s*x1+3.*r2s*x1+x1s
3577 -x2-r1s*x2+r2s*x2+x1*x2)
3579 -16.*(-1.-r1s-r2s+x1+r2s*x1+2.*x2+r1s*x2-x1*x2*0.5-x2s*0.5)
3589 if (combi == 2) offset = x3s;
3590 else if (combi == 3) offset = mix * x3s;
3591 else if (combi == 4) offset = 0.5 * x3s;
3592 rFO = ps * 4.5 * ( (x1+x2-1.+offset-r1s-r2s)/prop12
3593 - r1s/prop2s - r2s/prop1s );
3598 rLO = ps*(1.-r1s+r2s+2.*r2);
3599 rFO = ( 0.5*r3s + 2.*r1q + 0.5*r2s*r3s + r2*r3s - 2.*r1s
3600 - 0.5*r1s*r3s - 2.*r1s*r2s - 4.*r1s*r2 ) / prop2s
3601 + ( -2. + 2.*r2q + 2.*r1q + 2.*r2s*r3s - 4.*r2 + 2.*r2*r3s
3602 + 4.*r2*r2s - 4.*r1s*r2s - 4.*r1s*r2 ) /prop23
3603 + ( -2. - 0.5*r3s - 2.*r2s - 4.*r2 + 2.*r1s ) / prop2
3604 + ( -2. - r3s - 2.*r2s - r2s*r3s - 4.*r2 - 2.*r2*r3s
3605 + 2.*r1s + r1s*r3s ) / prop3s
3606 + ( -1. - r3s - r2s - 4.*r2 + r1s - x2 ) / prop3
3612 rLO = ps*(1.-4.*r1s);
3613 rFO = (r3s + 2.*r1s) * (-1. + 4.*r1s) * (1./prop1s + 1./prop2s)
3614 + (-1. + 8.*r1s - x2) / prop1
3615 + (-1. + 8.*r1s - x1) / prop2
3616 + 2. * (1. - 6.*r1s + 8.*r1q + 4.*r3s*r1s) / prop12
3623 if (combi == 2) offset = x3s;
3624 else if (combi == 3) offset = mix * x3s;
3625 else if (combi == 4) offset = 0.5 * x3s;
3626 rFO = ps * 2. * ( (x1+x2-1.+offset-r1s-r2s)/prop12
3627 - r1s/prop2s - r2s/prop1s );
3634 if (combi == 1 && isSet1) {
3637 else if (combi == 2 && isSet2) {
3640 else if (combi == 3 && isSet1 && isSet2) {
3641 rLO = mix * rLO1 + (1.-mix) * rLO2;
3642 rFO = mix * rFO1 + (1.-mix) * rFO2; }
3646 else if (combi == 4 && isSet1 && isSet2) {
3647 rLO = 0.5 * (rLO1 + rLO2);
3648 rFO = 0.5 * (rFO1 + rFO2); }
3661 void TimeShower::findAsymPol(
Event& event, TimeDipoleEnd* dip) {
3666 int iRad = dip->iRadiator;
3667 if (!doPhiPolAsym || event[iRad].
id() != 21)
return;
3670 int iMother =
event.iTopCopy(iRad);
3671 int iGrandM =
event[iMother].mother1();
3675 int statusGrandM =
event[iGrandM].status();
3676 bool isHardProc = (statusGrandM == -21 || statusGrandM == -31);
3678 if (event[iGrandM + 1].status() != statusGrandM)
return;
3679 if (event[iGrandM].isGluon() &&
event[iGrandM + 1].isGluon());
3680 else if (event[iGrandM].isQuark() &&
event[iGrandM + 1].isQuark());
3685 if (isHardProc) dip->iAunt = dip->iRecoiler;
3686 else dip->iAunt = (
event[iGrandM].daughter1() == iMother)
3687 ? event[iGrandM].daughter2() :
event[iGrandM].daughter1();
3691 double zProd = (isHardProc) ? 0.5 : event[iRad].e()
3692 / (
event[iRad].e() +
event[dip->iAunt].e());
3693 if (event[iGrandM].isGluon()) dip->asymPol = pow2( (1. - zProd)
3694 / (1. - zProd * (1. - zProd) ) );
3695 else dip->asymPol = 2. * (1. - zProd) / (1. + pow2(1. - zProd) );
3698 if (dip->flavour == 21) dip->asymPol *= pow2( (1. - dip->z)
3699 / (1. - dip->z * (1. - dip->z) ) );
3700 else dip->asymPol *= -2. * dip->z *( 1. - dip->z )
3701 / (1. - 2. * dip->z * (1. - dip->z) );
3709 void TimeShower::list(ostream& os)
const {
3712 os <<
"\n -------- PYTHIA TimeShower Dipole Listing ----------------"
3713 <<
"--------------------------------------------- \n \n i rad"
3714 <<
" rec pTmax col chg gam oni hv isr sys sysR typ"
3715 <<
"e MErec mix ord spl ~gR \n" << fixed << setprecision(3);
3718 for (
int i = 0; i < int(dipEnd.size()); ++i)
3719 os << setw(5) << i << setw(7) << dipEnd[i].iRadiator
3720 << setw(7) << dipEnd[i].iRecoiler << setw(12) << dipEnd[i].pTmax
3721 << setw(5) << dipEnd[i].colType << setw(5) << dipEnd[i].chgType
3722 << setw(5) << dipEnd[i].gamType << setw(5) << dipEnd[i].isOctetOnium
3723 << setw(5) << dipEnd[i].isHiddenValley << setw(5) << dipEnd[i].isrType
3724 << setw(5) << dipEnd[i].system << setw(5) << dipEnd[i].systemRec
3725 << setw(5) << dipEnd[i].MEtype << setw(7) << dipEnd[i].iMEpartner
3726 << setw(8) << dipEnd[i].MEmix << setw(5) << dipEnd[i].MEorder
3727 << setw(5) << dipEnd[i].MEsplit << setw(5) << dipEnd[i].MEgluinoRec
3731 os <<
"\n -------- End PYTHIA TimeShower Dipole Listing ------------"
3732 <<
"---------------------------------------------" << endl;