9 #include "Pythia8/VinciaFSR.h"
23 void Brancher::reset(
int iSysIn,
Event& event, vector<int> iIn) {
31 idSav.resize(iIn.size());
32 hSav.resize(iIn.size());
33 colTypeSav.resize(iIn.size());
34 colSav.resize(iIn.size());
35 acolSav.resize(iIn.size());
36 mSav.resize(iIn.size());
37 for (
unsigned int i = 0; i < iIn.size(); ++i) {
38 idSav[i] =
event[iIn[i]].id();
39 hSav[i] =
event[iIn[i]].pol();
40 colTypeSav[i] =
event[iIn[i]].colType();
41 colSav[i] =
event[iIn[i]].col();
42 acolSav[i] =
event[iIn[i]].acol();
43 mSav[i] =
event[iIn[i]].m();
44 if (mSav[i] != 0.0) nMassive += 1;
46 pSum +=
event[iIn[i]].p();
48 m2AntSav = pSum.m2Calc();
49 mAntSav = (m2AntSav >= 0) ? sqrt(m2AntSav) : -sqrt(-m2AntSav);
56 for (
unsigned int i = 0; i < iIn.size(); ++i) sAntSav -= pow2(mSav[i]);
59 if (nMassive == 2 && iIn.size() == 2)
60 kallenFacSav = sAntSav/sqrt(pow2(sAntSav) - 4*pow2(mSav[0]*mSav[1]));
70 double Brancher::getpTscale() {
72 if (invariantsSav.size() == 3) {
73 double sIK = invariantsSav[0];
74 double y12 = invariantsSav[1] / sIK;
75 double y23 = invariantsSav[2] / sIK;
76 return sIK * y12 * y23;
84 double Brancher::getXj() {
86 if (invariantsSav.size() == 3) {
87 double sIK = invariantsSav[0];
88 double y12 = invariantsSav[1] / sIK;
89 double y23 = invariantsSav[2] / sIK;
99 void Brancher::list(
string header)
const {
102 if (header !=
"none")
103 cout <<
" -------- " << std::left << setw(30) << header
104 <<
" ----------------"
105 <<
"--------------------------------------------- \n"
106 <<
" sys type mothers colTypes ID codes "
107 <<
" hels m qNewSav \n"
108 << fixed << std::right << setprecision(3);
109 cout << setw(5) << system() <<
" ";
111 if (iSav.size() == 3) type =
"FFF";
112 else if (iSav.size() >= 4) type=
"FS";
113 cout << setw(4) << type <<
" "
114 << setw(5) << i0() <<
" " << setw(5) << i1() <<
" "
115 << setw(5) << (i2() > 0 ? num2str(i2(), 5) :
" ") <<
" "
116 << setw(3) << colType0() <<
" " << setw(3) << colType1() <<
" "
117 << setw(3) << (i2() > 0 ? num2str(colType2(), 3) :
" ") <<
" "
118 << setw(9) << id0() << setw(9) << id1()
119 << setw(9) << (i2() > 0 ? num2str(id2(), 9) :
" ") <<
" "
120 << setw(2) << h0() <<
" " << setw(2) << h1() <<
" "
121 << setw(2) << (i2() > 0 ? num2str(h2(), 2) :
" ") <<
" "
122 << num2str(mAnt(), 10);
124 if (q2NewSav > 0.) cout <<
" " << num2str(sqrt(q2NewSav), 10);
125 else cout <<
" " << num2str(0.0, 10);
127 else cout <<
" " << setw(10) <<
"-";
136 void Brancher::setidPost() {
138 idPostSav.push_back(id0());
139 idPostSav.push_back(21);
140 idPostSav.push_back(id1());
143 vector<double> Brancher::setmPostVec() {
145 mPostSav.push_back(mSav[0]);
146 mPostSav.push_back(0.0);
147 mPostSav.push_back(mSav[1]);
151 void Brancher::setStatPost() {
152 statPostSav.resize(iSav.size() + 1, 51);}
154 void Brancher::setMaps(
int){
155 mothers2daughters.clear(); daughters2mothers.clear();}
161 int Brancher::iNew(){
164 if(mothers2daughters.find(i0()) != mothers2daughters.end())
165 return mothers2daughters[i0()].second;
181 void BrancherEmitFF::init() {
184 if (colType0() == 2 && colType1() == 2) iAntSav = iGGemitFF;
185 else if (colType1() == 2) iAntSav = iQGemitFF;
186 else if (colType0() == 2) iAntSav = iGQemitFF;
187 else iAntSav = iQQemitFF;
195 double BrancherEmitFF::genQ2(
int evTypeIn,
double q2BegIn, Rndm* rndmPtr,
196 const EvolutionWindow* evWindowIn,
double colFacIn,
197 vector<double> headroomIn, vector<double> enhanceIn,
202 evTypeSav = evTypeIn;
203 evWindowSav = evWindowIn;
204 colFacSav = colFacIn;
206 headroomSav = (headroomIn.size() >=1) ? headroomIn[0] : 1.0 ;
207 enhanceSav = (enhanceIn.size() >=1) ? enhanceIn[0] : 1.0 ;
211 double normFac = colFacSav * kallenFac() * headroomSav * enhanceSav;
213 if (evTypeSav == 1) {
215 if (evWindowSav->runMode <= 0) {
216 double coeff = normFac * evWindowSav->alphaSmax / 4. / M_PI;
217 double lnR = log(rndmPtr->flat());
218 double xT1 = q2BegSav / sAnt();
219 double ln2xT2 = pow2(log(xT1)) - lnR / coeff;
220 double xT2 = exp(-sqrt(ln2xT2));
221 q2NewSav = xT2 * sAnt();
225 double q2Min = pow2(evWindowSav->qMin);
226 double d = sqrt(1 - 4 * q2Min/sAnt());
227 double deltaY = log( (1.+d)/(1.-d) );
228 double coeff = normFac * deltaY / 2. / M_PI;
229 double b0 = evWindowSav->b0;
230 double powR = pow(rndmPtr->flat(),b0/coeff);
231 double facLam = evWindowSav->lambda2 / evWindowSav->kMu2;
232 q2NewSav = facLam * pow(q2BegSav/facLam,powR);
235 if (q2NewSav > q2BegIn) {
236 string errorMsg =
"Error in "+__METHOD_NAME__
237 +
": Generated q2New > q2BegIn."+
" Returning 0.";
238 cout<<errorMsg<<endl;
249 bool BrancherEmitFF::genInvariants(vector<double>& invariants,
254 if (q2NewSav <= 0.)
return false;
257 if (evTypeSav == 1) {
258 double xT = q2NewSav / sAnt();
259 if (xT > 0.25)
return false;
261 double yMinTrial, yMaxTrial;
262 if (evWindowSav->runMode <= 0) {
263 yMinTrial = log(xT)/2.;
264 yMaxTrial = -yMinTrial;
268 double q2MinNow = pow2(evWindowSav->qMin);
269 double xTMinNow = q2MinNow/sAnt();
270 double dTrial = sqrt(1. - 4*xTMinNow);
271 yMaxTrial = 0.5 * log( (1.+dTrial)/(1.-dTrial ) );
272 yMinTrial = -yMaxTrial;
274 double yTrial = yMinTrial + rndmPtr->flat()*(yMaxTrial - yMinTrial);
275 double dPhys = sqrt(1. - 4*xT);
276 double yMaxPhys = 0.5 * log((1. + dPhys)/(1. - dPhys));
277 double yMinPhys = -yMaxPhys;
278 if (yTrial < yMinPhys || yTrial > yMaxPhys)
return false;
279 double r = exp(yTrial);
280 double rootXT = sqrt(xT);
281 double yij = rootXT / r;
282 double yjk = rootXT * r;
283 double yik = 1.0 - yij - yjk;
284 if (yij < 0. || yjk < 0. || yik < 0.) {
285 cout <<
" Problem in genInvariants yij = " << yij <<
" yjk = "
289 double sij = sAnt() * yij;
290 double sjk = sAnt() * yjk;
291 double sik = sAnt() * yik;
294 invariants.push_back(sAnt());
295 invariants.push_back(sij);
296 invariants.push_back(sjk);
297 invariants.push_back(sik);
300 invariantsSav = invariants;
304 double det = gramDet(sij,sjk,sik,mPostSav[0],mPostSav[1],mPostSav[2]);
305 if (det > 0.)
return true;
316 double BrancherEmitFF::pAccept(
const double antPhys,
int) {
319 if (invariantsSav.size() <= 2)
return 0.;
320 double antTrial = headroomSav
321 *2.*invariantsSav[0]/invariantsSav[1]/invariantsSav[2];
323 if (evTypeSav == 1) {
325 if (evWindowSav->runMode <= 0)
326 antTrial *= colFacSav * evWindowSav->alphaSmax;
329 double b0 = evWindowSav->b0;
330 double facLam = evWindowSav->lambda2/evWindowSav->kMu2;
331 double lnx = log(q2NewSav/facLam);
332 double alphaTrial = 1./b0/lnx;
333 antTrial *= colFacSav * alphaTrial;
336 return antPhys/antTrial;
344 double BrancherEmitFF::getQ2Max(
int evType) {
346 if (evType == 1)
return sAntSav/4.;
347 else if (evType == 2)
return sAntSav/9.;
348 else if (evType == 3)
return sAntSav/2.;
357 void BrancherEmitFF::setMaps(
int sizeOld) {
359 mothers2daughters.clear();
360 daughters2mothers.clear();
363 mothers2daughters[i0()] = make_pair(sizeOld, sizeOld + 1);
364 mothers2daughters[i1()] = make_pair(sizeOld + 1, sizeOld + 2);
367 daughters2mothers[sizeOld] = make_pair(i0(), 0);
368 daughters2mothers[sizeOld+1] = make_pair(i0(), i1());
369 daughters2mothers[sizeOld+2] = make_pair(i1(), 0);
377 bool BrancherEmitFF::getNewParticles(
Event& event, vector<Vec4> momIn,
378 vector<int> hIn, vector<Particle> &pNew, Rndm* rndmPtr, Colour* colourPtr) {
381 unsigned int nPost = iSav.size() + 1;
386 double scaleNew = sqrt(q2NewSav);
387 setMaps(event.size());
390 if (momIn.size() != nPost || hIn.size() != nPost ||
391 mPostSav.size() != nPost || idPostSav.size() != nPost ||
392 statPostSav.size() != nPost || invariantsSav.size() < 3)
return false;
395 double sij = invariantsSav[1];
396 double sjk = invariantsSav[2];
397 bool inh01 = colourPtr->inherit01(sij,sjk);
398 int lastTag =
event.lastColTag();
399 vector<int> col(nPost, 0);
400 vector<int> acol(nPost, 0);
401 acol[0] =
event[i0()].acol();
402 col[0] =
event[i0()].col();
403 acol[2] =
event[i1()].acol();
404 col[2] =
event[i1()].col();
407 int colNew = lastTag + 1 + rndmPtr->flat()*10;
410 while (colNew%10 == col[2]%10 || colNew%10 == 0)
411 colNew = lastTag + 1 + rndmPtr->flat()*10;
417 while (colNew%10 == acol[0]%10 || colNew%10 == 0)
418 colNew = lastTag + 1 + rndmPtr->flat()*10;
425 for (
unsigned int ipart = 0; ipart < nPost; ++ipart) {
426 pNew[ipart].status(statPostSav[ipart]);
427 pNew[ipart].id(idPostSav[ipart]);
428 pNew[ipart].pol(hIn[ipart]);
429 pNew[ipart].p(momIn[ipart]);
430 pNew[ipart].m(mPostSav[ipart]);
431 pNew[ipart].setEvtPtr(&event);
432 pNew[ipart].scale(scaleNew);
433 pNew[ipart].daughters(0,0);
434 pNew[ipart].col(col[ipart]);
435 pNew[ipart].acol(acol[ipart]);
450 void BrancherSplitFF::init() {
451 branchType = 2; iAntSav = iGXsplitFF; swapped =
false;}
457 double BrancherSplitFF::genQ2(
int evTypeIn,
double q2BegIn,
458 Rndm* rndmPtr,
const EvolutionWindow* evWindowIn,
459 double, vector<double> headroomFlav,
460 vector<double> enhanceFlav,
int verboseIn) {
464 evTypeSav = evTypeIn;
466 evWindowSav = evWindowIn;
470 vector<double> wtFlav;
471 unsigned int nFlav = headroomFlav.size();
472 if (nFlav != enhanceFlav.size()) {
473 if (verboseIn >=normal) {
474 string errorMsg =
"Error in "+__METHOD_NAME__
475 +
": inconsistent size of headroom and enhancement vectors.";
476 cout<<errorMsg<<endl;
482 for (
unsigned int iFlav = 0; iFlav < nFlav; ++iFlav) {
483 double mFlav = evWindowSav->mass.at(iFlav+1);
484 if (mAnt() - m0() - m1() < 2.*mFlav) {
485 wtFlav.push_back(0.);
continue;
487 double wt = headroomFlav[iFlav] * enhanceFlav[iFlav];
488 wtFlav.push_back(wt);
496 double normFac = kallenFac() * wtSum;
498 if (evTypeSav == 1) {
499 double deltaZeta = 1.0;
500 double coeff = normFac * deltaZeta / 8. / M_PI;
501 double xT1 = q2BegSav / sAnt();
503 if (evWindowSav->runMode <= 0) {
504 double aStrial = evWindowSav->alphaSmax;
505 double xT2 = xT1 * pow(rndmPtr->flat(), 1./aStrial/coeff);
506 q2NewSav = xT2 * sAnt();
510 double b0 = evWindowSav->b0;
511 double facLam = evWindowSav->lambda2/evWindowSav->kMu2;
512 double powR = pow(rndmPtr->flat(),b0/coeff);
513 q2NewSav = facLam * pow(q2BegSav/facLam,powR);
518 double ranFlav = rndmPtr->flat() * wtSum;
519 for (
int iFlav = nFlav - 1; iFlav >= 0; --iFlav) {
520 ranFlav -= wtFlav[iFlav];
524 mFlavSav = evWindowSav->mass.at(idFlavSav);
526 enhanceSav = enhanceFlav[iFlav];
527 headroomSav = headroomFlav[iFlav];
531 if (q2NewSav > q2BegIn) {
532 string errorMsg =
"Error in "+__METHOD_NAME__
533 +
": Generated q2New > q2Beg."+
" Returning 0.";
534 cout<<errorMsg<<endl;
546 bool BrancherSplitFF::genInvariants(vector<double>& invariants,
547 Rndm* rndmPtr,
int) {
551 if (q2NewSav <= 0.)
return false;
554 double m2j = pow2(mFlavSav);
555 if (evTypeSav == 1) {
557 double zetaTrial = rndmPtr->flat();
558 double m2qq = q2NewSav / zetaTrial;
559 double sij = m2qq - 2*m2j;
560 if (sij < 0.)
return false;
568 sjk = sAnt()*zetaTrial - m2j;
569 sik = sAnt() - m2qq - sjk;
573 sik = sAnt()*zetaTrial - m2j;
574 sjk = sAnt() - m2qq - sik;
576 if (sjk < 0.)
return false;
579 invariants.push_back(sAnt());
580 invariants.push_back(sij);
581 invariants.push_back(sjk);
582 invariants.push_back(sik);
585 invariantsSav = invariants;
589 double det = gramDet(sij,sjk,sik,mPostSav[0],mPostSav[1],mPostSav[2]);
590 if (det > 0.)
return true;
603 double BrancherSplitFF::pAccept(
const double antPhys,
int) {
606 if (invariantsSav.size() <= 2)
return 0.;
607 double antTrial = headroomSav/(2.*(invariantsSav[1] + 2*pow2(mFlavSav)));
610 if (evTypeSav == 1) {
611 double alphaTrial = evWindowSav->alphaSmax;
612 if (evWindowSav->runMode >= 1) {
613 double b0 = evWindowSav->b0;
614 double facLam = evWindowSav->lambda2/evWindowSav->kMu2;
615 double lnx = log(q2NewSav/facLam);
616 alphaTrial = 1./b0/lnx;
618 antTrial *= alphaTrial;
620 return antPhys/antTrial;
628 double BrancherSplitFF::getQ2Max(
int evType) {
630 if (evType == 1)
return sAntSav/4.;
631 else if (evType == 2)
return sAntSav;
632 else if (evType == 3)
return sAntSav;
637 vector<double> BrancherSplitFF::setmPostVec() {
640 mPostSav.push_back(mFlavSav);
641 mPostSav.push_back(mFlavSav);
642 mPostSav.push_back(mSav[1]);
647 void BrancherSplitFF::setidPost() {
650 idPostSav.push_back(idFlavSav);
651 idPostSav.push_back(-idFlavSav);
652 idPostSav.push_back(id1());
656 void BrancherSplitFF::setStatPost() {
658 statPostSav.resize(iSav.size() + 1, 51);
663 void BrancherSplitFF::setMaps(
int sizeOld) {
666 mothers2daughters.clear();
667 daughters2mothers.clear();
668 mothers2daughters[i0()] = make_pair(sizeOld, sizeOld+1);
669 mothers2daughters[i1()] = make_pair(sizeOld+2,sizeOld+2);
672 daughters2mothers[sizeOld] = make_pair(i0(),0);
673 daughters2mothers[sizeOld+1] = make_pair(i0(),0);
674 daughters2mothers[sizeOld+2] = make_pair(i1(),i1());
682 bool BrancherSplitFF::getNewParticles(
Event& event, vector<Vec4> momIn,
683 vector<int> hIn, vector<Particle> &pNew, Rndm*, Colour*) {
686 unsigned int nPost = iSav.size() + 1;
691 double scaleNew = sqrt(q2NewSav);
692 setMaps(event.size());
695 if (momIn.size()!=nPost || hIn.size()!=nPost ||
696 mPostSav.size() !=nPost || idPostSav.size() != nPost ||
697 statPostSav.size() != nPost || invariantsSav.size() < 3)
return false;
698 vector<int> col(nPost,0);
699 vector<int> acol(nPost,0);
701 col[0] =
event[i0()].col();
702 acol[1] =
event[i0()].acol();
704 acol[2] =
event[i1()].acol();
705 col[2] =
event[i1()].col();
708 for (
unsigned int ipart = 0; ipart < nPost; ++ipart) {
709 pNew[ipart].status(statPostSav[ipart]);
710 pNew[ipart].id(idPostSav[ipart]);
711 pNew[ipart].pol(hIn[ipart]);
712 pNew[ipart].p(momIn[ipart]);
713 pNew[ipart].m(mPostSav[ipart]);
714 pNew[ipart].setEvtPtr(&event);
715 pNew[ipart].scale(scaleNew);
716 pNew[ipart].daughters(0,0);
717 pNew[ipart].col(col[ipart]);
718 pNew[ipart].acol(acol[ipart]);
735 void BrancherEmitRF::init(
Event& event, vector<int> allIn,
736 unsigned int posResIn,
unsigned int posFIn,
double Q2cut) {
741 int iRes = allIn.at(posRes);
742 int iFinal = allIn.at(posFinal);
743 colFlowRtoF =
event[iRes].col() ==
event[iFinal].col() &&
event[iRes].col()
747 Vec4 recoilVec(0., 0., 0., 0.);
748 for (vector<int>::iterator pos = allIn.begin(); pos != allIn.end(); ++pos) {
749 if ((*pos == iRes) || (*pos == iFinal))
continue;
750 recoilVec +=
event[*pos].p();
755 Vec4 resVec = recoilVec +
event[iFinal].p();
758 mRes = resVec.mCalc();
759 mFinal =
event[iFinal].mCalc();
760 mRecoilers = recoilVec.mCalc();
761 sAK = getsAK(mRes, mFinal, mRecoilers);
764 kallenFacSav = (2.0*sAK/(4.0*M_PI));
765 kallenFacSav /= sqrt(KallenFunction(mRes*mRes, mFinal*mFinal,
766 mRecoilers*mRecoilers));
769 zetaMin= zetaMinCalc(mRes, mFinal, mRecoilers, Q2cut);
770 zetaMax = zetaMaxCalc(mRes, mFinal, mRecoilers);
772 if (zetaMax < zetaMin) zetaIntSave = 0.;
774 else zetaIntSave = zetaIntegral(zetaMin, zetaMax);
777 Q2MaxSav = calcQ2Max(mRes, mRecoilers, mFinal);
781 if (abs(colTypeSav[posRes]) == 1) {
783 if (abs(colTypeSav[posFinal]) == 1) {
787 }
else if (colTypeSav[posFinal] == 2) {
789 swapped = posRes != 0;
807 vector<double> BrancherEmitRF::setmPostVec() {
809 mPostSav.push_back(mRes);
810 mPostSav.push_back(0.0);
811 mPostSav.push_back(mFinal);
812 mPostSav.push_back(mRecoilers);
816 void BrancherEmitRF::setidPost() {
820 idPostSav.insert(idPostSav.begin() + 1, 21);
823 void BrancherEmitRF::setStatPost() {
824 statPostSav.resize(iSav.size() + 1, 52);
825 statPostSav[posFinal] = 51;
826 statPostSav[posFinal+1] = 51;
829 int BrancherEmitRF::iNew() {
830 if (posFinal > 0 && iSav[posFinal] > 0
831 && mothers2daughters.find(iSav[posFinal]) != mothers2daughters.end())
832 return mothers2daughters[iSav[posFinal]].second;
836 void BrancherEmitRF::setMaps(
int sizeOld) {
837 mothers2daughters.clear();
838 daughters2mothers.clear();
843 mothers2daughters[iSav[posFinal]] = make_pair(sizeOld, sizeOld + 1);
844 daughters2mothers[sizeOld] = make_pair(iSav[posFinal], 0);
845 daughters2mothers[sizeOld+1] = make_pair(iSav[posFinal], 0);
848 int iInsert = sizeOld + 2;
849 unsigned int posNewEmit = 1;
850 for (
unsigned int pos = 0; pos < iSav.size(); pos++) {
851 if (pos >= posNewEmit) posNewtoOld[pos + 1] = pos;
852 else posNewtoOld[pos] = pos;
853 if (pos == posRes || pos == posFinal)
continue;
855 mothers2daughters[iSav[pos]] = make_pair(iInsert, iInsert);
856 daughters2mothers[iInsert] = make_pair(iSav[pos], iSav[pos]);
866 bool BrancherEmitRF::getNewParticles(
Event& event, vector<Vec4> momIn,
867 vector<int> hIn, vector<Particle> &pNew, Rndm* rndmPtr, Colour*) {
870 unsigned int nPost = iSav.size() + 1;
874 double scaleNew = sqrt(q2NewSav);
875 setMaps(event.size());
878 if(momIn.size() != nPost || hIn.size() != nPost ||
879 idPostSav.size() != nPost || statPostSav.size() != nPost)
return false;
882 int lastTag =
event.lastColTag();
885 if (colFlowRtoF) resTag =
event[iSav[posRes]].col();
886 else resTag =
event[iSav[posRes]].acol();
888 while (newTag%10 == resTag%10 || newTag%10 == 0)
889 newTag = lastTag + 1 + rndmPtr->flat()*10;
892 for (
unsigned int ipart = 0; ipart < nPost; ++ipart) {
896 if (posNewtoOld.find(ipart) == posNewtoOld.end()) {
898 if (colFlowRtoF) newPart.cols(resTag, newTag);
899 else newPart.cols(newTag, resTag);
901 }
else if (posNewtoOld[ipart] == posRes)
continue;
903 newPart.m(mSav[posNewtoOld[ipart]]);
904 int colNow =
event[iSav[posNewtoOld[ipart]]].col();
905 int acolNow =
event[iSav[posNewtoOld[ipart]]].acol();
906 if (posNewtoOld[ipart] == posFinal) {
907 if (colFlowRtoF) colNow = newTag;
908 else acolNow = newTag;
910 newPart.cols(colNow,acolNow);
914 newPart.status(statPostSav[ipart]);
915 newPart.id(idPostSav[ipart]);
916 newPart.pol(hIn[ipart]);
917 newPart.p(momIn[ipart]);
918 newPart.setEvtPtr(&event);
919 newPart.scale(scaleNew);
920 newPart.daughters(0,0);
921 if (abs(newPart.m() - newPart.mCalc()) > 0.001)
return false;
922 pNew.push_back(newPart);
933 double BrancherEmitRF::genQ2(
int evTypeIn,
double Q2MaxNow, Rndm* rndmPtr,
934 const EvolutionWindow* evWindowPtrIn,
double colFac,
935 vector<double> headroomIn, vector<double> enhanceIn,
939 headroomSav = (headroomIn.size() >= 1) ? headroomIn[0] : 1.0;
940 enhanceSav = (enhanceIn.size() >= 1) ? enhanceIn[0] : 1.0;
941 if (zetaIntSave <= 0.) {
951 double prefactor = kallenFacSav;
953 prefactor *= headroomSav * enhanceSav;
956 evTypeSav = evTypeIn;
958 evWindowSav = evWindowPtrIn;
962 double logR = log(rndmPtr->flat());
963 if (evWindowPtrIn->runMode <= 0){
965 prefactor *= evWindowPtrIn->alphaSmax;
967 q2NewSav = Q2MaxNow*exp(logR/(prefactor*zetaIntSave));
970 prefactor /= evWindowPtrIn->b0;
971 double muRScaleMod = evWindowPtrIn->kMu2/evWindowPtrIn->lambda2;
972 double logQ2Ratio = exp(logR/(prefactor*zetaIntSave));
973 double logQ2maxFactor = log(Q2MaxNow*muRScaleMod);
974 q2NewSav = exp(logQ2maxFactor*logQ2Ratio)/muRScaleMod;
976 if (q2NewSav > Q2MaxNow) {
977 if (verboseIn >= superdebug)
978 cout <<
"evolution mode = " << evWindowPtrIn->runMode << endl
979 <<
"prefactor = " << prefactor <<
" zetaIntSave = " << zetaIntSave
980 <<
" logR = " << logR << endl
981 <<
" kmu2 = " << evWindowPtrIn->kMu2
982 <<
" lambda2 = " << evWindowPtrIn->lambda2 << endl;
983 string errorMsg =
"Error in "+__METHOD_NAME__
984 +
": Generated q2New > q2Max"+
" Returning -1.";
985 cout<<errorMsg<<endl;
989 if (verboseIn >= normal) {
991 ss <<
"evTypeIn = " << evTypeIn;
992 string errorMsg =
"Error in "+__METHOD_NAME__
993 +
": Unsupported Evolution Type."+
" "+ss.str();
994 cout<<errorMsg<<endl;
1010 bool BrancherEmitRF::genInvariants(vector<double>& invariants,Rndm* rndmPtr,
1015 invariantsSav.clear();
1017 if (q2NewSav <= 0.)
return false;
1020 double zetaNext = getZetaNext(rndmPtr);
1021 double sjk = sAK*(zetaNext - 1.0);
1022 double saj = q2NewSav*(1.0 + sAK/sjk);
1023 double sak = sAK + sjk - saj;
1024 if (verboseIn >= louddebug) {
1026 ss <<
"Phase space point: Q2next = " << q2NewSav <<
" zeta = " << zetaNext;
1027 printOut(__METHOD_NAME__, ss.str());
1028 ss.str(
"Scaled invariants: yaj = ");
1029 ss << saj/(sjk+sAK) <<
" yjk = " << sjk/(sjk+sAK);
1030 printOut(__METHOD_NAME__, ss.str());
1034 invariantsSav.push_back(sAK);
1035 invariantsSav.push_back(saj);
1036 invariantsSav.push_back(sjk);
1037 invariantsSav.push_back(sak);
1040 if (vetoPhSpPoint(saj, sjk, sak, verboseIn))
return false;
1041 else {invariants = invariantsSav;
return true;}
1049 double BrancherEmitRF::pAccept(
const double antPhys,
int verboseIn) {
1052 if (q2NewSav <= 0.) {
1053 if (verboseIn >= normal) {
1054 string errorMsg =
"Error in "+__METHOD_NAME__+
": q2NewSav not set."+
1056 cout<<errorMsg<<endl;
1062 double antTrial = 2.0/q2NewSav;
1065 antTrial *= headroomSav;
1068 antTrial *= colFacSav;
1071 double alphaSTrial = evWindowSav->alphaSmax;
1072 if (evWindowSav->runMode >= 1) {
1073 double mu2 = q2NewSav;
1074 mu2 *= (evWindowSav->kMu2/evWindowSav->lambda2);
1075 alphaSTrial = 1.0/log(mu2)/evWindowSav->b0;
1077 antTrial *= alphaSTrial;
1078 return antPhys/antTrial;
1086 double BrancherEmitRF::KallenFunction(
double x,
double y,
double z) {
1087 return x*x + y*y + z*z - 2.*(x*y + x*z + y*z);}
1089 double BrancherEmitRF::zetaIntSingleLim(
double zetaLim) {
1090 double x = zetaLim-1;
return x + log(x);}
1092 double BrancherEmitRF::zetaIntegral(
double zLow,
double zHigh) {
1093 return zetaIntSingleLim(zHigh) - zetaIntSingleLim(zLow);}
1095 double BrancherEmitRF::getsAK(
double mA,
double mK,
double mAK) {
1096 return mA*mA +mK*mK - mAK*mAK;}
1098 double BrancherEmitRF::zetaMinCalc(
double mA,
double mK,
double mAK,
1100 return 1.0/(1.0 - Q2cut/(mA*mA -(mAK + mK)*(mAK + mK)));}
1102 double BrancherEmitRF::zetaMaxCalc(
double mA,
double mK,
double mAK) {
1103 return 1.0 + ((mA-mAK)*(mA-mAK) - mK*mK)/getsAK(mA, mK, mAK);}
1105 double BrancherEmitRF::getZetaNext(Rndm* rndmPtr) {
1108 double R = rndmPtr->flat();
1110 double intZrange = zetaIntegral(zetaMin, zetaMax);
1111 double intZMin = zetaIntSingleLim(zetaMin);
1113 double expIntZeta = exp(intZrange*R + intZMin);
1114 double lambWFact = LambertW(expIntZeta);
1116 return 1. + lambWFact;
1119 double BrancherEmitRF::calcQ2Max(
double mA,
double mAK,
double mK){
1120 double aM2 = (mA-mAK)*(mA-mAK) - mK*mK;
1121 double bM2 = mAK*(mA-mAK) + mK*mK;
1123 return aM2*aM2*mA/(2.0*cM*bM2);
1130 bool BrancherEmitRF::vetoPhSpPoint(
double saj,
double sjk,
double sak,
1134 double mAK = mRecoilers;
1135 double ma = mPostSav[0];
1136 double mj = mPostSav[1];
1137 double mk = mPostSav[2];
1141 if (saj<0. || sjk<0.) {
1142 if (verboseIn >= louddebug) {
1144 ss <<
"Negative invariants. saj = " << saj <<
" sjk = " << sjk;
1145 printOut(__METHOD_NAME__, ss.str());
1151 double invDiff = ma*ma + mj*mj + mk*mk - saj - sak + sjk - mAK*mAK;
1152 if (invDiff > 0.001) {
1153 if (verboseIn >= louddebug)
1154 printOut(__METHOD_NAME__,
"Failed on-shell AK condition.");
1159 double Ek = sak/(2.0*ma);
1160 if (Ek*Ek < mk*mk) {
1161 if (verboseIn >= louddebug)
1162 printOut(__METHOD_NAME__,
"Failed on-shell k condition.");
1165 double Ej = saj/(2.0*ma);
1167 if (verboseIn >= louddebug)
1168 printOut(__METHOD_NAME__,
"Failed on-shell j condition.");
1173 double cosTheta = getCosTheta(Ej,Ek,mj,mk,sjk);
1174 if (abs(cosTheta) > 1.0) {
1175 if (verboseIn >= louddebug)
1176 printOut(__METHOD_NAME__,
"Failed cos theta condition.");
1181 double det = saj*sjk*sak - saj*saj*mk*mk - sjk*sjk*ma*ma - sak*sak*mj*mj
1182 + 4.0*ma*ma*mj*mj*mk*mk;
1184 if (verboseIn >= louddebug)
1185 printOut(__METHOD_NAME__,
"Gram det < 0 : Outside phase space");
1196 double BrancherEmitRF::getEjMax(
double cosTheta,
double mA,
double mAK,
1199 double cos2Theta(cosTheta*cosTheta), sin2Theta(1. - cos2Theta),
1200 mA2(mA*mA), mK2(mK*mK), mAK2(mAK*mAK),
1201 tmp0(sqrt(sin2Theta*KallenFunction(mA2, mK2, mAK2) + 4.0*mAK2*mA2)),
1202 tmp1(mK/mA*tmp0), tmp2(cos2Theta*mK2 + mAK2), tmp3(mA2 - sin2Theta*mK2),
1203 tmp4((tmp2 + tmp1)/tmp3);
1204 double Emax = mA*(1 - tmp4)/2.0;
1205 double EabsoluteMax = mA/2.0 - (mK+mAK)*(mK+mAK)/(2.0*mA);
1206 return min(Emax,EabsoluteMax);
1218 void BrancherSplitRF::init(
Event& event, vector<int> allIn,
1219 unsigned int posResIn,
unsigned int posFIn,
double Q2cut) {
1224 int iRes = allIn.at(posRes);
1225 int iFinal = allIn.at(posFinal);
1226 colFlowRtoF =
event[iRes].col() ==
event[iFinal].col()
1227 &&
event[iRes].col() != 0;
1230 Vec4 recoilVec(0., 0., 0., 0.);
1231 for (vector<int>::iterator pos=allIn.begin(); pos!=allIn.end(); ++pos) {
1232 if ((*pos == iRes) || (*pos == iFinal))
continue;
1233 recoilVec +=
event[*pos].p();
1238 Vec4 resVec = recoilVec +
event[iFinal].p();
1239 mRes = resVec.mCalc();
1241 mRecoilers = recoilVec.mCalc();
1242 sAK = getsAK(mRes, mFinal, mRecoilers);
1245 kallenFacSav = (0.5*sAK/(4.0*M_PI));
1246 kallenFacSav /= sqrt(KallenFunction(mRes*mRes, mFinal*mFinal,
1247 mRecoilers*mRecoilers));
1250 zetaMin = zetaMinCalc(mRes, mFinal, mRecoilers,Q2cut);
1254 zetaIntSave= zetaMax-zetaMin;
1257 Q2MaxSav = calcQ2Max(mRes, mRecoilers,mFinal);
1260 iAntSav = iXGsplitRF;
1268 vector<double> BrancherSplitRF::setmPostVec() {
1270 mPostSav.push_back(mRes);
1271 mPostSav.push_back(mFlavSav);
1272 mPostSav.push_back(mFlavSav);
1273 mPostSav.push_back(mRecoilers);
1277 void BrancherSplitRF::setidPost(){
1282 idPostSav[posFinal] = -idFlavSav;
1283 idPostSav.insert(idPostSav.begin() + 1, idFlavSav);
1285 idPostSav[posFinal] = idFlavSav;
1286 idPostSav.insert(idPostSav.begin() + 1, -idFlavSav);
1290 void BrancherSplitRF::setStatPost() {
1291 statPostSav.resize(iSav.size() + 1, 52);
1292 statPostSav[1] = 51;
1293 statPostSav[posFinal+1] = 51;
1300 bool BrancherSplitRF::getNewParticles(
Event& event, vector<Vec4> momIn,
1301 vector<int> hIn, vector<Particle>& pNew, Rndm*, Colour*){
1304 unsigned int nPost = iSav.size() + 1;
1308 double scaleNew = sqrt(q2NewSav);
1309 setMaps(event.size());
1310 if (momIn.size() != nPost || hIn.size() != nPost ||
1311 idPostSav.size() != nPost || statPostSav.size() != nPost )
return false;
1313 if (colFlowRtoF) resTag =
event[iSav[posRes]].col();
1314 else resTag =
event[iSav[posRes]].acol();
1317 for (
unsigned int ipart = 0; ipart < nPost; ++ipart) {
1321 if (posNewtoOld.find(ipart) == posNewtoOld.end()) {
1322 newPart.m(mFlavSav);
1323 if (colFlowRtoF) newPart.cols(resTag, 0);
1324 else newPart.cols(0, resTag);
1325 }
else if (posNewtoOld[ipart] == posRes) {
continue;
1327 int colNow =
event[iSav[posNewtoOld[ipart]]].col();
1328 int acolNow =
event[iSav[posNewtoOld[ipart]]].acol();
1329 if (posNewtoOld[ipart] == posFinal) {
1330 if (colFlowRtoF) colNow = 0;
1332 newPart.m(mFlavSav);
1333 }
else newPart.m(mSav[posNewtoOld[ipart]]);
1334 newPart.cols(colNow,acolNow);
1338 newPart.status(statPostSav[ipart]);
1339 newPart.id(idPostSav[ipart]);
1340 newPart.pol(hIn[ipart]);
1341 newPart.p(momIn[ipart]);
1342 newPart.setEvtPtr(&event);
1343 newPart.scale(scaleNew);
1344 newPart.daughters(0,0);
1345 pNew.push_back(newPart);
1356 double BrancherSplitRF::genQ2(
int evTypeIn,
double Q2MaxNow, Rndm* rndmPtr,
1357 const EvolutionWindow* evWindowPtrIn,
double colFac,
1358 vector<double> headroomIn, vector<double> enhanceIn,
int verboseIn) {
1360 if (zetaIntSave <= 0.) {
1368 vector<double> wtFlav;
1369 unsigned int nFlav = headroomIn.size();
1370 if (nFlav != enhanceIn.size()) {
1371 if (verboseIn >= normal) {
1372 string errorMsg =
"Error in "+__METHOD_NAME__
1373 +
": Headroom and enhancement vectors have different sizes.";
1374 cout<<errorMsg<<endl;
1378 for (
unsigned int iFlav = 0; iFlav < nFlav; ++iFlav) {
1379 double wt = headroomIn[iFlav] * enhanceIn[iFlav];
1380 wtFlav.push_back(wt);
1385 if (evTypeIn == 1) {
1388 double prefactor = kallenFacSav;
1389 prefactor *= colFac;
1391 evTypeSav = evTypeIn;
1392 q2BegSav = Q2MaxNow;
1393 evWindowSav = evWindowPtrIn;
1395 double logR = log(rndmPtr->flat());
1398 if (evWindowPtrIn->runMode <= 0) {
1400 prefactor*= evWindowPtrIn->alphaSmax;
1402 q2NewSav = Q2MaxNow*exp(logR/(prefactor*zetaIntSave));
1405 prefactor /= evWindowPtrIn->b0;
1406 double muRScaleMod = evWindowPtrIn->kMu2/evWindowPtrIn->lambda2;
1407 double logQ2Ratio = exp(logR/(prefactor*zetaIntSave));
1408 double logQ2maxFactor = log(Q2MaxNow*muRScaleMod);
1409 q2NewSav = exp(logQ2maxFactor*logQ2Ratio)/muRScaleMod;
1412 if (verboseIn >= normal) {
1414 ss <<
"evTypeIn = " << evTypeIn;
1415 string errorMsg =
"Error in "+__METHOD_NAME__
1416 +
": Unsupported Evolution Type."+
" "+ss.str();
1417 cout<<errorMsg<<endl;
1423 double ranFlav = rndmPtr->flat() * wtSum;
1424 for (
int iFlav = nFlav - 1; iFlav >= 0; --iFlav) {
1425 ranFlav -= wtFlav[iFlav];
1427 idFlavSav = iFlav+1;
1428 mFlavSav = evWindowSav->mass.at(idFlavSav);
1429 enhanceSav = enhanceIn[iFlav];
1430 headroomSav = headroomIn[iFlav];
1436 if (verboseIn >= superdebug) {
1438 ss <<
"Selected splitting flavour: " << idFlavSav;
1439 printOut(__METHOD_NAME__, ss.str());
1441 if (q2NewSav > Q2MaxNow) {
1442 string errorMsg =
"Error in "+__METHOD_NAME__
1443 +
": Generated qq2New > q2Max"+
" Returning -1.";
1444 cout<<errorMsg<<endl;
1457 bool BrancherSplitRF::genInvariants(vector<double>& invariants,Rndm* rndmPtr,
1462 invariantsSav.clear();
1463 if (q2NewSav <= 0.)
return false;
1467 double zetaNext = getZetaNext(rndmPtr);
1468 if (zetaNext < 0.) cout << zetaMin<<
" " << zetaMax << endl;
1469 double m2q = mFlavSav*mFlavSav;
1470 double sak = zetaNext*sAK;
1471 double tmp1 = q2NewSav - (1.-zetaNext)*sAK + m2q;
1472 double tmp2 = sqrt(1.0 +4.0*sAK*q2NewSav/(tmp1*tmp1));
1473 double sjk = tmp1*(1-tmp2)/2.0 -2.0*m2q ;
1474 double saj = (1.0-zetaNext)*sAK + 2.0*m2q +sjk;
1475 if (verboseIn >= louddebug) {
1477 ss <<
"Phase space point: Q2next = " << q2NewSav <<
" zeta = " << zetaNext;
1478 printOut(__METHOD_NAME__, ss.str());
1479 ss.str(
"Scaled invariants: yaj = ");
1480 ss << saj/(sjk+sAK) <<
" yjk = " << sjk/(sjk+sAK);
1481 printOut(__METHOD_NAME__, ss.str());
1485 invariantsSav.push_back(sAK);
1486 invariantsSav.push_back(saj);
1487 invariantsSav.push_back(sjk);
1488 invariantsSav.push_back(sak);
1491 if (vetoPhSpPoint(saj, sjk, sak, verboseIn))
return false;
1492 else {invariants = invariantsSav;
return true;}
1501 double BrancherSplitRF::pAccept(
const double antPhys,
int verboseIn) {
1503 if (q2NewSav <= 0.) {
1504 if (verboseIn >= normal) {
1505 string errorMsg =
"Error in "+__METHOD_NAME__+
": q2NewSav not set";
1506 cout<<errorMsg<<endl;
1509 }
else if (invariantsSav.size() != 4) {
1510 if (verboseIn >= normal) {
1511 string errorMsg =
"Error in "+__METHOD_NAME__+
": invariants not set";
1512 cout<<errorMsg<<endl;
1516 double saj = invariantsSav[1];
1517 double sjk = invariantsSav[2];
1518 double sak = invariantsSav[3];
1519 double m2q = mFlavSav*mFlavSav;
1520 double antTrial = 0.5/(sjk + 2.0*m2q);
1521 double norm = 1.0 + (sjk + 2.0*m2q)/(sAK+sjk+2.0*m2q)*(sak+m2q)/(saj-m2q);
1525 antTrial *= headroomSav;
1528 antTrial *= colFacSav;
1531 double alphaSTrial = evWindowSav->alphaSmax;
1534 if (evWindowSav->runMode >= 1) {
1535 double mu2 = q2NewSav;
1536 mu2 *= (evWindowSav->kMu2/evWindowSav->lambda2);
1537 alphaSTrial = 1.0/log(mu2)/evWindowSav->b0;
1539 antTrial *= alphaSTrial;
1540 return antPhys/antTrial;
1552 void VinciaFSR::init( BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn) {
1555 if (isInit && settingsPtr->word(
"Merging:Process").compare(
"void") == 0)
1557 verbose = settingsPtr->mode(
"Vincia:verbose");
1558 if (verbose >= veryloud) printOut(__METHOD_NAME__,
"begin --------------");
1559 allowforceQuit =
false;
1569 nCallPythiaNext = 0;
1572 doFF = settingsPtr->flag(
"Vincia:doFF");
1573 doRF = settingsPtr->flag(
"Vincia:doRF");
1574 doII = settingsPtr->flag(
"Vincia:doII");
1575 doIF = settingsPtr->flag(
"Vincia:doIF");
1576 doQED = settingsPtr->flag(
"Vincia:doQED");
1583 beamAPtr = beamAPtrIn;
1584 beamBPtr = beamBPtrIn;
1587 m2BeamsSav = m2(beamAPtr->p(), beamBPtr->p());
1588 eCMBeamsSav = sqrt(m2BeamsSav);
1591 hasUserHooks = (userHooksPtr != 0);
1592 canVetoEmission = (hasUserHooks && userHooksPtr->canVetoFSREmission());
1595 nGluonToQuark = settingsPtr->mode(
"Vincia:nGluonToQuark");
1599 nFlavZeroMass = settingsPtr->mode(
"Vincia:nFlavZeroMass");
1602 helicityShower = settingsPtr->flag(
"Vincia:helicityShower");
1605 sectorShower = settingsPtr->flag(
"Vincia:sectorShower");
1610 q2CutoffEmit = pow2(settingsPtr->parm(
"Vincia:cutoffScaleFF"));
1612 q2CutoffSplit = pow2(settingsPtr->parm(
"Vincia:cutoffScaleFF"));
1615 useCMW = settingsPtr->flag(
"Vincia:useCMW");
1616 aSemitPtr = &vinComPtr->alphaStrong;
1617 aSsplitPtr = &vinComPtr->alphaStrong;
1620 aSemitPtr = &vinComPtr->alphaStrongCMW;
1621 aSsplitPtr = &vinComPtr->alphaStrongCMW;
1625 alphaSvalue = settingsPtr->parm(
"Vincia:alphaSvalue");
1626 alphaSorder = settingsPtr->mode(
"Vincia:alphaSorder");
1627 aSkMu2Emit = settingsPtr->parm(
"Vincia:renormMultFacEmitF");
1628 aSkMu2Split = settingsPtr->parm(
"Vincia:renormMultFacSplitF");
1629 alphaSmax = settingsPtr->parm(
"Vincia:alphaSmax");
1630 alphaSmuFreeze = settingsPtr->parm(
"Vincia:alphaSmuFreeze");
1631 mu2freeze = pow2(alphaSmuFreeze);
1634 alphaSmuMin = 1.05 * max(aSemitPtr->Lambda3(), aSsplitPtr->Lambda3());
1635 mu2min = pow2(alphaSmuMin);
1638 if (alphaSorder == 0) alphaSmax = alphaSvalue;
1639 initEvolutionWindows();
1642 enhanceInHard = settingsPtr->flag(
"Vincia:enhanceInHardProcess");
1643 enhanceInResDec = settingsPtr->flag(
"Vincia:enhanceInResonanceDecays");
1644 enhanceInMPI = settingsPtr->flag(
"Vincia:enhanceInMPIshowers");
1645 enhanceAll = settingsPtr->parm(
"Vincia:enhanceFacAll");
1647 enhanceBottom = max(1., settingsPtr->parm(
"Vincia:enhanceFacBottom"));
1648 enhanceCharm = max(1., settingsPtr->parm(
"Vincia:enhanceFacCharm"));
1649 enhanceCutoff = settingsPtr->parm(
"Vincia:enhanceCutoff");
1652 pAccept.resize(max(weightsPtr->nWeights(), 1));
1656 int nAntPhysMax = 20;
1657 nTrials.resize(nAntPhysMax + 1);
1658 nTrialsAccepted.resize(nAntPhysMax + 1);
1659 nFailedVeto.resize(nAntPhysMax + 1);
1660 nFailedHull.resize(nAntPhysMax + 1);
1661 nFailedKine.resize(nAntPhysMax + 1);
1662 nFailedMass.resize(nAntPhysMax + 1);
1663 nFailedCutoff.resize(nAntPhysMax + 1);
1664 nClosePSforHQ.resize(nAntPhysMax + 1);
1665 nSectorReject.resize(nAntPhysMax + 1);
1668 pTmaxMatch = settingsPtr->mode(
"Vincia:pTmaxMatch");
1669 pTmaxFudge = settingsPtr->parm(
"Vincia:pTmaxFudge");
1670 pT2maxFudge = pow2(pTmaxFudge);
1671 pT2maxFudgeMPI = pow2(settingsPtr->parm(
"Vincia:pTmaxFudgeMPI"));
1674 if (verbose >= veryloud)
1675 printOut(__METHOD_NAME__,
"initializing antennaSet");
1677 kMapResEmit = settingsPtr->mode(
"Vincia:kineMapRFemit");
1678 kMapResSplit = settingsPtr->mode(
"Vincia:kineMapRFsplit");
1681 if (!qedShowerPtr->isInit()) {
1682 if (verbose >= debug)
1683 printOut(__METHOD_NAME__,
"initializing QED shower module");
1684 qedShowerPtr->init(beamAPtrIn, beamBPtrIn);
1688 setDiagnostics(dynamic_pointer_cast<VinciaDiagnostics>(userHooksPtr));
1691 if (verbose >= veryloud) printOut(__METHOD_NAME__,
"end --------------");
1699 bool VinciaFSR::limitPTmax(
Event& event,
double,
double) {
1702 if (pTmaxMatch == 1)
return true;
1703 else if (pTmaxMatch == 2)
return false;
1706 else if (infoPtr->isNonDiffractive() || infoPtr->isDiffractiveA() ||
1707 infoPtr->isDiffractiveB() || infoPtr->isDiffractiveC())
1712 const int iSysHard = 0;
1713 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSysHard); ++i) {
1714 int idAbs =
event[partonSystemsPtr->getOut(iSysHard,i)].idAbs();
1715 if (idAbs <= 5 || idAbs == 21 || idAbs == 22)
return true;
1716 else if (idAbs == 6 && nGluonToQuark == 6)
return true;
1729 int VinciaFSR::shower(
int iBeg,
int iEnd,
Event& event,
double pTmax,
1733 if (verbose >= debug) printOut(
"VinciaFSR::shower",
"begin --------------");
1736 int iSys = partonSystemsPtr->addSys();
1739 if (verbose >= 8) printOut(
"VinciaFSR::shower",
1740 "preparing to shower. System no. " + num2str(iSys));
1744 for (
int i = iBeg; i <= iEnd; ++i)
1745 if (event[i].isFinal()) {
1746 partonSystemsPtr->addOut( iSys, i);
1747 pSum +=
event[i].p();
1749 partonSystemsPtr->setSHat( iSys, pSum.m2Calc() );
1755 resEmitters.clear();
1756 resSplitters.clear();
1759 lookupBrancherRF.clear();
1760 lookupSplitterRF.clear();
1761 lookupBrancherFF.clear();
1762 lookupSplitter.clear();
1763 qedShowerPtr->iSystems.clear();
1764 qedShowerPtr->emitSystems.clear();
1765 qedShowerPtr->splitSystems.clear();
1766 qedShowerPtr->convSystems.clear();
1769 prepare(iSys, event,
false);
1775 double pTtimes = pTnext(event, pTmax, 0.);
1777 if (branch(event)) ++nBranchNow;
1783 }
while (pTmax > 0. && (nBranchMax <= 0 || nBranchNow < nBranchMax));
1794 int VinciaFSR::showerQED(
int iBeg,
int iEnd,
Event& event,
double pTmax) {
1797 if(verbose >= debug) printOut(__METHOD_NAME__,
"begin --------------");
1800 partonSystemsPtr->addSys();
1801 int iSys = partonSystemsPtr->sizeSys()-1;
1805 partonSystemsPtr->addOut(iSys,iBeg);
1806 partonSystemsPtr->addOut(iSys,iEnd);
1808 for (
int i=iBeg; i<iEnd; ++i) partonSystemsPtr->addOut(iSys,i);
1810 qedShowerPtr->prepare( iSys, event,
true);
1811 double q2 = pow2(pTmax);
1812 double q2min = qedShowerPtr->q2min();
1815 q2 = qedShowerPtr->generateTrialScale(event, q2);
1816 if (q2 < q2min)
break;
1817 if (qedShowerPtr->checkVeto(event)) {
1818 qedShowerPtr->update(event, iSys);
1831 int VinciaFSR::showerQEDafterRemnants(
Event& event) {
1834 if (!doQED || infoPtr->getAbortPartonLevel())
return 0;
1835 if (verbose >= debug) printOut(__METHOD_NAME__,
"begin --------------");
1839 qedShowerPtr->prepare( -1, event,
true);
1841 int iSys = partonSystemsPtr->sizeSys()-1;
1842 double q2 = qedShowerPtr->q2minColoured();
1843 double q2min = max(qedShowerPtr->q2min(),1.e-13);
1846 q2 = qedShowerPtr->generateTrialScale(event, q2);
1847 if (q2 < q2min)
break;
1848 if (qedShowerPtr->checkVeto(event)) {
1849 qedShowerPtr->update(event, iSys);
1853 if (verbose >= debug) printOut(__METHOD_NAME__,
"end --------------");
1862 void VinciaFSR::prepare(
int iSys,
Event& event,
bool){
1867 if (!isInit)
return;
1870 if (!(doFF || doRF))
return;
1871 if (infoPtr->getAbortPartonLevel()) {
1872 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
1873 +
": Received abort from PartonLevel().",
"Aborting.");
1878 if (!headerIsPrinted && verbose >= normal) header();
1879 if (verbose >= debug) {
1880 printOut(__METHOD_NAME__,
"begin --------------");
1881 if (verbose >= louddebug) {
1883 ss <<
"Preparing system " << iSys;
1884 printOut(__METHOD_NAME__, ss.str());
1886 if (verbose >= superdebug) {
1888 partonSystemsPtr->list();
1894 for (
int j = 0; j < 11; ++j) {
1895 qBranch[iSys][j] = 0.0;
1896 pTphys[iSys][j] = 0.0;
1900 nAccepted = max(nAccepted, infoPtr->nAccepted());
1903 bool firstCallInEvent =
false;
1905 int nCallPythiaNextNow = infoPtr->getCounter(3);
1906 if (nCallPythiaNextNow > nCallPythiaNext) {
1907 nCallPythiaNext = nCallPythiaNextNow;
1910 firstCallInEvent =
true;
1913 long nSelectedNow = infoPtr->nSelected();
1914 if (nSelectedNow > nSelected) {
1915 nSelected = nSelectedNow;
1918 firstCallInEvent =
true;
1923 int nVetoUserHooksNow = (infoPtr->getCounter(10)-1);
1924 if (nVetoUserHooksNow > nVetoUserHooks) {
1925 nVetoUserHooks = nVetoUserHooksNow;
1926 firstCallInEvent =
true;
1932 int nFailHadLevelNow = (infoPtr->getCounter(14) - 1);
1933 if (nFailHadLevelNow > nFailHadLevel) {
1934 nFailHadLevel = nFailHadLevelNow;
1935 firstCallInEvent =
true;
1939 if (firstCallInEvent) {
1943 vinComPtr->resetCounters();
1944 weightsPtr->resetWeights(infoPtr->nAccepted());
1951 if (verbose >= debug) printOut(__METHOD_NAME__,
"User forced quit early.");
1956 int sizeSystem = partonSystemsPtr->sizeAll(iSys);
1957 if (sizeSystem <= 1)
return;
1964 nBranchFSR[iSys] = 0;
1965 if (doDiagnostics) diagnosticsPtr->setnBranchSys(iSys,nBranch[iSys]);
1968 bool checkIncoming =
false;
1970 polarisedSys[iSys] = mecsPtr->isPolarised(iSys, event, checkIncoming);
1971 else polarisedSys[iSys] =
false;
1972 stateChangeSys[iSys] =
true;
1973 stateChangeLast =
true;
1978 if (iSys == 0) firstQBranchBinned =
false;
1984 bool makeNewCopies =
false;
1989 if ((doIF || doII) && isrPtr->prepared(iSys)) {
1990 makeNewCopies =
false;
1993 isHardSys[iSys] = isrPtr->isHardSys[iSys];
1994 isResonanceSys[iSys] =
false;
1995 doMECsSys[iSys] = isrPtr->doMECsSys[iSys];
1996 polarisedSys[iSys] = isrPtr->polarisedSys[iSys];
2003 if (partonSystemsPtr->hasInAB(iSys)) {
2004 isHardSys[iSys] = ( iSys == 0 );
2005 isResonanceSys[iSys] =
false;
2007 isHardSys[iSys] =
false;
2008 isResonanceSys[iSys] = partonSystemsPtr->hasInRes(iSys);
2009 int iAncestor =
event[partonSystemsPtr->getOut(iSys,0)].mother1();
2012 partonSystemsPtr->setInA(iSys, iAncestor);
2016 if (!vinComPtr->mapToMassless(iSys, event, partonSystemsPtr,
2017 makeNewCopies))
return;
2019 doMECsSys[iSys] = mecsPtr->prepare(iSys, event);
2021 if (doMECsSys[iSys] && helicityShower)
2022 polarisedSys[iSys] = mecsPtr->polarise(iSys, event);
2024 if (doMECsSys[iSys]) doMECsSys[iSys] = mecsPtr->doMEC(iSys, 1);
2026 colourPtr->colourise(iSys, event);
2030 if (verbose >= superdebug) printOut(__METHOD_NAME__,
"Finding antennae....");
2031 if(!getAntennae(iSys, event))
return;
2034 setStartScale(iSys, event);
2038 if (verbose >= debug) {
2039 if (verbose >= superdebug) list();
2040 printOut(__METHOD_NAME__,
"end --------------");
2049 void VinciaFSR::update(
int iSys,
Event& event,
bool) {
2052 if (!isPrepared)
return;
2053 if (verbose >= debug) {
2054 printOut(__METHOD_NAME__,
"begin --------------");
2055 if (verbose >= louddebug)
event.list();
2059 qedShowerPtr->update(event, iSys);
2060 if (isResonanceSys[iSys]) {
2061 if (verbose >=normal) infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2062 +
": Update called unexpectedly in resonance shower.",
"Exiting.");
2071 map<int,int> indexOfAcol;
2072 map<int,int> indexOfCol;
2073 vector< pair<int,int> > antFF;
2074 const bool findFF =
true;
2075 const bool findIX =
false;
2076 colourPtr->makeColourMaps(iSys, event, indexOfAcol, indexOfCol,
2077 antFF, findFF, findIX);
2084 if (antFF.size() <= 0)
return;
2088 for (
int i = 0; i < (int)emitters.size(); i++) {
2089 Brancher* brancherPtr = &emitters[i];
2093 int i0Old = brancherPtr->i0();
2094 int i1Old = brancherPtr->i1();
2098 if (event[i0Old].status() < 0 || event[i1Old].status() < 0) {
2101 i0New = indexOfCol[
event[i0Old].col()];
2102 i1New = indexOfAcol[
event[i1Old].acol()];
2104 brancherPtr->reset(brancherPtr->system(), event, i0New, i1New);
2107 pair<int,bool> key = make_pair(i0Old,
true);
2108 if (lookupBrancherFF.find(key)!=lookupBrancherFF.end())
2109 lookupBrancherFF.erase(key);
2110 key = make_pair(i1Old,
false);
2111 if (lookupBrancherFF.find(key)!=lookupBrancherFF.end())
2112 lookupBrancherFF.erase(key);
2114 key = make_pair(i0New,
true);
2115 lookupBrancherFF[key] = i;
2116 key = make_pair(i1New,
false);
2117 lookupBrancherFF[key] = i;
2120 if (event[i0Old].isGluon()) {
2121 if (event[i0New].isGluon())
2122 updateSplitter(event,i0Old,i1Old,i0New,i1New,
true);
2123 else removeSplitter(i0Old);
2125 if (event[i1Old].isGluon()) {
2126 if (event[i1New].isGluon())
2127 updateSplitter(event,i1Old,i0Old,i1New,i0New,
false);
2128 else removeSplitter(i1Old);
2134 pair<int,int> pairNow = make_pair(i0New,i1New);
2135 vector< pair<int,int> >::iterator iter;
2136 iter = find (antFF.begin(), antFF.end(), pairNow);
2137 if (iter != antFF.end()) antFF.erase(iter);
2142 for (
int i = 0; i < (int)antFF.size(); i++) {
2143 int i0 = antFF[i].first;
2144 int i1 = antFF[i].second;
2146 if (!event[i0].isFinal() || !
event[i1].isFinal())
continue;
2147 if (verbose >= superdebug) {
2149 ss <<
"Creating antenna between " << i0 <<
" , " << i1
2150 <<
" col = " <<
event[i0].col();
2151 printOut(__METHOD_NAME__, ss.str());
2154 saveEmitter(iSys, event, i0, i1);
2156 if (event[i0].isGluon()) saveSplitter(iSys, event, i0, i1,
true);
2157 if (event[i1].isGluon()) saveSplitter(iSys, event, i1, i0,
false);
2161 if (emitters.size() + splitters.size() <= 0) {
2162 if (verbose >= quiteloud)
2163 printOut(__METHOD_NAME__,
"WARNING: Did not find any QCD antennae.");
2166 if (!check(event)) {
2167 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2168 +
": failed update antennae.");
2170 if (verbose >= superdebug) printLookup();
2171 infoPtr->setAbortPartonLevel(
true);
2174 if (verbose >=debug) {
2175 if (verbose >= louddebug) list();
2176 if (verbose >= superdebug) printLookup();
2177 printOut(__METHOD_NAME__,
"end --------------");
2186 double VinciaFSR::pTnext(
Event& event,
double pTevolBegAll,
2187 double pTevolEndAll,
bool,
bool) {
2190 if (infoPtr->getAbortPartonLevel() || !isPrepared)
return 0.;
2192 if (verbose >= debug) printOut(__METHOD_NAME__,
"User forced quit early.");
2195 if (verbose >= debug) printOut(__METHOD_NAME__,
"begin --------------");
2198 double q2Begin = pow2(pTevolBegAll);
2199 double q2EndAll = pow2(pTevolEndAll);
2207 if (doFF && emitters.size() > 0) {
2208 if ( !q2NextEmit(q2Begin, q2EndAll) )
return 0.;
2212 if (doFF && splitters.size() > 0) {
2213 if ( !q2NextSplit(q2Begin, q2EndAll) )
return 0.;
2217 if (doRF && resEmitters.size() > 0) {
2218 if ( !q2NextResEmit(q2Begin, q2EndAll) )
return 0.;
2222 if (doRF && resSplitters.size() > 0) {
2223 if ( !q2NextResSplit(q2Begin, q2EndAll) )
return 0.;
2228 double q2QED = qedShowerPtr->generateTrialScale(event, q2Begin);
2229 if (q2QED >q2Begin) {
2231 ss <<
"q2Begin = "<<q2Begin<<
" q2QED = " << q2QED;
2232 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2233 +
": Genereated q2QED > q2Begin.",ss.str());
2237 if (q2QED > q2WinSav && q2QED > q2EndAll) {
2245 if (q2WinSav > q2EndAll) {
2246 if (verbose >= debug) {
2249 ss <<
" QCD Winner at scale qWinNow = "
2251 <<
" col = " <<
event[winnerPtr->i0()].col()
2252 <<
" in System " << winnerPtr->system()
2253 <<
" qbegin = "<< pTevolBegAll;
2255 ss <<
"=== QED Winner at scale qWinNow = "
2257 printOut(__METHOD_NAME__, ss.str());
2259 if (verbose >= superdebug) list();
2264 if (verbose>=superdebug)
event.list();
2273 if (verbose >= normal && !firstQBranchBinned) {
2274 if (vinciaHistos.find(
"1stBranchingQE/eCM") != vinciaHistos.end())
2275 vinciaHistos[
"1stBranchingQE/eCM"].fill(0);
2276 firstQBranchBinned =
true;
2279 if (verbose >= debug) printOut(__METHOD_NAME__,
"end --------------");
2280 return sqrt(q2WinSav);
2288 bool VinciaFSR::branch(
Event& event,
bool ){
2291 if (verbose >= debug) printOut(__METHOD_NAME__,
"begin --------------");
2294 if (winnerQED)
return branchQED(event);
2297 iSysWin = winnerPtr->system();
2298 stateChangeLast =
false;
2299 stateChangeSys[iSysWin] =
false;
2303 winnerPtr->needsNewTrial();
2305 iAntWin = winnerPtr->iAntPhys();
2313 if (!acceptTrial(event)) {
2314 if (verbose >= debug)
2315 printOut(__METHOD_NAME__,
"Trial rejected (failed acceptTrial)");
2321 Event newevent = event;
2322 resJunctionInfo junctionInfoCopy;
2323 if (hasResJunction[iSysWin]) junctionInfoCopy=junctionInfo[iSysWin];
2324 if (!updateEvent(newevent,junctionInfoCopy)) {
2325 if (verbose >= loud)
2326 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2327 +
": Failed to update event.");
2332 if (canVetoEmission) {
2333 if (userHooksPtr->doVetoFSREmission(event.size(), newevent,
2334 iSysWin,isResonanceSys[iSysWin])) {
2335 if (verbose >= debug) printOut(__METHOD_NAME__,
"Trial rejected "
2336 "(failed UserHooks::doVetoFSREmission)");
2340 if (doDiagnostics) diagnosticsPtr->checkEvent(iSysWin,newevent,event.size());
2344 if (hasResJunction[iSysWin]) junctionInfo[iSysWin] = junctionInfoCopy;
2347 updatePartonSystems();
2350 if (!vinComPtr->checkCoM(iSysWin,event,partonSystemsPtr)) {
2351 infoPtr->setAbortPartonLevel(
true);
2352 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2353 +
": Failed momentum conservation test.");
2358 if(!updateAntennae(event)) {
2359 if (verbose >= loud)
2360 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2361 +
": Failed to update antennae");
2362 infoPtr->setAbortPartonLevel(
true);
2367 if (verbose >= normal && !firstQBranchBinned) {
2368 if (vinciaHistos.find(
"1stBranchingQE/eCM") != vinciaHistos.end())
2369 vinciaHistos[
"1stBranchingQE/eCM"].fill(sqrt(q2WinSav)/
event[0].e());
2370 firstQBranchBinned =
true;
2375 nBranchFSR[iSysWin]++;
2378 if(doDiagnostics) diagnosticsPtr->setnBranchSys(iSysWin,nBranch[iSysWin]);
2381 if (!vinComPtr->showerChecks(event,
false)) {
2382 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__+
": Failed shower checks.");
2383 infoPtr->setAbortPartonLevel(
true);
2388 if (iSysWin < 4 && nBranchFSR[iSysWin] < 11 && nBranchFSR[iSysWin]>0) {
2389 qBranch[iSysWin][nBranchFSR[iSysWin]]=sqrt(q2WinSav);
2391 pTphys[iSysWin][nBranchFSR[iSysWin]]=
event[iNewSav].pT();
2396 if (allowforceQuit) {
2397 if (nBranchFSR[iSysWin] >= nBranchQuit && nBranchQuit > 0) {
2399 if (verbose >= debug) {
2401 ss <<
"User forced quit after " << nBranchQuit <<
" emissions.";
2402 printOut(__METHOD_NAME__, ss.str());
2408 nTrialsAccepted[iAntWin]++;
2409 stateChangeSys[iSysWin] =
true;
2410 stateChangeLast =
true;
2411 pTLastAcceptedSav = sqrt(q2WinSav);
2412 if (verbose >= debug) printOut(__METHOD_NAME__,
"end --------------");
2421 void VinciaFSR::list()
const {
2423 if (resEmitters.size() + resSplitters.size() +
2424 emitters.size() + splitters.size() == 0) {
2425 cout <<
" -------- The list of FF antennae is empty -------------------"
2426 "------------------------------------------\n";
2429 cout << endl << endl;
2430 for (
unsigned int i = 0; i < resEmitters.size(); ++i) {
2431 if (i == 0) resEmitters[i].list(
"Gluon Resonance Emission Antennae");
2432 else resEmitters[i].list();
2434 for (
unsigned int i = 0; i < resSplitters.size(); ++i) {
2435 if (i == 0) resSplitters[i].list(
"Gluon Resonance Splitting Antennae");
2436 else resSplitters[i].list();
2438 for (
int i = 0; i < (int)emitters.size(); ++i) {
2439 if (i == 0) emitters[i].list(
"Gluon Emission Antennae");
2440 else emitters[i].list();
2442 for (
int i = 0; i < (int)splitters.size(); ++i) {
2443 if (i == 0) splitters[i].list(
"Gluon Splitting Antennae");
2444 else splitters[i].list();
2446 cout <<
" -------- End VINCIA FF Antenna Listing ------------------------"
2447 "----------------------------------\n";
2455 void VinciaFSR::initVinciaPtrs(Colour* colourPtrIn,
2456 shared_ptr<VinciaISR> isrPtrIn, QEDShower* qedPtrIn,MECs* mecsPtrIn,
2457 Resolution* resolutionPtrIn, VinciaCommon* vinComPtrIn,
2458 VinciaWeights* vinWeightsPtrIn) {
2459 colourPtr = colourPtrIn;
2461 qedShowerPtr = qedPtrIn;
2462 mecsPtr = mecsPtrIn;
2463 resolutionPtr = resolutionPtrIn;
2464 vinComPtr = vinComPtrIn;
2465 weightsPtr = vinWeightsPtrIn;
2472 void VinciaFSR::header() {
2475 if (!isInit)
return;
2478 if (headerIsPrinted)
return;
2479 headerIsPrinted =
true;
2481 cout <<setprecision(3);
2482 cout.setf(ios::left);
2484 cout <<
" *------- VINCIA Global Initialization ------"
2485 <<
"-------------------------------------------------*\n";
2489 cout <<
" | QCD Shower: doII,doIF,doFF,doRF = "
2490 << bool2str(doII,3) <<
","<<bool2str(doIF,3)
2491 <<
","<<bool2str(doFF,3)<<
","<<bool2str(doRF,3)
2493 cout <<
" | nGluonToQuark (FSR) = "
2494 << num2str(settingsPtr->mode(
"Vincia:nGluonToQuark"),9)<<
"\n";
2495 cout <<
" | convertGluonToQuark (ISR) = "
2496 << bool2str(settingsPtr->flag(
"Vincia:convertGluonToQuark"),9)<<
"\n";
2497 cout <<
" | convertQuarkToGluon (ISR) = "
2498 << bool2str(settingsPtr->flag(
"Vincia:convertQuarkToGluon"),9)<<
"\n";
2499 cout <<
" | helicityShower = "
2500 << bool2str(settingsPtr->flag(
"Vincia:helicityShower"),9)<<
"\n";
2501 cout <<
" | sectorShower = "
2502 << bool2str(settingsPtr->flag(
"Vincia:sectorShower"),9)<<
"\n";
2506 <<
" | Alpha_s: alphaS(mZ)|MSbar = "
2507 << num2str(alphaSvalue,9)<<
"\n"
2509 << num2str(alphaSorder,9)<<
"\n";
2510 if (alphaSorder >= 1) {
2512 cout <<
" | LambdaQCD[nF]|MSbar = "
2513 << num2str(vinComPtr->alphaStrong.Lambda3(),9)<<
"[3] "
2514 << num2str(vinComPtr->alphaStrong.Lambda4(),7)<<
"[4] "
2515 << num2str(vinComPtr->alphaStrong.Lambda5(),7)<<
"[5] "
2516 << num2str(vinComPtr->alphaStrong.Lambda6(),7)<<
"[6]\n";
2517 cout <<
" | LambdaQCD[nF]|CMW = "
2518 << num2str(vinComPtr->alphaStrongCMW.Lambda3(),9)<<
"[3] "
2519 << num2str(vinComPtr->alphaStrongCMW.Lambda4(),7)<<
"[4] "
2520 << num2str(vinComPtr->alphaStrongCMW.Lambda5(),7)<<
"[5] "
2521 << num2str(vinComPtr->alphaStrongCMW.Lambda6(),7)<<
"[6]\n";
2523 cout <<
" | LambdaQCD[nF] = "
2524 << num2str(vinComPtr->alphaStrong.Lambda3(),9)<<
"[3] "
2525 << num2str(vinComPtr->alphaStrong.Lambda4(),7)<<
"[4] "
2526 << num2str(vinComPtr->alphaStrong.Lambda5(),7)<<
"[5] "
2527 << num2str(vinComPtr->alphaStrong.Lambda6(),7)<<
"[6]\n";
2529 cout <<
" | useCMW = "
2530 << bool2str(settingsPtr->flag(
"Vincia:useCMW"),9)<<
"\n";
2531 cout <<
" | renormMultFacEmitF = "
2532 << num2str(settingsPtr->parm(
"Vincia:renormMultFacEmitF"),9)
2533 <<
" (muR prefactor for FSR emissions)\n";
2534 cout <<
" | renormMultFacSplitF = "
2535 << num2str(settingsPtr->parm(
"Vincia:renormMultFacSplitF"),9)
2536 <<
" (muR prefactor for FSR splittings)\n";
2537 cout <<
" | renormMultFacEmitI = "
2538 << num2str(settingsPtr->parm(
"Vincia:renormMultFacEmitI"),9)
2539 <<
" (muR prefactor for ISR emissions)\n";
2540 cout <<
" | renormMultFacSplitI = "
2541 << num2str(settingsPtr->parm(
"Vincia:renormMultFacSplitI"),9)
2542 <<
" (muR prefactor for ISR splittings)\n";
2543 cout <<
" | renormMultFacConvI = "
2544 << num2str(settingsPtr->parm(
"Vincia:renormMultFacConvI"),9)
2545 <<
" (muR prefactor for ISR conversions)\n";
2547 cout <<
" | alphaSmuFreeze = "
2548 << num2str(alphaSmuFreeze,9)<<
"\n";
2549 cout <<
" | alphaSmax = "
2550 << num2str(alphaSmax,9)<<
"\n";
2555 <<
" | IR Reg.: cutoffScaleEmitFF = "
2556 << num2str(sqrt(q2CutoffEmit),9)<<
"\n"
2557 <<
" | cutoffScaleSplitFF = "
2558 << num2str(sqrt(q2CutoffSplit),9)<<
"\n"
2559 <<
" | cutoffScaleII = "
2560 << num2str(settingsPtr->parm(
"Vincia:cutoffScaleII"),9)<<
"\n"
2561 <<
" | cutoffScaleIF = "
2562 << num2str(settingsPtr->parm(
"Vincia:cutoffScaleIF"),9)<<
"\n";
2566 <<
" | QED Shower: doQED = "
2567 << bool2str(doQED,9)<<endl;
2569 cout <<
" | nGammaToQuark = "
2570 <<num2str(settingsPtr->mode(
"Vincia:nGammaToQuark"),9)<<
"\n"
2571 <<
" | nGammaToLepton = "
2572 <<num2str(settingsPtr->mode(
"Vincia:nGammaToLepton"),9)<<
"\n"
2573 <<
" | convertGammaToQuark = "
2574 <<bool2str(settingsPtr->flag(
"Vincia:convertGammaToQuark"),9)<<
"\n"
2575 <<
" | convertQuarkToGamma = "
2576 <<bool2str(settingsPtr->flag(
"Vincia:convertQuarkToGamma"),9)<<
"\n";
2582 <<
" | AntennaFunctions: "
2583 <<
" chargeFactor kineMap"<<endl;
2584 vector<int> iAnt = antSetPtr->getIant();
2585 int modeSLC = settingsPtr->mode(
"Vincia:modeSLC");
2588 for (
int i=0;i<(int)iAnt.size();++i) {
2589 int iAntPhys = iAnt[i];
2590 AntennaFunction* antPtr = antSetPtr->getAnt(iAntPhys);
2591 if (antPtr ==
nullptr)
continue;
2593 cout.setf(ios::left);
2594 cout << setprecision(2);
2595 string antName = antPtr->vinciaName()+
" ["+antPtr->humanName()+
"]";
2596 cout <<
" | " << left << setw(32) << antName <<
" ";
2598 double chargeFac = antPtr->chargeFac();
2599 cout<<fixed<<setw(6)<<chargeFac;
2602 if (antPtr->vinciaName() ==
"Vincia:QGEmitFF" ||
2603 antPtr->vinciaName() ==
"Vincia:GQEmitFF" ||
2604 antPtr->vinciaName() ==
"Vincia:QGEmitRF" ||
2605 antPtr->vinciaName() ==
"Vincia:GQEmitRF") cout <<
"*";
2608 int kineMap = antPtr->kineMap();
2609 cout <<
" " << right << setw(5) << kineMap << left <<
"\n";
2613 AntennaSetISR* antSetISRPtr = isrPtr->antSetPtr;
2614 if (antSetISRPtr !=
nullptr) {
2615 vector<int> iAntISR = antSetISRPtr->getIant();
2616 for (
int i = 0; i < (int)iAntISR.size(); ++i) {
2617 int iAntPhys = iAntISR[i];
2618 AntennaFunctionIX* antPtr = antSetISRPtr->getAnt(iAntPhys);
2619 if (antPtr ==
nullptr)
continue;
2621 cout.setf(ios::left);
2622 cout << setprecision(2) <<
" | " << left << setw(32)
2623 << antPtr->vinciaName() +
" [" + antPtr->humanName() +
"]"
2626 double chargeFac = antPtr->chargeFac();
2627 cout << fixed << setw(6) << chargeFac;
2629 if (antPtr->vinciaName() ==
"Vincia:QGEmitII" ||
2630 antPtr->vinciaName() ==
"Vincia:GQEmitII" ||
2631 antPtr->vinciaName() ==
"Vincia:QGEmitIF" ||
2632 antPtr->vinciaName() ==
"Vincia:GQEmitIF") cout<<
"*";
2635 int kineMap = antPtr->kineMap();
2636 cout <<
" " << right << setw(5) << kineMap << left <<
"\n";
2639 cout <<
" | *: GQ antennae interpolate between "
2640 <<
"CA and 2CF (modeSLC = 2)" << endl;
2648 cout <<
" |-------------------------------------------"
2649 <<
"------------------------------------------\n |\n";
2650 cout <<
" | References :"<<endl;
2651 cout <<
" | VINCIA : Fischer, Prestel, Ritzmann, Skands, "
2652 <<
"EPJC76(2016)589, arXiv:1605.06142" << endl;
2653 cout <<
" | PYTHIA 8 : Sjostrand et al., CPC191(2015)159, "
2654 <<
"arXiv:1410.3012" << endl;
2655 cout <<
" |\n *------- End VINCIA Initialization "
2656 <<
"----------------------------------------------------*\n\n";
2657 cout.setf(ios::right);
2665 void VinciaFSR::printInfo(
bool pluginCall) {
2668 if (!isInit)
return;
2669 int nTotWeightsInt = weightsPtr->nTotWeights;
2670 int nNonunityInitialWeight = weightsPtr->nNonunityInitialWeight;
2671 int nNegativeInitialWeight = weightsPtr->nNegativeInitialWeight;
2672 int nNonunityWeight = weightsPtr->nNonunityWeight;
2673 int nNegativeWeight = weightsPtr->nNegativeWeight;
2674 double nTotWeights = max(1.0,((
double)(nTotWeightsInt)));
2675 vector<double> weightSum = weightsPtr->weightSum;
2676 vector<double> weightMax = weightsPtr->weightsMax;
2677 vector<double> weightMin = weightsPtr->weightsMin;
2681 cout <<
" *-------- VINCIA FSR and ISR Statistics ----------------"
2682 <<
"--------------------------------------------------------*\n";
2684 cout <<
" *-------- VINCIA FSR Statistics ------------------------"
2685 <<
"--------------------------------------------------------*\n";
2689 <<
" " << setw(40) <<
" " <<
" |\n";
2690 cout <<
" | Total Number of (accepted) events = "
2691 << num2str(nTotWeightsInt, 9) << setw(40) <<
" " <<
" |\n";
2692 cout <<
" | Number of events with nonunity initial weight = "
2693 << ((nNonunityInitialWeight <= 0) ?
2695 num2str(nNonunityInitialWeight, 9)
2696 +
" <-- (INITIALLY) WEIGHTED EVENTS")
2697 << setw(8) <<
" " <<
" |\n";
2698 cout <<
" | Number of events with negative initial weight = "
2699 << ((nNegativeInitialWeight <= 0) ?
" none"
2700 : num2str(nNegativeWeight, 9))
2701 << setw(40) <<
" " <<
" |\n";
2702 cout <<
" | Number of events with nonunity reweight = "
2703 << ((nNonunityWeight <= 0) ?
" none "
2704 : num2str(nNonunityWeight, 9)+
" <-- REWEIGHTED EVENTS" )
2705 << setw(18) <<
" " <<
" |\n";
2706 cout <<
" | Number of events with negative reweight = "
2707 << ((nNegativeWeight <= 0) ?
" none"
2708 : num2str(min(nNegativeWeight,nNonunityWeight), 9))
2709 << setw(40) <<
" " <<
" |\n";
2711 <<
" " << setw(40) <<
" " <<
" |\n";
2712 cout <<
" | weight(i) Avg Wt Avg Dev"
2713 <<
" rms(dev) kUnwt Expected effUnw |\n";
2714 cout <<
" | This run i = IsUnw <w> <w-1> "
2715 <<
" 1/<w> Max Wt <w>/MaxWt Min Wt |\n";
2716 cout <<
" |"<<setw(4)<<
" "<<
"User settings 0 ";
2717 cout << ((abs(1.0-weightSum[0]/nTotWeights) < TINY) ?
2719 cout << num2str(weightSum[0]/nTotWeights,9) <<
" ";
2720 cout << num2str(weightSum[0]/nTotWeights-1.0,9) <<
" ";
2721 cout << setw(9) <<
"-" <<
" ";
2722 cout << ((weightSum[0] != 0.0) ?
2723 num2str(nTotWeights/weightSum[0], 9) : num2str(0.0, 9));
2724 cout << num2str(weightMax[0],14)<<
" ";
2725 cout << ((weightMax[0] != 0.0) ? num2str(weightSum[0]/nTotWeights/
2726 weightMax[0],9) : num2str(0.0,9)) <<
" ";
2727 cout << num2str(weightMin[0],9) <<
" ";
2730 cout <<
" | - - - - FSR only Statistics - - - - - - - - - - - - "
2731 <<
"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - |\n";
2733 <<
" " << setw(40) <<
" " <<
" |\n";
2735 if (verbose >= 2 && nTrialsSum > 0) {
2736 cout <<
" | ----------"
2737 <<
"----------- P(Reject) --------------------"
2738 << setw(15) <<
"|" << endl;
2739 cout <<
" | Trial Veto Rates: nTrials nAcc eff Zeta kinMap"
2740 <<
" Veto Sector IR mMin HQPS"
2741 << setw(15) <<
"|" << endl;
2742 for (
int iAntPhys = 0; iAntPhys < (int)nTrials.size(); ++iAntPhys) {
2743 double nTot = nTrials[iAntPhys];
2744 if (nTot <= 0)
continue;
2745 cout <<
" | " << setw(17);
2746 if (iAntPhys == iQQemitFF) cout <<
"QQemitFF";
2747 else if (iAntPhys == iQGemitFF) cout <<
"QGemitFF";
2748 else if (iAntPhys == iGQemitFF) cout <<
"GQemitFF";
2749 else if (iAntPhys == iGGemitFF) cout <<
"GGemitFF";
2750 else if (iAntPhys == iGXsplitFF) cout <<
"GXsplitFF";
2751 else if (iAntPhys == iQQemitRF) cout <<
"QQemitRF";
2752 else if (iAntPhys == iQGemitRF) cout <<
"QGemitRF";
2753 else if (iAntPhys == iXGsplitRF) cout <<
"XGsplitRF";
2754 cout << fixed<<setprecision(2)
2755 <<
" "<< num2str(
int(nTot+0.5), 9)
2756 <<
" "<< num2str(
int(nTrialsAccepted[iAntPhys]+0.5), 8)
2757 <<
" " << nTrialsAccepted[iAntPhys]/nTot
2758 <<
" " << nFailedHull[iAntPhys]*1.0/max(1., nTot);
2759 nTot -= nFailedHull[iAntPhys];
2760 cout <<
" " << nFailedKine[iAntPhys]*1.0/max(1., nTot);
2761 nTot -= nFailedKine[iAntPhys];
2762 cout <<
" " << nFailedVeto[iAntPhys]*1.0/max(1., nTot);
2763 nTot -= nFailedVeto[iAntPhys];
2764 cout <<
" " << nSectorReject[iAntPhys]*1.0/max(1., nTot);
2765 nTot -= nSectorReject[iAntPhys];
2766 cout <<
" " << nFailedCutoff[iAntPhys]*1.0/max(1., nTot);
2767 nTot -= nFailedCutoff[iAntPhys];
2768 cout <<
" " << nFailedMass[iAntPhys]*1.0/max(1., nTot);
2769 nTot -= nFailedMass[iAntPhys];
2770 cout <<
" " << nClosePSforHQ[iAntPhys]*1.0/max(1., nTot);
2771 cout << setw(16) <<
"|\n";
2773 cout <<
" |" << setw(113) <<
" " <<
"|\n";
2776 cout <<
" *-------- End VINCIA FSR Statistics --------------------"
2777 <<
"---------------------------------------------------------*\n\n";
2785 void VinciaFSR::printHistos() {
2786 for (map<string,Hist>::iterator iH = vinciaHistos.begin();
2787 iH != vinciaHistos.end(); ++iH) {
2788 string Hname=iH->first;
2789 if (vinciaHistos[Hname].getEntries() >= 1)
2790 cout << Hname << vinciaHistos[Hname] << endl;
2798 void VinciaFSR::writeHistos(
string fileName,
string suffix) {
2799 for (map<string,Hist>::const_iterator iH = vinciaHistos.begin();
2800 iH != vinciaHistos.end(); ++iH) {
2801 string Hname=iH->first;
2802 if (vinciaHistos[Hname].getEntries() >= 1) {
2803 string file = sanitizeFileName(
2804 fileName +
"-Hist-" + Hname +
"." + suffix);
2805 cout <<
"Writing " << file << endl;
2806 iH->second.table(file);
2816 int VinciaFSR::getNbranch(
int iSys) {
2819 for (
int i = 0; i < (int)nBranchFSR.size(); ++i) n += nBranchFSR[i];
2820 else if (iSys < (
int)nBranchFSR.size()) n = nBranchFSR[iSys];
2829 bool VinciaFSR::check(
Event &event) {
2831 for (
int i = 0; i < (int)emitters.size(); ++i) {
2832 if (!event[emitters[i].i0()].isFinal()) {
2833 if (verbose > normal){
2834 ss <<
"Emitter " << i
2835 <<
" i0 = " << emitters[i].i0() <<
" not final.";
2836 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2837 +
": Failed to update emitter (not final).", ss.str());
2840 }
else if (!event[emitters[i].i1()].isFinal()) {
2841 if (verbose > normal) {
2842 ss <<
"Emitter " << i
2843 <<
" i1 = " << emitters[i].i1() <<
" not final.";
2844 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2845 +
": Failed to update emitter (not final).", ss.str());
2850 for (
int i = 0; i < (int)splitters.size(); ++i) {
2851 if(!event[splitters[i].i0()].isFinal()){
2852 if (verbose > normal) {
2853 ss <<
"Splitter " << i
2854 <<
" i0 = " << splitters[i].i0() <<
" not final.";
2855 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2856 +
": Failed to update splitter (not final).", ss.str());
2859 }
else if (!event[splitters[i].i1()].isFinal()) {
2860 if (verbose > normal) {
2861 ss <<
"Splitter " << i
2862 <<
" i1 = " << splitters[i].i1() <<
" not final.";
2863 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
2864 +
": Failed to update splitter (not final).", ss.str());
2869 if (verbose > superdebug)
2870 printOut(__METHOD_NAME__,
"Passed all checks on antennae.");
2879 void VinciaFSR::initEvolutionWindows(
void){
2881 evWindowsEmit.clear();
2882 evWindowsSplit.clear();
2883 EvolutionWindow window;
2884 window.alphaSmax = alphaSmax;
2885 window.mass[1] = 0.;
2886 window.mass[2] = 0.;
2887 window.mass[3] = 0.;
2888 window.mass[4] = (nFlavZeroMass >= 4) ? 0.0 : particleDataPtr->m0(4);
2889 window.mass[5] = (nFlavZeroMass >= 5) ? 0.0 : particleDataPtr->m0(5);
2890 window.mass[6] = (nFlavZeroMass >= 6) ? 0.0 : particleDataPtr->m0(6);
2892 for(
int iWindow = 0; iWindow < 4; iWindow++) {
2894 double qMinNowEmit=getQ2Window(iWindow, q2CutoffEmit);
2895 double qMinNowSplit=getQ2Window(iWindow ,q2CutoffSplit);
2900 window.lambda2 = 0.;
2902 window.runMode = 0 ;
2903 window.qMin = qMinNowEmit;
2904 evWindowsEmit[qMinNowEmit] = window;
2905 window.qMin = qMinNowSplit;
2906 evWindowsSplit[qMinNowSplit] = window;
2909 window.runMode = alphaSorder;
2911 if (qMinNowEmit < particleDataPtr->m0(4)) nFnow = 3;
2912 else if (qMinNowEmit < particleDataPtr->m0(5)) nFnow = 4;
2913 else if (qMinNowEmit >= particleDataPtr->m0(6)) nFnow = 6;
2914 window.b0 = (33.0 - 2.0*nFnow) / (12.0 * M_PI);
2915 double lambdaNow = getLambda(nFnow,aSemitPtr);
2916 window.lambda2 = (lambdaNow*lambdaNow);
2917 window.kMu2 = aSkMu2Emit;
2918 window.qMin = qMinNowEmit;
2919 evWindowsEmit[qMinNowEmit]=window;
2922 if (qMinNowSplit < particleDataPtr->m0(4)) nFnow = 3;
2923 else if (qMinNowSplit < particleDataPtr->m0(5)) nFnow = 4;
2924 else if (qMinNowSplit >= particleDataPtr->m0(6)) nFnow = 6;
2925 window.b0 = (33.0 - 2.0*nFnow) / (12.0 * M_PI);
2926 lambdaNow = getLambda(nFnow,aSsplitPtr);
2927 window.lambda2 = (lambdaNow*lambdaNow);
2928 window.kMu2 = aSkMu2Split;
2929 window.qMin = qMinNowSplit;
2930 evWindowsSplit[qMinNowSplit]=window;
2940 double VinciaFSR::getQ2Window(
int iWindow,
double q2cutoff){
2941 double qMinNow = 0.;
2945 qMinNow = min(sqrt(q2cutoff),particleDataPtr->m0(4));
2949 qMinNow = max(1.0,particleDataPtr->m0(4));
2953 qMinNow = max(3.0,particleDataPtr->m0(5));
2957 qMinNow = max(100.0,particleDataPtr->m0(6));
2967 double VinciaFSR::getLambda(
int nFin, AlphaStrong* aSptr) {
2968 if (nFin <= 3)
return 0.;
2969 else if (nFin == 4)
return aSptr->Lambda4();
2970 else if (nFin == 5)
return aSptr->Lambda5();
2971 else return aSptr->Lambda6();
2978 double VinciaFSR::getkMu2(
bool isEmit){
2982 bool muSoftCorr =
false;
2983 if (useCMW && muSoftCorr) {
2985 double xj = winnerPtr->getXj();
2986 double muSoftInvPow = 4;
2987 double a = 1./muSoftInvPow;
2988 kMu2 = pow(xj,a) * kMu2 + (1.-pow(xj,a));
2990 }
else kMu2 = aSkMu2Split;
2999 double VinciaFSR::getMu2(
bool isEmit) {
3000 double mu2 = winnerPtr->q2Trial();
3001 double kMu2 = getkMu2(isEmit);
3002 mu2 = max(mu2min, mu2freeze + mu2*kMu2);
3010 void VinciaFSR::clearContainers() {
3011 headroomSav.clear();
3015 isResonanceSys.clear();
3017 polarisedSys.clear();
3018 stateChangeSys.clear();
3032 bool VinciaFSR::getAntennae(
int iSys,
Event& event){
3035 if (partonSystemsPtr ==
nullptr) {
3036 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3037 +
": partonSystems pointer is NULL!");
3042 if (iSys == 0 || partonSystemsPtr->hasInRes(iSys) ||
3043 !partonSystemsPtr->hasInAB(iSys)) {
3044 resEmitters.clear();
3045 resSplitters.clear();
3048 lookupBrancherRF.clear();
3049 lookupSplitterRF.clear();
3050 lookupBrancherFF.clear();
3051 lookupSplitter.clear();
3054 if (iSys > partonSystemsPtr->sizeSys())
return false;
3056 if (partonSystemsPtr->sizeOut(iSys) == 0)
return false;
3063 int colPartner = -1;
3064 int acolPartner = -1;
3065 if (partonSystemsPtr->hasInRes(iSys)) {
3066 iMother = partonSystemsPtr->getInRes(iSys);
3068 if (event[iMother].status() > 0)
return false;
3069 resCol =
event[iMother].col();
3070 resACol =
event[iMother].acol();
3074 map<int, int> coltoDecID;
3076 map<int, int> aColtoDecID;
3078 vector<int> daughters;
3082 for (
int iPart = 0; iPart < partonSystemsPtr->sizeOut(iSys); iPart++) {
3085 int iOut = partonSystemsPtr->getOut(iSys, iPart);
3086 pSum +=
event[iOut].p();
3088 if (!event[iOut].isFinal())
return false;
3090 if (event[iOut].col() !=0 ) {
3092 if (event[iOut].col() == resCol) colPartner = iOut;
3094 else coltoDecID[
event[iOut].col()] = iOut;
3096 if (event[iOut].acol() !=0 ) {
3098 if (event[iOut].acol()==resACol) acolPartner = iOut;
3100 else aColtoDecID[
event[iOut].acol()] = iOut;
3103 if (iOut != colPartner && iOut != acolPartner) daughters.push_back(iOut);
3105 double mSys = m(pSum);
3108 Vec4 total(0., 0., 0., 0.);
3109 if (!isResonanceSys[iSys]) {
3110 if (partonSystemsPtr->getInA(iSys) > 0)
3111 total += event[partonSystemsPtr->getInA(iSys)].p();
3112 if (partonSystemsPtr->getInB(iSys) > 0)
3113 total += event[partonSystemsPtr->getInB(iSys)].p();
3114 }
else total +=
event[partonSystemsPtr->getInRes(iSys)].p();
3117 if (abs(total.e()) > SMALL || abs(total.px()) > SMALL ||
3118 abs(total.py()) > SMALL || abs(total.pz()) > SMALL) {
3120 cout <<
"total = " << setprecision(10) << total.e() <<
" "
3121 << total.px() <<
" " << total.py() <<
" " <<total.pz() << endl;
3123 ss <<
"iSys = " << iSys;
3124 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3125 +
": Failed momentum conservation test.", ss.str());
3126 infoPtr->setAbortPartonLevel(
true);
3131 mSystem[iSys] = mSys;
3134 if (doQED) qedShowerPtr->prepare(iSys, event,
false);
3137 if (colPartner > 0) {
3139 vector<int> resSysAll = daughters;
3140 if (acolPartner != colPartner && acolPartner > 0)
3141 resSysAll.push_back(acolPartner);
3144 resSysAll.insert(resSysAll.begin(), colPartner);
3145 resSysAll.insert(resSysAll.begin(), iMother);
3146 unsigned int posRes(0), posPartner(1);
3147 saveResEmitter(iSys, event, resSysAll, posRes, posPartner,
true);
3148 if (event[colPartner].isGluon())
3149 saveResSplitter(iSys, event, resSysAll, posRes, posPartner,
true);
3151 if (acolPartner > 0) {
3153 vector<int> resSysAll = daughters;
3154 if (acolPartner != colPartner && colPartner > 0)
3155 resSysAll.push_back(colPartner);
3158 resSysAll.insert(resSysAll.begin(), acolPartner);
3159 resSysAll.insert(resSysAll.begin(), iMother);
3160 unsigned int posRes(0), posPartner(1);
3161 saveResEmitter(iSys, event, resSysAll, posRes, posPartner,
false);
3162 if (event[acolPartner].isGluon())
3163 saveResSplitter(iSys, event, resSysAll, posRes, posPartner,
false);
3168 for (map<int,int>::iterator it = coltoDecID.begin(); it != coltoDecID.end();
3170 int col = it->first;
3171 int i0 = it->second;
3172 int i1 = aColtoDecID[col];
3175 if (!event[i0].isFinal() || !
event[i1].isFinal())
continue;
3178 saveEmitter(iSys, event, i0, i1);
3182 if (event[i0].isGluon()) saveSplitter(iSys, event, i0, i1,
true);
3183 if (event[i1].isGluon()) saveSplitter(iSys, event, i1, i0,
false);
3189 hasResJunction[iSys] =
false;
3190 if (isResonanceSys[iSys] && resCol > 0 && colPartner >0) {
3192 for (
int iJun = 0; iJun <
event.sizeJunction(); ++iJun) {
3194 for (
int iLeg = 0; iLeg < 3; ++iLeg) {
3195 if (event.endColJunction(iJun, iLeg) == resCol) {
3197 hasResJunction[iSys] =
true;
3198 junctionInfo[iSys].iJunction=iJun;
3199 junctionInfo[iSys].iEndCol=iLeg;
3200 junctionInfo[iSys].iEndColTag=resCol;
3201 junctionInfo[iSys].iEndQuark=colPartner;
3202 junctionInfo[iSys].colours.clear();
3203 junctionInfo[iSys].colours.push_back(resCol);
3207 while (!event[junctionInfo[iSys].iEndQuark].isQuark()) {
3208 int colNow =
event[junctionInfo[iSys].iEndQuark].acol();
3209 if (aColtoDecID.find(colNow) != aColtoDecID.end()) {
3210 int newPart = coltoDecID[colNow];
3211 junctionInfo[iSys].colours.push_back(colNow);
3212 junctionInfo[iSys].iEndQuark=newPart;
3213 junctionInfo[iSys].iEndColTag=colNow;
3215 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3216 +
": Resonance involved in junction that cannot be traced.");
3217 hasResJunction[iSys] =
false;
3221 if (event[junctionInfo[iSys].iEndQuark].col() == 0 ||
3222 !event[junctionInfo[iSys].iEndQuark].isFinal()) {
3223 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3224 +
": Failed to find end quark in resonance junction.");
3225 hasResJunction[iSys] =
false;
3238 for (
int i = 0; i < partonSystemsPtr->sizeAll(iSys); ++i) {
3239 Particle* partonPtr = &
event[partonSystemsPtr->getAll(iSys, i)];
3240 if (partonPtr->id()==21) nG[iSys]++;
3241 else if (abs(partonPtr->id()) < 7) nQ[iSys]++;
3242 else if (abs(partonPtr->id()) == 22) nGam[iSys]++;
3243 else if (partonPtr->isLepton()) nLep[iSys]++;
3247 if (verbose >= debug) {
3248 if (resEmitters.size() + resSplitters.size() +
3249 emitters.size() + splitters.size() <= 0)
3250 printOut(__METHOD_NAME__,
"did not find any QCD antennae.");
3251 else if (verbose >= louddebug) {
3253 if (verbose >= superdebug) printLookup();
3264 void VinciaFSR::setStartScale(
int iSys,
Event& event){
3268 if (isResonanceSys[iSys]) nIn = 1;
3269 else if (partonSystemsPtr->hasInAB(iSys)) nIn = 2;
3273 if (isResonanceSys[iSys]) {
3274 Q2hat[iSys] = pow2(mSystem[iSys]);
3278 }
else if (isHardSys[iSys]) {
3279 if (verbose >= superdebug)
3280 printOut(__METHOD_NAME__,
"Setting FSR starting scale for hard system");
3282 if (pTmaxMatch == 1) Q2hat[iSys] = pT2maxFudge * infoPtr->Q2Fac();
3284 else if (pTmaxMatch == 2) Q2hat[iSys] = m2BeamsSav;
3287 bool hasRad =
false;
3288 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSys); ++i) {
3289 int idAbs =
event[partonSystemsPtr->getOut(iSys, i)].idAbs();
3290 if (idAbs <= 5 || idAbs == 21 || idAbs == 22) hasRad =
true;
3291 if (idAbs == 6 && nGluonToQuark == 6) hasRad =
true;
3295 if (hasRad) Q2hat[iSys] = pT2maxFudge * infoPtr->Q2Fac();
3296 else Q2hat[iSys] = m2BeamsSav;
3298 }
else if (nIn == 2) {
3299 if (verbose >= superdebug)
3300 printOut(__METHOD_NAME__,
"Setting FSR starting scale of MPI system");
3303 int in1 = partonSystemsPtr->getInA(iSys);
3304 int in2 = partonSystemsPtr->getInB(iSys);
3305 Q2hat[iSys] = pT2maxFudgeMPI
3306 * pow2(min(event[in1].scale(),event[in2].scale()));
3309 Q2hat[iSys] = pow2(mSystem[iSys]);
3319 bool VinciaFSR::q2NextResEmit(
const double q2Begin,
const double q2End) {
3320 if (verbose >= verylouddebug)
3321 printOut(__METHOD_NAME__,
"begin --------------");
3322 double q2EndNow = max(q2End, q2CutoffEmit);
3323 bool gen = q2NextBranch<BrancherEmitRF>(resEmitters, evWindowsEmit,
3324 evTypeEmit, q2Begin, q2EndNow,
true);
3325 if (verbose >= verylouddebug)
3326 printOut(__METHOD_NAME__,
"end --------------");
3330 bool VinciaFSR::q2NextResSplit(
const double q2Begin,
const double q2End) {
3331 if (verbose >= verylouddebug)
3332 printOut(__METHOD_NAME__,
"begin --------------");
3333 double q2EndNow = max(q2End, q2CutoffSplit);
3334 bool gen = q2NextBranch<BrancherSplitRF>(resSplitters, evWindowsSplit,
3335 evTypeSplit, q2Begin, q2EndNow,
false);
3336 if (verbose >= verylouddebug)
3337 printOut(__METHOD_NAME__,
"end --------------");
3341 bool VinciaFSR::q2NextEmit(
const double q2Begin,
const double q2End) {
3342 if (verbose >= verylouddebug)
3343 printOut(__METHOD_NAME__,
"begin --------------");
3344 double q2EndNow = max(q2End, q2CutoffEmit);
3345 bool gen = q2NextBranch<BrancherEmitFF>(emitters, evWindowsEmit, evTypeEmit,
3346 q2Begin, q2EndNow,
true);
3347 if (verbose >= verylouddebug)
3348 printOut(__METHOD_NAME__,
"end --------------");
3352 bool VinciaFSR::q2NextSplit(
const double q2Begin,
const double q2End) {
3353 if (verbose >= verylouddebug)
3354 printOut(__METHOD_NAME__,
"begin --------------");
3355 double q2EndNow = max(q2End, q2CutoffSplit);
3356 bool gen = q2NextBranch<BrancherSplitFF>(splitters, evWindowsSplit,
3357 evTypeSplit, q2Begin, q2EndNow,
false);
3358 if (verbose >= verylouddebug)
3359 printOut(__METHOD_NAME__,
"end --------------");
3367 template <
class Brancher>
bool VinciaFSR::q2NextBranch(
3368 vector<Brancher>& brancherVec,
const map<double, EvolutionWindow> &evWindows,
3369 const int evType,
const double q2Begin,
const double q2End,
bool isEmit) {
3373 if (verbose >= superdebug) {
3375 ss <<
"qBegin = " << sqrt(q2Begin);
3376 printOut(__METHOD_NAME__, ss.str());
3378 if (q2Begin <= q2End) {
3379 if (verbose >= louddebug)
3380 printOut(__METHOD_NAME__,
"q2Begin below cutoff. Nothing to do.");
3382 }
else if (!isEmit && nGluonToQuark == 0)
return true;
3385 unsigned int numAnt = brancherVec.size();
3386 if (verbose >= superdebug) {
3388 ss <<
"Looping over " << numAnt <<
" antennae.";
3389 printOut(__METHOD_NAME__, ss.str());
3391 unsigned int iAnt = 0;
3392 for (
typename vector<Brancher>::iterator ibrancher = brancherVec.begin();
3393 ibrancher!=brancherVec.end(); ++ibrancher) {
3395 if (verbose >= superdebug) {
3397 ss <<
"Antenna " << iAnt <<
" / " << numAnt;
3398 printOut(__METHOD_NAME__,ss.str());
3402 double Q2MaxNow = min(q2Begin, ibrancher->getQ2Max(evType));
3403 if (Q2MaxNow < q2End) {
3404 if (verbose >= louddebug) printOut(__METHOD_NAME__,
3405 "No phase space left for current antenna, continuing.");
3411 if (ibrancher->hasTrial()) {
3412 q2Next = ibrancher->q2Trial();
3413 if (verbose >= louddebug) {
3415 ss <<
"Retrieving saved trial Q=" << sqrt(q2Next);
3416 printOut(__METHOD_NAME__, ss.str());
3420 if (verbose >= superdebug)
3421 printOut(__METHOD_NAME__,
"Generating new trial");
3424 int iSys = ibrancher->system();
3425 double colFac = getAnt(ibrancher->iAntPhys())->chargeFac();
3426 if (verbose >= louddebug) {
3428 ss <<
"Starting shower for current brancher at Q=" << sqrt(Q2MaxNow);
3429 printOut(__METHOD_NAME__, ss.str());
3434 map<double, EvolutionWindow>::const_iterator
3435 it = evWindows.lower_bound(sqrt(Q2MaxNow));
3437 map<double, EvolutionWindow>::const_reverse_iterator itWindowNow(it);
3440 if (verbose >= superdebug)
3441 printOut(__METHOD_NAME__,
"Looping over Q2 windows...");
3442 while(itWindowNow != evWindows.rend()) {
3445 double Q2MinWindow = pow2(itWindowNow->first);
3446 const EvolutionWindow* windowPtr = &(itWindowNow->second);
3449 vector<double> headroomVec = getHeadroom(iSys, isEmit, Q2MaxNow);
3451 if (sectorShower && isEmit) {
3452 if (ibrancher->colType0() == 2) headroomVec[0] *= 5;
3453 if (ibrancher->colType1() == 2) headroomVec[0] *= 5;
3455 vector<double> enhanceVec = getEnhance(iSys, isEmit, Q2MaxNow);
3456 double Q2NextWindow = ibrancher->genQ2(evType, Q2MaxNow, rndmPtr,
3457 windowPtr, colFac, headroomVec, enhanceVec, verbose);
3458 if (Q2NextWindow < 0.) {
3459 infoPtr->setAbortPartonLevel(
true);
3462 if (verbose >= superdebug) {
3464 ss <<
"Generated QNextWindow = " << sqrt(Q2NextWindow)
3465 <<
" (QMinWindow = " << itWindowNow->first <<
" )";
3466 printOut(__METHOD_NAME__, ss.str());
3470 if (Q2NextWindow > Q2MinWindow || Q2NextWindow <= 0.) {
3471 q2Next=Q2NextWindow;
3474 if (verbose >= superdebug) printOut(__METHOD_NAME__,
3475 "QNext below window threshold. Continuing to next window.");
3478 Q2MaxNow = Q2MinWindow;
3482 if (verbose >= superdebug && itWindowNow == evWindows.rend())
3483 printOut(__METHOD_NAME__,
"Out of windows. Continuing to "
3488 if (q2Next > q2WinSav && q2Next > q2End) {
3490 winnerPtr = &(*ibrancher);
3501 bool VinciaFSR::branchQED(
Event& event) {
3504 if (verbose >= debug) printOut(__METHOD_NAME__,
"begin --------------");
3505 int sizeOld =
event.size();
3506 bool updated =
false;
3507 if (qedShowerPtr->checkVeto(event)) {
3508 if (verbose >= debug)
3509 printOut(__METHOD_NAME__,
"QED trial accepted. About to update.");
3510 qedShowerPtr->update(event, qedShowerPtr->sysWin());
3513 if (!vinComPtr->checkCoM(qedShowerPtr->sysWin(),event,partonSystemsPtr)) {
3514 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3515 +
": Failed (E,p) conservation check.");
3516 infoPtr->setAbortPartonLevel(
true);
3521 updated = updateAfterQED(event, sizeOld);
3524 if (verbose > quiteloud) {
3525 if (partonSystemsPtr->hasInAB(iSysWin)) {
3526 int inA = partonSystemsPtr->getInA(iSysWin);
3527 int inB = partonSystemsPtr->getInB(iSysWin);
3528 if (inA <= 0 || inB <= 0 ) {
3530 ss <<
"iSysWin = "<<iSysWin <<
" non-positive. inA = "<< inA
3531 <<
" inB = " << inB;
3532 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3533 +
": Non-positive incoming parton.", ss.str());
3534 infoPtr->setAbortPartonLevel(
true);
3536 }
else if (event[inA].mother1() > 2 || event[inB].mother1() > 2) {
3538 ss <<
"iSysWin = "<<iSysWin;
3539 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3540 +
": Failed to update incoming particles after QED branching.",
3542 infoPtr->setAbortPartonLevel(
true);
3550 if (verbose >= debug) printOut(__METHOD_NAME__,
"QED trial failed.");
3555 pTLastAcceptedSav = sqrt(qedShowerPtr->q2Trial);
3556 if (verbose >= debug) printOut(__METHOD_NAME__,
"end --------------");
3565 bool VinciaFSR::rejectEarly(AntennaFunction* &antFunPtr,
bool doMEC) {
3568 if (winnerPtr->getBranchType() < 0) {
3569 if (verbose >= veryloud)
3570 printOut(__METHOD_NAME__,
"WARNING: could not identify branching type.");
3574 if (doDiagnostics) diagnosticsPtr->setBranchType(winnerPtr->getBranchType());
3582 if (winnerPtr->enhanceFac() > 1.0 &&
3583 winnerPtr->q2Trial() <= pow2(enhanceCutoff)) {
3584 if (rndmPtr->flat() > 1./winnerPtr->enhanceFac()) {
3585 if (verbose >= debug) printOut(__METHOD_NAME__,
3586 "Trial rejected (enhance applied below enhanceCutoff)");
3590 winnerPtr->resetEnhanceFac(1.0);
3595 vector<double> invariants;
3596 if (!winnerPtr->genInvariants(invariants, rndmPtr, verbose)) {
3597 if (verbose >= debug)
3598 printOut(__METHOD_NAME__,
"Trial rejected (failed genInvariants)");
3599 if (doDiagnostics) diagnosticsPtr->checkInvariants(
3600 iSysWin,winnerPtr->iAntPhys(), winnerPtr->getInvariants(),
false);
3601 ++nFailedHull[iAntWin];
3604 if (doDiagnostics) diagnosticsPtr->checkInvariants(iSysWin,
3605 winnerPtr->iAntPhys(), invariants,
true);
3609 if (iAntWin == iGXsplitFF && winnerPtr->idNew() <= nFlavZeroMass) {
3613 if (invariants[1] < facM*pow2(particleDataPtr->m0(winnerPtr->idNew()))) {
3614 ++nFailedMass[iAntWin];
3620 double antPhys = getAntPhys(antFunPtr);
3622 pAccept[0]=pAcceptCalc(antPhys);
3624 if (doDiagnostics) diagnosticsPtr->checkpAccept(iSysWin, pAccept[0]);
3629 double R = rndmPtr->flat();
3630 if (R > pAccept[0]) {
3635 if (verbose >= debug)
3636 printOut(__METHOD_NAME__,
"Trial rejected (failed R<pAccept)");
3637 ++nFailedVeto[iAntWin];
3654 double VinciaFSR::getAntPhys(AntennaFunction* &antFunPtr) {
3657 antFunPtr= getAnt(iAntWin);
3658 if (antFunPtr->chargeFac() <= 0.) {
3659 if (verbose >= veryloud)
3660 printOut(__METHOD_NAME__,
"Trial rejected (chargeFac <= 0)");
3663 bool isEmit = (iAntWin == iQQemitFF || iAntWin == iQGemitFF ||
3664 iAntWin == iGQemitFF || iAntWin == iGGemitFF ||
3665 iAntWin == iQQemitRF || iAntWin == iQGemitRF);
3672 double alphaSNow = alphaSmax;
3673 if (alphaSorder >= 1) {
3674 double mu2 = getMu2(isEmit);
3675 AlphaStrong * alphaSptr = aSemitPtr;
3676 if(!isEmit) alphaSptr = aSsplitPtr;
3677 alphaSNow = min(alphaSmax, alphaSptr->alphaS(mu2));
3683 vector<double> mPost = winnerPtr->getmPostVec();
3684 vector<double> invariants = winnerPtr->getInvariants();
3685 unsigned int nPre = winnerPtr->iVec().size();
3686 vector<int> hPre = ( helicityShower && polarisedSys[iSysWin] ) ?
3687 winnerPtr->hVec() : vector<int>(nPre, 9);
3688 vector<int> hPost(nPre+1,9);
3689 double antPhys = antFunPtr->antFun(invariants, mPost, hPre, hPost);
3691 if (verbose > normal) infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3692 +
": Negative Antenna Function.", num2str(iAntWin));
3695 antPhys *= antFunPtr->chargeFac();
3698 if (doDiagnostics) diagnosticsPtr->checkAnt(iSysWin, antPhys);
3708 double VinciaFSR::pAcceptCalc(
double antPhys) {
3709 double prob = winnerPtr->pAccept(antPhys,verbose);
3710 if (verbose >= louddebug)
3711 printOut(__METHOD_NAME__,
"Shower pAccept = " + num2str(prob));
3719 bool VinciaFSR::genFullKinematics(
int kineMap,
Event event,
3720 vector<Vec4> &pPost) {
3724 vector<int> iPre = winnerPtr->iVec();
3725 int nPre = iPre.size();
3726 int nPost = winnerPtr->iVec().size() + 1;
3727 vector<double> invariants = winnerPtr->getInvariants();
3728 vector<double> mPost = winnerPtr->getmPostVec();
3729 int branchType = winnerPtr->getBranchType();
3730 double phi = 2 * M_PI * rndmPtr->flat();
3731 for (
int i = 0; i < nPre; ++i) pPre.push_back(event[iPre[i]].p());
3734 if (branchType == 5 || branchType == 6) {
3735 if (!vinComPtr->map2toNRFmassive(pPost, pPre, winnerPtr->posR(),
3736 winnerPtr->posF(), invariants,phi,mPost)) {
3737 if (verbose >= debug)
3738 printOut(__METHOD_NAME__,
"Trial rejected (failed map2toNRF)");
3739 ++nFailedKine[iAntWin];
3744 if (nPre == 2 && nPost == 3) {
3745 if (!vinComPtr->map2to3FF(pPost, pPre, kineMap, invariants, phi,
3747 if (verbose >= debug)
3748 printOut(__METHOD_NAME__,
"Trial rejected (failed map2to3)");
3749 ++nFailedKine[iAntWin];
3753 }
else if (nPre == 2 && nPost == 4) {
3754 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3755 +
": 2->4 kinematics map not implemented yet.");
3758 }
else if (nPre == 3 && nPost == 4) {
3759 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3760 +
": 3->4 kinematics map not implemented yet.");
3772 bool VinciaFSR::acceptTrial(
Event& event) {
3773 bool accept =
false;
3774 bool doMEC = doMECsSys[iSysWin];
3775 AntennaFunction* antFunPtr;
3779 if (rejectEarly(antFunPtr,doMEC))
return accept;
3780 if (!getNewParticles(event,antFunPtr,pNew))
return accept;
3784 vector<Particle> stateNew;
3785 stateNew = mecsPtr->makeParticleList(iSysWin,event,pNew,winnerPtr->iVec());
3786 double q2sector = resolutionPtr->q2sector2to3(&pNew[0],&pNew[2],&pNew[1]);
3787 vector<int> iSctDum;
3788 if (q2sector > resolutionPtr->findSector(iSctDum, stateNew)) {
3789 ++nSectorReject[iAntWin];
3795 vector<Particle> stateOld;
3796 if (!isrPtr->checkHeavyQuarkPhaseSpace(stateOld,iSysWin)) {
3797 stateOld = mecsPtr->makeParticleList(iSysWin, event);
3798 if (verbose >= debug) printOut(__METHOD_NAME__,
"Trial rejected (failed "
3799 "checkHeavyQuarkPhaseSpace)");
3801 ++nClosePSforHQ[iAntWin];
3809 if (doMEC) pAccept[0] *= pMEC;
3813 int nQbef(0), nGbef(0), nBbef(0);
3814 for (
int i = 0; i < partonSystemsPtr->sizeOut(iSysWin); ++i) {
3815 if (event[partonSystemsPtr->getOut(iSysWin,i)].id() == 21) ++nGbef;
3816 else if (event[partonSystemsPtr->getOut(iSysWin,i)].idAbs() <= 4) ++nQbef;
3817 else if (event[partonSystemsPtr->getOut(iSysWin,i)].idAbs() == 5) ++nBbef;
3821 if (verbose >= quiteloud || (verbose >= normal && doMEC)) {
3823 if (nQbef >= 1) state += num2str(nQbef,1) +
"q";
3824 if (nBbef >= 1) state += num2str(nBbef,1) +
"b";
3825 if (nGbef >= 1) state += num2str(nBbef,1) +
"g";
3826 if (pNew[1].colType() == 2) state +=
"Emit";
3827 else if (pNew[1].colType() == -1) state +=
"SplitA";
3828 else if (pNew[1].colType() == 1) state +=
"SplitB";
3829 string HPacc =
"Log10(ME/AntTrial):" + state;
3830 if (vinciaHistos.find(HPacc) != vinciaHistos.end())
3831 vinciaHistos[HPacc].fill(log10(max(TINY,pAccept[0])));
3832 string HqTrial =
"Ln(q2trial/sSystem):" + state;
3833 if (vinciaHistos.find(HqTrial) != vinciaHistos.end())
3834 vinciaHistos[HqTrial].fill(
3835 log(max(TINY, q2WinSav/pow2(mSystem[iSysWin]))));
3839 if (doMEC && verbose >= verylouddebug) {
3841 ss <<
" MEC pAccept = " << pAccept[0];
3842 printOut(__METHOD_NAME__, ss.str());
3844 if (verbose >= loud ) {
3845 bool violation = (pAccept[0] > 1.0 + TINY);
3846 bool negPaccept = (pAccept[0] < 0.0);
3847 if (violation) infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3849 if (negPaccept) infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3852 if ((violation || negPaccept) && verbose > debug) winnerPtr->list();
3858 const double enhanceFac = winnerPtr->enhanceFac();
3859 if (rndmPtr->flat() > min(1.0,enhanceFac)*pAccept[0]) {
3860 if (verbose >= debug) printOut(__METHOD_NAME__ ,
"Trial rejected at veto "
3861 "step. wPhys/wTrial = " + num2str(pAccept[0])
3862 +
" * enhanceFac = "+num2str(enhanceFac));
3865 if (enhanceFac != 1.0)
3866 weightsPtr->scaleWeightEnhanceReject(pAccept[0],enhanceFac);
3869 ++nFailedVeto[iAntWin];
3871 if (verbose >= louddebug) printOut(__METHOD_NAME__,
"Trial accepted.");
3874 if (enhanceFac != 1.0) weightsPtr->scaleWeightEnhanceAccept(enhanceFac);
3877 if (verbose >= 3 || (verbose >= 2 && doMEC)) {
3879 if (nQbef >= 1) state += num2str(nQbef,1) +
"q";
3880 if (nBbef >= 1) state += num2str(nBbef,1) +
"b";
3881 if (nGbef >= 1) state += num2str(nBbef,1) +
"g";
3882 if (pNew[1].colType() == 2) state +=
"Emit";
3883 else if (pNew[1].colType() == -1) state +=
"SplitA";
3884 else if (pNew[1].colType() == 1) state +=
"SplitB";
3885 string HqPhys =
"Ln(q2/sSystem):" + state;
3886 if (vinciaHistos.find(HqPhys) != vinciaHistos.end())
3887 vinciaHistos[HqPhys].fill(
3888 log(max(TINY, q2WinSav/pow2(mSystem[iSysWin]))));
3889 string HalphaS =
"alphaS:" + state;
3890 string HalphaSratio =
"alphaSratio:" + state;
3892 string HPacc =
"Log10(ME/AntPhys):" + state;
3893 if (vinciaHistos.find(HPacc) != vinciaHistos.end()) {
3894 vinciaHistos[HPacc].fill(log10(max(TINY,pMEC)));
3908 bool VinciaFSR::getNewParticles(
Event& event, AntennaFunction* antFunPtr,
3909 vector<Particle>& newParts) {
3912 if (antFunPtr ==
nullptr) {
3913 if (verbose >= normal)
3914 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3915 +
": antFunPtr is NULL pointer.");
3920 int maptype = antFunPtr->kineMap();
3921 if (!genFullKinematics(maptype, event, pPost)) {
3922 if (verbose >= debug)
3923 printOut(__METHOD_NAME__,
"Failed to generate kinematics");
3928 vector<int> hPost = genHelicities(antFunPtr);
3929 if (pPost.size() != hPost.size()) {
3930 if (verbose >= normal) {
3932 ss <<
" pPost.size() = "
3933 << pPost.size() <<
" hPost.size() = " << hPost.size();
3934 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
3935 +
": Wrong size containers.", ss.str());
3938 }
else if (!winnerPtr->getNewParticles(event, pPost, hPost, newParts,
3939 rndmPtr, colourPtr)) {
3940 if (verbose >= debug)
3941 printOut(__METHOD_NAME__,
"Failed to generate new particles");
3951 vector<int> VinciaFSR::genHelicities(AntennaFunction* antFunPtr) {
3953 vector<int> hPre = winnerPtr->hVec();
3954 vector<int> hPost = hPre;
3955 hPost.insert(hPost.begin() + 1, 9);
3956 if (hPost.size() >=3) {
3957 if (helicityShower && polarisedSys[iSysWin]) {
3958 vector<double> mPost = winnerPtr->getmPostVec();
3959 vector<double> invariants = winnerPtr->getInvariants();
3960 double helSum = antFunPtr->antFun(invariants, mPost, hPre, hPost);
3961 double randHel = rndmPtr->flat() * helSum;
3966 for(
int iHel = 0; iHel < 8; ++iHel) {
3967 hPost[0] = ( (iHel%2) )*2 -1;
3968 hPost[1] = ( (iHel/2)%2 )*2 -1;
3969 hPost[2] = ( (iHel/4)%2 )*2 -1;
3970 aHel = antFunPtr->antFun(invariants, mPost, hPre, hPost);
3972 if (verbose >= verylouddebug) printOut(__METHOD_NAME__,
"antPhys(" +
3973 num2str(
int(hPre[0])) +
" " + num2str(
int(hPre[1])) +
" -> " +
3974 num2str(hPost[0]) +
" " + num2str(hPost[1]) +
" " +
3975 num2str(hPost[2]) +
") = " + num2str(aHel) +
", m(IK,ij,jk) = " +
3976 num2str(sqrt(invariants[0])) +
", " +
3977 num2str(sqrt(invariants[1])) +
", " +
3978 num2str(sqrt(invariants[2])) +
"; sum = "+num2str(helSum));
3979 if (randHel < 0.)
break;
3982 diagnosticsPtr->checkAntHel(iSysWin, aHel, hPre, hPost);
3984 if (verbose >= louddebug)
3985 printOut(__METHOD_NAME__,
"selected"+num2str((
int)(hPre[0]))
3986 +
" " + num2str(
int(hPre[1])) +
" -> " + num2str(hPost[0]) +
" "
3987 + num2str(hPost[1]) +
" " + num2str(hPost[2]) +
"\n");
3997 bool VinciaFSR::updateEvent(
Event& event, resJunctionInfo& junctionInfoIn) {
3999 for (
unsigned int i = 0; i < pNew.size(); ++i) event.append(pNew[i]);
4000 map<int, pair<int,int> >::iterator it;
4001 for (it = winnerPtr->mothers2daughters.begin();
4002 it != winnerPtr->mothers2daughters.end(); ++it) {
4003 int mother = it->first;
4004 int daughter1 = (it->second).first;
4005 int daughter2 = (it->second).second;
4006 if (mother<event.size() && mother > 0) {
4007 event[mother].daughters(daughter1,daughter2);
4008 event[mother].statusNeg();
4009 }
else return false;
4013 for(it = winnerPtr->daughters2mothers.begin();
4014 it != winnerPtr->daughters2mothers.end(); ++it) {
4015 int daughter = it->first;
4016 int mother1 = (it->second).first;
4017 int mother2 = (it->second).second;
4018 if (daughter<event.size() && daughter > 0)
4019 event[daughter].mothers(mother1, mother2);
4024 if (winnerPtr->colTag() != 0) {
4025 int lastTag =
event.nextColTag();
4026 int colMax = winnerPtr->colTag();
4027 while (colMax > lastTag) lastTag =
event.nextColTag();
4029 iNewSav = winnerPtr->iNew();
4032 if (hasResJunction[iSysWin]) {
4033 vector<int>* colours = &junctionInfoIn.colours;
4034 if (!event[junctionInfoIn.iEndQuark].isQuark()) {
4035 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4036 +
": Can't update junction. iEndQuark is not a quark!");
4037 hasResJunction[iSysWin]=
false;
4042 int branchType = winnerPtr->getBranchType();
4043 if (branchType == 2 || branchType == 6) {
4044 int splitter = winnerPtr->i0();
4045 if(branchType == 6) splitter = winnerPtr->iVec().at(winnerPtr->posF());
4047 int colLeft =
event[splitter].col();
4049 vector<int>::iterator pos = find(colours->begin(), colours->end(),
4052 if (pos != colours->end()) {
4054 colours->erase(pos + 1, colours->end());
4056 int d1 =
event[splitter].daughter1();
4057 int d2 =
event[splitter].daughter2();
4058 if (event[d1].isQuark() && event[d1].col() > 0) {
4059 junctionInfoIn.iEndQuark = d1;
4060 junctionInfoIn.iEndColTag =
event[d1].col();
4061 }
else if(event[d2].isQuark() && event[d2].col() > 0) {
4062 junctionInfoIn.iEndQuark = d2;
4063 junctionInfoIn.iEndColTag =
event[d2].col();
4066 event.endColJunction(junctionInfoIn.iJunction, junctionInfoIn.iEndCol,
4067 junctionInfoIn.iEndColTag);
4069 }
else if (branchType == 1 || branchType == 5){
4071 int iNew = winnerPtr->iNew();
4074 int iRad =
event[iNew].mother1();
4075 if(branchType == 1) {
4077 int m2 =
event[iNew].mother2();
4080 int m2after=
event[m2].daughter1();
4081 if (m2after==iNew) m2after =
event[m2].daughter2();
4084 int colBef =
event[m2].col();
4085 int acolBef =
event[m2].acol();
4086 int colAfter =
event[m2after].col();
4087 int acolAfter =
event[m2after].acol();
4088 if(colBef != colAfter || acolBef != acolAfter) iRad = m2;
4094 int colLeft =
event[iRad].col();
4095 if (event[iNew].col() == colLeft) colNew =
event[iNew].acol();
4096 else colNew =
event[iNew].col();
4098 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4099 +
": Couldn't find colour for updating junction info.");
4104 vector<int>::iterator pos = find(colours->begin(), colours->end(),
4106 if (pos!=colours->end()) colours->insert(pos+1,colNew);
4109 int iEndQuark = junctionInfoIn.iEndQuark;
4110 if (!event[iEndQuark].isFinal()) {
4111 int d1 =
event[iEndQuark].daughter1();
4112 int d2 =
event[iEndQuark].daughter2();
4113 if (event[d1].isQuark() && event[d1].col() > 0) {
4114 junctionInfoIn.iEndQuark = d1;
4115 junctionInfoIn.iEndColTag =
event[d1].col();
4116 }
else if (event[d2].isQuark() && event[d2].col() > 0) {
4117 junctionInfoIn.iEndQuark = d2;
4118 junctionInfoIn.iEndColTag =
event[d2].col();
4120 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4121 +
": Couldn't update junction.");
4125 event.endColJunction(junctionInfoIn.iJunction,
4126 junctionInfoIn.iEndCol, junctionInfoIn.iEndColTag);
4130 if (verbose >= louddebug) {
4131 printOut(__METHOD_NAME__,
"Succesfully updated event after emission.");
4142 void VinciaFSR::updatePartonSystems() {
4145 if (verbose >= verylouddebug) {
4146 printOut(__METHOD_NAME__,
"Parton systems before update: ");
4147 partonSystemsPtr->list();
4151 vector<int> newpartons;
4152 for (map<
int, pair<int,int> >::iterator it =
4153 winnerPtr->mothers2daughters.begin();
4154 it != winnerPtr->mothers2daughters.end(); ++it) {
4155 int mother = it->first;
4156 int daughter1 = (it->second).first;
4157 int daughter2 = (it->second).second;
4159 if (daughter1 == daughter2 && daughter1 != 0 && daughter2 != 0) {
4160 partonSystemsPtr->replace(iSysWin, mother, daughter1);
4161 newpartons.push_back(daughter1);
4164 else if (daughter1 != daughter2 && daughter1 != 0 && daughter2 != 0) {
4166 bool found1 =
false;
4167 bool found2 =
false;
4168 vector<int>::iterator findit = find(newpartons.begin(), newpartons.end(),
4170 if (findit != newpartons.end()) found1 =
true;
4171 findit = find(newpartons.begin(), newpartons.end(), daughter2);
4172 if (findit != newpartons.end()) found2=
true;
4174 if (found1 && found2)
continue;
4176 else if (found1 && !found2) {
4177 partonSystemsPtr->replace(iSysWin, mother, daughter2);
4178 newpartons.push_back(daughter2);
4180 }
else if (!found1 && found2) {
4181 partonSystemsPtr->replace(iSysWin, mother, daughter1);
4182 newpartons.push_back(daughter1);
4186 partonSystemsPtr->replace(iSysWin, mother, daughter1);
4187 partonSystemsPtr->addOut(iSysWin, daughter2);
4188 newpartons.push_back(daughter1);
4189 newpartons.push_back(daughter2);
4193 if (verbose >= verylouddebug) {
4194 printOut(__METHOD_NAME__,
"Parton systems after update: ");
4195 partonSystemsPtr->list();
4204 void VinciaFSR::saveEmitter(
int iSysIn,
Event& event,
int i0,
int i1) {
4205 if (event[i0].col() == event[i1].acol()) {
4206 emitters.push_back(BrancherEmitFF(iSysIn,event,i0,i1));
4207 lookupBrancherFF[make_pair(i0,
true)]=(emitters.size()-1);
4208 lookupBrancherFF[make_pair(i1,
false)]=(emitters.size()-1);
4216 void VinciaFSR::saveResEmitter(
int iSysIn,
Event& event, vector<int> allIn,
4217 unsigned int posResIn,
unsigned int posFIn,
bool colMode) {
4219 int iRes = allIn[posResIn];
4220 if (kMapResEmit == 2 && allIn.size() > 3) {
4223 int iRad = allIn[posFIn];
4225 int d1 =
event[iRes].daughter1();
4226 int d2 =
event[iRes].daughter2();
4231 if (event[d1].col() > 0 && event[iRes].col() == event[d1].col())
4232 iRec =
event[d2].iBotCopy();
4234 else iRec =
event[d1].iBotCopy();
4237 if(event[d1].acol() > 0 && event[iRes].acol() == event[d1].acol() )
4238 iRec =
event[d2].iBotCopy();
4240 else iRec =
event[d1].iBotCopy();
4242 allIn.push_back(iRes);
4243 allIn.push_back(iRad);
4244 allIn.push_back(iRec);
4251 if (!colMode) iRes *= -1;
4254 BrancherEmitRF temp(iSysIn,event,allIn,posResIn,posFIn,q2CutoffEmit);
4255 resEmitters.push_back(temp);
4256 lookupBrancherRF[make_pair(iRes,
true)]=(resEmitters.size() - 1);
4257 lookupBrancherRF[make_pair(allIn[posFIn],
false)]=(resEmitters.size() - 1);
4265 void VinciaFSR::saveResSplitter(
int iSysIn,
Event& event, vector<int> allIn,
4266 unsigned int posResIn,
unsigned int posFIn,
bool colMode) {
4268 int iRes = allIn[posResIn];
4269 if (kMapResSplit == 2 && allIn.size() > 3) {
4272 int iRad = allIn[posFIn];
4274 int d1 =
event[iRes].daughter1();
4275 int d2 =
event[iRes].daughter2();
4280 if(event[d1].col() > 0 && event[iRes].col() == event[d1].col())
4281 iRec =
event[d2].iBotCopy();
4283 else iRec =
event[d1].iBotCopy();
4286 if(event[d1].acol() > 0 && event[iRes].acol() == event[d1].acol())
4287 iRec =
event[d2].iBotCopy();
4289 else iRec =
event[d1].iBotCopy();
4291 allIn.push_back(iRes);
4292 allIn.push_back(iRad);
4293 allIn.push_back(iRec);
4300 if (!colMode) iRes*=-1;
4301 BrancherSplitRF temp(iSysIn,event,allIn,posResIn,posFIn,q2CutoffSplit);
4302 resSplitters.push_back(temp);
4303 lookupSplitterRF[make_pair(iRes,
true)]=(resSplitters.size() -1);
4304 lookupSplitterRF[make_pair(allIn[posFIn],
false)]=(resSplitters.size() -1);
4312 void VinciaFSR::saveSplitter(
int iSysIn,
Event& event,
int i0,
int i1,
4314 BrancherSplitFF temp(iSysIn, event, i0, i1, col2acol);
4315 splitters.push_back(temp);
4316 if (event[i0].isGluon()) {
4319 lookupSplitter[make_pair(i0,
true)]=(splitters.size()-1);
4320 lookupSplitter[make_pair(i1,
false)]=(splitters.size()-1);
4323 lookupSplitter[make_pair(-i0,
true)]=(splitters.size()-1);
4324 lookupSplitter[make_pair(-i1,
false)]=(splitters.size()-1);
4333 template <
class Brancher>
void VinciaFSR::updateBranchers(
4334 vector<Brancher>& brancherVec, map<pair<int, bool>,
4335 unsigned int>& lookupBrancher,
Event& event,
int iOld,
int iNew) {
4337 pair<int,bool> key = make_pair(iOld,
true);
4338 if (lookupBrancher.find(key) != lookupBrancher.end()) {
4339 unsigned int pos = lookupBrancher[key];
4340 int iRec = brancherVec[pos].i1();
4341 int iSysNow = brancherVec[pos].system();
4342 brancherVec[pos].reset(iSysNow, event, abs(iNew), iRec);
4343 lookupBrancher.erase(key);
4344 lookupBrancher[make_pair(iNew,
true)] = pos;
4346 key = make_pair(iOld,
false);
4347 if (lookupBrancher.find(key) != lookupBrancher.end()) {
4348 unsigned int pos = lookupBrancher[key];
4349 int iEmit = brancherVec[pos].i0();
4350 int iSysNow = brancherVec[pos].system();
4351 brancherVec[pos].reset(iSysNow, event, iEmit, abs(iNew));
4352 lookupBrancher.erase(key);
4353 lookupBrancher[make_pair(iNew,
false)]=pos;
4362 template <
class Brancher>
void VinciaFSR::updateBrancher(
4363 vector<Brancher>& brancherVec, map<pair<int, bool>,
4364 unsigned int>& lookupBrancher,
Event& event,
int iOld1,
int iOld2,
4365 int iNew1,
int iNew2) {
4367 pair<int,bool> key1 = make_pair(iOld1,
true);
4368 pair<int,bool> key2 = make_pair(iOld2,
false);
4369 if (lookupBrancher.find(key1) != lookupBrancher.end()) {
4370 unsigned int pos = lookupBrancher[key1];
4371 if (lookupBrancher.find(key2) != lookupBrancher.end()) {
4372 unsigned int pos2=lookupBrancher[key2];
4374 lookupBrancher.erase(key1);
4375 lookupBrancher.erase(key2);
4376 int iSysNow = brancherVec[pos].system();
4377 brancherVec[pos].reset(iSysNow, event, abs(iNew1), abs(iNew2));
4378 lookupBrancher[make_pair(iNew1,
true)]=pos;
4379 lookupBrancher[make_pair(iNew2,
false)]=pos;
4390 void VinciaFSR::updateEmitters(
Event& event,
int iOld,
int iNew){
4391 updateBranchers<BrancherEmitFF>(emitters,lookupBrancherFF,event,iOld,iNew);
4398 void VinciaFSR::updateEmitter(
Event& event,
int iOld1,
int iOld2,
4399 int iNew1,
int iNew2) {
4400 updateBrancher<BrancherEmitFF>(emitters, lookupBrancherFF, event,
4401 iOld1, iOld2, iNew1, iNew2);
4408 void VinciaFSR::updateSplitters(
Event& event,
int iOld,
int iNew) {
4409 updateBranchers<BrancherSplitFF>(splitters, lookupSplitter, event,
4411 updateBranchers<BrancherSplitFF>(splitters, lookupSplitter, event,
4419 void VinciaFSR::updateSplitter(
Event& event,
int iOld1,
int iOld2,
int iNew1,
4420 int iNew2,
bool col2acol) {
4421 if (col2acol) updateBrancher<BrancherSplitFF>(splitters, lookupSplitter,
4422 event, iOld1, iOld2, iNew1, iNew2);
4423 else updateBrancher<BrancherSplitFF>(splitters, lookupSplitter, event,
4424 -iOld1, -iOld2, -iNew1, -iNew2);
4431 void VinciaFSR::removeSplitter(
int iRemove) {
4433 for (
int isign = 0; isign < 2; isign++) {
4434 int sign = 1 - 2*isign;
4435 pair<int,bool> key = make_pair(sign*iRemove,
true);
4438 if (lookupSplitter.find(key) != lookupSplitter.end()) {
4439 unsigned int pos = lookupSplitter[key];
4440 lookupSplitter.erase(key);
4441 int iRec = splitters[pos].i1();
4442 pair<int,bool> recoilkey = make_pair(sign*iRec,
false);
4443 if (lookupSplitter.find(recoilkey) != lookupSplitter.end())
4444 lookupSplitter.erase(recoilkey);
4445 if (pos < splitters.size()) {
4446 splitters.erase(splitters.begin()+pos);
4449 for(; pos < splitters.size(); pos++) {
4451 BrancherSplitFF splitter = splitters.at(pos);
4453 int i0(splitter.i0()), i1(splitter.i1());
4455 if (!splitter.isXG()){
4456 lookupSplitter[make_pair(i0,
true)]=pos;
4457 lookupSplitter[make_pair(i1,
false)]=pos;
4459 lookupSplitter[make_pair(-i0,
true)]=pos;
4460 lookupSplitter[make_pair(-i1,
false)]=pos;
4473 bool VinciaFSR::updateResBranchers(
int iSysRes,
Event& event,
int iRes) {
4475 if (verbose >= verylouddebug)
4476 printOut(__METHOD_NAME__,
"begin --------------");
4480 int resCol =
event[iRes].col();
4481 int resACol =
event[iRes].acol();
4482 int colPartner = -1;
4483 int acolPartner = -1;
4484 vector<int> daughters;
4487 int sizeOut = partonSystemsPtr->sizeOut(iSysRes);
4488 for (
int iDecPart = 0; iDecPart < sizeOut; iDecPart++) {
4489 int iOut = partonSystemsPtr->getOut(iSysRes,iDecPart);
4492 if (event[iOut].col() != 0 && event[iOut].col() == resCol)
4494 if (event[iOut].acol() != 0 && event[iOut].acol() == resACol)
4496 if (iOut != colPartner && iOut != acolPartner)
4497 daughters.push_back(iOut);
4499 if (verbose >= verylouddebug) {
4501 ss <<
"col partner = " << colPartner <<
" acol partner = " << acolPartner;
4502 printOut(__METHOD_NAME__,ss.str());
4505 if (colPartner > 0) {
4507 vector<int> resSysAll = daughters;
4508 if (acolPartner != colPartner && acolPartner > 0)
4509 resSysAll.push_back(acolPartner);
4511 resSysAll.insert(resSysAll.begin(),colPartner);
4512 resSysAll.insert(resSysAll.begin(),iRes);
4513 unsigned int posRes(0), posPartner(1);
4514 updateResBranchers(iSysRes,event,resSysAll,posRes,posPartner,
true);
4516 if (acolPartner > 0) {
4518 vector<int> resSysAll = daughters;
4519 if (acolPartner != colPartner && colPartner > 0)
4520 resSysAll.push_back(colPartner);
4522 resSysAll.insert(resSysAll.begin(),acolPartner);
4523 resSysAll.insert(resSysAll.begin(),iRes);
4524 unsigned int posRes(0), posPartner(1);
4525 updateResBranchers(iSysRes,event,resSysAll,posRes,posPartner,
false);
4527 if (verbose >= verylouddebug)
4528 printOut(__METHOD_NAME__,
"end --------------");
4538 void VinciaFSR::updateResBranchers(
int iSysRes,
Event& event,
4539 vector<int> resSysAll,
unsigned int posRes,
unsigned int posPartner,
4542 if (posRes >= resSysAll.size() || posPartner >= resSysAll.size()) {
4543 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__+
": Invalid positions.");
4544 infoPtr->setAbortPartonLevel(
true);
4547 int iRes = resSysAll[posRes];
4548 int iPartner = resSysAll[posPartner];
4549 int posREmit = posRes;
4550 int posFEmit = posPartner;
4551 int posRSplit = posRes;
4552 int posFSplit = posPartner;
4553 vector<int> resSysAllEmit;
4554 vector<int> resSysAllSplit;
4557 if (kMapResEmit == 2 && resSysAll.size() > 3) {
4560 int d1 =
event[iRes].daughter1();
4561 int d2 =
event[iRes].daughter2();
4566 if (event[d1].col() > 0 && event[iRes].col() == event[d1].col())
4567 iRec =
event[d2].iBotCopy();
4569 else iRec =
event[d1].iBotCopy();
4572 if (event[d1].acol() > 0 && event[iRes].acol() == event[d1].acol())
4573 iRec =
event[d2].iBotCopy();
4575 else iRec =
event[d1].iBotCopy();
4577 resSysAllEmit.push_back(iRes);
4578 resSysAllEmit.push_back(iPartner);
4579 resSysAllEmit.push_back(iRec);
4582 }
else resSysAllEmit = resSysAll;
4583 if (kMapResSplit == 2) {
4584 resSysAllSplit = resSysAllEmit;
4587 }
else resSysAllSplit = resSysAll;
4588 if (!isCol) iRes*=-1;
4592 pair<int,bool> branchkey = make_pair(iRes,
true);
4593 if (lookupBrancherRF.find(branchkey) != lookupBrancherRF.end()) {
4594 unsigned int pos =lookupBrancherRF[branchkey];
4595 int iRec = (resEmitters[pos].iVec())[resEmitters[pos].posF()];
4596 pair<int,bool> recoilkey=make_pair(iRec,
false);
4598 if (lookupBrancherRF.find(recoilkey) != lookupBrancherRF.end())
4599 lookupBrancherRF.erase(recoilkey);
4601 resEmitters[pos].resetResBrancher(iSysRes, event, resSysAllEmit, posREmit,
4602 posFEmit,q2CutoffEmit);
4604 recoilkey = make_pair(iPartner,
false);
4605 lookupBrancherRF[recoilkey] = pos;
4609 if (lookupSplitterRF.find(branchkey) != lookupSplitterRF.end()){
4610 unsigned int pos = lookupSplitterRF[branchkey];
4611 int iSplit = (resSplitters[pos].iVec())[resSplitters[pos].posF()];
4612 pair<int,bool> splitkey=make_pair(iSplit,
false);
4615 if (lookupSplitterRF.find(splitkey) != lookupSplitterRF.end())
4616 lookupSplitterRF.erase(splitkey);
4619 if (!event[iPartner].isGluon()) {
4620 lookupSplitterRF.erase(branchkey);
4621 resSplitters.erase(resSplitters.begin()+pos);
4623 for (
unsigned int ipos = pos; ipos < resSplitters.size(); ipos++) {
4624 BrancherSplitRF splitter = resSplitters.at(ipos);
4625 int itmpSplit = (resSplitters[ipos].iVec())[resSplitters[ipos].posF()];
4627 lookupSplitterRF[make_pair(iRes,
true)] = ipos;
4628 lookupSplitterRF[make_pair(itmpSplit,
false)] = ipos;
4632 resSplitters[pos].resetResBrancher(iSysRes, event, resSysAllSplit,
4633 posRSplit, posFSplit, q2CutoffSplit);
4635 splitkey = make_pair(iPartner,
false);
4636 lookupSplitterRF[splitkey]=pos;
4639 }
else if (winnerPtr!=
nullptr) {
4640 if (winnerPtr->getBranchType()==5 &&
event[iPartner].isGluon())
4641 saveResSplitter(iSysRes,event,resSysAllSplit,posRSplit,posFSplit,isCol);
4650 bool VinciaFSR::updateAntennae(
Event& event) {
4652 if (verbose >= debug) {
4653 printOut(__METHOD_NAME__,
"begin --------------");
4654 if (verbose >= superdebug) printLookup();
4656 if (winnerPtr ==
nullptr) {
4657 if (verbose >= normal) infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4658 +
": winnerPtr is NULL");
4663 if (doQED) qedShowerPtr->update(event, iSysWin);
4666 int branchType = winnerPtr->getBranchType();
4667 if (branchType == 2) {
4669 int splitOld = winnerPtr->i0();
4670 int recOld = winnerPtr->i1();
4671 removeSplitter(splitOld);
4674 int iColSplit =
event[splitOld].daughter1();
4675 int iaColSplit =
event[splitOld].daughter2();
4676 if(event[iColSplit].col() == 0 && event[iaColSplit].acol() == 0 &&
4677 event[iColSplit].acol() != 0 && event[iaColSplit].col() != 0) {
4678 iColSplit =
event[splitOld].daughter2();
4679 iaColSplit =
event[splitOld].daughter1();
4683 int iColPartner = 0;
4684 int iaColPartner = 0;
4685 pair<int,bool> testkey = make_pair(splitOld,
true);
4686 if (lookupBrancherFF.find(testkey) != lookupBrancherFF.end()) {
4687 int iTest = emitters[lookupBrancherFF[testkey]].i1();
4688 if(event[iTest].acol() == event[splitOld].col()) iaColPartner = iTest;
4690 testkey = make_pair(splitOld,
false);
4691 if (lookupBrancherFF.find(testkey) != lookupBrancherFF.end()) {
4692 int iTest = emitters[lookupBrancherFF[testkey]].i0();
4693 if (event[iTest].col() == event[splitOld].acol()) iColPartner = iTest;
4697 updateSplitter(event,iaColPartner,splitOld,iaColPartner,iColSplit,
false);
4698 updateSplitter(event,iColPartner,splitOld,iColPartner,iaColSplit,
true);
4699 updateEmitter(event,iColPartner,splitOld,iColPartner,iaColSplit);
4700 updateEmitter(event,splitOld,iaColPartner,iColSplit,iaColPartner);
4703 int recNew =
event[recOld].daughter1();
4704 updateSplitters(event,recOld,recNew);
4705 updateEmitters(event,recOld,recNew);
4709 else if (branchType == 1) {
4711 int iOld1 = winnerPtr->i0();
4712 int iOld2 = winnerPtr->i1();
4713 int iNew1 =
event[iOld1].daughter1();
4714 int iNew2 =
event[iOld1].daughter2();
4715 int iNew3 =
event[iOld2].daughter1();
4718 if (iNew3 == iNew1) {
4721 iNew3=
event[iOld2].daughter2();
4722 }
else if (iNew3 == iNew2) iNew3=
event[iOld2].daughter2();
4726 if (event[iOld1].col() == event[iNew1].col()) {
4727 updateEmitter(event,iOld1,iOld2,iNew1,iNew2);
4728 if(event[iNew2].col() == event[iNew3].acol())
4729 saveEmitter(iSysWin,event,iNew2,iNew3);
4732 updateEmitter(event,iOld1,iOld2,iNew2,iNew3);
4733 if(event[iNew1].col()==event[iNew2].acol())
4734 saveEmitter(iSysWin,event,iNew1,iNew2);
4736 if (event[iNew1].isGluon())
4737 updateSplitter(event,iOld1,iOld2,iNew1,iNew2,
true);
4738 if (event[iNew3].isGluon())
4739 updateSplitter(event,iOld2,iOld1,iNew3,iNew2,
false);
4742 if (event[iNew2].isGluon()) {
4743 saveSplitter(iSysWin,event,iNew2,iNew3,
true);
4744 saveSplitter(iSysWin,event,iNew2,iNew1,
false);
4749 updateEmitters(event,iOld1,iNew1);
4750 updateEmitters(event,iOld2,iNew3);
4751 updateSplitters(event,iOld1,iNew1);
4752 updateSplitters(event,iOld2,iNew3);
4755 }
else if (branchType == 5 || branchType == 6) {
4757 for (map<
int, pair<int, int> >::iterator it =
4758 winnerPtr->mothers2daughters.begin();
4759 it!= winnerPtr->mothers2daughters.end(); ++it){
4760 int mother = it->first;
4761 int daughter1 = (it->second).first;
4762 int daughter2 = (it->second).second;
4764 if (daughter1 == daughter2) {
4765 updateEmitters(event,mother,daughter1);
4766 updateSplitters(event,mother,daughter1);
4771 if (branchType == 5 && event[daughter1].isGluon()) {
4772 if (event[daughter1].col()==event[daughter2].acol())
4773 saveEmitter(iSysWin,event,daughter1,daughter2);
4774 else if(event[daughter1].acol()==event[daughter2].col())
4775 saveEmitter(iSysWin,event,daughter2,daughter1);
4777 bool col2acol =
false;
4778 if (event[daughter1].col() == event[daughter2].acol())
4780 saveSplitter(iSysWin,event,daughter1,daughter2,col2acol);
4781 updateEmitters(event,mother,daughter2);
4782 updateSplitters(event,mother,daughter2);
4784 }
else if (branchType == 6 && event[mother].isGluon()
4785 && !event[daughter1].isGluon() && !event[daughter2].isGluon()) {
4786 removeSplitter(mother);
4787 int iColSplit = daughter1;
4788 int iaColSplit = daughter2;
4789 if(event[mother].col() != event[daughter1].col()) {
4790 iColSplit = daughter2;
4791 iaColSplit = daughter1;
4795 int iColPartner(0), iaColPartner(0);
4796 pair<int,bool> testkey = make_pair(mother,
true);
4797 if (lookupBrancherFF.find(testkey) != lookupBrancherFF.end()) {
4798 int iTest = emitters[lookupBrancherFF[testkey]].i1();
4799 if (event[iTest].acol() == event[mother].col())
4802 testkey = make_pair(mother,
false);
4803 if (lookupBrancherFF.find(testkey) != lookupBrancherFF.end()) {
4804 int iTest = emitters[lookupBrancherFF[testkey]].i0();
4805 if (event[iTest].col() == event[mother].acol())
4811 updateSplitter(event, iaColPartner, mother, iaColPartner, iColSplit,
4813 updateSplitter(event, iColPartner, mother, iColPartner, iaColSplit,
4815 updateEmitter(event, iColPartner, mother, iColPartner, iaColSplit);
4816 updateEmitter(event, mother, iaColPartner, iColSplit, iaColPartner);
4826 if (isResonanceSys[iSysWin]) {
4827 if (!updateResBranchers(iSysWin, event,
4828 partonSystemsPtr->getInRes(iSysWin))){
4829 if (verbose >= normal)
4830 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4831 +
": Failed updateResEmitters.");
4835 if (verbose >= debug) {
4836 if (verbose >= louddebug) list();
4837 if (verbose >= superdebug) {
4839 if (!check(event)) {
4840 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4841 +
": Failed update antennae.");
4845 printOut(__METHOD_NAME__,
"end --------------");
4855 bool VinciaFSR::updateAfterQED(
Event& event,
int sizeOld) {
4857 if (verbose >= verylouddebug)
4858 printOut(__METHOD_NAME__,
"begin --------------");
4859 bool updated =
false;
4860 iSysWin = qedShowerPtr->sysWin();
4863 map<int,int> iOfCol, iOfAcol;
4867 vector<int> status51coloured;
4868 vector<pair<int,int> > colouredrecoilers;
4869 for (
int i = sizeOld; i <
event.size(); ++i) {
4870 int col =
event[i].col();
4871 int acol =
event[i].acol();
4872 if (col != 0) iOfCol[col] = i;
4873 if (acol != 0) iOfAcol[acol] = i;
4876 if (event[i].colType() != 0 && event[i].status() == 51)
4877 status51coloured.push_back(i);
4878 else if (event[i].colType() != 0 &&
4879 (event[i].status() == 52 || event[i].status() == 43 ||
4880 event[i].status() == 44)) {
4881 int moth =
event[i].mother1();
4882 if (moth > 0) colouredrecoilers.push_back(make_pair(moth, i ));
4886 if (status51coloured.size() == 2) {
4887 int i1 = status51coloured[0];
4888 int i2 = status51coloured[1];
4889 int iCol =
event[i1].colType() > 0 ? i1 : i2;
4890 int iAcol =
event[i1].colType() > 0 ? i2 : i1;
4894 if (qedShowerPtr->isTrialSplit) saveEmitter(iSysWin,event,iCol,iAcol);
4897 int moth1 =
event[i1].mother1();
4898 colouredrecoilers.push_back(make_pair(moth1, i1));
4899 int moth2 =
event[i2].mother1();
4900 colouredrecoilers.push_back(make_pair(moth2, i2));
4901 if(event[moth1].col() == event[moth2].acol())
4902 updateEmitter(event,moth1,moth2,i1,i2);
4904 }
else if (status51coloured.size() == 1) {
4905 int i1 = status51coloured[0];
4906 int moth1 =
event[i1].mother1();
4907 colouredrecoilers.push_back(make_pair(moth1, i1));
4908 }
else if (status51coloured.size() > 2){
4909 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4910 +
": Too many status 51 particles");
4911 infoPtr->setAbortPartonLevel(
true);
4916 for(vector<pair<int,int> >::iterator it = colouredrecoilers.begin();
4917 it!= colouredrecoilers.end(); ++it) {
4918 int recOld = it->first;
4919 int recNew = it->second;
4920 updateEmitters(event,recOld,recNew);
4921 updateSplitters(event,recOld,recNew);
4925 if (isResonanceSys[iSysWin]){
4926 if (!updateResBranchers(iSysWin, event,
4927 partonSystemsPtr->getInRes(iSysWin))) {
4928 if (verbose >= normal)
4929 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4930 +
": Failed updateResEmitters.");
4936 if (!check(event)) {
4937 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4938 +
": Failed update antennae.");
4940 if (verbose >= superdebug) printLookup();
4941 infoPtr->setAbortPartonLevel(
true);
4946 if (hasResJunction[iSysWin]) {
4947 int iEndQuark = junctionInfo[iSysWin].iEndQuark;
4948 if (!event[iEndQuark].isFinal()) {
4949 int d1 =
event[iEndQuark].daughter1();
4950 int d2 =
event[iEndQuark].daughter2();
4951 if (event[d1].isQuark() && event[d1].col() > 0)
4952 junctionInfo[iSysWin].iEndQuark = d1;
4953 else if(event[d2].isQuark() && event[d2].col() > 0)
4954 junctionInfo[iSysWin].iEndQuark = d2;
4956 infoPtr->errorMsg(
"Error in "+__METHOD_NAME__
4957 +
": Couldn't update junction information");
4962 if (verbose >= verylouddebug)
4963 printOut(__METHOD_NAME__,
"end --------------");
4973 void VinciaFSR::printLookup(map< pair<int, bool>,
unsigned int>
4974 lookupBrancher,
string name) {
4975 for (map< pair<int, bool>,
unsigned int >::iterator ilook =
4976 lookupBrancher.begin(); ilook != lookupBrancher.end(); ++ilook)
4977 cout <<
" lookup" << name <<
"[" << (ilook->first).first
4978 <<
"," << (ilook->first).second <<
"] = " << ilook->second << endl;
4985 void VinciaFSR::printLookup() {
4986 cout << endl <<
" --------" <<
" Brancher lookup maps"
4987 <<
" -------------------------------------------------------------"
4989 printLookup(lookupBrancherRF,
"BrancherRF");
4990 printLookup(lookupSplitterRF,
"SplitterRF");
4991 printLookup(lookupBrancherFF,
"BrancherFF");
4992 printLookup(lookupSplitter,
"SplitterFF");
4993 cout <<
" --------" <<
" End lookup "
4994 <<
" -------------------------------------------------------------"
5002 vector<double> VinciaFSR::getHeadroom(
int iSys,
bool isEmit,
double) {
5005 bool doUncert =
false;
5008 pair<int, pair<bool,bool> > headroomKey =
5009 make_pair(iSys,make_pair(isEmit,doUncert));
5010 if (headroomSav.find(headroomKey) != headroomSav.end())
5011 return headroomSav[headroomKey];
5015 vector<double> headroomVec;
5017 double headroomFac = 1.0;
5019 if (doMECsSys[iSys] && mecsPtr->doMEC(iSys,nBranch[iSys]+1)) {
5022 if (!isResonanceSys[iSys]) headroomFac *= 2.;
5024 if (helicityShower && polarisedSys[iSys]) headroomFac *= 1.5;
5026 if (doUncert) headroomFac *= 1.33;
5027 headroomVec.push_back(headroomFac);
5031 for (
int iFlav = 1; iFlav <= nGluonToQuark; ++iFlav) {
5032 double headroomFac = 1.0;
5034 if (sectorShower) headroomFac *= 2;
5036 if (iFlav > nFlavZeroMass) headroomFac *= 1.5;
5038 if (doMECsSys[iSys] && mecsPtr->doMEC(iSys,nBranch[iSys]+1)) {
5041 if (!isResonanceSys[iSys]) headroomFac *= 2.;
5043 if (helicityShower && polarisedSys[iSys]) headroomFac *= 2.;
5045 headroomVec.push_back(headroomFac);
5048 headroomSav[headroomKey] = headroomVec;
5058 vector<double> VinciaFSR::getEnhance(
int iSys,
bool isEmit,
double q2In) {
5060 bool doEnhance =
false;
5061 if (q2In > pow2(enhanceCutoff)) {
5062 if (isHardSys[iSys] && enhanceInHard) doEnhance =
true;
5063 else if (isResonanceSys[iSys] && enhanceInResDec) doEnhance =
true;
5064 else if (!isHardSys[iSys] && !isResonanceSys[iSys] &&
5065 partonSystemsPtr->hasInAB(iSys) && enhanceInMPI) doEnhance =
true;
5069 pair<int,pair<bool,bool> > enhanceKey =
5070 make_pair(iSys,make_pair(isEmit,doEnhance));
5071 vector<double> enhanceVec;
5072 if (enhanceSav.find(enhanceKey) != enhanceSav.end())
5073 enhanceVec = enhanceSav[enhanceKey];
5075 double enhanceFac = 1.0;
5078 if (doEnhance) enhanceFac *= enhanceAll;
5079 enhanceVec.push_back(enhanceFac);
5082 for (
int iFlav = 1; iFlav <= nGluonToQuark; ++iFlav) {
5084 enhanceFac = enhanceAll;
5086 if (iFlav == 4) enhanceFac *= enhanceCharm;
5087 else if (iFlav == 5) enhanceFac *= enhanceBottom;
5089 enhanceVec.push_back(enhanceFac);
5092 enhanceSav[enhanceKey] = enhanceVec;