8 #include "Pythia8/TimeShower.h"
22 const double TimeShower::MCMIN = 1.2;
23 const double TimeShower::MBMIN = 4.0;
26 const double TimeShower::SIMPLIFYROOT = 1e-8;
31 const double TimeShower::XMARGIN = 1e-12;
32 const double TimeShower::XMARGINCOMB = 1e-4;
35 const double TimeShower::TINYPDF = 1e-10;
38 const double TimeShower::LARGEM2 = 1e20;
41 const double TimeShower::THRESHM2 = 4.004;
44 const double TimeShower::LAMBDA3MARGIN = 1.1;
49 const bool TimeShower::FIXRESCATTER =
true;
51 const bool TimeShower::VETONEGENERGY =
false;
53 const double TimeShower::MAXVIRTUALITYFRACTION = 0.5;
55 const double TimeShower::MAXNEGENERGYFRACTION = 0.7;
58 const double TimeShower::WEAKPSWEIGHT = 5.;
61 const double TimeShower::WG2QEXTRA = 20.;
64 const double TimeShower::REJECTFACTOR = 0.1;
67 const double TimeShower::PROBLIMIT = 0.99;
73 void TimeShower::init( BeamParticle* beamAPtrIn,
74 BeamParticle* beamBPtrIn) {
77 beamAPtr = beamAPtrIn;
78 beamBPtr = beamBPtrIn;
81 doQCDshower = settingsPtr->flag(
"TimeShower:QCDshower");
82 doQEDshowerByQ = settingsPtr->flag(
"TimeShower:QEDshowerByQ");
83 doQEDshowerByL = settingsPtr->flag(
"TimeShower:QEDshowerByL");
84 doQEDshowerByOther = settingsPtr->flag(
"TimeShower:QEDshowerByOther");
85 doQEDshowerByGamma = settingsPtr->flag(
"TimeShower:QEDshowerByGamma");
86 doWeakShower = settingsPtr->flag(
"TimeShower:weakShower");
87 doMEcorrections = settingsPtr->flag(
"TimeShower:MEcorrections");
88 doMEextended = settingsPtr->flag(
"TimeShower:MEextended");
89 if (!doMEcorrections) doMEextended =
false;
90 doMEafterFirst = settingsPtr->flag(
"TimeShower:MEafterFirst");
91 doPhiPolAsym = settingsPtr->flag(
"TimeShower:phiPolAsym");
92 doPhiPolAsymHard = settingsPtr->flag(
"TimeShower:phiPolAsymHard");
93 doInterleave = settingsPtr->flag(
"TimeShower:interleave");
94 allowBeamRecoil = settingsPtr->flag(
"TimeShower:allowBeamRecoil");
95 dampenBeamRecoil = settingsPtr->flag(
"TimeShower:dampenBeamRecoil");
96 recoilToColoured = settingsPtr->flag(
"TimeShower:recoilToColoured");
97 allowMPIdipole = settingsPtr->flag(
"TimeShower:allowMPIdipole");
100 doDipoleRecoil = settingsPtr->flag(
"SpaceShower:dipoleRecoil");
101 if (doDipoleRecoil) allowBeamRecoil =
true;
102 if (doDipoleRecoil) dampenBeamRecoil =
false;
105 pTmaxMatch = settingsPtr->mode(
"TimeShower:pTmaxMatch");
106 pTdampMatch = settingsPtr->mode(
"TimeShower:pTdampMatch");
107 pTmaxFudge = settingsPtr->parm(
"TimeShower:pTmaxFudge");
108 pTmaxFudgeMPI = settingsPtr->parm(
"TimeShower:pTmaxFudgeMPI");
109 pTdampFudge = settingsPtr->parm(
"TimeShower:pTdampFudge");
112 mc = max( MCMIN, particleDataPtr->m0(4));
113 mb = max( MBMIN, particleDataPtr->m0(5));
118 renormMultFac = settingsPtr->parm(
"TimeShower:renormMultFac");
119 factorMultFac = settingsPtr->parm(
"TimeShower:factorMultFac");
120 useFixedFacScale = settingsPtr->flag(
"TimeShower:useFixedFacScale");
121 fixedFacScale2 = pow2(settingsPtr->parm(
"TimeShower:fixedFacScale"));
124 alphaSvalue = settingsPtr->parm(
"TimeShower:alphaSvalue");
125 alphaSorder = settingsPtr->mode(
"TimeShower:alphaSorder");
126 alphaSnfmax = settingsPtr->mode(
"StandardModel:alphaSnfmax");
127 alphaSuseCMW = settingsPtr->flag(
"TimeShower:alphaSuseCMW");
128 alphaS2pi = 0.5 * alphaSvalue / M_PI;
131 alphaS.init( alphaSvalue, alphaSorder, alphaSnfmax, alphaSuseCMW);
134 Lambda3flav = alphaS.Lambda3();
135 Lambda4flav = alphaS.Lambda4();
136 Lambda5flav = alphaS.Lambda5();
137 Lambda5flav2 = pow2(Lambda5flav);
138 Lambda4flav2 = pow2(Lambda4flav);
139 Lambda3flav2 = pow2(Lambda3flav);
142 nGluonToQuark = settingsPtr->mode(
"TimeShower:nGluonToQuark");
143 weightGluonToQuark = settingsPtr->mode(
"TimeShower:weightGluonToQuark");
144 scaleGluonToQuark = settingsPtr->parm(
"TimeShower:scaleGluonToQuark");
145 extraGluonToQuark = (weightGluonToQuark%4 == 3) ? WG2QEXTRA : 1.;
146 recoilDeadCone = settingsPtr->flag(
"TimeShower:recoilDeadCone");
147 pTcolCutMin = settingsPtr->parm(
"TimeShower:pTmin");
148 if (pTcolCutMin > LAMBDA3MARGIN * Lambda3flav / sqrt(renormMultFac))
149 pTcolCut = pTcolCutMin;
151 pTcolCut = LAMBDA3MARGIN * Lambda3flav / sqrt(renormMultFac);
152 ostringstream newPTcolCut;
153 newPTcolCut << fixed << setprecision(3) << pTcolCut;
154 infoPtr->errorMsg(
"Warning in TimeShower::init: pTmin too low",
155 ", raised to " + newPTcolCut.str() );
156 infoPtr->setTooLowPTmin(
true);
158 pT2colCut = pow2(pTcolCut);
161 alphaEMorder = settingsPtr->mode(
"TimeShower:alphaEMorder");
164 alphaEM.init( alphaEMorder, settingsPtr);
167 nGammaToQuark = settingsPtr->mode(
"TimeShower:nGammaToQuark");
168 nGammaToLepton = settingsPtr->mode(
"TimeShower:nGammaToLepton");
169 pTchgQCut = settingsPtr->parm(
"TimeShower:pTminChgQ");
170 pT2chgQCut = pow2(pTchgQCut);
171 pTchgLCut = settingsPtr->parm(
"TimeShower:pTminChgL");
172 pT2chgLCut = pow2(pTchgLCut);
173 mMaxGamma = settingsPtr->parm(
"TimeShower:mMaxGamma");
174 m2MaxGamma = pow2(mMaxGamma);
177 weakMode = settingsPtr->mode(
"TimeShower:weakShowerMode");
178 pTweakCut = settingsPtr->parm(
"TimeShower:pTminWeak");
179 pT2weakCut = pow2(pTweakCut);
180 weakEnhancement = settingsPtr->parm(
"WeakShower:enhancement");
181 singleWeakEmission = settingsPtr->flag(
"WeakShower:singleEmission");
182 vetoWeakJets = settingsPtr->flag(
"WeakShower:vetoWeakJets");
183 vetoWeakDeltaR2 = pow2(settingsPtr->parm(
"WeakShower:vetoWeakDeltaR"));
184 weakExternal = settingsPtr->flag(
"WeakShower:externalSetup");
187 if (nGammaToQuark <= 0 && nGammaToLepton <= 0) doQEDshowerByGamma =
false;
190 globalRecoil = settingsPtr->flag(
"TimeShower:globalRecoil");
191 nMaxGlobalRecoil = settingsPtr->mode(
"TimeShower:nMaxGlobalRecoil");
193 nMaxGlobalBranch = settingsPtr->mode(
"TimeShower:nMaxGlobalBranch");
195 nFinalBorn = settingsPtr->mode(
"TimeShower:nPartonsInBorn");
197 globalRecoilMode = settingsPtr->mode(
"TimeShower:globalRecoilMode");
199 limitMUQ = settingsPtr->flag(
"TimeShower:limitPTmaxGlobal");
202 octetOniumFraction = settingsPtr->parm(
"TimeShower:octetOniumFraction");
203 octetOniumColFac = settingsPtr->parm(
"TimeShower:octetOniumColFac");
206 mZ = particleDataPtr->m0(23);
207 gammaZ = particleDataPtr->mWidth(23);
208 thetaWRat = 1. / (16. * coupSMPtr->sin2thetaW()
209 * coupSMPtr->cos2thetaW());
210 mW = particleDataPtr->m0(24);
211 gammaW = particleDataPtr->mWidth(24);
214 allowRescatter = settingsPtr->flag(
"PartonLevel:MPI")
215 && settingsPtr->flag(
"MultipartonInteractions:allowRescatter");
218 doHVshower = settingsPtr->flag(
"HiddenValley:FSR");
219 nCHV = settingsPtr->mode(
"HiddenValley:Ngauge");
220 alphaHVfix = settingsPtr->parm(
"HiddenValley:alphaFSR");
221 alphaHVorder = (nCHV > 1 )
222 ? settingsPtr->mode(
"HiddenValley:alphaOrder") : 0;
223 nFlavHV = settingsPtr->mode(
"HiddenValley:nFlav");
224 LambdaHV = settingsPtr->parm(
"HiddenValley:Lambda");
225 pThvCut = settingsPtr->parm(
"HiddenValley:pTminFSR");
226 CFHV = (nCHV == 1) ? 1. : (nCHV * nCHV - 1.)/(2. * nCHV);
227 idHV = (nCHV == 1) ? 4900022 : 4900021;
228 mHV = particleDataPtr->m0(idHV);
229 brokenHVsym = (nCHV == 1 && mHV > 0.);
230 if (pThvCut < LambdaHV) {
231 pThvCut = LAMBDA3MARGIN * LambdaHV;
232 ostringstream newPTcolCut;
233 newPTcolCut << fixed << setprecision(3) << pThvCut;
234 infoPtr->errorMsg(
"Warning in TimeShower::init: Hidden Valley pTmin ",
235 "too low, raised to " + newPTcolCut.str() );
237 pT2hvCut = pThvCut * pThvCut;
240 doSecondHard = settingsPtr->flag(
"SecondHard:generate");
243 hasUserHooks = (userHooksPtr != 0);
244 canVetoEmission = hasUserHooks && userHooksPtr->canVetoFSREmission();
251 hasWeaklyRadiated =
false;
254 canEnhanceEmission = hasUserHooks && userHooksPtr->canEnhanceEmission();
255 canEnhanceTrial = hasUserHooks && userHooksPtr->canEnhanceTrial();
256 if (canEnhanceEmission && canEnhanceTrial) {
257 infoPtr->errorMsg(
"Error in SpaceShower::init: Enhance for both actual "
258 "and trial emissions not possible. Both switched off.");
259 canEnhanceEmission =
false;
260 canEnhanceTrial =
false;
264 splittingNameSel =
"";
265 splittingNameNow =
"";
266 enhanceFactors.clear();
270 doUncertainties = settingsPtr->flag(
"UncertaintyBands:doVariations")
271 && initUncertainties();
272 doUncertaintiesNow = doUncertainties;
273 uVarNflavQ = settingsPtr->mode(
"UncertaintyBands:nFlavQ");
274 uVarMPIshowers = settingsPtr->flag(
"UncertaintyBands:MPIshowers");
275 cNSpTmin = settingsPtr->parm(
"UncertaintyBands:cNSpTmin");
276 uVarpTmin2 = pT2colCut;
277 uVarpTmin2 *= settingsPtr->parm(
"UncertaintyBands:FSRpTmin2Fac");
278 int varType = settingsPtr->mode(
"UncertaintyBands:type");
279 noResVariations = (varType == 1) ?
true:
false;
280 noProcVariations = (varType == 2) ?
true:
false;
281 overFactor = settingsPtr->parm(
"UncertaintyBands:overSampleFSR");
284 doPartonVertex = settingsPtr->flag(
"PartonVertex:setVertex")
285 && (partonVertexPtr != 0);
294 bool TimeShower::limitPTmax(
Event& event,
double Q2Fac,
double Q2Ren) {
297 bool dopTlimit =
false;
298 dopTlimit1 = dopTlimit2 =
false;
300 if (pTmaxMatch == 1) dopTlimit = dopTlimit1 = dopTlimit2 =
true;
301 else if (pTmaxMatch == 2) dopTlimit = dopTlimit1 = dopTlimit2 =
false;
304 else if (infoPtr->isNonDiffractive() || infoPtr->isDiffractiveA()
305 || infoPtr->isDiffractiveB() || infoPtr->isDiffractiveC() )
306 dopTlimit = dopTlimit1 = dopTlimit2 =
true;
312 int iBegin = 5 + beamOffset;
313 for (
int i = iBegin; i <
event.size(); ++i) {
314 if (event[i].status() == -21) ++n21;
316 int idAbs =
event[i].idAbs();
317 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit1 =
true;
318 if ( (event[i].col() != 0 || event[i].acol() != 0)
319 && idAbs > 5 && idAbs != 21 ) ++nHeavyCol;
320 }
else if (n21 == 2) {
321 int idAbs =
event[i].idAbs();
322 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit2 =
true;
325 dopTlimit = (doSecondHard) ? (dopTlimit1 && dopTlimit2) : dopTlimit1;
331 if (!dopTlimit1 && (pTdampMatch == 1 || pTdampMatch == 2)) {
333 pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 1) ? Q2Fac : Q2Ren);
335 if (!dopTlimit1 && nHeavyCol > 1 && (pTdampMatch == 3 || pTdampMatch == 4)) {
337 pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 3) ? Q2Fac : Q2Ren);
349 int TimeShower::shower(
int iBeg,
int iEnd,
Event& event,
double pTmax,
353 int iSys = partonSystemsPtr->addSys();
357 for (
int i = iBeg; i <= iEnd; ++i)
if (event[i].isFinal()) {
358 partonSystemsPtr->addOut( iSys, i);
359 pSum +=
event[i].p();
361 partonSystemsPtr->setSHat( iSys, pSum.m2Calc() );
367 hasWeaklyRadiated =
false;
368 prepare( iSys, event,
true);
374 double pTtimes = pTnext( event, pTmax, 0.);
378 if (branch( event)) {
380 pTLastBranch = pTtimes;
387 }
while (pTmax > 0. && (nBranchMax <= 0 || nBranch < nBranchMax));
399 int TimeShower::showerQED(
int i1,
int i2,
Event& event,
double pTmax) {
402 int iSys = partonSystemsPtr->addSys();
403 partonSystemsPtr->addOut( iSys, i1);
404 partonSystemsPtr->addOut( iSys, i2);
405 partonSystemsPtr->setSHat( iSys, m2(event[i1], event[i2]) );
408 int iChg1 =
event[i1].chargeType();
409 int iChg2 =
event[i2].chargeType();
410 int MEtype = (iChg1 + iChg2 == 0) ? 102 : 101;
414 if (iChg1 != 0) dipEnd.push_back( TimeDipoleEnd(i1, i2, pTmax,
415 0, iChg1, 0, 0, 0, iSys, MEtype, i2) );
416 if (iChg2 != 0) dipEnd.push_back( TimeDipoleEnd(i2, i1, pTmax,
417 0, iChg2, 0, 0, 0, iSys, MEtype, i1) );
428 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
429 TimeDipoleEnd& dip = dipEnd[iDip];
432 dip.mRad =
event[dip.iRadiator].m();
433 dip.mRec =
event[dip.iRecoiler].m();
434 dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
435 dip.m2Rad = pow2(dip.mRad);
436 dip.m2Rec = pow2(dip.mRec);
437 dip.m2Dip = pow2(dip.mDip);
440 dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
441 double pTbegDip = min( pTmax, dip.pTmax );
442 double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
446 if (pT2begDip > pT2sel) {
447 pT2nextQED( pT2begDip, pT2sel, dip, event);
450 if (dip.pT2 > pT2sel) {
457 double pTsel = (dipSel == 0) ? 0. : sqrt(pT2sel);
463 int iRadBef = dipSel->iRadiator;
464 int iRecBef = dipSel->iRecoiler;
465 Particle& radBef =
event[iRadBef];
466 Particle& recBef =
event[iRecBef];
467 Vec4 pRadBef =
event[iRadBef].p();
468 Vec4 pRecBef =
event[iRecBef].p();
471 double pTorig = sqrt( dipSel->pT2);
472 double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
474 double e2RadPlusEmt = pow2(eRadPlusEmt);
475 double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
476 - dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
477 double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z
478 * (1. - dipSel->z) - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
479 double pTcorr = sqrtpos( pT2corr );
480 double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
482 double pzEmt = (e2RadPlusEmt * (1. - dipSel->z)
483 - 0.5 * dipSel->m2) / pzRadPlusEmt;
484 double mRad = dipSel->mRad;
488 double m2Ratio = dipSel->m2Rad / dipSel->m2;
489 pTorig *= 1. - m2Ratio;
490 pTcorr *= 1. - m2Ratio;
491 pzRad += pzEmt * m2Ratio;
492 pzEmt *= 1. - m2Ratio;
495 double phi = 2. * M_PI * rndmPtr->flat();
496 Vec4 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
497 sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
498 Vec4 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
499 sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
500 Vec4 pRec = Vec4( 0., 0., -pzRadPlusEmt,
501 sqrt( pow2(pzRadPlusEmt) + dipSel->m2Rec ) );
505 M.fromCMframe(pRadBef, pRecBef);
511 Particle rad = Particle(radBef.id(), 51, iRadBef, 0, 0, 0,
512 radBef.col(), radBef.acol(), pRad, mRad, pTsel);
513 Particle emt = Particle(22, 51, iRadBef, 0, 0, 0,
514 0, 0, pEmt, mEmt, pTsel);
515 Particle rec = Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
516 recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel);
519 if (dipSel->MEtype == 0
520 || findMEcorr( dipSel, rad, rec, emt,
false) > rndmPtr->flat() ) {
523 if (radBef.hasVertex()) {
524 rad.vProd( radBef.vProd() );
525 emt.vProd( radBef.vProd() );
527 if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
528 rad.tau( event[iRadBef].tau() );
529 rec.tau( event[iRecBef].tau() );
532 int iRad =
event.append(rad);
533 int iEmt =
event.append(emt);
534 event[iRadBef].statusNeg();
535 event[iRadBef].daughters( iRad, iEmt);
536 int iRec =
event.append(rec);
537 event[iRecBef].statusNeg();
538 event[iRecBef].daughters( iRec, iRec);
541 dipSel->iRadiator = iRad;
542 dipSel->iRecoiler = iRec;
543 dipSel->pTmax = pTsel;
546 for (
int i = 0; i < int(dipEnd.size()); ++i)
if (i != iDipSel) {
547 if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
548 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
549 if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
550 if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
551 if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
552 if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
557 pTLastBranch = pTsel;
564 }
while (pTmax > 0.);
575 void TimeShower::prepareGlobal(
Event& event) {
581 hardPartons.resize(0);
582 nFinalBorn = settingsPtr->mode(
"TimeShower:nPartonsInBorn");
588 for (
int i = 0; i <
event.size(); ++i) {
589 if (event[i].isFinal() &&
event[i].colType() != 0)
590 hardPartons.push_back(i);
591 if ( event[i].isFinal() && event[i].idAbs() > 5 && event[i].idAbs() != 21
592 && (event[i].col() != 0 || event[i].acol() != 0))
595 nHard = hardPartons.size();
596 if (nFinalBorn > 0 && nHard > nFinalBorn) {
597 hardPartons.resize(0);
603 string nNow = infoPtr->getEventAttribute(
"npNLO",
true);
604 if (nNow !=
"" && nFinalBorn == -1){
605 nFinalBorn = max(0, atoi((
char*)nNow.c_str()));
607 nFinalBorn += nHeavyCol;
616 void TimeShower::prepare(
int iSys,
Event& event,
bool limitPTmaxIn) {
619 if (iSys == 0) hasWeaklyRadiated =
false;
622 int iInA = partonSystemsPtr->getInA(iSys);
623 int iInB = partonSystemsPtr->getInB(iSys);
624 if (iSys == 0 || iInA == 0) dipEnd.resize(0);
625 int dipEndSizeBeg = dipEnd.size();
628 if (partonSystemsPtr->sizeOut(iSys) < 2)
return;
631 if (doSecondHard && iSys == 0) limitPTmaxIn = dopTlimit1;
632 if (doSecondHard && iSys == 1) limitPTmaxIn = dopTlimit2;
637 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
638 int ii = partonSystemsPtr->getOut( iSys, i);
639 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard) {
640 if ( event[ii].isAncestor(hardPartons[iHard])
641 || ii == hardPartons[iHard]){
650 if (isHard && nProposed.find(iSys) == nProposed.end() )
651 nProposed.insert(make_pair(iSys,0));
654 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
655 int iRad = partonSystemsPtr->getOut( iSys, i);
657 if (event[iRad].isFinal() && event[iRad].scale() > 0.) {
660 int idRad =
event[iRad].id();
661 int idRadAbs = abs(idRad);
662 bool isOctetOnium = particleDataPtr->isOctetHadron(idRad);
663 bool doQCD = doQCDshower;
664 if (doQCD && isOctetOnium)
665 doQCD = (rndmPtr->flat() < octetOniumFraction);
668 int colTag =
event[iRad].col();
669 if (doQCD && colTag > 0) setupQCDdip( iSys, i, colTag, 1, event,
670 isOctetOnium, limitPTmaxIn);
673 int acolTag =
event[iRad].acol();
674 if (doQCD && acolTag > 0) setupQCDdip( iSys, i, acolTag, -1, event,
675 isOctetOnium, limitPTmaxIn);
678 int chgType =
event[iRad].chargeType();
679 bool doChgDip = (chgType != 0)
680 && ( ( doQEDshowerByQ && event[iRad].isQuark() )
681 || ( doQEDshowerByL &&
event[iRad].isLepton() )
682 || ( doQEDshowerByOther && event[iRad].isResonance() ) );
683 int gamType = (idRad == 22) ? 1 : 0;
684 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
685 if (doChgDip || doGamDip) setupQEDdip( iSys, i, chgType, gamType,
686 event, limitPTmaxIn);
689 if (doWeakShower && (iSys == 0 || !partonSystemsPtr->hasInAB(iSys))
690 && (event[iRad].isQuark() ||
event[iRad].isLepton())
691 && (!weakExternal || iSys != 0) ) {
692 if (weakMode == 0 || weakMode == 1)
693 setupWeakdip( iSys, i, 1, event, limitPTmaxIn);
694 if (weakMode == 0 || weakMode == 2)
695 setupWeakdip( iSys, i, 2, event, limitPTmaxIn);
699 bool isHVrad = (idRadAbs > 4900000 && idRadAbs < 4900007)
700 || (idRadAbs > 4900010 && idRadAbs < 4900017)
701 || (idRadAbs > 4900100 && idRadAbs < 4900109);
702 if (doHVshower && isHVrad) setupHVdip( iSys, i, event, limitPTmaxIn);
709 if (doWeakShower && weakExternal && iSys == 0)
710 setupWeakdipExternal(event, limitPTmaxIn);
713 for (
int iDip = dipEndSizeBeg; iDip < int(dipEnd.size()); ++iDip)
714 findMEtype( event, dipEnd[iDip]);
717 if (iSys > 0 && ( (iInA > 0 && event[iInA].status() == -34)
718 || (iInB > 0 &&
event[iInB].status() == -34) ) )
719 rescatterUpdate( iSys, event);
727 void TimeShower::rescatterUpdate(
int iSys,
Event& event) {
731 for (
int iResc = 0; iResc < 2; ++iResc) {
732 int iIn = (iResc == 0) ? partonSystemsPtr->getInA(iSys)
733 : partonSystemsPtr->getInB(iSys);
734 if (iIn == 0 || event[iIn].status() != -34)
continue;
735 int iOut =
event[iIn].mother1();
738 int dipEndSize = dipEnd.size();
739 for (
int iDip = 0; iDip < dipEndSize; ++iDip) {
740 TimeDipoleEnd& dipNow = dipEnd[iDip];
743 if (dipNow.iRadiator == iOut) {
750 if (dipNow.iMEpartner == iOut) {
752 dipNow.iMEpartner = -1;
756 if (dipNow.iRecoiler == iOut) {
757 int iRad = dipNow.iRadiator;
760 if (dipNow.colType > 0) {
761 int colTag =
event[iRad].col();
763 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
764 int iRecNow = partonSystemsPtr->getOut( iSys, i);
765 if (event[iRecNow].acol() == colTag) {
766 dipNow.iRecoiler = iRecNow;
767 dipNow.systemRec = iSys;
774 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
775 : partonSystemsPtr->getInA(iSys);
776 if (event[iIn2].col() == colTag) {
777 dipNow.iRecoiler = iIn2;
778 dipNow.systemRec = iSys;
780 int isrType =
event[iIn2].mother1();
782 while (isrType > 2 + beamOffset)
783 isrType =
event[isrType].mother1();
784 if (isrType > 2) isrType -= beamOffset;
785 dipNow.isrType = isrType;
791 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
793 setupQCDdip(dipNow.system, iRadNow, event[iRad].col(), 1,
794 event, dipNow.isOctetOnium,
true);
796 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
797 "failed to locate radiator in system");
803 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
804 "failed to locate new recoiling colour partner");
808 }
else if (dipNow.colType < 0) {
809 int acolTag =
event[iRad].acol();
811 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
812 int iRecNow = partonSystemsPtr->getOut( iSys, i);
813 if (event[iRecNow].col() == acolTag) {
814 dipNow.iRecoiler = iRecNow;
815 dipNow.systemRec = iSys;
822 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
823 : partonSystemsPtr->getInA(iSys);
824 if (event[iIn2].acol() == acolTag) {
825 dipNow.iRecoiler = iIn2;
826 dipNow.systemRec = iSys;
828 int isrType =
event[iIn2].mother1();
830 while (isrType > 2 + beamOffset)
831 isrType =
event[isrType].mother1();
832 if (isrType > 2) isrType -= beamOffset;
833 dipNow.isrType = isrType;
839 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
841 setupQCDdip(dipNow.system, iRadNow, event[iRad].acol(), -1,
842 event, dipNow.isOctetOnium,
true);
844 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
845 "failed to locate radiator in system");
851 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
852 "failed to locate new recoiling colour partner");
856 }
else if (dipNow.chgType != 0 || dipNow.gamType != 0) {
857 int idTag =
event[dipNow.iRecoiler].id();
859 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
860 int iRecNow = partonSystemsPtr->getOut( iSys, i);
861 if (event[iRecNow].
id() == idTag) {
862 dipNow.iRecoiler = iRecNow;
863 dipNow.systemRec = iSys;
870 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
871 : partonSystemsPtr->getInA(iSys);
872 if (event[iIn2].
id() == -idTag) {
873 dipNow.iRecoiler = iIn2;
874 dipNow.systemRec = iSys;
876 int isrType =
event[iIn2].mother1();
878 while (isrType > 2 + beamOffset)
879 isrType =
event[isrType].mother1();
880 if (isrType > 2) isrType -= beamOffset;
881 dipNow.isrType = isrType;
887 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
889 setupQEDdip(dipNow.system, iRadNow, dipNow.chgType,
890 dipNow.gamType, event,
true);
892 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
893 "failed to locate radiator in system");
899 infoPtr->errorMsg(
"Warning in TimeShower::rescatterUpdate: "
900 "failed to locate new recoiling charge partner");
915 void TimeShower::update(
int iSys,
Event& event,
bool hasWeakRad) {
918 vector<int> iRescatterer;
921 vector<int> iNew, iOld;
922 iNew.push_back( partonSystemsPtr->getInA(iSys) );
923 iOld.push_back( event[iNew[0]].daughter2() );
924 iNew.push_back( partonSystemsPtr->getInB(iSys) );
925 iOld.push_back( event[iNew[1]].daughter2() );
928 int sizeOut = partonSystemsPtr->sizeOut(iSys) - 1;
929 for (
int i = 0; i < sizeOut; ++i) {
930 int iNow = partonSystemsPtr->getOut(iSys, i);
931 iNew.push_back( iNow );
932 iOld.push_back( event[iNow].mother1() );
934 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
936 int iNewNew = partonSystemsPtr->getOut(iSys, sizeOut);
939 if (event[iNew[0]].status() != -41) {
940 swap( iNew[0], iNew[1]);
941 swap( iOld[0], iOld[1]);
946 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
947 if (dipEnd[iDip].system == iSys || dipEnd[iDip].systemRec == iSys) {
948 TimeDipoleEnd& dipNow = dipEnd[iDip];
951 for (
int i = 2; i < 2 + sizeOut; ++i)
952 if (dipNow.iRadiator == iOld[i]) {
953 dipNow.iRadiator = iNew[i];
958 for (
int i = 2; i < 2 + sizeOut; ++i)
959 if (dipNow.iMEpartner == iOld[i]) {
960 dipNow.iMEpartner = iNew[i];
966 if (dipNow.systemRec == iSys) {
967 for (
int i = 1; i < 2 + sizeOut; ++i)
968 if (dipNow.iRecoiler == iOld[i]) {
974 if ( dipNow.colType > 0
975 && event[dipNow.iRadiator].col() ==
event[iNewNew].acol() ) {
979 if ( dipNow.colType < 0
980 && event[dipNow.iRadiator].acol() ==
event[iNewNew].col() ) {
986 if ( iRec == 0 && dipNow.colType > 0
987 && event[dipNow.iRadiator].col() ==
event[iNew[0]].col() )
989 if ( iRec == 0 && dipNow.colType < 0
990 && event[dipNow.iRadiator].acol() ==
event[iNew[0]].acol() )
994 if ( iRec == 0 && (dipNow.chgType != 0 || dipNow.gamType != 0) ) {
995 if ( event[iNew[0]].chargeType() == 0 ) {
1004 }
else iRec = dipNow.iRecoiler;
1007 dipNow.iRecoiler = iRec;
1008 if ( iRec == 0 && (dipNow.colType != 0 || dipNow.chgType != 0
1009 || dipNow.gamType != 0) ) {
1013 infoPtr->errorMsg(
"Error in TimeShower::update: "
1014 "failed to locate new recoiling partner");
1019 if (hasWeakRad && singleWeakEmission && dipNow.weakType != 0)
1020 dipNow.weakType = 0;
1024 if (hasWeakRad) hasWeaklyRadiated =
true;
1027 int colTag =
event[iNewNew].col();
1028 if (doQCDshower && colTag > 0)
1029 setupQCDdip( iSys, sizeOut, colTag, 1, event,
false,
true);
1032 int acolTag =
event[iNewNew].acol();
1033 if (doQCDshower && acolTag > 0)
1034 setupQCDdip( iSys, sizeOut, acolTag, -1, event,
false,
true);
1038 int chgType =
event[iNewNew].chargeType();
1039 bool doChgDip = (chgType != 0)
1040 && ( ( doQEDshowerByQ && event[iNewNew].isQuark() )
1041 || ( doQEDshowerByL &&
event[iNewNew].isLepton() ) );
1042 int gamType = (
event[iNewNew].id() == 22) ? 1 : 0;
1043 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
1044 if (doChgDip || doGamDip)
1045 setupQEDdip( iSys, sizeOut, chgType, gamType, event,
true);
1049 unsigned int nDips = dipEnd.size();
1050 if (doWeakShower && (event[iNewNew].isQuark() || event[iNewNew].isLepton())
1051 && !(hasWeaklyRadiated && singleWeakEmission)
1052 && (iSys == 0 || !partonSystemsPtr->hasInAB(iSys))) {
1054 if (weakMode == 0 || weakMode == 1)
1055 setupWeakdip( iSys, sizeOut, 1, event,
true);
1057 if (nDips != dipEnd.size()) {
1058 nDips = dipEnd.size();
1059 dipEnd.back().MEtype = 200;
1060 dipEnd.back().iMEpartner = dipEnd.back().iRecoiler;
1063 if (weakMode == 0 || weakMode == 2)
1064 setupWeakdip( iSys, sizeOut, 2, event,
true);
1066 if (nDips != dipEnd.size()) {
1067 nDips = dipEnd.size();
1068 dipEnd.back().MEtype = 205;
1069 dipEnd.back().iMEpartner = dipEnd.back().iRecoiler;
1075 while (++iRescNow <
int(iRescatterer.size())) {
1078 int iOutNew = iRescatterer[iRescNow];
1079 int iInNew =
event[iOutNew].daughter1();
1080 int iSysResc = partonSystemsPtr->getSystemOf(iInNew,
true);
1085 iNew.push_back( partonSystemsPtr->getInA(iSysResc) );
1086 iOld.push_back( event[iNew[0]].daughter1() );
1087 iNew.push_back( partonSystemsPtr->getInB(iSysResc) );
1088 iOld.push_back( event[iNew[1]].daughter1() );
1091 sizeOut = partonSystemsPtr->sizeOut(iSysResc);
1092 for (
int i = 0; i < sizeOut; ++i) {
1093 int iNow = partonSystemsPtr->getOut(iSysResc, i);
1094 iNew.push_back( iNow );
1095 iOld.push_back( event[iNow].mother1() );
1097 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
1102 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
1103 if (dipEnd[iDip].system == iSysResc
1104 || dipEnd[iDip].systemRec == iSysResc) {
1105 TimeDipoleEnd& dipNow = dipEnd[iDip];
1108 for (
int i = 2; i < 2 + sizeOut; ++i)
1109 if (dipNow.iRadiator == iOld[i]) {
1110 dipNow.iRadiator = iNew[i];
1115 for (
int i = 2; i < 2 + sizeOut; ++i)
1116 if (dipNow.iMEpartner == iOld[i]) {
1117 dipNow.iMEpartner = iNew[i];
1122 for (
int i = 0; i < 2 + sizeOut; ++i)
1123 if (dipNow.iRecoiler == iOld[i]) {
1124 dipNow.iRecoiler = iNew[i];
1138 void TimeShower::setupQCDdip(
int iSys,
int i,
int colTag,
int colSign,
1139 Event& event,
bool isOctetOnium,
bool limitPTmaxIn) {
1142 int iRad = partonSystemsPtr->getOut(iSys, i);
1144 int sizeAllA = partonSystemsPtr->sizeAll(iSys);
1145 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1146 int sizeAll = ( allowBeamRecoil ) ? sizeAllA : sizeOut;
1147 int sizeIn = sizeAll - sizeOut;
1148 int sizeInA = sizeAllA - sizeIn - sizeOut;
1149 int iOffset = i + sizeAllA - sizeOut;
1150 bool otherSystemRec =
false;
1151 bool allowInitial = (partonSystemsPtr->hasInAB(iSys)) ?
true :
false;
1154 bool isFlexible =
false;
1155 double flexFactor = 1.0;
1156 vector<int> iRecVec(0);
1161 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1162 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1163 if ( ( j < sizeIn && event[iRecNow].col() == colTag
1164 && !event[iRecNow].isRescatteredIncoming() )
1165 || ( j >= sizeIn && event[iRecNow].acol() == colTag
1166 && event[iRecNow].isFinal() ) ) {
1175 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1176 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1177 if ( ( j < sizeIn && event[iRecNow].acol() == colTag
1178 && !event[iRecNow].isRescatteredIncoming() )
1179 || ( j >= sizeIn && event[iRecNow].col() == colTag
1180 && event[iRecNow].isFinal() ) ) {
1190 bool hasJunction =
false;
1191 if (iRec == 0 && !allowInitial) {
1192 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
1196 int iBeg = (
event.kindJunction(iJun)-1)/2;
1197 for (
int iLeg = iBeg; iLeg < 3; ++iLeg)
1198 if (event.endColJunction( iJun, iLeg) == colTag) hasJunction =
true;
1200 double ppMin = LARGEM2;
1201 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1202 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1203 if (!event[iRecNow].isFinal())
continue;
1204 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1205 -
event[iRecNow].m() *
event[iRad].m();
1206 if (ppNow < ppMin) {
1214 if ( iRec == 0 || (!doInterleave && allowMPIdipole
1215 && !event[iRec].isFinal()) ) {
1216 for (
int j = 0; j <
event.size(); ++j)
if (event[j].isFinal()) {
1217 if ( (colSign > 0 && event[j].acol() == colTag)
1218 || (colSign < 0 &&
event[j].col() == colTag) ) {
1220 otherSystemRec =
true;
1226 if (iRec == 0 && allowInitial) {
1227 for (
int iSysR = 0; iSysR < partonSystemsPtr->sizeSys(); ++iSysR)
1228 if (iSysR != iSys) {
1229 int j = partonSystemsPtr->getInA(iSysR);
1230 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
1231 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
1232 || (colSign < 0 && event[j].acol() == colTag) ) ) {
1234 otherSystemRec =
true;
1237 j = partonSystemsPtr->getInB(iSysR);
1238 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
1239 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
1240 || (colSign < 0 && event[j].acol() == colTag) ) ) {
1242 otherSystemRec =
true;
1258 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
1259 int kindJun =
event.kindJunction(iJun);
1260 int iBeg = (kindJun-1)/2;
1261 for (
int iLeg = iBeg; iLeg < 3; ++iLeg) {
1262 if (event.endColJunction( iJun, iLeg) == colTag) {
1270 if (sizeOut == 1)
return;
1275 else if (kindJun >= 3) {
1276 int iLegRec = 3-iLeg;
1277 int colTagRec =
event.endColJunction( iJun, iLegRec);
1278 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1279 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1280 if (!event[iRecNow].isFinal())
continue;
1281 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
1282 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
1293 for (
int jLeg = 1; jLeg <= 2; jLeg++) {
1294 int iLegRec = (iLeg + jLeg) % 3;
1295 int colTagRec =
event.endColJunction( iJun, iLegRec);
1296 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1297 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1298 if (!event[iRecNow].isFinal())
continue;
1299 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
1300 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
1302 iRecVec.push_back(iRecNow);
1320 double ppMin = LARGEM2;
1321 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1322 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1323 if (!event[iRecNow].isFinal())
continue;
1324 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1325 -
event[iRecNow].m() *
event[iRad].m();
1326 if (ppNow < ppMin) {
1336 double ppMin = LARGEM2;
1337 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1338 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1339 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1340 -
event[iRecNow].m() *
event[iRad].m();
1341 if (ppNow < ppMin) {
1343 otherSystemRec =
true;
1350 if (iRecVec.size() == 0 && iRec != 0) iRecVec.push_back(iRec);
1353 int nRec = iRecVec.size();
1354 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec)
1355 if (iRecVec[mRec] <= 0) nRec--;
1358 flexFactor = 1.0/nRec;
1363 infoPtr->errorMsg(
"Error in TimeShower::setupQCDdip: "
1364 "failed to locate any recoiling partner");
1369 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec) {
1370 iRec = iRecVec[mRec];
1371 if (iRec <= 0)
continue;
1373 double pTmax =
event[iRad].scale();
1375 if (iSys == 0 || (iSys == 1 && doSecondHard)) pTmax *= pTmaxFudge;
1376 else if (sizeIn > 0) pTmax *= pTmaxFudgeMPI;
1377 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1378 int colType = (
event[iRad].id() == 21) ? 2 * colSign : colSign;
1379 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1381 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1382 if (isrType > 2) isrType -= beamOffset;
1383 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax,
1384 colType, 0, 0, 0, isrType, iSys, -1, -1, 0, isOctetOnium) );
1387 if (otherSystemRec) {
1388 int systemRec = partonSystemsPtr->getSystemOf(iRec,
true);
1389 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1390 dipEnd.back().MEtype = 0;
1396 dipEnd.back().isFlexible =
true;
1397 dipEnd.back().flexFactor = flexFactor;
1408 void TimeShower::setupQEDdip(
int iSys,
int i,
int chgType,
int gamType,
1409 Event& event,
bool limitPTmaxIn) {
1412 int iRad = partonSystemsPtr->getOut(iSys, i);
1413 int idRad =
event[iRad].id();
1415 int sizeAllA = partonSystemsPtr->sizeAll(iSys);
1416 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1417 int sizeAll = ( allowBeamRecoil ) ? sizeAllA : sizeOut;
1418 int sizeIn = sizeAll - sizeOut;
1419 int sizeInA = sizeAllA - sizeIn - sizeOut;
1420 int iOffset = i + sizeAllA - sizeOut;
1421 double ppMin = LARGEM2;
1422 bool hasRescattered =
false;
1423 bool otherSystemRec =
false;
1429 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1430 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1431 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
1432 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
1433 if ( (j < sizeIn && event[iRecNow].
id() == idRad)
1434 || (j >= sizeIn && event[iRecNow].
id() == -idRad) ) {
1435 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1436 -
event[iRecNow].m() *
event[iRad].m();
1437 if (ppNow < ppMin) {
1442 }
else hasRescattered =
true;
1447 if (iRec == 0 && hasRescattered) {
1448 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1449 if (event[iRecNow].
id() == -idRad &&
event[iRecNow].isFinal()) {
1450 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1451 -
event[iRecNow].m() *
event[iRad].m();
1452 if (ppNow < ppMin) {
1455 otherSystemRec =
true;
1463 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1464 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1465 int chgTypeRecNow =
event[iRecNow].chargeType();
1466 if (chgTypeRecNow == 0)
continue;
1467 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
1468 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
1469 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1470 -
event[iRecNow].m() *
event[iRad].m())
1471 / pow2(chgTypeRecNow);
1472 if (ppNow < ppMin) {
1481 if (iRec == 0 && hasRescattered) {
1482 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1483 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1484 int chgTypeRecNow =
event[iRecNow].chargeType();
1485 if (chgTypeRecNow != 0 && event[iRecNow].isFinal()) {
1486 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1487 -
event[iRecNow].m() *
event[iRad].m())
1488 / pow2(chgTypeRecNow);
1489 if (ppNow < ppMin) {
1492 otherSystemRec =
true;
1500 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1501 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1502 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1503 -
event[iRecNow].m() *
event[iRad].m();
1504 if (ppNow < ppMin) {
1512 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1513 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1514 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1515 -
event[iRecNow].m() *
event[iRad].m();
1516 if (ppNow < ppMin) {
1519 otherSystemRec =
true;
1526 double pTmax =
event[iRad].scale();
1528 if (iSys == 0 || (iSys == 1 && doSecondHard)) pTmax *= pTmaxFudge;
1529 else if (sizeIn > 0) pTmax *= pTmaxFudgeMPI;
1530 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1531 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1533 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1534 if (isrType > 2) isrType -= beamOffset;
1535 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1536 0, chgType, gamType, 0, isrType, iSys, -1) );
1539 if (otherSystemRec) {
1540 int systemRec = partonSystemsPtr->getSystemOf(iRec);
1541 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1542 dipEnd.back().MEtype = 0;
1547 infoPtr->errorMsg(
"Error in TimeShower::setupQEDdip: "
1548 "failed to locate any recoiling partner");
1557 void TimeShower::setupWeakdip(
int iSys,
int i,
int weakType,
Event& event,
1558 bool limitPTmaxIn) {
1561 int iRad = partonSystemsPtr->getOut(iSys, i);
1562 int idRad =
event[iRad].id();
1564 int sizeAllA = partonSystemsPtr->sizeAll(iSys);
1565 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1567 int sizeAll = sizeOut;
1568 int sizeIn = sizeAll - sizeOut;
1569 int sizeInA = sizeAllA - sizeIn - sizeOut;
1570 int iOffset = i + sizeAllA - sizeOut;
1571 double ppMin = LARGEM2;
1572 bool hasRescattered =
false;
1573 bool otherSystemRec =
false;
1579 for (
int j = 0; j < sizeAll; ++j)
1580 if (j + sizeInA != iOffset) {
1581 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1582 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
1583 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
1584 if ( (j < sizeIn && event[iRecNow].
id() == idRad)
1585 || (j >= sizeIn && event[iRecNow].
id() == -idRad) ) {
1586 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1587 -
event[iRecNow].m() *
event[iRad].m();
1588 if (ppNow < ppMin) {
1593 }
else hasRescattered =
true;
1598 if (iRec == 0 && hasRescattered) {
1599 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1600 if (event[iRecNow].
id() == -idRad &&
event[iRecNow].isFinal()) {
1601 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1602 -
event[iRecNow].m() *
event[iRad].m();
1603 if (ppNow < ppMin) {
1606 otherSystemRec =
true;
1614 for (
int j = 0; j < sizeAll; ++j)
if (j + sizeInA != iOffset) {
1615 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInA);
1616 if (abs(event[iRecNow].
id()) >= 20 || weakType < 1
1617 || weakType > 2)
continue;
1618 double weakCoupNow = 1.;
1619 if (weakType == 2) weakCoupNow = coupSMPtr->vf2(event[iRecNow].idAbs())
1620 + coupSMPtr->af2(event[iRecNow].idAbs());
1621 if ( (j < sizeIn && !event[iRecNow].isRescatteredIncoming())
1622 || (j >= sizeIn && event[iRecNow].isFinal()) ) {
1623 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1624 -
event[iRecNow].m() *
event[iRad].m()) / weakCoupNow;
1625 if (ppNow < ppMin) {
1634 if (iRec == 0 && hasRescattered) {
1635 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1636 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1637 if (abs(event[iRecNow].
id()) >= 20 || weakType < 1
1638 || weakType > 2)
continue;
1639 double weakCoupNow = 1.;
1640 if (weakType == 2) weakCoupNow = coupSMPtr->vf2(event[iRecNow].idAbs())
1641 + coupSMPtr->af2(event[iRecNow].idAbs());
1642 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1643 -
event[iRecNow].m() *
event[iRad].m()) / weakCoupNow;
1644 if (ppNow < ppMin) {
1647 otherSystemRec =
true;
1654 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1655 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1656 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1657 -
event[iRecNow].m() *
event[iRad].m();
1658 if (ppNow < ppMin) {
1666 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1667 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1668 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1669 -
event[iRecNow].m() *
event[iRad].m();
1670 if (ppNow < ppMin) {
1673 otherSystemRec =
true;
1681 Vec4 p3weak =
event[3].p();
1682 Vec4 p4weak =
event[4].p();
1683 double tHat = (
event[iRad].p() - p3weak).m2Calc();
1684 double uHat = (
event[iRad].p() - p4weak).m2Calc();
1687 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1689 if (event[iRad].intPol() == 1 ||
event[iRad].intPol() == -1)
1690 weakPol = event[iRad].intPol();
1692 else if (event[iRad].statusAbs() > 40) {
1693 if (event[event[iRad].mother1()].idAbs() < 20)
1694 weakPol = event[event[iRad].mother1()].intPol();
1695 else if (
int(event[iRad].sisterList(
true).size()) != 0)
1696 weakPol =
event[
event[iRad].sisterList(
true)[0]].intPol();
1699 else if (infoPtr->nFinal() != 2) {
1700 if (event[iRec].intPol() == 1 ||
event[iRec].intPol() == -1)
1701 weakPol = event[iRec].intPol();
1704 else if (idRad == - event[iRec].
id()) {
1705 if (event[iRec].intPol() == 1 ||
event[iRec].intPol() == -1)
1706 weakPol = event[iRec].intPol();
1709 else if (event[event[iRad].mother1()].idAbs() == 24) weakPol = -1;
1711 else if (idRad == event[iRec].
id()) {
1712 if (uHat*uHat/(tHat*tHat + uHat*uHat) > 0.5) weakPol =
event[3].intPol();
1713 else weakPol =
event[4].intPol();
1716 else if (event[3].
id() == idRad) weakPol =
event[3].intPol();
1717 else if (event[4].
id() == idRad) weakPol =
event[4].intPol();
1720 if (weakPol > 1) weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1721 event[iRad].pol(weakPol);
1724 double pTmax =
event[iRad].scale();
1726 if (iSys == 0) pTmax *= pTmaxFudge;
1727 if (iSys > 0 && sizeIn > 0) pTmax *= pTmaxFudgeMPI;
1728 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1729 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1731 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1732 if (isrType > 2) isrType -= beamOffset;
1735 if (weakType == 1 && weakPol == 1)
return;
1736 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1737 0, 0, 0, weakType, isrType, iSys, -1, -1, weakPol) );
1740 if (otherSystemRec) {
1741 int systemRec = partonSystemsPtr->getSystemOf(iRec);
1742 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1743 dipEnd.back().MEtype = 0;
1748 infoPtr->errorMsg(
"Error in TimeShower::setupWeakdip: "
1749 "failed to locate any recoiling partner");
1756 void TimeShower::setupWeakdipExternal(
Event& event,
bool limitPTmaxIn) {
1759 vector<pair<int,int> > weakDipoles = infoPtr->getWeakDipoles();
1760 vector<int> weakModes = infoPtr->getWeakModes();
1761 weakMomenta = infoPtr->getWeakMomenta();
1762 weak2to2lines = infoPtr->getWeak2to2lines();
1763 weakHardSize = int(weakModes.size());
1766 for (
int i = 0; i < int(weakDipoles.size()); ++i) {
1768 if (event[weakDipoles[i].first].status() > 0) {
1770 int iRad = weakDipoles[i].first;
1771 int iRec = weakDipoles[i].second;
1775 if (weakModes[weakDipoles[i].first] == 1) MEtypeWeak = 200;
1776 else if (weakModes[weakDipoles[i].first] == 2) MEtypeWeak = 201;
1777 else if (weakModes[weakDipoles[i].first] == 3) MEtypeWeak = 202;
1778 else MEtypeWeak = 203;
1782 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1783 if (event[weakDipoles[i].first].intPol() != 9)
1784 weakPol = event[weakDipoles[i].first].intPol();
1785 else if (event[weakDipoles[i].second].intPol() != 9) {
1786 if (event[weakDipoles[i].second].status() < 0)
1787 weakPol = event[weakDipoles[i].second].intPol();
1789 weakPol = -
event[weakDipoles[i].second].intPol();
1791 event[weakDipoles[i].first].pol(weakPol);
1794 double pTmax =
event[iRad].scale();
1797 pTmax *= pTmaxFudge;
1798 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1805 if ( (weakMode == 0 || weakMode == 1) && weakPol == -1)
1806 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1807 0, 0, 0, 1, isrType, 0, MEtypeWeak, -1, weakPol) );
1809 if (weakMode == 0 || weakMode == 2)
1810 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1811 0, 0, 0, 2, isrType, 0, MEtypeWeak +5, -1, weakPol) );
1816 for (
int i = 0;i < int(dipEnd.size()); ++i) {
1817 Vec4 p3weak, p4weak;
1818 if (dipEnd[i].MEtype > 200) {
1819 int i2to2Mother = dipEnd[i].iRadiator;
1820 while (i2to2Mother >= weakHardSize)
1821 i2to2Mother =
event[i2to2Mother].mother1();
1822 if (weak2to2lines[2] == i2to2Mother) {
1823 p3weak = weakMomenta[0];
1824 p4weak = weakMomenta[1];
1826 p3weak = weakMomenta[1];
1827 p4weak = weakMomenta[0];
1838 void TimeShower::setupHVdip(
int iSys,
int i,
Event& event,
1839 bool limitPTmaxIn) {
1842 int iRad = partonSystemsPtr->getOut(iSys, i);
1844 int idRad =
event[iRad].id();
1845 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1849 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1850 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1851 int idRec =
event[iRecNow].id();
1852 if ( (abs(idRec) > 4900000 && abs(idRec) < 4900017)
1853 && idRad * idRec < 0) {
1861 double mMax = -sqrt(LARGEM2);
1863 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1864 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1865 if (event[iRecNow].m() > mMax) {
1867 mMax =
event[iRecNow].m();
1874 double pTmax =
event[iRad].scale();
1876 if (iSys == 0 || (iSys == 1 && doSecondHard)) pTmax *= pTmaxFudge;
1877 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1878 int colvType = (
event[iRad].id() > 0) ? 1 : -1;
1879 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax, 0, 0, 0, 0, 0,
1880 iSys, -1, -1, 0,
false,
true, colvType) );
1881 }
else infoPtr->errorMsg(
"Error in TimeShower::setupHVdip: "
1882 "failed to locate any recoiling partner");
1890 double TimeShower::pTnext(
Event& event,
double pTbegAll,
double pTendAll,
1891 bool isFirstTrial,
bool doTrialIn) {
1896 double pT2sel = pTendAll * pTendAll;
1899 doTrialNow = doTrialIn;
1900 canEnhanceET = (!doTrialNow && canEnhanceEmission)
1901 || ( doTrialNow && canEnhanceTrial);
1904 splittingNameSel =
"";
1905 splittingNameNow =
"";
1906 enhanceFactors.clear();
1907 if (hasUserHooks) userHooksPtr->setEnhancedTrial(0., 1.);
1909 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
1910 TimeDipoleEnd& dip = dipEnd[iDip];
1915 bool hardSystem =
true;
1916 bool isQCD =
event[dip.iRadiator].colType() != 0;
1917 for (
int i = 0; i < partonSystemsPtr->sizeOut(dip.system); ++i) {
1918 int ii = partonSystemsPtr->getOut( dip.system, i);
1919 bool hasHardAncestor =
event[ii].statusAbs() < 23;
1920 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard){
1921 if ( event[ii].isAncestor(hardPartons[iHard])
1922 || ii == hardPartons[iHard]
1923 || (
event[ii].status() == 23 &&
event[ii].colType() == 0) )
1924 hasHardAncestor =
true;
1926 if (!hasHardAncestor) hardSystem =
false;
1930 useLocalRecoilNow = !(globalRecoil && hardSystem
1931 && partonSystemsPtr->sizeOut(dip.system) <= nMaxGlobalRecoil);
1934 if (globalRecoilMode == 1 && isQCD) {
1935 if (globalRecoil && hardSystem) useLocalRecoilNow =
true;
1936 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
1937 if ( event[dip.iRadiator].isAncestor(hardPartons[iHard]) )
1938 useLocalRecoilNow =
false;
1940 if ( !globalRecoil || nGlobal >= nMaxGlobalBranch )
1941 useLocalRecoilNow =
true;
1943 }
else if (globalRecoilMode == 2 && isQCD) {
1944 useLocalRecoilNow = !(globalRecoil && hardSystem
1945 && nProposed.find(dip.system) != nProposed.end()
1946 && nProposed[dip.system]-infoPtr->getCounter(40) == 0);
1948 for (
int k = 0; k < int(event.size()); ++k)
1949 if ( event[k].isFinal() &&
event[k].colType() != 0) nFinal++;
1950 bool isFirst = (nHard == nFinal);
1953 if ( globalRecoil && doInterleave && !isFirst )
1954 useLocalRecoilNow =
true;
1956 if ( nFinalBorn > 0 && nHard > nFinalBorn )
1957 useLocalRecoilNow =
true;
1961 dip.mRad =
event[dip.iRadiator].m();
1962 if (useLocalRecoilNow) {
1963 dip.mRec =
event[dip.iRecoiler].m();
1964 dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
1971 for (
int iS = 0; iS < partonSystemsPtr->sizeSys(); ++iS) {
1972 for (
int i = 0; i < partonSystemsPtr->sizeOut(iS); ++i) {
1973 int ii = partonSystemsPtr->getOut( iS, i);
1974 bool hasHardAncestor =
event[ii].statusAbs() < 23;
1975 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard) {
1976 if ( event[ii].isAncestor(hardPartons[iHard])
1977 || ii == hardPartons[iHard]
1978 || (
event[ii].status() == 23 &&
event[ii].colType() == 0) )
1979 hasHardAncestor =
true;
1981 if (hasHardAncestor && ii != dip.iRadiator && event[ii].isFinal() )
1982 pSumGlobal += event[ii].p();
1985 dip.mRec = pSumGlobal.mCalc();
1986 dip.mDip = m( event[dip.iRadiator].p(), pSumGlobal);
1988 dip.m2Rad = pow2(dip.mRad);
1989 dip.m2Rec = pow2(dip.mRec);
1990 dip.m2Dip = pow2(dip.mDip);
1993 dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
1994 double pTbegDip = min( pTbegAll, dip.pTmax );
1995 double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
1998 bool isFirstWimpy = !useLocalRecoilNow && (pTmaxMatch == 1)
1999 && nProposed.find(dip.system) != nProposed.end()
2000 && (nProposed[dip.system] - infoPtr->getCounter(40) == 0
2002 double muQ = (infoPtr->scalup() > 0.) ? infoPtr->scalup()
2004 if (isFirstWimpy && !limitMUQ) pT2begDip = pow2(muQ);
2005 else if (isFirstWimpy && limitMUQ) {
2007 double mS =
event[dip.iRecoiler].m();
2008 double mD = m( event[dip.iRadiator], event[dip.iRecoiler] );
2009 double m2DC = pow2(mD - mS) - pow2(dip.mRad);
2011 pT2begDip = min( pow2(muQ), min(pow2(pTbegDip), 0.25 * m2DC) );
2016 if (dip.m2DipCorr < 0.) {
2017 infoPtr->errorMsg(
"Warning in TimeShower::pTnext: "
2018 "negative dipole mass.");
2023 if (pT2begDip > pT2sel) {
2024 if (dip.colType != 0)
2025 pT2nextQCD(pT2begDip, pT2sel, dip, event);
2026 else if (dip.chgType != 0 || dip.gamType != 0)
2027 pT2nextQED(pT2begDip, pT2sel, dip, event);
2028 else if (dip.weakType != 0)
2029 pT2nextWeak(pT2begDip, pT2sel, dip, event);
2030 else if (dip.colvType != 0)
2031 pT2nextHV(pT2begDip, pT2sel, dip, event);
2034 if (dip.pT2 > pT2sel) {
2038 splittingNameSel = splittingNameNow;
2044 if (dipSel != 0 && nProposed.find(dipSel->system) != nProposed.end())
2045 ++nProposed[dipSel->system];
2048 return (dipSel == 0) ? 0. : sqrt(pT2sel);
2056 void TimeShower::pT2nextQCD(
double pT2begDip,
double pT2sel,
2057 TimeDipoleEnd& dip,
Event& event) {
2060 double pT2endDip = max( pT2sel, pT2colCut );
2061 if (pT2begDip < pT2endDip)
return;
2065 int colTypeAbs = abs(dip.colType);
2066 if (doDipoleRecoil && dip.isrType != 0 && colTypeAbs == 1)
return;
2071 double wtPSglue = 2.;
2072 double colFac = (colTypeAbs == 1) ? 4./3. : 3./2.;
2073 if (dip.MEgluinoRec) colFac = 3.;
2074 if (dip.isOctetOnium) colFac *= 0.5 * octetOniumColFac;
2077 if (dip.isFlexible) colFac *= dip.flexFactor;
2078 double wtPSqqbar = (colTypeAbs == 2)
2079 ? 0.25 * nGluonToQuark * extraGluonToQuark : 0.;
2082 dip.pT2 = pT2begDip;
2084 double zMinAbs = 0.5;
2085 double pT2min = pT2endDip;
2087 double Lambda2 = Lambda3flav2;
2088 double emitCoefGlue = 0.;
2089 double emitCoefQqbar = 0.;
2090 double emitCoefTot = 0.;
2092 bool mustFindRange =
true;
2096 doUncertaintiesNow = doUncertainties;
2097 if (!uVarMPIshowers && dip.system != 0
2098 && partonSystemsPtr->getInA(dip.system) != 0) doUncertaintiesNow =
false;
2099 double overFac = doUncertaintiesNow ? overFactor : 1.0;
2102 bool isEnhancedQ2QG, isEnhancedG2QQ, isEnhancedG2GG;
2103 isEnhancedQ2QG = isEnhancedG2QQ = isEnhancedG2GG =
false;
2104 double enhanceNow = 1.;
2105 string nameNow =
"";
2111 isEnhancedQ2QG = isEnhancedG2QQ = isEnhancedG2GG =
false;
2117 if (mustFindRange) {
2120 if (dip.pT2 > m2b) {
2122 pT2min = max( m2b, pT2endDip);
2124 Lambda2 = Lambda5flav2;
2125 }
else if (dip.pT2 > m2c) {
2127 pT2min = max( m2c, pT2endDip);
2129 Lambda2 = Lambda4flav2;
2134 Lambda2 = Lambda3flav2;
2137 Lambda2 /= renormMultFac;
2140 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2min / dip.m2DipCorr );
2141 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2min / dip.m2DipCorr;
2142 if (zMinAbs > 0.499) { dip.pT2 = 0.;
return; }
2145 emitCoefGlue = overFac * wtPSglue * colFac * log(1. / zMinAbs - 1.);
2147 if (canEnhanceET && colTypeAbs == 2)
2148 emitCoefGlue *= userHooksPtr->enhanceFactor(
"fsr:G2GG");
2149 if (canEnhanceET && colTypeAbs == 1)
2150 emitCoefGlue *= userHooksPtr->enhanceFactor(
"fsr:Q2QG");
2153 if (doDipoleRecoil && dip.isrType != 0 && colTypeAbs == 2)
2157 emitCoefTot = emitCoefGlue;
2158 if (colTypeAbs == 2 && event[dip.iRadiator].id() == 21) {
2159 emitCoefQqbar = overFac * wtPSqqbar * (1. - 2. * zMinAbs);
2162 emitCoefQqbar *= userHooksPtr->enhanceFactor(
"fsr:G2QQ");
2163 emitCoefTot += emitCoefQqbar;
2167 mustFindRange =
false;
2171 if (alphaSorder == 0) {
2172 dip.pT2 = dip.pT2 * pow( rndmPtr->flat(),
2173 1. / (alphaS2pi * emitCoefTot) );
2176 }
else if (alphaSorder == 1) {
2177 dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
2178 pow( rndmPtr->flat(), b0 / emitCoefTot) );
2182 do dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
2183 pow( rndmPtr->flat(), b0 / emitCoefTot) );
2184 while (alphaS.alphaS2OrdCorr(renormMultFac * dip.pT2) < rndmPtr->flat()
2185 && dip.pT2 > pT2min);
2190 if (nFlavour == 5 && dip.pT2 < m2b) {
2191 mustFindRange =
true;
2193 }
else if ( nFlavour == 4 && dip.pT2 < m2c) {
2194 mustFindRange =
true;
2199 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2204 if (colTypeAbs == 2 && emitCoefQqbar > rndmPtr->flat()
2205 * emitCoefTot) dip.flavour = 0;
2208 if (dip.flavour == 21) {
2209 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2211 dip.z = zMinAbs + (1. - 2. * zMinAbs) * rndmPtr->flat();
2215 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2216 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2217 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2218 if (dip.z > zMin && dip.z < 1. - zMin
2219 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2220 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2223 if (dip.flavour == 0) {
2224 dip.flavour = min(5, 1 +
int(nGluonToQuark * rndmPtr->flat()));
2225 dip.mFlavour = particleDataPtr->m0(dip.flavour);
2228 if (dip.flavour == 21
2229 && (colTypeAbs == 1 || colTypeAbs == 3) ) {
2230 nameNow =
"fsr:Q2QG";
2233 double enhance = userHooksPtr->enhanceFactor(nameNow);
2234 if (enhance != 1.) {
2235 enhanceNow = enhance;
2236 isEnhancedQ2QG =
true;
2239 }
else if (dip.flavour == 21) {
2240 nameNow =
"fsr:G2GG";
2243 double enhance = userHooksPtr->enhanceFactor(nameNow);
2244 if (enhance != 1.) {
2245 enhanceNow = enhance;
2246 isEnhancedG2GG =
true;
2250 if (dip.flavour < 4) nameNow =
"fsr:G2QQ";
2251 else if (dip.flavour == 4) nameNow =
"fsr:G2QQ:cc";
2252 else nameNow =
"fsr:G2QQ:bb";
2255 double enhance = userHooksPtr->enhanceFactor(nameNow);
2256 if (enhance != 1.) {
2257 enhanceNow = enhance;
2258 isEnhancedG2QQ =
true;
2264 if (dip.MEtype > 0) {
2266 if (dip.flavour < 10 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
2270 }
else if (dip.flavour == 21
2271 && (colTypeAbs == 1 || colTypeAbs == 3) ) {
2272 wt = (1. + pow2(dip.z)) / wtPSglue;
2275 }
else if (dip.flavour == 21) {
2276 wt = (1. + pow3(dip.z)) / wtPSglue;
2277 if (recoilDeadCone && dip.mRec > 0.) {
2278 double r2G = dip.m2Rec / dip.m2Dip;
2279 double x1G = (1. - r2G + dip.m2 / dip.m2Dip) * dip.z;
2280 double x2G = 1. + r2G - dip.m2 / dip.m2Dip;
2281 wt *= 1. - (r2G / max(XMARGIN, x1G + x2G - 1. - r2G))
2282 * (max(XMARGIN, 1. + r2G - x2G) / max(XMARGIN,1. - r2G - x1G));
2287 double ratioQ = pow2(dip.mFlavour) / dip.m2;
2288 double betaQ = sqrtpos( 1. - 4. * ratioQ );
2289 if (weightGluonToQuark%4 == 1) {
2290 wt = betaQ * ( pow2(dip.z) + pow2(1. - dip.z) );
2291 }
else if (weightGluonToQuark%4 == 2) {
2292 wt = betaQ * ( pow2(dip.z) + pow2(1. - dip.z)
2293 + 8. * ratioQ * dip.z * (1. - dip.z) );
2295 double m2Rat = dip.m2 / dip.m2DipCorr;
2296 double zCosThe = ((1. + m2Rat) * dip.z - m2Rat) / (1. - m2Rat);
2297 wt = betaQ * ( pow2(zCosThe) + pow2(1. - zCosThe)
2298 + 8. * ratioQ * zCosThe * (1. - zCosThe) )
2299 * (1. + m2Rat) / ((1. - m2Rat) * extraGluonToQuark) ;
2300 if (weightGluonToQuark%4 == 0) wt *= pow3(1. - m2Rat);
2302 if (weightGluonToQuark > 4 && alphaSorder > 0)
2303 wt *= log(dip.pT2 / Lambda2)
2304 / log(scaleGluonToQuark * dip.m2 / Lambda2);
2311 if (dip.isrType != 0 && useLocalRecoilNow) {
2312 BeamParticle&
beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2313 int iSysRec = dip.systemRec;
2314 double xOld = beam[iSysRec].x();
2315 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2316 (dip.m2Dip - dip.m2Rad));
2317 double xMaxAbs = beam.xMax(iSysRec);
2319 infoPtr->errorMsg(
"Warning in TimeShower::pT2nextQCD: "
2320 "xMaxAbs negative");
2326 if (xNew > 1.) wt = 0.;
2329 if (xNew > xMaxAbs) wt = 0.;
2331 int idRec =
event[dip.iRecoiler].id();
2332 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2333 : factorMultFac * dip.pT2;
2334 double pdfOld = max ( TINYPDF,
2335 beam.xfISR( iSysRec, idRec, xOld, pdfScale2) );
2337 beam.xfISR( iSysRec, idRec, xNew, pdfScale2);
2338 wt *= min( 1., pdfNew / pdfOld);
2342 if (dampenBeamRecoil) {
2343 double pTpT = sqrt(event[dip.iRadiator].pT2() * dip.pT2);
2344 wt *= pTpT / (pTpT + dip.m2);
2349 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2350 wt *= pT2damp / (dip.pT2 + pT2damp);
2355 if (wt > 0. && dip.pT2 > pT2min && doUncertaintiesNow) {
2361 }
while (wt < rndmPtr->flat());
2364 splittingNameNow = nameNow;
2366 if (isEnhancedQ2QG) storeEnhanceFactor(dip.pT2,
"fsr:Q2QG", enhanceNow);
2367 if (isEnhancedG2QQ) storeEnhanceFactor(dip.pT2,
"fsr:G2QQ", enhanceNow);
2368 if (isEnhancedG2GG) storeEnhanceFactor(dip.pT2,
"fsr:G2GG", enhanceNow);
2377 void TimeShower::pT2nextQED(
double pT2begDip,
double pT2sel,
2378 TimeDipoleEnd& dip,
Event& event) {
2381 double pT2chgCut = (dip.chgType != 0 && abs(dip.chgType) != 3)
2382 ? pT2chgQCut : pT2chgLCut;
2383 double pT2endDip = max( pT2sel, pT2chgCut );
2384 if (pT2begDip < pT2endDip)
return;
2387 bool hasCharge = (dip.chgType != 0);
2390 double wtPSgam = 0.;
2391 double chg2Sum = 0.;
2392 double chg2SumL = 0.;
2393 double chg2SumQ = 0.;
2394 double zMinAbs = 0.;
2395 double emitCoefTot = 0.;
2398 double alphaEMmax = alphaEM.alphaEM(renormMultFac * dip.m2DipCorr);
2399 double alphaEM2pi = alphaEMmax / (2. * M_PI);
2402 bool isEnhancedQ2QA, isEnhancedA2LL, isEnhancedA2QQ;
2403 isEnhancedQ2QA = isEnhancedA2LL = isEnhancedA2QQ =
false;
2404 double enhanceNow = 1.;
2405 string nameNow =
"";
2410 double chg2 = pow2(dip.chgType / 3.);
2413 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2414 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2415 emitCoefTot = alphaEM2pi * chg2 * wtPSgam * log(1. / zMinAbs - 1.);
2417 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QA");
2421 chg2SumL = max(0, min(3, nGammaToLepton));
2422 if (nGammaToQuark > 4) chg2SumQ = 11. / 9.;
2423 else if (nGammaToQuark > 3) chg2SumQ = 10. / 9.;
2424 else if (nGammaToQuark > 2) chg2SumQ = 6. / 9.;
2425 else if (nGammaToQuark > 1) chg2SumQ = 5. / 9.;
2426 else if (nGammaToQuark > 0) chg2SumQ = 1. / 9.;
2429 if (canEnhanceET) chg2SumL *= userHooksPtr->enhanceFactor(
"fsr:A2LL");
2430 if (canEnhanceET) chg2SumQ *= userHooksPtr->enhanceFactor(
"fsr:A2QQ");
2433 chg2Sum = chg2SumL + 3. * chg2SumQ;
2434 emitCoefTot = alphaEM2pi * chg2Sum * extraGluonToQuark;
2438 dip.pT2 = pT2begDip;
2446 isEnhancedQ2QA = isEnhancedA2LL = isEnhancedA2QQ =
false;
2451 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
2455 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2458 if (hasCharge) dip.z = 1. - zMinAbs
2459 * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2460 else dip.z = rndmPtr->flat();
2463 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2464 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2465 if (dip.z <= zMin || dip.z >= 1. - zMin)
continue;
2466 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2467 if (dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2468 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec)
2470 && (hasCharge || dip.m2 < m2MaxGamma) ) {
2479 if (rndmPtr->flat() * chg2Sum < chg2SumL)
2480 dip.flavour = 9 + 2 * min(3, 1 +
int(chg2SumL * rndmPtr->flat()));
2482 double rndmQ = 9. * chg2SumQ * rndmPtr->flat();
2483 if (rndmQ < 1.) dip.flavour = 1;
2484 else if (rndmQ < 5.) dip.flavour = 2;
2485 else if (rndmQ < 6.) dip.flavour = 3;
2486 else if (rndmQ < 10.) dip.flavour = 4;
2487 else dip.flavour = 5;
2489 dip.mFlavour = particleDataPtr->m0(dip.flavour);
2494 nameNow =
"fsr:Q2QA";
2497 double enhance = userHooksPtr->enhanceFactor(nameNow);
2498 if (enhance != 1.) {
2499 enhanceNow = enhance;
2500 isEnhancedQ2QA =
true;
2503 }
else if (dip.flavour > 10) {
2504 nameNow =
"fsr:A2LL";
2507 double enhance = userHooksPtr->enhanceFactor(nameNow);
2508 if (enhance != 1.) {
2509 enhanceNow = enhance;
2510 isEnhancedA2LL =
true;
2514 nameNow =
"fsr:A2QQ";
2517 double enhance = userHooksPtr->enhanceFactor(nameNow);
2518 if (enhance != 1.) {
2519 enhanceNow = enhance;
2520 isEnhancedA2QQ =
true;
2526 if (dip.MEtype > 0) {
2528 if (dip.flavour < 20 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
2532 }
else if (hasCharge) {
2533 wt = (1. + pow2(dip.z)) / wtPSgam;
2537 double ratioF = pow2(dip.mFlavour) / dip.m2;
2538 double betaF = sqrtpos( 1. - 4. * ratioF );
2539 if (weightGluonToQuark%4 == 1) {
2540 wt = betaF * ( pow2(dip.z) + pow2(1. - dip.z) );
2541 }
else if (weightGluonToQuark%4 == 2) {
2542 wt = betaF * ( pow2(dip.z) + pow2(1. - dip.z)
2543 + 8. * ratioF * dip.z * (1. - dip.z) );
2545 double m2Rat = dip.m2 / dip.m2DipCorr;
2546 double zCosThe = ((1. + m2Rat) * dip.z - m2Rat) / (1. - m2Rat);
2547 wt = betaF * ( pow2(zCosThe) + pow2(1. - zCosThe)
2548 + 8. * ratioF * zCosThe * (1. - zCosThe) )
2549 * (1. + m2Rat) / ((1. - m2Rat) * extraGluonToQuark) ;
2550 if (weightGluonToQuark%4 == 0) wt *= pow3(1. - m2Rat);
2555 double aEMscale = dip.pT2;
2556 if (dip.flavour < 20 && weightGluonToQuark > 4)
2557 aEMscale = scaleGluonToQuark * dip.m2;
2558 double alphaEMnow = alphaEM.alphaEM(renormMultFac * aEMscale);
2559 wt *= (alphaEMnow / alphaEMmax);
2562 if (dip.isrType != 0 && useLocalRecoilNow) {
2563 BeamParticle& beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2564 int iSys = dip.system;
2565 double xOld = beam[iSys].x();
2566 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2567 (dip.m2Dip - dip.m2Rad));
2568 double xMaxAbs = beam.xMax(iSys);
2570 infoPtr->errorMsg(
"Warning in TimeShower::pT2nextQED: "
2571 "xMaxAbs negative");
2577 if (xNew > 1.) wt = 0.;
2580 if (xNew > xMaxAbs) wt = 0.;
2582 int idRec =
event[dip.iRecoiler].id();
2583 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2584 : factorMultFac * dip.pT2;
2585 double pdfOld = max ( TINYPDF,
2586 beam.xfISR( iSys, idRec, xOld, pdfScale2) );
2588 beam.xfISR( iSys, idRec, xNew, pdfScale2);
2589 wt *= min( 1., pdfNew / pdfOld);
2593 if (dampenBeamRecoil) {
2594 double pT24 = 4. *
event[dip.iRadiator].pT2();
2595 wt *= pT24 / (pT24 + dip.m2);
2600 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2601 wt *= pT2damp / (dip.pT2 + pT2damp);
2605 }
while (wt < rndmPtr->flat());
2608 splittingNameNow = nameNow;
2610 if (isEnhancedQ2QA) storeEnhanceFactor(dip.pT2,
"fsr:Q2QA", enhanceNow);
2611 if (isEnhancedA2LL) storeEnhanceFactor(dip.pT2,
"fsr:A2LL", enhanceNow);
2612 if (isEnhancedA2QQ) storeEnhanceFactor(dip.pT2,
"fsr:A2QQ", enhanceNow);
2621 void TimeShower::pT2nextWeak(
double pT2begDip,
double pT2sel,
2622 TimeDipoleEnd& dip,
Event& event) {
2625 double pT2endDip = max( pT2sel, pT2weakCut );
2626 if (pT2begDip < pT2endDip)
return;
2629 double wtPSgam = 0.;
2630 double zMinAbs = 0.;
2631 double emitCoefTot = 0.;
2634 double alphaEMmax = alphaEM.alphaEM(renormMultFac * pT2begDip);
2635 double alphaEM2pi = alphaEMmax / (2. * M_PI);
2641 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2642 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2645 double weakCoupling = 0.;
2648 if (dip.weakType == 1)
2649 weakCoupling = 2. * alphaEM2pi / (4. * coupSMPtr->sin2thetaW());
2651 else if (dip.weakType == 2 && dip.weakPol == -1)
2652 weakCoupling = alphaEM2pi * thetaWRat
2653 * pow2(2. * coupSMPtr->lf( event[dip.iRadiator].idAbs() ));
2655 weakCoupling = alphaEM2pi * thetaWRat
2656 * pow2(2. * coupSMPtr->rf( event[dip.iRadiator].idAbs() ));
2659 bool isEnhancedQ2QW;
2660 isEnhancedQ2QW =
false;
2661 double enhanceNow = 1.;
2662 string nameNow =
"";
2665 emitCoefTot = weakEnhancement * weakCoupling
2666 * wtPSgam * log(1. / zMinAbs - 1.);
2668 if ( dip.MEtype == 201 || dip.MEtype == 202 || dip.MEtype == 203
2669 || dip.MEtype == 206 || dip.MEtype == 207 || dip.MEtype == 208 )
2670 emitCoefTot *= WEAKPSWEIGHT;
2671 dip.pT2 = pT2begDip;
2675 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QW");
2681 isEnhancedQ2QW =
false;
2686 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
2690 if ( dip.pT2 < pT2endDip) {dip.pT2 = 0.;
return; }
2693 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2696 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2697 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2698 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2699 if (dip.z > zMin && dip.z < 1. - zMin
2700 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2701 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2704 if (dip.weakType == 1) {
2705 dip.flavour = (
event[dip.iRadiator].id() > 0) ? 24 : -24;
2706 if (event[dip.iRadiator].idAbs() % 2 == 1) dip.flavour = -dip.flavour;
2707 }
else if (dip.weakType == 2) dip.flavour = 23;
2710 dip.mFlavour = particleDataPtr->mSel( dip.flavour);
2714 if (dip.MEtype > 0) wt = 1.;
2717 double alphaEMnow = alphaEM.alphaEM(renormMultFac * dip.pT2);
2718 wt *= (alphaEMnow / alphaEMmax);
2720 nameNow =
"fsr:Q2QW";
2723 double enhance = userHooksPtr->enhanceFactor(nameNow);
2724 if (enhance != 1.) {
2725 enhanceNow = enhance;
2726 isEnhancedQ2QW =
true;
2731 if (dip.isrType != 0 && useLocalRecoilNow) {
2732 BeamParticle& beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2733 int iSys = dip.system;
2734 double xOld = beam[iSys].x();
2735 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2736 (dip.m2Dip - dip.m2Rad));
2737 double xMaxAbs = beam.xMax(iSys);
2739 infoPtr->errorMsg(
"Warning in TimeShower::pT2nextWeak: "
2740 "xMaxAbs negative");
2746 if (xNew > 1.) wt = 0.;
2749 if (xNew > xMaxAbs) wt = 0.;
2751 int idRec =
event[dip.iRecoiler].id();
2752 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2753 : factorMultFac * dip.pT2;
2754 double pdfOld = max ( TINYPDF,
2755 beam.xfISR( iSys, idRec, xOld, pdfScale2) );
2757 beam.xfISR( iSys, idRec, xNew, pdfScale2);
2758 wt *= min( 1., pdfNew / pdfOld);
2761 if (dampenBeamRecoil) {
2762 double pT24 = 4. *
event[dip.iRadiator].pT2();
2763 wt *= pT24 / (pT24 + dip.m2);
2769 if (dopTdamp && dip.system == 0) wt *= pT2damp / (dip.pT2 + pT2damp);
2772 }
while (wt < rndmPtr->flat());
2775 splittingNameNow = nameNow;
2776 if (canEnhanceET && isEnhancedQ2QW)
2777 storeEnhanceFactor(dip.pT2,
"fsr:Q2QW", enhanceNow);
2785 void TimeShower::pT2nextHV(
double pT2begDip,
double pT2sel,
2786 TimeDipoleEnd& dip,
Event& ) {
2789 double pT2endDip = max( pT2sel, pT2hvCut );
2790 if (pT2begDip < pT2endDip)
return;
2793 int colvTypeAbs = abs(dip.colvType);
2794 double colvFac = (colvTypeAbs == 1) ? CFHV : 0.5 * nCHV;
2795 double alphaHV2pi = alphaHVfix / (2. * M_PI);
2796 double b0HV = (11. /6. * nCHV - 2. / 6. * nFlavHV);
2799 double zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2800 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2801 double emitCoefTot = colvFac * 2. * log(1. / zMinAbs - 1.);
2802 double LambdaHV2 = pow2(LambdaHV);
2805 dip.pT2 = pT2begDip;
2809 bool isEnhancedQ2QHV;
2810 isEnhancedQ2QHV =
false;
2811 double enhanceNow = 1.;
2812 string nameNow =
"";
2815 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QHV");
2821 isEnhancedQ2QHV =
false;
2826 if (alphaHVorder == 0) {
2827 dip.pT2 = dip.pT2 * pow( rndmPtr->flat(),
2828 1. / (alphaHV2pi * emitCoefTot) );
2829 }
else if (alphaHVorder == 1) {
2830 dip.pT2 = LambdaHV2 * pow( dip.pT2 / LambdaHV2,
2831 pow( rndmPtr->flat(), b0HV / emitCoefTot) );
2836 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2839 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2842 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2843 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2844 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2845 if (dip.z > zMin && dip.z < 1. - zMin
2846 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2847 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2854 if (dip.MEtype > 0) wt = 1.;
2857 else if (colvTypeAbs == 1) wt = (1. + pow2(dip.z)) / 2.;
2858 else wt = (1. + pow3(dip.z)) / 2.;
2860 nameNow =
"fsr:Q2QHV";
2863 double enhance = userHooksPtr->enhanceFactor(nameNow);
2864 if (enhance != 1.) {
2865 enhanceNow = enhance;
2866 isEnhancedQ2QHV =
true;
2873 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2874 wt *= pT2damp / (dip.pT2 + pT2damp);
2877 }
while (wt < rndmPtr->flat());
2880 splittingNameNow = nameNow;
2881 if (canEnhanceET && isEnhancedQ2QHV)
2882 storeEnhanceFactor(dip.pT2,
"fsr:Q2QHV", enhanceNow);
2893 bool TimeShower::branch(
Event& event,
bool isInterleaved) {
2897 bool hardSystem =
true;
2898 bool isQCD =
event[dipSel->iRadiator].colType() != 0;
2899 for (
int i = 0; i < partonSystemsPtr->sizeOut(dipSel->system); ++i) {
2900 int ii = partonSystemsPtr->getOut( dipSel->system, i);
2901 bool hasHardAncestor =
event[ii].statusAbs() < 23;
2902 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard){
2903 if ( event[ii].isAncestor(hardPartons[iHard])
2904 || ii == hardPartons[iHard]
2905 || (
event[ii].status() == 23 &&
event[ii].colType() == 0))
2906 hasHardAncestor =
true;
2908 if (!hasHardAncestor) hardSystem =
false;
2912 useLocalRecoilNow = !(globalRecoil && hardSystem
2913 && partonSystemsPtr->sizeOut(dipSel->system) <= nMaxGlobalRecoil);
2916 if (globalRecoilMode == 1 && isQCD) {
2917 if ( globalRecoil && hardSystem) useLocalRecoilNow =
true;
2918 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
2919 if ( event[dipSel->iRadiator].isAncestor(hardPartons[iHard]) )
2920 useLocalRecoilNow =
false;
2922 if ( !globalRecoil || nGlobal >= nMaxGlobalBranch )
2923 useLocalRecoilNow =
true;
2926 }
else if (globalRecoilMode == 2 && isQCD) {
2927 useLocalRecoilNow = !(globalRecoil
2928 && nProposed.find(dipSel->system) != nProposed.end()
2929 && nProposed[dipSel->system] - infoPtr->getCounter(40) == 1);
2932 for (
int i = 0; i < int(event.size()); ++i)
2933 if ( event[i].isFinal() &&
event[i].colType() != 0) nFinal++;
2934 bool isFirst = (nHard == nFinal);
2935 if ( globalRecoil && doInterleave && !isFirst )
2936 useLocalRecoilNow =
true;
2938 if ( nFinalBorn > 0 && nHard > nFinalBorn )
2939 useLocalRecoilNow =
true;
2943 bool canMergeFirst = (mergingHooksPtr != 0)
2944 ? mergingHooksPtr->canVetoEmission() :
false;
2946 int npartons = 0, nfinal = 0, nw = 0, nz = 0;
2947 for (
int i = 0; i <
event.size(); ++i) {
if(event[i].isFinal() ) {
2949 if (event[i].colType() != 0) npartons++;
2950 if (event[i].
id() == 23) nz++;
2951 if (event[i].idAbs() == 24) nw++;
2956 int iRadBef = dipSel->iRadiator;
2957 int iRecBef = dipSel->iRecoiler;
2958 Particle& radBef =
event[iRadBef];
2959 Particle& recBef =
event[iRecBef];
2962 Vec4 pRadBef =
event[iRadBef].p();
2964 vector<int> iGRecBef, iGRec;
2965 if (useLocalRecoilNow) pRecBef =
event[iRecBef].p();
2969 for (
int iS = 0; iS < partonSystemsPtr->sizeSys(); ++iS) {
2970 for (
int i = 0; i < partonSystemsPtr->sizeOut(iS); ++i) {
2971 int iG = partonSystemsPtr->getOut( iS, i);
2972 bool hasHardAncestor =
event[iG].statusAbs() < 23;
2973 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
2974 if ( event[iG].isAncestor(hardPartons[iHard])
2975 || iG == hardPartons[iHard]
2976 || (
event[iG].status() == 23 &&
event[iG].colType() == 0))
2977 hasHardAncestor =
true;
2978 if (hasHardAncestor && iG != dipSel->iRadiator
2979 && event[iG].isFinal() ) {
2980 iGRecBef.push_back(iG);
2981 pRecBef +=
event[iG].p();
2988 Vec4 p3weak =
event[3].p();
2989 Vec4 p4weak =
event[4].p();
2990 if ( dipSel->MEtype == 201 || dipSel->MEtype == 202
2991 || dipSel->MEtype == 203 || dipSel->MEtype == 206
2992 || dipSel->MEtype == 207 || dipSel->MEtype == 208) {
2993 if (!weakExternal) {
2995 int i2to2Mother = iRadBef;
2996 while (i2to2Mother != 5 && i2to2Mother != 6 && i2to2Mother != 0)
2997 i2to2Mother =
event[i2to2Mother].mother1();
2998 if (i2to2Mother == 0)
return false;
3001 if (event[3].
id() != event[4].
id()) {
3002 if (event[3].
id() == event[i2to2Mother].
id());
3003 else if (event[4].
id() == event[i2to2Mother].
id())
3004 swap(p3weak, p4weak);
3006 else if (rndmPtr->flat() < 0.5) swap(p3weak, p4weak);
3009 else if (rndmPtr->flat() < 0.5) swap(p3weak, p4weak);
3011 int i2to2Mother = iRadBef;
3012 while (i2to2Mother >= weakHardSize)
3013 i2to2Mother =
event[i2to2Mother].mother1();
3014 if (weak2to2lines[2] == i2to2Mother) {
3015 p3weak = weakMomenta[0];
3016 p4weak = weakMomenta[1];
3018 p3weak = weakMomenta[1];
3019 p4weak = weakMomenta[0];
3025 int idRad = radBef.id();
3026 int idEmt = dipSel->flavour;
3027 int colRad = radBef.col();
3028 int acolRad = radBef.acol();
3031 iSysSel = dipSel->system;
3032 int iSysSelRec = dipSel->systemRec;
3035 if (dipSel->flavour == 22 || dipSel->flavour == idHV) {
3037 }
else if (dipSel->flavour == 21 && dipSel->colType > 0) {
3039 colRad =
event.nextColTag();
3041 }
else if (dipSel->flavour == 21) {
3043 acolRad =
event.nextColTag();
3046 }
else if (dipSel->colType > 0) {
3047 idEmt = dipSel->flavour ;
3051 }
else if (dipSel->colType < 0) {
3052 idEmt = -dipSel->flavour ;
3057 }
else if (dipSel->gamType == 1 && rndmPtr->flat() > 0.5) {
3058 idEmt = -dipSel->flavour ;
3060 if (idRad < 10) colRad =
event.nextColTag();
3062 }
else if (dipSel->gamType == 1) {
3063 idEmt = dipSel->flavour ;
3065 if (idEmt < 10) colEmt =
event.nextColTag();
3070 int idRadSv = idRad;
3071 if (abs(idEmt) == 24) {
3072 if (rndmPtr->flat() > coupSMPtr->V2CKMsum(idRad))
return false;
3073 idRad = coupSMPtr->V2CKMpick(idRad);
3078 double pTorig = sqrt( dipSel->pT2);
3079 double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
3081 double e2RadPlusEmt = pow2(eRadPlusEmt);
3082 double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
3083 - dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
3084 double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z * (1. - dipSel->z)
3085 - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
3086 double pTcorr = sqrtpos( pT2corr );
3087 double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
3089 double pzEmt = (e2RadPlusEmt * (1. - dipSel->z) - 0.5 * dipSel->m2)
3092 double mRad = (idRad == idRadSv) ? dipSel->mRad
3093 : particleDataPtr->m0(idRad);
3094 double m2Rad = pow2(mRad);
3099 if ( dipSel->weakType != 0
3100 || (abs(dipSel->colvType) == 1 && dipSel->mFlavour > 0.) ) {
3101 mEmt = dipSel->mFlavour;
3102 if (pow2(mRad + mEmt) > dipSel->m2)
return false;
3103 double m2Emt = pow2(mEmt);
3104 double lambda = sqrtpos( pow2(dipSel->m2 - m2Rad - m2Emt)
3105 - 4. * m2Rad * m2Emt );
3106 kRad = 0.5 * (dipSel->m2 - lambda + m2Emt - m2Rad)
3108 kEmt = 0.5 * (dipSel->m2 - lambda + m2Rad - m2Emt)
3110 pTorig *= 1. - kRad - kEmt;
3111 pTcorr *= 1. - kRad - kEmt;
3112 double pzMove = kRad * pzRad - kEmt * pzEmt;
3117 }
else if (abs(dipSel->colType) == 1 || dipSel->chgType != 0
3118 || abs(dipSel->colvType) == 1) {
3119 pTorig *= 1. - dipSel->m2Rad / dipSel->m2;
3120 pTcorr *= 1. - dipSel->m2Rad / dipSel->m2;
3121 pzRad += pzEmt * dipSel->m2Rad / dipSel->m2;
3122 pzEmt *= 1. - dipSel->m2Rad / dipSel->m2;
3125 }
else if (abs(dipSel->flavour) < 20) {
3126 mEmt = dipSel->mFlavour;
3128 double beta = sqrtpos( 1. - 4. * pow2(mEmt) / dipSel->m2 );
3131 pzRad = 0.5 * ( (1. + beta) * pzRad + (1. - beta) * pzEmt );
3132 pzEmt = pzRadPlusEmt - pzRad;
3136 if (idEmt == 21 && pTorig < pTcolCut)
return false;
3140 M.fromCMframe(pRadBef, pRecBef);
3142 M1.fromCMframe(pRadBef, pRecBef);
3144 M2.toCMframe(pRadBef, pRecBef);
3147 findAsymPol( event, dipSel);
3150 Vec4 pRad, pEmt, pRec;
3153 double phi = 2. * M_PI * rndmPtr->flat();
3156 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
3157 sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
3158 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
3159 sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
3160 pRec = Vec4( 0., 0., -pzRadPlusEmt, sqrt( pow2(pzRadPlusEmt)
3161 + dipSel->m2Rec ) );
3170 if (dipSel->isrType != 0) {
3171 if (abs(pRec.px()) > 0.) {
3172 double phixx = pRec.phi();
3173 RotBstMatrix rot_by_pphi;
3174 rot_by_pphi.rot(0.,-phixx);
3175 pRec.rotbst( rot_by_pphi);
3176 double thetaxx = pRec.theta();
3177 if ( pRec.px() < 0. ) thetaxx *= -1.;
3178 if ( pRec.pz() < 0.) thetaxx += M_PI;
3179 RotBstMatrix rot_by_ptheta;
3180 rot_by_ptheta.rot(-thetaxx, 0.);
3181 pRec.rotbst( rot_by_ptheta );
3186 if (dipSel->asymPol != 0.) {
3187 Vec4 pAunt =
event[dipSel->iAunt].p();
3188 double cosPhi = cosphi( pRad, pAunt, pRadBef );
3189 wtPhi = ( 1. + dipSel->asymPol * (2. * pow2(cosPhi) - 1.) )
3190 / ( 1. + abs(dipSel->asymPol) );
3192 }
while (wtPhi < rndmPtr->flat()) ;
3195 int isrTypeNow = dipSel->isrType;
3196 int isrTypeSave = isrTypeNow;
3197 if (!useLocalRecoilNow) isrTypeNow = 0;
3198 if (isrTypeNow != 0) pRec = 2. * recBef.p() - pRec;
3201 if ( isrTypeNow != 0 && 2.*pRec.e()/
event[0].m() > 1. ) {
3202 infoPtr->errorMsg(
"Error in TimeShower::branch: "
3203 "Larger than unity Bjorken x value");
3208 bool isFlexible = dipSel->isFlexible;
3211 double pTsel = sqrt(dipSel->pT2);
3212 Particle rad = Particle(idRad, 51, iRadBef, 0, 0, 0,
3213 colRad, acolRad, pRad, mRad, pTsel);
3214 Particle emt = Particle(idEmt, 51, iRadBef, 0, 0, 0,
3215 colEmt, acolEmt, pEmt, mEmt, pTsel);
3218 Particle rec = (isrTypeNow == 0)
3219 ? Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
3220 recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel)
3221 : Particle(recBef.id(), -53, 0, 0, iRecBef, iRecBef,
3222 recBef.col(), recBef.acol(), pRec, 0., 0.);
3226 if (emt.idAbs() == 23 || emt.idAbs() == 24) {
3228 event[iRadBef].pol( dipSel->weakPol );
3229 rad.pol( dipSel->weakPol );
3233 double pAccept = dipSel->pAccept;
3236 if (dipSel->MEtype > 0) {
3237 Particle& partner = (dipSel->iMEpartner == iRecBef)
3238 ? rec : event[dipSel->iMEpartner];
3239 double pMEC = findMEcorr( dipSel, rad, partner, emt);
3240 if (dipSel->MEtype >= 200 && dipSel->MEtype <= 210)
3241 pMEC *= findMEcorrWeak( dipSel, rad.p(), partner.p(), emt.p(),
3242 p3weak, p4weak,
event[iRadBef].p(),
event[iRecBef].p());
3248 bool acceptEvent =
true;
3249 if (pAccept < 1.0) acceptEvent = (rndmPtr->flat() < pAccept);
3252 bool inResonance = (partonSystemsPtr->getInA(iSysSel) == 0) ?
true :
false;
3255 doUncertaintiesNow = doUncertainties;
3257 if (!uVarMPIshowers && iSysSel != 0 && !inResonance)
3258 doUncertaintiesNow =
false;
3261 if (noResVariations && inResonance) doUncertaintiesNow =
false;
3264 if (noProcVariations && iSysSel==0 && !inResonance)
3265 doUncertaintiesNow =
false;
3268 if ( dipSel->pT2 < uVarpTmin2 ) doUncertaintiesNow =
false;
3271 if (!doUncertaintiesNow && !acceptEvent)
return false;
3276 if (allowRescatter && FIXRESCATTER && isInterleaved
3277 && iSysSel != iSysSelRec) {
3278 Vec4 pNew = rad.p() + emt.p();
3279 if (!rescatterPropagateRecoil(event, pNew))
return false;
3283 if ( isrTypeNow != 0 ) {
3284 BeamParticle& beamRec = (isrTypeNow == 1) ? *beamAPtr : *beamBPtr;
3285 if ( beamRec.isGamma() ) {
3287 if ( !beamRec.resolvedGamma() )
return false;
3288 BeamParticle& beamOther = (isrTypeNow == 1) ? *beamBPtr : *beamAPtr;
3289 bool physical =
true;
3290 double xRec = 2. * pRec.e() / (beamRec.e() + beamOther.e());
3291 double sCM = m2( beamRec.p(), beamOther.p());
3292 double eCM = sqrt(sCM);
3294 if ( !beamOther.resolvedGamma() ) {
3295 physical = beamRec.roomFor1Remnant(beamRec[0].
id(), xRec, eCM);
3298 physical = beamOther.roomFor2Remnants(beamRec[0].
id(), xRec, eCM);
3301 if (!physical)
return false;
3306 int eventSizeOld =
event.size();
3307 int iRadStatusV =
event[iRadBef].status();
3308 int iRadDau1V =
event[iRadBef].daughter1();
3309 int iRadDau2V =
event[iRadBef].daughter2();
3310 int iRecStatusV =
event[iRecBef].status();
3311 int iRecMot1V =
event[iRecBef].mother1();
3312 int iRecMot2V =
event[iRecBef].mother2();
3313 int iRecDau1V =
event[iRecBef].daughter1();
3314 int iRecDau2V =
event[iRecBef].daughter2();
3315 int beamOff1 = 1 + beamOffset;
3316 int beamOff2 = 2 + beamOffset;
3317 int ev1Dau1V =
event[beamOff1].daughter1();
3318 int ev2Dau1V =
event[beamOff2].daughter1();
3321 if (radBef.hasVertex()) {
3322 rad.vProd( radBef.vProd() );
3323 emt.vProd( radBef.vProd() );
3325 if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
3328 int iRad =
event.append(rad);
3329 int iEmt =
event.append(emt);
3332 if (doPartonVertex) partonVertexPtr->vertexFSR( iEmt, event);
3335 event[iRadBef].statusNeg();
3336 event[iRadBef].daughters( iRad, iEmt);
3338 if (useLocalRecoilNow) {
3339 iRec =
event.append(rec);
3340 if (isrTypeNow == 0) {
3341 event[iRecBef].statusNeg();
3342 event[iRecBef].daughters( iRec, iRec);
3344 event[iRecBef].mothers( iRec, iRec);
3345 event[iRec].mothers( iRecMot1V, iRecMot2V);
3346 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( iRec);
3347 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( iRec);
3353 RotBstMatrix MG = M;
3355 double pzRecBef = -0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2Rad
3356 - dipSel->m2Rec) - 4. * dipSel->m2Rad * dipSel->m2Rec ) / dipSel->mDip;
3357 double eRecBef = sqrt( pow2(pzRecBef) + dipSel->m2Rec);
3358 double pzRecAft = -pzRadPlusEmt;
3359 double eRecAft = sqrt( pow2(pzRecAft) + dipSel->m2Rec);
3360 MG.bst( Vec4(0., 0., pzRecBef, eRecBef), Vec4(0., 0., pzRecAft, eRecAft) );
3364 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3365 iRec =
event.copy( iGRecBef[iG], 52);
3366 iGRec.push_back( iRec);
3367 Vec4 pGRec =
event[iRec].p();
3369 event[iRec].p( pGRec);
3374 if ( (canVetoEmission && userHooksPtr->doVetoFSREmission( eventSizeOld,
3375 event, iSysSel, inResonance))
3376 || (canMergeFirst && mergingHooksPtr->doVetoEmission( event )) ) {
3377 event.popBack( event.size() - eventSizeOld);
3378 event[iRadBef].status( iRadStatusV);
3379 event[iRadBef].daughters( iRadDau1V, iRadDau2V);
3380 if (useLocalRecoilNow && isrTypeNow == 0) {
3381 event[iRecBef].status( iRecStatusV);
3382 event[iRecBef].daughters( iRecDau1V, iRecDau2V);
3383 }
else if (useLocalRecoilNow) {
3384 event[iRecBef].mothers( iRecMot1V, iRecMot2V);
3385 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( ev1Dau1V);
3386 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( ev2Dau1V);
3388 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3389 event[iGRecBef[iG]].statusPos();
3390 event[iGRecBef[iG]].daughters( 0, 0);
3398 bool vetoedEnhancedEmission =
false;
3403 bool foundEnhance =
false;
3406 for ( map<
double,pair<string,double> >::reverse_iterator
3407 it = enhanceFactors.rbegin();
3408 it != enhanceFactors.rend(); ++it ){
3409 if (splittingNameSel.find(it->second.first) != string::npos
3410 && abs(it->second.second-1.0) > 1e-9) {
3411 foundEnhance =
true;
3412 weight = it->second.second;
3413 vp = userHooksPtr->vetoProbability(splittingNameSel);
3419 if (foundEnhance && rndmPtr->flat() < vp ) vetoedEnhancedEmission =
true;
3422 if (foundEnhance && vetoedEnhancedEmission) rwgt *= (1.-1./weight)/vp;
3423 else if (foundEnhance) rwgt *= 1./((1.-vp)*weight);
3426 enhanceFactors.clear();
3429 double wtOld = userHooksPtr->getEnhancedEventWeight();
3430 if (!doTrialNow && canEnhanceEmission && !doUncertaintiesNow)
3431 userHooksPtr->setEnhancedEventWeight(wtOld*rwgt);
3432 if ( doTrialNow && canEnhanceTrial)
3433 userHooksPtr->setEnhancedTrial(sqrt(dipSel->pT2), weight);
3435 if (vetoedEnhancedEmission && canEnhanceEmission) infoPtr->addCounter(40);
3440 if (vetoedEnhancedEmission) acceptEvent =
false;
3441 if (doUncertaintiesNow) calcUncertainties( acceptEvent, pAccept, weight, vp,
3442 dipSel, &rad, &emt, &rec);
3446 if ( (vetoedEnhancedEmission && canEnhanceEmission) || !acceptEvent) {
3447 event.popBack( event.size() - eventSizeOld);
3448 event[iRadBef].status( iRadStatusV);
3449 event[iRadBef].daughters( iRadDau1V, iRadDau2V);
3450 if (useLocalRecoilNow && isrTypeNow == 0) {
3451 event[iRecBef].status( iRecStatusV);
3452 event[iRecBef].daughters( iRecDau1V, iRecDau2V);
3453 }
else if (useLocalRecoilNow) {
3454 event[iRecBef].mothers( iRecMot1V, iRecMot2V);
3455 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( ev1Dau1V);
3456 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( ev2Dau1V);
3458 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3459 event[iGRecBef[iG]].statusPos();
3460 event[iGRecBef[iG]].daughters( 0, 0);
3467 if (!useLocalRecoilNow) {
3469 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
3470 if (iGRecBef[iG] == iRecBef) iRec = iGRec[iG];
3474 if (isrTypeNow != 0) {
3475 BeamParticle& beamRec = (isrTypeNow == 1) ? *beamAPtr : *beamBPtr;
3476 double xOld = beamRec[iSysSelRec].x();
3477 double xRec = 2. * pRec.e() / (beamAPtr->e() + beamBPtr->e());
3478 beamRec[iSysSelRec].iPos( iRec);
3479 beamRec[iSysSelRec].x( xRec);
3480 partonSystemsPtr->setSHat( iSysSelRec,
3481 partonSystemsPtr->getSHat(iSysSelRec) * xRec / xOld);
3486 if ( !useLocalRecoilNow || nGlobal >= nMaxGlobalBranch) {
3488 while ( doRemove ) {
3489 bool hasRemoved =
false;
3490 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
3491 if ( event[dipSel->iRadiator].isAncestor(hardPartons[iHard]) ) {
3492 hardPartons.erase( hardPartons.begin() + iHard );
3496 doRemove = hasRemoved;
3501 if ( !useLocalRecoilNow ) ++nGlobal;
3504 if (dipSel->flavour == 22) {
3505 dipSel->iRadiator = iRad;
3506 dipSel->iRecoiler = iRec;
3509 if (recoilToColoured && inResonance && event[iRec].chargeType() == 0)
3510 dipSel->iRecoiler = iEmt;
3511 dipSel->pTmax = pTsel;
3512 if (doQEDshowerByGamma) dipEnd.push_back( TimeDipoleEnd(iEmt, iRad,
3513 pTsel, 0, 0, 1, 0, 0, iSysSel, 0) );
3516 }
else if (dipSel->flavour == 21) {
3517 dipSel->iRadiator = iRad;
3518 dipSel->iRecoiler = iEmt;
3519 dipSel->systemRec = iSysSel;
3520 dipSel->isrType = 0;
3521 dipSel->pTmax = pTsel;
3523 if (!doMEafterFirst) dipSel->MEtype = 0;
3526 double flexFactor = (isFlexible) ? dipSel->flexFactor : 1.0;
3527 dipSel->isFlexible =
false;
3528 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3529 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
3530 && dipEnd[i].colType != 0) {
3531 dipEnd[i].iRadiator = iRec;
3532 dipEnd[i].iRecoiler = iEmt;
3534 if (!doMEafterFirst) dipEnd[i].MEtype = 0;
3536 if ( !isFlexible && dipEnd[i].colType * dipSel->colType > 0)
3537 dipEnd[i].iRecoiler = iRad;
3538 dipEnd[i].pTmax = pTsel;
3545 if (event[iRadBef].
id() == 21 && dipEnd[i].iRecoiler == iRadBef
3546 && dipEnd[i].weakType != 0) {
3547 double m1 = (
event[iRad].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3548 double m2 = (
event[iEmt].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3549 dipEnd[i].iRecoiler = (m1 > m2) ? iRad : iEmt;
3550 dipEnd[i].iMEpartner = dipEnd[i].iRecoiler;
3553 int colType = (dipSel->colType > 0) ? 2 : -2 ;
3557 if (recoilToColoured && inResonance && event[iRec].col() == 0
3558 &&
event[iRec].acol() == 0) iRecMod = iRad;
3559 dipEnd.push_back( TimeDipoleEnd(iEmt, iRecMod, pTsel,
3560 colType, 0, 0, 0, isrTypeSave, iSysSel, 0));
3561 dipEnd.back().systemRec = iSysSelRec;
3564 dipEnd.back().isFlexible =
true;
3565 dipEnd.back().flexFactor = flexFactor;
3567 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3568 -colType, 0, 0, 0, 0, iSysSel, 0));
3571 }
else if (dipSel->colType != 0) {
3572 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3574 if ( !isFlexible && dipEnd[i].iRecoiler == iRadBef
3575 && dipEnd[i].colType * dipSel->colType < 0 )
3576 dipEnd[i].iRecoiler = iEmt;
3577 if (dipEnd[i].iRadiator == iRadBef && abs(dipEnd[i].colType) == 2) {
3578 dipEnd[i].colType /= 2;
3579 if (dipEnd[i].system != dipEnd[i].systemRec)
continue;
3583 dipEnd[i].MEtype = (doMEcorrections && doMEafterFirst) ? 66 : 0;
3584 if (&dipEnd[i] == dipSel) dipEnd[i].iMEpartner = iRad;
3585 else dipEnd[i].iMEpartner = iEmt;
3588 if (event[iRadBef].
id() == 21 && dipEnd[i].iRecoiler == iRadBef
3589 && dipEnd[i].weakType != 0) {
3590 double m1 = (
event[iRad].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3591 double m2 = (
event[iEmt].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3592 dipEnd[i].iRecoiler = (m1 > m2) ? iRad : iEmt;
3593 dipEnd[i].iMEpartner = dipEnd[i].iRecoiler;
3596 dipSel->iRadiator = iEmt;
3597 dipSel->iRecoiler = iRec;
3598 dipSel->pTmax = pTsel;
3603 if (doQEDshowerByQ) {
3604 int chgType =
event[iRad].chargeType();
3605 int meType = (doMEcorrections && doMEafterFirst) ? 66 : 0;
3606 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3607 0, chgType, 0, 0, 0, iSysSel, meType, iEmt));
3608 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3609 0, -chgType, 0, 0, 0, iSysSel, meType, iRad));
3614 if (doWeakShower && iSysSel == 0 &&
3615 !(hasWeaklyRadiated && singleWeakEmission)) {
3616 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
3617 event[iRad].pol(weakPol);
3618 event[iEmt].pol(weakPol);
3619 if ((weakMode == 0 || weakMode == 1) && weakPol == -1) {
3620 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3621 0, 0, 0, 1, 0, iSysSel, 200, iEmt, weakPol) );
3622 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3623 0, 0, 0, 1, 0, iSysSel, 200, iRad, weakPol) );
3625 if (weakMode == 0 || weakMode == 2) {
3626 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3627 0, 0, 0, 2, 0, iSysSel, 205, iEmt, weakPol) );
3628 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3629 0, 0, 0, 2, 0, iSysSel, 205, iRad, weakPol) );
3636 }
else if (dipSel->gamType != 0) {
3637 dipSel->gamType = 0;
3638 int chgType =
event[iRad].chargeType();
3639 int colType =
event[iRad].colType();
3641 if ( chgType != 0 && ( ( doQEDshowerByQ && colType != 0 )
3642 || ( doQEDshowerByL && colType == 0 ) ) ) {
3643 int MEtype = (doMEcorrections && doMEafterFirst) ? 102 : 0;
3644 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3645 0, chgType, 0, 0, 0, iSysSel, MEtype, iEmt) );
3646 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3647 0, -chgType, 0, 0, 0, iSysSel, MEtype, iRad) );
3650 if (colType != 0 && doQCDshower) {
3651 int MEtype = (doMEcorrections && doMEafterFirst) ? 11 : 0;
3652 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3653 colType, 0, 0, 0, 0, iSysSel, MEtype, iEmt) );
3654 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3655 -colType, 0, 0, 0, 0, iSysSel, MEtype, iRad) );
3659 }
else if (dipSel->flavour == 4900022) {
3660 dipSel->iRadiator = iRad;
3661 dipSel->iRecoiler = iRec;
3662 dipSel->pTmax = pTsel;
3665 }
else if (dipSel->flavour == 4900021) {
3666 dipSel->iRadiator = iRad;
3667 dipSel->iRecoiler = iEmt;
3668 dipSel->pTmax = pTsel;
3669 for (
int i = 0; i < int(dipEnd.size()); ++i)
3670 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
3671 && dipEnd[i].isHiddenValley) {
3672 dipEnd[i].iRadiator = iRec;
3673 dipEnd[i].iRecoiler = iEmt;
3674 dipEnd[i].pTmax = pTsel;
3676 int colvType = (dipSel->colvType > 0) ? 2 : -2 ;
3677 dipEnd.push_back( TimeDipoleEnd(iEmt, iRec, pTsel,
3678 0, 0, 0, 0, isrTypeSave, iSysSel, 0, -1, 0,
false,
true, colvType) );
3679 dipEnd.back().systemRec = iSysSelRec;
3680 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3681 0, 0, 0, 0, 0, iSysSel, 0, -1, 0,
false,
true, -colvType) );
3684 }
else if (dipSel->weakType != 0) {
3685 hasWeaklyRadiated =
true;
3686 if (singleWeakEmission)
3687 for (
int i = 0; i < int(dipEnd.size()); ++i) dipEnd[i].weakType = 0;
3691 if (event[iRad].
id() ==
event[iRadBef].id()) {
3692 event[iRad].tau( event[iRadBef].tau() );
3694 event[iRad].tau( event[iRad].tau0() * rndmPtr->exp() );
3695 event[iEmt].tau( event[iEmt].tau0() * rndmPtr->exp() );
3697 event[iRec].tau( event[iRecBef].tau() );
3700 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3703 if (isFlexible && !dipSel->isFlexible && dipEnd[i].isFlexible) {
3704 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iEmt;
3705 if (dipEnd[i].iRadiator == iRadBef) {
3706 dipEnd[i].iRadiator = iEmt;
3707 if (dipEnd[i].colType == 1 && dipSel->flavour == 21)
3708 dipEnd[i].colType = 2;
3709 if (dipEnd[i].colType ==-1 && dipSel->flavour == 21)
3710 dipEnd[i].colType =-2;
3713 if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
3714 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
3715 if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
3716 if (useLocalRecoilNow) {
3717 if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
3718 if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
3719 if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
3721 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3722 if (dipEnd[i].iRadiator == iGRecBef[iG])
3723 dipEnd[i].iRadiator = iGRec[iG];
3724 if (dipEnd[i].iRecoiler == iGRecBef[iG])
3725 dipEnd[i].iRecoiler = iGRec[iG];
3726 if (dipEnd[i].iMEpartner == iGRecBef[iG])
3727 dipEnd[i].iMEpartner = iGRec[iG];
3736 for (
int iJun = 0; iJun <
event.sizeJunction(); iJun++) {
3738 int nIncoming = (
event.kindJunction(iJun)-1)/2;
3742 colChk = (
event.kindJunction(iJun) % 2 == 0 )
3743 ? event[iRadBef].col() :
event[iRadBef].acol();
3745 for (
int iCol = 0; iCol < nIncoming; iCol++) {
3746 int colJun =
event.colJunction( iJun, iCol);
3748 if (colJun == colChk) {
3750 if ( event.kindJunction(iJun) % 2 == 0 ) colNew = colRad;
3751 else colNew = acolRad;
3752 event.colJunction( iJun, iCol, colNew );
3758 partonSystemsPtr->replace(iSysSel, iRadBef, iRad);
3759 partonSystemsPtr->addOut(iSysSel, iEmt);
3760 if (useLocalRecoilNow)
3761 partonSystemsPtr->replace(iSysSelRec, iRecBef, iRec);
3763 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
3764 partonSystemsPtr->replace(iSysSel, iGRecBef[iG], iGRec[iG]);
3776 bool TimeShower::initUncertainties() {
3778 if( infoPtr->nWeights() > 1 )
return(nUncertaintyVariations);
3781 uVarMuSoftCorr = settingsPtr->flag(
"UncertaintyBands:muSoftCorr");
3782 dASmax = settingsPtr->parm(
"UncertaintyBands:deltaAlphaSmax");
3784 varPDFplus = &infoPtr->varPDFplus;
3785 varPDFminus = &infoPtr->varPDFminus;
3786 varPDFmember = &infoPtr->varPDFmember;
3789 varG2GGmuRfac.clear(); varG2GGcNS.clear();
3790 varQ2QGmuRfac.clear(); varQ2QGcNS.clear();
3791 varX2XGmuRfac.clear(); varX2XGcNS.clear();
3792 varG2QQmuRfac.clear(); varG2QQcNS.clear();
3794 vector<string> keys;
3795 keys.push_back(
"fsr:murfac");
3796 keys.push_back(
"fsr:g2gg:murfac");
3797 keys.push_back(
"fsr:q2qg:murfac");
3798 keys.push_back(
"fsr:x2xg:murfac");
3799 keys.push_back(
"fsr:g2qq:murfac");
3800 keys.push_back(
"fsr:cns");
3801 keys.push_back(
"fsr:g2gg:cns");
3802 keys.push_back(
"fsr:q2qg:cns");
3803 keys.push_back(
"fsr:x2xg:cns");
3804 keys.push_back(
"fsr:g2qq:cns");
3806 int nKeysQCD=keys.size();
3809 vector<string> uVars = settingsPtr->wvec(
"UncertaintyBands:List");
3810 size_t varSize = uVars.size();
3811 nUncertaintyVariations = int(uVars.size());
3812 if (nUncertaintyVariations == 0)
return false;
3813 vector<string> uniqueVars;
3816 for (
size_t iWeight = 0; iWeight < varSize; ++iWeight) {
3819 string uVarString = toLower(uVars[iWeight]);
3820 while (uVarString.find(
" ") == 0) uVarString.erase( 0, 1);
3821 int iEnd = uVarString.find(
" ", 0);
3822 uVarString.erase(0,iEnd+1);
3823 while (uVarString.find(
"=") != string::npos) {
3824 int firstEqual = uVarString.find_first_of(
"=");
3825 string testString = uVarString.substr(0, firstEqual);
3826 iEnd = uVarString.find_first_of(
" ", 0);
3827 if( iEnd<0 ) iEnd = uVarString.length();
3828 string insertString = uVarString.substr(0,iEnd);
3830 if( find(keys.begin(), keys.end(), testString) != keys.end() ) {
3831 if( uniqueVars.size() == 0 ) {
3832 uniqueVars.push_back(insertString);
3833 }
else if ( find(uniqueVars.begin(), uniqueVars.end(), insertString)
3834 == uniqueVars.end() ) {
3835 uniqueVars.push_back(insertString);
3838 uVarString.erase(0,iEnd+1);
3842 nUncertaintyVariations = int(uniqueVars.size());
3845 if (infoPtr->nWeights() <= 1.) {
3846 infoPtr->setNWeights( nUncertaintyVariations + 1 );
3847 infoPtr->setWeightLabel( 0,
"Baseline");
3848 for(
int iWeight = 1; iWeight <= nUncertaintyVariations; ++iWeight) {
3849 string uVarString = uniqueVars[iWeight-1];
3850 infoPtr->setWeightLabel(iWeight, uVarString);
3852 while (uVarString.find(
"=") != string::npos) {
3853 int firstEqual = uVarString.find_first_of(
"=");
3854 uVarString.replace(firstEqual, 1,
" ");
3856 while (uVarString.find(
" ") != string::npos)
3857 uVarString.erase( uVarString.find(
" "), 1);
3858 if (uVarString ==
"" || uVarString ==
" ")
continue;
3861 int nRecognizedQCD = 0;
3862 for (
int iWord = 0; iWord < int(keys.size()); ++iWord) {
3864 string key = toLower(keys[iWord]);
3866 if (uVarString.find(key) == string::npos)
continue;
3868 int iKey = uVarString.find(key);
3869 int iBeg = uVarString.find(
" ", iKey) + 1;
3870 int iEnd = uVarString.find(
" ", iBeg);
3871 string valueString = uVarString.substr(iBeg, iEnd - iBeg);
3872 stringstream ss(valueString);
3879 if (key ==
"fsr:murfac" || key ==
"fsr:g2gg:murfac")
3880 varG2GGmuRfac[iWeight] = value;
3881 if (key ==
"fsr:murfac" || key ==
"fsr:q2qg:murfac")
3882 varQ2QGmuRfac[iWeight] = value;
3883 if (key ==
"fsr:murfac" || key ==
"fsr:x2xg:murfac")
3884 varX2XGmuRfac[iWeight] = value;
3885 if (key ==
"fsr:murfac" || key ==
"fsr:g2qq:murfac")
3886 varG2QQmuRfac[iWeight] = value;
3887 if (key ==
"fsr:cns" || key ==
"fsr:g2gg:cns")
3888 varG2GGcNS[iWeight] = value;
3889 if (key ==
"fsr:cns" || key ==
"fsr:q2qg:cns")
3890 varQ2QGcNS[iWeight] = value;
3891 if (key ==
"fsr:cns" || key ==
"fsr:x2xg:cns")
3892 varX2XGcNS[iWeight] = value;
3893 if (key ==
"fsr:cns" || key ==
"fsr:g2qq:cns")
3894 varG2QQcNS[iWeight] = value;
3896 if (iWord < nKeysQCD) nRecognizedQCD++;
3900 if (nRecognizedQCD > 0) ++nVarQCD;
3903 infoPtr->initUncertainties(&uVars);
3905 return (nUncertaintyVariations > 0);
3913 void TimeShower::calcUncertainties(
bool accept,
double pAccept,
double enhance,
3914 double vp, TimeDipoleEnd* dip, Particle* radPtr, Particle* emtPtr,
3918 if (!doUncertainties || !doUncertaintiesNow || nUncertaintyVariations <= 0)
3923 map<int,double>* varPtr=0;
3924 map<int,double>::iterator itVar;
3926 map<int,double> dummy; dummy.clear();
3928 int numWeights = infoPtr->nWeights();
3931 vector<double> uVarFac(numWeights, 1.0);
3932 vector<bool> doVar(numWeights,
false);
3939 int idEmt = emtPtr->id();
3940 int idRad = radPtr->id();
3943 if (dip->colType != 0) {
3946 if (alphaSorder == 0) varPtr = &dummy;
3947 else if (idEmt == 21 && idRad == 21) varPtr = &varG2GGmuRfac;
3948 else if (idEmt == 21 && abs(idRad) <= uVarNflavQ)
3949 varPtr = &varQ2QGmuRfac;
3950 else if (idEmt == 21) varPtr = &varX2XGmuRfac;
3951 else if (abs(idRad) <= nGluonToQuark && abs(idEmt) <= nGluonToQuark)
3952 varPtr = &varG2QQmuRfac;
3953 else varPtr = &dummy;
3954 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
3955 int iWeight = itVar->first;
3956 double valFac = itVar->second;
3957 double muR2 = renormMultFac * dip->pT2;
3958 double alphaSbaseline = alphaS.alphaS(muR2);
3960 double muR2var = max(1.1 * Lambda3flav2, pow2(valFac) * muR2);
3961 double alphaSratio = alphaS.alphaS(muR2var) / alphaSbaseline;
3963 double facCorr = 1.;
3964 if (idEmt == 21 && uVarMuSoftCorr) {
3967 if (dip->pT2 < pow2(mc)) nf = 3;
3968 else if (dip->pT2 < pow2(mb)) nf = 4;
3969 double alphaScorr = alphaS.alphaS(dip->m2Dip);
3970 double facSoft = alphaScorr * (33. - 2. * nf) / (6. * M_PI);
3971 double zeta = 1. - dip->z;
3972 if (idRad == 21) zeta = min(dip->z, 1. - dip->z);
3973 facCorr = 1. + (1. - zeta) * facSoft * log(valFac);
3976 double alphaSfac = alphaSratio * facCorr;
3979 alphaSfac = min(alphaSfac, (alphaSbaseline + dASmax) / alphaSbaseline);
3980 else if (alphaSbaseline > dASmax)
3981 alphaSfac = max(alphaSfac, (alphaSbaseline - dASmax) / alphaSbaseline);
3982 uVarFac[iWeight] *= alphaSfac;
3983 doVar[iWeight] =
true;
3987 if (dip->MEtype != 0 || dip->pT2 < pow2(cNSpTmin) ) varPtr = &dummy;
3988 else if (idEmt == 21 && idRad == 21) varPtr = &varG2GGcNS;
3989 else if (idEmt == 21 && abs(idRad) <= uVarNflavQ) varPtr = &varQ2QGcNS;
3990 else if (idEmt == 21) varPtr = &varX2XGcNS;
3991 else if (abs(idRad) <= nGluonToQuark && abs(idEmt) <= nGluonToQuark)
3992 varPtr = &varG2QQcNS;
3993 else varPtr = &dummy;
3994 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
3995 int iWeight = itVar->first;
3996 double valFac = itVar->second;
3999 double Q2 = dip->m2;
4001 if (abs(idRad) >= 4 && idRad != 21) Q2 = max(1., Q2-radPtr->m2());
4002 double yQ = Q2 / dip->m2Dip;
4003 double num = yQ * valFac;
4006 if (idEmt == 21 && idRad == 21)
4007 denom = pow2(1. - z * (1.-z)) / (z*(1.-z));
4009 else if (idEmt == 21)
4010 denom = (1. + pow2(z)) / (1. - z);
4013 denom = pow2(z) + pow2(1. - z);
4015 uVarFac[iWeight] *= 1. + num / denom;
4016 doVar[iWeight] =
true;
4020 if ( dip->isrType != 0 ){
4021 if ( !varPDFplus->empty() || !varPDFminus->empty()
4022 || !varPDFmember->empty() ) {
4024 double scale2 = (useFixedFacScale) ? fixedFacScale2
4025 : factorMultFac * dip->pT2;
4026 BeamParticle& beam = (dip->isrType == 1) ? *beamAPtr : *beamBPtr;
4027 int iSysRec = dip->systemRec;
4028 double xOld = beam[iSysRec].x();
4029 double xNew = xOld * (1. + (dip->m2 - dip->m2Rad)
4030 / (dip->m2Dip - dip->m2Rad));
4031 int idRec = recPtr->id();
4032 int valSea = (beam[iSysSel].isValence()) ? 1 : 0;
4033 if( beam[iSysSel].isUnmatched() ) valSea = 2;
4034 beam.calcPDFEnvelope( make_pair(idRec,idRec),
4035 make_pair(xNew,xOld), scale2, valSea);
4036 PDF::PDFEnvelope ratioPDFEnv = beam.getPDFEnvelope( );
4038 varPtr = varPDFplus;
4039 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4040 int iWeight = itVar->first;
4041 uVarFac[iWeight] *= 1.0 + min(ratioPDFEnv.errplusPDF
4042 / ratioPDFEnv.centralPDF,0.5);
4043 doVar[iWeight] =
true;
4046 varPtr = varPDFminus;
4047 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4048 int iWeight = itVar->first;
4049 uVarFac[iWeight] *= max(.01,1.0 - min(ratioPDFEnv.errminusPDF
4050 / ratioPDFEnv.centralPDF,0.5));
4051 doVar[iWeight] =
true;
4053 varPtr = varPDFmember;
4054 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4055 int iWeight = itVar->first;
4056 int member = int( itVar->second );
4057 uVarFac[iWeight] *= max(.01,ratioPDFEnv.pdfMemberVars[member]
4058 / ratioPDFEnv.centralPDF);
4059 doVar[iWeight] =
true;
4068 for (
int iWeight = 1; iWeight<=nUncertaintyVariations; ++iWeight) {
4069 if (!doVar[iWeight])
continue;
4070 double pAcceptPrime = pAccept * uVarFac[iWeight];
4071 if (pAcceptPrime > PROBLIMIT && dip->colType != 0) {
4072 uVarFac[iWeight] *= PROBLIMIT / pAcceptPrime;
4077 for (
int iWeight = 0; iWeight <= nUncertaintyVariations; ++iWeight) {
4078 if (!doVar[iWeight])
continue;
4080 if (accept) infoPtr->reWeight(iWeight,
4081 uVarFac[iWeight] / ((1.0 - vp) * enhance) );
4086 double denom = 1. - pAccept*(1.0 - vp);
4087 if (denom < REJECTFACTOR) {
4088 stringstream message;
4090 infoPtr->errorMsg(
"Warning in TimeShower: reject denom for iWeight = ",
4094 double reWtFail = max(0.01, (1. - uVarFac[iWeight] * pAccept / enhance)
4096 infoPtr->reWeight(iWeight, reWtFail);
4115 typedef pair < int, int > pairInt;
4116 typedef vector < pairInt > vectorPairInt;
4135 inline vectorPairInt findParentSystems(
const int sys,
4136 Event& event, PartonSystems* partonSystemsPtr,
bool forwards) {
4138 vectorPairInt parentSystems;
4139 parentSystems.reserve(10);
4144 int iInA = partonSystemsPtr->getInA(iSysCur);
4145 int iInB = partonSystemsPtr->getInB(iSysCur);
4149 if (event[iInA].isRescatteredIncoming()) iIn = iInA;
4150 if (event[iInB].isRescatteredIncoming()) iIn = -iInB;
4153 parentSystems.push_back( pairInt(-iSysCur, iIn) );
4154 if (iIn == 0)
break;
4156 int iInAbs = abs(iIn);
4157 int iMother =
event[iInAbs].mother1();
4158 iSysCur = partonSystemsPtr->getSystemOf(iMother);
4159 if (iSysCur == -1) {
4160 parentSystems.clear();
4168 vectorPairInt::reverse_iterator rit;
4169 for (rit = parentSystems.rbegin(); rit < (parentSystems.rend() - 1);
4171 pairInt &cur = *rit;
4172 pairInt &next = *(rit + 1);
4173 cur.first = -cur.first;
4174 cur.second = (next.second < 0) ? -event[abs(next.second)].mother1() :
4175 event[abs(next.second)].mother1();
4179 return parentSystems;
4190 bool TimeShower::rescatterPropagateRecoil(
Event& event, Vec4& pNew) {
4193 int iRadBef = dipSel->iRadiator;
4194 iSysSel = dipSel->system;
4195 int iSysSelRec = dipSel->systemRec;
4196 Vec4 pImbal = pNew -
event[iRadBef].p();
4200 vector < pair < int, Vec4 > > eventMod;
4201 eventMod.reserve(10);
4206 vectorPairInt systemMod;
4207 systemMod.reserve(10);
4210 vectorPairInt radParent = findParentSystems(iSysSel, event,
4211 partonSystemsPtr,
false);
4212 vectorPairInt recParent = findParentSystems(iSysSelRec, event,
4213 partonSystemsPtr,
true);
4214 if (radParent.size() == 0 || recParent.size() == 0) {
4216 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
4217 "couldn't find parent system; branching vetoed");
4221 bool foundPath =
false;
4222 unsigned int iRadP = 0;
4223 unsigned int iRecP = 0;
4224 for (iRadP = 0; iRadP < radParent.size(); iRadP++) {
4225 for (iRecP = 0; iRecP < recParent.size(); iRecP++)
4226 if (abs(radParent[iRadP].first) == abs(recParent[iRecP].first)) {
4230 if (foundPath)
break;
4235 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4236 "couldn't find recoil path; branching vetoed");
4243 if (radParent.size() > 1)
4244 path.assign(radParent.begin(), radParent.begin() + iRadP);
4245 if (recParent.size() > 1)
4246 path.insert(path.end(), recParent.rend() - iRecP - 1,
4247 recParent.rend() - 1);
4250 for (
unsigned int i = 0; i < path.size(); i++) {
4252 bool isIncoming = (path[i].first < 0) ?
true :
false;
4253 int iSysCur = abs(path[i].first);
4254 bool isIncomingA = (path[i].second > 0) ?
true :
false;
4255 int iLink = abs(path[i].second);
4258 if (isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
4261 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
4262 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
4266 if (iMemCur == -1) {
4268 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
4269 "couldn't find parton system; branching vetoed");
4274 Vec4 pMod = (isIncoming) ? event[iLink].p() + pImbal :
4275 event[iLink].p() - pImbal;
4276 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
4277 systemMod.push_back(pairInt(iSysCur, iMemCur));
4280 int iInCurA = partonSystemsPtr->getInA(iSysCur);
4281 int iInCurB = partonSystemsPtr->getInB(iSysCur);
4282 Vec4 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
4285 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
4286 double sHatCur = pTotCur.m2Calc();
4290 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
4291 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4292 "virtuality much larger than sHat; branching vetoed");
4298 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
4299 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4300 "rest frame energy too negative; branching vetoed");
4305 if (sHatCur < 0.0) {
4306 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4307 "sHat became negative; branching vetoed");
4312 iLink = (isIncoming) ? event[iLink].mother1() :
4313 event[iLink].daughter1();
4314 iSysCur = partonSystemsPtr->getSystemOf(iLink,
true);
4316 if (!isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
4319 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
4320 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
4324 if (iMemCur == -1) {
4326 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
4327 "couldn't find parton system; branching vetoed");
4332 pMod = (isIncoming) ? event[iLink].p() + pImbal :
4333 event[iLink].p() - pImbal;
4334 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
4335 systemMod.push_back(pairInt(iSysCur, iMemCur));
4338 iInCurA = partonSystemsPtr->getInA(iSysCur);
4339 iInCurB = partonSystemsPtr->getInB(iSysCur);
4340 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
4343 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
4344 sHatCur = pTotCur.m2Calc();
4348 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
4349 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4350 "virtuality much larger than sHat; branching vetoed");
4356 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
4357 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4358 "rest frame energy too negative; branching vetoed");
4363 if (sHatCur < 0.0) {
4364 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4365 "sHat became negative; branching vetoed");
4370 if (VETONEGENERGY && pMod.e() < 0.0) {
4371 infoPtr->errorMsg(
"Warning in TimeShower::rescatterPropagateRecoil: "
4372 "energy became negative; branching vetoed");
4381 for (
unsigned int i = 0; i < eventMod.size(); i++) {
4382 int idx = eventMod[i].first;
4383 Vec4 &pMod = eventMod[i].second;
4384 int iSys = systemMod[i].first;
4385 int iMem = systemMod[i].second;
4388 if (event[idx].isRescatteredIncoming()) {
4389 int mother1 =
event[idx].mother1();
4390 idx =
event.copy(idx, -54);
4391 event[mother1].daughters(idx, idx);
4394 double eCM = sqrt(m2( beamAPtr->p(), beamBPtr->p()));
4396 partonSystemsPtr->setInA(iSys, idx);
4397 (*beamAPtr)[iSys].x((pMod.e() + pMod.pz()) / eCM);
4398 (*beamAPtr)[iSys].m(pMod.mCalc());
4399 (*beamAPtr)[iSys].p(pMod);
4400 (*beamAPtr)[iSys].iPos(idx);
4401 }
else if (iMem == -2) {
4402 partonSystemsPtr->setInB(iSys, idx);
4403 (*beamBPtr)[iSys].x((pMod.e() - pMod.pz()) / eCM);
4404 (*beamBPtr)[iSys].m(pMod.mCalc());
4405 (*beamBPtr)[iSys].p(pMod);
4406 (*beamBPtr)[iSys].iPos(idx);
4409 infoPtr->errorMsg(
"Error in TimeShower::rescatterPropagateRecoil: "
4410 "internal bookeeping error");
4415 int daughter1 =
event[idx].daughter1();
4416 idx =
event.copy(idx, 55);
4417 event[idx].statusNeg();
4418 event[daughter1].mothers(idx, idx);
4420 partonSystemsPtr->setOut(iSys, iMem, idx);
4423 event[idx].p( eventMod[i].second );
4424 event[idx].m( event[idx].mCalc() );
4437 void TimeShower::findMEtype(
Event& event, TimeDipoleEnd& dip) {
4440 bool setME = doMEcorrections;
4441 int iMother =
event[dip.iRadiator].mother1();
4442 int iMother2 =
event[dip.iRadiator].mother2();
4445 if (dip.isHiddenValley && event[dip.iRecoiler].id()
4446 == -
event[dip.iRadiator].id());
4449 else if (dip.weakType != 0);
4452 else if (!doMEextended) {
4453 if (iMother2 != iMother && iMother2 != 0) setME =
false;
4454 if (event[dip.iRecoiler].mother1() != iMother) setME =
false;
4455 if (event[dip.iRecoiler].mother2() != iMother2) setME =
false;
4459 if (event[dip.iRecoiler].status() < 0) setME = doMEextended;
4462 if (dip.system != dip.systemRec) setME =
false;
4471 if (dip.iMEpartner < 0) {
4472 int idAbs1 =
event[dip.iRadiator].idAbs();
4473 int idAbs2 =
event[dip.iRecoiler].idAbs();
4474 bool isRare1 = (idAbs1 > 5 && idAbs1 < 11) || (idAbs1 > 16 && idAbs1 < 21)
4476 bool isRare2 = (idAbs2 > 5 && idAbs2 < 11) || (idAbs2 > 16 && idAbs2 < 21)
4478 if (isRare1 && !isRare2) {
4479 vector<int> iSis =
event[dip.iRadiator].sisterList();
4481 for (
int iS = 0; iS < int(iSis.size()); ++iS) {
4482 idAbs2 =
event[iSis[iS]].idAbs();
4483 isRare2 = (idAbs2 > 5 && idAbs2 < 11) || (idAbs2 > 16 && idAbs2 < 21)
4485 if (idAbs2 == idAbs1) dip.iMEpartner = iSis[iS];
4486 if (isRare2 && dip.iMEpartner < 0) dip.iMEpartner = iSis[iS];
4492 if (dip.iMEpartner < 0) dip.iMEpartner = dip.iRecoiler;
4495 if (dip.MEtype != -1)
return;
4498 if (dip.colType != 0 || dip.colvType != 0) {
4499 bool isHiddenColour = (dip.colvType != 0);
4502 int idDau1 =
event[dip.iRadiator].id();
4503 int idDau2 =
event[dip.iMEpartner].id();
4504 int dau1Type = findMEparticle(idDau1, isHiddenColour);
4505 int dau2Type = findMEparticle(idDau2, isHiddenColour);
4506 int minDauType = min(dau1Type, dau2Type);
4507 int maxDauType = max(dau1Type, dau2Type);
4510 dip.MEorder = (dau2Type >= dau1Type);
4511 dip.MEsplit = (maxDauType <= 6);
4512 dip.MEgluinoRec =
false;
4515 if (minDauType == 0 && dip.MEtype < 0) dip.MEtype = 0;
4516 if (dip.MEtype >= 0)
return;
4520 if (dau1Type == 4 && dau2Type == 4)
return;
4524 if ( event[dip.iRecoiler].mother1() == iMother && iMother >= 0
4525 && (iMother2 == 0 || iMother2 == iMother) )
4526 idMother =
event[iMother].id();
4527 int motherType = (idMother != 0)
4528 ? findMEparticle(idMother, isHiddenColour) : 0;
4531 if (motherType == 0) {
4532 int col1 =
event[dip.iRadiator].col();
4533 int acol1 =
event[dip.iRadiator].acol();
4534 int col2 =
event[dip.iMEpartner].col();
4535 int acol2 =
event[dip.iMEpartner].acol();
4537 int spinT = (
event[dip.iRadiator].spinType()
4538 +
event[dip.iMEpartner].spinType() )%2;
4540 if ( col1 == acol2 && acol1 == col2 )
4541 motherType = (spinT == 0) ? 7 : 9;
4543 else if ( (col1 == acol2 && acol1 != 0 && col2 != 0)
4544 || (acol1 == col2 && col1 != 0 && acol2 != 0) )
4545 motherType = (spinT == 0) ? 4 : 5;
4547 else if ( (col1 == acol2 && acol1 != col2)
4548 || (acol1 == col2 && col1 != acol2) )
4549 motherType = (spinT == 0) ? 2 : 1;
4561 if (isHiddenColour && brokenHVsym) {
4562 MEkind = (dau2Type == 0 || dau2Type > 6) ? 30 : 31;
4563 dip.MEtype = 5 * MEkind + 1;
4569 dip.MEgluinoRec = (dau1Type >= 1 && dau1Type <= 3 && dau2Type == 5);
4572 if (minDauType == 1 && maxDauType == 1 &&
4573 (motherType == 4 || motherType == 7) ) {
4575 if (idMother == 21 || idMother == 22 || motherType == 4) MEcombi = 1;
4576 else if (idMother == 23 || idDau1 + idDau2 == 0) {
4578 dip.MEmix = gammaZmix( event, iMother, dip.iRadiator, dip.iRecoiler );
4580 else if (idMother == 24) MEcombi = 4;
4583 else if (minDauType == 1 && maxDauType == 1 && motherType == 9)
4587 else if (minDauType == 1 && maxDauType == 7 && motherType == 1) {
4589 if (idDau1 == 22 || idDau2 == 22) MEcombi = 1;
4592 }
else if (minDauType == 1 && maxDauType == 1 && motherType == 8) {
4594 if (idMother == 25 || idMother == 35 || idMother == 37) MEcombi = 1;
4595 else if (idMother == 36) MEcombi = 2;
4597 else if (minDauType == 1 && maxDauType == 8 && motherType == 1)
4601 else if (minDauType == 2 && maxDauType == 2 && (motherType == 4
4602 || motherType == 7) ) MEkind = 6;
4603 else if (minDauType == 2 && (maxDauType == 4 || maxDauType == 7)
4604 && motherType == 2) MEkind = 7;
4605 else if (minDauType == 2 && maxDauType == 2 && motherType == 8)
4607 else if (minDauType == 2 && maxDauType == 8 && motherType == 2)
4611 else if (minDauType == 1 && maxDauType == 2 && motherType == 9)
4613 else if (minDauType == 1 && maxDauType == 9 && motherType == 2)
4615 else if (minDauType == 2 && maxDauType == 9 && motherType == 1)
4619 else if (minDauType == 1 && maxDauType == 2 && motherType == 5)
4621 else if (minDauType == 1 && maxDauType == 5 && motherType == 2)
4623 else if (minDauType == 2 && maxDauType == 5 && motherType == 1)
4628 else if (minDauType == 1 && maxDauType == 9 && motherType == 3)
4631 else if (minDauType == 3 && maxDauType == 9 && motherType == 1)
4635 else if (minDauType == 5 && maxDauType == 5) MEkind = 16;
4638 dip.MEtype = 5 * MEkind + MEcombi;
4641 }
else if (dip.chgType != 0) {
4646 if (dip.MEtype >= 0)
return;
4649 int idDau1 =
event[dip.iRadiator].id();
4650 int idDau2 =
event[dip.iMEpartner].id();
4651 if (abs(idDau1) < 9 && abs(idDau2) < 9 && idDau1 * idDau2 < 0) ;
4652 else if (abs(idDau1) > 10 && abs(idDau1) < 19 && abs(idDau2) > 10
4653 && abs(idDau2) < 19 && idDau1 * idDau2 < 0) ;
4654 else { dip.MEtype = 0;
return; }
4658 if (idDau1 + idDau2 == 0) dip.MEtype = 102;
4663 else if (dip.weakType == 1) {
4664 if (event[dip.iRadiator].id() == -
event[dip.iRecoiler].id()
4665 ||
event[
event[dip.iRadiator].mother1()].idAbs() == 24
4666 || infoPtr->nFinal() != 2) dip.MEtype = 200;
4667 else if (event[dip.iRadiator].idAbs() == 21
4668 ||
event[dip.iRecoiler].idAbs() == 21) dip.MEtype = 201;
4669 else if (event[dip.iRadiator].id() ==
event[dip.iRecoiler].id())
4671 else dip.MEtype = 203;
4672 }
else if (dip.weakType == 2) {
4673 if (event[dip.iRadiator].id() == -
event[dip.iRecoiler].id()
4674 ||
event[
event[dip.iRadiator].mother1()].idAbs() == 24) dip.MEtype = 205;
4675 else if (event[dip.iRadiator].idAbs() == 21
4676 ||
event[dip.iRecoiler].idAbs() == 21) dip.MEtype = 206;
4677 else if (event[dip.iRadiator].id() ==
event[dip.iRecoiler].id())
4679 else dip.MEtype = 208;
4690 int TimeShower::findMEparticle(
int id,
bool isHiddenColour) {
4694 int colType = abs(particleDataPtr->colType(
id));
4695 int spinType = particleDataPtr->spinType(
id);
4699 if (isHiddenColour) {
4701 int idAbs = abs(
id);
4702 if ( (idAbs > 4900000 && idAbs < 4900007)
4703 || (idAbs > 4900010 && idAbs < 4900017)
4704 || (idAbs > 4900100 && idAbs < 4900109) ) colType = 1;
4708 if (colType == 1 && spinType == 2) type = 1;
4709 else if (colType == 1 && spinType == 1) type = 2;
4710 else if (colType == 1) type = 3;
4711 else if (colType == 2 && spinType == 3) type = 4;
4712 else if (colType == 2 && spinType == 2) type = 5;
4713 else if (colType == 2) type = 6;
4714 else if (colType == 0 && spinType == 3) type = 7;
4715 else if (colType == 0 && spinType == 1) type = 8;
4716 else if (colType == 0 && spinType == 2) type = 9;
4727 double TimeShower::gammaZmix(
Event& event,
int iRes,
int iDau1,
int iDau2) {
4732 int iIn1 = (iRes >= 0) ? event[iRes].mother1() : -1;
4733 int iIn2 = (iRes >= 0) ? event[iRes].mother2() : -1;
4734 if (iIn1 > 0 && iIn2 <= 0 && event[iDau1].mother2() > 0)
4735 iIn2 = event[event[iDau1].mother2()].mother1();
4736 if (iIn1 >=0) idIn1 =
event[iIn1].id();
4737 if (iIn2 >=0) idIn2 =
event[iIn2].id();
4740 if (idIn1 == 21 || idIn1 == 22) idIn1 = -idIn2;
4741 if (idIn2 == 21 || idIn2 == 22) idIn2 = -idIn1;
4744 if (idIn1 + idIn2 != 0 )
return 0.5;
4745 int idInAbs = abs(idIn1);
4746 if (idInAbs == 0 || idInAbs > 18 )
return 0.5;
4747 double ei = coupSMPtr->ef(idInAbs);
4748 double vi = coupSMPtr->vf(idInAbs);
4749 double ai = coupSMPtr->af(idInAbs);
4752 if (event[iDau1].
id() + event[iDau2].
id() != 0)
return 0.5;
4753 int idOutAbs = abs(event[iDau1].
id());
4754 if (idOutAbs == 0 || idOutAbs >18 )
return 0.5;
4755 double ef = coupSMPtr->ef(idOutAbs);
4756 double vf = coupSMPtr->vf(idOutAbs);
4757 double af = coupSMPtr->af(idOutAbs);
4760 Vec4 psum =
event[iDau1].p() +
event[iDau2].p();
4761 double sH = psum.m2Calc();
4762 double intNorm = 2. * thetaWRat * sH * (sH - mZ*mZ)
4763 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
4764 double resNorm = pow2(thetaWRat * sH)
4765 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
4768 double vect = ei*ei * ef*ef + ei*vi * intNorm * ef*vf
4769 + (vi*vi + ai*ai) * resNorm * vf*vf;
4770 double axiv = (vi*vi + ai*ai) * resNorm * af*af;
4771 return vect / (vect + axiv);
4779 double TimeShower::findMEcorr(TimeDipoleEnd* dip, Particle& rad,
4780 Particle& partner, Particle& emt,
bool cutEdge) {
4785 int MEkind = dip->MEtype / 5;
4786 int MEcombi = dip->MEtype % 5;
4789 Vec4 sum = rad.p() + partner.p() + emt.p();
4790 double eCMME = sum.mCalc();
4791 double x1 = 2. * (sum * rad.p()) / pow2(eCMME);
4792 double x2 = 2. * (sum * partner.p()) / pow2(eCMME);
4793 double r1 = rad.m() / eCMME;
4794 double r2 = partner.m() / eCMME;
4798 double gammavCorr = 1.;
4799 if (dip->colvType != 0 && brokenHVsym) {
4800 r3 = emt.m() / eCMME;
4801 double x3Tmp = 2. - x1 - x2;
4802 gammavCorr = x3Tmp / (x3Tmp - kRad * (x1 + x3Tmp));
4805 double m2Pair = (rad.p() + partner.p()).m2Calc();
4806 double m2Avg = 0.5 * (rad.m2() + partner.m2())
4807 - 0.25 * pow2(rad.m2() - partner.m2()) / m2Pair;
4808 r1 = sqrt(m2Avg) / eCMME;
4810 double xShift = 0.5 * (x1 + x2) * (partner.m2() - rad.m2()) / m2Pair;
4817 double x1minus, x2minus, x3;
4819 x1minus = max(XMARGIN, 1. + r1*r1 - r2*r2 - x1);
4820 x2minus = max(XMARGIN, 1. + r2*r2 - r1*r1 - x2) ;
4821 x3 = max(XMARGIN, 2. - x1 - x2);
4823 x1minus = max(XMARGIN*XMARGIN, 1. + r1*r1 - r2*r2 - x1);
4824 x2minus = max(XMARGIN*XMARGIN, 1. + r2*r2 - r1*r1 - x2) ;
4825 x3 = max(XMARGIN*XMARGIN, 2. - x1 - x2);
4829 if (dip->colType !=0 || dip->colvType != 0) {
4832 if (dip->MEorder) wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix,
4833 x1, x2, r1, r2, r3, cutEdge);
4834 else wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix,
4835 x2, x1, r2, r1, r3, cutEdge);
4838 if (dip->MEsplit) wtME = wtME * x1minus / x3;
4841 wtPS = 2. / ( x3 * x2minus );
4842 if (dip->MEgluinoRec) wtPS *= 9./4.;
4843 if (dip->colvType != 0 && brokenHVsym) wtPS *= gammavCorr;
4847 }
else if (dip->chgType !=0 && dip->MEtype == 101) {
4848 double chg1 = particleDataPtr->charge(rad.id());
4849 double chg2 = particleDataPtr->charge(partner.id());
4850 wtME = (x1*x1 + x2*x2) * pow2( chg1 * x1minus / x3
4851 - chg2 * x2minus / x3 );
4852 wtPS = 2. * ( chg1*chg1 * x1minus / x3 + chg2*chg2 * x2minus / x3 );
4855 }
else if (dip->chgType !=0 && dip->MEtype == 102) {
4856 wtME = calcMEcorr(2, 1, dip->MEmix, x1, x2, r1, r2, 0., cutEdge)
4858 wtPS = 2. / ( x3 * x2minus );
4863 else if (dip->MEtype == 200 || dip->MEtype == 205) {
4864 r3 = emt.m() / eCMME;
4865 wtME = calcMEcorr(32, 1, dip->MEmix, x1, x2, r1, r2, r3, cutEdge)
4867 wtPS = 8. / (x3 * x2minus);
4868 wtPS *= x3 / (x3 - kRad * (x1 + x3));
4871 else if (dip->MEtype == 201 || dip->MEtype == 202
4872 || dip->MEtype == 203 || dip->MEtype == 205
4873 || dip->MEtype == 206 || dip->MEtype == 207)
return 1.;
4876 if (wtME > wtPS) infoPtr->errorMsg(
"Warning in TimeShower::findMEcorr: "
4877 "ME weight above PS one");
4915 double TimeShower::calcMEcorr(
int kind,
int combiIn,
double mixIn,
4916 double x1,
double x2,
double r1,
double r2,
double r3,
bool cutEdge) {
4919 double x3 = 2. - x1 - x2;
4920 double x1s = x1 * x1;
4921 double x2s = x2 * x2;
4922 double x3s = x3 * x3;
4923 double x1c = x1 * x1s;
4924 double x2c = x2 * x2s;
4925 double x3c = x3 * x3s;
4926 double r1s = r1 * r1;
4927 double r2s = r2 * r2;
4928 double r1c = r1 * r1s;
4929 double r2c = r2 * r2s;
4930 double r1q = r1s * r1s;
4931 double r2q = r2s * r2s;
4932 double prop1 = 1. + r1s - r2s - x1;
4933 double prop2 = 1. + r2s - r1s - x2;
4934 double prop1s = prop1 * prop1;
4935 double prop2s = prop2 * prop2;
4936 double prop12 = prop1 * prop2;
4937 double prop13 = prop1 * x3;
4938 double prop23 = prop2 * x3;
4941 double r3s = r3 * r3;
4942 double prop3 = r3s - x3;
4943 double prop3s = prop3 * prop3;
4944 if (kind == 30) prop13 = prop1 * prop3;
4948 if (x1 - 2.*r1 < XMARGIN || prop1 < XMARGIN)
return 0.;
4949 if (x2 - 2.*r2 < XMARGIN || prop2 < XMARGIN)
return 0.;
4951 if (kind != 30 && kind != 31) {
4952 if (x1 + x2 - 1. - pow2(r1+r2) < XMARGIN)
return 0.;
4956 if ( (x1s - 4.*r1s) * (x2s - 4.*r2s)
4957 - pow2( 2. * (1. - x1 - x2 + r1s + r2s) + x1*x2 )
4958 < XMARGIN * (XMARGINCOMB + r1 + r2) )
return 0.;
4963 int combi = max(1, min(4, combiIn) );
4964 double mix = max(0., min(1., mixIn) );
4965 bool isSet1 =
false;
4966 bool isSet2 =
false;
4967 bool isSet4 =
false;
4968 double ps = sqrtpos( pow2(1. - r1*r1 - r2*r2) - pow2(2. * r1 * r2) );
4969 double rLO = 0., rFO = 0., rLO1 = 0., rFO1 = 0., rLO2 = 0.,
4970 rFO2 = 0., rLO4 = 0., rFO4 = 0.;
4980 if (combi == 1 || combi == 3) {
4981 rLO1 = ps*(2.-r1s-r1q+6.*r1*r2-r2s+2.*r1s*r2s-r2q)/2.;
4982 rFO1 = -(3.+6.*r1s+r1q-6.*r1*r2+6.*r1c*r2-2.*r2s-6.*r1s*r2s
4983 +6.*r1*r2c+r2q-3.*x1+6.*r1*r2*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(combi == 2 || combi == 3) {
5306 rLO2 = ps*(1.-pow2(r1-r2));
5307 rFO2 = (1.+r1s-2.*r1*r2+r2s-x1-x2)*(x1+x2)
5309 -(-1.+r1q+2.*r1*r2+2.*r1c*r2-6.*r1s*r2s+2.*r1*r2c+r2q+x1
5310 -r1s*x1+r2s*x1+x2+3.*r1s*x2-2.*r1*r2*x2-r2s*x2-x1*x2)
5312 +(-1.-2.*r1s-r1q+2.*r1*r2+2.*r1c*r2-2.*r1*r2c+r2q+x1+r1s*x1
5313 +2.*r1*r2*x1-3.*r2s*x1+2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
5318 rLO4 = ps*(1.-r1s-r2s);
5319 rFO4 = (1.+r1s+r2s-x1-x2)*(x1+x2)
5321 -(-1.+r1q-6.*r1s*r2s+r2q+x1-r1s*x1+r2s*x1+x2
5322 +3.*r1s*x2-r2s*x2-x1*x2)
5324 +(-1.-2.*r1s-r1q+r2q+x1+r1s*x1-3.*r2s*x1
5325 +2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
5333 if (combi == 1 || combi == 3) {
5334 rLO1 = ps*(1.-r1s+r2s+2.*r2);
5335 rFO1 = (2.*r2+x2)*(-1.-r1s-r2s+x2)
5337 +(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1-2.*r2*x1+r2s*x1+x1s
5338 -3.*x2-r1s*x2-2.*r2*x2+r2s*x2+x1*x2)
5340 +2.*(-1.-r1s+r2+r1s*r2-r2s-r2c+x1+r2*x1+r2s*x1+2.*x2
5341 +r1s*x2-x1*x2*0.5-x2s*0.5)
5345 if (combi == 2 || combi == 3) {
5346 rLO2 = ps*(1.-r1s+r2s-2.*r2);
5347 rFO2 = (2.*r2-x2)*(1.+r1s+r2s-x2)
5349 +(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1+2.*r2*x1+r2s*x1+x1s
5350 -3.*x2-r1s*x2+2.*r2*x2+r2s*x2+x1*x2)
5352 +2.*(-1.-r1s-r2-r1s*r2-r2s+r2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 -x2-r1s*x2+r2s*x2+x1*x2)
5570 -16.*(-1.-r1s-r2s+x1+r2s*x1+2.*x2+r1s*x2-x1*x2*0.5-x2s*0.5)
5580 if (combi == 2) offset = x3s;
5581 else if (combi == 3) offset = mix * x3s;
5582 else if (combi == 4) offset = 0.5 * x3s;
5583 rFO = ps * 4.5 * ( (x1+x2-1.+offset-r1s-r2s)/prop12
5584 - r1s/prop2s - r2s/prop1s );
5589 rLO = ps*(1.-r1s+r2s+2.*r2);
5590 rFO = ( 0.5*r3s + 2.*r1q + 0.5*r2s*r3s + r2*r3s - 2.*r1s
5591 - 0.5*r1s*r3s - 2.*r1s*r2s - 4.*r1s*r2 ) / prop2s
5592 + ( -2. + 2.*r2q + 2.*r1q + 2.*r2s*r3s - 4.*r2 + 2.*r2*r3s
5593 + 4.*r2*r2s - 4.*r1s*r2s - 4.*r1s*r2 ) /prop23
5594 + ( -2. - 0.5*r3s - 2.*r2s - 4.*r2 + 2.*r1s ) / prop2
5595 + ( -2. - r3s - 2.*r2s - r2s*r3s - 4.*r2 - 2.*r2*r3s
5596 + 2.*r1s + r1s*r3s ) / prop3s
5597 + ( -1. - r3s - r2s - 4.*r2 + r1s - x2 ) / prop3
5603 rLO = ps*(1.-4.*r1s);
5604 rFO = (r3s + 2.*r1s) * (-1. + 4.*r1s) * (1./prop1s + 1./prop2s)
5605 + (-1. + 8.*r1s - x2) / prop1
5606 + (-1. + 8.*r1s - x1) / prop2
5607 + 2. * (1. - 6.*r1s + 8.*r1q + 4.*r3s*r1s) / prop12
5614 rFO = (2. * r3s * r3s + 2. * r3s * (x1 + x2) + x1s + x2s) / prop12
5615 - r3s / prop1s - r3s / prop2s;
5621 rFO = (2. * r3s * r3s + 2. * r3s * (x1 + x2) + x1s + x2s) / prop12
5622 - r3s / prop1s - r3s / prop2s;
5628 if (combi == 2) offset = x3s;
5629 else if (combi == 3) offset = mix * x3s;
5630 else if (combi == 4) offset = 0.5 * x3s;
5631 rFO = ps * 2. * ( (x1+x2-1.+offset-r1s-r2s)/prop12
5632 - r1s/prop2s - r2s/prop1s );
5639 if (combi == 1 && isSet1) {
5642 else if (combi == 2 && isSet2) {
5645 else if (combi == 3 && isSet1 && isSet2) {
5646 rLO = mix * rLO1 + (1.-mix) * rLO2;
5647 rFO = mix * rFO1 + (1.-mix) * rFO2; }
5651 else if (combi == 4 && isSet1 && isSet2) {
5652 rLO = 0.5 * (rLO1 + rLO2);
5653 rFO = 0.5 * (rFO1 + rFO2); }
5666 double TimeShower::findMEcorrWeak(TimeDipoleEnd* dip,Vec4 rad,
5667 Vec4 rec, Vec4 emt,Vec4 p3,Vec4 p4,Vec4 radBef, Vec4 recBef) {
5670 if (dip->MEtype > 210 || dip->MEtype < 200)
return 1.;
5675 if (infoPtr->nISR() + infoPtr->nFSRinProc() == 0
5676 && infoPtr->code() > 110 && infoPtr->code() < 130
5678 double d = emt.pT2();
5679 if (rad.pT2() < d) {d = rad.pT2(); cut =
true;}
5680 if (rec.pT2() < d) {d = rec.pT2(); cut =
true;}
5683 double dij = min(rad.pT2(),emt.pT2())
5684 * pow2(RRapPhi(rad,emt)) / vetoWeakDeltaR2;
5692 if (dip->MEtype == 200 || dip->MEtype == 205 ||
5693 dip->MEtype == 201 || dip->MEtype == 206) {
5694 dij = min(rad.pT2(),rec.pT2()) * pow2(RRapPhi(rad,rec))
5702 if (dip->MEtype == 200 || dip->MEtype == 205 ||
5703 dip->MEtype == 202 || dip->MEtype == 207 ||
5704 dip->MEtype == 203 || dip->MEtype == 208) {
5705 dij = min(emt.pT2(),rec.pT2()) * pow2(RRapPhi(emt,rec))
5716 if ( dip->MEtype != 201 && dip->MEtype != 202 && dip->MEtype != 203
5717 && dip->MEtype != 206 && dip->MEtype != 207 && dip->MEtype != 208)
5721 double scaleFactor2 = (rad + rec + emt).m2Calc() / (p3 + p4).m2Calc();
5722 double scaleFactor = sqrt(scaleFactor2);
5727 RotBstMatrix rot2to2frame;
5728 rot2to2frame.bstback(p3 + p4);
5729 p3.rotbst(rot2to2frame);
5730 p4.rotbst(rot2to2frame);
5731 rad.rotbst(rot2to2frame);
5732 emt.rotbst(rot2to2frame);
5733 rec.rotbst(rot2to2frame);
5734 recBef.rotbst(rot2to2frame);
5735 radBef.rotbst(rot2to2frame);
5738 RotBstMatrix rot2to3frame;
5739 rot2to3frame.bstback(rad + emt + rec);
5740 rad.rotbst(rot2to3frame);
5741 emt.rotbst(rot2to3frame);
5742 rec.rotbst(rot2to3frame);
5743 recBef.rotbst(rot2to3frame);
5744 radBef.rotbst(rot2to3frame);
5747 double sHat = (p3 + p4).m2Calc();
5748 double tHat = (radBef - p3).m2Calc();
5749 double uHat = (recBef - p3).m2Calc();
5751 double pT2 = dip->pT2;
5752 double Q2 = pT2 / (z*(1.-z));
5755 double wt = 2. * pT2 / z * (Q2+sHat)/sHat * (1. - kRad - kEmt) / 4.;
5756 if (dip->MEtype == 201 || dip->MEtype == 206)
5757 wt *= weakShowerMEs.getMEqg2qgZ( p3, p4, rec, emt, rad)
5758 / weakShowerMEs.getMEqg2qg( sHat, tHat, uHat);
5759 else if (dip->MEtype == 202 || dip->MEtype == 207)
5760 wt *= weakShowerMEs.getMEqq2qqZ( p3, p4, emt, rec, rad)
5761 / weakShowerMEs.getMEqq2qq( sHat, tHat, uHat,
true);
5762 else if (dip->MEtype == 203 || dip->MEtype == 208)
5763 wt *= weakShowerMEs.getMEqq2qqZ( p3, p4, emt, rec, rad)
5764 / weakShowerMEs.getMEqq2qq( sHat, tHat, uHat,
false);
5767 wt *= abs((-emt + p3).m2Calc()) / ((emt + rad).m2Calc()
5768 + abs((-p3 + emt).m2Calc()));
5772 if (wt > 1.) infoPtr->errorMsg(
"Warning in TimeShower::findMEcorrWeak: "
5773 "weight is above unity");
5782 void TimeShower::findAsymPol(
Event& event, TimeDipoleEnd* dip) {
5787 int iRad = dip->iRadiator;
5788 if (!doPhiPolAsym || event[iRad].
id() != 21)
return;
5791 int iMother =
event[iRad].iTopCopy();
5792 int iGrandM =
event[iMother].mother1();
5796 int statusGrandM =
event[iGrandM].status();
5797 bool isHardProc = (statusGrandM == -21 || statusGrandM == -31);
5799 if (!doPhiPolAsymHard)
return;
5800 if (event[iGrandM + 1].status() != statusGrandM)
return;
5801 if (event[iGrandM].isGluon() &&
event[iGrandM + 1].isGluon());
5802 else if (event[iGrandM].isQuark() &&
event[iGrandM + 1].isQuark());
5807 if (isHardProc) dip->iAunt = dip->iRecoiler;
5808 else dip->iAunt = (
event[iGrandM].daughter1() == iMother)
5809 ? event[iGrandM].daughter2() :
event[iGrandM].daughter1();
5813 double zProd = (isHardProc) ? 0.5 : event[iRad].e()
5814 / (
event[iRad].e() +
event[dip->iAunt].e());
5815 if (event[iGrandM].isGluon()) dip->asymPol = pow2( (1. - zProd)
5816 / (1. - zProd * (1. - zProd) ) );
5817 else dip->asymPol = 2. * (1. - zProd) / (1. + pow2(1. - zProd) );
5820 if (dip->flavour == 21) dip->asymPol *= pow2( dip->z * (1. - dip->z)
5821 / (1. - dip->z * (1. - dip->z) ) );
5822 else dip->asymPol *= -2. * dip->z * ( 1. - dip->z )
5823 / (1. - 2. * dip->z * (1. - dip->z) );
5831 void TimeShower::list()
const {
5834 cout <<
"\n -------- PYTHIA TimeShower Dipole Listing ----------------"
5835 <<
"------------------------------------------------------- \n \n "
5836 <<
" i rad rec pTmax col chg gam weak oni hv is"
5837 <<
"r sys sysR type MErec mix ord spl ~gR pol \n"
5838 << fixed << setprecision(3);
5841 for (
int i = 0; i < int(dipEnd.size()); ++i)
5842 cout << setw(5) << i << setw(7) << dipEnd[i].iRadiator
5843 << setw(7) << dipEnd[i].iRecoiler << setw(12) << dipEnd[i].pTmax
5844 << setw(5) << dipEnd[i].colType << setw(5) << dipEnd[i].chgType
5845 << setw(5) << dipEnd[i].gamType << setw(5) << dipEnd[i].weakType
5846 << setw(5) << dipEnd[i].isOctetOnium
5847 << setw(5) << dipEnd[i].isHiddenValley << setw(5) << dipEnd[i].isrType
5848 << setw(5) << dipEnd[i].system << setw(5) << dipEnd[i].systemRec
5849 << setw(5) << dipEnd[i].MEtype << setw(7) << dipEnd[i].iMEpartner
5850 << setw(8) << dipEnd[i].MEmix << setw(5) << dipEnd[i].MEorder
5851 << setw(5) << dipEnd[i].MEsplit << setw(5) << dipEnd[i].MEgluinoRec
5852 << setw(5) << dipEnd[i].weakPol <<
"\n";
5855 cout <<
"\n -------- End PYTHIA TimeShower Dipole Listing ------------"
5856 <<
"-------------------------------------------------------" << endl;