22 #ifndef Pythia8_ColourReconnectionHooks_H
23 #define Pythia8_ColourReconnectionHooks_H
26 #include "Pythia8/Pythia.h"
33 class MBReconUserHooks :
public UserHooks {
47 MBReconUserHooks(
int modeIn = 0,
int flipIn = 0,
double dLamCutIn = 0.,
48 double fracGluonIn = 1.) : mode(modeIn), flip(flipIn), dLamCut(dLamCutIn),
49 fracGluon(fracGluonIn) { m2Ref = 1.; dLamCut = max(0., dLamCut); }
50 ~MBReconUserHooks() {}
53 virtual bool canReconnectResonanceSystems() {
return true;}
56 virtual bool doReconnectResonanceSystems(
int,
Event& event) {
59 if (mode <= 0 || mode > 2)
return true;
63 if (infoPtr->isDiffractiveA() && infoPtr->isDiffractiveB())
67 if (!setupConfig( event))
return false;
70 if ( (mode == 1 && nGlu < 2) || (mode == 2 && nGlu < 1) )
return true;
73 bool hasRec = (mode == 1) ? doReconnectSwap( event)
74 : doReconnectMove( event);
75 if (!hasRec)
return false;
78 if (flip > 0)
return doReconnectFlip( event);
90 int mode, flip, nRec, nGlu, nAllCol, nCol;
91 double dLamCut, fracGluon, m2Ref, dLamTot;
97 vector<int> iToAllCol, iAllCol;
100 map<int, int> colMap, acolMap;
103 vector<double> lambdaij;
106 double lambda12(
int i,
int j) {
107 int iAC = iToAllCol[i];
int jAC = iToAllCol[j];
108 return lambdaij[nAllCol * min( iAC, jAC) + max( iAC, jAC)];
112 double lambda123(
int i,
int j,
int k) {
113 int iAC = iToAllCol[i];
int jAC = iToAllCol[j];
int kAC = iToAllCol[k];
114 return lambdaij[nAllCol * min( iAC, jAC) + max( iAC, jAC)]
115 + lambdaij[nAllCol * min( iAC, kAC) + max( iAC, kAC)]
116 - lambdaij[nAllCol * min( jAC, kAC) + max( jAC, kAC)];
122 InfoSwapMove(
int i1in = 0,
int i2in = 0) : i1(i1in), i2(i2in) {}
123 InfoSwapMove(
int i1in,
int i2in,
int iCol1in,
int iAcol1in,
int iCol2in,
124 int iAcol2in,
int dLamIn) : i1(i1in), i2(i2in), iCol1(iCol1in),
125 iAcol1(iAcol1in), iCol2(iCol2in), iAcol2(iAcol2in), dLam(dLamIn) {}
127 int i1, i2, col1, acol1, iCol1, iAcol1, col2, acol2, iCol2, iAcol2;
132 vector<InfoSwapMove> infoSM;
138 inline bool setupConfig(
Event& event) {
142 iToAllCol.resize( event.size() );
151 for (
int i = 3; i <
event.size(); ++i)
if (event[i].isFinal()) {
152 if (event[i].
id() == 21 && rndmPtr->flat() < fracGluon)
156 if (event[i].col() > 0 || event[i].acol() > 0) {
157 iToAllCol[i] = iAllCol.size();
158 iAllCol.push_back(i);
159 if (event[i].col() > 0) colMap[
event[i].col()] = i;
160 if (event[i].acol() > 0) acolMap[
event[i].acol()] = i;
165 for (
int iJun = 0; iJun <
event.sizeJunction(); ++iJun) {
166 if (event.kindJunction(iJun) == 1) {
167 for (
int j = 0; j < 3; ++j) {
168 int jCol =
event.colJunction( iJun, j);
169 for (map<int, int>::iterator colM = colMap.begin();
170 colM != colMap.end(); ++colM)
171 if (colM->first == jCol) {
175 for (
int iG = 0; iG < int(iGlu.size()); ++iG)
176 if (event[iGlu[iG]].col() == jCol) {
177 iGlu.erase(iGlu.begin() + iG);
181 }
else if (event.kindJunction(iJun) == 2) {
182 for (
int j = 0; j < 3; ++j) {
183 int jCol =
event.colJunction( iJun, j);
184 for (map<int, int>::iterator acolM = acolMap.begin();
185 acolM != acolMap.end(); ++acolM)
186 if (acolM->first == jCol) {
187 acolMap.erase( acolM);
190 for (
int iG = 0; iG < int(iGlu.size()); ++iG)
191 if (event[iGlu[iG]].acol() == jCol) {
192 iGlu.erase(iGlu.begin() + iG);
201 nCol = colMap.size();
202 if (
int(acolMap.size()) != nCol) {
203 infoPtr->errorMsg(
"Error in MBReconUserHooks: map sizes do not match");
206 map<int, int>::iterator colM = colMap.begin();
207 map<int, int>::iterator acolM = acolMap.begin();
208 for (
int iCol = 0; iCol < nCol; ++iCol) {
209 if (colM->first != acolM->first) {
210 infoPtr->errorMsg(
"Error in MBReconUserHooks: map elements"
219 nAllCol = iAllCol.size();
220 lambdaij.resize( pow2(nAllCol) );
222 for (
int iAC = 0; iAC < nAllCol - 1; ++iAC) {
224 for (
int jAC = iAC + 1; jAC < nAllCol; ++jAC) {
226 lambdaij[nAllCol * iAC + jAC]
227 = log(1. + m2( event[i], event[j]) / m2Ref);
240 inline bool doReconnectSwap(
Event& event) {
243 for (
int iG1 = 0; iG1 < nGlu - 1; ++iG1) {
245 for (
int iG2 = iG1 + 1; iG2 < nGlu; ++iG2) {
247 InfoSwapMove tmpSM( i1, i2);
248 calcLamSwap( tmpSM, event);
249 infoSM.push_back( tmpSM);
252 int nPair = infoSM.size();
255 for (
int iSwap = 0; iSwap < nGlu; ++iSwap) {
257 double dLamMin = 1e4;
260 for (
int iPair = 0; iPair < nPair; ++iPair)
261 if (infoSM[iPair].dLam < dLamMin) {
263 dLamMin = infoSM[iPair].dLam;
267 if (dLamMin > -dLamCut)
break;
270 int i1min = infoSM[iPairMin].i1;
271 int i2min = infoSM[iPairMin].i2;
274 int col1 =
event[i1min].col();
275 int acol1 =
event[i1min].acol();
276 int col2 =
event[i2min].col();
277 int acol2 =
event[i2min].acol();
278 event[i1min].cols( col2, acol2);
279 event[i2min].cols( col1, acol1);
282 colMap[col1] = i2min;
283 acolMap[acol1] = i2min;
284 colMap[col2] = i1min;
285 acolMap[acol2] = i1min;
288 infoSM[iPairMin] = infoSM.back();
293 for (
int iPair = 0; iPair < nPair; ++iPair) {
294 InfoSwapMove& tmpSM = infoSM[iPair];
295 if ( tmpSM.i1 == i1min || tmpSM.i1 == i2min
296 || tmpSM.i2 == i1min || tmpSM.i2 == i2min
297 || tmpSM.iCol1 == i1min || tmpSM.iCol1 == i2min
298 || tmpSM.iAcol1 == i1min || tmpSM.iAcol1 == i2min
299 || tmpSM.iCol2 == i1min || tmpSM.iCol2 == i2min
300 || tmpSM.iAcol2 == i1min || tmpSM.iAcol2 == i2min)
301 calcLamSwap( tmpSM, event);
314 inline void calcLamSwap( InfoSwapMove& tmpSM,
Event& event) {
317 tmpSM.col1 =
event[tmpSM.i1].col();
318 tmpSM.acol1 =
event[tmpSM.i1].acol();
319 tmpSM.iCol1 = acolMap[tmpSM.col1];
320 tmpSM.iAcol1 = colMap[tmpSM.acol1];
321 tmpSM.col2 =
event[tmpSM.i2].col();
322 tmpSM.acol2 =
event[tmpSM.i2].acol();
323 tmpSM.iCol2 = acolMap[tmpSM.col2];
324 tmpSM.iAcol2 = colMap[tmpSM.acol2];
327 double lam1c = lambda12( tmpSM.i1, tmpSM.iCol1);
328 double lam1a = lambda12( tmpSM.i1, tmpSM.iAcol1);
329 double lam2c = lambda12( tmpSM.i2, tmpSM.iCol2);
330 double lam2a = lambda12( tmpSM.i2, tmpSM.iAcol2);
331 double lam3c = lambda12( tmpSM.i1, tmpSM.iCol2);
332 double lam3a = lambda12( tmpSM.i1, tmpSM.iAcol2);
333 double lam4c = lambda12( tmpSM.i2, tmpSM.iCol1);
334 double lam4a = lambda12( tmpSM.i2, tmpSM.iAcol1);
335 if (tmpSM.col1 == tmpSM.acol2 && tmpSM.acol1 == tmpSM.col2)
337 else if (tmpSM.col1 == tmpSM.acol2)
338 tmpSM.dLam = (lam3c + lam4a) - (lam1a + lam2c);
339 else if (tmpSM.acol1 == tmpSM.col2)
340 tmpSM.dLam = (lam3a + lam4c) - (lam1c + lam2a);
341 else tmpSM.dLam = (lam3c + lam3a + lam4c + lam4a)
342 - (lam1c + lam1a + lam2c + lam2a);
351 inline bool doReconnectMove(
Event& event) {
354 int iNow, colNow, acolNow, iColNow, iAcolNow, col2Now;
358 for (
int iG = 0; iG < nGlu; ++iG) {
362 colNow =
event[iNow].col();
363 acolNow =
event[iNow].acol();
364 iColNow = acolMap[colNow];
365 iAcolNow = colMap[acolNow];
368 lamNow = lambda123( iNow, iColNow, iAcolNow);
371 for (map<int, int>::iterator colM = colMap.begin();
372 colM != colMap.end(); ++colM) {
373 col2Now = colM->first;
376 InfoSwapMove tmpSM( iNow);
378 tmpSM.acol1 = acolNow;
379 tmpSM.iCol1 = iColNow;
380 tmpSM.iAcol1 = iAcolNow;
381 tmpSM.lamNow = lamNow;
382 tmpSM.col2 = col2Now;
383 tmpSM.iCol2 = colMap[col2Now];
384 tmpSM.iAcol2 = acolMap[col2Now];
387 tmpSM.dLam = (tmpSM.iCol2 == tmpSM.i1 || tmpSM.iAcol2 == tmpSM.i1
388 || tmpSM.iCol1 == tmpSM.iAcol1) ? 2e4
389 : lambda123( tmpSM.i1, tmpSM.iCol2, tmpSM.iAcol2) - tmpSM.lamNow;
390 infoSM.push_back( tmpSM);
393 int nPair = infoSM.size();
396 for (
int iMove = 0; iMove < nGlu; ++iMove) {
398 double dLamMin = 1e4;
401 for (
int iPair = 0; iPair < nPair; ++iPair)
402 if (infoSM[iPair].dLam < dLamMin) {
404 dLamMin = infoSM[iPair].dLam;
408 if (dLamMin > -dLamCut)
break;
413 InfoSwapMove& selSM = infoSM[iPairMin];
414 int i1Sel = selSM.i1;
415 int iCol1Sel = selSM.iCol1;
416 int iAcol1Sel = selSM.iAcol1;
417 int iCol2Sel = selSM.iCol2;
418 int iAcol2Sel = selSM.iAcol2;
419 int iCol2Mod[3] = { iAcol1Sel , i1Sel , iCol2Sel };
420 int col2Mod[3] = { selSM.col1, selSM.col2, selSM.acol1};
423 for (
int i = 0; i < 3; ++i) {
424 event[ iCol2Mod[i] ].col( col2Mod[i] );
425 colMap[ col2Mod[i] ] = iCol2Mod[i];
430 bool doUpdate =
false;
431 for (
int iPair = 0; iPair < nPair; ++iPair) {
432 InfoSwapMove& tmpSM = infoSM[iPair];
433 if (tmpSM.i1 != i1Now) {
436 if (i1Now == i1Sel || i1Now == iCol1Sel || i1Now == iAcol1Sel
437 || i1Now == iCol2Sel || i1Now == iAcol2Sel) {
438 colNow =
event[i1Now].col();
439 acolNow =
event[i1Now].acol();
440 iColNow = acolMap[colNow];
441 iAcolNow = colMap[acolNow];
442 lamNow = lambda123( i1Now, iColNow, iAcolNow);
448 tmpSM.acol1 = acolNow;
449 tmpSM.iCol1 = iColNow;
450 tmpSM.iAcol1 = iAcolNow;
451 tmpSM.lamNow = lamNow;
456 for (
int iPair = 0; iPair < nPair; ++iPair) {
457 InfoSwapMove& tmpSM = infoSM[iPair];
459 for (
int i = 0; i < 3; ++i)
if (tmpSM.col2 == col2Mod[i]) iMod = i;
460 if (iMod > -1) tmpSM.iCol2 = iCol2Mod[iMod];
461 if (tmpSM.i1 == i1Sel || tmpSM.i1 == iCol1Sel || tmpSM.i1 == iAcol1Sel
462 || tmpSM.i1 == iCol2Sel || tmpSM.i1 == iAcol2Sel || iMod > -1)
463 tmpSM.dLam = (tmpSM.iCol2 == tmpSM.i1 || tmpSM.iAcol2 == tmpSM.i1
464 || tmpSM.iCol1 == tmpSM.iAcol1) ? 2e4
465 : lambda123( tmpSM.i1, tmpSM.iCol2, tmpSM.iAcol2) - tmpSM.lamNow;
480 inline bool doReconnectFlip(
Event& event) {
483 vector<int> iTmp, iVec, iBeg, iEnd;
486 for (
int i = 3; i <
event.size(); ++i)
487 if (event[i].isFinal() &&
event[i].col() > 0 &&
event[i].acol() == 0) {
493 map<int, int>::iterator acolM = acolMap.find( event[iNow].col() );
494 bool foundEnd =
false;
495 while (acolM != acolMap.end()) {
496 iNow = acolM->second;
497 iTmp.push_back( iNow);
498 if (event[iNow].col() == 0) {
502 acolM = acolMap.find( event[iNow].col() );
506 if (foundEnd || flip == 2) {
507 iBeg.push_back( iVec.size());
508 for (
int j = 0; j < int(iTmp.size()); ++j) iVec.push_back( iTmp[j]);
509 iEnd.push_back( iVec.size());
514 if (flip == 2)
for (
int i = 3; i <
event.size(); ++i)
515 if (event[i].isFinal() &&
event[i].acol() > 0 &&
event[i].col() == 0) {
521 map<int, int>::iterator colM = colMap.find( event[iNow].acol() );
522 bool foundEnd =
false;
523 while (colM != colMap.end()) {
525 iTmp.push_back( iNow);
526 if (event[iNow].acol() == 0) {
530 colM = colMap.find( event[iNow].acol() );
535 iBeg.push_back( iVec.size());
536 for (
int j = 0; j < int(iTmp.size()); ++j) iVec.push_back( iTmp[j]);
537 iEnd.push_back( iVec.size());
543 int nSys = iBeg.size();
544 int i1c, i1a, i2c, i2a, i1cMin, i1aMin, i2cMin, i2aMin, iSMin;
545 double dLam, dLamMin;
546 vector<InfoSwapMove> flipMin;
549 for (
int iSys1 = 0; iSys1 < nSys - 1; ++iSys1)
if (iBeg[iSys1] >= 0)
550 for (
int iSys2 = iSys1 + 1; iSys2 < nSys; ++iSys2) if (iBeg[iSys2] >= 0) {
558 for (
int j1 = iBeg[iSys1]; j1 < iEnd[iSys1] - 1; ++j1)
559 for (
int j2 = iBeg[iSys2]; j2 < iEnd[iSys2] - 1; ++j2) {
564 dLam = lambda12( i1c, i2a) + lambda12( i2c, i1a)
565 - lambda12( i1c, i1a) - lambda12( i2c, i2a);
566 if (dLam < dLamMin) {
576 if (dLamMin < -dLamCut) flipMin.push_back( InfoSwapMove(
577 iSys1, iSys2, i1cMin, i1aMin, i2cMin, i2aMin, dLamMin) );
579 int flipSize = flipMin.size();
582 for (
int iFlip = 0; iFlip < min( nSys / 2, flipSize); ++iFlip) {
585 for (
int iSys12 = 0; iSys12 < flipSize; ++iSys12)
586 if (flipMin[iSys12].i1 >= 0 && flipMin[iSys12].dLam < dLamMin) {
588 dLamMin = flipMin[iSys12].dLam;
593 InfoSwapMove& flipNow = flipMin[iSMin];
594 int iS1 = flipNow.i1;
595 int iS2 = flipNow.i2;
596 event[ flipNow.iAcol1 ].acol( event[flipNow.iCol2].col() );
597 event[ flipNow.iAcol2 ].acol( event[flipNow.iCol1].col() );
599 dLamTot += flipNow.dLam;
600 for (
int iSys12 = 0; iSys12 < flipSize; ++iSys12)
601 if ( flipMin[iSys12].i1 == iS1 || flipMin[iSys12].i1 == iS2
602 || flipMin[iSys12].i2 == iS1 || flipMin[iSys12].i2 == iS2)
603 flipMin[iSys12].i1 = -1;
620 class TopReconUserHooks :
public UserHooks {
638 TopReconUserHooks(
int modeIn = 0,
double strengthIn = 1.) : mode(modeIn),
639 strength(strengthIn) { iList = 0; nList = 0; pTolerance = 0.01;
641 ~TopReconUserHooks() {}
644 virtual bool canReconnectResonanceSystems() {
return true;}
647 virtual bool doReconnectResonanceSystems(
int,
Event& event) {
650 if (mode <= 0 || mode > 5)
return true;
653 classifyFinalPartons(event);
656 if (!checkClassification(event))
return false;
659 if (iList++ < nList) {
660 listClassification();
665 bool tqrkFirst = (rndmPtr->flat() < 0.5);
666 doReconnect( tqrkFirst, event);
667 doReconnect(!tqrkFirst, event);
679 int mode, iList, nList, nRec;
680 double strength, pTolerance, m2Ref;
684 vector<int> iBqrk, iWpos, iTqrk, iBbar, iWneg, iTbar, iRest;
687 map<int, int> colMap, acolMap;
694 inline bool classifyFinalPartons(
Event& event) {
709 for (
int i = 3; i <
event.size(); ++i)
if (event[i].isFinal()) {
710 bool hasCol = (
event[i].colType() != 0);
713 bool fsrFromT =
false;
714 bool fromTqrk =
false;
715 bool fromBqrk =
false;
716 bool fromWpos =
false;
717 bool fromTbar =
false;
718 bool fromBbar =
false;
719 bool fromWneg =
false;
725 int idNow =
event[iNow].id();
728 if (abs(idNow) == 6 && (idOld == 21 || idOld == 22)) fsrFromT =
true;
731 else if (idNow == 6) fromTqrk =
true;
732 else if (idNow == 5) fromBqrk =
true;
733 else if (idNow == 24) fromWpos =
true;
734 else if (idNow == -6) fromTbar =
true;
735 else if (idNow == -5) fromBbar =
true;
736 else if (idNow == -24) fromWneg =
true;
739 iNow =
event[iNow].mother1();
741 }
while (iNow > 2 && !fsrFromT);
745 if (fromTqrk && fromWpos && hasCol) iWpos.push_back(i);
746 else if (fromTqrk && fromBqrk && hasCol) iBqrk.push_back(i);
747 else if (fromTqrk) iTqrk.push_back(i);
748 else if (fromTbar && fromWneg && hasCol) iWneg.push_back(i);
749 else if (fromTbar && fromBbar && hasCol) iBbar.push_back(i);
750 else if (fromTbar) iTbar.push_back(i);
751 else if (hasCol) iRest.push_back(i);
754 if (hasCol && (mode == 4 || mode == 5)) {
755 if (event[i].col() > 0) colMap[
event[i].col()] = i;
756 if (event[i].acol() > 0) acolMap[
event[i].acol()] = i;
769 inline bool checkClassification(
Event& event) {
774 for (
int i = 3; i <
event.size(); ++i) {
775 if(event[i].
id() == 6) iTqrkLoc = i;
776 if(event[i].
id() == -6) iTbarLoc = i;
780 Vec4 tqrkDiff =
event[iTqrkLoc].p();
781 for (
int i = 0; i < int(iBqrk.size()); ++i)
782 tqrkDiff -= event[iBqrk[i]].p();
783 for (
int i = 0; i < int(iWpos.size()); ++i)
784 tqrkDiff -= event[iWpos[i]].p();
785 for (
int i = 0; i < int(iTqrk.size()); ++i)
786 tqrkDiff -= event[iTqrk[i]].p();
789 Vec4 tbarDiff =
event[iTbarLoc].p();
790 for (
int i = 0; i < int(iBbar.size()); ++i)
791 tbarDiff -= event[iBbar[i]].p();
792 for (
int i = 0; i < int(iWneg.size()); ++i)
793 tbarDiff -= event[iWneg[i]].p();
794 for (
int i = 0; i < int(iTbar.size()); ++i)
795 tbarDiff -= event[iTbar[i]].p();
798 double totErr = abs(tqrkDiff.px()) + abs(tqrkDiff.py())
799 + abs(tqrkDiff.pz()) + abs(tqrkDiff.e()) + abs(tbarDiff.px())
800 + abs(tbarDiff.py()) + abs(tbarDiff.pz()) + abs(tqrkDiff.e());
801 if (totErr > pTolerance) {
802 infoPtr->errorMsg(
"Error in TopReconUserHooks::checkClassification");
803 cout <<
"\n Error in t/tbar daughter search: \n t difference "
804 << tqrkDiff <<
" tbar difference "<< tbarDiff;
805 listClassification();
810 return (totErr < pTolerance);
817 inline void listClassification() {
819 cout <<
"\n Final-state coloured partons classified by source: ";
820 cout <<
"\n From Bqrk:";
821 for (
int i = 0; i < int(iBqrk.size()); ++i) cout <<
" " << iBqrk[i];
822 cout <<
"\n From Wpos:";
823 for (
int i = 0; i < int(iWpos.size()); ++i) cout <<
" " << iWpos[i];
824 cout <<
"\n From Tqrk:";
825 for (
int i = 0; i < int(iTqrk.size()); ++i) cout <<
" " << iTqrk[i];
826 cout <<
"\n From Bbar:";
827 for (
int i = 0; i < int(iBbar.size()); ++i) cout <<
" " << iBbar[i];
828 cout <<
"\n From Wneg:";
829 for (
int i = 0; i < int(iWneg.size()); ++i) cout <<
" " << iWneg[i];
830 cout <<
"\n From Tbar:";
831 for (
int i = 0; i < int(iTbar.size()); ++i) cout <<
" " << iTbar[i];
832 cout <<
"\n From Rest:";
833 for (
int i = 0; i < int(iRest.size()); ++i) {
834 cout <<
" " << iRest[i];
835 if (i%20 == 19 && i + 1 !=
int(iRest.size())) cout <<
"\n ";
844 inline bool doReconnect(
bool doTqrk,
Event& event) {
849 for (
int i = 0; i < int(iBqrk.size()); ++i) iTdec.push_back(iBqrk[i]);
850 for (
int i = 0; i < int(iWpos.size()); ++i) iTdec.push_back(iWpos[i]);
852 for (
int i = 0; i < int(iBbar.size()); ++i) iTdec.push_back(iBbar[i]);
853 for (
int i = 0; i < int(iWneg.size()); ++i) iTdec.push_back(iWneg[i]);
858 for (
int i = 0; i < int(iTdec.size()); ++i) {
859 int colNow =
event[iTdec[i]].col();
860 int acolNow =
event[iTdec[i]].acol();
861 if (colNow > 0 && acolNow > 0) iGT.push_back(iTdec[i]);
863 int nGT = iGT.size();
866 if (nGT > 1)
for (
int i = 0; i < nGT; ++i) {
867 int j = min(
int(nGT * rndmPtr->flat()), nGT - 1 );
868 swap( iGT[i], iGT[j]);
873 for (
int i = 0; i < int(iRest.size()); ++i) {
874 int colNow =
event[iRest[i]].col();
875 int acolNow =
event[iRest[i]].acol();
876 if (colNow > 0 && acolNow > 0) iGR.push_back(iRest[i]);
878 int nGR = iGR.size();
879 int iR, colT, acolT, iColT, iAcolT, colR, acolR, iColR, iAcolR;
880 double mTR2, mTR2now, dLam = 0.0, lamT, lamNow, lamRec;
883 if (nGT > 0 && nGR > 0)
884 for (
int iT = 0; iT < nGT; ++iT) {
885 if (strength < rndmPtr->flat())
continue;
888 if (mode == 1) iR = min(
int(nGR * rndmPtr->flat()), nGR - 1 );
893 mTR2 = m2( event[iGT[iT]], event[iGR[iR]]);
894 for (
int ii = 1; ii < nGR; ++ii) {
895 mTR2now = m2( event[iGT[iT]], event[iGR[ii]]);
896 if (mode == 2 && mTR2now < mTR2) {iR = ii; mTR2 = mTR2now;}
897 if (mode == 3 && mTR2now > mTR2) {iR = ii; mTR2 = mTR2now;}
904 colT =
event[iGT[iT]].col();
905 acolT =
event[iGT[iT]].acol();
906 iColT = acolMap[colT];
907 iAcolT = colMap[acolT];
908 lamT = log(1. + m2( event[iGT[iT]], event[iColT]) / m2Ref)
909 + log(1. + m2( event[iGT[iT]], event[iAcolT]) / m2Ref);
910 for (
int ii = 0; ii < nGR; ++ii) {
911 colR =
event[iGR[ii]].col();
912 acolR =
event[iGR[ii]].acol();
913 iColR = acolMap[colR];
914 iAcolR = colMap[acolR];
916 + log(1. + m2( event[iGR[ii]], event[iColR]) / m2Ref)
917 + log(1. + m2( event[iGR[ii]], event[iAcolR]) / m2Ref);
918 lamRec = log(1. + m2( event[iGT[iT]], event[iColR]) / m2Ref)
919 + log(1. + m2( event[iGT[iT]], event[iAcolR]) / m2Ref)
920 + log(1. + m2( event[iGR[ii]], event[iColT]) / m2Ref)
921 + log(1. + m2( event[iGR[ii]], event[iAcolT]) / m2Ref);
922 if (lamRec - lamNow < dLam) {iR = ii; dLam = lamRec - lamNow;}
924 if (mode == 5 && dLam > 0.)
continue;
929 swapCols( iGT[iT], iGR[iR], event);
941 inline void swapCols(
int i,
int j,
Event& event) {
944 int coli =
event[i].col();
945 int acoli =
event[i].acol();
946 int colj =
event[j].col();
947 int acolj =
event[j].acol();
948 event[i].cols( colj, acolj);
949 event[j].cols( coli, acoli);
965 #endif // end Pythia8_ColourReconnectionHooks_H