9 #include "Pythia8/FragmentationSystems.h"
23 const double ColConfig::CONSTITUENTMASS = 0.325;
29 void ColConfig::init(Info* infoPtrIn, Settings& settings,
30 StringFlav* flavSelPtrIn) {
34 flavSelPtr = flavSelPtrIn;
37 mJoin = settings.parm(
"FragmentationSystems:mJoin");
40 mJoin = max( mJoin, 2. * StringRegion::MJOIN);
43 mJoinJunction = settings.parm(
"FragmentationSystems:mJoinJunction");
44 mStringMin = settings.parm(
"HadronLevel:mStringMin");
53 bool ColConfig::insert( vector<int>& iPartonIn,
Event& event) {
58 bool hasJunctionIn =
false;
59 int nJunctionLegs = 0;
60 for (
int i = 0; i < int(iPartonIn.size()); ++i) {
61 if (iPartonIn[i] < 0) {
65 pSumIn +=
event[ iPartonIn[i] ].p();
66 if (!event[ iPartonIn[i] ].isGluon())
67 mSumIn +=
event[ iPartonIn[i] ].constituentMass();
70 double massIn = pSumIn.mCalc();
71 double massExcessIn = massIn - mSumIn;
74 if (nJunctionLegs >= 5) {
75 infoPtr->errorMsg(
"Error in ColConfig::insert: "
76 "junction topology too complicated; too many junction legs");
80 else if (nJunctionLegs > 0 && nJunctionLegs <= 2) {
81 infoPtr->errorMsg(
"Error in ColConfig::insert: "
82 "junction topology inconsistent; too few junction legs");
87 if (abs(massExcessIn) >= 0.);
89 infoPtr->errorMsg(
"Error in ColConfig::insert: "
90 "not-a-number system mass");
95 bool isClosedIn = (iPartonIn[0] >= 0 &&
event[ iPartonIn[0] ].col() != 0
96 &&
event[ iPartonIn[0] ].acol() != 0 );
97 if (isClosedIn) massExcessIn -= 2. * CONSTITUENTMASS;
100 if (hasJunctionIn && joinJunction( iPartonIn, event, massExcessIn))
101 hasJunctionIn =
false;
104 bool hasJoined =
true;
105 while (hasJoined && iPartonIn.size() > 2) {
110 double mJoinMin = 2. * mJoin;
111 int nSize = iPartonIn.size();
112 int nPair = (isClosedIn) ? nSize : nSize - 1;
113 for (
int i = 0; i < nPair; ++i) {
115 if (iPartonIn[i] < 0 || iPartonIn[(i + 1)%nSize] < 0)
continue;
116 Particle& parton1 =
event[ iPartonIn[i] ];
117 Particle& parton2 =
event[ iPartonIn[(i + 1)%nSize] ];
119 if (!parton1.isParton() || !parton2.isParton())
continue;
121 pSumNow += (parton1.isGluon()) ? 0.5 * parton1.p() : parton1.p();
122 pSumNow += (parton2.isGluon()) ? 0.5 * parton2.p() : parton2.p();
123 double mJoinNow = pSumNow.mCalc();
124 if (!parton1.isGluon()) mJoinNow -= parton1.m();
125 if (!parton2.isGluon()) mJoinNow -= parton2.m();
126 if (mJoinNow < mJoinMin) { iJoinMin = i; mJoinMin = mJoinNow; }
132 if (mJoinMin < mJoin) {
133 int iJoin1 = iPartonIn[iJoinMin];
134 int iJoin2 = iPartonIn[(iJoinMin + 1)%nSize];
135 int idNew = (
event[iJoin1].isGluon()) ? event[iJoin2].
id()
136 :
event[iJoin1].id();
137 int iMoth1 = min(iJoin1, iJoin2);
138 int iMoth2 = max(iJoin1, iJoin2);
140 if (event[iMoth1].
id() == 21 && event[iMoth2].
id() != 21)
141 swap( iMoth1, iMoth2);
142 int colNew =
event[iJoin1].col();
143 int acolNew =
event[iJoin2].acol();
144 if (colNew == acolNew) {
145 colNew =
event[iJoin2].col();
146 acolNew =
event[iJoin1].acol();
148 Vec4 pNew =
event[iJoin1].p() +
event[iJoin2].p();
151 int iNew =
event.append( idNew, 73, iMoth1, iMoth2, 0, 0,
152 colNew, acolNew, pNew, pNew.mCalc() );
155 int iVtx = (
event[iJoin1].isGluon()) ? iJoin2 : iJoin1;
156 event[iNew].tau( event[iVtx].tau() );
157 if (event[iVtx].hasVertex())
event[iNew].vProd( event[iVtx].vProd() );
160 event[iJoin1].statusNeg();
161 event[iJoin2].statusNeg();
162 event[iJoin1].daughter1(iNew);
163 event[iJoin2].daughter1(iNew);
164 if (iJoinMin == nSize - 1) iPartonIn[0] = iNew;
166 iPartonIn[iJoinMin] = iNew;
167 for (
int i = iJoinMin + 1; i < nSize - 1; ++i)
168 iPartonIn[i] = iPartonIn[i + 1];
170 iPartonIn.pop_back();
178 singlets.push_back( ColSinglet(iPartonIn, pSumIn, massIn,
179 massExcessIn, hasJunctionIn, isClosedIn) );
182 int iInsert = singlets.size() - 1;
183 for (
int iSub = singlets.size() - 2; iSub >= 0; --iSub) {
184 if (massExcessIn > singlets[iSub].massExcess)
break;
185 singlets[iSub + 1] = singlets[iSub];
188 if (iInsert <
int(singlets.size()) - 1) singlets[iInsert] =
189 ColSinglet(iPartonIn, pSumIn, massIn, massExcessIn,
190 hasJunctionIn, isClosedIn);
202 bool ColConfig::joinJunction( vector<int>& iPartonIn,
Event& event,
203 double massExcessIn) {
207 double mLeg[3] = { 0., 0., 0.};
210 for (
int i = 0; i < int(iPartonIn.size()); ++ i) {
211 if (iPartonIn[i] < 0) ++leg;
213 pLeg[leg] +=
event[ iPartonIn[i] ].p();
214 mLeg[leg] =
event[ iPartonIn[i] ].m();
215 idAbsLeg[leg] =
event[ iPartonIn[i] ].idAbs();
220 double m01 = (pLeg[0] + pLeg[1]).mCalc() - mLeg[0] - mLeg[1];
221 double m02 = (pLeg[0] + pLeg[2]).mCalc() - mLeg[0] - mLeg[2];
222 double m12 = (pLeg[1] + pLeg[2]).mCalc() - mLeg[1] - mLeg[2];
225 double mMin = mJoinJunction + 1.;
228 if (m01 < mMin && idAbsLeg[0] < 9 && idAbsLeg[1] < 9) {
233 if (m02 < mMin && idAbsLeg[0] < 9 && idAbsLeg[2] < 9) {
238 if (m12 < mMin && idAbsLeg[1] < 9 && idAbsLeg[2] < 9) {
243 int legC = 3 - legA - legB;
247 if (legA == -1 || (mMin > mJoinJunction && massExcessIn > mStringMin))
251 vector<int> iLegA, iLegB, iLegC;
253 for (
int i = 0; i < int(iPartonIn.size()); ++ i) {
254 if (iPartonIn[i] < 0) ++leg;
255 else if( leg == legA) iLegA.push_back( iPartonIn[i] );
256 else if( leg == legB) iLegB.push_back( iPartonIn[i] );
257 else if( leg == legC) iLegC.push_back( iPartonIn[i] );
263 for (leg = 0; leg < 2; ++leg) {
264 vector<int>& iLegNow = (leg == 0) ? iLegA : iLegB;
265 int sizeNow = iLegNow.size();
266 for (
int i = sizeNow - 2; i >= 0; --i) {
267 int iQ = iLegNow.back();
269 int colNew = (
event[iQ].id() > 0) ? event[iG].col() : 0;
270 int acolNew = (
event[iQ].id() < 0) ? event[iG].acol() : 0;
271 Vec4 pNew =
event[iQ].p() +
event[iG].p();
272 int iNew =
event.append( event[iQ].
id(), 74, iQ, iG, 0, 0,
273 colNew, acolNew, pNew, pNew.mCalc() );
276 event[iQ].statusNeg();
277 event[iG].statusNeg();
278 event[iQ].daughter1(iNew);
279 event[iG].daughter1(iNew);
280 iLegNow.back() = iNew;
285 int iQA = iLegA.back();
286 int iQB = iLegB.back();
287 int idQA =
event[iQA].id();
288 int idQB =
event[iQB].id();
289 int idNew = flavSelPtr->makeDiquark( idQA, idQB );
291 int colNew = (idNew > 0) ? 0 : event[ iLegC[0] ].acol();
292 int acolNew = (idNew > 0) ? event[ iLegC[0] ].col() : 0;
293 Vec4 pNew = pLeg[legA] + pLeg[legB];
294 int iNew =
event.append( idNew, 74, min(iQA, iQB), max( iQA, iQB),
295 0, 0, colNew, acolNew, pNew, pNew.mCalc() );
298 event[iQA].statusNeg();
299 event[iQB].statusNeg();
300 event[iQA].daughter1(iNew);
301 event[iQB].daughter1(iNew);
303 iPartonIn.push_back( iNew);
304 for (
int i = 0; i < int(iLegC.size()) ; ++i)
305 iPartonIn.push_back( iLegC[i]);
309 for (
int i = 0; i <
event.sizeJunction(); ++i)
310 for (
int j = 0; j < 3; ++ j)
311 if ( event.colJunction(i,j) == max(colNew, acolNew) ) iJun = i;
312 if (iJun >= 0)
event.eraseJunction(iJun);
323 void ColConfig::collect(
int iSub,
Event& event,
bool skipTrivial) {
326 for (
int i = 0; i < singlets[iSub].size(); ++i) {
327 int iNow = singlets[iSub].iParton[i];
328 if (iNow > 0 && event[iNow].e() < 0.)
329 infoPtr->errorMsg(
"Warning in ColConfig::collect: "
330 "negative-energy parton encountered");
334 if (singlets[iSub].isCollected)
return;
335 singlets[iSub].isCollected =
true;
339 for (
int i = 0; i < singlets[iSub].size() - 1; ++i) {
340 int iFirst = singlets[iSub].iParton[i];
341 if (iFirst < 0)
continue;
342 int iSecond = singlets[iSub].iParton[i + 1];
343 if (iSecond < 0) iSecond = singlets[iSub].iParton[i + 2];
344 if (iSecond != iFirst + 1) { inOrder =
false;
break;}
348 if (inOrder && skipTrivial)
return;
351 for (
int i = 0; i < singlets[iSub].size(); ++i) {
352 int iOld = singlets[iSub].iParton[i];
353 if (iOld < 0)
continue;
354 int iNew =
event.copy(iOld, 71);
355 singlets[iSub].iParton[i] = iNew;
365 int ColConfig::findSinglet(
int i) {
368 for (
int iSub = 0; iSub < int(singlets.size()); ++iSub)
369 for (
int iMem = 0; iMem < singlets[iSub].size(); ++iMem)
370 if (singlets[iSub].iParton[iMem] == i)
return iSub;
380 void ColConfig::list(ostream& os)
const {
383 os <<
"\n -------- Colour Singlet Systems Listing -------------------\n";
384 for (
int iSub = 0; iSub < int(singlets.size()); ++iSub) {
387 os <<
" singlet " << iSub <<
" contains " ;
388 for (
int i = 0; i < singlets[iSub].size(); ++i)
389 os << singlets[iSub].iParton[i] <<
" ";
410 const double StringRegion::MJOIN = 0.1;
413 const double StringRegion::TINY = 1e-20;
419 void StringRegion::setUp(Vec4 p1, Vec4 p2,
bool isMassless) {
426 if (w2 < MJOIN*MJOIN) {isSetUp =
true; isEmpty =
true;
return;}
434 double m1Sq = p1 * p1;
435 double m2Sq = p2 * p2;
436 double p1p2 = p1 * p2;
437 w2 = m1Sq + 2. * p1p2 + m2Sq;
438 double rootSq = pow2(p1p2) - m1Sq * m2Sq;
441 if (w2 <= 0. || rootSq <= 0.) {
442 if (m1Sq < 0.) m1Sq = 0.;
443 p1.e( sqrt(m1Sq + p1.pAbs2()) );
444 if (m2Sq < 0.) m2Sq = 0.;
445 p2.e( sqrt(m2Sq + p2.pAbs2()) );
447 w2 = m1Sq + 2. * p1p2 + m2Sq;
448 rootSq = pow2(p1p2) - m1Sq * m2Sq;
452 if (w2 < MJOIN*MJOIN) {isSetUp =
true; isEmpty =
true;
return;}
455 double root = sqrt( max(TINY, rootSq) );
456 double k1 = 0.5 * ( (m2Sq + p1p2) / root - 1.);
457 double k2 = 0.5 * ( (m1Sq + p1p2) / root - 1.);
458 pPos = (1. + k1) * p1 - k2 * p2;
459 pNeg = (1. + k2) * p2 - k1 * p1;
464 Vec4 eDiff = pPos / pPos.e() - pNeg / pNeg.e();
465 double eDx = pow2( eDiff.px() );
466 double eDy = pow2( eDiff.py() );
467 double eDz = pow2( eDiff.pz() );
468 if (eDx < min(eDy, eDz)) {
469 eX = Vec4( 1., 0., 0., 0.);
470 eY = (eDy < eDz) ? Vec4( 0., 1., 0., 0.) : Vec4( 0., 0., 1., 0.);
471 }
else if (eDy < eDz) {
472 eX = Vec4( 0., 1., 0., 0.);
473 eY = (eDx < eDz) ? Vec4( 1., 0., 0., 0.) : Vec4( 0., 0., 1., 0.);
475 eX = Vec4( 0., 0., 1., 0.);
476 eY = (eDx < eDy) ? Vec4( 1., 0., 0., 0.) : Vec4( 0., 1., 0., 0.);
480 double pPosNeg = pPos * pNeg;
481 double kXPos = eX * pPos / pPosNeg;
482 double kXNeg = eX * pNeg / pPosNeg;
483 double kXX = 1. / sqrt( 1. + 2. * kXPos * kXNeg * pPosNeg );
484 double kYPos = eY * pPos / pPosNeg;
485 double kYNeg = eY * pNeg / pPosNeg;
486 double kYX = kXX * (kXPos * kYNeg + kXNeg * kYPos) * pPosNeg;
487 double kYY = 1. / sqrt(1. + 2. * kYPos * kYNeg * pPosNeg - pow2(kYX));
488 eX = kXX * (eX - kXNeg * pPos - kXPos * pNeg);
489 eY = kYY * (eY - kYNeg * pPos - kYPos * pNeg - kYX * eX);
501 void StringRegion::project(Vec4 pIn) {
504 xPosProj = 2. * (pIn * pNeg) / w2;
505 xNegProj = 2. * (pIn * pPos) / w2;
506 pxProj = - (pIn * eX);
507 pyProj = - (pIn * eY);
519 void StringSystem::setUp(vector<int>& iSys,
Event& event) {
522 sizePartons = iSys.size();
523 sizeStrings = sizePartons - 1;
524 sizeRegions = (sizeStrings * (sizeStrings + 1)) / 2;
525 indxReg = 2 * sizeStrings + 1;
526 iMax = sizeStrings - 1;
530 system.resize(sizeRegions);
533 for (
int i = 0; i < sizeStrings; ++i) {
534 Vec4 p1 =
event[ iSys[i] ].p();
535 if ( event[ iSys[i] ].isGluon() ) p1 *= 0.5;
536 Vec4 p2 =
event[ iSys[i+1] ].p();
537 if ( event[ iSys[i+1] ].isGluon() ) p2 *= 0.5;
538 system[ iReg(i, iMax - i) ].setUp( p1, p2,
false);