9 #include "Pythia8/Merging.h"
21 const double Merging::TMSMISMATCH = 1.5;
30 tmsNowMin = infoPtr->eCM();
37 void Merging::statistics() {
40 bool enforceCutOnLHE = flag(
"Merging:enforceCutOnLHE");
42 double tmsval = mergingHooksPtr ? mergingHooksPtr->tms() : 0;
43 bool printBanner = enforceCutOnLHE && tmsNowMin > TMSMISMATCH*tmsval;
45 tmsNowMin = infoPtr->eCM();
47 if (!printBanner)
return;
50 cout <<
"\n *------- PYTHIA Matrix Element Merging Information ------"
51 <<
"-------------------------------------------------------*\n"
56 cout <<
" | Warning in Merging::statistics: All Les Houches events"
57 <<
" significantly above Merging:TMS cut. Please check. |\n";
62 <<
" *------- End PYTHIA Matrix Element Merging Information -----"
63 <<
"-----------------------------------------------------*" << endl;
70 int Merging::mergeProcess(
Event& process){
75 mergingHooksPtr->hardProcess->clear();
76 mergingHooksPtr->processNow = word(
"Merging:Process");
77 mergingHooksPtr->hardProcess->initOnProcess(
78 mergingHooksPtr->processNow, particleDataPtr);
80 settingsPtr->word(
"Merging:Process", mergingHooksPtr->processSave);
82 mergingHooksPtr->doUserMergingSave = flag(
"Merging:doUserMerging");
83 mergingHooksPtr->doMGMergingSave = flag(
"Merging:doMGMerging");
84 mergingHooksPtr->doKTMergingSave = flag(
"Merging:doKTMerging");
85 mergingHooksPtr->doPTLundMergingSave = flag(
"Merging:doPTLundMerging");
86 mergingHooksPtr->doCutBasedMergingSave = flag(
"Merging:doCutBasedMerging");
87 mergingHooksPtr->doNL3TreeSave = flag(
"Merging:doNL3Tree");
88 mergingHooksPtr->doNL3LoopSave = flag(
"Merging:doNL3Loop");
89 mergingHooksPtr->doNL3SubtSave = flag(
"Merging:doNL3Subt");
90 mergingHooksPtr->doUNLOPSTreeSave = flag(
"Merging:doUNLOPSTree");
91 mergingHooksPtr->doUNLOPSLoopSave = flag(
"Merging:doUNLOPSLoop");
92 mergingHooksPtr->doUNLOPSSubtSave = flag(
"Merging:doUNLOPSSubt");
93 mergingHooksPtr->doUNLOPSSubtNLOSave = flag(
"Merging:doUNLOPSSubtNLO");
94 mergingHooksPtr->doUMEPSTreeSave = flag(
"Merging:doUMEPSTree");
95 mergingHooksPtr->doUMEPSSubtSave = flag(
"Merging:doUMEPSSubt");
96 mergingHooksPtr->nReclusterSave = mode(
"Merging:nRecluster");
98 mergingHooksPtr->hasJetMaxLocal =
false;
99 mergingHooksPtr->nJetMaxLocal = mergingHooksPtr->nJetMaxSave;
100 mergingHooksPtr->nJetMaxNLOLocal = mergingHooksPtr->nJetMaxNLOSave;
101 mergingHooksPtr->nRequestedSave = mode(
"Merging:nRequested");
104 bool includeWGT = mergingHooksPtr->includeWGTinXSEC();
107 bool applyTMSCut = flag(
"Merging:doXSectionEstimate");
108 if ( applyTMSCut && cutOnProcess(process) ) {
109 if (includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
113 if ( applyTMSCut )
return 1;
116 if ( mergingHooksPtr->doCKKWLMerging() )
117 vetoCode = mergeProcessCKKWL(process);
120 if ( mergingHooksPtr->doUMEPSMerging() )
121 vetoCode = mergeProcessUMEPS(process);
124 if ( mergingHooksPtr->doNL3Merging() )
125 vetoCode = mergeProcessNL3(process);
128 if ( mergingHooksPtr->doUNLOPSMerging() )
129 vetoCode = mergeProcessUNLOPS(process);
139 int Merging::mergeProcessCKKWL(
Event& process) {
142 mergingHooksPtr->doIgnoreStep(
true);
145 if ( mergingHooksPtr->getProcessString().compare(
"pp>h") == 0 )
146 mergingHooksPtr->allowCutOnRecState(
true);
148 mergingHooksPtr->orderHistories(
true);
151 bool includeWGT = mergingHooksPtr->includeWGTinXSEC();
154 int nWgts = mergingHooksPtr->nWgts;
155 vector<double> wgt( nWgts, 1.0 );
156 mergingHooksPtr->setWeightCKKWL(wgt);
157 mergingHooksPtr->muMI(-1.);
162 Event newProcess( mergingHooksPtr->bareEvent( process,
true) );
164 if (mergingHooksPtr->doWeakClustering())
165 for (
int i = 0;i < newProcess.size();++i)
166 newProcess[i].pol(9);
168 mergingHooksPtr->storeHardProcessCandidates( newProcess);
171 double tmsval = mergingHooksPtr->tms();
173 double tmsnow = mergingHooksPtr->tmsNow( newProcess );
175 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( newProcess,
true);
178 bool applyVeto = flag(
"Merging:applyVeto");
183 int nRequested = mergingHooksPtr->nRequested();
186 mergingHooksPtr->setHardProcessInfo(nSteps, tmsnow);
187 mergingHooksPtr->setEventVetoInfo(-1, -1.);
188 if (nSteps < nRequested ) {
189 if (!includeWGT) mergingHooksPtr->
190 setWeightCKKWL(vector<double>(nWgts, 0.));
191 if ( includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
192 if (applyVeto)
return -1;
197 tmsNowMin = (nSteps > 0 && tmsnow < infoPtr->eCM())
198 ? min(tmsNowMin, tmsnow) : 0.;
201 double RN = rndmPtr->flat();
204 newProcess.scale(0.0);
206 History FullHistory( nSteps, 0.0, newProcess, Clustering(), mergingHooksPtr,
207 (*beamAPtr), (*beamBPtr), particleDataPtr, infoPtr,
208 trialPartonLevelPtr, coupSMPtr,
true,
true,
true,
true, 1.0, 0);
211 FullHistory.projectOntoDesiredHistories();
214 FullHistory.select(RN)->setSelectedChild();
218 bool applyCut = nSteps > 0 && FullHistory.select(RN)->nClusterings() > 0;
222 bool enforceCutOnLHE = flag(
"Merging:enforceCutOnLHE");
223 if ( enforceCutOnLHE && applyCut && tmsnow < tmsval && tmsnow >= 0. ) {
224 string message=
"Warning in Merging::mergeProcessCKKWL: Les Houches Event";
225 message+=
" fails merging scale cut. Reject event.";
226 infoPtr->errorMsg(message);
227 if (!includeWGT) mergingHooksPtr->
228 setWeightCKKWL(vector<double>(nWgts, 0.));
229 if ( includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
231 if (applyVeto)
return -1;
240 coreProcess.init(
"(hard process-modified)", particleDataPtr );
242 coreProcess = FullHistory.lowestMultProc(RN);
243 for (
int i = 0; i < coreProcess.size(); ++i )
244 if ( coreProcess[i].isFinal() ) {
245 if ( coreProcess[i].colType() != 0 )
247 if ( coreProcess[i].idAbs() == 24 )
251 bool complete = (FullHistory.select(RN)->nClusterings() == nSteps) ||
252 ( mergingHooksPtr->doWeakClustering() && nFinalP == 2 && nFinalW == 0 );
255 string message=
"Warning in Merging::mergeProcessCKKWL: No clusterings";
256 message+=
" found. History incomplete.";
257 infoPtr->errorMsg(message);
263 wgt = FullHistory.weightCKKWL( trialPartonLevelPtr,
264 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
265 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(), RN);
269 FullHistory.getStartingConditions( RN, process );
271 mergingHooksPtr->reattachResonanceDecays(process);
275 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
276 FullHistory.lowestMultProc(RN) );
280 for (
double& wgti: wgt) wgti *= dampWeight;
283 if (!includeWGT) mergingHooksPtr->setWeightCKKWL(wgt);
289 vector<double> relWgt({1.});
290 for (
int iVar = 1; iVar < nWgts; ++iVar)
291 relWgt.push_back(wgt[0] != 0 ? wgt[iVar]/wgt[0] :
292 std::numeric_limits<double>::infinity());
293 infoPtr->weightContainerPtr->
294 setWeightNominal(infoPtr->weight()*wgt[0]);
295 mergingHooksPtr->setWeightCKKWL(relWgt);
299 mergingHooksPtr->doIgnoreStep(
false);
302 if ( applyVeto && wgt[0] == 0. )
return 0;
313 int Merging::mergeProcessUMEPS(
Event& process) {
316 bool doUMEPSTree = flag(
"Merging:doUMEPSTree");
317 bool doUMEPSSubt = flag(
"Merging:doUMEPSSubt");
319 mergingHooksPtr->nReclusterSave = mode(
"Merging:nRecluster");
320 int nRecluster = mode(
"Merging:nRecluster");
323 mergingHooksPtr->doIgnoreEmissions(
true);
326 if ( mergingHooksPtr->getProcessString().compare(
"pp>h") == 0 )
327 mergingHooksPtr->allowCutOnRecState(
true);
329 mergingHooksPtr->orderHistories(
true);
332 bool includeWGT = mergingHooksPtr->includeWGTinXSEC();
335 if (mergingHooksPtr->doWeakClustering())
336 for (
int i = 0;i < process.size();++i)
340 int nWgts = mergingHooksPtr->nWgts;
341 vector<double> wgt( nWgts, 1.);
342 mergingHooksPtr->setWeightCKKWL(wgt);
343 mergingHooksPtr->muMI(-1.);
348 Event newProcess( mergingHooksPtr->bareEvent( process,
true) );
350 mergingHooksPtr->storeHardProcessCandidates( newProcess );
353 double tmsval = mergingHooksPtr->tms();
355 double tmsnow = mergingHooksPtr->tmsNow( newProcess );
357 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( newProcess,
true);
358 int nRequested = mergingHooksPtr->nRequested();
361 bool applyVeto = flag(
"Merging:applyVeto");
366 if (nSteps < nRequested) {
367 if (!includeWGT) mergingHooksPtr->
368 setWeightCKKWL(vector<double>(nWgts, 0.));
369 if ( includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
370 if (applyVeto)
return -1;
375 tmsNowMin = (nSteps == 0) ? 0. : min(tmsNowMin, tmsnow);
378 double RN = rndmPtr->flat();
380 newProcess.scale(0.0);
382 History FullHistory( nSteps, 0.0, newProcess, Clustering(), mergingHooksPtr,
383 (*beamAPtr), (*beamBPtr), particleDataPtr, infoPtr,
384 trialPartonLevelPtr, coupSMPtr,
true,
true,
true,
true, 1.0, 0);
386 FullHistory.projectOntoDesiredHistories();
390 bool applyCut = nSteps > 0 && FullHistory.select(RN)->nClusterings() > 0;
394 bool enforceCutOnLHE = flag(
"Merging:enforceCutOnLHE");
395 if ( enforceCutOnLHE && applyCut && tmsnow < tmsval ) {
396 string message=
"Warning in Merging::mergeProcessUMEPS: Les Houches Event";
397 message+=
" fails merging scale cut. Reject event.";
398 infoPtr->errorMsg(message);
399 if (!includeWGT) mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
400 if ( includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
401 if (applyVeto)
return -1;
407 if ( nSteps > 0 && doUMEPSSubt
408 && !FullHistory.getFirstClusteredEventAboveTMS( RN, nRecluster,
409 newProcess, nPerformed,
false ) ) {
411 if (!includeWGT) mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
412 if ( includeWGT) infoPtr->weightContainerPtr->setWeightNominal(0.);
413 if (applyVeto)
return -1;
417 mergingHooksPtr->nMinMPI(nSteps - nPerformed);
423 wgt = FullHistory.weightUMEPSTree( trialPartonLevelPtr,
424 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
425 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(), RN);
427 wgt = FullHistory.weightUMEPSSubt( trialPartonLevelPtr,
428 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
429 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(), RN);
434 if ( doUMEPSTree ) FullHistory.getStartingConditions( RN, process );
436 else FullHistory.getFirstClusteredEventAboveTMS( RN, nRecluster, process,
441 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
442 FullHistory.lowestMultProc(RN) );
446 for (
double& wgti: wgt) wgti *= dampWeight;
449 if (!includeWGT) mergingHooksPtr->setWeightCKKWL(wgt);
455 vector<double> relWgt({1.});
456 for (
int iVar = 1; iVar < nWgts; ++iVar)
457 relWgt.push_back(wgt[0] != 0 ? wgt[iVar]/wgt[0] :
458 std::numeric_limits<double>::infinity());
459 infoPtr->weightContainerPtr->
460 setWeightNominal(infoPtr->weight()*wgt[0]);
461 mergingHooksPtr->setWeightCKKWL(relWgt);
467 double muf = process[0].e();
468 for (
int i=0; i < process.size(); ++i )
469 if ( process[i].isFinal()
470 && (process[i].colType() != 0 || process[i].id() == 22 ) ) {
472 muf = min( muf, abs(process[i].mT()) );
478 int nStepsNew = mergingHooksPtr->getNumberOfClusteringSteps( process );
480 && ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
481 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0) )
485 mergingHooksPtr->storeHardProcessCandidates( process );
487 mergingHooksPtr->reattachResonanceDecays(process);
490 mergingHooksPtr->doIgnoreEmissions(
false);
493 if ( applyVeto && wgt[0] == 0. )
return 0;
504 int Merging::mergeProcessNL3(
Event& process) {
507 bool doNL3Tree = flag(
"Merging:doNL3Tree");
508 bool doNL3Loop = flag(
"Merging:doNL3Loop");
509 bool doNL3Subt = flag(
"Merging:doNL3Subt");
512 mergingHooksPtr->doIgnoreEmissions(
true);
514 mergingHooksPtr->doIgnoreStep(
true);
517 if ( mergingHooksPtr->getProcessString().compare(
"pp>h") == 0)
518 mergingHooksPtr->allowCutOnRecState(
true);
520 mergingHooksPtr->orderHistories(
true);
523 int nWgts = mergingHooksPtr->nWgts;
524 vector<double> wgt( nWgts, 1. );
525 mergingHooksPtr->setWeightCKKWL(wgt);
527 vector<double> wgtFIRST( nWgts, 0. );
528 mergingHooksPtr->setWeightFIRST(wgtFIRST);
529 mergingHooksPtr->muMI(-1.);
534 Event newProcess( mergingHooksPtr->bareEvent( process,
true) );
536 mergingHooksPtr->storeHardProcessCandidates( newProcess);
539 double tmsval = mergingHooksPtr->tms();
541 double tmsnow = mergingHooksPtr->tmsNow( newProcess );
543 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( newProcess,
true);
544 int nRequested = mergingHooksPtr->nRequested();
549 if (nSteps < nRequested) {
550 mergingHooksPtr->setWeightCKKWL(vector<double>( nWgts, 0.));
551 mergingHooksPtr->setWeightFIRST(vector<double>( nWgts, 0.));
556 tmsNowMin = (nSteps == 0) ? 0. : min(tmsNowMin, tmsnow);
560 bool enforceCutOnLHE = flag(
"Merging:enforceCutOnLHE");
561 if ( enforceCutOnLHE && nSteps > 0 && nSteps == nRequested
562 && tmsnow < tmsval ) {
563 string message=
"Warning in Merging::mergeProcessNL3: Les Houches Event";
564 message+=
" fails merging scale cut. Reject event.";
565 infoPtr->errorMsg(message);
566 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts, 0.));
567 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts, 0.));
572 double RN = rndmPtr->flat();
574 newProcess.scale(0.0);
576 History FullHistory( nSteps, 0.0, newProcess, Clustering(), mergingHooksPtr,
577 (*beamAPtr), (*beamBPtr), particleDataPtr, infoPtr,
578 trialPartonLevelPtr, coupSMPtr,
true,
true,
true,
true, 1.0, 0);
580 FullHistory.projectOntoDesiredHistories();
583 if ( nSteps > 0 && doNL3Subt
584 && FullHistory.select(RN)->nClusterings() == 0 ){
585 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts, 0.));
586 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts, 0.));
592 bool containsRealKin = nSteps > nRequested && nSteps > 0;
596 if ( containsRealKin ) {
600 dummy.init(
"(hard process-modified)", particleDataPtr );
603 if ( !FullHistory.getClusteredEvent( RN, nSteps, dummy )) {
604 mergingHooksPtr->setWeightCKKWL( vector<double>( nWgts, 0. ) );
605 mergingHooksPtr->setWeightFIRST( vector<double>( nWgts, 0. ) );
608 double tnowNew = mergingHooksPtr->tmsNow( dummy );
610 if ( enforceCutOnLHE && nRequested > 0 && tnowNew < tmsval ) {
611 mergingHooksPtr->setWeightCKKWL(vector<double>( nWgts, 0. ) );
612 mergingHooksPtr->setWeightFIRST( vector<double>( nWgts, 0. ) );
618 if ( doNL3Subt || containsRealKin ) mergingHooksPtr->nMinMPI(nSteps - 1);
619 else mergingHooksPtr->nMinMPI(nSteps);
626 wgt = FullHistory.weightNL3Tree( trialPartonLevelPtr,
627 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
628 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(), RN);
629 }
else if( doNL3Loop || doNL3Subt ) {
632 wgt = FullHistory.weightNL3Loop( trialPartonLevelPtr, RN);
637 if ( !doNL3Subt && !containsRealKin )
638 FullHistory.getStartingConditions(RN, process);
644 if ( !FullHistory.getClusteredEvent( RN, nSteps, process )) {
645 mergingHooksPtr->setWeightCKKWL(vector<double> (nWgts, 0.));
646 mergingHooksPtr->setWeightFIRST(vector<double> (nWgts, 0.));
653 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
654 FullHistory.lowestMultProc(RN) );
658 for (
double& wgti: wgt) wgti *= dampWeight;
664 if( nSteps > mergingHooksPtr->nMaxJetsNLO() )
665 kFactor = mergingHooksPtr->kFactor( mergingHooksPtr->nMaxJetsNLO() );
666 else kFactor = mergingHooksPtr->kFactor(nSteps);
668 for (
double& wgti: wgt) wgti *= kFactor;
672 mergingHooksPtr->setWeightCKKWL(wgt);
677 bool doOASTree = doNL3Tree && nSteps <= mergingHooksPtr->nMaxJetsNLO();
682 wgtFIRST = FullHistory.weightNL3First( trialPartonLevelPtr,
683 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
684 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(), RN,
687 for (
double& wFi: wgtFIRST) wFi *= dampWeight;
689 mergingHooksPtr->setWeightFIRST(wgtFIRST);
692 for (
int iVar = 0; iVar < nWgts; ++iVar)
693 wgt[iVar] = wgt[iVar] - wgtFIRST[iVar];
699 for(
int i=0; i < process.size(); ++i)
700 if(process[i].isFinal() && process[i].colType() != 0) {
701 pT = sqrt(pow(process[i].px(),2) + pow(process[i].py(),2));
707 && mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0)
711 mergingHooksPtr->storeHardProcessCandidates( process );
713 mergingHooksPtr->reattachResonanceDecays(process);
716 mergingHooksPtr->doIgnoreEmissions(
false);
718 mergingHooksPtr->doIgnoreStep(
false);
729 int Merging::mergeProcessUNLOPS(
Event& process) {
732 bool nloTilde = flag(
"Merging:doUNLOPSTilde");
733 bool doUNLOPSTree = flag(
"Merging:doUNLOPSTree");
734 bool doUNLOPSLoop = flag(
"Merging:doUNLOPSLoop");
735 bool doUNLOPSSubt = flag(
"Merging:doUNLOPSSubt");
736 bool doUNLOPSSubtNLO = flag(
"Merging:doUNLOPSSubtNLO");
738 mergingHooksPtr->nReclusterSave = mode(
"Merging:nRecluster");
739 int nRecluster = mode(
"Merging:nRecluster");
742 mergingHooksPtr->doIgnoreEmissions(
true);
744 mergingHooksPtr->orderHistories(
true);
747 if ( mergingHooksPtr->getProcessString().compare(
"pp>h") == 0)
748 mergingHooksPtr->allowCutOnRecState(
true);
751 int nWgts = mergingHooksPtr->nWgts;
752 vector<double> wgt( nWgts, 1. );
753 mergingHooksPtr->setWeightCKKWL(wgt);
755 vector<double> wgtFIRST( nWgts, 0. );
756 mergingHooksPtr->setWeightFIRST(wgtFIRST);
757 mergingHooksPtr->muMI(-1.);
760 vector<double> wgtP( nWgts, 1. );
761 vector<double> wgtPC( nWgts, 1. );
762 vector<double> wgtFIRSTP( nWgts, 0. );
763 vector<double> wgtFIRSTPC( nWgts, 0. );
766 bool doSchemeVariation = settingsPtr->flag(
"Merging:doSchemeVariation");
767 if (doSchemeVariation) {
768 infoPtr->weightContainerPtr->weightsMerging.weightValuesP = wgtP;
769 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC = wgtPC;
770 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP
772 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC
780 Event newProcess( mergingHooksPtr->bareEvent( process,
true) );
782 mergingHooksPtr->storeHardProcessCandidates( newProcess );
785 double tmsval = mergingHooksPtr->tms();
787 double tmsnow = mergingHooksPtr->tmsNow( newProcess );
789 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( newProcess,
true);
790 int nRequested = mergingHooksPtr->nRequested();
793 bool allowReject = flag(
"Merging:applyVeto");
798 if (nSteps < nRequested) {
799 string message=
"Warning in Merging::mergeProcessUNLOPS: Les Houches Event";
800 message+=
" after removing decay products does not contain enough partons.";
801 infoPtr->errorMsg(message);
802 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
803 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts,0.));
804 if (doSchemeVariation) {
805 infoPtr->weightContainerPtr->weightsMerging.weightValuesP =
806 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC =
807 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP =
808 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC =
809 vector<double>(nWgts,0.);
811 return ((allowReject)? -1 : 1);
815 tmsNowMin = (nSteps == 0) ? 0. : min(tmsNowMin, tmsnow);
818 double RN = rndmPtr->flat();
820 newProcess.scale(0.0);
822 History FullHistory( nSteps, 0.0, newProcess, Clustering(), mergingHooksPtr,
823 (*beamAPtr), (*beamBPtr), particleDataPtr, infoPtr,
824 trialPartonLevelPtr, coupSMPtr,
true,
true,
true,
true, 1.0, 0);
826 FullHistory.projectOntoDesiredHistories();
830 bool applyCut = nSteps > 0 && FullHistory.select(RN)->nClusterings() > 0;
834 bool enforceCutOnLHE = flag(
"Merging:enforceCutOnLHE");
835 if ( enforceCutOnLHE && applyCut && nSteps == nRequested
836 && tmsnow < tmsval ) {
837 string message=
"Warning in Merging::mergeProcessUNLOPS: Les Houches";
838 message+=
" Event fails merging scale cut. Reject event.";
839 infoPtr->errorMsg(message);
840 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
841 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts,0.));
842 if (doSchemeVariation) {
843 infoPtr->weightContainerPtr->weightsMerging.weightValuesP =
844 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC =
845 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP =
846 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC =
847 vector<double>(nWgts,0.);
849 return ((allowReject)? -1 : 1);
854 bool containsRealKin = nSteps > nRequested && nSteps > 0;
855 if ( containsRealKin ) nRecluster += nSteps - nRequested;
860 bool allowIncompleteReal = flag(
"Merging:allowIncompleteHistoriesInReal");
861 if ( doUNLOPSLoop && containsRealKin && !allowIncompleteReal
862 && FullHistory.select(RN)->nClusterings() == 0 ) {
863 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
864 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts,0.));
865 if (doSchemeVariation) {
866 infoPtr->weightContainerPtr->weightsMerging.weightValuesP =
867 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC =
868 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP =
869 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC =
870 vector<double>(nWgts,0.);
872 return ((allowReject)? -1 : 1);
877 if ( nSteps > 0 && !allowIncompleteReal
878 && ( doUNLOPSSubt || doUNLOPSSubtNLO || containsRealKin )
879 && !FullHistory.getFirstClusteredEventAboveTMS( RN, nRecluster,
880 newProcess, nPerformed,
false ) ) {
881 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts, 0.));
882 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts, 0.));
883 if (doSchemeVariation) {
884 infoPtr->weightContainerPtr->weightsMerging.weightValuesP =
885 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC =
886 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP =
887 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC =
888 vector<double>(nWgts,0.);
890 return ((allowReject)? -1 : 1);
894 mergingHooksPtr->nMinMPI(nSteps - nPerformed);
898 if ( containsRealKin ) {
902 dummy.init(
"(hard process-modified)", particleDataPtr );
905 FullHistory.getClusteredEvent( RN, nSteps, dummy );
906 double tnowNew = mergingHooksPtr->tmsNow( dummy );
908 if ( enforceCutOnLHE && nRequested > 0 && tnowNew < tmsval ) {
909 string message=
"Warning in Merging::mergeProcessUNLOPS: Les Houches";
910 message+=
" Event fails merging scale cut. Reject event.";
911 infoPtr->errorMsg(message);
912 mergingHooksPtr->setWeightCKKWL(vector<double>(nWgts,0.));
913 mergingHooksPtr->setWeightFIRST(vector<double>(nWgts,0.));
914 if (doSchemeVariation) {
915 infoPtr->weightContainerPtr->weightsMerging.weightValuesP =
916 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC =
917 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP =
918 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC =
919 vector<double>(nWgts,0.);
921 return ((allowReject)? -1 : 1);
926 int depth = (!doSchemeVariation) ? -1 : ( (containsRealKin) ?
934 wgt = FullHistory.weightUNLOPSTree( trialPartonLevelPtr,
935 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
936 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(),
938 }
else if( doUNLOPSLoop ) {
940 wgt = FullHistory.weightUNLOPSLoop( trialPartonLevelPtr,
941 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
942 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(),
944 }
else if( doUNLOPSSubtNLO ) {
946 wgt = FullHistory.weightUNLOPSSubtNLO( trialPartonLevelPtr,
947 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
948 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(),
950 }
else if( doUNLOPSSubt ) {
953 wgt = FullHistory.weightUNLOPSSubt( trialPartonLevelPtr,
954 mergingHooksPtr->AlphaS_FSR(), mergingHooksPtr->AlphaS_ISR(),
955 mergingHooksPtr->AlphaEM_FSR(), mergingHooksPtr->AlphaEM_ISR(),
960 if (doSchemeVariation && (doUNLOPSLoop || doUNLOPSSubtNLO)) {
962 wgt = mergingHooksPtr->individualWeights.mpiWeightSave;
963 wgtP = mergingHooksPtr->getSudakovWeight();
968 if (!doUNLOPSSubt && !doUNLOPSSubtNLO && !containsRealKin )
969 FullHistory.getStartingConditions(RN, process);
971 else FullHistory.getFirstClusteredEventAboveTMS( RN, nRecluster, process,
976 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
977 FullHistory.lowestMultProc(RN) );
981 for (
double& wgti: wgt) wgti *= dampWeight;
982 if (doSchemeVariation && (doUNLOPSLoop || doUNLOPSSubtNLO)) {
983 for (
double& wgti: wgtP) wgti *= dampWeight;
984 for (
double& wgti: wgtPC) wgti *= dampWeight;
988 if ( doUNLOPSTree || doUNLOPSSubt ){
991 if ( nSteps > mergingHooksPtr->nMaxJetsNLO() )
992 kFactor = mergingHooksPtr->kFactor( mergingHooksPtr->nMaxJetsNLO() );
993 else kFactor = mergingHooksPtr->kFactor(nSteps);
995 for (
double& wgti: wgt) wgti *= (nRecluster == 2 && nloTilde) ?
1000 mergingHooksPtr->setWeightCKKWL(wgt);
1001 if ( doSchemeVariation ) {
1002 if (doUNLOPSLoop || doUNLOPSSubtNLO) {
1003 infoPtr->weightContainerPtr->weightsMerging.weightValuesP = wgtP;
1004 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC = wgtPC;
1006 infoPtr->weightContainerPtr->weightsMerging.weightValuesP = wgtP = wgt;
1007 infoPtr->weightContainerPtr->weightsMerging.weightValuesPC = wgtPC = wgt;
1014 int nMaxNLO = mergingHooksPtr->nMaxJetsNLO();
1015 bool doOASTree = doUNLOPSTree && nSteps <= nMaxNLO;
1016 bool doOASSubt = doUNLOPSSubt && nSteps <= nMaxNLO+1 && nSteps > 0;
1019 if ( doOASTree || doOASSubt ) {
1022 int order = ( nSteps > 0 && nSteps <= nMaxNLO) ? 1 : -1;
1027 if ( nloTilde && doUNLOPSSubt && nRecluster == 1
1028 && nSteps == nMaxNLO+1 ) order = 0;
1034 if (nloTilde && doUNLOPSSubt && ( nSteps > nMaxNLO+1
1035 || (nSteps == nMaxNLO+1 && nPerformed != nRecluster) ))
1039 wgtFIRST = FullHistory.weightUNLOPSFirst( order,
1040 trialPartonLevelPtr, mergingHooksPtr->AlphaS_FSR(),
1041 mergingHooksPtr->AlphaS_ISR(), mergingHooksPtr->AlphaEM_FSR(),
1042 mergingHooksPtr->AlphaEM_ISR(), RN, rndmPtr );
1047 if ( nloTilde && doUNLOPSSubt && nRecluster == 1
1048 && nPerformed == nRecluster && nSteps <= nMaxNLO )
1049 for (
double& wFi: wgtFIRST) wFi += 1.;
1052 for (
double& wFi: wgtFIRST) wFi *= dampWeight;
1055 mergingHooksPtr->setWeightFIRST(wgtFIRST);
1056 if (doSchemeVariation) {
1057 vector<double> sudFact = mergingHooksPtr->getSudakovWeight();
1058 vector<double> couplingFact = mergingHooksPtr->getCouplingWeight();
1059 for (
int iWgt = 0; iWgt < nWgts; ++iWgt) {
1060 double wgtF = wgtFIRST[iWgt]*sudFact[iWgt];
1061 wgtFIRSTP[iWgt] = wgtF;
1062 wgtF *= couplingFact[iWgt];
1063 wgtFIRSTPC[iWgt] = wgtF;
1065 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP
1067 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC
1077 for (
int i = 0; i < nWgts; ++i) {
1078 wgt[i] = wgt[i] - wgtFIRST[i];
1079 if (doSchemeVariation) {
1080 wgtP[i] = wgtP[i] - wgtFIRSTP[i];
1081 wgtPC[i] = wgtPC[i] - wgtFIRSTPC[i];
1087 else if (doSchemeVariation) {
1088 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstP
1090 infoPtr->weightContainerPtr->weightsMerging.weightValuesFirstPC
1097 double muf = process[0].e();
1098 for (
int i=0; i < process.size(); ++i )
1099 if ( process[i].isFinal()
1100 && (process[i].colType() != 0 || process[i].id() == 22 ) ) {
1102 muf = min( muf, abs(process[i].mT()) );
1106 if ( nSteps == 0 && nFinal == 2
1107 && ( mergingHooksPtr->getProcessString().compare(
"pp>jj") == 0
1108 || mergingHooksPtr->getProcessString().compare(
"pp>aj") == 0) )
1112 mergingHooksPtr->storeHardProcessCandidates( process );
1116 vector <int> oldResonance;
1117 for (
int i=0; i < newProcess.size(); ++i )
1118 if ( newProcess[i].status() == 22 )
1119 oldResonance.push_back(newProcess[i].id());
1120 vector <int> newResonance;
1121 for (
int i=0; i < process.size(); ++i )
1122 if ( process[i].status() == 22 )
1123 newResonance.push_back(process[i].id());
1125 for (
int i=0; i < int(oldResonance.size()); ++i )
1126 for (
int j=0; j < int(newResonance.size()); ++j )
1127 if ( newResonance[j] == oldResonance[i] ) {
1128 oldResonance[i] = 99;
1131 bool hasNewResonances = (newResonance.size() != oldResonance.size());
1132 for (
int i=0; i < int(oldResonance.size()); ++i )
1133 hasNewResonances = (oldResonance[i] != 99);
1136 if (!hasNewResonances) mergingHooksPtr->reattachResonanceDecays(process);
1139 mergingHooksPtr->doIgnoreEmissions(
false);
1143 if (!doSchemeVariation && wgt[0] == 0.)
return 0;
1144 if (doSchemeVariation && wgt[0] == 0. && wgtP[0] == 0. && wgtPC[0] == 0.)
1150 if (hasNewResonances)
return 2;
1161 bool Merging::cutOnProcess(
Event& process) {
1164 mergingHooksPtr->nReclusterSave = mode(
"Merging:nRecluster");
1167 mergingHooksPtr->orderHistories(
true);
1170 if ( mergingHooksPtr->getProcessString().compare(
"pp>h") == 0)
1171 mergingHooksPtr->allowCutOnRecState(
true);
1174 if (mergingHooksPtr->doWeakClustering())
1175 for (
int i = 0;i < process.size();++i)
1181 Event newProcess( mergingHooksPtr->bareEvent( process,
true) );
1183 mergingHooksPtr->storeHardProcessCandidates( newProcess );
1186 double tmsval = mergingHooksPtr->tms();
1188 double tmsnow = mergingHooksPtr->tmsNow( newProcess );
1190 int nSteps = mergingHooksPtr->getNumberOfClusteringSteps( newProcess,
true);
1195 int nRequested = mergingHooksPtr->nRequested();
1196 if (nSteps < nRequested)
return true;
1199 tmsNowMin = (nSteps == 0) ? 0. : min(tmsNowMin, tmsnow);
1203 bool containsRealKin = nSteps > nRequested && nSteps > 0;
1206 double RN = rndmPtr->flat();
1208 newProcess.scale(0.0);
1210 History FullHistory( nSteps, 0.0, newProcess, Clustering(), mergingHooksPtr,
1211 (*beamAPtr), (*beamBPtr), particleDataPtr, infoPtr,
1212 trialPartonLevelPtr, coupSMPtr,
true,
true,
true,
true, 1.0, 0);
1214 FullHistory.projectOntoDesiredHistories();
1219 bool allowIncompleteReal = flag(
"Merging:allowIncompleteHistoriesInReal");
1220 if ( containsRealKin && !allowIncompleteReal
1221 && FullHistory.select(RN)->nClusterings() == 0 )
1225 double dampWeight = mergingHooksPtr->dampenIfFailCuts(
1226 FullHistory.lowestMultProc(RN) );
1227 if ( dampWeight == 0. )
return true;
1231 if ( nSteps > 0 && FullHistory.select(RN)->nClusterings() == 0 )
1236 if ( nSteps > 0 && nSteps == nRequested && tmsnow < tmsval ) {
1237 string message=
"Warning in Merging::cutOnProcess: Les Houches Event";
1238 message+=
" fails merging scale cut. Reject event.";
1239 infoPtr->errorMsg(message);
1247 coreProcess.clear();
1248 coreProcess.init(
"(hard process-modified)", particleDataPtr );
1249 coreProcess.clear();
1250 coreProcess = FullHistory.lowestMultProc(RN);
1251 for (
int i = 0; i < coreProcess.size(); ++i )
1252 if ( coreProcess[i].isFinal() ) {
1253 if ( coreProcess[i].colType() != 0 )
1255 if ( coreProcess[i].idAbs() == 24 )
1259 bool complete = (FullHistory.select(RN)->nClusterings() == nSteps) ||
1260 ( mergingHooksPtr->doWeakClustering() && nFinalP == 2 && nFinalW == 0 );
1263 string message=
"Warning in Merging::cutOnProcess: No clusterings";
1264 message+=
" found. History incomplete.";
1265 infoPtr->errorMsg(message);
1269 if ( !containsRealKin )
return false;
1277 dummy.init(
"(hard process-modified)", particleDataPtr );
1280 FullHistory.getClusteredEvent( RN, nSteps, dummy );
1281 double tnowNew = mergingHooksPtr->tmsNow( dummy );
1283 if ( nRequested > 0 && tnowNew < tmsval ) {
1284 string message =
"Warning in Merging::cutOnProcess: Les Houches Event";
1285 message +=
" fails merging scale cut. Reject event.";
1286 infoPtr->errorMsg(message);