10 #include "Pythia8/History.h"
26 void Clustering::list()
const {
27 cout <<
" emt " << emitted
29 <<
" rec " << recoiler
30 <<
" partner " << partner
31 <<
" pTscale " << pTscale << endl;
53 const int History::NTRIAL = 1;
70 History::History(
int depth,
74 MergingHooks* mergingHooksPtrIn,
77 ParticleData* particleDataPtrIn,
79 bool isOrdered =
true,
80 bool isStronglyOrdered =
true,
81 bool isAllowed =
true,
82 bool isNextInInput =
true,
90 foundOrderedPath(false),
91 foundStronglyOrderedPath(false),
92 foundAllowedPath(false),
93 foundCompletePath(false),
95 nextInInput(isNextInInput),
100 mergingHooksPtr(mergingHooksPtrIn),
103 particleDataPtr(particleDataPtrIn),
110 if (mother && mergingHooksPtr->includeRedundant()) prob *= pdfForSudakov();
115 double acoll = (mother->state[clusterIn.emittor].isFinal())
116 ? mergingHooksPtr->herwigAcollFSR()
117 : mergingHooksPtr->herwigAcollISR();
118 sumScalarPT = mother->sumScalarPT + acoll*scale;
123 if ( mother ) iReclusteredOld = mother->iReclusteredNew;
128 for (
int i = 0; i < int(state.size()); ++i )
129 if ( state[i].isFinal() ) {
130 if ( state[i].colType() != 0 )
132 if ( state[i].idAbs() == 24 )
135 if ( mergingHooksPtr->doWClustering()
136 && nFinalP == 2 && nFinalW == 0 ) depth = 0;
140 vector<Clustering> clusterings;
141 if ( depth > 0 ) clusterings = getAllQCDClusterings();
144 vector<Clustering> clusteringsEW;
145 if ( depth > 0 && mergingHooksPtr->doWClustering() )
146 clusteringsEW = getAllEWClusterings();
147 if ( !clusteringsEW.empty() ) {
148 clusterings.resize(0);
149 clusterings.insert( clusterings.end(), clusteringsEW.begin(),
150 clusteringsEW.end() );
154 vector<Clustering> clusteringsSQCD;
155 if ( depth > 0 && mergingHooksPtr->doSQCDClustering() )
156 clusteringsSQCD = getAllSQCDClusterings();
157 if ( !clusteringsSQCD.empty() )
158 clusterings.insert( clusterings.end(), clusteringsSQCD.begin(),
159 clusteringsSQCD.end() );
163 if ( clusterings.empty() ) {
165 prob *= hardProcessME(state);
166 registerPath( *
this, isOrdered, isStronglyOrdered, isAllowed, depth == 0 );
172 multimap<double, Clustering *> sorted;
173 for (
int i = 0, N = clusterings.size(); i < N; ++i ) {
174 sorted.insert(make_pair(clusterings[i].pT(), &clusterings[i]));
177 for ( multimap<double, Clustering *>::iterator it = sorted.begin();
178 it != sorted.end(); ++it ) {
182 bool stronglyOrdered = isStronglyOrdered;
183 if ( mergingHooksPtr->enforceStrongOrdering()
184 && ( !stronglyOrdered
185 || ( mother && ( it->first <
186 mergingHooksPtr->scaleSeparationFactor()*scale ) ))) {
187 if ( onlyStronglyOrderedPaths() )
continue;
188 stronglyOrdered =
false;
192 bool ordered = isOrdered;
193 if ( mergingHooksPtr->orderInRapidity()
194 && mergingHooksPtr->orderHistories() ) {
196 double z = getCurrentZ((*it->second).emittor,
197 (*it->second).recoiler,(*it->second).emitted);
199 double zOld = (!mother) ? 0. : mother->getCurrentZ(clusterIn.emittor,
200 clusterIn.recoiler,clusterIn.emitted);
203 if ( !ordered || ( mother && (it->first < scale
204 || it->first < pow(1. - z,2) / (z * (1. - zOld ))*scale ))) {
205 if ( onlyOrderedPaths() )
continue;
209 }
else if ( mergingHooksPtr->orderHistories() ) {
213 if ( !ordered || ( mother && (it->first < scale) ) ) {
214 if ( onlyOrderedPaths() && onlyAllowedPaths() )
continue;
220 bool doCut = mergingHooksPtr->canCutOnRecState()
221 || mergingHooksPtr->allowCutOnRecState();
222 bool allowed = isAllowed;
224 && mergingHooksPtr->doCutOnRecState(cluster(*it->second)) ) {
225 if ( onlyAllowedPaths() )
continue;
231 children.push_back(
new History(depth - 1,it->first,cluster(*it->second),
232 *it->second, mergingHooksPtr, beamA, beamB, particleDataPtr,
233 infoPtr, ordered, stronglyOrdered, allowed,
true,
234 prob*getProb(*it->second),
this ));
242 bool History::projectOntoDesiredHistories() {
244 return trimHistories();
259 double History::weightTREE(PartonLevel* trial, AlphaStrong * asFSR,
260 AlphaStrong * asISR,
double RN) {
262 if ( mergingHooksPtr->canCutOnRecState() && !foundAllowedPath ) {
263 string message=
"Warning in History::weightTREE: No allowed history";
264 message+=
" found. Using disallowed history.";
265 infoPtr->errorMsg(message);
267 if ( mergingHooksPtr->orderHistories() && !foundOrderedPath ) {
268 string message=
"Warning in History::weightTREE: No ordered history";
269 message+=
" found. Using unordered history.";
270 infoPtr->errorMsg(message);
272 if ( mergingHooksPtr->canCutOnRecState()
273 && mergingHooksPtr->orderHistories()
274 && !foundAllowedPath && !foundOrderedPath ) {
275 string message=
"Warning in History::weightTREE: No allowed or ordered";
276 message+=
" history found.";
277 infoPtr->errorMsg(message);
281 double asME = infoPtr->alphaS();
282 double maxScale = (foundCompletePath) ? infoPtr->eCM()
283 : mergingHooksPtr->muFinME();
285 History * selected = select(RN);
287 selected->setScalesInHistory();
290 double asWeight = 1.;
291 double pdfWeight = 1.;
294 double wt = selected->weightTree( trial, asME, maxScale,
295 selected->clusterIn.pT(), asFSR, asISR, asWeight,
299 int njetsMaxMPI = mergingHooksPtr->nMinMPI();
300 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
304 bool resetScales = mergingHooksPtr->resetHardQRen();
309 && mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0) {
311 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
312 double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
313 asWeight *= pow2(runningCoupling);
320 && mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0) {
322 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
323 double runningCoupling =
324 (*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
325 asWeight *= runningCoupling;
329 return (wt*asWeight*pdfWeight*mpiwt);
338 double History::weightLOOP(PartonLevel* trial,
double RN ) {
340 if ( mergingHooksPtr->canCutOnRecState() && !foundAllowedPath ) {
341 string message=
"Warning in History::weightLOOP: No allowed history";
342 message+=
" found. Using disallowed history.";
343 infoPtr->errorMsg(message);
347 History * selected = select(RN);
349 selected->setScalesInHistory();
355 double maxScale = (foundCompletePath) ? infoPtr->eCM()
356 : mergingHooksPtr->muFinME();
357 int njetsMaxMPI = mergingHooksPtr->nMinMPI();
358 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
369 double History::weightFIRST(PartonLevel* trial, AlphaStrong* asFSR,
370 AlphaStrong* asISR,
double RN, Rndm* rndmPtr ) {
373 double asME = infoPtr->alphaS();
374 double muR = mergingHooksPtr->muRinME();
375 double maxScale = (foundCompletePath)
377 : mergingHooksPtr->muFinME();
380 History * selected = select(RN);
382 selected->setScalesInHistory();
384 double nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
387 double kFactor = asME * mergingHooksPtr->k1Factor(nSteps);
391 double wt = 1. + kFactor;
394 wt += selected->weightFirst(trial,asME, muR, maxScale, asFSR, asISR,
398 double startingScale = (selected->mother) ? state.scale() : infoPtr->eCM();
404 double nWeight1 = 0.;
405 for(
int i=0; i < NTRIAL; ++i) {
407 vector<double> unresolvedEmissionTerm = countEmissions( trial,
408 startingScale, mergingHooksPtr->tms(), 2, asME, asFSR, asISR, 3,
410 nWeight1 += unresolvedEmissionTerm[1];
413 wt += nWeight1/double(NTRIAL);
422 double History::weight_UMEPS_TREE(PartonLevel* trial, AlphaStrong * asFSR,
423 AlphaStrong * asISR,
double RN) {
425 return weightTREE( trial, asFSR, asISR, RN);
432 double History::weight_UMEPS_SUBT(PartonLevel* trial, AlphaStrong * asFSR,
433 AlphaStrong * asISR,
double RN ) {
436 double asME = infoPtr->alphaS();
437 double maxScale = (foundCompletePath) ? infoPtr->eCM()
438 : mergingHooksPtr->muFinME();
440 History * selected = select(RN);
442 selected->setScalesInHistory();
445 double asWeight = 1.;
446 double pdfWeight = 1.;
449 double sudakov = selected->weightTree(trial, asME, maxScale,
450 selected->clusterIn.pT(), asFSR, asISR,
451 asWeight, pdfWeight);
454 int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
455 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
459 bool resetScales = mergingHooksPtr->resetHardQRen();
464 && mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0) {
466 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
467 double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
468 asWeight *= pow(runningCoupling,2);
475 && mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0) {
477 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
478 double runningCoupling =
479 (*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
480 asWeight *= runningCoupling;
484 return (asWeight*pdfWeight*sudakov*mpiwt);
490 double History::weight_UNLOPS_TREE(PartonLevel* trial, AlphaStrong * asFSR,
491 AlphaStrong * asISR,
double RN) {
494 double asME = infoPtr->alphaS();
495 double maxScale = (foundCompletePath) ? infoPtr->eCM()
496 : mergingHooksPtr->muFinME();
498 History * selected = select(RN);
500 selected->setScalesInHistory();
503 double asWeight = 1.;
504 double pdfWeight = 1.;
507 double wt = selected->weightTree(trial, asME, maxScale,
508 selected->clusterIn.pT(), asFSR, asISR, asWeight, pdfWeight);
510 int njetsMaxMPI = mergingHooksPtr->nMinMPI();
511 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
515 bool resetScales = mergingHooksPtr->resetHardQRen();
520 && mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0) {
522 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
523 double runningCoupling = (*asFSR).alphaS(newQ2Ren) / asME;
524 asWeight *= pow(runningCoupling,2);
531 && mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0) {
533 double newQ2Ren = pow2( selected->hardRenScale(selected->state) );
534 double runningCoupling =
535 (*asISR).alphaS( newQ2Ren + pow(mergingHooksPtr->pT0ISR(),2) ) / asME;
536 asWeight *= runningCoupling;
540 return (wt*asWeight*pdfWeight*mpiwt);
546 double History::weight_UNLOPS_LOOP(PartonLevel* trial,
double RN ) {
548 return weightLOOP(trial, RN );
553 double History::weight_UNLOPS_SUBT(PartonLevel* trial, AlphaStrong * asFSR,
554 AlphaStrong * asISR,
double RN ) {
557 History * selected = select(RN);
559 selected->setScalesInHistory();
564 double asME = infoPtr->alphaS();
565 double maxScale = (foundCompletePath)
567 : mergingHooksPtr->muFinME();
571 double nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
572 if ( nSteps == 2 && mergingHooksPtr->nRecluster() == 2
573 && ( !foundCompletePath
574 || !selected->allIntermediateAboveRhoMS( mergingHooksPtr->tms() )) ) {
579 double asWeight = 1.;
580 double pdfWeight = 1.;
582 double sudakov = selected->weightTree(trial, asME, maxScale,
583 selected->clusterIn.pT(), asFSR, asISR,
584 asWeight, pdfWeight);
586 int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
587 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
591 wt = ( mergingHooksPtr->nRecluster() == 2 ) ? 1.
592 : asWeight*pdfWeight*sudakov*mpiwt;
601 double History::weight_UNLOPS_SUBTNLO(PartonLevel* trial,
double RN ) {
604 History * selected = select(RN);
606 selected->setScalesInHistory();
610 double maxScale = (foundCompletePath) ? infoPtr->eCM()
611 : mergingHooksPtr->muFinME();
612 int njetsMaxMPI = mergingHooksPtr->nMinMPI()+1;
613 double mpiwt = selected->weightTreeEmissions( trial, -1, njetsMaxMPI,
625 double History::weight_UNLOPS_CORRECTION(
int order, PartonLevel* trial,
626 AlphaStrong* asFSR, AlphaStrong* asISR,
627 double RN, Rndm* rndmPtr ) {
630 if ( order < 0 )
return 0.;
633 double asME = infoPtr->alphaS();
634 double muR = mergingHooksPtr->muRinME();
635 double maxScale = (foundCompletePath)
637 : mergingHooksPtr->muFinME();
640 History * selected = select(RN);
642 selected->setScalesInHistory();
644 double nSteps = mergingHooksPtr->getNumberOfClusteringSteps(state);
647 double kFactor = asME * mergingHooksPtr->k1Factor(nSteps);
654 if ( order == 0 )
return wt;
664 double wA = selected->weightFirstALPHAS( asME, muR, asFSR, asISR );
666 wt += (fixas) ? wA : 0.;
669 for (
int i=0; i < NTRIAL; ++i ) {
671 double wE = selected->weightFirstEmissions(trial,asME, maxScale,
672 asFSR, asISR, fixpdf, fixas );
676 double pscale = selected->clusterIn.pT();
677 double wP = selected->weightFirstPDFs(asME, maxScale, pscale, rndmPtr);
679 nWeight += (fixpdf) ? wP : 0.;
681 wt += nWeight/double(NTRIAL);
684 if ( order == 1 )
return wt;
695 void History::getStartingConditions(
const double RN,
Event& outState ) {
698 History * selected = select(RN);
701 selected->setScalesInHistory();
707 if (!selected->mother) {
709 for(
int i=0; i < int(outState.size()); ++i)
710 if (outState[i].isFinal()) nFinal++;
712 outState.scale(mergingHooksPtr->muF());
718 if (mergingHooksPtr->getNumberOfClusteringSteps(state) == 0) {
719 infoPtr->zNowISR(0.5);
720 infoPtr->pT2NowISR(pow(state[0].e(),2));
721 infoPtr->hasHistory(
true);
724 infoPtr->zNowISR(selected->zISR());
725 infoPtr->pT2NowISR(pow(selected->pTISR(),2));
726 infoPtr->hasHistory(
true);
734 infoPtr->zNowISR(selected->zISR());
735 infoPtr->pT2NowISR(pow(selected->pTISR(),2));
736 infoPtr->hasHistory(
true);
741 if (mergingHooksPtr->getNumberOfClusteringSteps(state) == 0)
742 mergingHooksPtr->muMI(infoPtr->eCM());
744 mergingHooksPtr->muMI(outState.scale());
752 void History::printHistory(
const double RN ) {
753 History * selected = select(RN);
754 selected->printStates();
762 void History::printStates() {
770 mother->printStates();
779 bool History::getClusteredEvent(
const double RN,
int nSteps,
783 History * selected = select(RN);
787 selected->setScalesInHistory();
790 if (nSteps > selected->nClusterings())
return false;
793 outState = selected->clusteredState(nSteps-1);
801 bool History::getFirstClusteredEventAboveTMS(
const double RN,
int nDesired,
802 Event& process,
int& nPerformed,
bool doUpdate ) {
805 int nTried = nDesired - 1;
807 int nSteps = select(RN)->nClusterings();
809 select(RN)->setScalesInHistory();
816 dummy.init(
"(hard process-modified)", particleDataPtr );
821 if ( !getClusteredEvent( RN, nSteps-nTried+1, dummy ) )
return false;
822 if ( nTried >= nSteps )
break;
824 }
while ( mergingHooksPtr->rhoms( dummy,
false) < mergingHooksPtr->tms() );
827 if ( doUpdate ) process = dummy;
830 if ( nTried > nSteps )
return false;
835 mergingHooksPtr->nReclusterSave = nPerformed;
837 if (mergingHooksPtr->getNumberOfClusteringSteps(state) == 0)
838 mergingHooksPtr->muMI(infoPtr->eCM());
840 mergingHooksPtr->muMI(state.scale());
852 double History::getPDFratio(
int side,
bool forSudakov,
bool useHardPDFs,
853 int flavNum,
double xNum,
double muNum,
854 int flavDen,
double xDen,
double muDen) {
857 if ( abs(flavNum) > 10 && flavNum != 21 )
return 1.0;
858 if ( abs(flavDen) > 10 && flavDen != 21 )
return 1.0;
861 double pdfRatio = 1.0;
871 pdfNum = mother->beamA.xfHard( flavNum, xNum, muNum*muNum);
873 pdfNum = beamA.xfHard( flavNum, xNum, muNum*muNum);
875 pdfDen = max(1e-10, beamA.xfHard( flavDen, xDen, muDen*muDen));
877 pdfDen = max(1e-10, beamA.xfHard( flavDen, xDen, muDen*muDen));
880 pdfNum = mother->beamB.xfHard( flavNum, xNum, muNum*muNum);
882 pdfNum = beamB.xfHard( flavNum, xNum, muNum*muNum);
885 pdfDen = max(1e-10,beamB.xfHard( flavDen, xDen, muDen*muDen));
887 pdfDen = max(1e-10,beamB.xfHard( flavDen, xDen, muDen*muDen));
894 pdfNum = mother->beamA.xfISR(0, flavNum, xNum, muNum*muNum);
896 pdfNum = beamA.xfISR(0, flavNum, xNum, muNum*muNum);
898 pdfDen = max(1e-10, beamA.xfISR(0, flavDen, xDen, muDen*muDen));
900 pdfDen = max(1e-10, beamA.xfISR(0, flavDen, xDen, muDen*muDen));
904 pdfNum = mother->beamB.xfISR(0, flavNum, xNum, muNum*muNum);
906 pdfNum = beamB.xfISR(0, flavNum, xNum, muNum*muNum);
909 pdfDen = max(1e-10,beamB.xfISR(0, flavDen, xDen, muDen*muDen));
911 pdfDen = max(1e-10,beamB.xfISR(0, flavDen, xDen, muDen*muDen));
916 if ( pdfNum > 1e-15 && pdfDen > 1e-10 ) {
917 pdfRatio *= pdfNum / pdfDen;
918 }
else if ( pdfNum < pdfDen ) {
920 }
else if ( pdfNum > pdfDen ) {
936 void History::setScalesInHistory() {
943 setScales(ident,
true);
958 void History::findPath(vector<int>& out) {
961 if (!mother &&
int(children.size()) < 1)
return;
966 int size = int(mother->children.size());
968 for (
int i=0; i < size; ++i) {
969 if ( mother->children[i]->scale == scale
970 && mother->children[i]->prob == prob
971 && equalClustering(mother->children[i]->clusterIn,clusterIn)) {
978 out.push_back(iChild);
979 mother->findPath(out);
1004 void History::setScales( vector<int> index,
bool forward) {
1008 if ( children.empty() && forward ) {
1011 double scaleNew = 1.;
1013 if (mergingHooksPtr->incompleteScalePrescip()==0) {
1014 scaleNew = mergingHooksPtr->muF();
1015 }
else if (mergingHooksPtr->incompleteScalePrescip()==1) {
1017 pOut.p(0.,0.,0.,0.);
1018 for(
int i=0; i<int(state.size()); ++i)
1019 if (state[i].isFinal())
1020 pOut += state[i].p();
1021 scaleNew = pOut.mCalc();
1022 }
else if (mergingHooksPtr->incompleteScalePrescip()==2) {
1023 scaleNew = state[0].e();
1026 scaleNew = max( mergingHooksPtr->pTcut(), scaleNew);
1028 state.scale(scaleNew);
1029 for(
int i=3; i < int(state.size());++i)
1030 if (state[i].colType() != 0)
1031 state[i].scale(scaleNew);
1034 state.scale( state[0].e() );
1036 bool isLEP = ( state[3].isLepton() && state[4].isLepton() );
1038 int nFinalPartons = 0;
1039 int nFinalPhotons = 0;
1040 for (
int i=0; i < int(state.size()); ++i ) {
1041 if ( state[i].isFinal() ) {
1043 if ( state[i].colType() != 0 ) nFinalPartons++;
1044 if ( state[i].
id() == 22 ) nFinalPhotons++;
1047 bool isQCD = ( nFinal == 2 && nFinal == nFinalPartons );
1048 bool isPPh = ( nFinal == 2 && nFinalPartons == 1 && nFinalPhotons == 1);
1050 if ( !isLEP && ( isQCD || isPPh ) )
1051 state.scale( hardFacScale(state) );
1057 if (mother && forward) {
1059 double scaleNew = 1.;
1060 if (mergingHooksPtr->unorderedScalePrescip() == 0) {
1062 scaleNew = max( mergingHooksPtr->pTcut(), max(scale,mother->scale));
1063 }
else if (mergingHooksPtr->unorderedScalePrescip() == 1) {
1065 if (scale < mother->scale)
1066 scaleNew *= max( mergingHooksPtr->pTcut(), min(scale,mother->scale));
1068 scaleNew *= max( mergingHooksPtr->pTcut(), max(scale,mother->scale));
1073 mother->state[clusterIn.emitted].scale(scaleNew);
1074 mother->state[clusterIn.emittor].scale(scaleNew);
1075 mother->state[clusterIn.recoiler].scale(scaleNew);
1079 mother->scaleCopies(clusterIn.emitted, mother->state, scaleNew);
1080 mother->scaleCopies(clusterIn.emittor, mother->state, scaleNew);
1081 mother->scaleCopies(clusterIn.recoiler, mother->state, scaleNew);
1084 mother->setScales(index,
true);
1089 if (!mother || !forward) {
1092 if (
int(index.size()) > 0 ) {
1093 iChild = index.back();
1099 scale = max(mergingHooksPtr->pTcut(), scale);
1102 if (iChild != -1 && !children.empty()) {
1104 if (scale > children[iChild]->scale ) {
1105 if (mergingHooksPtr->unorderedScalePrescip() == 0) {
1107 double scaleNew = max( mergingHooksPtr->pTcut(),
1108 max(scale,children[iChild]->scale));
1110 for(
int i = 0; i < int(children[iChild]->state.size()); ++i)
1111 if (children[iChild]->state[i].scale() == children[iChild]->scale)
1112 children[iChild]->state[i].scale(scaleNew);
1114 children[iChild]->scale = scaleNew;
1116 }
else if ( mergingHooksPtr->unorderedScalePrescip() == 1) {
1118 double scaleNew = max(mergingHooksPtr->pTcut(),
1119 min(scale,children[iChild]->scale));
1121 for(
int i = 0; i < int(state.size()); ++i)
1122 if (state[i].scale() == scale)
1123 state[i].scale(scaleNew);
1129 double scalemin = state[0].e();
1130 for(
int i = 0; i < int(state.size()); ++i)
1131 if (state[i].colType() != 0)
1132 scalemin = max(mergingHooksPtr->pTcut(),
1133 min(scalemin,state[i].scale()));
1134 state.scale(scalemin);
1135 scale = max(mergingHooksPtr->pTcut(), scale);
1138 children[iChild]->setScales(index,
false);
1154 void History::scaleCopies(
int iPart,
const Event& refEvent,
double rho) {
1159 for(
int i=0; i < mother->state.size(); ++i) {
1160 if ( ( mother->state[i].id() == refEvent[iPart].id()
1161 && mother->state[i].colType() == refEvent[iPart].colType()
1162 && mother->state[i].chargeType() == refEvent[iPart].chargeType()
1163 && mother->state[i].col() == refEvent[iPart].col()
1164 && mother->state[i].acol() == refEvent[iPart].acol() )
1167 mother->state[i].scale(rho);
1170 mother->scaleCopies( iPart, refEvent, rho );
1183 void History::setEventScales() {
1187 mother->state.scale(scale);
1189 mother->setEventScales();
1199 double History::zISR() {
1202 if (!mother)
return 0.0;
1204 if (mother->state[clusterIn.emittor].isFinal())
return mother->zISR();
1206 int rad = clusterIn.emittor;
1207 int rec = clusterIn.recoiler;
1208 int emt = clusterIn.emitted;
1209 double z = (mother->state[rad].p() + mother->state[rec].p()
1210 - mother->state[emt].p()).m2Calc()
1211 / (mother->state[rad].p() + mother->state[rec].p()).m2Calc();
1213 double znew = mother->zISR();
1215 if (znew > 0.) z = znew;
1226 double History::zFSR() {
1229 if (!mother)
return 0.0;
1231 if (!mother->state[clusterIn.emittor].isFinal())
return mother->zFSR();
1233 int rad = clusterIn.emittor;
1234 int rec = clusterIn.recoiler;
1235 int emt = clusterIn.emitted;
1237 Vec4 sum = mother->state[rad].p() + mother->state[rec].p()
1238 + mother->state[emt].p();
1239 double m2Dip = sum.m2Calc();
1240 double x1 = 2. * (sum * mother->state[rad].p()) / m2Dip;
1241 double x3 = 2. * (sum * mother->state[emt].p()) / m2Dip;
1243 double z = x1/(x1+x3);
1245 double znew = mother->zFSR();
1247 if (znew > 0.) z = znew;
1258 double History::pTISR() {
1260 if (!mother)
return 0.0;
1262 if (mother->state[clusterIn.emittor].isFinal())
return mother->pTISR();
1263 double pT = mother->state.scale();
1265 double pTnew = mother->pTISR();
1267 if (pTnew > 0.) pT = pTnew;
1278 double History::pTFSR() {
1281 if (!mother)
return 0.0;
1283 if (!mother->state[clusterIn.emittor].isFinal())
return mother->pTFSR();
1284 double pT = mother->state.scale();
1286 double pTnew = mother->pTFSR();
1288 if (pTnew > 0.) pT = pTnew;
1299 int History::nClusterings() {
1300 if (!mother)
return 0;
1301 int w = mother->nClusterings();
1314 Event History::clusteredState(
int nSteps) {
1317 Event outState = state;
1319 if (mother && nSteps > 0)
1320 outState = mother->clusteredState(nSteps - 1);
1333 History * History::select(
double rnd) {
1336 if ( goodBranches.empty() && badBranches.empty() )
return this;
1340 map<double, History*> selectFrom;
1341 if ( !goodBranches.empty() ) {
1342 selectFrom = goodBranches;
1343 sum = sumGoodBranches;
1345 selectFrom = badBranches;
1346 sum = sumBadBranches;
1349 if (mergingHooksPtr->pickBySumPT()) {
1352 for (
int i=0; i < state.size(); ++i)
1353 if (state[i].isFinal())
1356 double sumMin = (nFinal-2)*state[0].e();
1357 for ( map<double, History*>::iterator it = selectFrom.begin();
1358 it != selectFrom.end(); ++it ) {
1360 if (it->second->sumScalarPT < sumMin) {
1361 sumMin = it->second->sumScalarPT;
1366 return selectFrom.lower_bound(iMin)->second;
1370 return selectFrom.upper_bound(sum*rnd)->second;
1372 return selectFrom.lower_bound(sum*rnd)->second;
1382 bool History::trimHistories() {
1384 if ( paths.empty() )
return false;
1386 for ( map<double, History*>::iterator it = paths.begin();
1387 it != paths.end(); ++it ) {
1389 if ( it->second->keep() && !it->second->keepHistory() )
1390 it->second->remove();
1393 double sumold, sumnew, sumprob, mismatch;
1394 sumold = sumnew = sumprob = mismatch = 0.;
1397 for ( map<double, History*>::iterator it = paths.begin();
1398 it != paths.end(); ++it ) {
1401 if ( it->second->keep() ) {
1403 goodBranches.insert( make_pair( sumnew - mismatch, it->second) );
1405 sumGoodBranches = sumnew - mismatch;
1409 double mismatchOld = mismatch;
1410 mismatch += sumnew - sumold;
1412 badBranches.insert( make_pair( mismatchOld + sumnew - sumold,
1415 sumBadBranches = mismatchOld + sumnew - sumold;
1422 return !goodBranches.empty();
1429 bool History::keepHistory() {
1430 bool keepPath =
true;
1432 if ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
1433 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 ) {
1436 double maxScale = hardFacScale(state);
1437 keepPath = isOrderedPath( maxScale );
1448 bool History::isOrderedPath(
double maxscale ) {
1449 double newscale = clusterIn.pT();
1450 if ( !mother )
return true;
1451 bool ordered = mother->isOrderedPath(newscale);
1452 if ( !ordered || maxscale < newscale)
return false;
1461 bool History::allIntermediateAboveRhoMS(
double rhoms,
bool good ) {
1464 if ( !good )
return false;
1467 for (
int i = 0; i < state.size(); ++i )
1468 if ( state[i].isFinal() && state[i].colType() != 0 )
1470 double rhoNew = (nFinal > 0 ) ? mergingHooksPtr->rhoms( state,
false )
1473 if ( !mother )
return good;
1475 return good && mother->allIntermediateAboveRhoMS( rhoms, (rhoNew > rhoms) );
1482 bool History::foundAnyOrderedPaths() {
1484 if ( paths.empty() )
return false;
1485 double maxscale = infoPtr->eCM();
1487 for ( map<double, History*>::iterator it = paths.begin();
1488 it != paths.end(); ++it )
1489 if ( it->second->isOrderedPath(maxscale) )
1510 double History::weightTree(PartonLevel* trial,
double as0,
double maxscale,
1511 double pdfScale, AlphaStrong * asFSR, AlphaStrong * asISR,
1512 double& asWeight,
double& pdfWeight) {
1515 double newScale = scale;
1520 int sideRad = (state[3].pz() > 0) ? 1 :-1;
1521 int sideRec = (state[4].pz() > 0) ? 1 :-1;
1523 if (state[3].colType() != 0) {
1525 double x = 2.*state[3].e() / state[0].e();
1526 int flav = state[3].id();
1529 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1530 double scaleDen = mergingHooksPtr->muFinME();
1532 double ratio = getPDFratio(sideRad,
false,
false, flav, x, scaleNum,
1538 if (state[4].colType() != 0) {
1540 double x = 2.*state[4].e() / state[0].e();
1541 int flav = state[4].id();
1543 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1544 double scaleDen = mergingHooksPtr->muFinME();
1546 double ratio = getPDFratio(sideRec,
false,
false, flav, x, scaleNum,
1556 double newPDFscale = newScale;
1557 if (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1558 newPDFscale = clusterIn.pT();
1561 double w = mother->weightTree(trial, as0, newScale, newPDFscale,
1562 asFSR, asISR, asWeight, pdfWeight);
1565 if (state.size() < 3)
return 1.0;
1567 if ( w < 1e-12 )
return 0.0;
1569 w *= doTrialShower(trial, 1, maxscale);
1570 if ( w < 1e-12 )
return 0.0;
1573 if ( asFSR && asISR ) {
1574 double asScale = pow2( newScale );
1575 if (mergingHooksPtr->unorderedASscalePrescip() == 1)
1576 asScale = pow2( clusterIn.pT() );
1577 bool FSR = mother->state[clusterIn.emittor].isFinal();
1578 double alphaSinPS = (FSR) ? (*asFSR).alphaS(asScale)
1579 : (*asISR).alphaS(asScale
1580 + pow2(mergingHooksPtr->pT0ISR()) );
1581 asWeight *= alphaSinPS / as0;
1587 int sideP = (mother->state[inP].pz() > 0) ? 1 :-1;
1588 int sideM = (mother->state[inM].pz() > 0) ? 1 :-1;
1590 if ( mother->state[inP].colType() != 0 ) {
1592 double x = getCurrentX(sideP);
1593 int flav = getCurrentFlav(sideP);
1595 double scaleNum = (children.empty())
1596 ? hardFacScale(state)
1597 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1598 ? pdfScale : maxscale );
1599 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1600 ? clusterIn.pT() : newScale;
1602 double ratio = getPDFratio(sideP,
false,
false, flav, x, scaleNum,
1607 if ( mother->state[inM].colType() != 0 ) {
1609 double x = getCurrentX(sideM);
1610 int flav = getCurrentFlav(sideM);
1612 double scaleNum = (children.empty())
1613 ? hardFacScale(state)
1614 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1615 ? pdfScale : maxscale );
1616 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1617 ? clusterIn.pT() : newScale;
1619 double ratio = getPDFratio(sideM,
false,
false, flav, x, scaleNum,
1632 double History::weightTreeALPHAS(
double as0, AlphaStrong * asFSR,
1633 AlphaStrong * asISR ) {
1636 if ( !mother )
return 1.;
1638 double w = mother->weightTreeALPHAS( as0, asFSR, asISR );
1640 if (state.size() < 3)
return w;
1643 if ( asFSR && asISR ) {
1644 double asScale = pow2( scale );
1645 if (mergingHooksPtr->unorderedASscalePrescip() == 1)
1646 asScale = pow2( clusterIn.pT() );
1647 bool FSR = mother->state[clusterIn.emittor].isFinal();
1648 double alphaSinPS = (FSR)
1649 ? (*asFSR).alphaS(asScale)
1650 : (*asISR).alphaS(asScale + pow2(mergingHooksPtr->pT0ISR()) );
1651 w *= alphaSinPS / as0;
1662 double History::weightTreePDFs(
double maxscale,
double pdfScale ) {
1665 double newScale = scale;
1671 int sideRad = (state[3].pz() > 0) ? 1 :-1;
1672 int sideRec = (state[4].pz() > 0) ? 1 :-1;
1675 if (state[3].colType() != 0) {
1677 double x = 2.*state[3].e() / state[0].e();
1678 int flav = state[3].id();
1680 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1681 double scaleDen = mergingHooksPtr->muFinME();
1683 wt *= getPDFratio(sideRad,
false,
false, flav, x, scaleNum, flav, x,
1688 if (state[4].colType() != 0) {
1690 double x = 2.*state[4].e() / state[0].e();
1691 int flav = state[4].id();
1693 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1694 double scaleDen = mergingHooksPtr->muFinME();
1696 wt *= getPDFratio(sideRec,
false,
false, flav, x, scaleNum, flav, x,
1705 double newPDFscale = newScale;
1706 if ( mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1707 newPDFscale = clusterIn.pT();
1710 double w = mother->weightTreePDFs( newScale, newPDFscale );
1713 if (state.size() < 3)
return w;
1718 int sideP = (mother->state[inP].pz() > 0) ? 1 :-1;
1719 int sideM = (mother->state[inM].pz() > 0) ? 1 :-1;
1721 if ( mother->state[inP].colType() != 0 ) {
1723 double x = getCurrentX(sideP);
1724 int flav = getCurrentFlav(sideP);
1726 double scaleNum = (children.empty())
1727 ? hardFacScale(state)
1728 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1729 ? pdfScale : maxscale );
1730 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1731 ? clusterIn.pT() : newScale;
1733 double ratio = getPDFratio(sideP,
false,
false, flav, x, scaleNum,
1738 if ( mother->state[inM].colType() != 0 ) {
1740 double x = getCurrentX(sideM);
1741 int flav = getCurrentFlav(sideM);
1743 double scaleNum = (children.empty())
1744 ? hardFacScale(state)
1745 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1746 ? pdfScale : maxscale );
1747 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1748 ? clusterIn.pT() : newScale;
1750 double ratio = getPDFratio(sideM,
false,
false, flav, x, scaleNum,
1763 double History::weightTreeEmissions( PartonLevel* trial,
int type,
1764 int njetMax,
double maxscale ) {
1767 double newScale = scale;
1769 if ( !mother )
return 1.0;
1771 double w = mother->weightTreeEmissions( trial, type, njetMax, newScale );
1773 if (state.size() < 3)
return 1.0;
1775 if ( w < 1e-12 )
return 0.0;
1777 int njetNow = mergingHooksPtr->getNumberOfClusteringSteps( state) ;
1778 if (njetNow >= njetMax)
return 1.0;
1780 w *= doTrialShower(trial, type, maxscale);
1781 if ( w < 1e-12 )
return 0.0;
1791 double History::weightFirst(PartonLevel* trial,
double as0,
double muR,
1792 double maxscale, AlphaStrong * asFSR, AlphaStrong * asISR, Rndm* rndmPtr ) {
1795 double newScale = scale;
1802 if (state[3].colType() != 0) {
1804 double x = 2.*state[3].e() / state[0].e();
1805 int flav = state[3].id();
1807 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1808 double scaleDen = mergingHooksPtr->muFinME();
1810 double intPDF4 = monteCarloPDFratios(flav, x, scaleNum, scaleDen,
1811 mergingHooksPtr->muFinME(), as0, rndmPtr);
1816 if (state[4].colType() != 0) {
1818 double x = 2.*state[4].e() / state[0].e();
1819 int flav = state[4].id();
1821 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1822 double scaleDen = mergingHooksPtr->muFinME();
1824 double intPDF4 = monteCarloPDFratios(flav, x, scaleNum, scaleDen,
1825 mergingHooksPtr->muFinME(), as0, rndmPtr);
1833 double w = mother->weightFirst(trial, as0, muR, newScale, asFSR, asISR,
1837 if (state.size() < 3)
return 0.0;
1841 double asScale2 = newScale*newScale;
1842 int showerType = (mother->state[clusterIn.emittor].isFinal() ) ? 1 : -1;
1843 if (showerType == -1) {
1844 asScale2 += pow(mergingHooksPtr->pT0ISR(),2);
1849 double BETA0 = 11. - 2./3.* NF;
1851 w += as0 / (2.*M_PI) * 0.5 * BETA0 * log( (muR*muR) / (b*asScale2) );
1857 double nWeight1 = 0.;
1858 double nWeight2 = 0.;
1860 for(
int i=0; i < NTRIAL; ++i) {
1862 vector<double> unresolvedEmissionTerm = countEmissions(trial, maxscale,
1863 newScale, 2, as0, asFSR, asISR, 3, fixpdf, fixas);
1864 nWeight1 += unresolvedEmissionTerm[1];
1866 w += nWeight1/double(NTRIAL) + nWeight2/double(NTRIAL);
1871 int sideP = (mother->state[inP].pz() > 0) ? 1 :-1;
1872 int sideM = (mother->state[inM].pz() > 0) ? 1 :-1;
1874 if ( mother->state[inP].colType() != 0 ) {
1876 double x = getCurrentX(sideP);
1877 int flav = getCurrentFlav(sideP);
1879 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1881 double intPDF4 = monteCarloPDFratios(flav, x, scaleNum, newScale,
1882 mergingHooksPtr->muFinME(), as0, rndmPtr);
1887 if ( mother->state[inM].colType() != 0 ) {
1889 double x = getCurrentX(sideM);
1890 int flav = getCurrentFlav(sideM);
1892 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1894 double intPDF4 = monteCarloPDFratios(flav, x, scaleNum, newScale,
1895 mergingHooksPtr->muFinME(), as0, rndmPtr);
1910 double History::weightFirstALPHAS(
double as0,
double muR,
1911 AlphaStrong * asFSR, AlphaStrong * asISR ) {
1914 double newScale = scale;
1916 if ( !mother )
return 0.;
1918 double w = mother->weightFirstALPHAS( as0, muR, asFSR, asISR );
1920 int showerType = (mother->state[clusterIn.emittor].isFinal() ) ? 1 : -1;
1922 double asScale = pow2( newScale );
1923 if ( mergingHooksPtr->unorderedASscalePrescip() == 1 )
1924 asScale = pow2( clusterIn.pT() );
1925 if (showerType == -1) {
1926 asScale += pow2( mergingHooksPtr->pT0ISR() );
1931 double BETA0 = 11. - 2./3.* NF;
1933 w += as0 / (2.*M_PI) * 0.5 * BETA0 * log( (muR*muR) / (b*asScale) );
1944 double History::weightFirstPDFs(
double as0,
double maxscale,
double pdfScale,
1948 double newScale = scale;
1955 if (state[3].colType() != 0) {
1957 double x = 2.*state[3].e() / state[0].e();
1958 int flav = state[3].id();
1960 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1961 double scaleDen = mergingHooksPtr->muFinME();
1963 wt += monteCarloPDFratios(flav, x, scaleNum, scaleDen,
1964 mergingHooksPtr->muFinME(), as0, rndmPtr);
1967 if (state[4].colType() != 0) {
1969 double x = 2.*state[4].e() / state[0].e();
1970 int flav = state[4].id();
1972 double scaleNum = (children.empty()) ? hardFacScale(state) : maxscale;
1973 double scaleDen = mergingHooksPtr->muFinME();
1975 wt += monteCarloPDFratios(flav, x, scaleNum, scaleDen,
1976 mergingHooksPtr->muFinME(), as0, rndmPtr);
1985 double newPDFscale = newScale;
1986 if (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
1987 newPDFscale = clusterIn.pT();
1990 double w = mother->weightFirstPDFs( as0, newScale, newPDFscale, rndmPtr);
1995 int sideP = (mother->state[inP].pz() > 0) ? 1 :-1;
1996 int sideM = (mother->state[inM].pz() > 0) ? 1 :-1;
1998 if ( mother->state[inP].colType() != 0 ) {
2000 double x = getCurrentX(sideP);
2001 int flav = getCurrentFlav(sideP);
2003 double scaleNum = (children.empty())
2004 ? hardFacScale(state)
2005 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
2006 ? pdfScale : maxscale );
2007 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
2008 ? clusterIn.pT() : newScale;
2010 w += monteCarloPDFratios(flav, x, scaleNum, scaleDen,
2011 mergingHooksPtr->muFinME(), as0, rndmPtr);
2014 if ( mother->state[inM].colType() != 0 ) {
2016 double x = getCurrentX(sideM);
2017 int flav = getCurrentFlav(sideM);
2019 double scaleNum = (children.empty())
2020 ? hardFacScale(state)
2021 : ( (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
2022 ? pdfScale : maxscale );
2023 double scaleDen = (mergingHooksPtr->unorderedPDFscalePrescip() == 1)
2024 ? clusterIn.pT() : newScale;
2026 w += monteCarloPDFratios(flav, x, scaleNum, scaleDen,
2027 mergingHooksPtr->muFinME(), as0, rndmPtr);
2041 double History::weightFirstEmissions(PartonLevel* trial,
double as0,
2042 double maxscale, AlphaStrong * asFSR, AlphaStrong * asISR,
2043 bool fixpdf,
bool fixas ) {
2046 double newScale = scale;
2047 if ( !mother )
return 0.0;
2049 double w = mother->weightFirstEmissions(trial, as0, newScale, asFSR, asISR,
2052 if (state.size() < 3)
return 0.0;
2054 double nWeight1 = 0.;
2055 double nWeight2 = 0.;
2056 for(
int i=0; i < NTRIAL; ++i) {
2058 vector<double> unresolvedEmissionTerm = countEmissions(trial, maxscale,
2059 newScale, 2, as0, asFSR, asISR, 3, fixpdf, fixas);
2060 nWeight1 += unresolvedEmissionTerm[1];
2063 w += nWeight1/double(NTRIAL) + nWeight2/double(NTRIAL);
2074 double History::hardFacScale(
const Event& event) {
2076 double hardscale = 0.;
2078 if ( !mergingHooksPtr->resetHardQFac() )
return mergingHooksPtr->muF();
2082 if ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
2083 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 ) {
2086 for (
int i=0; i <
event.size(); ++i)
2087 if ( event[i].isFinal() &&
event[i].colType() != 0 )
2088 mT.push_back( abs(event[i].mT2()) );
2089 if (
int(mT.size()) != 2 )
2090 hardscale = infoPtr->QFac();
2092 hardscale = sqrt( min( mT[0], mT[1] ) );
2094 hardscale = infoPtr->QFac();
2104 double History::hardRenScale(
const Event& event) {
2106 double hardscale = 0.;
2108 if ( !mergingHooksPtr->resetHardQRen() )
return mergingHooksPtr->muR();
2112 if ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
2113 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 ) {
2116 for (
int i=0; i <
event.size(); ++i)
2117 if ( event[i].isFinal()
2118 && (
event[i].colType() != 0 ||
event[i].id() == 22 ) )
2119 mT.push_back( abs(event[i].mT()) );
2120 if (
int(mT.size()) != 2 )
2121 hardscale = infoPtr->QRen();
2123 hardscale = sqrt( mT[0]*mT[1] );
2125 hardscale = infoPtr->QRen();
2142 double History::doTrialShower( PartonLevel* trial,
int type,
2143 double maxscaleIn,
double minscaleIn ) {
2146 Event process = state;
2148 double startingScale = maxscaleIn;
2151 if ( mergingHooksPtr->getNumberOfClusteringSteps(process) == 0
2152 && ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
2153 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 ) )
2154 startingScale = min( startingScale, hardFacScale(process) );
2157 bool doVeto =
false;
2162 trial->resetTrial();
2165 event.init(
"(hard process-modified)", particleDataPtr);
2169 process.scale(startingScale);
2173 double minScale = (minscaleIn > 0.) ? minscaleIn : scale;
2178 if (minScale >= startingScale)
break;
2184 double z = ( mergingHooksPtr->getNumberOfClusteringSteps(state) == 0
2187 : mother->getCurrentZ(clusterIn.emittor,clusterIn.recoiler,
2190 infoPtr->zNowISR(z);
2191 infoPtr->pT2NowISR(pow(startingScale,2));
2192 infoPtr->hasHistory(
true);
2195 trial->next(process,event);
2197 double pTtrial = trial->pTLastInShower();
2198 int typeTrial = trial->typeLastInShower();
2201 trial->resetTrial();
2204 double vetoScale = (mother) ? 0. : mergingHooksPtr->tms();
2206 double tnow = mergingHooksPtr->tmsNow( event );
2209 if ( pTtrial < minScale )
break;
2211 startingScale = pTtrial;
2214 if ( tnow < vetoScale && vetoScale > 0. )
continue;
2217 if ( mergingHooksPtr->canVetoTrialEmission()
2218 && mergingHooksPtr->doVetoTrialEmission( process, event) )
continue;
2222 if ( type == -1 && typeTrial != 1 )
continue;
2224 if ( type == 1 && !(typeTrial == 2 || typeTrial >= 3) )
continue;
2227 if ( pTtrial > minScale ) doVeto =
true;
2237 && mergingHooksPtr->getNumberOfClusteringSteps(process) == 0
2238 && ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
2239 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 )
2240 && pTtrial > hardFacScale(process) )
2245 if ( pTtrial < minScale ) doVeto =
false;
2253 return ( (doVeto) ? 0. : 1. );
2263 bool History::updateind(vector<int> & ind,
int i,
int N) {
2264 if ( i < 0 )
return false;
2265 if ( ++ind[i] < N )
return true;
2266 if ( !updateind(ind, i - 1, N - 1) )
return false;
2267 ind[i] = ind[i - 1] + 1;
2278 History::countEmissions(PartonLevel* trial,
double maxscale,
2279 double minscale,
int showerType,
double as0,
2280 AlphaStrong * asFSR, AlphaStrong * asISR,
int N = 1,
2281 bool fixpdf =
true,
bool fixas =
true) {
2283 if ( N < 0 )
return vector<double>();
2284 vector<double> result(N+1);
2286 if ( N < 1 )
return result;
2289 Event process = state;
2291 double startingScale = maxscale;
2294 if ( mergingHooksPtr->getNumberOfClusteringSteps(process) == 0
2295 && ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
2296 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0 ) )
2297 startingScale = min( startingScale, hardFacScale(process) );
2303 trial->resetTrial();
2306 event.init(
"(hard process-modified)", particleDataPtr);
2310 process.scale(startingScale);
2315 if (minscale >= startingScale)
return result;
2321 double z = ( mergingHooksPtr->getNumberOfClusteringSteps(state) == 0)
2323 : mother->getCurrentZ(clusterIn.emittor,clusterIn.recoiler,
2326 infoPtr->zNowISR(z);
2327 infoPtr->pT2NowISR(pow(startingScale,2));
2328 infoPtr->hasHistory(
true);
2332 trial->next(process,event);
2335 double pTtrial = trial->pTLastInShower();
2336 int typeTrial = trial->typeLastInShower();
2339 trial->resetTrial();
2342 double vetoScale = (mother) ? 0. : mergingHooksPtr->tms();
2344 double tnow = mergingHooksPtr->tmsNow( event );
2347 startingScale = pTtrial;
2349 if ( pTtrial < minscale )
break;
2351 if ( tnow < vetoScale && vetoScale > 0. )
continue;
2353 if ( mergingHooksPtr->canVetoTrialEmission()
2354 && mergingHooksPtr->doVetoTrialEmission( process, event) )
continue;
2359 double alphaSinPS = as0;
2362 if ( (showerType == -1 || showerType == 2) && typeTrial == 2 ) {
2364 if ( fixas ) alphaSinPS = (*asISR).alphaS(pTtrial*pTtrial);
2367 pdfs = pdfFactor( event, typeTrial, pTtrial,
2368 mergingHooksPtr->muFinME() );
2370 }
else if ( (showerType == 1 || showerType == 2) && typeTrial >= 3 ) {
2372 if ( fixas ) alphaSinPS = (*asFSR).alphaS(pTtrial*pTtrial);
2376 pdfs = pdfFactor( event, typeTrial, pTtrial,
2377 mergingHooksPtr->muFinME() );
2381 if ( typeTrial == 2 || typeTrial >= 3 )
2382 wts.push_back(as0/alphaSinPS*pdfs);
2386 for (
int n = 1; n <= min(N,
int(wts.size())); ++n ) {
2388 for (
int i = 0; i < N; ++i ) ind[i] = i;
2391 for (
int j = 0; j < n; ++j ) x *= wts[ind[j]];
2393 }
while ( updateind(ind, n - 1, wts.size()) );
2394 if ( n%2 ) result[n] *= -1.0;
2406 double History::monteCarloPDFratios(
int flav,
double x,
double maxScale,
2407 double minScale,
double pdfScale,
double asME, Rndm* rndmPtr) {
2411 double factor = asME / (2.*M_PI);
2413 factor *= log(maxScale/minScale);
2416 if (factor == 0.)
return 0.;
2424 double integral = 0.;
2425 double RN = rndmPtr->flat();
2428 double zTrial = pow(x,RN);
2429 integral = -log(x) * zTrial *
2430 integrand(flav, x, pdfScale, zTrial);
2431 integral += 1./6.*(11.*CA - 4.*NF*TR)
2434 double zTrial = x + RN*(1. - x);
2436 integrand(flav, x, pdfScale, zTrial);
2437 integral += 3./2.*CF
2442 return (factor*integral);
2451 bool History::onlyOrderedPaths() {
2452 if ( !mother || foundOrderedPath )
return foundOrderedPath;
2453 return foundOrderedPath = mother->onlyOrderedPaths();
2462 bool History::onlyStronglyOrderedPaths() {
2463 if ( !mother || foundStronglyOrderedPath )
return foundStronglyOrderedPath;
2464 return foundStronglyOrderedPath = mother->onlyStronglyOrderedPaths();
2473 bool History::onlyAllowedPaths() {
2474 if ( !mother || foundAllowedPath )
return foundAllowedPath;
2475 return foundAllowedPath = mother->onlyAllowedPaths();
2487 bool History::registerPath(History & l,
bool isOrdered,
2488 bool isStronglyOrdered,
bool isAllowed,
bool isComplete) {
2494 if ( mother )
return mother->registerPath(l, isOrdered,
2495 isStronglyOrdered, isAllowed, isComplete);
2498 if ( sumpath == sumpath + l.prob )
2500 if ( mergingHooksPtr->canCutOnRecState()
2501 && foundAllowedPath && !isAllowed )
2503 if ( mergingHooksPtr->enforceStrongOrdering()
2504 && foundStronglyOrderedPath && !isStronglyOrdered )
2506 if ( mergingHooksPtr->orderHistories()
2507 && foundOrderedPath && !isOrdered ) {
2509 if ( (!foundCompletePath && isComplete)
2510 || (!foundAllowedPath && isAllowed) ) ;
2514 if ( foundCompletePath && !isComplete )
2516 if ( !mergingHooksPtr->canCutOnRecState()
2517 && !mergingHooksPtr->allowCutOnRecState() )
2518 foundAllowedPath =
true;
2520 if ( mergingHooksPtr->canCutOnRecState() && isAllowed && isComplete) {
2521 if ( !foundAllowedPath || !foundCompletePath ) {
2527 foundAllowedPath =
true;
2531 if ( mergingHooksPtr->enforceStrongOrdering() && isStronglyOrdered
2533 if ( !foundStronglyOrderedPath || !foundCompletePath ) {
2539 foundStronglyOrderedPath =
true;
2540 foundCompletePath =
true;
2544 if ( mergingHooksPtr->orderHistories() && isOrdered && isComplete ) {
2545 if ( !foundOrderedPath || !foundCompletePath ) {
2551 foundOrderedPath =
true;
2552 foundCompletePath =
true;
2557 if ( !foundCompletePath ) {
2563 foundCompletePath =
true;
2568 foundOrderedPath =
true;
2573 paths[sumpath] = &l;
2585 vector<Clustering> History::getAllQCDClusterings() {
2586 vector<Clustering> ret;
2589 vector <int> PosFinalPartn;
2590 vector <int> PosInitPartn;
2591 vector <int> PosFinalGluon;
2592 vector <int> PosFinalQuark;
2593 vector <int> PosFinalAntiq;
2594 vector <int> PosInitGluon;
2595 vector <int> PosInitQuark;
2596 vector <int> PosInitAntiq;
2600 for (
int i=0; i < state.size(); ++i )
2601 if ( state[i].isFinal() && state[i].colType() !=0 ) {
2603 if ( state[i].
id() == 21 ) PosFinalGluon.push_back(i);
2604 else if ( state[i].idAbs() < 10 && state[i].
id() > 0)
2605 PosFinalQuark.push_back(i);
2606 else if ( state[i].idAbs() < 10 && state[i].
id() < 0)
2607 PosFinalAntiq.push_back(i);
2608 }
else if (state[i].status() == -21 && state[i].colType() != 0 ) {
2610 if ( state[i].
id() == 21 ) PosInitGluon.push_back(i);
2611 else if ( state[i].idAbs() < 10 && state[i].
id() > 0)
2612 PosInitQuark.push_back(i);
2613 else if ( state[i].idAbs() < 10 && state[i].
id() < 0)
2614 PosInitAntiq.push_back(i);
2618 vector<Clustering> systems;
2619 systems = getQCDClusterings(state);
2620 ret.insert(ret.end(), systems.begin(), systems.end());
2624 if ( !ret.empty() )
return ret;
2629 else if ( ret.empty()
2630 && mergingHooksPtr->allowColourShuffling() ) {
2633 for(
int i = 0; i < int(PosFinalQuark.size()); ++i) {
2635 if ( mergingHooksPtr->hardProcess.matchesAnyOutgoing(PosFinalQuark[i],
2638 int col = NewState[PosFinalQuark[i]].col();
2639 for(
int j = 0; j < int(PosInitAntiq.size()); ++j) {
2641 int acl = NewState[PosInitAntiq[j]].acol();
2642 if ( col == acl )
continue;
2643 NewState[PosFinalQuark[i]].col(acl);
2644 NewState[PosInitAntiq[j]].acol(col);
2645 systems = getQCDClusterings(NewState);
2646 if (!systems.empty()) {
2649 ret.insert(ret.end(), systems.begin(), systems.end());
2656 for(
int i = 0; i < int(PosFinalAntiq.size()); ++i) {
2658 if ( mergingHooksPtr->hardProcess.matchesAnyOutgoing(PosFinalAntiq[i],
2661 int acl = NewState[PosFinalAntiq[i]].acol();
2662 for(
int j = 0; j < int(PosInitQuark.size()); ++j) {
2664 int col = NewState[PosInitQuark[j]].col();
2665 if ( col == acl )
continue;
2666 NewState[PosFinalAntiq[i]].acol(col);
2667 NewState[PosInitQuark[j]].col(acl);
2668 systems = getQCDClusterings(NewState);
2669 if (!systems.empty()) {
2672 ret.insert(ret.end(), systems.begin(), systems.end());
2679 if ( !ret.empty() ) {
2680 string message=
"Warning in History::getAllQCDClusterings: Changed";
2681 message+=
" colour structure to allow at least one clustering.";
2682 infoPtr->errorMsg(message);
2697 vector<Clustering> History::getQCDClusterings(
const Event& event) {
2698 vector<Clustering> ret;
2702 vector <int> PosFinalPartn;
2703 vector <int> PosInitPartn;
2705 vector <int> PosFinalGluon;
2706 vector <int> PosFinalQuark;
2707 vector <int> PosFinalAntiq;
2708 vector <int> PosInitGluon;
2709 vector <int> PosInitQuark;
2710 vector <int> PosInitAntiq;
2714 for (
int i=0; i <
event.size(); ++i)
2715 if ( event[i].isFinal() &&
event[i].colType() !=0 ) {
2717 PosFinalPartn.push_back(i);
2718 if ( event[i].
id() == 21 ) PosFinalGluon.push_back(i);
2719 else if ( event[i].idAbs() < 10 && event[i].
id() > 0)
2720 PosFinalQuark.push_back(i);
2721 else if ( event[i].idAbs() < 10 && event[i].
id() < 0)
2722 PosFinalAntiq.push_back(i);
2723 }
else if ( event[i].status() == -21 && event[i].colType() != 0 ) {
2725 PosInitPartn.push_back(i);
2726 if ( event[i].
id() == 21 ) PosInitGluon.push_back(i);
2727 else if ( event[i].idAbs() < 10 && event[i].
id() > 0)
2728 PosInitQuark.push_back(i);
2729 else if ( event[i].idAbs() < 10 && event[i].
id() < 0)
2730 PosInitAntiq.push_back(i);
2733 int nFiGluon = int(PosFinalGluon.size());
2734 int nFiQuark = int(PosFinalQuark.size());
2735 int nFiAntiq = int(PosFinalAntiq.size());
2736 int nInGluon = int(PosInitGluon.size());
2737 int nInQuark = int(PosInitQuark.size());
2738 int nInAntiq = int(PosInitAntiq.size());
2740 vector<Clustering> systems;
2744 for (
int i = 0; i < nFiGluon; ++i) {
2745 int EmtGluon = PosFinalGluon[i];
2746 systems = findQCDTriple( EmtGluon, 2, event, PosFinalPartn, PosInitPartn);
2747 ret.insert(ret.end(), systems.begin(), systems.end());
2753 bool check_g2qq =
true;
2754 if ( ( ( nInQuark + nInAntiq == 0 )
2756 && (nFiQuark == 1) && (nFiAntiq == 1) )
2757 || ( ( nFiQuark + nFiAntiq == 0)
2758 && (nInQuark == 1) && (nInAntiq == 1) ) )
2765 for(
int i=0; i < nFiQuark; ++i) {
2766 int EmtQuark = PosFinalQuark[i];
2767 systems = findQCDTriple( EmtQuark,1,event, PosFinalPartn, PosInitPartn);
2768 ret.insert(ret.end(), systems.begin(), systems.end());
2774 for(
int i=0; i < nFiAntiq; ++i) {
2775 int EmtAntiq = PosFinalAntiq[i];
2776 systems = findQCDTriple( EmtAntiq,1,event, PosFinalPartn, PosInitPartn);
2777 ret.insert(ret.end(), systems.begin(), systems.end());
2797 vector<Clustering> History::findQCDTriple (
int EmtTagIn,
int colTopIn,
2799 vector<int> PosFinalPartn,
2800 vector <int> PosInitPartn ) {
2803 int EmtTag = EmtTagIn;
2806 int colTop = colTopIn;
2809 int FinalSize = int(PosFinalPartn.size());
2810 int InitSize = int(PosInitPartn.size());
2811 int Size = InitSize + FinalSize;
2813 vector<Clustering> clus;
2817 for (
int a = 0; a < Size; ++a ) {
2818 int i = (a < FinalSize)? a : (a - FinalSize) ;
2819 int iRad = (a < FinalSize)? PosFinalPartn[i] : PosInitPartn[i];
2821 if ( event[iRad].col() ==
event[EmtTag].col()
2822 &&
event[iRad].acol() ==
event[EmtTag].acol() )
2825 if (iRad != EmtTag ) {
2826 int pTdef =
event[iRad].isFinal() ? 1 : -1;
2827 int sign = (a < FinalSize)? 1 : -1 ;
2833 if ( event[iRad].
id() == -sign*
event[EmtTag].id() ) {
2836 if (event[iRad].
id() < 0) {
2837 col =
event[EmtTag].acol();
2838 acl =
event[iRad].acol();
2840 col =
event[EmtTag].col();
2841 acl =
event[iRad].col();
2850 iRec = FindCol(col,iRad,EmtTag,event,1,
true);
2853 if ( (sign < 0) && (event[iRec].isFinal()) ) {
2857 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
2858 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
2864 if ( iRec != 0 && iPartner != 0
2865 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
2866 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
2867 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
2874 iRec = FindCol(col,iRad,EmtTag,event,2,
true);
2877 if ( (sign < 0) && (event[iRec].isFinal()) ) {
2881 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
2882 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
2888 if ( iRec != 0 && iPartner != 0
2889 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
2890 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
2891 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
2902 iRec = FindCol(acl,iRad,EmtTag,event,1,
true);
2905 if ( (sign < 0) && (event[iRec].isFinal()) ) {
2909 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
2910 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
2916 if ( iRec != 0 && iPartner != 0
2917 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
2918 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
2919 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
2926 iRec = FindCol(acl,iRad,EmtTag,event,2,
true);
2929 if ( (sign < 0) && (event[iRec].isFinal()) ) {
2933 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
2934 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
2940 if ( iRec != 0 && iPartner != 0
2941 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
2942 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
2943 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
2948 }
else if ( event[iRad].
id() == 21
2949 &&( event[iRad].col() == event[EmtTag].col()
2950 || event[iRad].acol() == event[EmtTag].acol() )) {
2956 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
2957 if (PosInitPartn[l] != iRad) RecInit = PosInitPartn[l];
2961 int col = getRadBeforeCol(iRad, EmtTag, event);
2962 int acl = getRadBeforeAcol(iRad, EmtTag, event);
2972 int colRemove = (
event[iRad].col() ==
event[EmtTag].col())
2973 ? event[iRad].col() : 0;
2976 if (colRemove > 0 && col > 0)
2977 iPartner = FindCol(col,iRad,EmtTag,event,1,
true)
2978 + FindCol(col,iRad,EmtTag,event,2,
true);
2979 else if (colRemove > 0 && acl > 0)
2980 iPartner = FindCol(acl,iRad,EmtTag,event,1,
true)
2981 + FindCol(acl,iRad,EmtTag,event,2,
true);
2983 if ( allowedClustering( iRad, EmtTag, RecInit, iPartner, event ) ) {
2984 clus.push_back( Clustering(EmtTag, iRad, RecInit, iPartner,
2985 pTLund(event[iRad],event[EmtTag],event[RecInit], pTdef) ));
2993 if ( (event[iRad].col() == event[EmtTag].acol())
2994 || (event[iRad].acol() == event[EmtTag].col())
2995 || (event[iRad].col() == event[EmtTag].col())
2996 || (event[iRad].acol() == event[EmtTag].acol()) ) {
3003 if (event[iRad].isFinal() ) {
3005 if ( event[iRad].
id() < 0) {
3006 acl =
event[EmtTag].acol();
3007 col =
event[iRad].col();
3008 }
else if ( event[iRad].
id() > 0 && event[iRad].
id() < 10) {
3009 col =
event[EmtTag].col();
3010 acl =
event[iRad].acol();
3012 col =
event[iRad].col();
3013 acl =
event[iRad].acol();
3018 iRec = FindCol(col,iRad,EmtTag,event,1,
true);
3019 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3021 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3022 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3023 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3027 iRec = FindCol(col,iRad,EmtTag,event,2,
true);
3028 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3030 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3031 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3032 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3039 iRec = FindCol(acl,iRad,EmtTag,event,1,
true);
3040 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3042 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3043 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3044 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3048 iRec = FindCol(acl,iRad,EmtTag,event,2,
true);
3049 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3051 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3052 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3053 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3067 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3068 if (PosInitPartn[l] != iRad) RecInit = PosInitPartn[l];
3072 col = getRadBeforeCol(iRad, EmtTag, event);
3073 acl = getRadBeforeAcol(iRad, EmtTag, event);
3083 int colRemove = (
event[iRad].col() ==
event[EmtTag].col())
3084 ? event[iRad].col() : 0;
3085 iPartner = (colRemove > 0)
3086 ? FindCol(col,iRad,EmtTag,event,1,
true)
3087 + FindCol(col,iRad,EmtTag,event,2,
true)
3088 : FindCol(acl,iRad,EmtTag,event,1,true)
3089 + FindCol(acl,iRad,EmtTag,event,2,true);
3091 if ( allowedClustering( iRad, EmtTag, RecInit, iPartner, event)) {
3092 clus.push_back( Clustering(EmtTag, iRad, RecInit, iPartner,
3093 pTLund(event[iRad],event[EmtTag],event[RecInit], pTdef)));
3114 vector<Clustering> History::getAllEWClusterings() {
3115 vector<Clustering> ret;
3118 vector<Clustering> systems;
3119 systems = getEWClusterings(state);
3120 ret.insert(ret.end(), systems.begin(), systems.end());
3131 vector<Clustering> History::getEWClusterings(
const Event& event) {
3132 vector<Clustering> ret;
3136 vector <int> PosFinalPartn;
3137 vector <int> PosInitPartn;
3138 vector <int> PosFinalW;
3142 for (
int i=0; i <
event.size(); ++i )
3143 if ( event[i].isFinal() && abs(event[i].colType()) == 1 ) {
3145 PosFinalPartn.push_back(i);
3146 }
else if ( event[i].status() == -21 && abs(event[i].colType()) == 1 ) {
3148 PosInitPartn.push_back(i);
3151 for (
int i=0; i <
event.size(); ++i )
3152 if ( event[i].isFinal() &&
event[i].idAbs() == 24 )
3153 PosFinalW.push_back( i );
3155 vector<Clustering> systems;
3158 for (
int i = 0; i < int(PosFinalW.size()); ++i ) {
3159 int EmtW = PosFinalW[i];
3160 systems = findEWTriple( EmtW, event, PosFinalPartn);
3161 ret.insert(ret.end(), systems.begin(), systems.end());
3180 vector<Clustering> History::findEWTriple (
int EmtTagIn,
const Event& event,
3181 vector<int> PosFinalPartn ) {
3183 int EmtTag = EmtTagIn;
3188 int FinalSize = int(PosFinalPartn.size());
3190 vector<Clustering> clus;
3194 for (
int a = 0; a < FinalSize; ++a ) {
3196 int iRad = PosFinalPartn[a];
3197 if (iRad != EmtTag ) {
3200 int flavRad =
event[iRad].id();
3201 int flavEmt =
event[EmtTag].id();
3204 for (
int i = 0; i < FinalSize; ++i ) {
3205 int iRec = PosFinalPartn[i];
3206 if ( i != a && flavEmt > 0
3207 && event[iRec].
id() == -flavRad - 1 )
3208 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3209 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ) );
3225 vector<Clustering> History::getAllSQCDClusterings() {
3226 vector<Clustering> ret;
3229 vector<Clustering> systems;
3230 systems = getSQCDClusterings(state);
3231 ret.insert(ret.end(), systems.begin(), systems.end());
3242 vector<Clustering> History::getSQCDClusterings(
const Event& event) {
3243 vector<Clustering> ret;
3247 vector <int> PosFinalPartn;
3248 vector <int> PosInitPartn;
3250 vector <int> PosFinalGluon;
3251 vector <int> PosFinalQuark;
3252 vector <int> PosFinalAntiq;
3253 vector <int> PosInitGluon;
3254 vector <int> PosInitQuark;
3255 vector <int> PosInitAntiq;
3259 for (
int i=0; i <
event.size(); ++i)
3260 if ( event[i].isFinal() &&
event[i].colType() !=0 ) {
3262 PosFinalPartn.push_back(i);
3263 if ( event[i].
id() == 21 || event[i].
id() == 1000021)
3264 PosFinalGluon.push_back(i);
3265 else if ( (event[i].idAbs() < 10 && event[i].
id() > 0)
3266 || (event[i].idAbs() < 1000010 && event[i].idAbs() > 1000000
3267 && event[i].
id() > 0)
3268 || (event[i].idAbs() < 2000010 && event[i].idAbs() > 2000000
3269 && event[i].
id() > 0))
3270 PosFinalQuark.push_back(i);
3271 else if ( (event[i].idAbs() < 10 && event[i].
id() < 0)
3272 || (event[i].idAbs() < 1000010 && event[i].idAbs() > 1000000
3273 && event[i].
id() < 0)
3274 || (event[i].idAbs() < 2000010 && event[i].idAbs() > 2000000
3275 && event[i].
id() < 0))
3276 PosFinalAntiq.push_back(i);
3277 }
else if ( event[i].status() == -21 && event[i].colType() != 0 ) {
3279 PosInitPartn.push_back(i);
3280 if ( event[i].
id() == 21 || event[i].
id() == 1000021)
3281 PosInitGluon.push_back(i);
3282 else if ( (event[i].idAbs() < 10 && event[i].
id() > 0)
3283 || (event[i].idAbs() < 1000010 && event[i].idAbs() > 1000000
3284 && event[i].
id() > 0)
3285 || (event[i].idAbs() < 2000010 && event[i].idAbs() > 2000000
3286 && event[i].
id() > 0))
3287 PosInitQuark.push_back(i);
3288 else if ( (event[i].idAbs() < 10 && event[i].
id() < 0)
3289 || (event[i].idAbs() < 1000010 && event[i].idAbs() > 1000000
3290 && event[i].
id() < 0)
3291 || (event[i].idAbs() < 2000010 && event[i].idAbs() > 2000000
3292 && event[i].
id() < 0))
3293 PosInitAntiq.push_back(i);
3296 int nFiGluon = int(PosFinalGluon.size());
3297 int nFiQuark = int(PosFinalQuark.size());
3298 int nFiAntiq = int(PosFinalAntiq.size());
3299 int nInGluon = int(PosInitGluon.size());
3300 int nInQuark = int(PosInitQuark.size());
3301 int nInAntiq = int(PosInitAntiq.size());
3303 vector<Clustering> systems;
3307 for (
int i = 0; i < nFiGluon; ++i) {
3308 int EmtGluon = PosFinalGluon[i];
3309 systems = findSQCDTriple( EmtGluon, 2, event, PosFinalPartn, PosInitPartn);
3310 ret.insert(ret.end(), systems.begin(), systems.end());
3316 bool check_g2qq =
true;
3317 if ( ( ( nInQuark + nInAntiq == 0 )
3319 && (nFiQuark == 1) && (nFiAntiq == 1) )
3320 || ( ( nFiQuark + nFiAntiq == 0)
3321 && (nInQuark == 1) && (nInAntiq == 1) ) )
3328 for(
int i=0; i < nFiQuark; ++i) {
3329 int EmtQuark = PosFinalQuark[i];
3330 systems = findSQCDTriple( EmtQuark,1,event, PosFinalPartn, PosInitPartn);
3331 ret.insert(ret.end(), systems.begin(), systems.end());
3337 for(
int i=0; i < nFiAntiq; ++i) {
3338 int EmtAntiq = PosFinalAntiq[i];
3339 systems = findSQCDTriple( EmtAntiq,1,event, PosFinalPartn, PosInitPartn);
3340 ret.insert(ret.end(), systems.begin(), systems.end());
3360 vector<Clustering> History::findSQCDTriple (
int EmtTagIn,
int colTopIn,
3362 vector<int> PosFinalPartn,
3363 vector <int> PosInitPartn ) {
3366 int EmtTag = EmtTagIn;
3369 int colTop = colTopIn;
3372 int offsetL = 1000000;
3373 int offsetR = 2000000;
3376 int FinalSize = int(PosFinalPartn.size());
3377 int InitSize = int(PosInitPartn.size());
3378 int Size = InitSize + FinalSize;
3380 vector<Clustering> clus;
3384 for (
int a = 0; a < Size; ++a ) {
3385 int i = (a < FinalSize)? a : (a - FinalSize) ;
3386 int iRad = (a < FinalSize)? PosFinalPartn[i] : PosInitPartn[i];
3388 if ( event[iRad].col() ==
event[EmtTag].col()
3389 &&
event[iRad].acol() ==
event[EmtTag].acol() )
3393 int radID =
event[iRad].id();
3395 bool isSQCDrad = (abs(radID) > offsetL);
3397 bool isSQCDemt = (
event[EmtTag].idAbs() > offsetL );
3399 if (iRad != EmtTag ) {
3400 int pTdef =
event[iRad].isFinal() ? 1 : -1;
3401 int sign = (a < FinalSize)? 1 : -1 ;
3404 int radBefID = getRadBeforeFlav(iRad,EmtTag,event);
3405 if ( pTdef == -1 && abs(radBefID) > offsetL )
continue;
3411 int emtSign = (
event[EmtTag].id() < 0) ? -1 : 1;
3414 bool finalSplitting =
false;
3415 if ( abs(radID) < 10
3416 && radID == -sign*emtSign*(offsetL +
event[EmtTag].idAbs()) )
3417 finalSplitting =
true;
3418 if ( abs(radID) < 10
3419 && radID == -sign*emtSign*(offsetR +
event[EmtTag].idAbs()) )
3420 finalSplitting =
true;
3421 if ( abs(radID) > offsetL && abs(radID) < offsetL+10
3422 && radID == -sign*emtSign*(
event[EmtTag].idAbs() - offsetL) )
3423 finalSplitting =
true;
3424 if ( abs(radID) > offsetR && abs(radID) < offsetR+10
3425 && radID == -sign*emtSign*(
event[EmtTag].idAbs() - offsetR) )
3426 finalSplitting =
true;
3429 bool initialSplitting =
false;
3430 if ( radID == 21 && ( ( event[EmtTag].idAbs() > offsetL
3431 && event[EmtTag].idAbs() < offsetL+10)
3432 || (
event[EmtTag].idAbs() > offsetR
3433 &&
event[EmtTag].idAbs() < offsetR+10) )
3434 && (
event[iRad].col() ==
event[EmtTag].col()
3435 ||
event[iRad].acol() ==
event[EmtTag].acol() ) )
3436 initialSplitting =
true;
3438 if ( finalSplitting ) {
3442 if ( radID < 0 && event[iRad].colType() == -1) {
3443 acl =
event[EmtTag].acol();
3444 col =
event[iRad].acol();
3445 }
else if ( event[iRad].colType() == 1 ) {
3446 col =
event[EmtTag].col();
3447 acl =
event[iRad].col();
3457 iRec = FindCol(col,iRad,EmtTag,event,1,
true);
3460 if ( (sign < 0) && (event[iRec].isFinal()) ) {
3464 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3465 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
3473 if ( !isSQCDrad && !isSQCDemt
3474 && (event[iRec].idAbs() < 10 ||
event[iRec].id() == 21) )
3477 if ( iRec != 0 && iPartner != 0
3478 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
3479 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
3480 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
3487 iRec = FindCol(col,iRad,EmtTag,event,2,
true);
3490 if ( (sign < 0) && (event[iRec].isFinal()) ) {
3494 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3495 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
3503 if ( !isSQCDrad && !isSQCDemt
3504 && (event[iRec].idAbs() < 10 ||
event[iRec].id() == 21) )
3507 if ( iRec != 0 && iPartner != 0
3508 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
3509 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
3510 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
3520 iRec = FindCol(acl,iRad,EmtTag,event,1,
true);
3523 if ( (sign < 0) && (event[iRec].isFinal()) ) {
3527 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3528 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
3536 if ( !isSQCDrad && !isSQCDemt
3537 && (event[iRec].idAbs() < 10 ||
event[iRec].id() == 21) )
3540 if ( iRec != 0 && iPartner != 0
3541 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
3542 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
3543 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
3550 iRec = FindCol(acl,iRad,EmtTag,event,2,
true);
3553 if ( (sign < 0) && (event[iRec].isFinal()) ) {
3557 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3558 if (PosInitPartn[l] != iRad) iRec = PosInitPartn[l];
3566 if ( !isSQCDrad && !isSQCDemt
3567 && (event[iRec].idAbs() < 10 ||
event[iRec].id() == 21) )
3570 if ( iRec != 0 && iPartner != 0
3571 && allowedClustering( iRad, EmtTag, iRec, iPartner, event) ) {
3572 clus.push_back( Clustering(EmtTag, iRad, iRec, iPartner,
3573 pTLund(event[iRad], event[EmtTag], event[iRec], pTdef) ));
3578 }
else if ( initialSplitting ) {
3581 if ( !isSQCDrad && !isSQCDemt )
continue;
3588 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3589 if (PosInitPartn[l] != iRad) RecInit = PosInitPartn[l];
3593 int col = getRadBeforeCol(iRad, EmtTag, event);
3594 int acl = getRadBeforeAcol(iRad, EmtTag, event);
3604 int colRemove = (
event[iRad].col() ==
event[EmtTag].col())
3605 ? event[iRad].col() : 0;
3608 if (colRemove > 0 && col > 0)
3609 iPartner = FindCol(col,iRad,EmtTag,event,1,
true)
3610 + FindCol(col,iRad,EmtTag,event,2,
true);
3611 else if (colRemove > 0 && acl > 0)
3612 iPartner = FindCol(acl,iRad,EmtTag,event,1,
true)
3613 + FindCol(acl,iRad,EmtTag,event,2,
true);
3615 if ( allowedClustering( iRad, EmtTag, RecInit, iPartner, event ) ) {
3616 clus.push_back( Clustering(EmtTag, iRad, RecInit, iPartner,
3617 pTLund(event[iRad],event[EmtTag],event[RecInit], pTdef) ));
3626 if ( (event[iRad].col() == event[EmtTag].acol())
3627 || (event[iRad].acol() == event[EmtTag].col())
3628 || (event[iRad].col() == event[EmtTag].col())
3629 || (event[iRad].acol() == event[EmtTag].acol()) ) {
3636 if (event[iRad].isFinal() ) {
3638 if ( radID < 0 && event[iRad].colType() == -1) {
3639 acl =
event[EmtTag].acol();
3640 col =
event[iRad].col();
3641 }
else if ( radID > 0 && event[iRad].colType() == 1 ) {
3642 col =
event[EmtTag].col();
3643 acl =
event[iRad].acol();
3645 col =
event[iRad].col();
3646 acl =
event[iRad].acol();
3651 iRec = FindCol(col,iRad,EmtTag,event,1,
true);
3652 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3654 if ( !isSQCDrad && !isSQCDemt
3655 && (event[iRec].idAbs() < 10 || event[iRec].
id() == 21) )
3658 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3659 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3660 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3664 iRec = FindCol(col,iRad,EmtTag,event,2,
true);
3665 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3667 if ( !isSQCDrad && !isSQCDemt
3668 && (event[iRec].idAbs() < 10 || event[iRec].
id() == 21) )
3671 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3672 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3673 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3679 iRec = FindCol(acl,iRad,EmtTag,event,1,
true);
3680 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3682 if ( !isSQCDrad && !isSQCDemt
3683 && (event[iRec].idAbs() < 10 || event[iRec].
id() == 21) )
3686 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3687 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3688 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3692 iRec = FindCol(acl,iRad,EmtTag,event,2,
true);
3693 if ( (sign < 0) && (event[iRec].isFinal()) ) iRec = 0;
3695 if ( !isSQCDrad && !isSQCDemt
3696 && (event[iRec].idAbs() < 10 || event[iRec].
id() == 21) )
3699 && allowedClustering( iRad, EmtTag, iRec, iRec, event) ) {
3700 clus.push_back( Clustering(EmtTag, iRad, iRec, iRec,
3701 pTLund(event[iRad],event[EmtTag],event[iRec], pTdef) ));
3713 if ( !isSQCDrad || !isSQCDemt )
continue;
3721 for(
int l = 0; l < int(PosInitPartn.size()); ++l)
3722 if (PosInitPartn[l] != iRad) RecInit = PosInitPartn[l];
3726 col = getRadBeforeCol(iRad, EmtTag, event);
3727 acl = getRadBeforeAcol(iRad, EmtTag, event);
3737 int colRemove = (
event[iRad].col() ==
event[EmtTag].col())
3738 ? event[iRad].col() : 0;
3739 iPartner = (colRemove > 0)
3740 ? FindCol(col,iRad,EmtTag,event,1,
true)
3741 + FindCol(col,iRad,EmtTag,event,2,
true)
3742 : FindCol(acl,iRad,EmtTag,event,1,true)
3743 + FindCol(acl,iRad,EmtTag,event,2,true);
3745 if ( allowedClustering( iRad, EmtTag, RecInit, iPartner, event)) {
3746 clus.push_back( Clustering(EmtTag, iRad, RecInit, iPartner,
3747 pTLund(event[iRad],event[EmtTag],event[RecInit], pTdef)));
3769 double History::getProb(
const Clustering & SystemIn) {
3772 int Rad = SystemIn.emittor;
3773 int Rec = SystemIn.recoiler;
3774 int Emt = SystemIn.emitted;
3777 double showerProb = 0.0;
3781 if (SystemIn.pT() <= 0.)
return 0.;
3790 bool isFSR = (state[Rad].isFinal() && state[Rec].isFinal());
3791 bool isFSRinREC = (state[Rad].isFinal() && !state[Rec].isFinal());
3792 bool isISR = !state[Rad].isFinal();
3797 for(
int i=0; i < state.size(); ++i)
3798 if (state[i].isFinal()) nFinal++;
3799 bool isLast = (nFinal == (mergingHooksPtr->hardProcess.nQuarksOut()
3800 +mergingHooksPtr->hardProcess.nLeptonOut()+1));
3807 for(
int i=0;i< int(state.size()); ++i) {
3808 if (state[i].mother1() == 1) inP = i;
3809 if (state[i].mother1() == 2) inM = i;
3812 Vec4 sum = state[Rad].p() + state[Rec].p() - state[Emt].p();
3813 double m2Dip = sum.m2Calc();
3814 double sHat = (state[inM].p() + state[inP].p()).m2Calc();
3816 double z1 = m2Dip / sHat;
3818 Vec4 Q1( state[Rad].p() - state[Emt].p() );
3819 Vec4 Q2( state[Rec].p() - state[Emt].p() );
3821 double Q1sq = -Q1.m2Calc();
3823 double pT1sq = pow(SystemIn.pT(),2);
3826 bool g2QQmassive = mergingHooksPtr->includeMassive()
3827 && state[Rad].id() == 21
3828 && ( (state[Emt].idAbs() >= 4 && state[Emt].idAbs() < 7)
3829 || (state[Emt].idAbs() > 1000000 && state[Emt].idAbs() < 1000010 )
3830 || (state[Emt].idAbs() > 2000000 && state[Emt].idAbs() < 2000010 ));
3831 bool Q2Qgmassive = mergingHooksPtr->includeMassive()
3832 && state[Emt].id() == 21
3833 && ( (state[Rad].idAbs() >= 4 && state[Rad].idAbs() < 7)
3834 || (state[Rad].idAbs() > 1000000 && state[Rad].idAbs() < 1000010 )
3835 || (state[Rad].idAbs() > 2000000 && state[Rad].idAbs() < 2000010 ));
3836 bool isMassive = mergingHooksPtr->includeMassive()
3837 && ( g2QQmassive || Q2Qgmassive
3838 || state[Emt].id() == 1000021);
3839 double m2Emt0 = pow(particleDataPtr->m0(state[Emt].id()),2);
3840 double m2Rad0 = pow(particleDataPtr->m0(state[Rad].id()),2);
3843 if ( g2QQmassive) Q1sq += m2Emt0;
3844 else if (Q2Qgmassive) Q1sq += m2Rad0;
3847 double pT0sq = pow(mergingHooksPtr->pT0ISR(),2);
3848 double Q2sq = -Q2.m2Calc();
3851 bool g2QQmassiveRec = mergingHooksPtr->includeMassive()
3852 && state[Rec].id() == 21
3853 && ( state[Emt].idAbs() >= 4 && state[Emt].idAbs() < 7);
3854 bool Q2QgmassiveRec = mergingHooksPtr->includeMassive()
3855 && state[Emt].id() == 21
3856 && ( state[Rec].idAbs() >= 4 && state[Rec].idAbs() < 7);
3857 double m2Rec0 = pow(particleDataPtr->m0(state[Rad].id()),2);
3858 if ( g2QQmassiveRec) Q2sq += m2Emt0;
3859 else if (Q2QgmassiveRec) Q2sq += m2Rec0;
3861 bool hasJoinedEvol = (state[Emt].id() == 21
3862 || state[Rad].id() == state[Rec].id());
3867 if ( mergingHooksPtr->pickByFull() || mergingHooksPtr->pickBySumPT()) {
3868 double facJoined = ( Q2sq + pT0sq/(1.-z1) )
3869 * 1./(Q1sq*Q2sq + pT0sq*sHat + pow(pT0sq/(1.-z1),2));
3870 double facSingle = mergingHooksPtr->nonJoinedNorm()*1./( pT1sq + pT0sq);
3872 fac = (hasJoinedEvol && isLast) ? facJoined : facSingle;
3874 }
else if (mergingHooksPtr->pickByPoPT2()) {
3875 fac = 1./(pT1sq + pT0sq);
3877 string message=
"Error in History::getProb: Scheme for calculating";
3878 message+=
" shower splitting probability is undefined.";
3879 infoPtr->errorMsg(message);
3886 if ( state[Emt].
id() == 21 && state[Rad].
id() != 21) {
3888 double num = CF*(1. + pow(z1,2)) / (1.-z1);
3889 if (isMassive) num -= CF * z1 * (1.-z1) * (m2Rad0/pT1sq);
3892 double meReweighting = 1.;
3896 for(
int i=0; i < state.size(); ++i)
3897 if (state[i].isFinal() && state[i].colType() != 0
3898 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,state) )
3903 &&
int(mergingHooksPtr->hardProcess.hardIntermediate.size()) == 1) {
3904 double sH = m2Dip / z1;
3906 double uH = Q1sq - m2Dip * (1. - z1) / z1;
3907 double misMatch = (uH*tH - (uH + tH)*pT0sq/(1.-z1)
3908 + pow(pT0sq/(1.-z1),2) ) / (uH*tH);
3909 meReweighting *= (tH*tH + uH*uH + 2. * m2Dip * sH)
3910 / (sH*sH + m2Dip*m2Dip);
3911 meReweighting *= misMatch;
3914 showerProb = num*fac*meReweighting;
3917 }
else if ( state[Emt].
id() == 21 && state[Rad].id() == 21) {
3919 double num = 2.*NC*pow2(1. - z1*(1.-z1)) / (z1*(1.-z1));
3923 double meReweighting = 1.;
3927 for(
int i=0; i < state.size(); ++i)
3928 if (state[i].isFinal() && state[i].colType() != 0
3929 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,state) )
3934 && mergingHooksPtr->getProcessString().compare(
"pp>h") == 0
3935 && int(mergingHooksPtr->hardProcess.hardIntermediate.size()) == 1 ) {
3936 double sH = m2Dip / z1;
3938 double uH = Q1sq - m2Dip * (1. - z1) / z1;
3939 meReweighting *= 0.5
3940 * (pow4(sH) + pow4(tH) + pow4(uH) + pow4(m2Dip))
3941 / pow2(sH*sH - m2Dip * (sH - m2Dip));
3945 showerProb = num*fac*meReweighting;
3948 }
else if ( state[Emt].
id() != 21 && state[Rad].id() != 21 ) {
3950 double num = CF*(1. + pow2(1.-z1)) / z1;
3954 double meReweighting = 1.;
3958 for (
int i=0; i < state.size(); ++i )
3959 if ( state[i].isFinal() && state[i].colType() != 0
3960 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,state) )
3965 && mergingHooksPtr->getProcessString().compare(
"pp>h") == 0
3966 && int(mergingHooksPtr->hardProcess.hardIntermediate.size()) == 1) {
3967 double sH = m2Dip / z1;
3968 double uH = Q1sq - m2Dip * (1. - z1) / z1;
3969 meReweighting *= (sH*sH + uH*uH)
3970 / (sH*sH + pow2(sH -m2Dip));
3974 showerProb = num*fac*meReweighting;
3977 }
else if ( state[Emt].
id() != 21 && state[Rad].id() == 21 ) {
3979 double num = TR * ( pow(z1,2) + pow(1.-z1,2) );
3980 if (isMassive) num += TR * 2.*z1*(1.-z1)*(m2Emt0/pT1sq);
3982 double meReweighting = 1.;
3986 for (
int i=0; i < state.size(); ++i )
3987 if ( state[i].isFinal() && state[i].colType() != 0
3988 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,state) )
3993 &&
int(mergingHooksPtr->hardProcess.hardIntermediate.size()) == 1) {
3994 double sH = m2Dip / z1;
3996 double uH = Q1sq - m2Dip * (1. - z1) / z1;
3998 double misMatch = ( uH - pT0sq/(1.-z1) ) / uH;
3999 double me = (sH*sH + uH*uH + 2. * m2Dip * tH)
4000 / (pow2(sH - m2Dip) + m2Dip*m2Dip);
4002 meReweighting *= me;
4003 meReweighting *= misMatch;
4006 showerProb = num*fac*meReweighting;
4010 string message =
"Error in History::getProb: Splitting kernel"
4011 " undefined in ISR in clustering.";
4012 infoPtr->errorMsg(message);
4016 double m2Sister0 = pow(state[Emt].m0(),2);
4017 double pT2corr = (Q1sq - z1*(m2Dip + Q1sq)*(Q1sq + m2Sister0)/m2Dip);
4018 if (pT2corr < 0.) showerProb *= 1e-9;
4022 if ( state[Emt].
id() == state[Rad].id()
4023 && ( state[Rad].idAbs() == 4 || state[Rad].idAbs() == 5 )) {
4024 double m2QQsister = 2.*4.*m2Sister0;
4025 double pT2QQcorr = Q1sq - z1*(m2Dip + Q1sq)*(Q1sq + m2QQsister)
4027 if (pT2QQcorr < 0.0) showerProb *= 1e-9;
4030 if (mergingHooksPtr->includeRedundant()) {
4032 AlphaStrong* asISR = mergingHooksPtr->AlphaS_ISR();
4033 double as = (*asISR).alphaS(pT1sq + pT0sq) / (2.*M_PI);
4040 }
else if (isFSR || isFSRinREC) {
4043 Vec4 sum = state[Rad].p() + state[Rec].p() + state[Emt].p();
4044 double m2Dip = sum.m2Calc();
4046 double x1 = 2. * (sum * state[Rad].p()) / m2Dip;
4047 double x2 = 2. * (sum * state[Rec].p()) / m2Dip;
4048 double prop1 = max(1e-12, 1. - x1);
4049 double prop2 = max(1e-12, 1. - x2);
4050 double x3 = max(1e-12, 2. - x1 - x2);
4052 double z1 = x1/(x1 + x3);
4055 Vec4 Q1( state[Rad].p() + state[Emt].p() );
4056 Vec4 Q2( state[Rec].p() + state[Emt].p() );
4059 double Q1sq = Q1.m2Calc();
4061 double pT1sq = pow(SystemIn.pT(),2);
4063 double Q2sq = Q2.m2Calc();
4066 bool isMassiveRad = ( state[Rad].idAbs() >= 4
4067 && state[Rad].id() != 21 );
4068 bool isMassiveRec = ( state[Rec].idAbs() >= 4
4069 && state[Rec].id() != 21 );
4071 double m2Rad0 = pow(particleDataPtr->m0(state[Rad].id()),2);
4072 double m2Rec0 = pow(particleDataPtr->m0(state[Rad].id()),2);
4073 if ( mergingHooksPtr->includeMassive() && isMassiveRad ) Q1sq -= m2Rad0;
4074 if ( mergingHooksPtr->includeMassive() && isMassiveRec ) Q2sq -= m2Rec0;
4079 if ( mergingHooksPtr->pickByFull() || mergingHooksPtr->pickBySumPT()) {
4080 double facJoined = (1.-z1)/Q1sq * m2Dip/( Q1sq + Q2sq );
4081 double facSingle = mergingHooksPtr->fsrInRecNorm() * 1./ pT1sq;
4082 fac = (!isFSRinREC && isLast) ? facJoined : facSingle;
4083 }
else if (mergingHooksPtr->pickByPoPT2()) {
4086 string message=
"Error in History::getProb: Scheme for calculating";
4087 message+=
" shower splitting probability is undefined.";
4088 infoPtr->errorMsg(message);
4094 if ( state[Emt].
id() == 21 && state[Rad].
id() == 21) {
4096 double num = 0.5* NC * (1. + pow3(z1)) / (1.-z1);
4098 showerProb = num*fac;
4101 }
else if ( state[Emt].
id() == 21
4102 && state[Rad].
id() != 21 && state[Rec].
id() != 21) {
4105 double num = CF * 2./(1.-z1);
4109 for(
int i=0; i < state.size(); ++i)
4110 if (state[i].isFinal() && state[i].colType() != 0
4111 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,state) )
4115 ||
int(mergingHooksPtr->hardProcess.hardIntermediate.size()) > 1)
4116 num = CF * (1. + pow2(z1)) /(1.-z1);
4118 double meReweighting = 1.;
4122 &&
int(mergingHooksPtr->hardProcess.hardIntermediate.size()) == 1 ) {
4124 double ShowerRate1 = 2./( x3 * prop2 );
4125 double meDividingFactor1 = prop1 / x3;
4126 double me = (pow(x1,2) + pow(x2,2))/(prop1*prop2);
4127 meReweighting = meDividingFactor1 * me / ShowerRate1;
4130 showerProb = num*fac*meReweighting;
4133 }
else if ( state[Emt].idAbs() == 24
4134 && state[Rad].id() != 21 && state[Rec].id() != 21 ) {
4135 double m2W = state[Emt].p().m2Calc();
4136 double num = ( 3.*pow2(m2W / m2Dip)
4137 + 2.* (m2W/m2Dip)*(x1 + x2)
4138 + pow2(x1) + pow2(x2) ) / ( prop1*prop2 )
4139 - (m2W/m2Dip) / pow2(prop1)
4140 - (m2W/m2Dip) / pow2(prop2);
4142 showerProb = num*fac;
4145 }
else if ( state[Emt].
id() == 21 && state[Rad].id() != 21
4146 && state[Rec].id() == 21 ) {
4150 double num = CF * (1. + pow2(z1)) / (1.-z1);
4151 showerProb = num*fac;
4154 }
else if ( state[Emt].
id() != 21 ) {
4156 int flavour = state[Emt].id();
4159 double mFlavour = particleDataPtr->m0(flavour);
4161 double mDipole = m(state[Rad].p(), state[Emt].p());
4163 double beta = sqrtpos( 1. - 4.*pow2(mFlavour)/pow2(mDipole) );
4165 double num = 0.5*TR * ( z1*z1 + (1.-z1)*(1.-z1) );
4166 if (beta <= 0.) beta = 0.;
4168 showerProb = num*fac*beta;
4172 string message=
"Error in History::getProb: Splitting kernel undefined";
4173 message+=
" in FSR clustering.";
4174 infoPtr->errorMsg(message);
4177 if (mergingHooksPtr->includeRedundant()) {
4179 AlphaStrong* asFSR = mergingHooksPtr->AlphaS_FSR();
4180 double as = (*asFSR).alphaS(pT1sq) / (2.*M_PI);
4187 string message=
"Error in History::getProb: Radiation could not be";
4188 message+=
" interpreted as FSR or ISR.";
4189 infoPtr->errorMsg(message);
4192 if (showerProb <= 0.) showerProb = 0.;
4222 void History::setupBeams() {
4227 if (state.size() < 4)
return;
4229 if ( state[3].colType() == 0 )
return;
4230 if ( state[4].colType() == 0 )
return;
4236 for(
int i=0;i< int(state.size()); ++i) {
4237 if (state[i].mother1() == 1) inP = i;
4238 if (state[i].mother1() == 2) inM = i;
4243 int motherPcompRes = -1;
4244 int motherMcompRes = -1;
4246 bool sameFlavP =
false;
4247 bool sameFlavM =
false;
4252 for(
int i=0;i< int(mother->state.size()); ++i) {
4253 if (mother->state[i].mother1() == 1) inMotherP = i;
4254 if (mother->state[i].mother1() == 2) inMotherM = i;
4256 sameFlavP = (state[inP].id() == mother->state[inMotherP].id());
4257 sameFlavM = (state[inM].id() == mother->state[inMotherM].id());
4259 motherPcompRes = (sameFlavP) ? beamA[0].companion() : -2;
4260 motherMcompRes = (sameFlavM) ? beamB[0].companion() : -2;
4268 double Ep = 2. * state[inP].e();
4269 double Em = 2. * state[inM].e();
4272 if (state[inP].m() != 0. || state[inM].m() != 0.) {
4273 Ep = state[inP].pPos() + state[inM].pPos();
4274 Em = state[inP].pNeg() + state[inM].pNeg();
4278 double x1 = Ep / state[inS].m();
4279 beamA.append( inP, state[inP].
id(), x1);
4280 double x2 = Em / state[inS].m();
4281 beamB.append( inM, state[inM].
id(), x2);
4285 double scalePDF = (mother) ? scale : infoPtr->QFac();
4289 beamA.xfISR( 0, state[inP].
id(), x1, scalePDF*scalePDF);
4291 beamA.pickValSeaComp();
4293 beamA[0].companion(motherPcompRes);
4295 beamB.xfISR( 0, state[inM].
id(), x2, scalePDF*scalePDF);
4297 beamB.pickValSeaComp();
4299 beamB[0].companion(motherMcompRes);
4309 double History::pdfForSudakov() {
4312 if ( state[3].colType() == 0 )
return 1.0;
4313 if ( state[4].colType() == 0 )
return 1.0;
4316 bool FSR = ( mother->state[clusterIn.emittor].isFinal()
4317 && mother->state[clusterIn.recoiler].isFinal());
4318 bool FSRinRec = ( mother->state[clusterIn.emittor].isFinal()
4319 && !mother->state[clusterIn.recoiler].isFinal());
4322 if (FSR)
return 1.0;
4324 int iInMother = (FSRinRec)? clusterIn.recoiler : clusterIn.emittor;
4326 int side = ( mother->state[iInMother].pz() > 0 ) ? 1 : -1;
4330 for(
int i=0;i< int(state.size()); ++i) {
4331 if (state[i].mother1() == 1) inP = i;
4332 if (state[i].mother1() == 2) inM = i;
4336 int idMother = mother->state[iInMother].id();
4338 int iDau = (side == 1) ? inP : inM;
4339 int idDaughter = state[iDau].id();
4341 double xMother = 2. * mother->state[iInMother].e() / mother->state[0].e();
4343 double xDaughter = 2.*state[iDau].e() / state[0].e();
4346 double ratio = getPDFratio(side,
true,
false, idMother, xMother, scale,
4347 idDaughter, xDaughter, scale);
4352 return ( (FSRinRec)? min(1.,ratio) : ratio);
4360 double History::hardProcessME(
const Event& event ) {
4363 string process = mergingHooksPtr->getProcessString();
4366 if ( process.compare(
"pp>e+ve") == 0
4367 || process.compare(
"pp>e-ve~") == 0
4368 || process.compare(
"pp>LEPTONS,NEUTRINOS") == 0 ) {
4371 for (
int i=0; i < int(event.size()); ++i )
4372 if ( event[i].isFinal() ) nFinal++;
4373 if ( nFinal != 2 )
return 1.;
4375 double mW = particleDataPtr->m0(24);
4376 double gW = particleDataPtr->mWidth(24) / mW;
4378 int inP = (
event[3].pz() > 0) ? 3 : 4;
4379 int inM = (
event[3].pz() > 0) ? 4 : 3;
4382 for (
int i=0; i < int(event.size()); ++i ) {
4383 if ( event[i].isFinal() &&
event[i].px() > 0 ) outP = i;
4386 double sH = (
event[inP].p() +
event[inM].p()).m2Calc();
4387 double tH = (
event[inP].p() -
event[outP].p()).m2Calc();
4388 double uH = - sH - tH;
4391 result = ( 1. + (tH - uH)/sH ) / ( pow2(sH - mW*mW) + pow2(sH*gW) );
4393 result = mergingHooksPtr->hardProcessME(event);
4406 Event History::cluster(
const Clustering & inSystem ) {
4409 int Rad = inSystem.emittor;
4410 int Rec = inSystem.recoiler;
4411 int Emt = inSystem.emitted;
4413 double eCM = state[0].e();
4415 int radType = state[Rad].isFinal() ? 1 : -1;
4416 int recType = state[Rec].isFinal() ? 1 : -1;
4420 NewEvent.init(
"(hard process-modified)", particleDataPtr);
4423 for (
int i = 0; i < state.size(); ++i)
4424 if ( i != Rad && i != Rec && i != Emt )
4425 NewEvent.append( state[i] );
4428 for (
int i = 0; i < state.sizeJunction(); ++i)
4429 NewEvent.appendJunction( state.getJunction(i) );
4431 double mu = choseHardScale(state);
4433 NewEvent.saveSize();
4434 NewEvent.saveJunctionSize();
4436 NewEvent.scaleSecond(mu);
4440 Particle RecBefore = Particle( state[Rec] );
4441 RecBefore.setEvtPtr(&NewEvent);
4442 RecBefore.daughters(0,0);
4444 int radID = getRadBeforeFlav(Rad, Emt, state);
4445 int recID = state[Rec].id();
4446 Particle RadBefore = Particle( state[Rad] );
4447 RadBefore.setEvtPtr(&NewEvent);
4448 RadBefore.id(radID);
4449 RadBefore.daughters(0,0);
4451 RadBefore.cols(RecBefore.acol(),RecBefore.col());
4454 if ( particleDataPtr->isResonance(radID) && radType == 1)
4455 RadBefore.status(state[Rad].status());
4458 double radMass = particleDataPtr->m0(radID);
4459 double recMass = particleDataPtr->m0(recID);
4460 if (radType == 1 ) RadBefore.m(radMass);
4461 else RadBefore.m(0.0);
4462 if (recType == 1 ) RecBefore.m(recMass);
4463 else RecBefore.m(0.0);
4467 if ( radType + recType == 2 && state[Emt].idAbs() != 24 ) {
4470 Vec4 sum = state[Rad].p() + state[Rec].p() + state[Emt].p();
4471 double eCMME = sum.mCalc();
4477 double mDsq = pow2(eCMME);
4479 double mRsq = (radID == state[Rad].id() )
4480 ? abs(state[Rad].p().m2Calc())
4481 : pow2(particleDataPtr->m0(radID));
4482 double mSsq = abs(state[Rec].p().m2Calc());
4483 double a = 0.5*sqrt(mDsq);
4484 double b = 0.25*(mRsq - mSsq) / a;
4485 double c = sqrt(pow2(a) + pow2(b) - 2.*a*b - mSsq);
4487 Rad4mom.p( 0., 0., c, a+b);
4488 Rec4mom.p( 0., 0.,-c, a-b);
4491 Vec4 old1 = Vec4(state[Rad].p() + state[Emt].p());
4492 Vec4 old2 = Vec4(state[Rec].p());
4493 RotBstMatrix fromCM;
4494 fromCM.fromCMframe(old1, old2);
4496 Rad4mom.rotbst(fromCM);
4497 Rec4mom.rotbst(fromCM);
4499 RadBefore.p(Rad4mom);
4500 RecBefore.p(Rec4mom);
4501 RadBefore.m(sqrt(mRsq));
4502 RecBefore.m(sqrt(mSsq));
4504 }
else if ( radType + recType == 2 && state[Emt].idAbs() == 24 ) {
4507 Vec4 sum = state[Rad].p() + state[Rec].p() + state[Emt].p();
4508 double eCMME = sum.mCalc();
4514 double mDsq = pow2(eCMME);
4516 double mRsq = (radID == state[Rad].id() )
4517 ? abs(state[Rad].p().m2Calc())
4518 : pow2(particleDataPtr->m0(radID));
4519 double mSsq = abs(state[Rec].p().m2Calc());
4520 double a = 0.5*sqrt(mDsq);
4521 double b = 0.25*(mRsq - mSsq) / a;
4522 double c = sqrt(pow2(a) + pow2(b) - 2.*a*b - mSsq);
4524 Rad4mom.p( 0., 0., c, a+b);
4525 Rec4mom.p( 0., 0.,-c, a-b);
4528 Vec4 old1 = Vec4(state[Rad].p() + state[Emt].p());
4529 Vec4 old2 = Vec4(state[Rec].p());
4530 RotBstMatrix fromCM;
4531 fromCM.fromCMframe(old1, old2);
4533 Rad4mom.rotbst(fromCM);
4534 Rec4mom.rotbst(fromCM);
4536 RadBefore.p(Rad4mom);
4537 RecBefore.p(Rec4mom);
4538 RadBefore.m(sqrt(mRsq));
4539 RecBefore.m(sqrt(mSsq));
4541 }
else if ( radType + recType == 0 ) {
4544 Vec4 sum = state[Rad].p() + state[Rec].p() + state[Emt].p();
4545 double eCMME = sum.mCalc();
4550 double mDsq = pow2(eCMME);
4552 double mRsq = (radID == state[Rad].id() )
4553 ? abs(state[Rad].p().m2Calc())
4554 : pow2(particleDataPtr->m0(radID));
4555 double mSsq = abs(state[Rec].p().m2Calc());
4556 double a = 0.5*sqrt(mDsq);
4557 double b = 0.25*(mRsq - mSsq) / a;
4558 double c = sqrt(pow2(a) + pow2(b) - 2.*a*b - mSsq);
4560 Rad4mom.p( 0., 0., c, a+b);
4561 Rec4mom.p( 0., 0.,-c, a-b);
4564 Vec4 old1 = Vec4(state[Rad].p() + state[Emt].p());
4565 Vec4 old2 = Vec4(state[Rec].p());
4566 RotBstMatrix fromCM;
4567 fromCM.fromCMframe(old1, old2);
4569 Rad4mom.rotbst(fromCM);
4570 Rec4mom.rotbst(fromCM);
4573 Rec4mom = 2.*state[Rec].p() - Rec4mom;
4575 RadBefore.p(Rad4mom);
4576 RecBefore.p(Rec4mom);
4577 RadBefore.m(sqrt(mRsq));
4589 Vec4 pMother( state[Rad].p() );
4590 Vec4 pSister( state[Emt].p() );
4591 Vec4 pPartner( state[Rec].p() );
4592 Vec4 pDaughter( 0.,0.,0.,0. );
4593 Vec4 pRecoiler( 0.,0.,0.,0. );
4596 int sign = (state[Rad].pz() > 0.) ? 1 : -1;
4600 double phi = pSister.phi();
4602 RotBstMatrix rot_by_mphi;
4603 rot_by_mphi.rot(0.,-phi);
4605 RotBstMatrix rot_by_pphi;
4606 rot_by_pphi.rot(0.,phi);
4609 pMother.rotbst( rot_by_mphi );
4610 pSister.rotbst( rot_by_mphi );
4611 pPartner.rotbst( rot_by_mphi );
4612 for(
int i=3; i< NewEvent.size(); ++i)
4613 NewEvent[i].rotbst( rot_by_mphi );
4617 double x1 = 2. * pMother.e() / eCM;
4619 double x2 = 2. * pPartner.e() / eCM;
4621 pDaughter.p( pMother - pSister);
4622 pRecoiler.p( pPartner );
4626 RotBstMatrix from_CM_to_DR;
4628 from_CM_to_DR.toCMframe(pDaughter, pRecoiler);
4630 from_CM_to_DR.toCMframe(pRecoiler, pDaughter);
4633 pMother.rotbst( from_CM_to_DR );
4634 pPartner.rotbst( from_CM_to_DR );
4635 pSister.rotbst( from_CM_to_DR );
4636 for(
int i=3; i< NewEvent.size(); ++i)
4637 NewEvent[i].rotbst( from_CM_to_DR );
4641 double theta = pMother.theta();
4642 if ( pMother.px() < 0. ) theta *= -1.;
4643 if (sign == -1) theta += M_PI;
4647 RotBstMatrix rot_by_ptheta;
4648 rot_by_ptheta.rot(theta, 0.);
4651 pMother.rotbst( rot_by_ptheta );
4652 pPartner.rotbst( rot_by_ptheta );
4653 pSister.rotbst( rot_by_ptheta );
4654 for(
int i=3; i< NewEvent.size(); ++i)
4655 NewEvent[i].rotbst( rot_by_ptheta );
4658 Vec4 qDip( pMother - pSister);
4659 Vec4 qAfter(pMother + pPartner);
4660 Vec4 qBefore(qDip + pPartner);
4661 double z = qBefore.m2Calc() / qAfter.m2Calc();
4664 double x1New = z*x1;
4666 double sHat = x1New*x2New*eCM*eCM;
4669 pDaughter.p( 0., 0., sign*0.5*sqrt(sHat), 0.5*sqrt(sHat));
4670 pRecoiler.p( 0., 0., -sign*0.5*sqrt(sHat), 0.5*sqrt(sHat));
4675 RotBstMatrix from_DR_to_CM;
4676 from_DR_to_CM.bst( 0., 0., sign*( x1New - x2New ) / ( x1New + x2New ) );
4679 pMother.rotbst( from_DR_to_CM );
4680 pPartner.rotbst( from_DR_to_CM );
4681 pSister.rotbst( from_DR_to_CM );
4682 pDaughter.rotbst( from_DR_to_CM );
4683 pRecoiler.rotbst( from_DR_to_CM );
4684 for(
int i=3; i< NewEvent.size(); ++i)
4685 NewEvent[i].rotbst( from_DR_to_CM );
4688 pMother.rotbst( rot_by_pphi );
4689 pPartner.rotbst( rot_by_pphi );
4690 pSister.rotbst( rot_by_pphi );
4691 pDaughter.rotbst( rot_by_pphi );
4692 pRecoiler.rotbst( rot_by_pphi );
4693 for(
int i=3; i< NewEvent.size(); ++i)
4694 NewEvent[i].rotbst( rot_by_pphi );
4697 RecBefore.p( pRecoiler );
4698 RadBefore.p( pDaughter );
4699 if (RecBefore.pz() > 0.) RecBefore.mother1(1);
4700 else RecBefore.mother1(2);
4701 if (RadBefore.pz() > 0.) RadBefore.mother1(1);
4702 else RadBefore.mother1(2);
4707 RecBefore.scale(mu);
4708 RadBefore.scale(mu);
4711 NewEvent.append(RecBefore);
4715 int emtID = state[Emt].id();
4716 if ( emtID == 22 || emtID == 23 || abs(emtID) == 24 )
4717 RadBefore.cols( state[Rad].col(), state[Rad].acol() );
4719 else if ( !connectRadiator( RadBefore, radType, RecBefore, recType,
4729 outState.init(
"(hard process-modified)", particleDataPtr);
4733 for (
int i = 0; i < 3; ++i)
4734 outState.append( NewEvent[i] );
4736 for (
int i = 0; i < state.sizeJunction(); ++i)
4737 outState.appendJunction( state.getJunction(i) );
4739 outState.saveSize();
4740 outState.saveJunctionSize();
4742 outState.scaleSecond(mu);
4743 bool radAppended =
false;
4744 bool recAppended =
false;
4745 int size = int(outState.size());
4750 if ( RecBefore.mother1() == 1) {
4751 outState.append( RecBefore );
4753 }
else if ( RadBefore.mother1() == 1 ) {
4754 radPos = outState.append( RadBefore );
4759 for(
int i=0; i < int(state.size()); ++i)
4760 if (state[i].mother1() == 1) in1 =i;
4761 outState.append( state[in1] );
4765 if ( RecBefore.mother1() == 2) {
4766 outState.append( RecBefore );
4768 }
else if ( RadBefore.mother1() == 2 ) {
4769 radPos = outState.append( RadBefore );
4774 for(
int i=0; i < int(state.size()); ++i)
4775 if (state[i].mother1() == 2) in2 =i;
4777 outState.append( state[in2] );
4782 if (!recAppended && !RecBefore.isFinal()) {
4784 outState.append( RecBefore);
4787 if (!radAppended && !RadBefore.isFinal()) {
4789 radPos = outState.append( RadBefore);
4796 for (
int i = 0; i < int(NewEvent.size()-1); ++i)
4797 if (NewEvent[i].status() == -22) outState.append( NewEvent[i] );
4799 for (
int i = 0; i < int(NewEvent.size()-1); ++i)
4800 if (NewEvent[i].status() == 22) outState.append( NewEvent[i] );
4802 if (!radAppended && RadBefore.statusAbs() == 22)
4803 radPos = outState.append(RadBefore);
4805 outState.append(RecBefore);
4806 if (!radAppended && RadBefore.statusAbs() != 22)
4807 radPos = outState.append(RadBefore);
4809 for(
int i = 0; i < int(NewEvent.size()-1); ++i)
4810 if ( NewEvent[i].status() != 22
4811 && NewEvent[i].colType() != 0
4812 && NewEvent[i].isFinal())
4813 outState.append( NewEvent[i] );
4815 for(
int i = 0; i < int(NewEvent.size()-1); ++i)
4816 if ( NewEvent[i].status() != 22
4817 && NewEvent[i].colType() == 0
4818 && NewEvent[i].isFinal() )
4819 outState.append( NewEvent[i]);
4822 vector<int> PosIntermediate;
4823 vector<int> PosDaughter1;
4824 vector<int> PosDaughter2;
4825 for(
int i=0; i < int(outState.size()); ++i)
4826 if (outState[i].status() == -22) {
4827 PosIntermediate.push_back(i);
4828 int d1 = outState[i].daughter1();
4829 int d2 = outState[i].daughter2();
4831 int daughter1 = FindParticle( state[d1], outState);
4832 int daughter2 = FindParticle( state[d2], outState);
4837 PosDaughter1.push_back( daughter1);
4840 while(!outState[daughter1].isFinal() ) daughter1++;
4841 PosDaughter1.push_back( daughter1);
4844 PosDaughter2.push_back( daughter2);
4846 daughter2 = outState.size()-1;
4847 while(!outState[daughter2].isFinal() ) daughter2--;
4848 PosDaughter2.push_back( daughter2);
4852 for(
int i=0; i < int(PosIntermediate.size()); ++i) {
4853 outState[PosIntermediate[i]].daughters(PosDaughter1[i],PosDaughter2[i]);
4854 outState[PosDaughter1[i]].mother1(PosIntermediate[i]);
4855 outState[PosDaughter2[i]].mother1(PosIntermediate[i]);
4859 int minParFinal = int(outState.size());
4860 int maxParFinal = 0;
4861 for(
int i=0; i < int(outState.size()); ++i)
4862 if (outState[i].mother1() == 3 && outState[i].mother2() == 4) {
4863 minParFinal = min(i,minParFinal);
4864 maxParFinal = max(i,maxParFinal);
4867 if (minParFinal == maxParFinal) maxParFinal = 0;
4868 outState[3].daughters(minParFinal,maxParFinal);
4869 outState[4].daughters(minParFinal,maxParFinal);
4872 outState.saveSize();
4873 outState.saveJunctionSize();
4887 if ( radType == -1 && state[Rad].colType() == 1) {
4889 for(
int i=0; i < int(state.size()); ++i)
4890 if ( i != Rad && i != Emt && i != Rec
4891 && state[i].status() == -22
4892 && state[i].col() == state[Rad].col() )
4894 }
else if ( radType == -1 && state[Rad].colType() == -1) {
4896 for(
int i=0; i < int(state.size()); ++i)
4897 if ( i != Rad && i != Emt && i != Rec
4898 && state[i].status() == -22
4899 && state[i].acol() == state[Rad].acol() )
4901 }
else if ( radType == 1 && state[Rad].colType() == 1) {
4903 for(
int i=0; i < int(state.size()); ++i)
4904 if ( i != Rad && i != Emt && i != Rec
4905 && state[i].status() == -22
4906 && state[i].col() == state[Rad].col() )
4908 }
else if ( radType == 1 && state[Rad].colType() == -1) {
4910 for(
int i=0; i < int(state.size()); ++i)
4911 if ( i != Rad && i != Emt && i != Rec
4912 && state[i].status() == -22
4913 && state[i].acol() == state[Rad].acol() )
4919 int iColResNow = FindParticle( state[iColRes], outState);
4922 int radCol = outState[radPos].col();
4923 int radAcl = outState[radPos].acol();
4925 int resCol = outState[iColResNow].col();
4926 int resAcl = outState[iColResNow].acol();
4928 bool matchesRes = (radCol > 0
4929 && ( radCol == resCol || radCol == resAcl))
4931 && ( radAcl == resCol || radAcl == resAcl));
4935 if (!matchesRes && iColResNow > 0) {
4936 if ( radType == -1 && outState[radPos].colType() == 1)
4937 outState[iColResNow].col(radCol);
4938 else if ( radType ==-1 && outState[radPos].colType() ==-1)
4939 outState[iColResNow].acol(radAcl);
4940 else if ( radType == 1 && outState[radPos].colType() == 1)
4941 outState[iColResNow].col(radCol);
4942 else if ( radType == 1 && outState[radPos].colType() ==-1)
4943 outState[iColResNow].acol(radAcl);
4950 if (!matchesRes && iColResNow > 0 && iColRes != iColResNow)
4951 outState[radPos].mother1(iColResNow);
4956 if ( !validEvent(outState) ) {
4962 iReclusteredNew = radPos;
4976 int History::getRadBeforeFlav(
const int RadAfter,
const int EmtAfter,
4977 const Event& event) {
4979 int type =
event[RadAfter].isFinal() ? 1 :-1;
4980 int emtID =
event[EmtAfter].id();
4981 int radID =
event[RadAfter].id();
4982 int emtCOL =
event[EmtAfter].col();
4983 int radCOL =
event[RadAfter].col();
4984 int emtACL =
event[EmtAfter].acol();
4985 int radACL =
event[RadAfter].acol();
4987 bool colConnected = ((type == 1) && ( (emtCOL !=0 && (emtCOL ==radACL))
4988 || (emtACL !=0 && (emtACL ==radCOL)) ))
4989 ||((type ==-1) && ( (emtCOL !=0 && (emtCOL ==radCOL))
4990 || (emtACL !=0 && (emtACL ==radACL)) ));
4996 if ( type == 1 && emtID == -radID && !colConnected )
4999 if ( type ==-1 && radID == 21 )
5002 if ( type ==-1 && !colConnected
5003 && emtID != 21 && radID != 21 && abs(emtID) < 10 && abs(radID) < 10)
5007 int radSign = (radID < 0) ? -1 : 1;
5008 int offsetL = 1000000;
5009 int offsetR = 2000000;
5011 if ( emtID == 1000021 ) {
5013 if (abs(radID) < 10 ) {
5014 int offset = offsetL;
5017 for (
int i=0; i < int(event.size()); ++i)
5018 if ( event[i].isFinal()
5019 &&
event[i].idAbs() < offsetR+10 &&
event[i].idAbs() > offsetR)
5021 return radSign*(abs(radID)+offset);
5024 if (abs(radID) > offsetL && abs(radID) < offsetL+10 )
5025 return radSign*(abs(radID)-offsetL);
5026 if (abs(radID) > offsetR && abs(radID) < offsetR+10 )
5027 return radSign*(abs(radID)-offsetR);
5029 if (radID == 21 )
return emtID;
5032 int emtSign = (emtID < 0) ? -1 : 1;
5035 if ( abs(emtID) > offsetL && abs(emtID) < offsetL+10 )
5036 emtOffset = offsetL;
5037 if ( abs(emtID) > offsetR && abs(emtID) < offsetR+10 )
5038 emtOffset = offsetR;
5040 if ( abs(radID) > offsetL && abs(radID) < offsetL+10 )
5041 radOffset = offsetL;
5042 if ( abs(radID) > offsetR && abs(radID) < offsetR+10 )
5043 radOffset = offsetR;
5046 if ( type == 1 && !colConnected ) {
5048 if ( emtOffset > 0 && radOffset == 0
5049 && emtSign*(abs(emtID) - emtOffset) == -radID )
5052 if ( emtOffset == 0 && radOffset > 0
5053 && emtID == -radSign*(abs(radID) - radOffset) )
5058 if ( type ==-1 && radID == 1000021 ) {
5060 if ( emtOffset > 0 )
return -emtSign*(abs(emtID) - emtOffset);
5062 else return -emtSign*(abs(emtID) + emtOffset);
5067 && ( (abs(emtID) > offsetL && abs(emtID) < offsetL+10)
5068 || (abs(emtID) > offsetR && abs(emtID) < offsetR+10))
5069 && ( (abs(radID) > offsetL && abs(radID) < offsetL+10)
5070 || (abs(radID) > offsetR && abs(radID) < offsetR+10))
5071 && emtSign*(abs(emtID)+emtOffset) == radSign*(abs(radID) - radOffset)
5072 && !colConnected ) {
5078 double m2final = (
event[RadAfter].p()+
event[EmtAfter].p()).m2Calc();
5080 if ( emtID == 22 || emtID == 23 )
return radID;
5082 if ( type == 1 && emtID == -radID && colConnected && sqrt(m2final) <= 10. )
5085 if ( type == 1 && emtID == -radID && colConnected && sqrt(m2final) > 10. )
5088 if ( type ==-1 && (radID == 22 || radID == 23) )
5091 if ( type ==-1 && abs(emtID) < 10 && abs(radID) < 10 && colConnected )
5096 if ( emtID == 24 && radID < 0 )
return radID + 1;
5097 if ( emtID == 24 && radID > 0 )
return radID + 1;
5101 if ( emtID ==-24 && radID < 0 )
return radID - 1;
5102 if ( emtID ==-24 && radID > 0 )
return radID - 1;
5121 bool History::connectRadiator( Particle& Radiator,
const int RadType,
5122 const Particle& Recoiler,
const int RecType,
5123 const Event& event ) {
5126 Radiator.cols( -1, -1 );
5130 if ( Radiator.colType() == -1 ) {
5133 if ( RadType + RecType == 2 )
5134 Radiator.cols( 0, Recoiler.col());
5135 else if ( RadType + RecType == 0 )
5136 Radiator.cols( 0, Recoiler.acol());
5144 for (
int i = 0; i <
event.size(); ++i) {
5145 int col =
event[i].col();
5146 int acl =
event[i].acol();
5148 if ( event[i].isFinal()) {
5150 if ( acl > 0 && FindCol(acl,i,0,event,1,
true) == 0
5151 && FindCol(acl,i,0,event,2,
true) == 0 )
5152 Radiator.acol(event[i].acol());
5155 if ( col > 0 && FindCol(col,i,0,event,1,
true) == 0
5156 && FindCol(col,i,0,event,2,
true) == 0 )
5157 Radiator.acol(event[i].col());
5162 }
else if ( Radiator.colType() == 1 ) {
5165 if ( RadType + RecType == 2 )
5166 Radiator.cols( Recoiler.acol(), 0);
5168 else if ( RadType + RecType == 0 )
5169 Radiator.cols( Recoiler.col(), 0);
5178 for (
int i = 0; i <
event.size(); ++i) {
5179 int col =
event[i].col();
5180 int acl =
event[i].acol();
5182 if ( event[i].isFinal()) {
5184 if ( col > 0 && FindCol(col,i,0,event,1,
true) == 0
5185 && FindCol(col,i,0,event,2,
true) == 0)
5186 Radiator.col(event[i].col());
5189 if ( acl > 0 && FindCol(acl,i,0,event,1,
true) == 0
5190 && FindCol(acl,i,0,event,2,
true) == 0)
5191 Radiator.col(event[i].acol());
5197 }
else if ( Radiator.colType() == 2 ) {
5203 for (
int i = 0; i <
event.size(); ++i) {
5204 int col =
event[i].col();
5205 int acl =
event[i].acol();
5208 if ( event[i].isFinal()) {
5209 if ( col > 0 && FindCol(col,iEx,0,event,1,
true) == 0
5210 && FindCol(col,iEx,0,event,2,
true) == 0) {
5211 if (Radiator.status() < 0 ) Radiator.col(event[i].col());
5212 else Radiator.acol(event[i].col());
5214 if ( acl > 0 && FindCol(acl,iEx,0,event,2,
true) == 0
5215 && FindCol(acl,iEx,0,event,1,
true) == 0 ) {
5216 if (Radiator.status() < 0 ) Radiator.acol(event[i].acol());
5217 else Radiator.col(event[i].acol());
5220 if ( col > 0 && FindCol(col,iEx,0,event,1,
true) == 0
5221 && FindCol(col,iEx,0,event,2,
true) == 0) {
5222 if (Radiator.status() < 0 ) Radiator.acol(event[i].col());
5223 else Radiator.col(event[i].col());
5225 if ( acl > 0 && (FindCol(acl,iEx,0,event,2,
true) == 0
5226 && FindCol(acl,iEx,0,event,1,
true) == 0)) {
5227 if (Radiator.status() < 0 ) Radiator.col(event[i].acol());
5228 else Radiator.acol(event[i].acol());
5235 if (Radiator.col() < 0 || Radiator.acol() < 0)
return false;
5257 int History::FindCol(
int col,
int iExclude1,
int iExclude2,
5258 const Event& event,
int type,
bool isHardIn) {
5260 bool isHard = isHardIn;
5265 for(
int n = 0; n <
event.size(); ++n) {
5266 if ( n != iExclude1 && n != iExclude2
5267 && event[n].colType() != 0
5268 &&(
event[n].status() > 0
5269 ||
event[n].status() == -21) ) {
5270 if ( event[n].acol() == col ) {
5274 if ( event[n].col() == col ) {
5283 for(
int n = 0; n <
event.size(); ++n) {
5284 if ( n != iExclude1 && n != iExclude2
5285 && event[n].colType() != 0
5286 &&(
event[n].status() == 43
5287 ||
event[n].status() == 51
5288 ||
event[n].status() == -41
5289 ||
event[n].status() == -42) ) {
5290 if ( event[n].acol() == col ) {
5294 if ( event[n].col() == col ) {
5302 if ( type == 1 && index < 0)
return abs(index);
5303 if ( type == 2 && index > 0)
return abs(index);
5317 int History::FindParticle(
const Particle& particle,
const Event& event,
5318 bool checkStatus ) {
5322 for (
int i =
int(event.size()) - 1; i > 0; --i )
5323 if ( event[i].
id() == particle.id()
5324 &&
event[i].colType() == particle.colType()
5325 &&
event[i].chargeType() == particle.chargeType()
5326 &&
event[i].col() == particle.col()
5327 &&
event[i].acol() == particle.acol()
5328 &&
event[i].charge() == particle.charge() ) {
5333 if ( checkStatus && event[index].status() != particle.status() )
5348 int History::getRadBeforeCol(
const int rad,
const int emt,
5349 const Event& event) {
5352 int type = (
event[rad].isFinal()) ? 1 :-1;
5354 int radBeforeFlav = getRadBeforeFlav(rad,emt,event);
5356 int radBeforeCol = -1;
5358 if (radBeforeFlav == 21) {
5361 if (type == 1 && event[emt].
id() != 21) {
5362 radBeforeCol = (
event[rad].col() > 0)
5363 ? event[rad].col() :
event[emt].col();
5365 }
else if (type == -1 && event[emt].
id() != 21) {
5366 radBeforeCol = (
event[rad].col() > 0)
5367 ? event[rad].col() :
event[emt].acol();
5369 }
else if (type == 1 && event[emt].
id() == 21) {
5372 int colRemove = (
event[rad].col() ==
event[emt].acol())
5373 ? event[rad].acol() :
event[rad].col();
5374 radBeforeCol = (
event[rad].col() == colRemove)
5375 ? event[emt].col() :
event[rad].col();
5377 }
else if (type == -1 && event[emt].
id() == 21) {
5380 int colRemove = (
event[rad].col() ==
event[emt].col())
5381 ? event[rad].col() :
event[rad].acol();
5382 radBeforeCol = (
event[rad].col() == colRemove)
5383 ? event[emt].acol() :
event[rad].col();
5387 }
else if ( radBeforeFlav != 21 && radBeforeFlav > 0) {
5390 if (type == 1 && event[emt].
id() != 21) {
5393 int colRemove = (
event[rad].col() ==
event[emt].acol())
5394 ? event[rad].acol() : 0;
5395 radBeforeCol = (
event[rad].col() == colRemove)
5396 ? event[emt].col() :
event[rad].col();
5398 }
else if (type == 1 && event[emt].
id() == 21) {
5401 int colRemove = (
event[rad].col() ==
event[emt].acol())
5402 ? event[rad].col() : 0;
5403 radBeforeCol = (
event[rad].col() == colRemove)
5404 ? event[emt].col() :
event[rad].col();
5406 }
else if (type == -1 && event[emt].
id() != 21) {
5409 int colRemove = (
event[rad].col() ==
event[emt].col())
5410 ? event[rad].col() : 0;
5411 radBeforeCol = (
event[rad].col() == colRemove)
5412 ? event[emt].acol() :
event[rad].col();
5414 }
else if (type == -1 && event[emt].
id() == 21) {
5417 int colRemove = (
event[rad].col() ==
event[emt].col())
5418 ? event[rad].col() : 0;
5419 radBeforeCol = (
event[rad].col() == colRemove)
5420 ? event[emt].acol() :
event[rad].col();
5427 return radBeforeCol;
5440 int History::getRadBeforeAcol(
const int rad,
const int emt,
5441 const Event& event) {
5444 int type = (
event[rad].isFinal()) ? 1 :-1;
5447 int radBeforeFlav = getRadBeforeFlav(rad,emt,event);
5449 int radBeforeAcl = -1;
5451 if (radBeforeFlav == 21) {
5454 if (type == 1 && event[emt].
id() != 21) {
5455 radBeforeAcl = (
event[rad].acol() > 0)
5456 ? event[rad].acol() :
event[emt].acol();
5458 }
else if (type == -1 && event[emt].
id() != 21) {
5459 radBeforeAcl = (
event[rad].acol() > 0)
5460 ? event[rad].acol() :
event[emt].col();
5462 }
else if (type == 1 && event[emt].
id() == 21) {
5465 int colRemove = (
event[rad].col() ==
event[emt].acol())
5466 ? event[rad].acol() :
event[rad].col();
5467 radBeforeAcl = (
event[rad].acol() == colRemove)
5468 ? event[emt].acol() :
event[rad].acol();
5470 }
else if (type == -1 && event[emt].
id() == 21) {
5473 int colRemove = (
event[rad].col() ==
event[emt].col())
5474 ? event[rad].col() :
event[rad].acol();
5475 radBeforeAcl = (
event[rad].acol() == colRemove)
5476 ? event[emt].col() :
event[rad].acol();
5480 }
else if ( radBeforeFlav != 21 && radBeforeFlav < 0) {
5483 if (type == 1 && event[emt].
id() != 21) {
5486 int colRemove = (
event[rad].col() ==
event[emt].acol())
5487 ? event[rad].acol() : 0;
5488 radBeforeAcl = (
event[rad].acol() == colRemove)
5489 ? event[emt].acol() :
event[rad].acol();
5491 }
else if (type == 1 && event[emt].
id() == 21) {
5494 int colRemove = (
event[rad].acol() ==
event[emt].col())
5495 ? event[rad].acol() : 0;
5496 radBeforeAcl = (
event[rad].acol() == colRemove)
5497 ? event[emt].acol() :
event[rad].acol();
5499 }
else if (type == -1 && event[emt].
id() != 21) {
5502 int colRemove = (
event[rad].acol() ==
event[emt].acol())
5503 ? event[rad].acol() : 0;
5504 radBeforeAcl = (
event[rad].acol() == colRemove)
5505 ? event[emt].col() :
event[rad].acol();
5507 }
else if (type == -1 && event[emt].
id() == 21) {
5510 int colRemove = (
event[rad].acol() ==
event[emt].acol())
5511 ? event[rad].acol() : 0;
5512 radBeforeAcl = (
event[rad].acol() == colRemove)
5513 ? event[emt].col() :
event[rad].acol();
5520 return radBeforeAcl;
5532 int History::getColPartner(
const int in,
const Event& event) {
5534 if (event[in].col() == 0)
return 0;
5538 partner = FindCol(event[in].col(),in,0,event,1,
true);
5541 partner = FindCol(event[in].col(),in,0,event,2,
true);
5556 int History::getAcolPartner(
const int in,
const Event& event) {
5558 if (event[in].acol() == 0)
return 0;
5562 partner = FindCol(event[in].acol(),in,0,event,2,
true);
5565 partner = FindCol(event[in].acol(),in,0,event,1,
true);
5582 vector<int> History::getReclusteredPartners(
const int rad,
const int emt,
5583 const Event& event) {
5586 int type =
event[rad].isFinal() ? 1 : -1;
5588 int radBeforeCol = getRadBeforeCol(rad, emt, event);
5589 int radBeforeAcl = getRadBeforeAcol(rad, emt, event);
5591 vector<int> partners;
5597 for(
int i=0; i < int(event.size()); ++i) {
5599 if ( i != emt && i != rad
5600 && event[i].status() == -21
5601 &&
event[i].col() > 0
5602 &&
event[i].col() == radBeforeCol)
5603 partners.push_back(i);
5605 if ( i != emt && i != rad
5606 && event[i].isFinal()
5607 && event[i].acol() > 0
5608 && event[i].acol() == radBeforeCol)
5609 partners.push_back(i);
5611 if ( i != emt && i != rad
5612 && event[i].status() == -21
5613 && event[i].acol() > 0
5614 && event[i].acol() == radBeforeAcl)
5615 partners.push_back(i);
5617 if ( i != emt && i != rad
5618 && event[i].isFinal()
5619 && event[i].col() > 0
5620 && event[i].col() == radBeforeAcl)
5621 partners.push_back(i);
5626 for(
int i=0; i < int(event.size()); ++i) {
5628 if ( i != emt && i != rad
5629 && event[i].status() == -21
5630 &&
event[i].acol() > 0
5631 &&
event[i].acol() == radBeforeCol)
5632 partners.push_back(i);
5634 if ( i != emt && i != rad
5635 && event[i].isFinal()
5636 && event[i].col() > 0
5637 && event[i].col() == radBeforeCol)
5638 partners.push_back(i);
5640 if ( i != emt && i != rad
5641 && event[i].status() == -21
5642 && event[i].col() > 0
5643 && event[i].col() == radBeforeAcl)
5644 partners.push_back(i);
5646 if ( i != emt && i != rad
5647 && event[i].isFinal()
5648 && event[i].acol() > 0
5649 && event[i].acol() == radBeforeAcl)
5650 partners.push_back(i);
5677 bool History::getColSinglet(
const int flavType,
const int iParton,
5678 const Event& event, vector<int>& exclude, vector<int>& colSinglet) {
5681 if (iParton < 0)
return false;
5689 for(
int i=0; i < int(event.size()); ++i)
5690 if ( event[i].isFinal() &&
event[i].colType() != 0)
5695 int nExclude = int(exclude.size());
5696 int nInitExclude = 0;
5697 if (!event[exclude[2]].isFinal())
5699 if (!event[exclude[3]].isFinal())
5703 if (nFinal == nExclude - nInitExclude)
5713 colSinglet.push_back(iParton);
5715 exclude.push_back(iParton);
5718 colP = getColPartner(iParton,event);
5721 colP = getAcolPartner(iParton,event);
5724 for(
int i = 0; i < int(exclude.size()); ++i)
5725 if (colP == exclude[i])
5729 return getColSinglet(flavType,colP,event,exclude,colSinglet);
5740 bool History::isColSinglet(
const Event& event,
5741 vector<int> system ) {
5744 for(
int i=0; i < int(system.size()); ++i ) {
5747 && (event[system[i]].colType() == 1
5748 ||
event[system[i]].colType() == 2) ) {
5749 for(
int j=0; j < int(system.size()); ++j)
5753 && event[system[i]].col() ==
event[system[j]].acol()) {
5762 && (event[system[i]].colType() == -1
5763 || event[system[i]].colType() == 2) ) {
5764 for(
int j=0; j < int(system.size()); ++j)
5768 && event[system[i]].acol() ==
event[system[j]].col()) {
5780 bool isColSing =
true;
5781 for(
int i=0; i < int(system.size()); ++i)
5782 if ( system[i] != 0 )
5800 bool History::isFlavSinglet(
const Event& event,
5801 vector<int> system,
int flav) {
5806 for(
int i=0; i < int(system.size()); ++i)
5807 if ( system[i] > 0 ) {
5808 for(
int j=0; j < int(system.size()); ++j) {
5812 if ( event[i].idAbs() != 21
5813 &&
event[i].idAbs() != 22
5814 &&
event[i].idAbs() != 23
5815 &&
event[i].idAbs() != 24
5818 &&
event[system[i]].isFinal()
5819 &&
event[system[j]].isFinal()
5820 &&
event[system[i]].id() == -1*
event[system[j]].id()) {
5823 if (abs(flav) > 0 &&
event[system[i]].idAbs() != flav)
5833 if ( event[i].idAbs() != 21
5834 &&
event[i].idAbs() != 22
5835 &&
event[i].idAbs() != 23
5836 &&
event[i].idAbs() != 24
5839 && ( ( !
event[system[i]].isFinal() &&
event[system[j]].isFinal())
5840 ||( !event[system[j]].isFinal() &&
event[system[i]].isFinal()) )
5841 &&
event[system[i]].id() ==
event[system[j]].id()) {
5844 if (abs(flav) > 0 &&
event[system[i]].idAbs() != flav)
5857 bool isFlavSing =
true;
5858 for(
int i=0; i < int(system.size()); ++i)
5859 if ( system[i] != 0 )
5874 bool History::allowedClustering(
int rad,
int emt,
int rec,
int partner,
5875 const Event& event ) {
5878 bool allowed =
true;
5883 bool isSing = isSinglett(rad,emt,partner,event);
5884 int type = (
event[rad].isFinal()) ? 1 :-1;
5886 int radBeforeFlav = getRadBeforeFlav(rad,emt,event);
5888 int radBeforeCol = getRadBeforeCol(rad,emt,event);
5889 int radBeforeAcl = getRadBeforeAcol(rad,emt,event);
5891 vector<int> radBeforeColP = getReclusteredPartners(rad, emt, event);
5894 int nPartonInHard = 0;
5895 for(
int i=0; i < int(event.size()); ++i)
5897 if ( event[i].isFinal()
5898 &&
event[i].colType() != 0
5899 && mergingHooksPtr->hardProcess.matchesAnyOutgoing(i, event) )
5905 for(
int i=0; i < int(event.size()); ++i)
5907 if ( i!=emt && i!=rad && i!=rec
5908 && event[i].isFinal()
5909 &&
event[i].colType() != 0
5910 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i, event) )
5914 int nInitialPartons = 0;
5915 for(
int i=0; i < int(event.size()); ++i)
5916 if ( event[i].status() == -21
5917 &&
event[i].colType() != 0 )
5922 for(
int i=0; i < int(event.size()); ++i)
5923 if ( event[i].isFinal()
5924 &&(
event[i].id() == 22
5925 ||
event[i].id() == 23
5926 ||
event[i].id() == 24
5927 ||(
event[i].idAbs() > 10 &&
event[i].idAbs() < 20)
5928 ||(event[i].idAbs() > 10 &&
event[i].idAbs() < 20)
5929 ||(event[i].idAbs() > 1000010 &&
event[i].idAbs() < 1000020)
5930 ||(event[i].idAbs() > 2000010 &&
event[i].idAbs() < 2000020) ))
5937 int nFinalQuark = 0;
5939 int nFinalQuarkExc = 0;
5940 for(
int i=0; i < int(event.size()); ++i) {
5941 if (i !=rad && i != emt && i != rec) {
5942 if (event[i].isFinal() && abs(event[i].colType()) == 1 ) {
5943 if ( !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,event) )
5952 if (event[rec].isFinal() &&
event[rec].isQuark()) nFinalQuark++;
5954 if (event[rad].isFinal() && abs(radBeforeFlav) < 10) nFinalQuark++;
5957 int nInitialQuark = 0;
5959 if (event[rec].isFinal()) {
5960 if (event[3].isQuark()) nInitialQuark++;
5961 if (event[4].isQuark()) nInitialQuark++;
5963 int iOtherIn = (rec == 3) ? 4 : 3;
5964 if (event[rec].isQuark()) nInitialQuark++;
5965 if (event[iOtherIn].isQuark()) nInitialQuark++;
5969 if (event[rec].isQuark()) nInitialQuark++;
5971 if (abs(radBeforeFlav) < 10) nInitialQuark++;
5977 int proton[] = {1,2,3,4,5,21,22,23,24};
5978 bool isInProton =
false;
5979 for(
int i=0; i < 9; ++i)
5980 if (abs(radBeforeFlav) == proton[i]) isInProton =
true;
5981 if (type == -1 && !isInProton)
return false;
5984 vector<int> unmatchedCol;
5985 vector<int> unmatchedAcl;
5987 for (
int i = 0; i <
event.size(); ++i)
5988 if ( i != emt && i != rad
5989 && (event[i].isFinal() || event[i].status() == -21)
5990 &&
event[i].colType() != 0 ) {
5992 int colP = getColPartner(i,event);
5993 int aclP = getAcolPartner(i,event);
5995 if (event[i].col() > 0
5996 && (colP == emt || colP == rad || colP == 0) )
5997 unmatchedCol.push_back(i);
5998 if (event[i].acol() > 0
5999 && (aclP == emt || aclP == rad || aclP == 0) )
6000 unmatchedAcl.push_back(i);
6006 if (
int(unmatchedCol.size()) +
int(unmatchedAcl.size()) > 2)
6013 if (isSing && (abs(radBeforeFlav)<10 &&
event[rec].isQuark()) )
6017 if ( mergingHooksPtr->hardProcess.matchesAnyOutgoing(emt,event) ) {
6021 bool canReplace = mergingHooksPtr->hardProcess.findOtherCandidates(emt,
6023 if (canReplace) allowed =
true;
6024 else allowed =
false;
6029 if ( mergingHooksPtr->hardProcess.matchesAnyOutgoing(rad,event)
6030 &&
event[rad].id() != radBeforeFlav )
6035 if (nFinalEW != 0 && nInitialQuark == 0
6036 && nFinalQuark == 0 && nFinalQuarkExc == 0)
6039 if ( (nInitialQuark + nFinalQuark + nFinalQuarkExc)%2 != 0 )
6048 if (event[3].col() ==
event[4].acol()
6049 &&
event[3].acol() ==
event[4].col()
6050 && nFinalQuark == 0){
6053 int nTripletts = abs(event[rec].colType())
6054 + abs(particleDataPtr->colType(radBeforeFlav));
6055 if (event[3].isGluon()) allowed =
false;
6056 else if (nTripletts != 2 && nFinalQuarkExc%2 == 0) allowed =
false;
6060 if (event[emt].
id() == 21)
6064 if (event[emt].
id() == 1000021)
6068 vector<int> outgoingParticles;
6069 int nOut1 = int(mergingHooksPtr->hardProcess.PosOutgoing1.size());
6070 for (
int i=0; i < nOut1; ++i ) {
6071 int iPos = mergingHooksPtr->hardProcess.PosOutgoing1[i];
6072 outgoingParticles.push_back(
6073 mergingHooksPtr->hardProcess.state[iPos].id() );
6075 int nOut2 = int(mergingHooksPtr->hardProcess.PosOutgoing2.size());
6076 for (
int i=0; i < nOut2; ++i ) {
6077 int iPos = mergingHooksPtr->hardProcess.PosOutgoing2[i];
6078 outgoingParticles.push_back(
6079 mergingHooksPtr->hardProcess.state[iPos].id() );
6086 vector<int> iInQuarkFlav;
6087 for(
int i=0; i < int(event.size()); ++i)
6089 if ( i != emt && i != rad
6090 && event[i].status() == -21
6091 &&
event[i].idAbs() ==
event[emt].idAbs() )
6092 iInQuarkFlav.push_back(i);
6095 vector<int> iOutQuarkFlav;
6096 for(
int i=0; i < int(event.size()); ++i)
6098 if ( i != emt && i != rad
6099 && event[i].isFinal()
6100 &&
event[i].idAbs() ==
event[emt].idAbs() ) {
6104 bool matchOut =
false;
6105 for (
int j = 0; j < int(outgoingParticles.size()); ++j)
6106 if ( event[i].idAbs() == abs(outgoingParticles[j])) {
6108 outgoingParticles[j] = 99;
6110 if (!matchOut) iOutQuarkFlav.push_back(i);
6115 int nInQuarkFlav = int(iInQuarkFlav.size());
6116 int nOutQuarkFlav = int(iOutQuarkFlav.size());
6121 if ( event[partner].isFinal()
6122 &&
event[partner].id() == 21
6123 && radBeforeFlav == 21
6124 &&
event[partner].col() == radBeforeCol
6125 &&
event[partner].acol() == radBeforeAcl)
6129 if (nInQuarkFlav + nOutQuarkFlav == 0)
6136 vector<int> partons;
6137 for(
int i=0; i < int(event.size()); ++i)
6139 if ( i!=emt && i!=rad
6140 && event[i].colType() != 0
6141 && (
event[i].isFinal() ||
event[i].status() == -21) ) {
6143 partons.push_back(i);
6145 if (event[i].colType() == 2)
6147 else if (event[i].colType() == 1)
6149 else if (event[i].colType() == -1)
6155 bool isFSRg2qq = ((type == 1) && (event[rad].
id() == -1*
event[emt].id()) );
6156 bool isISRg2qq = ((type ==-1) && (event[rad].
id() ==
event[emt].id()) );
6161 if ( (isFSRg2qq || isISRg2qq)
6162 && int(quark.size()) +
int(antiq.size())
6163 +
int(gluon.size()) > nPartonInHard ) {
6165 vector<int> colours;
6166 vector<int> anticolours;
6171 colours.push_back(radBeforeCol);
6172 anticolours.push_back(radBeforeAcl);
6174 colours.push_back(radBeforeAcl);
6175 anticolours.push_back(radBeforeCol);
6178 for(
int i=0; i < int(gluon.size()); ++i)
6179 if (event[gluon[i]].isFinal()) {
6180 colours.push_back(event[gluon[i]].col());
6181 anticolours.push_back(event[gluon[i]].acol());
6183 colours.push_back(event[gluon[i]].acol());
6184 anticolours.push_back(event[gluon[i]].col());
6189 for(
int i=0; i < int(colours.size()); ++i)
6190 for(
int j=0; j < int(anticolours.size()); ++j)
6191 if (colours[i] > 0 && anticolours[j] > 0
6192 && colours[i] == anticolours[j]) {
6200 bool allMatched =
true;
6201 for(
int i=0; i < int(colours.size()); ++i)
6202 if (colours[i] != 0)
6204 for(
int i=0; i < int(anticolours.size()); ++i)
6205 if (anticolours[i] != 0)
6213 for(
int i=0; i < int(quark.size()); ++i)
6214 if ( event[quark[i]].isFinal()
6215 && mergingHooksPtr->hardProcess.matchesAnyOutgoing(quark[i], event) )
6216 colours.push_back(event[quark[i]].col());
6218 for(
int i=0; i < int(antiq.size()); ++i)
6219 if ( event[antiq[i]].isFinal()
6220 && mergingHooksPtr->hardProcess.matchesAnyOutgoing(antiq[i], event) )
6221 anticolours.push_back(event[antiq[i]].acol());
6225 for(
int i=0; i < int(colours.size()); ++i)
6227 for(
int j=0; j < int(anticolours.size()); ++j)
6228 if (colours[i] > 0 && anticolours[j] > 0
6229 && colours[i] == anticolours[j]) {
6236 for (
int i=0; i < int(quark.size()); ++i )
6237 if ( !mergingHooksPtr->hardProcess.matchesAnyOutgoing( quark[i],
6240 for (
int i=0; i < int(antiq.size()); ++i )
6241 if ( !mergingHooksPtr->hardProcess.matchesAnyOutgoing( antiq[i],
6244 for(
int i=0; i < int(gluon.size()); ++i)
6245 if ( event[gluon[i]].isFinal() )
6253 for(
int i=0; i < int(colours.size()); ++i)
6254 if (colours[i] != 0)
6256 for(
int i=0; i < int(anticolours.size()); ++i)
6257 if (anticolours[i] != 0)
6260 if (allMatched && nNotInHard > 0)
6267 if (isFSRg2qq && nInQuarkFlav + nOutQuarkFlav > 0) {
6271 for(
int i=0; i < int(gluon.size()); ++i) {
6272 if (!event[gluon[i]].isFinal()
6273 &&
event[gluon[i]].col() == radBeforeCol
6274 &&
event[gluon[i]].acol() == radBeforeAcl)
6280 for(
int i=0; i < int(gluon.size()); ++i) {
6281 if (event[gluon[i]].isFinal()
6282 &&
event[gluon[i]].col() == radBeforeAcl
6283 &&
event[gluon[i]].acol() == radBeforeCol)
6289 if (
int(radBeforeColP.size()) == 2
6290 && event[radBeforeColP[0]].isFinal()
6291 &&
event[radBeforeColP[1]].isFinal()
6292 &&
event[radBeforeColP[0]].id() == -1*
event[radBeforeColP[1]].id() ) {
6296 if (nInitialPartons > 0)
6303 if (
int(radBeforeColP.size()) == 2
6304 && (( event[radBeforeColP[0]].status() == -21
6305 && event[radBeforeColP[1]].isFinal())
6306 ||(
event[radBeforeColP[0]].isFinal()
6307 &&
event[radBeforeColP[1]].status() == -21))
6308 &&
event[radBeforeColP[0]].id() ==
event[radBeforeColP[1]].id() ) {
6315 int incoming = (
event[radBeforeColP[0]].isFinal())
6316 ? radBeforeColP[1] : radBeforeColP[0];
6317 int outgoing = (
event[radBeforeColP[0]].isFinal())
6318 ? radBeforeColP[0] : radBeforeColP[1];
6321 bool clusPossible =
false;
6322 for(
int i=0; i < int(event.size()); ++i)
6323 if ( i != emt && i != rad
6324 && i != incoming && i != outgoing
6325 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,event) ) {
6327 if ( event[i].status() == -21
6328 && (
event[i].id() ==
event[outgoing].id()
6329 ||
event[i].id() == -1*
event[incoming].id()) )
6330 clusPossible =
true;
6332 if ( event[i].isFinal()
6333 && (
event[i].id() == -1*
event[outgoing].id()
6334 ||
event[i].id() ==
event[incoming].id()) )
6335 clusPossible =
true;
6346 vector<int> excludeIn1;
6347 for(
int i=0; i < 4; ++i)
6348 excludeIn1.push_back(0);
6349 vector<int> colSingletIn1;
6350 int flavIn1Type = (
event[incoming].id() > 0) ? 1 : -1;
6352 bool isColSingIn1 = getColSinglet(flavIn1Type,incoming,event,
6353 excludeIn1,colSingletIn1);
6355 bool isFlavSingIn1 = isFlavSinglet(event,colSingletIn1);
6360 int incoming2 = (incoming == 3) ? 4 : 3;
6361 vector<int> excludeIn2;
6362 for(
int i=0; i < 4; ++i)
6363 excludeIn2.push_back(0);
6364 vector<int> colSingletIn2;
6365 int flavIn2Type = (
event[incoming2].id() > 0) ? 1 : -1;
6367 bool isColSingIn2 = getColSinglet(flavIn2Type,incoming2,event,
6368 excludeIn2,colSingletIn2);
6370 bool isFlavSingIn2 = isFlavSinglet(event,colSingletIn2);
6374 && (!isColSingIn1 || !isFlavSingIn1
6375 || !isColSingIn2 || !isFlavSingIn2))
6387 int flav =
event[emt].id();
6388 vector<int> exclude;
6389 exclude.push_back(emt);
6390 exclude.push_back(rad);
6391 exclude.push_back(radBeforeColP[0]);
6392 exclude.push_back(radBeforeColP[1]);
6393 vector<int> colSinglet;
6397 for(
int i=0; i < int(event.size()); ++i)
6402 && i != radBeforeColP[0]
6403 && i != radBeforeColP[1]
6404 && event[i].isFinal() ) {
6406 if (event[i].
id() == flav) {
6412 int flavType = (
event[iOther].id() > 0) ? 1 : -1;
6414 bool isColSing = getColSinglet(flavType,iOther,event,exclude,colSinglet);
6416 bool isFlavSing = isFlavSinglet(event,colSinglet);
6420 bool isHardSys =
true;
6421 for(
int i=0; i < int(colSinglet.size()); ++i)
6423 mergingHooksPtr->hardProcess.matchesAnyOutgoing(colSinglet[i], event);
6428 if (isColSing && isFlavSing && !isHardSys) {
6434 vector<int> allFinal;
6435 for(
int i=0; i < int(event.size()); ++i)
6436 if ( event[i].isFinal() )
6437 allFinal.push_back(i);
6440 bool isFullColSing = isColSinglet(event,allFinal);
6442 bool isFullFlavSing = isFlavSinglet(event,allFinal,flav);
6447 if (!isFullColSing || !isFullFlavSing)
6454 if (isISRg2qq && nInQuarkFlav + nOutQuarkFlav > 0) {
6458 for(
int i=0; i < int(gluon.size()); ++i) {
6459 if (event[gluon[i]].isFinal()
6460 &&
event[gluon[i]].col() == radBeforeCol
6461 &&
event[gluon[i]].acol() == radBeforeAcl)
6467 for(
int i=0; i < int(gluon.size()); ++i) {
6468 if (event[gluon[i]].status() == -21
6469 &&
event[gluon[i]].acol() == radBeforeCol
6470 &&
event[gluon[i]].col() == radBeforeAcl)
6476 if (
int(radBeforeColP.size()) == 2
6477 && event[radBeforeColP[0]].isFinal()
6478 &&
event[radBeforeColP[1]].isFinal()
6479 &&
event[radBeforeColP[0]].id() == -1*
event[radBeforeColP[1]].id() ) {
6486 bool clusPossible =
false;
6487 for(
int i=0; i < int(event.size()); ++i)
6488 if ( i != emt && i != rad
6489 && i != radBeforeColP[0]
6490 && i != radBeforeColP[1]
6491 && !mergingHooksPtr->hardProcess.matchesAnyOutgoing(i,event) ) {
6492 if (event[i].status() == -21
6493 && (
event[radBeforeColP[0]].id() ==
event[i].id()
6494 ||
event[radBeforeColP[1]].id() ==
event[i].id() ))
6496 clusPossible =
true;
6497 if (event[i].isFinal()
6498 && (
event[radBeforeColP[0]].id() == -1*
event[i].id()
6499 ||
event[radBeforeColP[1]].id() == -1*
event[i].id() ))
6500 clusPossible =
true;
6512 vector<int> excludeIn1;
6513 for(
int i=0; i < 4; ++i)
6514 excludeIn1.push_back(0);
6515 vector<int> colSingletIn1;
6516 int flavIn1Type = (
event[incoming1].id() > 0) ? 1 : -1;
6518 bool isColSingIn1 = getColSinglet(flavIn1Type,incoming1,event,
6519 excludeIn1,colSingletIn1);
6521 bool isFlavSingIn1 = isFlavSinglet(event,colSingletIn1);
6527 vector<int> excludeIn2;
6528 for(
int i=0; i < 4; ++i)
6529 excludeIn2.push_back(0);
6530 vector<int> colSingletIn2;
6531 int flavIn2Type = (
event[incoming2].id() > 0) ? 1 : -1;
6533 bool isColSingIn2 = getColSinglet(flavIn2Type,incoming2,event,
6534 excludeIn2,colSingletIn2);
6536 bool isFlavSingIn2 = isFlavSinglet(event,colSingletIn2);
6540 && (!isColSingIn1 || !isFlavSingIn1
6541 || !isColSingIn2 || !isFlavSingIn2))
6560 bool History::isSinglett(
int rad,
int emt,
int rec,
const Event& event ) {
6562 int radCol =
event[rad].col();
6563 int emtCol =
event[emt].col();
6564 int recCol =
event[rec].col();
6565 int radAcl =
event[rad].acol();
6566 int emtAcl =
event[emt].acol();
6567 int recAcl =
event[rec].acol();
6568 int recType =
event[rec].isFinal() ? 1 : -1;
6570 bool isSing =
false;
6572 if ( ( recType == -1
6573 && radCol + emtCol == recCol && radAcl + emtAcl == recAcl)
6575 && radCol + emtCol == recAcl && radAcl + emtAcl == recCol) )
6591 bool History::validEvent(
const Event& event ) {
6594 bool validColour =
true;
6595 for (
int i = 0; i <
event.size(); ++i)
6597 if ( event[i].isFinal() &&
event[i].colType() == 1
6599 && ( FindCol(event[i].col(),i,0,event,1,
true) == 0
6601 && FindCol(event[i].col(),i,0,event,2,
true) == 0 )) {
6602 validColour =
false;
6605 }
else if ( event[i].isFinal() &&
event[i].colType() == -1
6607 && ( FindCol(event[i].acol(),i,0,event,2,
true) == 0
6609 && FindCol(event[i].acol(),i,0,event,1,
true) == 0 )) {
6610 validColour =
false;
6613 }
else if ( event[i].isFinal() &&
event[i].colType() == 2
6615 && ( FindCol(event[i].col(),i,0,event,1,
true) == 0
6617 && FindCol(event[i].col(),i,0,event,2,
true) == 0 )
6619 && ( FindCol(event[i].acol(),i,0,event,2,
true) == 0
6621 && FindCol(event[i].acol(),i,0,event,1,
true) == 0 )) {
6622 validColour =
false;
6627 bool validCharge =
true;
6628 double initCharge =
event[3].charge() +
event[4].charge();
6629 double finalCharge = 0.0;
6630 for(
int i = 0; i <
event.size(); ++i)
6631 if (event[i].isFinal()) finalCharge += event[i].charge();
6632 if (abs(initCharge-finalCharge) > 1e-12) validCharge =
false;
6634 return (validColour && validCharge);
6643 bool History::equalClustering( Clustering clus1 , Clustering clus2 ) {
6644 return ( (clus1.emittor == clus2.emittor)
6645 && (clus1.emitted == clus2.emitted)
6646 && (clus1.recoiler == clus2.recoiler)
6647 && (clus1.partner == clus2.partner)
6648 && (clus1.pT() == clus2.pT()) );
6657 double History::choseHardScale(
const Event& event )
const {
6660 double mHat = (
event[3].p() +
event[4].p()).mCalc();
6667 for(
int i = 0; i <
event.size(); ++i)
6668 if ( event[i].isFinal() ) {
6671 if ( event[i].idAbs() == 23
6672 ||
event[i].idAbs() == 24 ) {
6675 mBos +=
event[i].m();
6677 }
else if ( abs(event[i].status()) == 22
6678 && ( event[i].idAbs() == 23
6679 || event[i].idAbs() == 24 )) {
6681 mBos +=
event[i].m();
6685 if ( nBosons > 0 && (nFinal + nFinBos*2) <= 3)
6686 return (mBos /
double(nBosons));
6697 int History::getCurrentFlav(
const int side)
const {
6698 int in = (side == 1) ? 3 : 4;
6699 return state[in].id();
6704 double History::getCurrentX(
const int side)
const {
6705 int in = (side == 1) ? 3 : 4;
6706 return ( 2.*state[in].e()/state[0].e() );
6711 double History::getCurrentZ(
const int rad,
6712 const int rec,
const int emt)
const {
6714 int type = state[rad].isFinal() ? 1 : -1;
6719 Vec4 sum = state[rad].p() + state[rec].p()
6721 double m2Dip = sum.m2Calc();
6722 double x1 = 2. * (sum * state[rad].p()) / m2Dip;
6723 double x3 = 2. * (sum * state[emt].p()) / m2Dip;
6728 Vec4 qBR(state[rad].p() - state[emt].p() + state[rec].p());
6729 Vec4 qAR(state[rad].p() + state[rec].p());
6731 z = (qBR.m2Calc())/( qAR.m2Calc());
6742 double History::pTLund(
const Particle& RadAfterBranch,
6743 const Particle& EmtAfterBranch,
6744 const Particle& RecAfterBranch,
int ShowerType) {
6747 int Type = ShowerType;
6749 int sign = (Type==1) ? 1 : -1;
6750 Vec4 Q(RadAfterBranch.p() + sign*EmtAfterBranch.p());
6751 double Qsq = sign * Q.m2Calc();
6754 bool isMassive = ( RadAfterBranch.idAbs() >= 4
6755 && RadAfterBranch.id() != 21 );
6756 double m2Rad = ( mergingHooksPtr->includeMassive() && isMassive )
6757 ? pow2( particleDataPtr->m0(RadAfterBranch.id()) ) : 0.;
6759 Vec4 sum = RadAfterBranch.p() + RecAfterBranch.p()
6760 + EmtAfterBranch.p();
6761 double m2Dip = sum.m2Calc();
6762 double x1 = 2. * (sum * RadAfterBranch.p()) / m2Dip;
6763 double x3 = 2. * (sum * EmtAfterBranch.p()) / m2Dip;
6765 Vec4 qBR(RadAfterBranch.p() - EmtAfterBranch.p() + RecAfterBranch.p());
6766 Vec4 qAR(RadAfterBranch.p() + RecAfterBranch.p());
6769 double z = (Type==1) ? x1/(x1+x3)
6770 : (qBR.m2Calc())/( qAR.m2Calc());
6772 double pTpyth = (Type==1) ? z*(1.-z) : (1.-z);
6774 pTpyth *= (Qsq - sign*m2Rad);
6775 if ( pTpyth < 0. ) pTpyth = 0.;
6778 return sqrt(pTpyth);
6786 int History::posChangedIncoming(
const Event& event,
bool before) {
6792 for (
int i =0; i <
event.size(); ++i)
6793 if (event[i].status() == 43) {
6799 if (iSister > 0) iMother =
event[iSister].mother1();
6802 if (iSister > 0 && iMother > 0) {
6805 int flavSister =
event[iSister].id();
6806 int flavMother =
event[iMother].id();
6809 int flavDaughter = 0;
6810 if ( abs(flavMother) < 21 && flavSister == 21)
6811 flavDaughter = flavMother;
6812 else if ( flavMother == 21 && flavSister == 21)
6813 flavDaughter = flavMother;
6814 else if ( flavMother == 21 && abs(flavSister) < 21)
6815 flavDaughter = -1*flavSister;
6816 else if ( abs(flavMother) < 21 && abs(flavSister) < 21)
6821 for (
int i =0; i <
event.size(); ++i)
6822 if ( !event[i].isFinal()
6823 &&
event[i].mother1() == iMother
6824 &&
event[i].id() == flavDaughter )
6828 if ( !before )
return iMother;
6829 else return iDaughter;
6837 for (
int i =0; i <
event.size(); ++i)
6838 if ( abs(event[i].status()) == 53 || abs(event[i].status()) == 54) {
6844 if (iMother > 0) iDaughter =
event[iMother].daughter1();
6847 if (iDaughter > 0 && iMother > 0) {
6850 if ( !before )
return iMother;
6851 else return iDaughter;
6867 double History::pdfFactor(
const Event& event,
const int type,
6868 double pdfScale,
double mu ) {
6877 for (
int i =0; i <
event.size(); ++i)
6878 if ( abs(event[i].status()) == 53 || abs(event[i].status()) == 54) {
6882 int flavMother =
event[iMother].id();
6885 if ( iMother == 0 )
return 1.;
6888 int iDaughter =
event[iMother].daughter1();
6889 int flavDaughter =
event[iDaughter].id();
6892 double xMother = 2.*
event[iMother].e() /
event[0].e();
6893 double xDaughter = 2.*
event[iDaughter].e() /
event[0].e();
6897 int sideSplit = (
event[iMother].pz() > 0.) ? 1 : -1;
6898 double pdfDen1, pdfDen2, pdfNum1, pdfNum2;
6899 pdfDen1 = pdfDen2 = pdfNum1 = pdfNum2 = 1.;
6900 if ( sideSplit == 1 ) {
6902 pdfDen1 = max(1e-15,beamA.xfISR(0, flavDaughter, xDaughter, pow2(mu)) );
6903 pdfNum1 = beamA.xfISR(0, flavDaughter, xDaughter, pow2(pdfScale) );
6904 pdfNum2 = beamA.xfISR(0, flavMother, xMother, pow2(mu) );
6905 pdfDen2 = max(1e-15,beamA.xfISR(0,flavMother, xMother, pow2(pdfScale)) );
6908 pdfDen1 = max(1e-15,beamB.xfISR(0, flavDaughter, xDaughter, pow2(mu)) );
6909 pdfNum1 = beamB.xfISR(0, flavDaughter, xDaughter, pow2(pdfScale) );
6910 pdfNum2 = beamB.xfISR(0, flavMother, xMother, pow2(mu) );
6911 pdfDen2 = max(1e-15,beamB.xfISR(0,flavMother, xMother, pow2(pdfScale)) );
6916 if ( pdfDen2/pdfNum1 > 1. )
return 1.;
6921 weight = (pdfNum1/pdfDen1) * (pdfNum2)/(pdfDen2);
6924 }
else if (type == 2) {
6928 for (
int i =0; i <
event.size(); ++i)
6929 if (event[i].status() == 43) {
6933 int flavSister =
event[iSister].id();
6936 int iMother =
event[iSister].mother1();
6937 int flavMother =
event[iMother].id();
6940 int flavDaughter = 0;
6941 if ( abs(flavMother) < 21 && flavSister == 21)
6942 flavDaughter = flavMother;
6943 else if ( flavMother == 21 && flavSister == 21)
6944 flavDaughter = flavMother;
6945 else if ( flavMother == 21 && abs(flavSister) < 21)
6946 flavDaughter = -1*flavSister;
6947 else if ( abs(flavMother) < 21 && abs(flavSister) < 21)
6951 double xMother = 2.*
event[iMother].e() /
event[0].e();
6955 for (
int i =0; i <
event.size(); ++i)
6956 if ( !event[i].isFinal()
6957 &&
event[i].mother1() == iMother
6958 &&
event[i].id() == flavDaughter )
6960 double xDaughter = 2.*
event[iDaughter].e() /
event[0].e();
6965 int sideSplit = (
event[iMother].pz() > 0.) ? 1 : -1;
6966 double ratio1 = getPDFratio( sideSplit,
false,
false, flavDaughter,
6967 xDaughter, pdfScale, flavDaughter, xDaughter, mu );
6968 double ratio2 = getPDFratio( sideSplit,
false,
false, flavMother,
6969 xMother, mu, flavMother, xMother, pdfScale );
6971 weight = ratio1*ratio2;
6988 double History::integrand(
int flav,
double x,
double scaleInt,
double z) {
7000 AlphaStrong* as = mergingHooksPtr->AlphaS_ISR();
7001 double asNow = (*as).alphaS(z);
7002 result = 1./z *asNow*asNow* ( log(scaleInt/z) -3./2. );
7006 }
else if (flav==21) {
7008 double measure1 = 1./(1. - z);
7009 double measure2 = 1.;
7013 * z * beamB.xf( 21,x/z,pow(scaleInt,2))
7014 / beamB.xf( 21,x, pow(scaleInt,2))
7019 2.*CA *((1. -z)/z + z*(1.-z))
7020 * beamB.xf( 21,x/z,pow(scaleInt,2))
7021 / beamB.xf( 21,x, pow(scaleInt,2))
7023 + CF * ((1+pow(1-z,2))/z)
7024 *( beamB.xf( 1, x/z,pow(scaleInt,2))
7025 / beamB.xf( 21, x, pow(scaleInt,2))
7026 + beamB.xf( -1, x/z,pow(scaleInt,2))
7027 / beamB.xf( 21, x, pow(scaleInt,2))
7028 + beamB.xf( 2, x/z,pow(scaleInt,2))
7029 / beamB.xf( 21, x, pow(scaleInt,2))
7030 + beamB.xf( -2, x/z,pow(scaleInt,2))
7031 / beamB.xf( 21, x, pow(scaleInt,2))
7032 + beamB.xf( 3, x/z,pow(scaleInt,2))
7033 / beamB.xf( 21, x, pow(scaleInt,2))
7034 + beamB.xf( -3, x/z,pow(scaleInt,2))
7035 / beamB.xf( 21, x, pow(scaleInt,2))
7036 + beamB.xf( 4, x/z,pow(scaleInt,2))
7037 / beamB.xf( 21, x, pow(scaleInt,2))
7038 + beamB.xf( -4, x/z,pow(scaleInt,2))
7039 / beamB.xf( 21, x, pow(scaleInt,2)) );
7042 result = integrand1*measure1 + integrand2*measure2;
7046 double measure1 = 1./(1. -z);
7047 double measure2 = 1.;
7052 * beamB.xf( flav, x/z, pow(scaleInt,2))
7053 / beamB.xf( flav, x, pow(scaleInt,2))
7058 + TR * (pow(z,2) + pow(1-z,2))
7059 * beamB.xf( 21, x/z, pow(scaleInt,2))
7060 / beamB.xf( flav, x, pow(scaleInt,2));
7063 result = measure1*integrand1 + measure2*integrand2;