9 #include "Pythia8/SimpleTimeShower.h"
23 const double SimpleTimeShower::MCMIN = 1.2;
24 const double SimpleTimeShower::MBMIN = 4.0;
27 const double SimpleTimeShower::SIMPLIFYROOT = 1e-8;
32 const double SimpleTimeShower::XMARGIN = 1e-12;
33 const double SimpleTimeShower::XMARGINCOMB = 1e-4;
36 const double SimpleTimeShower::TINYPDF = 1e-10;
39 const double SimpleTimeShower::LARGEM2 = 1e20;
42 const double SimpleTimeShower::THRESHM2 = 4.004;
45 const double SimpleTimeShower::LAMBDA3MARGIN = 1.1;
50 const bool SimpleTimeShower::FIXRESCATTER =
true;
52 const bool SimpleTimeShower::VETONEGENERGY =
false;
54 const double SimpleTimeShower::MAXVIRTUALITYFRACTION = 0.5;
56 const double SimpleTimeShower::MAXNEGENERGYFRACTION = 0.7;
59 const double SimpleTimeShower::WEAKPSWEIGHT = 5.;
62 const double SimpleTimeShower::WG2QEXTRA = 20.;
65 const double SimpleTimeShower::REJECTFACTOR = 0.1;
68 const double SimpleTimeShower::PROBLIMIT = 0.99;
74 void SimpleTimeShower::init( BeamParticle* beamAPtrIn,
75 BeamParticle* beamBPtrIn) {
78 beamAPtr = beamAPtrIn;
79 beamBPtr = beamBPtrIn;
82 doQCDshower = flag(
"TimeShower:QCDshower");
83 doQEDshowerByQ = flag(
"TimeShower:QEDshowerByQ");
84 doQEDshowerByL = flag(
"TimeShower:QEDshowerByL");
85 doQEDshowerByOther = flag(
"TimeShower:QEDshowerByOther");
86 doQEDshowerByGamma = flag(
"TimeShower:QEDshowerByGamma");
87 doWeakShower = flag(
"TimeShower:weakShower");
88 doMEcorrections = flag(
"TimeShower:MEcorrections");
89 doMEextended = flag(
"TimeShower:MEextended");
90 if (!doMEcorrections) doMEextended =
false;
91 doMEafterFirst = flag(
"TimeShower:MEafterFirst");
92 doPhiPolAsym = flag(
"TimeShower:phiPolAsym");
93 doPhiPolAsymHard = flag(
"TimeShower:phiPolAsymHard");
94 doInterleave = flag(
"TimeShower:interleave");
95 allowBeamRecoil = flag(
"TimeShower:allowBeamRecoil");
96 dampenBeamRecoil = flag(
"TimeShower:dampenBeamRecoil");
97 recoilToColoured = flag(
"TimeShower:recoilToColoured");
98 allowMPIdipole = flag(
"TimeShower:allowMPIdipole");
101 doDipoleRecoil = flag(
"SpaceShower:dipoleRecoil");
102 if (doDipoleRecoil) {allowBeamRecoil =
true; dampenBeamRecoil =
false;}
105 pTmaxMatch = mode(
"TimeShower:pTmaxMatch");
106 pTdampMatch = mode(
"TimeShower:pTdampMatch");
107 pTmaxFudge = parm(
"TimeShower:pTmaxFudge");
108 pTmaxFudgeMPI = parm(
"TimeShower:pTmaxFudgeMPI");
109 pTdampFudge = parm(
"TimeShower:pTdampFudge");
112 mc = max( MCMIN, particleDataPtr->m0(4));
113 mb = max( MBMIN, particleDataPtr->m0(5));
118 renormMultFac = parm(
"TimeShower:renormMultFac");
119 factorMultFac = parm(
"TimeShower:factorMultFac");
120 useFixedFacScale = flag(
"TimeShower:useFixedFacScale");
121 fixedFacScale2 = pow2(parm(
"TimeShower:fixedFacScale"));
124 alphaSvalue = parm(
"TimeShower:alphaSvalue");
125 alphaSorder = mode(
"TimeShower:alphaSorder");
126 alphaSnfmax = mode(
"StandardModel:alphaSnfmax");
127 alphaSuseCMW = 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 = mode(
"TimeShower:nGluonToQuark");
143 weightGluonToQuark = mode(
"TimeShower:weightGluonToQuark");
144 scaleGluonToQuark = parm(
"TimeShower:scaleGluonToQuark");
145 extraGluonToQuark = (weightGluonToQuark%4 == 3) ? WG2QEXTRA : 1.;
146 recoilDeadCone = flag(
"TimeShower:recoilDeadCone");
147 pTcolCutMin = 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 = mode(
"TimeShower:alphaEMorder");
164 alphaEM.init( alphaEMorder, settingsPtr);
167 nGammaToQuark = mode(
"TimeShower:nGammaToQuark");
168 nGammaToLepton = mode(
"TimeShower:nGammaToLepton");
169 pTchgQCut = parm(
"TimeShower:pTminChgQ");
170 pT2chgQCut = pow2(pTchgQCut);
171 pTchgLCut = parm(
"TimeShower:pTminChgL");
172 pT2chgLCut = pow2(pTchgLCut);
173 mMaxGamma = parm(
"TimeShower:mMaxGamma");
174 m2MaxGamma = pow2(mMaxGamma);
177 weakMode = mode(
"TimeShower:weakShowerMode");
178 pTweakCut = parm(
"TimeShower:pTminWeak");
179 pT2weakCut = pow2(pTweakCut);
180 weakEnhancement = parm(
"WeakShower:enhancement");
181 singleWeakEmission = flag(
"WeakShower:singleEmission");
182 vetoWeakJets = flag(
"WeakShower:vetoWeakJets");
183 vetoWeakDeltaR2 = pow2(parm(
"WeakShower:vetoWeakDeltaR"));
184 weakExternal = flag(
"WeakShower:externalSetup");
187 if (nGammaToQuark <= 0 && nGammaToLepton <= 0) doQEDshowerByGamma =
false;
190 globalRecoil = flag(
"TimeShower:globalRecoil");
191 nMaxGlobalRecoil = mode(
"TimeShower:nMaxGlobalRecoil");
193 nMaxGlobalBranch = mode(
"TimeShower:nMaxGlobalBranch");
195 nFinalBorn = mode(
"TimeShower:nPartonsInBorn");
197 globalRecoilMode = mode(
"TimeShower:globalRecoilMode");
199 limitMUQ = flag(
"TimeShower:limitPTmaxGlobal");
202 octetOniumFraction = parm(
"TimeShower:octetOniumFraction");
203 octetOniumColFac = 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 = flag(
"PartonLevel:MPI")
215 && flag(
"MultipartonInteractions:allowRescatter");
218 doHVshower = flag(
"HiddenValley:FSR");
219 nCHV = mode(
"HiddenValley:Ngauge");
220 alphaHVfix = parm(
"HiddenValley:alphaFSR");
221 alphaHVorder = (nCHV > 1 )
222 ? mode(
"HiddenValley:alphaOrder") : 0;
223 nFlavHV = mode(
"HiddenValley:nFlav");
224 LambdaHV = parm(
"HiddenValley:Lambda");
225 pThvCut = 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 SimpleTimeShower::init: Hidden Valley ",
235 "pTmin too low, raised to " + newPTcolCut.str() );
237 pT2hvCut = pThvCut * pThvCut;
240 doSecondHard = flag(
"SecondHard:generate");
241 twoHard = doSecondHard;
244 hasUserHooks = (userHooksPtr != 0);
245 canVetoEmission = hasUserHooks && userHooksPtr->canVetoFSREmission();
252 hasWeaklyRadiated =
false;
255 canEnhanceEmission = hasUserHooks && userHooksPtr->canEnhanceEmission();
256 canEnhanceTrial = hasUserHooks && userHooksPtr->canEnhanceTrial();
257 if (canEnhanceEmission && canEnhanceTrial) {
258 infoPtr->errorMsg(
"Error in SimpleTimeShower::init: Enhance for both "
259 "actual and trial emissions not possible. Both switched off.");
260 canEnhanceEmission =
false;
261 canEnhanceTrial =
false;
266 canEnhanceET =
false;
269 splittingNameSel =
"";
270 splittingNameNow =
"";
271 enhanceFactors.clear();
275 doUncertainties = flag(
"UncertaintyBands:doVariations")
276 && initUncertainties();
277 doUncertaintiesNow = doUncertainties;
278 uVarNflavQ = mode(
"UncertaintyBands:nFlavQ");
279 uVarMPIshowers = flag(
"UncertaintyBands:MPIshowers");
280 cNSpTmin = parm(
"UncertaintyBands:cNSpTmin");
281 uVarpTmin2 = pT2colCut;
282 uVarpTmin2 *= parm(
"UncertaintyBands:FSRpTmin2Fac");
283 int varType = mode(
"UncertaintyBands:type");
284 noResVariations = (varType == 1) ?
true:
false;
285 noProcVariations = (varType == 2) ?
true:
false;
286 overFactor = parm(
"UncertaintyBands:overSampleFSR");
289 doPartonVertex = flag(
"PartonVertex:setVertex")
290 && (partonVertexPtr != 0);
299 bool SimpleTimeShower::limitPTmax(
Event& event,
double Q2Fac,
double Q2Ren) {
302 twoHard = doSecondHard;
303 bool dopTlimit =
false;
304 dopTlimit1 = dopTlimit2 =
false;
306 if (pTmaxMatch == 1) dopTlimit = dopTlimit1 = dopTlimit2 =
true;
307 else if (pTmaxMatch == 2) dopTlimit = dopTlimit1 = dopTlimit2 =
false;
310 else if (infoPtr->isNonDiffractive() || infoPtr->isDiffractiveA()
311 || infoPtr->isDiffractiveB() || infoPtr->isDiffractiveC() )
312 dopTlimit = dopTlimit1 = dopTlimit2 =
true;
318 int iBegin = 5 + beamOffset;
319 for (
int i = iBegin; i <
event.size(); ++i) {
320 if (event[i].status() == -21) ++n21;
322 int idAbs =
event[i].idAbs();
323 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit1 =
true;
324 if ( (event[i].col() != 0 || event[i].acol() != 0)
325 && idAbs > 5 && idAbs != 21 ) ++nHeavyCol;
326 }
else if (n21 == 2) {
327 int idAbs =
event[i].idAbs();
328 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) dopTlimit2 =
true;
331 twoHard = (n21 == 2);
332 dopTlimit = (twoHard) ? (dopTlimit1 && dopTlimit2) : dopTlimit1;
338 if (!dopTlimit1 && (pTdampMatch == 1 || pTdampMatch == 2)) {
340 pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 1) ? Q2Fac : Q2Ren);
342 if (!dopTlimit1 && nHeavyCol > 1 && (pTdampMatch == 3 || pTdampMatch == 4)) {
344 pT2damp = pow2(pTdampFudge) * ((pTdampMatch == 3) ? Q2Fac : Q2Ren);
356 int SimpleTimeShower::shower(
int iBeg,
int iEnd,
Event& event,
double pTmax,
360 int iSys = partonSystemsPtr->addSys();
365 bool isResDec =
true;
367 for (
int i = iBeg; i <= iEnd; ++i) {
368 if (event[i].isFinal()) {
369 partonSystemsPtr->addOut( iSys, i);
370 pSum +=
event[i].p();
372 if ( event[i].mother2() != 0 && event[i].mother1() != event[i].mother2())
374 else if ( iRes != -1 && event[i].mother1() != iRes)
377 iRes =
event[i].mother1();
380 partonSystemsPtr->setSHat( iSys, pSum.m2Calc() );
381 if (isResDec) partonSystemsPtr->setInRes( iSys, iRes);
387 hasWeaklyRadiated =
false;
388 prepare( iSys, event,
true);
394 double pTtimes = pTnext( event, pTmax, 0.);
398 if (branch( event)) {
400 pTLastBranch = pTtimes;
407 }
while (pTmax > 0. && (nBranchMax <= 0 || nBranch < nBranchMax));
419 int SimpleTimeShower::showerQED(
int i1,
int i2,
Event& event,
double pTmax) {
422 int iSys = partonSystemsPtr->addSys();
423 partonSystemsPtr->addOut( iSys, i1);
424 partonSystemsPtr->addOut( iSys, i2);
425 partonSystemsPtr->setSHat( iSys, m2(event[i1], event[i2]) );
427 partonSystemsPtr->setInRes( iSys, event[i1].mother1() );
430 int iChg1 =
event[i1].chargeType();
431 int iChg2 =
event[i2].chargeType();
432 int MEtype = (iChg1 + iChg2 == 0) ? 102 : 101;
436 if (iChg1 != 0) dipEnd.push_back( TimeDipoleEnd(i1, i2, pTmax,
437 0, iChg1, 0, 0, 0, iSys, MEtype, i2) );
438 if (iChg2 != 0) dipEnd.push_back( TimeDipoleEnd(i2, i1, pTmax,
439 0, iChg2, 0, 0, 0, iSys, MEtype, i1) );
450 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
451 TimeDipoleEnd& dip = dipEnd[iDip];
454 dip.mRad =
event[dip.iRadiator].m();
455 dip.mRec =
event[dip.iRecoiler].m();
456 dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
457 dip.m2Rad = pow2(dip.mRad);
458 dip.m2Rec = pow2(dip.mRec);
459 dip.m2Dip = pow2(dip.mDip);
462 dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
463 double pTbegDip = min( pTmax, dip.pTmax );
464 double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
468 if (pT2begDip > pT2sel) {
469 pT2nextQED( pT2begDip, pT2sel, dip, event);
472 if (dip.pT2 > pT2sel) {
479 double pTsel = (dipSel == 0) ? 0. : sqrt(pT2sel);
485 int iRadBef = dipSel->iRadiator;
486 int iRecBef = dipSel->iRecoiler;
487 Particle& radBef =
event[iRadBef];
488 Particle& recBef =
event[iRecBef];
489 Vec4 pRadBef =
event[iRadBef].p();
490 Vec4 pRecBef =
event[iRecBef].p();
493 double pTorig = sqrt( dipSel->pT2);
494 double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
496 double e2RadPlusEmt = pow2(eRadPlusEmt);
497 double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
498 - dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
499 double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z
500 * (1. - dipSel->z) - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
501 double pTcorr = sqrtpos( pT2corr );
502 double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
504 double pzEmt = (e2RadPlusEmt * (1. - dipSel->z)
505 - 0.5 * dipSel->m2) / pzRadPlusEmt;
506 double mRad = dipSel->mRad;
510 double m2Ratio = dipSel->m2Rad / dipSel->m2;
511 pTorig *= 1. - m2Ratio;
512 pTcorr *= 1. - m2Ratio;
513 pzRad += pzEmt * m2Ratio;
514 pzEmt *= 1. - m2Ratio;
517 double phi = 2. * M_PI * rndmPtr->flat();
518 Vec4 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
519 sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
520 Vec4 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
521 sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
522 Vec4 pRec = Vec4( 0., 0., -pzRadPlusEmt,
523 sqrt( pow2(pzRadPlusEmt) + dipSel->m2Rec ) );
527 M.fromCMframe(pRadBef, pRecBef);
533 Particle rad = Particle(radBef.id(), 51, iRadBef, 0, 0, 0,
534 radBef.col(), radBef.acol(), pRad, mRad, pTsel);
535 Particle emt = Particle(22, 51, iRadBef, 0, 0, 0,
536 0, 0, pEmt, mEmt, pTsel);
537 Particle rec = Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
538 recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel);
541 if (dipSel->MEtype == 0
542 || findMEcorr( dipSel, rad, rec, emt,
false) > rndmPtr->flat() ) {
545 if (radBef.hasVertex()) {
546 rad.vProd( radBef.vProd() );
547 emt.vProd( radBef.vProd() );
549 if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
550 rad.tau( event[iRadBef].tau() );
551 rec.tau( event[iRecBef].tau() );
554 int iRad =
event.append(rad);
555 int iEmt =
event.append(emt);
556 event[iRadBef].statusNeg();
557 event[iRadBef].daughters( iRad, iEmt);
558 int iRec =
event.append(rec);
559 event[iRecBef].statusNeg();
560 event[iRecBef].daughters( iRec, iRec);
563 dipSel->iRadiator = iRad;
564 dipSel->iRecoiler = iRec;
565 dipSel->pTmax = pTsel;
568 for (
int i = 0; i < int(dipEnd.size()); ++i)
if (i != iDipSel) {
569 if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
570 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
571 if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
572 if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
573 if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
574 if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
579 pTLastBranch = pTsel;
586 }
while (pTmax > 0.);
597 void SimpleTimeShower::prepareGlobal(
Event& event) {
603 hardPartons.resize(0);
604 nFinalBorn = mode(
"TimeShower:nPartonsInBorn");
610 for (
int i = 0; i <
event.size(); ++i) {
611 if (event[i].isFinal() &&
event[i].colType() != 0)
612 hardPartons.push_back(i);
613 if ( event[i].isFinal() && event[i].idAbs() > 5 && event[i].idAbs() != 21
614 && (event[i].col() != 0 || event[i].acol() != 0))
617 nHard = hardPartons.size();
618 if (nFinalBorn > 0 && nHard > nFinalBorn) {
619 hardPartons.resize(0);
625 string nNow = infoPtr->getEventAttribute(
"npNLO",
true);
626 if (nNow !=
"" && nFinalBorn == -1){
627 nFinalBorn = max(0, atoi((
char*)nNow.c_str()));
629 nFinalBorn += nHeavyCol;
638 void SimpleTimeShower::prepare(
int iSys,
Event& event,
bool limitPTmaxIn) {
641 if (iSys == 0) hasWeaklyRadiated =
false;
644 int iInA = partonSystemsPtr->getInA(iSys);
645 int iInB = partonSystemsPtr->getInB(iSys);
646 if (iSys == 0 || iInA == 0) dipEnd.resize(0);
647 int dipEndSizeBeg = dipEnd.size();
650 if (partonSystemsPtr->sizeOut(iSys) < 2)
return;
653 if (twoHard && iSys == 0) limitPTmaxIn = dopTlimit1;
654 if (twoHard && iSys == 1) limitPTmaxIn = dopTlimit2;
659 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
660 int ii = partonSystemsPtr->getOut( iSys, i);
661 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard) {
662 if ( event[ii].isAncestor(hardPartons[iHard])
663 || ii == hardPartons[iHard]){
672 if (isHard && nProposed.find(iSys) == nProposed.end() )
673 nProposed.insert(make_pair(iSys,0));
674 partonSystemsPtr->setHard(iSys, isHard);
677 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
678 int iRad = partonSystemsPtr->getOut( iSys, i);
680 if (event[iRad].isFinal() && event[iRad].scale() > 0.) {
683 int idRad =
event[iRad].id();
684 int idRadAbs = abs(idRad);
685 bool isOctetOnium = particleDataPtr->isOctetHadron(idRad);
686 bool doQCD = doQCDshower;
687 if (doQCD && isOctetOnium)
688 doQCD = (rndmPtr->flat() < octetOniumFraction);
691 int colTag =
event[iRad].col();
692 if (doQCD && colTag > 0) setupQCDdip( iSys, i, colTag, 1, event,
693 isOctetOnium, limitPTmaxIn);
696 int acolTag =
event[iRad].acol();
697 if (doQCD && acolTag > 0) setupQCDdip( iSys, i, acolTag, -1, event,
698 isOctetOnium, limitPTmaxIn);
701 int chgType =
event[iRad].chargeType();
702 bool doChgDip = (chgType != 0)
703 && ( ( doQEDshowerByQ && event[iRad].isQuark() )
704 || ( doQEDshowerByL &&
event[iRad].isLepton() )
705 || ( doQEDshowerByOther && event[iRad].isResonance() ) );
706 int gamType = (idRad == 22) ? 1 : 0;
707 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
708 if (doChgDip || doGamDip) setupQEDdip( iSys, i, chgType, gamType,
709 event, limitPTmaxIn);
712 if (doWeakShower && (iSys == 0 || !partonSystemsPtr->hasInAB(iSys))
713 && (event[iRad].isQuark() ||
event[iRad].isLepton())
714 && (!weakExternal || iSys != 0) ) {
715 if (weakMode == 0 || weakMode == 1)
716 setupWeakdip( iSys, i, 1, event, limitPTmaxIn);
717 if (weakMode == 0 || weakMode == 2)
718 setupWeakdip( iSys, i, 2, event, limitPTmaxIn);
722 bool isHVrad = (idRadAbs > 4900000 && idRadAbs < 4900007)
723 || (idRadAbs > 4900010 && idRadAbs < 4900017)
724 || (idRadAbs > 4900100 && idRadAbs < 4900109);
725 if (doHVshower && isHVrad) setupHVdip( iSys, i, event, limitPTmaxIn);
732 if (doWeakShower && weakExternal && iSys == 0)
733 setupWeakdipExternal(event, limitPTmaxIn);
736 for (
int iDip = dipEndSizeBeg; iDip < int(dipEnd.size()); ++iDip)
737 findMEtype( event, dipEnd[iDip]);
740 if (iSys > 0 && ( (iInA > 0 && event[iInA].status() == -34)
741 || (iInB > 0 &&
event[iInB].status() == -34) ) )
742 rescatterUpdate( iSys, event);
750 void SimpleTimeShower::rescatterUpdate(
int iSys,
Event& event) {
754 for (
int iResc = 0; iResc < 2; ++iResc) {
755 int iIn = (iResc == 0) ? partonSystemsPtr->getInA(iSys)
756 : partonSystemsPtr->getInB(iSys);
757 if (iIn == 0 || event[iIn].status() != -34)
continue;
758 int iOut =
event[iIn].mother1();
761 int dipEndSize = dipEnd.size();
762 for (
int iDip = 0; iDip < dipEndSize; ++iDip) {
763 TimeDipoleEnd& dipNow = dipEnd[iDip];
766 if (dipNow.iRadiator == iOut) {
773 if (dipNow.iMEpartner == iOut) {
775 dipNow.iMEpartner = -1;
779 if (dipNow.iRecoiler == iOut) {
780 int iRad = dipNow.iRadiator;
783 if (dipNow.colType > 0) {
784 int colTag =
event[iRad].col();
786 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
787 int iRecNow = partonSystemsPtr->getOut( iSys, i);
788 if (event[iRecNow].acol() == colTag) {
789 dipNow.iRecoiler = iRecNow;
790 dipNow.systemRec = iSys;
797 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
798 : partonSystemsPtr->getInA(iSys);
799 if (event[iIn2].col() == colTag) {
800 dipNow.iRecoiler = iIn2;
801 dipNow.systemRec = iSys;
803 int isrType =
event[iIn2].mother1();
805 while (isrType > 2 + beamOffset)
806 isrType =
event[isrType].mother1();
807 if (isrType > 2) isrType -= beamOffset;
808 dipNow.isrType = isrType;
814 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
816 setupQCDdip(dipNow.system, iRadNow, event[iRad].col(), 1,
817 event, dipNow.isOctetOnium,
true);
819 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
820 "Update: failed to locate radiator in system");
826 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
827 "Update: failed to locate new recoiling colour partner");
831 }
else if (dipNow.colType < 0) {
832 int acolTag =
event[iRad].acol();
834 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
835 int iRecNow = partonSystemsPtr->getOut( iSys, i);
836 if (event[iRecNow].col() == acolTag) {
837 dipNow.iRecoiler = iRecNow;
838 dipNow.systemRec = iSys;
845 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
846 : partonSystemsPtr->getInA(iSys);
847 if (event[iIn2].acol() == acolTag) {
848 dipNow.iRecoiler = iIn2;
849 dipNow.systemRec = iSys;
851 int isrType =
event[iIn2].mother1();
853 while (isrType > 2 + beamOffset)
854 isrType =
event[isrType].mother1();
855 if (isrType > 2) isrType -= beamOffset;
856 dipNow.isrType = isrType;
862 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
864 setupQCDdip(dipNow.system, iRadNow, event[iRad].acol(), -1,
865 event, dipNow.isOctetOnium,
true);
867 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
868 "Update: failed to locate radiator in system");
874 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
875 "Update: failed to locate new recoiling colour partner");
879 }
else if (dipNow.chgType != 0 || dipNow.gamType != 0) {
880 int idTag =
event[dipNow.iRecoiler].id();
882 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
883 int iRecNow = partonSystemsPtr->getOut( iSys, i);
884 if (event[iRecNow].
id() == idTag) {
885 dipNow.iRecoiler = iRecNow;
886 dipNow.systemRec = iSys;
893 int iIn2 = (iResc == 0) ? partonSystemsPtr->getInB(iSys)
894 : partonSystemsPtr->getInA(iSys);
895 if (event[iIn2].
id() == -idTag) {
896 dipNow.iRecoiler = iIn2;
897 dipNow.systemRec = iSys;
899 int isrType =
event[iIn2].mother1();
901 while (isrType > 2 + beamOffset)
902 isrType =
event[isrType].mother1();
903 if (isrType > 2) isrType -= beamOffset;
904 dipNow.isrType = isrType;
910 int iRadNow = partonSystemsPtr->getIndexOfOut(dipNow.system, iRad);
912 setupQEDdip(dipNow.system, iRadNow, dipNow.chgType,
913 dipNow.gamType, event,
true);
915 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
916 "Update: failed to locate radiator in system");
922 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatter"
923 "Update: failed to locate new recoiling charge partner");
938 void SimpleTimeShower::update(
int iSys,
Event& event,
bool hasWeakRad) {
941 vector<int> iRescatterer;
944 vector<int> iNew, iOld;
945 iNew.push_back( partonSystemsPtr->getInA(iSys) );
946 iOld.push_back( event[iNew[0]].daughter2() );
947 iNew.push_back( partonSystemsPtr->getInB(iSys) );
948 iOld.push_back( event[iNew[1]].daughter2() );
951 int sizeOut = partonSystemsPtr->sizeOut(iSys) - 1;
952 for (
int i = 0; i < sizeOut; ++i) {
953 int iNow = partonSystemsPtr->getOut(iSys, i);
954 iNew.push_back( iNow );
955 iOld.push_back( event[iNow].mother1() );
957 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
959 int iNewNew = partonSystemsPtr->getOut(iSys, sizeOut);
962 if (event[iNew[0]].status() != -41) {
963 swap( iNew[0], iNew[1]);
964 swap( iOld[0], iOld[1]);
969 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
970 if (dipEnd[iDip].system == iSys || dipEnd[iDip].systemRec == iSys) {
971 TimeDipoleEnd& dipNow = dipEnd[iDip];
974 for (
int i = 2; i < 2 + sizeOut; ++i)
975 if (dipNow.iRadiator == iOld[i]) {
976 dipNow.iRadiator = iNew[i];
981 for (
int i = 2; i < 2 + sizeOut; ++i)
982 if (dipNow.iMEpartner == iOld[i]) {
983 dipNow.iMEpartner = iNew[i];
989 int colRad =
event[dipNow.iRadiator].col();
990 int acolRad =
event[dipNow.iRadiator].acol();
991 if (dipNow.systemRec == iSys) {
992 for (
int i = 1; i < 2 + sizeOut; ++i)
993 if (dipNow.iRecoiler == iOld[i]) {
999 if (dipNow.colType > 0 && event[iNewNew].acol() == colRad) {
1003 if (dipNow.colType < 0 && event[iNewNew].col() == acolRad) {
1009 if (iRec == 0 && dipNow.colType > 0 && event[iNew[0]].col() == colRad)
1011 if (iRec == 0 && dipNow.colType < 0 && event[iNew[0]].acol() == acolRad)
1015 if (iRec == 0 && dipNow.colType > 0 ) {
1016 for (
int i = 2; i < 2 + sizeOut; ++i)
1017 if (event[iNew[i]].acol() == colRad) {
1023 if (iRec == 0 && dipNow.colType < 0 ) {
1024 for (
int i = 2; i < 2 + sizeOut; ++i)
1025 if (event[iNew[i]].col() == acolRad) {
1033 if ( iRec == 0 && (dipNow.chgType != 0 || dipNow.gamType != 0) ) {
1034 if ( event[iNew[0]].chargeType() == 0 ) {
1043 }
else iRec = dipNow.iRecoiler;
1046 dipNow.iRecoiler = iRec;
1047 if ( iRec == 0 && (dipNow.colType != 0 || dipNow.chgType != 0
1048 || dipNow.gamType != 0) ) {
1052 infoPtr->errorMsg(
"Error in SimpleTimeShower::update: "
1053 "failed to locate new recoiling partner");
1058 if (hasWeakRad && singleWeakEmission && dipNow.weakType != 0)
1059 dipNow.weakType = 0;
1063 if (hasWeakRad) hasWeaklyRadiated =
true;
1066 int colTag =
event[iNewNew].col();
1067 if (doQCDshower && colTag > 0)
1068 setupQCDdip( iSys, sizeOut, colTag, 1, event,
false,
true);
1071 int acolTag =
event[iNewNew].acol();
1072 if (doQCDshower && acolTag > 0)
1073 setupQCDdip( iSys, sizeOut, acolTag, -1, event,
false,
true);
1077 int chgType =
event[iNewNew].chargeType();
1078 bool doChgDip = (chgType != 0)
1079 && ( ( doQEDshowerByQ && event[iNewNew].isQuark() )
1080 || ( doQEDshowerByL &&
event[iNewNew].isLepton() ) );
1081 int gamType = (
event[iNewNew].id() == 22) ? 1 : 0;
1082 bool doGamDip = (gamType == 1) && doQEDshowerByGamma;
1083 if (doChgDip || doGamDip)
1084 setupQEDdip( iSys, sizeOut, chgType, gamType, event,
true);
1088 unsigned int nDips = dipEnd.size();
1089 if (doWeakShower && (event[iNewNew].isQuark() || event[iNewNew].isLepton())
1090 && !(hasWeaklyRadiated && singleWeakEmission)
1091 && (iSys == 0 || !partonSystemsPtr->hasInAB(iSys))) {
1093 if (weakMode == 0 || weakMode == 1)
1094 setupWeakdip( iSys, sizeOut, 1, event,
true);
1096 if (nDips != dipEnd.size()) {
1097 nDips = dipEnd.size();
1098 dipEnd.back().MEtype = 200;
1099 dipEnd.back().iMEpartner = dipEnd.back().iRecoiler;
1102 if (weakMode == 0 || weakMode == 2)
1103 setupWeakdip( iSys, sizeOut, 2, event,
true);
1105 if (nDips != dipEnd.size()) {
1106 nDips = dipEnd.size();
1107 dipEnd.back().MEtype = 205;
1108 dipEnd.back().iMEpartner = dipEnd.back().iRecoiler;
1114 while (++iRescNow <
int(iRescatterer.size())) {
1117 int iOutNew = iRescatterer[iRescNow];
1118 int iInNew =
event[iOutNew].daughter1();
1119 int iSysResc = partonSystemsPtr->getSystemOf(iInNew,
true);
1124 iNew.push_back( partonSystemsPtr->getInA(iSysResc) );
1125 iOld.push_back( event[iNew[0]].daughter1() );
1126 iNew.push_back( partonSystemsPtr->getInB(iSysResc) );
1127 iOld.push_back( event[iNew[1]].daughter1() );
1130 sizeOut = partonSystemsPtr->sizeOut(iSysResc);
1131 for (
int i = 0; i < sizeOut; ++i) {
1132 int iNow = partonSystemsPtr->getOut(iSysResc, i);
1133 iNew.push_back( iNow );
1134 iOld.push_back( event[iNow].mother1() );
1136 if (!event[iNow].isFinal()) iRescatterer.push_back( iNow );
1141 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip)
1142 if (dipEnd[iDip].system == iSysResc
1143 || dipEnd[iDip].systemRec == iSysResc) {
1144 TimeDipoleEnd& dipNow = dipEnd[iDip];
1147 for (
int i = 2; i < 2 + sizeOut; ++i)
1148 if (dipNow.iRadiator == iOld[i]) {
1149 dipNow.iRadiator = iNew[i];
1154 for (
int i = 2; i < 2 + sizeOut; ++i)
1155 if (dipNow.iMEpartner == iOld[i]) {
1156 dipNow.iMEpartner = iNew[i];
1161 for (
int i = 0; i < 2 + sizeOut; ++i)
1162 if (dipNow.iRecoiler == iOld[i]) {
1163 dipNow.iRecoiler = iNew[i];
1177 void SimpleTimeShower::setupQCDdip(
int iSys,
int i,
int colTag,
int colSign,
1178 Event& event,
bool isOctetOnium,
bool limitPTmaxIn) {
1181 int iRad = partonSystemsPtr->getOut(iSys, i);
1183 int sizeAll = partonSystemsPtr->sizeAll(iSys);
1184 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1186 int sizeRec = ( allowBeamRecoil && partonSystemsPtr->hasInAB(iSys) ) ?
1188 int sizeInRec = sizeRec - sizeOut;
1189 int sizeInNonRec = sizeAll - sizeOut - sizeInRec;
1190 int iOffset = i + sizeAll - sizeOut;
1191 bool otherSystemRec =
false;
1192 bool allowInitial = partonSystemsPtr->hasInAB(iSys);
1195 bool isFlexible =
false;
1196 double flexFactor = 1.0;
1197 vector<int> iRecVec(0);
1202 for (
int j = 0; j < sizeRec; ++j) {
1203 if (j + sizeInNonRec != iOffset) {
1204 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1205 if ( ( j < sizeInRec && event[iRecNow].col() == colTag
1206 && !event[iRecNow].isRescatteredIncoming() )
1207 || ( j >= sizeInRec && event[iRecNow].acol() == colTag
1208 && event[iRecNow].isFinal() ) ) {
1219 for (
int j = 0; j < sizeRec; ++j) {
1220 if (j + sizeInNonRec != iOffset) {
1221 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1222 if ( ( j < sizeInRec && event[iRecNow].acol() == colTag
1223 && !event[iRecNow].isRescatteredIncoming() )
1224 || ( j >= sizeInRec && event[iRecNow].col() == colTag
1225 && event[iRecNow].isFinal() ) ) {
1237 bool hasJunction =
false;
1238 if (iRec == 0 && !allowInitial) {
1239 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
1243 int iBeg = (
event.kindJunction(iJun)-1)/2;
1244 for (
int iLeg = iBeg; iLeg < 3; ++iLeg)
1245 if (event.endColJunction( iJun, iLeg) == colTag) hasJunction =
true;
1247 double ppMin = LARGEM2;
1248 for (
int j = 0; j < sizeOut; ++j) {
1250 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1251 if (!event[iRecNow].isFinal())
continue;
1252 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1253 -
event[iRecNow].m() *
event[iRad].m();
1254 if (ppNow < ppMin) {
1263 if ( iRec == 0 || (!doInterleave && allowMPIdipole
1264 && !event[iRec].isFinal()) ) {
1265 for (
int j = 0; j <
event.size(); ++j) {
1266 if (event[j].isFinal()) {
1267 if ( (colSign > 0 && event[j].acol() == colTag)
1268 || (colSign < 0 &&
event[j].col() == colTag) ) {
1270 otherSystemRec =
true;
1277 if (iRec == 0 && allowInitial) {
1278 for (
int iSysR = 0; iSysR < partonSystemsPtr->sizeSys(); ++iSysR)
1279 if (iSysR != iSys) {
1280 int j = partonSystemsPtr->getInA(iSysR);
1281 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
1282 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
1283 || (colSign < 0 && event[j].acol() == colTag) ) ) {
1285 otherSystemRec =
true;
1288 j = partonSystemsPtr->getInB(iSysR);
1289 if (j > 0 && event[j].isRescatteredIncoming()) j = 0;
1290 if (j > 0 && ( (colSign > 0 && event[j].col() == colTag)
1291 || (colSign < 0 && event[j].acol() == colTag) ) ) {
1293 otherSystemRec =
true;
1309 for (
int iJun = 0; iJun <
event.sizeJunction(); ++ iJun) {
1310 int kindJun =
event.kindJunction(iJun);
1311 int iBeg = (kindJun-1)/2;
1312 for (
int iLeg = iBeg; iLeg < 3; ++iLeg) {
1313 if (event.endColJunction( iJun, iLeg) == colTag) {
1321 if (sizeOut == 1)
return;
1326 else if (kindJun >= 3) {
1327 int iLegRec = 3-iLeg;
1328 int colTagRec =
event.endColJunction( iJun, iLegRec);
1329 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1330 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1331 if (!event[iRecNow].isFinal())
continue;
1332 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
1333 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
1344 for (
int jLeg = 1; jLeg <= 2; jLeg++) {
1345 int iLegRec = (iLeg + jLeg) % 3;
1346 int colTagRec =
event.endColJunction( iJun, iLegRec);
1347 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1348 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1349 if (!event[iRecNow].isFinal())
continue;
1350 if ( (colSign > 0 && event[iRecNow].col() == colTagRec)
1351 || (colSign < 0 && event[iRecNow].acol() == colTagRec) ) {
1353 iRecVec.push_back(iRecNow);
1371 double ppMin = LARGEM2;
1372 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1373 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1374 if (!event[iRecNow].isFinal())
continue;
1375 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1376 -
event[iRecNow].m() *
event[iRad].m();
1377 if (ppNow < ppMin) {
1387 double ppMin = LARGEM2;
1388 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1389 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1390 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1391 -
event[iRecNow].m() *
event[iRad].m();
1392 if (ppNow < ppMin) {
1394 otherSystemRec =
true;
1401 if (iRecVec.size() == 0 && iRec != 0) iRecVec.push_back(iRec);
1404 int nRec = iRecVec.size();
1405 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec)
1406 if (iRecVec[mRec] <= 0) nRec--;
1409 flexFactor = 1.0/nRec;
1414 infoPtr->errorMsg(
"Error in SimpleTimeShower::setupQCDdip: "
1415 "failed to locate any recoiling partner");
1420 for (
unsigned int mRec = 0; mRec < iRecVec.size(); ++mRec) {
1421 iRec = iRecVec[mRec];
1422 if (iRec <= 0)
continue;
1424 double pTmax =
event[iRad].scale();
1426 if (iSys == 0 || (iSys == 1 && twoHard)) pTmax *= pTmaxFudge;
1427 else if (sizeInRec > 0) pTmax *= pTmaxFudgeMPI;
1428 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1429 int colType = (
event[iRad].id() == 21) ? 2 * colSign : colSign;
1430 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1432 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1433 if (isrType > 2) isrType -= beamOffset;
1434 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax,
1435 colType, 0, 0, 0, isrType, iSys, -1, -1, 0, isOctetOnium) );
1437 dipEnd.back().hasJunction = hasJunction;
1439 if (otherSystemRec) {
1440 int systemRec = partonSystemsPtr->getSystemOf(iRec,
true);
1441 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1442 dipEnd.back().MEtype = 0;
1448 dipEnd.back().isFlexible =
true;
1449 dipEnd.back().flexFactor = flexFactor;
1460 void SimpleTimeShower::setupQEDdip(
int iSys,
int i,
int chgType,
int gamType,
1461 Event& event,
bool limitPTmaxIn) {
1464 int iRad = partonSystemsPtr->getOut(iSys, i);
1465 int idRad =
event[iRad].id();
1467 int sizeAll = partonSystemsPtr->sizeAll(iSys);
1468 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1470 int sizeRec = ( allowBeamRecoil && partonSystemsPtr->hasInAB(iSys) )
1471 ? sizeAll : sizeOut;
1472 int sizeInRec = sizeRec - sizeOut;
1473 int sizeInNonRec = sizeAll - sizeOut - sizeInRec;
1474 int iOffset = i + sizeAll - sizeOut;
1475 double ppMin = LARGEM2;
1476 bool hasRescattered =
false;
1477 bool otherSystemRec =
false;
1483 for (
int j = 0; j < sizeRec; ++j) {
1484 if (j + sizeInNonRec != iOffset) {
1485 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1486 if ( (j < sizeInRec && !event[iRecNow].isRescatteredIncoming())
1487 || (j >= sizeInRec && event[iRecNow].isFinal()) ) {
1488 if ( (j < sizeInRec && event[iRecNow].
id() == idRad)
1489 || (j >= sizeInRec && event[iRecNow].
id() == -idRad) ) {
1490 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1491 -
event[iRecNow].m() *
event[iRad].m();
1492 if (ppNow < ppMin) {
1497 }
else hasRescattered =
true;
1503 if (iRec == 0 && hasRescattered) {
1504 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1505 if (event[iRecNow].
id() == -idRad &&
event[iRecNow].isFinal()) {
1506 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1507 -
event[iRecNow].m() *
event[iRad].m();
1508 if (ppNow < ppMin) {
1511 otherSystemRec =
true;
1519 for (
int j = 0; j < sizeRec; ++j) {
1520 if (j + sizeInNonRec != iOffset) {
1521 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1522 int chgTypeRecNow =
event[iRecNow].chargeType();
1523 if (chgTypeRecNow == 0)
continue;
1524 if ( (j < sizeInRec && !event[iRecNow].isRescatteredIncoming())
1525 || (j >= sizeInRec && event[iRecNow].isFinal()) ) {
1526 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1527 -
event[iRecNow].m() *
event[iRad].m())
1528 / pow2(chgTypeRecNow);
1529 if (ppNow < ppMin) {
1540 if (iRec == 0 && hasRescattered) {
1541 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1542 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1543 int chgTypeRecNow =
event[iRecNow].chargeType();
1544 if (chgTypeRecNow != 0 && event[iRecNow].isFinal()) {
1545 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1546 -
event[iRecNow].m() *
event[iRad].m())
1547 / pow2(chgTypeRecNow);
1548 if (ppNow < ppMin) {
1551 otherSystemRec =
true;
1559 for (
int j = 0; j < sizeOut; ++j) {
1561 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1562 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1563 -
event[iRecNow].m() *
event[iRad].m();
1564 if (ppNow < ppMin) {
1574 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow) {
1575 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1576 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1577 -
event[iRecNow].m() *
event[iRad].m();
1578 if (ppNow < ppMin) {
1581 otherSystemRec =
true;
1590 double pTmax =
event[iRad].scale();
1592 if (iSys == 0 || (iSys == 1 && twoHard)) pTmax *= pTmaxFudge;
1593 else if (sizeInRec > 0) pTmax *= pTmaxFudgeMPI;
1594 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1595 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1597 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1598 if (isrType > 2) isrType -= beamOffset;
1599 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1600 0, chgType, gamType, 0, isrType, iSys, -1) );
1603 if (otherSystemRec) {
1604 int systemRec = partonSystemsPtr->getSystemOf(iRec);
1605 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1606 dipEnd.back().MEtype = 0;
1611 infoPtr->errorMsg(
"Error in SimpleTimeShower::setupQEDdip: "
1612 "failed to locate any recoiling partner");
1621 void SimpleTimeShower::setupWeakdip(
int iSys,
int i,
int weakType,
1622 Event& event,
bool limitPTmaxIn) {
1625 int iRad = partonSystemsPtr->getOut(iSys, i);
1626 int idRad =
event[iRad].id();
1628 int sizeAll = partonSystemsPtr->sizeAll(iSys);
1629 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1631 int sizeRec = sizeOut;
1632 int sizeInNonRec = sizeAll - sizeOut;
1633 int iOffset = i + sizeAll - sizeOut;
1634 double ppMin = LARGEM2;
1635 bool hasRescattered =
false;
1636 bool otherSystemRec =
false;
1642 for (
int j = 0; j < sizeRec; ++j)
1643 if (j + sizeInNonRec != iOffset) {
1644 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1645 if ( event[iRecNow].isFinal() ) {
1646 if ( event[iRecNow].
id() == -idRad ) {
1647 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1648 -
event[iRecNow].m() *
event[iRad].m();
1649 if (ppNow < ppMin) {
1654 }
else hasRescattered =
true;
1659 if (iRec == 0 && hasRescattered) {
1660 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1661 if (event[iRecNow].
id() == -idRad &&
event[iRecNow].isFinal()) {
1662 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1663 -
event[iRecNow].m() *
event[iRad].m();
1664 if (ppNow < ppMin) {
1667 otherSystemRec =
true;
1675 for (
int j = 0; j < sizeRec; ++j)
if (j + sizeInNonRec != iOffset) {
1676 int iRecNow = partonSystemsPtr->getAll(iSys, j + sizeInNonRec);
1677 if (abs(event[iRecNow].
id()) >= 20 || weakType < 1
1678 || weakType > 2)
continue;
1679 double weakCoupNow = 1.;
1680 if (weakType == 2) weakCoupNow = coupSMPtr->vf2(event[iRecNow].idAbs())
1681 + coupSMPtr->af2(event[iRecNow].idAbs());
1682 if ( event[iRecNow].isFinal() ) {
1683 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1684 -
event[iRecNow].m() *
event[iRad].m()) / weakCoupNow;
1685 if (ppNow < ppMin) {
1694 if (iRec == 0 && hasRescattered) {
1695 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1696 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1697 if (abs(event[iRecNow].
id()) >= 20 || weakType < 1
1698 || weakType > 2)
continue;
1699 double weakCoupNow = 1.;
1700 if (weakType == 2) weakCoupNow = coupSMPtr->vf2(event[iRecNow].idAbs())
1701 + coupSMPtr->af2(event[iRecNow].idAbs());
1702 double ppNow = (
event[iRecNow].p() *
event[iRad].p()
1703 -
event[iRecNow].m() *
event[iRad].m()) / weakCoupNow;
1704 if (ppNow < ppMin) {
1707 otherSystemRec =
true;
1714 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1715 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1716 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1717 -
event[iRecNow].m() *
event[iRad].m();
1718 if (ppNow < ppMin) {
1726 for (
int iRecNow = 0; iRecNow <
event.size(); ++iRecNow)
1727 if (iRecNow != iRad && event[iRecNow].isFinal()) {
1728 double ppNow =
event[iRecNow].p() *
event[iRad].p()
1729 -
event[iRecNow].m() *
event[iRad].m();
1730 if (ppNow < ppMin) {
1733 otherSystemRec =
true;
1741 Vec4 p3weak =
event[3].p();
1742 Vec4 p4weak =
event[4].p();
1743 double tHat = (
event[iRad].p() - p3weak).m2Calc();
1744 double uHat = (
event[iRad].p() - p4weak).m2Calc();
1747 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1749 if (event[iRad].intPol() == 1 ||
event[iRad].intPol() == -1)
1750 weakPol = event[iRad].intPol();
1752 else if (event[iRad].statusAbs() > 40) {
1753 if (event[event[iRad].mother1()].idAbs() < 20)
1754 weakPol = event[event[iRad].mother1()].intPol();
1755 else if (
int(event[iRad].sisterList(
true).size()) != 0)
1756 weakPol =
event[
event[iRad].sisterList(
true)[0]].intPol();
1759 else if (infoPtr->nFinal() != 2) {
1760 if (event[iRec].intPol() == 1 ||
event[iRec].intPol() == -1)
1761 weakPol = event[iRec].intPol();
1764 else if (idRad == - event[iRec].
id()) {
1765 if (event[iRec].intPol() == 1 ||
event[iRec].intPol() == -1)
1766 weakPol = event[iRec].intPol();
1769 else if (event[event[iRad].mother1()].idAbs() == 24) weakPol = -1;
1771 else if (idRad == event[iRec].
id()) {
1772 if (uHat*uHat/(tHat*tHat + uHat*uHat) > 0.5) weakPol =
event[3].intPol();
1773 else weakPol =
event[4].intPol();
1776 else if (event[3].
id() == idRad) weakPol =
event[3].intPol();
1777 else if (event[4].
id() == idRad) weakPol =
event[4].intPol();
1780 if (weakPol > 1) weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1781 event[iRad].pol(weakPol);
1784 double pTmax =
event[iRad].scale();
1786 if (iSys == 0) pTmax *= pTmaxFudge;
1787 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1788 int isrType = (
event[iRec].isFinal()) ? 0 : event[iRec].mother1();
1790 while (isrType > 2 + beamOffset) isrType =
event[isrType].mother1();
1791 if (isrType > 2) isrType -= beamOffset;
1794 if (weakType == 1 && weakPol == 1)
return;
1795 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1796 0, 0, 0, weakType, isrType, iSys, -1, -1, weakPol) );
1799 if (otherSystemRec) {
1800 int systemRec = partonSystemsPtr->getSystemOf(iRec);
1801 if (systemRec >= 0) dipEnd.back().systemRec = systemRec;
1802 dipEnd.back().MEtype = 0;
1807 infoPtr->errorMsg(
"Error in SimpleTimeShower::setupWeakdip: "
1808 "failed to locate any recoiling partner");
1815 void SimpleTimeShower::setupWeakdipExternal(
Event& event,
bool limitPTmaxIn) {
1818 vector<pair<int,int> > weakDipoles = infoPtr->getWeakDipoles();
1819 vector<int> weakModes = infoPtr->getWeakModes();
1820 weakMomenta = infoPtr->getWeakMomenta();
1821 weak2to2lines = infoPtr->getWeak2to2lines();
1822 weakHardSize = int(weakModes.size());
1825 for (
int i = 0; i < int(weakDipoles.size()); ++i) {
1827 if (event[weakDipoles[i].first].status() > 0) {
1829 int iRad = weakDipoles[i].first;
1830 int iRec = weakDipoles[i].second;
1834 if (weakModes[weakDipoles[i].first] == 1) MEtypeWeak = 200;
1835 else if (weakModes[weakDipoles[i].first] == 2) MEtypeWeak = 201;
1836 else if (weakModes[weakDipoles[i].first] == 3) MEtypeWeak = 202;
1837 else MEtypeWeak = 203;
1841 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
1842 if (event[weakDipoles[i].first].intPol() != 9)
1843 weakPol = event[weakDipoles[i].first].intPol();
1844 else if (event[weakDipoles[i].second].intPol() != 9) {
1845 if (event[weakDipoles[i].second].status() < 0)
1846 weakPol = event[weakDipoles[i].second].intPol();
1848 weakPol = -
event[weakDipoles[i].second].intPol();
1850 event[weakDipoles[i].first].pol(weakPol);
1853 double pTmax =
event[iRad].scale();
1856 pTmax *= pTmaxFudge;
1857 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1864 if ( (weakMode == 0 || weakMode == 1) && weakPol == -1)
1865 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1866 0, 0, 0, 1, isrType, 0, MEtypeWeak, -1, weakPol) );
1868 if (weakMode == 0 || weakMode == 2)
1869 dipEnd.push_back( TimeDipoleEnd(iRad, iRec, pTmax,
1870 0, 0, 0, 2, isrType, 0, MEtypeWeak +5, -1, weakPol) );
1875 for (
int i = 0;i < int(dipEnd.size()); ++i) {
1876 Vec4 p3weak, p4weak;
1877 if (dipEnd[i].MEtype > 200) {
1878 int i2to2Mother = dipEnd[i].iRadiator;
1879 while (i2to2Mother >= weakHardSize)
1880 i2to2Mother =
event[i2to2Mother].mother1();
1881 if (weak2to2lines[2] == i2to2Mother) {
1882 p3weak = weakMomenta[0];
1883 p4weak = weakMomenta[1];
1885 p3weak = weakMomenta[1];
1886 p4weak = weakMomenta[0];
1897 void SimpleTimeShower::setupHVdip(
int iSys,
int i,
Event& event,
1898 bool limitPTmaxIn) {
1901 int iRad = partonSystemsPtr->getOut(iSys, i);
1903 int idRad =
event[iRad].id();
1904 int sizeOut = partonSystemsPtr->sizeOut(iSys);
1908 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1909 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1910 int idRec =
event[iRecNow].id();
1911 if ( (abs(idRec) > 4900000 && abs(idRec) < 4900017)
1912 && idRad * idRec < 0) {
1920 double mMax = -sqrt(LARGEM2);
1922 for (
int j = 0; j < sizeOut; ++j)
if (j != i) {
1923 int iRecNow = partonSystemsPtr->getOut(iSys, j);
1924 if (event[iRecNow].m() > mMax) {
1926 mMax =
event[iRecNow].m();
1933 double pTmax =
event[iRad].scale();
1935 if (iSys == 0 || (iSys == 1 && twoHard)) pTmax *= pTmaxFudge;
1936 }
else pTmax = 0.5 * m( event[iRad], event[iRec]);
1937 int colvType = (
event[iRad].id() > 0) ? 1 : -1;
1938 dipEnd.push_back( TimeDipoleEnd( iRad, iRec, pTmax, 0, 0, 0, 0, 0,
1939 iSys, -1, -1, 0,
false,
true, colvType) );
1940 }
else infoPtr->errorMsg(
"Error in SimpleTimeShower::setupHVdip: "
1941 "failed to locate any recoiling partner");
1949 double SimpleTimeShower::pTnext(
Event& event,
double pTbegAll,
1950 double pTendAll,
bool isFirstTrial,
bool doTrialIn) {
1955 double pT2sel = pTendAll * pTendAll;
1958 doTrialNow = doTrialIn;
1959 canEnhanceET = (!doTrialNow && canEnhanceEmission)
1960 || ( doTrialNow && canEnhanceTrial);
1963 splittingNameSel =
"";
1964 splittingNameNow =
"";
1965 enhanceFactors.clear();
1966 if (hasUserHooks) userHooksPtr->setEnhancedTrial(0., 1.);
1968 for (
int iDip = 0; iDip < int(dipEnd.size()); ++iDip) {
1969 TimeDipoleEnd& dip = dipEnd[iDip];
1974 bool hardSystem = partonSystemsPtr->getHard(dip.system);
1975 bool isQCD =
event[dip.iRadiator].colType() != 0;
1978 useLocalRecoilNow = !(globalRecoil && hardSystem
1979 && partonSystemsPtr->sizeOut(dip.system) <= nMaxGlobalRecoil);
1982 if (globalRecoilMode == 1 && isQCD) {
1983 if (globalRecoil && hardSystem) useLocalRecoilNow =
true;
1984 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
1985 if ( event[dip.iRadiator].isAncestor(hardPartons[iHard]) )
1986 useLocalRecoilNow =
false;
1988 if ( !globalRecoil || nGlobal >= nMaxGlobalBranch )
1989 useLocalRecoilNow =
true;
1991 }
else if (globalRecoilMode == 2 && isQCD) {
1992 useLocalRecoilNow = !(globalRecoil && hardSystem
1993 && nProposed.find(dip.system) != nProposed.end()
1994 && nProposed[dip.system]-infoPtr->getCounter(40) == 0);
1996 for (
int k = 0; k < int(event.size()); ++k)
1997 if ( event[k].isFinal() &&
event[k].colType() != 0) nFinal++;
1998 bool isFirst = (nHard == nFinal);
2001 if ( globalRecoil && doInterleave && !isFirst )
2002 useLocalRecoilNow =
true;
2004 if ( nFinalBorn > 0 && nHard > nFinalBorn )
2005 useLocalRecoilNow =
true;
2009 dip.mRad =
event[dip.iRadiator].m();
2010 if (useLocalRecoilNow) {
2011 dip.mRec =
event[dip.iRecoiler].m();
2012 dip.mDip = m( event[dip.iRadiator], event[dip.iRecoiler] );
2019 for (
int iS = 0; iS < partonSystemsPtr->sizeSys(); ++iS) {
2020 for (
int i = 0; i < partonSystemsPtr->sizeOut(iS); ++i) {
2021 int ii = partonSystemsPtr->getOut( iS, i);
2022 bool hasHardAncestor =
event[ii].statusAbs() < 23;
2023 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard) {
2024 if ( event[ii].isAncestor(hardPartons[iHard])
2025 || ii == hardPartons[iHard]
2026 || (
event[ii].status() == 23 &&
event[ii].colType() == 0) )
2027 hasHardAncestor =
true;
2029 if (hasHardAncestor && ii != dip.iRadiator && event[ii].isFinal() )
2030 pSumGlobal += event[ii].p();
2033 dip.mRec = pSumGlobal.mCalc();
2034 dip.mDip = m( event[dip.iRadiator].p(), pSumGlobal);
2036 dip.m2Rad = pow2(dip.mRad);
2037 dip.m2Rec = pow2(dip.mRec);
2038 dip.m2Dip = pow2(dip.mDip);
2041 dip.m2DipCorr = pow2(dip.mDip - dip.mRec) - dip.m2Rad;
2042 double pTbegDip = min( pTbegAll, dip.pTmax );
2043 double pT2begDip = min( pow2(pTbegDip), 0.25 * dip.m2DipCorr);
2046 bool isFirstWimpy = !useLocalRecoilNow && (pTmaxMatch == 1)
2047 && nProposed.find(dip.system) != nProposed.end()
2048 && (nProposed[dip.system] - infoPtr->getCounter(40) == 0
2050 double muQ = (infoPtr->scalup() > 0.) ? infoPtr->scalup()
2052 if (isFirstWimpy && !limitMUQ) pT2begDip = pow2(muQ);
2053 else if (isFirstWimpy && limitMUQ) {
2055 double mS =
event[dip.iRecoiler].m();
2056 double mD = m( event[dip.iRadiator], event[dip.iRecoiler] );
2057 double m2DC = pow2(mD - mS) - pow2(dip.mRad);
2059 pT2begDip = min( pow2(muQ), min(pow2(pTbegDip), 0.25 * m2DC) );
2064 if (dip.m2DipCorr < 0.) {
2065 infoPtr->errorMsg(
"Warning in SimpleTimeShower::pTnext: "
2066 "negative dipole mass.");
2071 if (pT2begDip > pT2sel) {
2072 if (dip.colType != 0)
2073 pT2nextQCD(pT2begDip, pT2sel, dip, event);
2074 else if (dip.chgType != 0 || dip.gamType != 0)
2075 pT2nextQED(pT2begDip, pT2sel, dip, event);
2076 else if (dip.weakType != 0)
2077 pT2nextWeak(pT2begDip, pT2sel, dip, event);
2078 else if (dip.colvType != 0)
2079 pT2nextHV(pT2begDip, pT2sel, dip, event);
2082 if (dip.pT2 > pT2sel) {
2086 splittingNameSel = splittingNameNow;
2092 if (dipSel != 0 && nProposed.find(dipSel->system) != nProposed.end())
2093 ++nProposed[dipSel->system];
2096 return (dipSel == 0) ? 0. : sqrt(pT2sel);
2104 void SimpleTimeShower::pT2nextQCD(
double pT2begDip,
double pT2sel,
2105 TimeDipoleEnd& dip,
Event& event) {
2108 double pT2endDip = max( pT2sel, pT2colCut );
2109 if (pT2begDip < pT2endDip)
return;
2113 int colTypeAbs = abs(dip.colType);
2114 if (doDipoleRecoil && dip.isrType != 0 && colTypeAbs == 1)
return;
2119 double wtPSglue = 2.;
2120 double colFac = (colTypeAbs == 1) ? 4./3. : 3./2.;
2121 if (dip.MEgluinoRec) colFac = 3.;
2122 if (dip.isOctetOnium) colFac *= 0.5 * octetOniumColFac;
2125 if (dip.isFlexible) colFac *= dip.flexFactor;
2126 double wtPSqqbar = (colTypeAbs == 2)
2127 ? 0.25 * nGluonToQuark * extraGluonToQuark : 0.;
2130 dip.pT2 = pT2begDip;
2132 double zMinAbs = 0.5;
2133 double pT2min = pT2endDip;
2135 double Lambda2 = Lambda3flav2;
2136 double emitCoefGlue = 0.;
2137 double emitCoefQqbar = 0.;
2138 double emitCoefTot = 0.;
2140 bool mustFindRange =
true;
2144 doUncertaintiesNow = doUncertainties;
2145 if (!uVarMPIshowers && dip.system != 0
2146 && partonSystemsPtr->hasInAB(dip.system)) doUncertaintiesNow =
false;
2147 double overFac = doUncertaintiesNow ? overFactor : 1.0;
2150 bool isEnhancedQ2QG, isEnhancedG2QQ, isEnhancedG2GG;
2151 isEnhancedQ2QG = isEnhancedG2QQ = isEnhancedG2GG =
false;
2152 double enhanceNow = 1.;
2153 string nameNow =
"";
2159 isEnhancedQ2QG = isEnhancedG2QQ = isEnhancedG2GG =
false;
2165 if (mustFindRange) {
2168 if (dip.pT2 > m2b) {
2170 pT2min = max( m2b, pT2endDip);
2172 Lambda2 = Lambda5flav2;
2173 }
else if (dip.pT2 > m2c) {
2175 pT2min = max( m2c, pT2endDip);
2177 Lambda2 = Lambda4flav2;
2182 Lambda2 = Lambda3flav2;
2185 Lambda2 /= renormMultFac;
2188 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2min / dip.m2DipCorr );
2189 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2min / dip.m2DipCorr;
2190 if (zMinAbs > 0.499) { dip.pT2 = 0.;
return; }
2193 emitCoefGlue = overFac * wtPSglue * colFac * log(1. / zMinAbs - 1.);
2195 if (canEnhanceET && colTypeAbs == 2)
2196 emitCoefGlue *= userHooksPtr->enhanceFactor(
"fsr:G2GG");
2197 if (canEnhanceET && colTypeAbs == 1)
2198 emitCoefGlue *= userHooksPtr->enhanceFactor(
"fsr:Q2QG");
2201 if (doDipoleRecoil && dip.isrType != 0 && colTypeAbs == 2)
2205 emitCoefTot = emitCoefGlue;
2206 if (colTypeAbs == 2 && event[dip.iRadiator].id() == 21) {
2207 emitCoefQqbar = overFac * wtPSqqbar * (1. - 2. * zMinAbs);
2210 emitCoefQqbar *= userHooksPtr->enhanceFactor(
"fsr:G2QQ");
2211 emitCoefTot += emitCoefQqbar;
2215 mustFindRange =
false;
2219 if (alphaSorder == 0) {
2220 dip.pT2 = dip.pT2 * pow( rndmPtr->flat(),
2221 1. / (alphaS2pi * emitCoefTot) );
2224 }
else if (alphaSorder == 1) {
2225 dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
2226 pow( rndmPtr->flat(), b0 / emitCoefTot) );
2230 do dip.pT2 = Lambda2 * pow( dip.pT2 / Lambda2,
2231 pow( rndmPtr->flat(), b0 / emitCoefTot) );
2232 while (alphaS.alphaS2OrdCorr(renormMultFac * dip.pT2) < rndmPtr->flat()
2233 && dip.pT2 > pT2min);
2238 if (nFlavour == 5 && dip.pT2 < m2b) {
2239 mustFindRange =
true;
2241 }
else if ( nFlavour == 4 && dip.pT2 < m2c) {
2242 mustFindRange =
true;
2247 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2252 if (colTypeAbs == 2 && emitCoefQqbar > rndmPtr->flat()
2253 * emitCoefTot) dip.flavour = 0;
2256 if (dip.flavour == 21) {
2257 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2259 dip.z = zMinAbs + (1. - 2. * zMinAbs) * rndmPtr->flat();
2263 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2264 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2265 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2266 if (dip.z > zMin && dip.z < 1. - zMin
2267 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2268 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2271 if (dip.flavour == 0) {
2272 dip.flavour = min(5, 1 +
int(nGluonToQuark * rndmPtr->flat()));
2273 dip.mFlavour = particleDataPtr->m0(dip.flavour);
2276 if (dip.flavour == 21
2277 && (colTypeAbs == 1 || colTypeAbs == 3) ) {
2278 nameNow =
"fsr:Q2QG";
2281 double enhance = userHooksPtr->enhanceFactor(nameNow);
2282 if (enhance != 1.) {
2283 enhanceNow = enhance;
2284 isEnhancedQ2QG =
true;
2287 }
else if (dip.flavour == 21) {
2288 nameNow =
"fsr:G2GG";
2291 double enhance = userHooksPtr->enhanceFactor(nameNow);
2292 if (enhance != 1.) {
2293 enhanceNow = enhance;
2294 isEnhancedG2GG =
true;
2298 if (dip.flavour < 4) nameNow =
"fsr:G2QQ";
2299 else if (dip.flavour == 4) nameNow =
"fsr:G2QQ:cc";
2300 else nameNow =
"fsr:G2QQ:bb";
2303 double enhance = userHooksPtr->enhanceFactor(nameNow);
2304 if (enhance != 1.) {
2305 enhanceNow = enhance;
2306 isEnhancedG2QQ =
true;
2312 if (dip.MEtype > 0) {
2314 if (dip.flavour < 10 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
2318 }
else if (dip.flavour == 21
2319 && (colTypeAbs == 1 || colTypeAbs == 3) ) {
2320 wt = (1. + pow2(dip.z)) / wtPSglue;
2323 }
else if (dip.flavour == 21) {
2324 wt = (1. + pow3(dip.z)) / wtPSglue;
2325 if (recoilDeadCone && dip.mRec > 0.) {
2326 double r2G = dip.m2Rec / dip.m2Dip;
2327 double x1G = (1. - r2G + dip.m2 / dip.m2Dip) * dip.z;
2328 double x2G = 1. + r2G - dip.m2 / dip.m2Dip;
2329 wt *= 1. - (r2G / max(XMARGIN, x1G + x2G - 1. - r2G))
2330 * (max(XMARGIN, 1. + r2G - x2G) / max(XMARGIN,1. - r2G - x1G));
2335 double ratioQ = pow2(dip.mFlavour) / dip.m2;
2336 double betaQ = sqrtpos( 1. - 4. * ratioQ );
2337 if (weightGluonToQuark%4 == 1) {
2338 wt = betaQ * ( pow2(dip.z) + pow2(1. - dip.z) );
2339 }
else if (weightGluonToQuark%4 == 2) {
2340 wt = betaQ * ( pow2(dip.z) + pow2(1. - dip.z)
2341 + 8. * ratioQ * dip.z * (1. - dip.z) );
2343 double m2Rat = dip.m2 / dip.m2DipCorr;
2344 double zCosThe = ((1. + m2Rat) * dip.z - m2Rat) / (1. - m2Rat);
2345 wt = betaQ * ( pow2(zCosThe) + pow2(1. - zCosThe)
2346 + 8. * ratioQ * zCosThe * (1. - zCosThe) )
2347 * (1. + m2Rat) / ((1. - m2Rat) * extraGluonToQuark) ;
2348 if (weightGluonToQuark%4 == 0) wt *= pow3(1. - m2Rat);
2350 if (weightGluonToQuark > 4 && alphaSorder > 0)
2351 wt *= log(dip.pT2 / Lambda2)
2352 / log(scaleGluonToQuark * dip.m2 / Lambda2);
2359 if (dip.isrType != 0 && useLocalRecoilNow) {
2360 BeamParticle&
beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2361 int iSysRec = dip.systemRec;
2362 double xOld = beam[iSysRec].x();
2363 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2364 (dip.m2Dip - dip.m2Rad));
2365 double xMaxAbs = beam.xMax(iSysRec);
2367 infoPtr->errorMsg(
"Warning in SimpleTimeShower::pT2nextQCD: "
2368 "xMaxAbs negative");
2374 if (xNew > 1.) wt = 0.;
2377 if (xNew > xMaxAbs) wt = 0.;
2379 int idRec =
event[dip.iRecoiler].id();
2380 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2381 : factorMultFac * dip.pT2;
2382 xfModPrepData xfData = beam.xfModPrep(iSysRec, pdfScale2);
2383 double pdfOld = max ( TINYPDF,
2384 beam.xfISR( iSysRec, idRec, xOld, pdfScale2, xfData) );
2386 beam.xfISR( iSysRec, idRec, xNew, pdfScale2, xfData);
2387 wt *= min( 1., pdfNew / pdfOld);
2391 if (dampenBeamRecoil) {
2392 double pTpT = sqrt(event[dip.iRadiator].pT2() * dip.pT2);
2393 wt *= pTpT / (pTpT + dip.m2);
2398 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2399 wt *= pT2damp / (dip.pT2 + pT2damp);
2404 if (wt > 0. && dip.pT2 > pT2min && doUncertaintiesNow) {
2410 }
while (wt < rndmPtr->flat());
2413 splittingNameNow = nameNow;
2415 if (isEnhancedQ2QG) storeEnhanceFactor(dip.pT2,
"fsr:Q2QG", enhanceNow);
2416 if (isEnhancedG2QQ) storeEnhanceFactor(dip.pT2,
"fsr:G2QQ", enhanceNow);
2417 if (isEnhancedG2GG) storeEnhanceFactor(dip.pT2,
"fsr:G2GG", enhanceNow);
2426 void SimpleTimeShower::pT2nextQED(
double pT2begDip,
double pT2sel,
2427 TimeDipoleEnd& dip,
Event& event) {
2430 double pT2chgCut = (dip.chgType != 0 && abs(dip.chgType) != 3)
2431 ? pT2chgQCut : pT2chgLCut;
2432 double pT2endDip = max( pT2sel, pT2chgCut );
2433 if (pT2begDip < pT2endDip)
return;
2436 bool hasCharge = (dip.chgType != 0);
2439 double wtPSgam = 0.;
2440 double chg2Sum = 0.;
2441 double chg2SumL = 0.;
2442 double chg2SumQ = 0.;
2443 double zMinAbs = 0.;
2444 double emitCoefTot = 0.;
2447 double alphaEMmax = alphaEM.alphaEM(renormMultFac * dip.m2DipCorr);
2448 double alphaEM2pi = alphaEMmax / (2. * M_PI);
2451 bool isEnhancedQ2QA, isEnhancedA2LL, isEnhancedA2QQ;
2452 isEnhancedQ2QA = isEnhancedA2LL = isEnhancedA2QQ =
false;
2453 double enhanceNow = 1.;
2454 string nameNow =
"";
2459 double chg2 = pow2(dip.chgType / 3.);
2462 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2463 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2464 emitCoefTot = alphaEM2pi * chg2 * wtPSgam * log(1. / zMinAbs - 1.);
2466 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QA");
2470 chg2SumL = max(0, min(3, nGammaToLepton));
2471 if (nGammaToQuark > 4) chg2SumQ = 11. / 9.;
2472 else if (nGammaToQuark > 3) chg2SumQ = 10. / 9.;
2473 else if (nGammaToQuark > 2) chg2SumQ = 6. / 9.;
2474 else if (nGammaToQuark > 1) chg2SumQ = 5. / 9.;
2475 else if (nGammaToQuark > 0) chg2SumQ = 1. / 9.;
2478 if (canEnhanceET) chg2SumL *= userHooksPtr->enhanceFactor(
"fsr:A2LL");
2479 if (canEnhanceET) chg2SumQ *= userHooksPtr->enhanceFactor(
"fsr:A2QQ");
2482 chg2Sum = chg2SumL + 3. * chg2SumQ;
2483 emitCoefTot = alphaEM2pi * chg2Sum * extraGluonToQuark;
2487 dip.pT2 = pT2begDip;
2495 isEnhancedQ2QA = isEnhancedA2LL = isEnhancedA2QQ =
false;
2500 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
2504 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2507 if (hasCharge) dip.z = 1. - zMinAbs
2508 * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2509 else dip.z = rndmPtr->flat();
2512 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2513 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2514 if (dip.z <= zMin || dip.z >= 1. - zMin)
continue;
2515 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2516 if (dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2517 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec)
2519 && (hasCharge || dip.m2 < m2MaxGamma) ) {
2528 if (rndmPtr->flat() * chg2Sum < chg2SumL)
2529 dip.flavour = 9 + 2 * min(3, 1 +
int(chg2SumL * rndmPtr->flat()));
2531 double rndmQ = 9. * chg2SumQ * rndmPtr->flat();
2532 if (rndmQ < 1.) dip.flavour = 1;
2533 else if (rndmQ < 5.) dip.flavour = 2;
2534 else if (rndmQ < 6.) dip.flavour = 3;
2535 else if (rndmQ < 10.) dip.flavour = 4;
2536 else dip.flavour = 5;
2538 dip.mFlavour = particleDataPtr->m0(dip.flavour);
2543 nameNow =
"fsr:Q2QA";
2546 double enhance = userHooksPtr->enhanceFactor(nameNow);
2547 if (enhance != 1.) {
2548 enhanceNow = enhance;
2549 isEnhancedQ2QA =
true;
2552 }
else if (dip.flavour > 10) {
2553 nameNow =
"fsr:A2LL";
2556 double enhance = userHooksPtr->enhanceFactor(nameNow);
2557 if (enhance != 1.) {
2558 enhanceNow = enhance;
2559 isEnhancedA2LL =
true;
2563 nameNow =
"fsr:A2QQ";
2566 double enhance = userHooksPtr->enhanceFactor(nameNow);
2567 if (enhance != 1.) {
2568 enhanceNow = enhance;
2569 isEnhancedA2QQ =
true;
2575 if (dip.MEtype > 0) {
2577 if (dip.flavour < 20 && dip.m2 < THRESHM2 * pow2(dip.mFlavour))
2581 }
else if (hasCharge) {
2582 wt = (1. + pow2(dip.z)) / wtPSgam;
2586 double ratioF = pow2(dip.mFlavour) / dip.m2;
2587 double betaF = sqrtpos( 1. - 4. * ratioF );
2588 if (weightGluonToQuark%4 == 1) {
2589 wt = betaF * ( pow2(dip.z) + pow2(1. - dip.z) );
2590 }
else if (weightGluonToQuark%4 == 2) {
2591 wt = betaF * ( pow2(dip.z) + pow2(1. - dip.z)
2592 + 8. * ratioF * dip.z * (1. - dip.z) );
2594 double m2Rat = dip.m2 / dip.m2DipCorr;
2595 double zCosThe = ((1. + m2Rat) * dip.z - m2Rat) / (1. - m2Rat);
2596 wt = betaF * ( pow2(zCosThe) + pow2(1. - zCosThe)
2597 + 8. * ratioF * zCosThe * (1. - zCosThe) )
2598 * (1. + m2Rat) / ((1. - m2Rat) * extraGluonToQuark) ;
2599 if (weightGluonToQuark%4 == 0) wt *= pow3(1. - m2Rat);
2604 double aEMscale = dip.pT2;
2605 if (dip.flavour < 20 && weightGluonToQuark > 4)
2606 aEMscale = scaleGluonToQuark * dip.m2;
2607 double alphaEMnow = alphaEM.alphaEM(renormMultFac * aEMscale);
2608 wt *= (alphaEMnow / alphaEMmax);
2611 if (dip.isrType != 0 && useLocalRecoilNow) {
2612 BeamParticle& beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2613 int iSys = dip.system;
2614 double xOld = beam[iSys].x();
2615 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2616 (dip.m2Dip - dip.m2Rad));
2617 double xMaxAbs = beam.xMax(iSys);
2619 infoPtr->errorMsg(
"Warning in SimpleTimeShower::pT2nextQED: "
2620 "xMaxAbs negative");
2626 if (xNew > 1.) wt = 0.;
2629 if (xNew > xMaxAbs) wt = 0.;
2631 int idRec =
event[dip.iRecoiler].id();
2632 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2633 : factorMultFac * dip.pT2;
2634 xfModPrepData xfData = beam.xfModPrep(iSys, pdfScale2);
2635 double pdfOld = max ( TINYPDF,
2636 beam.xfISR( iSys, idRec, xOld, pdfScale2, xfData) );
2638 beam.xfISR( iSys, idRec, xNew, pdfScale2, xfData);
2639 wt *= min( 1., pdfNew / pdfOld);
2643 if (dampenBeamRecoil) {
2644 double pT24 = 4. *
event[dip.iRadiator].pT2();
2645 wt *= pT24 / (pT24 + dip.m2);
2650 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2651 wt *= pT2damp / (dip.pT2 + pT2damp);
2655 }
while (wt < rndmPtr->flat());
2658 splittingNameNow = nameNow;
2660 if (isEnhancedQ2QA) storeEnhanceFactor(dip.pT2,
"fsr:Q2QA", enhanceNow);
2661 if (isEnhancedA2LL) storeEnhanceFactor(dip.pT2,
"fsr:A2LL", enhanceNow);
2662 if (isEnhancedA2QQ) storeEnhanceFactor(dip.pT2,
"fsr:A2QQ", enhanceNow);
2671 void SimpleTimeShower::pT2nextWeak(
double pT2begDip,
double pT2sel,
2672 TimeDipoleEnd& dip,
Event& event) {
2675 double pT2endDip = max( pT2sel, pT2weakCut );
2676 if (pT2begDip < pT2endDip)
return;
2679 double wtPSgam = 0.;
2680 double zMinAbs = 0.;
2681 double emitCoefTot = 0.;
2684 double alphaEMmax = alphaEM.alphaEM(renormMultFac * pT2begDip);
2685 double alphaEM2pi = alphaEMmax / (2. * M_PI);
2691 zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2692 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2695 double weakCoupling = 0.;
2698 if (dip.weakType == 1)
2699 weakCoupling = 2. * alphaEM2pi / (4. * coupSMPtr->sin2thetaW());
2701 else if (dip.weakType == 2 && dip.weakPol == -1)
2702 weakCoupling = alphaEM2pi * thetaWRat
2703 * pow2(2. * coupSMPtr->lf( event[dip.iRadiator].idAbs() ));
2705 weakCoupling = alphaEM2pi * thetaWRat
2706 * pow2(2. * coupSMPtr->rf( event[dip.iRadiator].idAbs() ));
2709 bool isEnhancedQ2QW;
2710 isEnhancedQ2QW =
false;
2711 double enhanceNow = 1.;
2712 string nameNow =
"";
2715 emitCoefTot = weakEnhancement * weakCoupling
2716 * wtPSgam * log(1. / zMinAbs - 1.);
2718 if ( dip.MEtype == 201 || dip.MEtype == 202 || dip.MEtype == 203
2719 || dip.MEtype == 206 || dip.MEtype == 207 || dip.MEtype == 208 )
2720 emitCoefTot *= WEAKPSWEIGHT;
2721 dip.pT2 = pT2begDip;
2725 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QW");
2731 isEnhancedQ2QW =
false;
2736 dip.pT2 = dip.pT2 * pow(rndmPtr->flat(), 1. / emitCoefTot);
2740 if ( dip.pT2 < pT2endDip) {dip.pT2 = 0.;
return; }
2743 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2746 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2747 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2748 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2749 if (dip.z > zMin && dip.z < 1. - zMin
2750 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2751 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2754 if (dip.weakType == 1) {
2755 dip.flavour = (
event[dip.iRadiator].id() > 0) ? 24 : -24;
2756 if (event[dip.iRadiator].idAbs() % 2 == 1) dip.flavour = -dip.flavour;
2757 }
else if (dip.weakType == 2) dip.flavour = 23;
2760 dip.mFlavour = particleDataPtr->mSel( dip.flavour);
2764 if (dip.MEtype > 0) wt = 1.;
2767 double alphaEMnow = alphaEM.alphaEM(renormMultFac * dip.pT2);
2768 wt *= (alphaEMnow / alphaEMmax);
2770 nameNow =
"fsr:Q2QW";
2773 double enhance = userHooksPtr->enhanceFactor(nameNow);
2774 if (enhance != 1.) {
2775 enhanceNow = enhance;
2776 isEnhancedQ2QW =
true;
2781 if (dip.isrType != 0 && useLocalRecoilNow) {
2782 BeamParticle& beam = (dip.isrType == 1) ? *beamAPtr : *beamBPtr;
2783 int iSys = dip.system;
2784 double xOld = beam[iSys].x();
2785 double xNew = xOld * (1. + (dip.m2 - dip.m2Rad) /
2786 (dip.m2Dip - dip.m2Rad));
2787 double xMaxAbs = beam.xMax(iSys);
2789 infoPtr->errorMsg(
"Warning in SimpleTimeShower::pT2nextWeak: "
2790 "xMaxAbs negative");
2796 if (xNew > 1.) wt = 0.;
2799 if (xNew > xMaxAbs) wt = 0.;
2801 int idRec =
event[dip.iRecoiler].id();
2802 pdfScale2 = (useFixedFacScale) ? fixedFacScale2
2803 : factorMultFac * dip.pT2;
2804 xfModPrepData xfData = beam.xfModPrep(iSys, pdfScale2);
2805 double pdfOld = max ( TINYPDF,
2806 beam.xfISR( iSys, idRec, xOld, pdfScale2, xfData) );
2808 beam.xfISR( iSys, idRec, xNew, pdfScale2, xfData);
2809 wt *= min( 1., pdfNew / pdfOld);
2812 if (dampenBeamRecoil) {
2813 double pT24 = 4. *
event[dip.iRadiator].pT2();
2814 wt *= pT24 / (pT24 + dip.m2);
2820 if (dopTdamp && dip.system == 0) wt *= pT2damp / (dip.pT2 + pT2damp);
2823 }
while (wt < rndmPtr->flat());
2826 splittingNameNow = nameNow;
2827 if (canEnhanceET && isEnhancedQ2QW)
2828 storeEnhanceFactor(dip.pT2,
"fsr:Q2QW", enhanceNow);
2836 void SimpleTimeShower::pT2nextHV(
double pT2begDip,
double pT2sel,
2837 TimeDipoleEnd& dip,
Event& ) {
2840 double pT2endDip = max( pT2sel, pT2hvCut );
2841 if (pT2begDip < pT2endDip)
return;
2844 int colvTypeAbs = abs(dip.colvType);
2845 double colvFac = (colvTypeAbs == 1) ? CFHV : 0.5 * nCHV;
2846 double alphaHV2pi = alphaHVfix / (2. * M_PI);
2847 double b0HV = (11. /6. * nCHV - 2. / 6. * nFlavHV);
2850 double zMinAbs = 0.5 - sqrtpos( 0.25 - pT2endDip / dip.m2DipCorr );
2851 if (zMinAbs < SIMPLIFYROOT) zMinAbs = pT2endDip / dip.m2DipCorr;
2852 double emitCoefTot = colvFac * 2. * log(1. / zMinAbs - 1.);
2853 double LambdaHV2 = pow2(LambdaHV);
2856 dip.pT2 = pT2begDip;
2860 bool isEnhancedQ2QHV;
2861 isEnhancedQ2QHV =
false;
2862 double enhanceNow = 1.;
2863 string nameNow =
"";
2866 if (canEnhanceET) emitCoefTot *= userHooksPtr->enhanceFactor(
"fsr:Q2QHV");
2872 isEnhancedQ2QHV =
false;
2877 if (alphaHVorder == 0) {
2878 dip.pT2 = dip.pT2 * pow( rndmPtr->flat(),
2879 1. / (alphaHV2pi * emitCoefTot) );
2880 }
else if (alphaHVorder == 1) {
2881 dip.pT2 = LambdaHV2 * pow( dip.pT2 / LambdaHV2,
2882 pow( rndmPtr->flat(), b0HV / emitCoefTot) );
2887 if ( dip.pT2 < pT2endDip) { dip.pT2 = 0.;
return; }
2890 dip.z = 1. - zMinAbs * pow( 1. / zMinAbs - 1., rndmPtr->flat() );
2893 double zMin = 0.5 - sqrtpos( 0.25 - dip.pT2 / dip.m2DipCorr );
2894 if (zMin < SIMPLIFYROOT) zMin = dip.pT2 / dip.m2DipCorr;
2895 dip.m2 = dip.m2Rad + dip.pT2 / (dip.z * (1. - dip.z));
2896 if (dip.z > zMin && dip.z < 1. - zMin
2897 && dip.m2 * dip.m2Dip < dip.z * (1. - dip.z)
2898 * pow2(dip.m2Dip + dip.m2 - dip.m2Rec) ) {
2905 if (dip.MEtype > 0) wt = 1.;
2908 else if (colvTypeAbs == 1) wt = (1. + pow2(dip.z)) / 2.;
2909 else wt = (1. + pow3(dip.z)) / 2.;
2911 nameNow =
"fsr:Q2QHV";
2914 double enhance = userHooksPtr->enhanceFactor(nameNow);
2915 if (enhance != 1.) {
2916 enhanceNow = enhance;
2917 isEnhancedQ2QHV =
true;
2924 if (dopTdamp && dip.system == 0 && dip.MEtype == 0)
2925 wt *= pT2damp / (dip.pT2 + pT2damp);
2928 }
while (wt < rndmPtr->flat());
2931 splittingNameNow = nameNow;
2932 if (canEnhanceET && isEnhancedQ2QHV)
2933 storeEnhanceFactor(dip.pT2,
"fsr:Q2QHV", enhanceNow);
2944 bool SimpleTimeShower::branch(
Event& event,
bool isInterleaved) {
2948 bool hardSystem = partonSystemsPtr->getHard(dipSel->system);
2949 bool isQCD =
event[dipSel->iRadiator].colType() != 0;
2952 useLocalRecoilNow = !(globalRecoil && hardSystem
2953 && partonSystemsPtr->sizeOut(dipSel->system) <= nMaxGlobalRecoil);
2956 if (globalRecoilMode == 1 && isQCD) {
2957 if ( globalRecoil && hardSystem) useLocalRecoilNow =
true;
2958 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
2959 if ( event[dipSel->iRadiator].isAncestor(hardPartons[iHard]) )
2960 useLocalRecoilNow =
false;
2962 if ( !globalRecoil || nGlobal >= nMaxGlobalBranch )
2963 useLocalRecoilNow =
true;
2966 }
else if (globalRecoilMode == 2 && isQCD) {
2967 useLocalRecoilNow = !(globalRecoil
2968 && nProposed.find(dipSel->system) != nProposed.end()
2969 && nProposed[dipSel->system] - infoPtr->getCounter(40) == 1);
2972 for (
int i = 0; i < int(event.size()); ++i)
2973 if ( event[i].isFinal() &&
event[i].colType() != 0) nFinal++;
2974 bool isFirst = (nHard == nFinal);
2975 if ( globalRecoil && doInterleave && !isFirst )
2976 useLocalRecoilNow =
true;
2978 if ( nFinalBorn > 0 && nHard > nFinalBorn )
2979 useLocalRecoilNow =
true;
2983 bool canMergeFirst = (mergingHooksPtr != 0)
2984 ? mergingHooksPtr->canVetoEmission() :
false;
2986 int npartons = 0, nfinal = 0, nw = 0, nz = 0;
2987 for (
int i = 0; i <
event.size(); ++i) {
if(event[i].isFinal() ) {
2989 if (event[i].colType() != 0) npartons++;
2990 if (event[i].
id() == 23) nz++;
2991 if (event[i].idAbs() == 24) nw++;
2996 int iRadBef = dipSel->iRadiator;
2997 int iRecBef = dipSel->iRecoiler;
2998 Particle& radBef =
event[iRadBef];
2999 Particle& recBef =
event[iRecBef];
3002 Vec4 pRadBef =
event[iRadBef].p();
3004 vector<int> iGRecBef, iGRec;
3005 if (useLocalRecoilNow) pRecBef =
event[iRecBef].p();
3009 for (
int iS = 0; iS < partonSystemsPtr->sizeSys(); ++iS) {
3010 for (
int i = 0; i < partonSystemsPtr->sizeOut(iS); ++i) {
3011 int iG = partonSystemsPtr->getOut( iS, i);
3012 bool hasHardAncestor =
event[iG].statusAbs() < 23;
3013 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
3014 if ( event[iG].isAncestor(hardPartons[iHard])
3015 || iG == hardPartons[iHard]
3016 || (
event[iG].status() == 23 &&
event[iG].colType() == 0))
3017 hasHardAncestor =
true;
3018 if (hasHardAncestor && iG != dipSel->iRadiator
3019 && event[iG].isFinal() ) {
3020 iGRecBef.push_back(iG);
3021 pRecBef +=
event[iG].p();
3028 Vec4 p3weak, p4weak;
3029 if (dipSel->MEtype >= 200 && dipSel->MEtype <= 210) {
3030 p3weak =
event[3].p();
3031 p4weak =
event[4].p();
3033 if ( dipSel->MEtype == 201 || dipSel->MEtype == 202
3034 || dipSel->MEtype == 203 || dipSel->MEtype == 206
3035 || dipSel->MEtype == 207 || dipSel->MEtype == 208) {
3036 if (!weakExternal) {
3038 int i2to2Mother = iRadBef;
3039 while (i2to2Mother != 5 && i2to2Mother != 6 && i2to2Mother != 0)
3040 i2to2Mother =
event[i2to2Mother].mother1();
3041 if (i2to2Mother == 0)
return false;
3044 if (event[3].
id() != event[4].
id()) {
3045 if (event[3].
id() == event[i2to2Mother].
id());
3046 else if (event[4].
id() == event[i2to2Mother].
id())
3047 swap(p3weak, p4weak);
3049 else if (rndmPtr->flat() < 0.5) swap(p3weak, p4weak);
3052 else if (rndmPtr->flat() < 0.5) swap(p3weak, p4weak);
3054 int i2to2Mother = iRadBef;
3055 while (i2to2Mother >= weakHardSize)
3056 i2to2Mother =
event[i2to2Mother].mother1();
3057 if (weak2to2lines[2] == i2to2Mother) {
3058 p3weak = weakMomenta[0];
3059 p4weak = weakMomenta[1];
3061 p3weak = weakMomenta[1];
3062 p4weak = weakMomenta[0];
3068 int idRad = radBef.id();
3069 int idEmt = dipSel->flavour;
3070 int colRad = radBef.col();
3071 int acolRad = radBef.acol();
3074 iSysSel = dipSel->system;
3075 int iSysSelRec = dipSel->systemRec;
3078 int colTypeTmp = dipSel->colType;
3079 int colTypeRec = particleDataPtr->colType( recBef.id() );
3081 if (!recBef.isFinal()) colTypeRec = -colTypeRec;
3082 int colTypeRad = particleDataPtr->colType( idRad );
3084 bool hasJunction = dipSel->hasJunction;
3088 if (colTypeRec == 1 && colTypeTmp > 0) colTypeTmp = -colTypeTmp;
3089 if (colTypeRec == -1 && colTypeTmp < 0) colTypeTmp = -colTypeTmp;
3090 if (colTypeRad == 1 && colTypeTmp < 0) colTypeTmp = -colTypeTmp;
3091 if (colTypeRad == -1 && colTypeTmp > 0) colTypeTmp = -colTypeTmp;
3095 if (dipSel->flavour == 22 || dipSel->flavour == idHV) {
3097 }
else if (dipSel->flavour == 21 && colTypeTmp > 0) {
3099 colRad =
event.nextColTag();
3101 }
else if (dipSel->flavour == 21) {
3103 acolRad =
event.nextColTag();
3106 }
else if (colTypeTmp > 0) {
3107 idEmt = dipSel->flavour ;
3111 }
else if (colTypeTmp < 0) {
3112 idEmt = -dipSel->flavour ;
3117 }
else if (dipSel->gamType == 1 && rndmPtr->flat() > 0.5) {
3118 idEmt = -dipSel->flavour ;
3120 if (idRad < 10) colRad =
event.nextColTag();
3122 }
else if (dipSel->gamType == 1) {
3123 idEmt = dipSel->flavour ;
3125 if (idEmt < 10) colEmt =
event.nextColTag();
3130 int idRadSv = idRad;
3131 if (abs(idEmt) == 24) {
3132 if (rndmPtr->flat() > coupSMPtr->V2CKMsum(idRad))
return false;
3133 idRad = coupSMPtr->V2CKMpick(idRad);
3138 double pTorig = sqrt( dipSel->pT2);
3139 double eRadPlusEmt = 0.5 * (dipSel->m2Dip + dipSel->m2 - dipSel->m2Rec)
3141 double e2RadPlusEmt = pow2(eRadPlusEmt);
3142 double pzRadPlusEmt = 0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2
3143 - dipSel->m2Rec) - 4. * dipSel->m2 * dipSel->m2Rec ) / dipSel->mDip;
3144 double pT2corr = dipSel->m2 * (e2RadPlusEmt * dipSel->z * (1. - dipSel->z)
3145 - 0.25 * dipSel->m2) / pow2(pzRadPlusEmt);
3146 double pTcorr = sqrtpos( pT2corr );
3147 double pzRad = (e2RadPlusEmt * dipSel->z - 0.5 * dipSel->m2)
3149 double pzEmt = (e2RadPlusEmt * (1. - dipSel->z) - 0.5 * dipSel->m2)
3152 double mRad = (idRad == idRadSv) ? dipSel->mRad
3153 : particleDataPtr->m0(idRad);
3154 double m2Rad = pow2(mRad);
3159 if ( dipSel->weakType != 0
3160 || (abs(dipSel->colvType) == 1 && dipSel->mFlavour > 0.) ) {
3161 mEmt = dipSel->mFlavour;
3162 if (pow2(mRad + mEmt) > dipSel->m2)
return false;
3163 double m2Emt = pow2(mEmt);
3164 double lambda = sqrtpos( pow2(dipSel->m2 - m2Rad - m2Emt)
3165 - 4. * m2Rad * m2Emt );
3166 kRad = 0.5 * (dipSel->m2 - lambda + m2Emt - m2Rad)
3168 kEmt = 0.5 * (dipSel->m2 - lambda + m2Rad - m2Emt)
3170 pTorig *= 1. - kRad - kEmt;
3171 pTcorr *= 1. - kRad - kEmt;
3172 double pzMove = kRad * pzRad - kEmt * pzEmt;
3177 }
else if (abs(dipSel->colType) == 1 || dipSel->chgType != 0
3178 || abs(dipSel->colvType) == 1) {
3179 pTorig *= 1. - dipSel->m2Rad / dipSel->m2;
3180 pTcorr *= 1. - dipSel->m2Rad / dipSel->m2;
3181 pzRad += pzEmt * dipSel->m2Rad / dipSel->m2;
3182 pzEmt *= 1. - dipSel->m2Rad / dipSel->m2;
3185 }
else if (abs(dipSel->flavour) < 20) {
3186 mEmt = dipSel->mFlavour;
3188 double beta = sqrtpos( 1. - 4. * pow2(mEmt) / dipSel->m2 );
3191 pzRad = 0.5 * ( (1. + beta) * pzRad + (1. - beta) * pzEmt );
3192 pzEmt = pzRadPlusEmt - pzRad;
3196 if (idEmt == 21 && pTorig < pTcolCut)
return false;
3200 M.fromCMframe(pRadBef, pRecBef);
3202 M1.fromCMframe(pRadBef, pRecBef);
3204 M2.toCMframe(pRadBef, pRecBef);
3207 findAsymPol( event, dipSel);
3210 Vec4 pRad, pEmt, pRec;
3213 double phi = 2. * M_PI * rndmPtr->flat();
3216 pRad = Vec4( pTcorr * cos(phi), pTcorr * sin(phi), pzRad,
3217 sqrt( pow2(pTcorr) + pow2(pzRad) + pow2(mRad) ) );
3218 pEmt = Vec4( -pRad.px(), -pRad.py(), pzEmt,
3219 sqrt( pow2(pTcorr) + pow2(pzEmt) + pow2(mEmt) ) );
3220 pRec = Vec4( 0., 0., -pzRadPlusEmt, sqrt( pow2(pzRadPlusEmt)
3221 + dipSel->m2Rec ) );
3230 if (dipSel->isrType != 0) {
3231 if (abs(pRec.px()) > 0.) {
3232 double phixx = pRec.phi();
3233 RotBstMatrix rot_by_pphi;
3234 rot_by_pphi.rot(0.,-phixx);
3235 pRec.rotbst( rot_by_pphi);
3236 double thetaxx = pRec.theta();
3237 if ( pRec.px() < 0. ) thetaxx *= -1.;
3238 if ( pRec.pz() < 0.) thetaxx += M_PI;
3239 RotBstMatrix rot_by_ptheta;
3240 rot_by_ptheta.rot(-thetaxx, 0.);
3241 pRec.rotbst( rot_by_ptheta );
3246 if (dipSel->asymPol != 0.) {
3247 Vec4 pAunt =
event[dipSel->iAunt].p();
3248 double cosPhi = cosphi( pRad, pAunt, pRadBef );
3249 wtPhi = ( 1. + dipSel->asymPol * (2. * pow2(cosPhi) - 1.) )
3250 / ( 1. + abs(dipSel->asymPol) );
3252 }
while (wtPhi < rndmPtr->flat()) ;
3255 int isrTypeNow = dipSel->isrType;
3256 int isrTypeSave = isrTypeNow;
3257 if (!useLocalRecoilNow) isrTypeNow = 0;
3258 if (isrTypeNow != 0) pRec = 2. * recBef.p() - pRec;
3261 if ( isrTypeNow != 0 && 2.*pRec.e()/
event[0].m() > 1. ) {
3262 infoPtr->errorMsg(
"Error in SimpleTimeShower::branch: "
3263 "Larger than unity Bjorken x value");
3268 bool isFlexible = dipSel->isFlexible;
3271 double pTsel = sqrt(dipSel->pT2);
3272 Particle rad = Particle(idRad, 51, iRadBef, 0, 0, 0,
3273 colRad, acolRad, pRad, mRad, pTsel);
3274 Particle emt = Particle(idEmt, 51, iRadBef, 0, 0, 0,
3275 colEmt, acolEmt, pEmt, mEmt, pTsel);
3278 Particle rec = (isrTypeNow == 0)
3279 ? Particle(recBef.id(), 52, iRecBef, iRecBef, 0, 0,
3280 recBef.col(), recBef.acol(), pRec, dipSel->mRec, pTsel)
3281 : Particle(recBef.id(), -53, 0, 0, iRecBef, iRecBef,
3282 recBef.col(), recBef.acol(), pRec, 0., 0.);
3286 if (emt.idAbs() == 23 || emt.idAbs() == 24) {
3288 event[iRadBef].pol( dipSel->weakPol );
3289 rad.pol( dipSel->weakPol );
3293 double pAccept = dipSel->pAccept;
3296 if (dipSel->MEtype > 0) {
3297 Particle& partner = (dipSel->iMEpartner == iRecBef)
3298 ? rec : event[dipSel->iMEpartner];
3299 double pMEC = findMEcorr( dipSel, rad, partner, emt);
3300 if (dipSel->MEtype >= 200 && dipSel->MEtype <= 210)
3301 pMEC *= findMEcorrWeak( dipSel, rad.p(), partner.p(), emt.p(),
3302 p3weak, p4weak,
event[iRadBef].p(),
event[iRecBef].p());
3308 bool acceptEvent =
true;
3309 if (pAccept < 1.0) acceptEvent = (rndmPtr->flat() < pAccept);
3312 bool inResonance = !partonSystemsPtr->hasInAB(iSysSel);
3315 doUncertaintiesNow = doUncertainties;
3317 if (!uVarMPIshowers && iSysSel != 0 && !inResonance)
3318 doUncertaintiesNow =
false;
3321 if (noResVariations && inResonance) doUncertaintiesNow =
false;
3324 if (noProcVariations && iSysSel==0 && !inResonance)
3325 doUncertaintiesNow =
false;
3328 if ( dipSel->pT2 < uVarpTmin2 ) doUncertaintiesNow =
false;
3331 if (!doUncertaintiesNow && !acceptEvent)
return false;
3336 if (allowRescatter && FIXRESCATTER && isInterleaved
3337 && iSysSel != iSysSelRec) {
3338 Vec4 pNew = rad.p() + emt.p();
3339 if (!rescatterPropagateRecoil(event, pNew))
return false;
3343 if ( isrTypeNow != 0 ) {
3344 BeamParticle& beamRec = (isrTypeNow == 1) ? *beamAPtr : *beamBPtr;
3345 if ( beamRec.isGamma() ) {
3347 if ( !beamRec.resolvedGamma() )
return false;
3348 BeamParticle& beamOther = (isrTypeNow == 1) ? *beamBPtr : *beamAPtr;
3349 bool physical =
true;
3350 double xRec = 2. * pRec.e() / (beamRec.e() + beamOther.e());
3351 double sCM = m2( beamRec.p(), beamOther.p());
3352 double eCM = sqrt(sCM);
3354 if ( !beamOther.resolvedGamma() ) {
3355 physical = beamRec.roomFor1Remnant(beamRec[0].
id(), xRec, eCM);
3358 physical = beamOther.roomFor2Remnants(beamRec[0].
id(), xRec, eCM);
3361 if (!physical)
return false;
3366 int eventSizeOld =
event.size();
3367 int iRadStatusV =
event[iRadBef].status();
3368 int iRadDau1V =
event[iRadBef].daughter1();
3369 int iRadDau2V =
event[iRadBef].daughter2();
3370 int iRecStatusV =
event[iRecBef].status();
3371 int iRecMot1V =
event[iRecBef].mother1();
3372 int iRecMot2V =
event[iRecBef].mother2();
3373 int iRecDau1V =
event[iRecBef].daughter1();
3374 int iRecDau2V =
event[iRecBef].daughter2();
3375 int beamOff1 = 1 + beamOffset;
3376 int beamOff2 = 2 + beamOffset;
3377 int ev1Dau1V =
event[beamOff1].daughter1();
3378 int ev2Dau1V =
event[beamOff2].daughter1();
3381 if (radBef.hasVertex()) {
3382 rad.vProd( radBef.vProd() );
3383 emt.vProd( radBef.vProd() );
3385 if (recBef.hasVertex()) rec.vProd( recBef.vProd() );
3388 int iRad =
event.append(rad);
3389 int iEmt =
event.append(emt);
3392 if (doPartonVertex) partonVertexPtr->vertexFSR( iEmt, event);
3395 event[iRadBef].statusNeg();
3396 event[iRadBef].daughters( iRad, iEmt);
3398 if (useLocalRecoilNow) {
3399 iRec =
event.append(rec);
3400 if (isrTypeNow == 0) {
3401 event[iRecBef].statusNeg();
3402 event[iRecBef].daughters( iRec, iRec);
3404 event[iRecBef].mothers( iRec, iRec);
3405 event[iRec].mothers( iRecMot1V, iRecMot2V);
3406 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( iRec);
3407 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( iRec);
3413 RotBstMatrix MG = M;
3415 double pzRecBef = -0.5 * sqrtpos( pow2(dipSel->m2Dip - dipSel->m2Rad
3416 - dipSel->m2Rec) - 4. * dipSel->m2Rad * dipSel->m2Rec ) / dipSel->mDip;
3417 double eRecBef = sqrt( pow2(pzRecBef) + dipSel->m2Rec);
3418 double pzRecAft = -pzRadPlusEmt;
3419 double eRecAft = sqrt( pow2(pzRecAft) + dipSel->m2Rec);
3420 MG.bst( Vec4(0., 0., pzRecBef, eRecBef), Vec4(0., 0., pzRecAft, eRecAft) );
3424 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3425 iRec =
event.copy( iGRecBef[iG], 52);
3426 iGRec.push_back( iRec);
3427 Vec4 pGRec =
event[iRec].p();
3429 event[iRec].p( pGRec);
3434 if ( (canVetoEmission && userHooksPtr->doVetoFSREmission( eventSizeOld,
3435 event, iSysSel, inResonance))
3436 || (canMergeFirst && mergingHooksPtr->doVetoEmission( event )) ) {
3437 event.popBack( event.size() - eventSizeOld);
3438 event[iRadBef].status( iRadStatusV);
3439 event[iRadBef].daughters( iRadDau1V, iRadDau2V);
3440 if (useLocalRecoilNow && isrTypeNow == 0) {
3441 event[iRecBef].status( iRecStatusV);
3442 event[iRecBef].daughters( iRecDau1V, iRecDau2V);
3443 }
else if (useLocalRecoilNow) {
3444 event[iRecBef].mothers( iRecMot1V, iRecMot2V);
3445 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( ev1Dau1V);
3446 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( ev2Dau1V);
3448 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3449 event[iGRecBef[iG]].statusPos();
3450 event[iGRecBef[iG]].daughters( 0, 0);
3458 bool vetoedEnhancedEmission =
false;
3463 bool foundEnhance =
false;
3466 for ( map<
double,pair<string,double> >::reverse_iterator
3467 it = enhanceFactors.rbegin();
3468 it != enhanceFactors.rend(); ++it ){
3469 if (splittingNameSel.find(it->second.first) != string::npos
3470 && abs(it->second.second-1.0) > 1e-9) {
3471 foundEnhance =
true;
3472 weight = it->second.second;
3473 vp = userHooksPtr->vetoProbability(splittingNameSel);
3479 if (foundEnhance && rndmPtr->flat() < vp ) vetoedEnhancedEmission =
true;
3482 if (foundEnhance && vetoedEnhancedEmission) rwgt *= (1.-1./weight)/vp;
3483 else if (foundEnhance) rwgt *= 1./((1.-vp)*weight);
3486 enhanceFactors.clear();
3489 double wtOld = userHooksPtr->getEnhancedEventWeight();
3490 if (!doTrialNow && canEnhanceEmission && !doUncertaintiesNow)
3491 userHooksPtr->setEnhancedEventWeight(wtOld*rwgt);
3492 if ( doTrialNow && canEnhanceTrial)
3493 userHooksPtr->setEnhancedTrial(sqrt(dipSel->pT2), weight);
3495 if (vetoedEnhancedEmission && canEnhanceEmission)
3496 infoPtr->addCounter(40);
3501 if (vetoedEnhancedEmission) acceptEvent =
false;
3502 if (doUncertaintiesNow) calcUncertainties( acceptEvent, pAccept, weight, vp,
3503 dipSel, &rad, &emt, &rec);
3507 if ( (vetoedEnhancedEmission && canEnhanceEmission) || !acceptEvent) {
3508 event.popBack( event.size() - eventSizeOld);
3509 event[iRadBef].status( iRadStatusV);
3510 event[iRadBef].daughters( iRadDau1V, iRadDau2V);
3511 if (useLocalRecoilNow && isrTypeNow == 0) {
3512 event[iRecBef].status( iRecStatusV);
3513 event[iRecBef].daughters( iRecDau1V, iRecDau2V);
3514 }
else if (useLocalRecoilNow) {
3515 event[iRecBef].mothers( iRecMot1V, iRecMot2V);
3516 if (iRecMot1V == beamOff1)
event[beamOff1].daughter1( ev1Dau1V);
3517 if (iRecMot1V == beamOff2)
event[beamOff2].daughter1( ev2Dau1V);
3519 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3520 event[iGRecBef[iG]].statusPos();
3521 event[iGRecBef[iG]].daughters( 0, 0);
3528 if (!useLocalRecoilNow) {
3530 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
3531 if (iGRecBef[iG] == iRecBef) iRec = iGRec[iG];
3535 if (isrTypeNow != 0) {
3536 BeamParticle& beamRec = (isrTypeNow == 1) ? *beamAPtr : *beamBPtr;
3537 double xOld = beamRec[iSysSelRec].x();
3538 double xRec = 2. * pRec.e() / (beamAPtr->e() + beamBPtr->e());
3539 beamRec[iSysSelRec].iPos( iRec);
3540 beamRec[iSysSelRec].x( xRec);
3541 partonSystemsPtr->setSHat( iSysSelRec,
3542 partonSystemsPtr->getSHat(iSysSelRec) * xRec / xOld);
3547 if ( !useLocalRecoilNow || nGlobal >= nMaxGlobalBranch) {
3549 while ( doRemove ) {
3550 bool hasRemoved =
false;
3551 for (
int iHard = 0; iHard < int(hardPartons.size()); ++iHard)
3552 if ( event[dipSel->iRadiator].isAncestor(hardPartons[iHard]) ) {
3553 hardPartons.erase( hardPartons.begin() + iHard );
3557 doRemove = hasRemoved;
3562 if ( !useLocalRecoilNow ) ++nGlobal;
3565 if (dipSel->flavour == 22) {
3566 dipSel->iRadiator = iRad;
3567 dipSel->iRecoiler = iRec;
3570 if (recoilToColoured && inResonance && event[iRec].chargeType() == 0)
3571 dipSel->iRecoiler = iEmt;
3572 dipSel->pTmax = pTsel;
3573 if (doQEDshowerByGamma) dipEnd.push_back( TimeDipoleEnd(iEmt, iRad,
3574 pTsel, 0, 0, 1, 0, 0, iSysSel, 0) );
3577 }
else if (dipSel->flavour == 21) {
3578 dipSel->iRadiator = iRad;
3579 dipSel->iRecoiler = iEmt;
3580 dipSel->systemRec = iSysSel;
3581 dipSel->isrType = 0;
3582 dipSel->pTmax = pTsel;
3584 if (!doMEafterFirst) dipSel->MEtype = 0;
3587 double flexFactor = (isFlexible) ? dipSel->flexFactor : 1.0;
3588 dipSel->isFlexible =
false;
3589 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3590 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
3591 && dipEnd[i].colType != 0) {
3592 dipEnd[i].iRadiator = iRec;
3593 dipEnd[i].iRecoiler = iEmt;
3595 if (!doMEafterFirst) dipEnd[i].MEtype = 0;
3597 if ( !isFlexible && dipEnd[i].colType * dipSel->colType > 0)
3598 dipEnd[i].iRecoiler = iRad;
3599 dipEnd[i].pTmax = pTsel;
3606 if (event[iRadBef].
id() == 21 && dipEnd[i].iRecoiler == iRadBef
3607 && dipEnd[i].weakType != 0) {
3608 double m1 = (
event[iRad].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3609 double m2 = (
event[iEmt].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3610 dipEnd[i].iRecoiler = (m1 > m2) ? iRad : iEmt;
3611 dipEnd[i].iMEpartner = dipEnd[i].iRecoiler;
3614 int colType = (dipSel->colType > 0) ? 2 : -2 ;
3618 if (recoilToColoured && inResonance && event[iRec].col() == 0
3619 &&
event[iRec].acol() == 0) iRecMod = iRad;
3620 dipEnd.push_back( TimeDipoleEnd(iEmt, iRecMod, pTsel,
3621 colType, 0, 0, 0, isrTypeSave, iSysSel, 0));
3622 dipEnd.back().systemRec = iSysSelRec;
3623 dipEnd.back().hasJunction = hasJunction;
3626 dipEnd.back().isFlexible =
true;
3627 dipEnd.back().flexFactor = flexFactor;
3629 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3630 -colType, 0, 0, 0, 0, iSysSel, 0));
3631 dipEnd.back().hasJunction = hasJunction;
3634 }
else if (dipSel->colType != 0) {
3635 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3637 if ( !isFlexible && dipEnd[i].iRecoiler == iRadBef
3638 && dipEnd[i].colType * dipSel->colType < 0 )
3639 dipEnd[i].iRecoiler = iEmt;
3640 if (dipEnd[i].iRadiator == iRadBef && abs(dipEnd[i].colType) == 2) {
3641 dipEnd[i].colType /= 2;
3642 if (dipEnd[i].system != dipEnd[i].systemRec)
continue;
3646 dipEnd[i].MEtype = (doMEcorrections && doMEafterFirst) ? 66 : 0;
3647 if (&dipEnd[i] == dipSel) dipEnd[i].iMEpartner = iRad;
3648 else dipEnd[i].iMEpartner = iEmt;
3651 if (event[iRadBef].
id() == 21 && dipEnd[i].iRecoiler == iRadBef
3652 && dipEnd[i].weakType != 0) {
3653 double m1 = (
event[iRad].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3654 double m2 = (
event[iEmt].p()+
event[dipEnd[i].iRadiator].p()).m2Calc();
3655 dipEnd[i].iRecoiler = (m1 > m2) ? iRad : iEmt;
3656 dipEnd[i].iMEpartner = dipEnd[i].iRecoiler;
3659 dipSel->iRadiator = iEmt;
3660 dipSel->iRecoiler = iRec;
3661 dipSel->pTmax = pTsel;
3666 if (doQEDshowerByQ) {
3667 int chgType =
event[iRad].chargeType();
3668 int meType = (doMEcorrections && doMEafterFirst) ? 66 : 0;
3669 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3670 0, chgType, 0, 0, 0, iSysSel, meType, iEmt));
3671 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3672 0, -chgType, 0, 0, 0, iSysSel, meType, iRad));
3677 if (doWeakShower && iSysSel == 0 &&
3678 !(hasWeaklyRadiated && singleWeakEmission)) {
3679 int weakPol = (rndmPtr->flat() > 0.5) ? -1 : 1;
3680 event[iRad].pol(weakPol);
3681 event[iEmt].pol(weakPol);
3682 if ((weakMode == 0 || weakMode == 1) && weakPol == -1) {
3683 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3684 0, 0, 0, 1, 0, iSysSel, 200, iEmt, weakPol) );
3685 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3686 0, 0, 0, 1, 0, iSysSel, 200, iRad, weakPol) );
3688 if (weakMode == 0 || weakMode == 2) {
3689 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3690 0, 0, 0, 2, 0, iSysSel, 205, iEmt, weakPol) );
3691 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3692 0, 0, 0, 2, 0, iSysSel, 205, iRad, weakPol) );
3699 }
else if (dipSel->gamType != 0) {
3700 dipSel->gamType = 0;
3701 int chgType =
event[iRad].chargeType();
3702 int colType =
event[iRad].colType();
3704 if ( chgType != 0 && ( ( doQEDshowerByQ && colType != 0 )
3705 || ( doQEDshowerByL && colType == 0 ) ) ) {
3706 int MEtype = (doMEcorrections && doMEafterFirst) ? 102 : 0;
3707 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3708 0, chgType, 0, 0, 0, iSysSel, MEtype, iEmt) );
3709 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3710 0, -chgType, 0, 0, 0, iSysSel, MEtype, iRad) );
3713 if (colType != 0 && doQCDshower) {
3714 int MEtype = (doMEcorrections && doMEafterFirst) ? 11 : 0;
3715 dipEnd.push_back( TimeDipoleEnd(iRad, iEmt, pTsel,
3716 colType, 0, 0, 0, 0, iSysSel, MEtype, iEmt) );
3717 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3718 -colType, 0, 0, 0, 0, iSysSel, MEtype, iRad) );
3722 }
else if (dipSel->flavour == 4900022) {
3723 dipSel->iRadiator = iRad;
3724 dipSel->iRecoiler = iRec;
3725 dipSel->pTmax = pTsel;
3728 }
else if (dipSel->flavour == 4900021) {
3729 dipSel->iRadiator = iRad;
3730 dipSel->iRecoiler = iEmt;
3731 dipSel->pTmax = pTsel;
3732 for (
int i = 0; i < int(dipEnd.size()); ++i)
3733 if (dipEnd[i].iRadiator == iRecBef && dipEnd[i].iRecoiler == iRadBef
3734 && dipEnd[i].isHiddenValley) {
3735 dipEnd[i].iRadiator = iRec;
3736 dipEnd[i].iRecoiler = iEmt;
3737 dipEnd[i].pTmax = pTsel;
3739 int colvType = (dipSel->colvType > 0) ? 2 : -2 ;
3740 dipEnd.push_back( TimeDipoleEnd(iEmt, iRec, pTsel,
3741 0, 0, 0, 0, isrTypeSave, iSysSel, 0, -1, 0,
false,
true, colvType) );
3742 dipEnd.back().systemRec = iSysSelRec;
3743 dipEnd.push_back( TimeDipoleEnd(iEmt, iRad, pTsel,
3744 0, 0, 0, 0, 0, iSysSel, 0, -1, 0,
false,
true, -colvType) );
3747 }
else if (dipSel->weakType != 0) {
3748 hasWeaklyRadiated =
true;
3749 if (singleWeakEmission)
3750 for (
int i = 0; i < int(dipEnd.size()); ++i) dipEnd[i].weakType = 0;
3754 if (event[iRad].
id() ==
event[iRadBef].id()) {
3755 event[iRad].tau( event[iRadBef].tau() );
3757 event[iRad].tau( event[iRad].tau0() * rndmPtr->exp() );
3759 event[iRec].tau( event[iRecBef].tau() );
3760 event[iEmt].tau( event[iEmt].tau0() * rndmPtr->exp() );
3763 for (
int i = 0; i < int(dipEnd.size()); ++i) {
3766 if (isFlexible && !dipSel->isFlexible && dipEnd[i].isFlexible) {
3767 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iEmt;
3768 if (dipEnd[i].iRadiator == iRadBef) {
3769 dipEnd[i].iRadiator = iEmt;
3770 if (dipEnd[i].colType == 1 && dipSel->flavour == 21)
3771 dipEnd[i].colType = 2;
3772 if (dipEnd[i].colType ==-1 && dipSel->flavour == 21)
3773 dipEnd[i].colType =-2;
3776 if (dipEnd[i].iRadiator == iRadBef) dipEnd[i].iRadiator = iRad;
3777 if (dipEnd[i].iRecoiler == iRadBef) dipEnd[i].iRecoiler = iRad;
3778 if (dipEnd[i].iMEpartner == iRadBef) dipEnd[i].iMEpartner = iRad;
3779 if (useLocalRecoilNow) {
3780 if (dipEnd[i].iRadiator == iRecBef) dipEnd[i].iRadiator = iRec;
3781 if (dipEnd[i].iRecoiler == iRecBef) dipEnd[i].iRecoiler = iRec;
3782 if (dipEnd[i].iMEpartner == iRecBef) dipEnd[i].iMEpartner = iRec;
3784 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG) {
3785 if (dipEnd[i].iRadiator == iGRecBef[iG])
3786 dipEnd[i].iRadiator = iGRec[iG];
3787 if (dipEnd[i].iRecoiler == iGRecBef[iG])
3788 dipEnd[i].iRecoiler = iGRec[iG];
3789 if (dipEnd[i].iMEpartner == iGRecBef[iG])
3790 dipEnd[i].iMEpartner = iGRec[iG];
3799 for (
int iJun = 0; iJun <
event.sizeJunction(); iJun++) {
3801 int nIncoming = (
event.kindJunction(iJun)-1)/2;
3805 colChk = (
event.kindJunction(iJun) % 2 == 0 )
3806 ? event[iRadBef].col() :
event[iRadBef].acol();
3808 for (
int iCol = 0; iCol < nIncoming; iCol++) {
3809 int colJun =
event.colJunction( iJun, iCol);
3811 if (colJun == colChk) {
3813 if ( event.kindJunction(iJun) % 2 == 0 ) colNew = colRad;
3814 else colNew = acolRad;
3815 event.colJunction( iJun, iCol, colNew );
3821 partonSystemsPtr->replace(iSysSel, iRadBef, iRad);
3822 partonSystemsPtr->addOut(iSysSel, iEmt);
3823 if (useLocalRecoilNow)
3824 partonSystemsPtr->replace(iSysSelRec, iRecBef, iRec);
3826 for (
int iG = 0; iG < int(iGRecBef.size()); ++iG)
3827 partonSystemsPtr->replace(iSysSel, iGRecBef[iG], iGRec[iG]);
3839 bool SimpleTimeShower::initUncertainties() {
3841 if( weightContainerPtr->weightsPS.getWeightsSize() > 1 )
3842 return(nUncertaintyVariations);
3845 uVarMuSoftCorr = flag(
"UncertaintyBands:muSoftCorr");
3846 dASmax = parm(
"UncertaintyBands:deltaAlphaSmax");
3848 varPDFplus = &weightContainerPtr->weightsPS.varPDFplus;
3849 varPDFminus = &weightContainerPtr->weightsPS.varPDFminus;
3850 varPDFmember = &weightContainerPtr->weightsPS.varPDFmember;
3853 varG2GGmuRfac.clear(); varG2GGcNS.clear();
3854 varQ2QGmuRfac.clear(); varQ2QGcNS.clear();
3855 varX2XGmuRfac.clear(); varX2XGcNS.clear();
3856 varG2QQmuRfac.clear(); varG2QQcNS.clear();
3858 vector<string> keys;
3859 keys.push_back(
"fsr:murfac");
3860 keys.push_back(
"fsr:g2gg:murfac");
3861 keys.push_back(
"fsr:q2qg:murfac");
3862 keys.push_back(
"fsr:x2xg:murfac");
3863 keys.push_back(
"fsr:g2qq:murfac");
3864 keys.push_back(
"fsr:cns");
3865 keys.push_back(
"fsr:g2gg:cns");
3866 keys.push_back(
"fsr:q2qg:cns");
3867 keys.push_back(
"fsr:x2xg:cns");
3868 keys.push_back(
"fsr:g2qq:cns");
3871 int nKeysQCD=keys.size();
3874 vector<string> uniqueVarsIn = weightContainerPtr->weightsPS.
3875 getUniqueShowerVars();
3876 size_t varSize = uniqueVarsIn.size();
3878 nUncertaintyVariations = varSize;
3881 vector<string> uniqueVars;
3884 for (
string uVarString: uniqueVarsIn) {
3885 int firstEqual = uVarString.find_first_of(
"=");
3886 string testString = uVarString.substr(0, firstEqual);
3888 if( find(keys.begin(), keys.end(), testString) != keys.end() ) {
3889 if( uniqueVars.size() == 0 ) {
3890 uniqueVars.push_back(uVarString);
3891 }
else if ( find(uniqueVars.begin(), uniqueVars.end(), uVarString)
3892 == uniqueVars.end() ) {
3893 uniqueVars.push_back(uVarString);
3898 nUncertaintyVariations = int(uniqueVars.size());
3901 if (weightContainerPtr->weightsPS.getWeightsSize() <= 1.) {
3902 for(
int iWeight = 1; iWeight <= nUncertaintyVariations; ++iWeight) {
3903 string uVarString = uniqueVars[iWeight-1];
3904 weightContainerPtr->weightsPS.bookWeight(uVarString);
3906 while (uVarString.find(
"=") != string::npos) {
3907 int firstEqual = uVarString.find_first_of(
"=");
3908 uVarString.replace(firstEqual, 1,
" ");
3910 while (uVarString.find(
" ") != string::npos)
3911 uVarString.erase( uVarString.find(
" "), 1);
3912 if (uVarString ==
"" || uVarString ==
" ")
continue;
3915 int nRecognizedQCD = 0;
3916 for (
int iWord = 0; iWord < int(keys.size()); ++iWord) {
3918 string key = toLower(keys[iWord]);
3920 if (uVarString.find(key) == string::npos)
continue;
3922 int iKey = uVarString.find(key);
3923 int iBeg = uVarString.find(
" ", iKey) + 1;
3924 int iEnd = uVarString.find(
" ", iBeg);
3925 string valueString = uVarString.substr(iBeg, iEnd - iBeg);
3926 stringstream ss(valueString);
3933 if (key ==
"fsr:murfac" || key ==
"fsr:g2gg:murfac")
3934 varG2GGmuRfac[iWeight] = value;
3935 if (key ==
"fsr:murfac" || key ==
"fsr:q2qg:murfac")
3936 varQ2QGmuRfac[iWeight] = value;
3937 if (key ==
"fsr:murfac" || key ==
"fsr:x2xg:murfac")
3938 varX2XGmuRfac[iWeight] = value;
3939 if (key ==
"fsr:murfac" || key ==
"fsr:g2qq:murfac")
3940 varG2QQmuRfac[iWeight] = value;
3941 if (key ==
"fsr:cns" || key ==
"fsr:g2gg:cns")
3942 varG2GGcNS[iWeight] = value;
3943 if (key ==
"fsr:cns" || key ==
"fsr:q2qg:cns")
3944 varQ2QGcNS[iWeight] = value;
3945 if (key ==
"fsr:cns" || key ==
"fsr:x2xg:cns")
3946 varX2XGcNS[iWeight] = value;
3947 if (key ==
"fsr:cns" || key ==
"fsr:g2qq:cns")
3948 varG2QQcNS[iWeight] = value;
3950 if (iWord < nKeysQCD) nRecognizedQCD++;
3954 if (nRecognizedQCD > 0) ++nVarQCD;
3959 return (nUncertaintyVariations > 0);
3967 void SimpleTimeShower::calcUncertainties(
bool accept,
double pAccept,
3968 double enhance,
double vp, TimeDipoleEnd* dip, Particle* radPtr,
3969 Particle* emtPtr, Particle* recPtr) {
3972 if (!doUncertainties || !doUncertaintiesNow || nUncertaintyVariations <= 0)
3977 map<int,double>* varPtr=0;
3978 map<int,double>::iterator itVar;
3980 map<int,double> dummy; dummy.clear();
3982 int numWeights = weightContainerPtr->weightsPS.getWeightsSize();
3985 vector<double> uVarFac(numWeights, 1.0);
3986 vector<bool> doVar(numWeights,
false);
3993 int idEmt = emtPtr->id();
3994 int idRad = radPtr->id();
3997 if (dip->colType != 0) {
4000 if (alphaSorder == 0) varPtr = &dummy;
4001 else if (idEmt == 21 && idRad == 21) varPtr = &varG2GGmuRfac;
4002 else if (idEmt == 21 && abs(idRad) <= uVarNflavQ)
4003 varPtr = &varQ2QGmuRfac;
4004 else if (idEmt == 21) varPtr = &varX2XGmuRfac;
4005 else if (abs(idRad) <= nGluonToQuark && abs(idEmt) <= nGluonToQuark)
4006 varPtr = &varG2QQmuRfac;
4007 else varPtr = &dummy;
4008 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4009 int iWeight = itVar->first;
4010 double valFac = itVar->second;
4011 double muR2 = renormMultFac * dip->pT2;
4012 double alphaSbaseline = alphaS.alphaS(muR2);
4014 double muR2var = max(1.1 * Lambda3flav2, pow2(valFac) * muR2);
4015 double alphaSratio = alphaS.alphaS(muR2var) / alphaSbaseline;
4017 double facCorr = 1.;
4018 if (idEmt == 21 && uVarMuSoftCorr) {
4021 if (dip->pT2 < pow2(mc)) nf = 3;
4022 else if (dip->pT2 < pow2(mb)) nf = 4;
4023 double alphaScorr = alphaS.alphaS(dip->m2Dip);
4024 double facSoft = alphaScorr * (33. - 2. * nf) / (6. * M_PI);
4025 double zeta = 1. - dip->z;
4026 if (idRad == 21) zeta = min(dip->z, 1. - dip->z);
4027 facCorr = 1. + (1. - zeta) * facSoft * log(valFac);
4030 double alphaSfac = alphaSratio * facCorr;
4033 alphaSfac = min(alphaSfac, (alphaSbaseline + dASmax) / alphaSbaseline);
4034 else if (alphaSbaseline > dASmax)
4035 alphaSfac = max(alphaSfac, (alphaSbaseline - dASmax) / alphaSbaseline);
4036 uVarFac[iWeight] *= alphaSfac;
4037 doVar[iWeight] =
true;
4041 if (dip->MEtype != 0 || dip->pT2 < pow2(cNSpTmin) ) varPtr = &dummy;
4042 else if (idEmt == 21 && idRad == 21) varPtr = &varG2GGcNS;
4043 else if (idEmt == 21 && abs(idRad) <= uVarNflavQ) varPtr = &varQ2QGcNS;
4044 else if (idEmt == 21) varPtr = &varX2XGcNS;
4045 else if (abs(idRad) <= nGluonToQuark && abs(idEmt) <= nGluonToQuark)
4046 varPtr = &varG2QQcNS;
4047 else varPtr = &dummy;
4048 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4049 int iWeight = itVar->first;
4050 double valFac = itVar->second;
4053 double Q2 = dip->m2;
4055 if (abs(idRad) >= 4 && idRad != 21) Q2 = max(1., Q2-radPtr->m2());
4056 double yQ = Q2 / dip->m2Dip;
4057 double num = yQ * valFac;
4060 if (idEmt == 21 && idRad == 21)
4061 denom = pow2(1. - z * (1.-z)) / (z*(1.-z));
4063 else if (idEmt == 21)
4064 denom = (1. + pow2(z)) / (1. - z);
4067 denom = pow2(z) + pow2(1. - z);
4069 uVarFac[iWeight] *= 1. + num / denom;
4070 doVar[iWeight] =
true;
4074 if ( dip->isrType != 0 ){
4075 if ( !varPDFplus->empty() || !varPDFminus->empty()
4076 || !varPDFmember->empty() ) {
4078 double scale2 = (useFixedFacScale) ? fixedFacScale2
4079 : factorMultFac * dip->pT2;
4080 BeamParticle& beam = (dip->isrType == 1) ? *beamAPtr : *beamBPtr;
4081 int iSysRec = dip->systemRec;
4082 double xOld = beam[iSysRec].x();
4083 double xNew = xOld * (1. + (dip->m2 - dip->m2Rad)
4084 / (dip->m2Dip - dip->m2Rad));
4085 int idRec = recPtr->id();
4086 int valSea = (beam[iSysSel].isValence()) ? 1 : 0;
4087 if( beam[iSysSel].isUnmatched() ) valSea = 2;
4088 beam.calcPDFEnvelope( make_pair(idRec,idRec),
4089 make_pair(xNew,xOld), scale2, valSea);
4090 PDF::PDFEnvelope ratioPDFEnv = beam.getPDFEnvelope( );
4092 varPtr = varPDFplus;
4093 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4094 int iWeight = itVar->first;
4095 uVarFac[iWeight] *= 1.0 + min(ratioPDFEnv.errplusPDF
4096 / ratioPDFEnv.centralPDF,0.5);
4097 doVar[iWeight] =
true;
4100 varPtr = varPDFminus;
4101 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4102 int iWeight = itVar->first;
4103 uVarFac[iWeight] *= max(.01,1.0 - min(ratioPDFEnv.errminusPDF
4104 / ratioPDFEnv.centralPDF,0.5));
4105 doVar[iWeight] =
true;
4107 varPtr = varPDFmember;
4108 for (itVar = varPtr->begin(); itVar != varPtr->end(); ++itVar) {
4109 int iWeight = itVar->first;
4110 int member = int( itVar->second );
4111 uVarFac[iWeight] *= max(.01,ratioPDFEnv.pdfMemberVars[member]
4112 / ratioPDFEnv.centralPDF);
4113 doVar[iWeight] =
true;
4122 for (
int iWeight = 1; iWeight<=nUncertaintyVariations; ++iWeight) {
4123 if (!doVar[iWeight])
continue;
4124 double pAcceptPrime = pAccept * uVarFac[iWeight];
4125 if (pAcceptPrime > PROBLIMIT && dip->colType != 0) {
4126 uVarFac[iWeight] *= PROBLIMIT / pAcceptPrime;
4131 for (
int iWeight = 0; iWeight <= nUncertaintyVariations; ++iWeight) {
4132 if (!doVar[iWeight])
continue;
4135 weightContainerPtr->weightsPS.reweightValueByIndex(iWeight,
4136 uVarFac[iWeight] / ((1.0 - vp) * enhance) );
4142 double denom = 1. - pAccept*(1.0 - vp);
4143 if (denom < REJECTFACTOR) {
4144 stringstream message;
4146 infoPtr->errorMsg(
"Warning in SimpleTimeShower: reject denom for "
4147 "iWeight = ", message.str());
4150 double reWtFail = max(0.01, (1. - uVarFac[iWeight] * pAccept / enhance)
4152 weightContainerPtr->weightsPS.reweightValueByIndex(iWeight,
4172 typedef pair < int, int > pairInt;
4173 typedef vector < pairInt > vectorPairInt;
4192 inline vectorPairInt findParentSystems(
const int sys,
4193 Event& event, PartonSystems* partonSystemsPtr,
bool forwards) {
4195 vectorPairInt parentSystems;
4196 parentSystems.reserve(10);
4201 int iInA = partonSystemsPtr->getInA(iSysCur);
4202 int iInB = partonSystemsPtr->getInB(iSysCur);
4206 if (event[iInA].isRescatteredIncoming()) iIn = iInA;
4207 if (event[iInB].isRescatteredIncoming()) iIn = -iInB;
4210 parentSystems.push_back( pairInt(-iSysCur, iIn) );
4211 if (iIn == 0)
break;
4213 int iInAbs = abs(iIn);
4214 int iMother =
event[iInAbs].mother1();
4215 iSysCur = partonSystemsPtr->getSystemOf(iMother);
4216 if (iSysCur == -1) {
4217 parentSystems.clear();
4225 vectorPairInt::reverse_iterator rit;
4226 for (rit = parentSystems.rbegin(); rit < (parentSystems.rend() - 1);
4228 pairInt &cur = *rit;
4229 pairInt &next = *(rit + 1);
4230 cur.first = -cur.first;
4231 cur.second = (next.second < 0) ? -event[abs(next.second)].mother1() :
4232 event[abs(next.second)].mother1();
4236 return parentSystems;
4247 bool SimpleTimeShower::rescatterPropagateRecoil(
Event& event, Vec4& pNew) {
4250 int iRadBef = dipSel->iRadiator;
4251 iSysSel = dipSel->system;
4252 int iSysSelRec = dipSel->systemRec;
4253 Vec4 pImbal = pNew -
event[iRadBef].p();
4257 vector < pair < int, Vec4 > > eventMod;
4258 eventMod.reserve(10);
4263 vectorPairInt systemMod;
4264 systemMod.reserve(10);
4267 vectorPairInt radParent = findParentSystems(iSysSel, event,
4268 partonSystemsPtr,
false);
4269 vectorPairInt recParent = findParentSystems(iSysSelRec, event,
4270 partonSystemsPtr,
true);
4271 if (radParent.size() == 0 || recParent.size() == 0) {
4273 infoPtr->errorMsg(
"Error in SimpleTimeShower::rescatterPropagate"
4274 "Recoil: couldn't find parent system; branching vetoed");
4278 bool foundPath =
false;
4279 unsigned int iRadP = 0;
4280 unsigned int iRecP = 0;
4281 for (iRadP = 0; iRadP < radParent.size(); iRadP++) {
4282 for (iRecP = 0; iRecP < recParent.size(); iRecP++)
4283 if (abs(radParent[iRadP].first) == abs(recParent[iRecP].first)) {
4287 if (foundPath)
break;
4292 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4293 "Recoil: couldn't find recoil path; branching vetoed");
4300 if (radParent.size() > 1)
4301 path.assign(radParent.begin(), radParent.begin() + iRadP);
4302 if (recParent.size() > 1)
4303 path.insert(path.end(), recParent.rend() - iRecP - 1,
4304 recParent.rend() - 1);
4307 for (
unsigned int i = 0; i < path.size(); i++) {
4309 bool isIncoming = (path[i].first < 0) ?
true :
false;
4310 int iSysCur = abs(path[i].first);
4311 bool isIncomingA = (path[i].second > 0) ?
true :
false;
4312 int iLink = abs(path[i].second);
4315 if (isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
4318 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
4319 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
4323 if (iMemCur == -1) {
4325 infoPtr->errorMsg(
"Error in SimpleTimeShower::rescatterPropagate"
4326 "Recoil: couldn't find parton system; branching vetoed");
4331 Vec4 pMod = (isIncoming) ? event[iLink].p() + pImbal :
4332 event[iLink].p() - pImbal;
4333 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
4334 systemMod.push_back(pairInt(iSysCur, iMemCur));
4337 int iInCurA = partonSystemsPtr->getInA(iSysCur);
4338 int iInCurB = partonSystemsPtr->getInB(iSysCur);
4339 Vec4 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
4342 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
4343 double sHatCur = pTotCur.m2Calc();
4347 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
4348 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4349 "Recoil: virtuality much larger than sHat; branching vetoed");
4355 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
4356 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4357 "Recoil: rest frame energy too negative; branching vetoed");
4362 if (sHatCur < 0.0) {
4363 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4364 "Recoil: sHat became negative; branching vetoed");
4369 iLink = (isIncoming) ? event[iLink].mother1() :
4370 event[iLink].daughter1();
4371 iSysCur = partonSystemsPtr->getSystemOf(iLink,
true);
4373 if (!isIncoming) iMemCur = (isIncomingA) ? -1 : -2;
4376 for (
int j = 0; j < partonSystemsPtr->sizeOut(iSysCur); j++)
4377 if (partonSystemsPtr->getOut(iSysCur, j) == iLink) {
4381 if (iMemCur == -1) {
4383 infoPtr->errorMsg(
"Error in SimpleTimeShower::rescatterPropagate"
4384 "Recoil: couldn't find parton system; branching vetoed");
4389 pMod = (isIncoming) ? event[iLink].p() + pImbal :
4390 event[iLink].p() - pImbal;
4391 eventMod.push_back(pair <int, Vec4> (iLink, pMod));
4392 systemMod.push_back(pairInt(iSysCur, iMemCur));
4395 iInCurA = partonSystemsPtr->getInA(iSysCur);
4396 iInCurB = partonSystemsPtr->getInB(iSysCur);
4397 pTotCur =
event[iInCurA].p() +
event[iInCurB].p();
4400 if (iMemCur < 0) pTotCur += (isIncoming) ? pImbal : -pImbal;
4401 sHatCur = pTotCur.m2Calc();
4405 if (abs(pMod.m2Calc()) > MAXVIRTUALITYFRACTION * sHatCur) {
4406 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4407 "Recoil: virtuality much larger than sHat; branching vetoed");
4413 if (!isIncoming && pMod * pTotCur < -MAXNEGENERGYFRACTION * sHatCur) {
4414 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4415 "Recoil: rest frame energy too negative; branching vetoed");
4420 if (sHatCur < 0.0) {
4421 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4422 "Recoil: sHat became negative; branching vetoed");
4427 if (VETONEGENERGY && pMod.e() < 0.0) {
4428 infoPtr->errorMsg(
"Warning in SimpleTimeShower::rescatterPropagate"
4429 "Recoil: energy became negative; branching vetoed");
4438 for (
unsigned int i = 0; i < eventMod.size(); i++) {
4439 int idx = eventMod[i].first;
4440 Vec4 &pMod = eventMod[i].second;
4441 int iSys = systemMod[i].first;
4442 int iMem = systemMod[i].second;
4445 if (event[idx].isRescatteredIncoming()) {
4446 int mother1 =
event[idx].mother1();
4447 idx =
event.copy(idx, -54);
4448 event[mother1].daughters(idx, idx);
4451 double eCM = sqrt(m2( beamAPtr->p(), beamBPtr->p()));
4453 partonSystemsPtr->setInA(iSys, idx);
4454 (*beamAPtr)[iSys].x((pMod.e() + pMod.pz()) / eCM);
4455 (*beamAPtr)[iSys].m(pMod.mCalc());
4456 (*beamAPtr)[iSys].p(pMod);
4457 (*beamAPtr)[iSys].iPos(idx);
4458 }
else if (iMem == -2) {
4459 partonSystemsPtr->setInB(iSys, idx);
4460 (*beamBPtr)[iSys].x((pMod.e() - pMod.pz()) / eCM);
4461 (*beamBPtr)[iSys].m(pMod.mCalc());
4462 (*beamBPtr)[iSys].p(pMod);
4463 (*beamBPtr)[iSys].iPos(idx);
4466 infoPtr->errorMsg(
"Error in SimpleTimeShower::rescatterPropagate"
4467 "Recoil: internal bookeeping error");
4472 int daughter1 =
event[idx].daughter1();
4473 idx =
event.copy(idx, 55);
4474 event[idx].statusNeg();
4475 event[daughter1].mothers(idx, idx);
4477 partonSystemsPtr->setOut(iSys, iMem, idx);
4480 event[idx].p( eventMod[i].second );
4481 event[idx].m( event[idx].mCalc() );
4494 void SimpleTimeShower::findMEtype(
Event& event, TimeDipoleEnd& dip) {
4497 bool setME = doMEcorrections;
4498 int iMother =
event[dip.iRadiator].mother1();
4499 int iMother2 =
event[dip.iRadiator].mother2();
4502 if (dip.isHiddenValley && event[dip.iRecoiler].id()
4503 == -
event[dip.iRadiator].id());
4506 else if (dip.weakType != 0);
4509 else if (!doMEextended) {
4510 if (iMother2 != iMother && iMother2 != 0) setME =
false;
4511 if (event[dip.iRecoiler].mother1() != iMother) setME =
false;
4512 if (event[dip.iRecoiler].mother2() != iMother2) setME =
false;
4516 if (event[dip.iRecoiler].status() < 0) setME = doMEextended;
4519 if (dip.system != dip.systemRec) setME =
false;
4528 if (dip.iMEpartner < 0) {
4529 int idAbs1 =
event[dip.iRadiator].idAbs();
4530 int idAbs2 =
event[dip.iRecoiler].idAbs();
4531 bool isRare1 = (idAbs1 > 5 && idAbs1 < 11) || (idAbs1 > 16 && idAbs1 < 21)
4533 bool isRare2 = (idAbs2 > 5 && idAbs2 < 11) || (idAbs2 > 16 && idAbs2 < 21)
4535 if (isRare1 && !isRare2) {
4536 vector<int> iSis =
event[dip.iRadiator].sisterList();
4538 for (
int iS = 0; iS < int(iSis.size()); ++iS) {
4539 idAbs2 =
event[iSis[iS]].idAbs();
4540 isRare2 = (idAbs2 > 5 && idAbs2 < 11) || (idAbs2 > 16 && idAbs2 < 21)
4542 if (idAbs2 == idAbs1) dip.iMEpartner = iSis[iS];
4543 if (isRare2 && dip.iMEpartner < 0) dip.iMEpartner = iSis[iS];
4549 if (dip.iMEpartner < 0) dip.iMEpartner = dip.iRecoiler;
4552 if (dip.MEtype != -1)
return;
4555 if (dip.colType != 0 || dip.colvType != 0) {
4556 bool isHiddenColour = (dip.colvType != 0);
4559 int idDau1 =
event[dip.iRadiator].id();
4560 int idDau2 =
event[dip.iMEpartner].id();
4561 int dau1Type = findMEparticle(idDau1, isHiddenColour);
4562 int dau2Type = findMEparticle(idDau2, isHiddenColour);
4563 int minDauType = min(dau1Type, dau2Type);
4564 int maxDauType = max(dau1Type, dau2Type);
4567 dip.MEorder = (dau2Type >= dau1Type);
4568 dip.MEsplit = (maxDauType <= 6);
4569 dip.MEgluinoRec =
false;
4572 if (minDauType == 0) dip.MEtype = 0;
4573 if (dip.MEtype >= 0)
return;
4577 if (dau1Type == 4 && dau2Type == 4)
return;
4581 if ( event[dip.iRecoiler].mother1() == iMother && iMother >= 0
4582 && (iMother2 == 0 || iMother2 == iMother) )
4583 idMother =
event[iMother].id();
4584 int motherType = (idMother != 0)
4585 ? findMEparticle(idMother, isHiddenColour) : 0;
4588 if (motherType == 0) {
4589 int col1 =
event[dip.iRadiator].col();
4590 int acol1 =
event[dip.iRadiator].acol();
4591 int col2 =
event[dip.iMEpartner].col();
4592 int acol2 =
event[dip.iMEpartner].acol();
4594 int spinT = (
event[dip.iRadiator].spinType()
4595 +
event[dip.iMEpartner].spinType() )%2;
4597 if ( col1 == acol2 && acol1 == col2 )
4598 motherType = (spinT == 0) ? 7 : 9;
4600 else if ( (col1 == acol2 && acol1 != 0 && col2 != 0)
4601 || (acol1 == col2 && col1 != 0 && acol2 != 0) )
4602 motherType = (spinT == 0) ? 4 : 5;
4604 else if ( (col1 == acol2 && acol1 != col2)
4605 || (acol1 == col2 && col1 != acol2) )
4606 motherType = (spinT == 0) ? 2 : 1;
4618 if (isHiddenColour && brokenHVsym) {
4619 MEkind = (dau2Type == 0 || dau2Type > 6) ? 30 : 31;
4620 dip.MEtype = 5 * MEkind + 1;
4626 dip.MEgluinoRec = (dau1Type >= 1 && dau1Type <= 3 && dau2Type == 5);
4629 if (minDauType == 1 && maxDauType == 1 &&
4630 (motherType == 4 || motherType == 7) ) {
4632 if (idMother == 21 || idMother == 22 || motherType == 4) MEcombi = 1;
4633 else if (idMother == 23 || idDau1 + idDau2 == 0) {
4635 dip.MEmix = gammaZmix( event, iMother, dip.iRadiator, dip.iRecoiler );
4637 else if (idMother == 24) MEcombi = 4;
4640 else if (minDauType == 1 && maxDauType == 1 && motherType == 9)
4644 else if (minDauType == 1 && maxDauType == 7 && motherType == 1) {
4646 if (idDau1 == 22 || idDau2 == 22) MEcombi = 1;
4649 }
else if (minDauType == 1 && maxDauType == 1 && motherType == 8) {
4651 if (idMother == 25 || idMother == 35 || idMother == 37) MEcombi = 1;
4652 else if (idMother == 36) MEcombi = 2;
4654 else if (minDauType == 1 && maxDauType == 8 && motherType == 1)
4658 else if (minDauType == 2 && maxDauType == 2 && (motherType == 4
4659 || motherType == 7) ) MEkind = 6;
4660 else if (minDauType == 2 && (maxDauType == 4 || maxDauType == 7)
4661 && motherType == 2) MEkind = 7;
4662 else if (minDauType == 2 && maxDauType == 2 && motherType == 8)
4664 else if (minDauType == 2 && maxDauType == 8 && motherType == 2)
4668 else if (minDauType == 1 && maxDauType == 2 && motherType == 9)
4670 else if (minDauType == 1 && maxDauType == 9 && motherType == 2)
4672 else if (minDauType == 2 && maxDauType == 9 && motherType == 1)
4676 else if (minDauType == 1 && maxDauType == 2 && motherType == 5)
4678 else if (minDauType == 1 && maxDauType == 5 && motherType == 2)
4680 else if (minDauType == 2 && maxDauType == 5 && motherType == 1)
4685 else if (minDauType == 1 && maxDauType == 9 && motherType == 3)
4688 else if (minDauType == 3 && maxDauType == 9 && motherType == 1)
4692 else if (minDauType == 5 && maxDauType == 5) MEkind = 16;
4695 dip.MEtype = 5 * MEkind + MEcombi;
4698 }
else if (dip.chgType != 0) {
4705 int idDau1 =
event[dip.iRadiator].id();
4706 int idDau2 =
event[dip.iMEpartner].id();
4707 if (abs(idDau1) < 9 && abs(idDau2) < 9 && idDau1 * idDau2 < 0) ;
4708 else if (abs(idDau1) > 10 && abs(idDau1) < 19 && abs(idDau2) > 10
4709 && abs(idDau2) < 19 && idDau1 * idDau2 < 0) ;
4710 else { dip.MEtype = 0;
return; }
4714 if (idDau1 + idDau2 == 0) dip.MEtype = 102;
4719 else if (dip.weakType == 1) {
4720 if (event[dip.iRadiator].id() == -
event[dip.iRecoiler].id()
4721 ||
event[
event[dip.iRadiator].mother1()].idAbs() == 24
4722 || infoPtr->nFinal() != 2) dip.MEtype = 200;
4723 else if (event[dip.iRadiator].idAbs() == 21
4724 ||
event[dip.iRecoiler].idAbs() == 21) dip.MEtype = 201;
4725 else if (event[dip.iRadiator].id() ==
event[dip.iRecoiler].id())
4727 else dip.MEtype = 203;
4728 }
else if (dip.weakType == 2) {
4729 if (event[dip.iRadiator].id() == -
event[dip.iRecoiler].id()
4730 ||
event[
event[dip.iRadiator].mother1()].idAbs() == 24) dip.MEtype = 205;
4731 else if (event[dip.iRadiator].idAbs() == 21
4732 ||
event[dip.iRecoiler].idAbs() == 21) dip.MEtype = 206;
4733 else if (event[dip.iRadiator].id() ==
event[dip.iRecoiler].id())
4735 else dip.MEtype = 208;
4746 int SimpleTimeShower::findMEparticle(
int id,
bool isHiddenColour) {
4750 int colType = abs(particleDataPtr->colType(
id));
4751 int spinType = particleDataPtr->spinType(
id);
4755 if (isHiddenColour) {
4757 int idAbs = abs(
id);
4758 if ( (idAbs > 4900000 && idAbs < 4900007)
4759 || (idAbs > 4900010 && idAbs < 4900017)
4760 || (idAbs > 4900100 && idAbs < 4900109) ) colType = 1;
4764 if (colType == 1 && spinType == 2) type = 1;
4765 else if (colType == 1 && spinType == 1) type = 2;
4766 else if (colType == 1) type = 3;
4767 else if (colType == 2 && spinType == 3) type = 4;
4768 else if (colType == 2 && spinType == 2) type = 5;
4769 else if (colType == 2) type = 6;
4770 else if (colType == 0 && spinType == 3) type = 7;
4771 else if (colType == 0 && spinType == 1) type = 8;
4772 else if (colType == 0 && spinType == 2) type = 9;
4783 double SimpleTimeShower::gammaZmix(
Event& event,
int iRes,
int iDau1,
4789 int iIn1 = (iRes >= 0) ? event[iRes].mother1() : -1;
4790 int iIn2 = (iRes >= 0) ? event[iRes].mother2() : -1;
4791 if (iIn1 > 0 && iIn2 <= 0 && event[iDau1].mother2() > 0)
4792 iIn2 = event[event[iDau1].mother2()].mother1();
4793 if (iIn1 >=0) idIn1 =
event[iIn1].id();
4794 if (iIn2 >=0) idIn2 =
event[iIn2].id();
4797 if (idIn1 == 21 || idIn1 == 22) idIn1 = -idIn2;
4798 if (idIn2 == 21 || idIn2 == 22) idIn2 = -idIn1;
4801 if (idIn1 + idIn2 != 0 )
return 0.5;
4802 int idInAbs = abs(idIn1);
4803 if (idInAbs == 0 || idInAbs > 18 )
return 0.5;
4804 double ei = coupSMPtr->ef(idInAbs);
4805 double vi = coupSMPtr->vf(idInAbs);
4806 double ai = coupSMPtr->af(idInAbs);
4809 if (event[iDau1].
id() + event[iDau2].
id() != 0)
return 0.5;
4810 int idOutAbs = abs(event[iDau1].
id());
4811 if (idOutAbs == 0 || idOutAbs >18 )
return 0.5;
4812 double ef = coupSMPtr->ef(idOutAbs);
4813 double vf = coupSMPtr->vf(idOutAbs);
4814 double af = coupSMPtr->af(idOutAbs);
4817 Vec4 psum =
event[iDau1].p() +
event[iDau2].p();
4818 double sH = psum.m2Calc();
4819 double intNorm = 2. * thetaWRat * sH * (sH - mZ*mZ)
4820 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
4821 double resNorm = pow2(thetaWRat * sH)
4822 / ( pow2(sH - mZ*mZ) + pow2(sH * gammaZ / mZ) );
4825 double vect = ei*ei * ef*ef + ei*vi * intNorm * ef*vf
4826 + (vi*vi + ai*ai) * resNorm * vf*vf;
4827 double axiv = (vi*vi + ai*ai) * resNorm * af*af;
4828 return vect / (vect + axiv);
4836 double SimpleTimeShower::findMEcorr(TimeDipoleEnd* dip, Particle& rad,
4837 Particle& partner, Particle& emt,
bool cutEdge) {
4842 int MEkind = dip->MEtype / 5;
4843 int MEcombi = dip->MEtype % 5;
4846 Vec4 sum = rad.p() + partner.p() + emt.p();
4847 double eCMME = sum.mCalc();
4848 double x1 = 2. * (sum * rad.p()) / pow2(eCMME);
4849 double x2 = 2. * (sum * partner.p()) / pow2(eCMME);
4850 double r1 = rad.m() / eCMME;
4851 double r2 = partner.m() / eCMME;
4855 double gammavCorr = 1.;
4856 if (dip->colvType != 0 && brokenHVsym) {
4857 r3 = emt.m() / eCMME;
4858 double x3Tmp = 2. - x1 - x2;
4859 gammavCorr = x3Tmp / (x3Tmp - kRad * (x1 + x3Tmp));
4862 double m2Pair = (rad.p() + partner.p()).m2Calc();
4863 double m2Avg = 0.5 * (rad.m2() + partner.m2())
4864 - 0.25 * pow2(rad.m2() - partner.m2()) / m2Pair;
4865 r1 = sqrt(m2Avg) / eCMME;
4867 double xShift = 0.5 * (x1 + x2) * (partner.m2() - rad.m2()) / m2Pair;
4874 double x1minus, x2minus, x3;
4876 x1minus = max(XMARGIN, 1. + r1*r1 - r2*r2 - x1);
4877 x2minus = max(XMARGIN, 1. + r2*r2 - r1*r1 - x2) ;
4878 x3 = max(XMARGIN, 2. - x1 - x2);
4880 x1minus = max(XMARGIN*XMARGIN, 1. + r1*r1 - r2*r2 - x1);
4881 x2minus = max(XMARGIN*XMARGIN, 1. + r2*r2 - r1*r1 - x2) ;
4882 x3 = max(XMARGIN*XMARGIN, 2. - x1 - x2);
4886 if (dip->colType !=0 || dip->colvType != 0) {
4889 if (dip->MEorder) wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix,
4890 x1, x2, r1, r2, r3, cutEdge);
4891 else wtME = calcMEcorr(MEkind, MEcombi, dip->MEmix,
4892 x2, x1, r2, r1, r3, cutEdge);
4895 if (dip->MEsplit) wtME = wtME * x1minus / x3;
4898 wtPS = 2. / ( x3 * x2minus );
4899 if (dip->MEgluinoRec) wtPS *= 9./4.;
4900 if (dip->colvType != 0 && brokenHVsym) wtPS *= gammavCorr;
4904 }
else if (dip->chgType !=0 && dip->MEtype == 101) {
4905 double chg1 = particleDataPtr->charge(rad.id());
4906 double chg2 = particleDataPtr->charge(partner.id());
4907 wtME = (x1*x1 + x2*x2) * pow2( chg1 * x1minus / x3
4908 - chg2 * x2minus / x3 );
4909 wtPS = 2. * ( chg1*chg1 * x1minus / x3 + chg2*chg2 * x2minus / x3 );
4912 }
else if (dip->chgType !=0 && dip->MEtype == 102) {
4913 wtME = calcMEcorr(2, 1, dip->MEmix, x1, x2, r1, r2, 0., cutEdge)
4915 wtPS = 2. / ( x3 * x2minus );
4920 else if (dip->MEtype == 200 || dip->MEtype == 205) {
4921 r3 = emt.m() / eCMME;
4922 wtME = calcMEcorr(32, 1, dip->MEmix, x1, x2, r1, r2, r3, cutEdge)
4924 wtPS = 8. / (x3 * x2minus);
4925 wtPS *= x3 / (x3 - kRad * (x1 + x3));
4928 else if (dip->MEtype == 201 || dip->MEtype == 202 || dip->MEtype == 203
4929 || dip->MEtype == 206 || dip->MEtype == 207)
return 1.;
4932 if (wtME > wtPS) infoPtr->errorMsg(
"Warning in SimpleTimeShower::"
4933 "findMEcorr: ME weight above PS one");
4971 double SimpleTimeShower::calcMEcorr(
int kind,
int combiIn,
double mixIn,
4972 double x1,
double x2,
double r1,
double r2,
double r3,
bool cutEdge) {
4975 double x3 = 2. - x1 - x2;
4976 double x1s = x1 * x1;
4977 double x2s = x2 * x2;
4978 double x3s = x3 * x3;
4979 double x1c = x1 * x1s;
4980 double x2c = x2 * x2s;
4981 double x3c = x3 * x3s;
4982 double r1s = r1 * r1;
4983 double r2s = r2 * r2;
4984 double r1c = r1 * r1s;
4985 double r2c = r2 * r2s;
4986 double r1q = r1s * r1s;
4987 double r2q = r2s * r2s;
4988 double prop1 = 1. + r1s - r2s - x1;
4989 double prop2 = 1. + r2s - r1s - x2;
4990 double prop1s = prop1 * prop1;
4991 double prop2s = prop2 * prop2;
4992 double prop12 = prop1 * prop2;
4993 double prop13 = prop1 * x3;
4994 double prop23 = prop2 * x3;
4997 double r3s = r3 * r3;
4998 double prop3 = r3s - x3;
4999 double prop3s = prop3 * prop3;
5000 if (kind == 30) prop13 = prop1 * prop3;
5004 if (x1 - 2.*r1 < XMARGIN || prop1 < XMARGIN)
return 0.;
5005 if (x2 - 2.*r2 < XMARGIN || prop2 < XMARGIN)
return 0.;
5007 if (kind != 30 && kind != 31) {
5008 if (x1 + x2 - 1. - pow2(r1+r2) < XMARGIN)
return 0.;
5012 if ( (x1s - 4.*r1s) * (x2s - 4.*r2s)
5013 - pow2( 2. * (1. - x1 - x2 + r1s + r2s) + x1*x2 )
5014 < XMARGIN * (XMARGINCOMB + r1 + r2) )
return 0.;
5019 int combi = max(1, min(4, combiIn) );
5020 double mix = max(0., min(1., mixIn) );
5021 bool isSet1 =
false;
5022 bool isSet2 =
false;
5023 bool isSet4 =
false;
5024 double ps = sqrtpos( pow2(1. - r1*r1 - r2*r2) - pow2(2. * r1 * r2) );
5025 double rLO = 0., rFO = 0., rLO1 = 0., rFO1 = 0., rLO2 = 0.,
5026 rFO2 = 0., rLO4 = 0., rFO4 = 0.;
5036 if (combi == 1 || combi == 3) {
5037 rLO1 = ps*(2.-r1s-r1q+6.*r1*r2-r2s+2.*r1s*r2s-r2q)/2.;
5038 rFO1 = -(3.+6.*r1s+r1q-6.*r1*r2+6.*r1c*r2-2.*r2s-6.*r1s*r2s
5039 +6.*r1*r2c+r2q-3.*x1+6.*r1*r2*x1+2.*r2s*x1+x1s-2.*r1s*x1s
5040 +3.*r1s*x3+6.*r1*r2*x3-r2s*x3-2.*x1*x3-5.*r1s*x1*x3
5041 +r2s*x1*x3+x1s*x3-3.*x3s-3.*r1s*x3s+r2s*x3s
5044 -2.*(-3.+r1s-6.*r1*r2+6.*r1c*r2+3.*r2s-4.*r1s*r2s
5045 +6.*r1*r2c+2.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s)
5321 if (combi == 2 || combi == 3) {
5322 rLO2 = ps*(1.-2.*r1+r1s-r2s);
5323 rFO2 = (2.*r1-x1)*(1.+r1s+r2s-x1)
5325 +2.*(-1.-r1s+2.*r1c-r2s+2.*r1*r2s+3.*x1*0.5-r1*x1
5326 -r1s*x1*0.5-r2s*x1*0.5+x2-r1*x2+r1s*x2-x1*x2*0.5)
5328 +(2.+2.*r1-6.*r1s+2.*r1c+2.*r2s+2.*r1*r2s-x1+r1s*x1
5329 -r2s*x1-3.*x2-2.*r1*x2+3.*r1s*x2-r2s*x2+x1*x2+x2s)/
5334 rLO4 = ps*(1.+r1s-r2s);
5335 rFO4 = x1*(-1.-r1s-r2s+x1)
5337 +2.*(-1.-r1s-r2s+3.*x1*0.5-r1s*x1*0.5-r2s*x1*0.5
5338 +x2+r1s*x2-x1*x2*0.5)
5340 +(2.-6.*r1s+2.*r2s-x1+r1s*x1-r2s*x1-3.*x2+3.*r1s*x2
5349 if (combi == 1 || combi == 3) {
5350 rLO1 = ps*(1.-pow2(r1+r2));
5351 rFO1 = (1.+r1s+2.*r1*r2+r2s-x1-x2)*(x1+x2)
5353 -(-1.+r1q-2.*r1*r2-2.*r1c*r2-6.*r1s*r2s-2.*r1*r2c+r2q+x1
5354 -r1s*x1+r2s*x1+x2+3.*r1s*x2+2.*r1*r2*x2-r2s*x2-x1*x2)
5356 +(-1.-2.*r1s-r1q-2.*r1*r2-2.*r1c*r2+2.*r1*r2c+r2q+x1+r1s*x1
5357 -2.*r1*r2*x1-3.*r2s*x1+2.*r1s*x2-2.*r2s*x2+x1*x2+x2s)
5361 if (combi == 2 || combi == 3) {
5362 rLO2 = ps*(1.-pow2(r1-r2));
5363 rFO2 = (1.+r1s-2.*r1*r2+r2s-x1-x2)*(x1+x2)
5365 -(-1.+r1q+2.*r1*r2+2.*r1c*r2-6.*r1s*r2s+2.*r1*r2c+r2q+x1
5366 -r1s*x1+r2s*x1+x2+3.*r1s*x2-2.*r1*r2*x2-r2s*x2-x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*(1.+r1s+r2s-x2)
5592 +8.*(-1.-r1s+2.*r1s*r2-r2s+2.*r2c+x1-r2*x1+r2s*x1
5593 +3.*x2*0.5-r1s*x2*0.5-r2*x2-r2s*x2*0.5-x1*x2*0.5)
5595 +8.*(2.+2.*r1s+2.*r2+2.*r1s*r2-6.*r2s+2.*r2c-3.*x1-r1s*x1
5596 -2.*r2*x1+3.*r2s*x1+x1s-x2-r1s*x2+r2s*x2+x1*x2)
5598 -8.*(3.+3.*r1s+r2-r1s*r2-5.*r2s+r2c-4.*x1-r1s*x1+2.*r2s*x1+x1s
5599 -2.*x2+r2*x2+r2s*x2+x1*x2)
5601 +32*(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1+2.*r2*x1+r2s*x1
5602 +x1s-3.*x2-r1s*x2+2.*r2*x2+r2s*x2+x1*x2)
5604 -8.*(-1.-r1s-r2-r1s*r2-r2s+r2c+x1-r2*x1+r2s*x1+2.*x2+r1s*x2
5611 rLO4 = ps*(1.-r1s+r2s);
5612 rFO4 = 64.*x2*(-1.-r1s-r2s+x2)
5614 +16.*(-1.-r1s-r2s+x1+r2s*x1+3.*x2*0.5-r1s*x2*0.5
5615 -r2s*x2*0.5-x1*x2*0.5)
5617 -16.*(3.+3.*r1s-5.*r2s-4.*x1-r1s*x1+2.*r2s*x1+x1s-2.*x2+r2s*x2
5620 +64.*(4.+4.*r1s-4.*r2s-5.*x1-r1s*x1+r2s*x1+x1s-3.*x2
5621 -r1s*x2+r2s*x2+x1*x2)
5623 +16.*(2.+2.*r1s-6.*r2s-3.*x1-r1s*x1+3.*r2s*x1+x1s
5624 -x2-r1s*x2+r2s*x2+x1*x2)
5626 -16.*(-1.-r1s-r2s+x1+r2s*x1+2.*x2+r1s*x2-x1*x2*0.5-x2s*0.5)
5636 if (combi == 2) offset = x3s;
5637 else if (combi == 3) offset = mix * x3s;
5638 else if (combi == 4) offset = 0.5 * x3s;
5639 rFO = ps * 4.5 * ( (x1+x2-1.+offset-r1s-r2s)/prop12
5640 - r1s/prop2s - r2s/prop1s );
5645 rLO = ps*(1.-r1s+r2s+2.*r2);
5646 rFO = ( 0.5*r3s + 2.*r1q + 0.5*r2s*r3s + r2*r3s - 2.*r1s
5647 - 0.5*r1s*r3s - 2.*r1s*r2s - 4.*r1s*r2 ) / prop2s
5648 + ( -2. + 2.*r2q + 2.*r1q + 2.*r2s*r3s - 4.*r2 + 2.*r2*r3s
5649 + 4.*r2*r2s - 4.*r1s*r2s - 4.*r1s*r2 ) /prop23
5650 + ( -2. - 0.5*r3s - 2.*r2s - 4.*r2 + 2.*r1s ) / prop2
5651 + ( -2. - r3s - 2.*r2s - r2s*r3s - 4.*r2 - 2.*r2*r3s
5652 + 2.*r1s + r1s*r3s ) / prop3s
5653 + ( -1. - r3s - r2s - 4.*r2 + r1s - x2 ) / prop3
5659 rLO = ps*(1.-4.*r1s);
5660 rFO = (r3s + 2.*r1s) * (-1. + 4.*r1s) * (1./prop1s + 1./prop2s)
5661 + (-1. + 8.*r1s - x2) / prop1
5662 + (-1. + 8.*r1s - x1) / prop2
5663 + 2. * (1. - 6.*r1s + 8.*r1q + 4.*r3s*r1s) / prop12
5671 rFO = (2. * r3s * r3s + 2. * r3s * (x1 + x2) + x1s + x2s) / prop12
5672 - r3s / prop1s - r3s / prop2s;
5678 if (combi == 2) offset = x3s;
5679 else if (combi == 3) offset = mix * x3s;
5680 else if (combi == 4) offset = 0.5 * x3s;
5681 rFO = ps * 2. * ( (x1+x2-1.+offset-r1s-r2s)/prop12
5682 - r1s/prop2s - r2s/prop1s );
5689 if (combi == 1 && isSet1) {
5692 else if (combi == 2 && isSet2) {
5695 else if (combi == 3 && isSet1 && isSet2) {
5696 rLO = mix * rLO1 + (1.-mix) * rLO2;
5697 rFO = mix * rFO1 + (1.-mix) * rFO2; }
5701 else if (combi == 4 && isSet1 && isSet2) {
5702 rLO = 0.5 * (rLO1 + rLO2);
5703 rFO = 0.5 * (rFO1 + rFO2); }
5716 double SimpleTimeShower::findMEcorrWeak(TimeDipoleEnd* dip,Vec4 rad,
5717 Vec4 rec, Vec4 emt,Vec4 p3,Vec4 p4,Vec4 radBef, Vec4 recBef) {
5720 if (dip->MEtype > 210 || dip->MEtype < 200)
return 1.;
5725 if (infoPtr->nISR() + infoPtr->nFSRinProc() == 0
5726 && infoPtr->code() > 110 && infoPtr->code() < 130
5728 double d = emt.pT2();
5729 if (rad.pT2() < d) {d = rad.pT2(); cut =
true;}
5730 if (rec.pT2() < d) {d = rec.pT2(); cut =
true;}
5733 double dij = min(rad.pT2(),emt.pT2())
5734 * pow2(RRapPhi(rad,emt)) / vetoWeakDeltaR2;
5742 if (dip->MEtype == 200 || dip->MEtype == 205 ||
5743 dip->MEtype == 201 || dip->MEtype == 206) {
5744 dij = min(rad.pT2(),rec.pT2()) * pow2(RRapPhi(rad,rec))
5752 if (dip->MEtype == 200 || dip->MEtype == 205 ||
5753 dip->MEtype == 202 || dip->MEtype == 207 ||
5754 dip->MEtype == 203 || dip->MEtype == 208) {
5755 dij = min(emt.pT2(),rec.pT2()) * pow2(RRapPhi(emt,rec))
5766 if ( dip->MEtype != 201 && dip->MEtype != 202 && dip->MEtype != 203
5767 && dip->MEtype != 206 && dip->MEtype != 207 && dip->MEtype != 208)
5771 double scaleFactor2 = (rad + rec + emt).m2Calc() / (p3 + p4).m2Calc();
5772 double scaleFactor = sqrt(scaleFactor2);
5777 RotBstMatrix rot2to2frame;
5778 rot2to2frame.bstback(p3 + p4);
5779 p3.rotbst(rot2to2frame);
5780 p4.rotbst(rot2to2frame);
5781 rad.rotbst(rot2to2frame);
5782 emt.rotbst(rot2to2frame);
5783 rec.rotbst(rot2to2frame);
5784 recBef.rotbst(rot2to2frame);
5785 radBef.rotbst(rot2to2frame);
5788 RotBstMatrix rot2to3frame;
5789 rot2to3frame.bstback(rad + emt + rec);
5790 rad.rotbst(rot2to3frame);
5791 emt.rotbst(rot2to3frame);
5792 rec.rotbst(rot2to3frame);
5793 recBef.rotbst(rot2to3frame);
5794 radBef.rotbst(rot2to3frame);
5797 double sHat = (p3 + p4).m2Calc();
5798 double tHat = (radBef - p3).m2Calc();
5799 double uHat = (recBef - p3).m2Calc();
5801 double pT2 = dip->pT2;
5802 double Q2 = pT2 / (z*(1.-z));
5805 double wt = 2. * pT2 / z * (Q2+sHat)/sHat * (1. - kRad - kEmt) / 4.;
5806 if (dip->MEtype == 201 || dip->MEtype == 206)
5807 wt *= simpleWeakShowerMEs.getMEqg2qgZ( p3, p4, rec, emt, rad)
5808 / simpleWeakShowerMEs.getMEqg2qg( sHat, tHat, uHat);
5809 else if (dip->MEtype == 202 || dip->MEtype == 207)
5810 wt *= simpleWeakShowerMEs.getMEqq2qqZ( p3, p4, emt, rec, rad)
5811 / simpleWeakShowerMEs.getMEqq2qq( sHat, tHat, uHat,
true);
5813 wt *= simpleWeakShowerMEs.getMEqq2qqZ( p3, p4, emt, rec, rad)
5814 / simpleWeakShowerMEs.getMEqq2qq( sHat, tHat, uHat,
false);
5817 wt *= abs((-emt + p3).m2Calc()) / ((emt + rad).m2Calc()
5818 + abs((-p3 + emt).m2Calc()));
5822 if (wt > 1.) infoPtr->errorMsg(
"Warning in SimpleTimeShower::"
5823 "findMEcorrWeak: weight is above unity");
5832 void SimpleTimeShower::findAsymPol(
Event& event, TimeDipoleEnd* dip) {
5837 int iRad = dip->iRadiator;
5838 if (!doPhiPolAsym || event[iRad].
id() != 21)
return;
5841 int iMother =
event[iRad].iTopCopy();
5842 int iGrandM =
event[iMother].mother1();
5846 int statusGrandM =
event[iGrandM].status();
5847 bool isHardProc = (statusGrandM == -21 || statusGrandM == -31);
5849 if (!doPhiPolAsymHard)
return;
5850 if (event[iGrandM + 1].status() != statusGrandM)
return;
5851 if (event[iGrandM].isGluon() &&
event[iGrandM + 1].isGluon());
5852 else if (event[iGrandM].isQuark() &&
event[iGrandM + 1].isQuark());
5857 if (isHardProc) dip->iAunt = dip->iRecoiler;
5858 else dip->iAunt = (
event[iGrandM].daughter1() == iMother)
5859 ? event[iGrandM].daughter2() :
event[iGrandM].daughter1();
5863 double zProd = (isHardProc) ? 0.5 : event[iRad].e()
5864 / (
event[iRad].e() +
event[dip->iAunt].e());
5865 if (event[iGrandM].isGluon()) dip->asymPol = pow2( (1. - zProd)
5866 / (1. - zProd * (1. - zProd) ) );
5867 else dip->asymPol = 2. * (1. - zProd) / (1. + pow2(1. - zProd) );
5870 if (dip->flavour == 21) dip->asymPol *= pow2( dip->z * (1. - dip->z)
5871 / (1. - dip->z * (1. - dip->z) ) );
5872 else dip->asymPol *= -2. * dip->z * ( 1. - dip->z )
5873 / (1. - 2. * dip->z * (1. - dip->z) );
5881 void SimpleTimeShower::list()
const {
5884 cout <<
"\n -------- PYTHIA SimpleTimeShower Dipole Listing -----------"
5885 <<
"------------------------------------------------------- \n \n "
5886 <<
" i rad rec pTmax col chg gam weak oni hv is"
5887 <<
"r sys sysR type MErec mix ord spl ~gR pol \n"
5888 << fixed << setprecision(3);
5891 for (
int i = 0; i < int(dipEnd.size()); ++i)
5892 cout << setw(5) << i << setw(7) << dipEnd[i].iRadiator
5893 << setw(7) << dipEnd[i].iRecoiler << setw(12) << dipEnd[i].pTmax
5894 << setw(5) << dipEnd[i].colType << setw(5) << dipEnd[i].chgType
5895 << setw(5) << dipEnd[i].gamType << setw(5) << dipEnd[i].weakType
5896 << setw(5) << dipEnd[i].isOctetOnium
5897 << setw(5) << dipEnd[i].isHiddenValley << setw(5) << dipEnd[i].isrType
5898 << setw(5) << dipEnd[i].system << setw(5) << dipEnd[i].systemRec
5899 << setw(5) << dipEnd[i].MEtype << setw(7) << dipEnd[i].iMEpartner
5900 << setw(8) << dipEnd[i].MEmix << setw(5) << dipEnd[i].MEorder
5901 << setw(5) << dipEnd[i].MEsplit << setw(5) << dipEnd[i].MEgluinoRec
5902 << setw(5) << dipEnd[i].weakPol <<
"\n";
5905 cout <<
"\n -------- End PYTHIA SimpleTimeShower Dipole Listing -------"
5906 <<
"-------------------------------------------------------" << endl;