From 8a829c88803abd40f18a76d29471e3b4e8c9a1f6 Mon Sep 17 00:00:00 2001 From: Valdis Slokenbergs Date: Fri, 21 Jul 2023 16:25:53 +0200 Subject: [PATCH 1/9] Backport to 13_2 --- .../Pythia8Interface/plugins/TopRecoilHook.h | 136 ++++++++++++++++++ .../test/TopRecoilHook_test_cfg.py | 92 ++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h create mode 100644 GeneratorInterface/Pythia8Interface/test/TopRecoilHook_test_cfg.py diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h new file mode 100644 index 0000000000000..c07c84ef9e4c9 --- /dev/null +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -0,0 +1,136 @@ +// TopRecoilHook.h is a part of the PYTHIA event generator. +// Copyright (C) 2020 Torbjorn Sjostrand. +// PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details. +// Please respect the MCnet Guidelines, see GUIDELINES for details. + +// Includes a user hook that corrects emission in top decay for dipole +// from gluon to W, to instead be from gluon to top. + +// Important: the top mass shift analysis encoded here is very primitive, +// does not perform well at all, and should not be taken seriously. +// The important part is that you see how the different scenarios +// should be set up to operate as intended. + +#include "Pythia8/Pythia.h" +namespace Pythia8 { + + //========================================================================== + + // Write own derived UserHooks class for modified emission in top decay. + + class TopRecoilHook : public UserHooks { + public: + // Constructor. + // doTopRecoil : eikonal correction in GW dipole on/off when no MEC applied. + // useOldDipole : in GW dipole, use partons before or after branching. + // doList : diagnostic output; set false for production runs. + TopRecoilHook(bool doTopRecoilIn = true, bool useOldDipoleIn = false, bool doListIn = false) { + doTopRecoil = doTopRecoilIn; + useOldDipole = useOldDipoleIn; + doList = doListIn; + // Constructor also creates some histograms for analysis inside User Hook. + wtCorr = new Hist("corrective weight", 100, 0., 2.); + } + + // Destructor prints histogram. + ~TopRecoilHook() override { + if (doTopRecoil) + ; + delete wtCorr; + } + + // Initialise. Only use hook for simple showers with recoilToColoured = off. + bool initAfterBeams() override { + // Switch off if recoilToColoured = on. + bool recoilToColoured = settingsPtr->flag("TimeShower:recoilToColoured"); + if (recoilToColoured) + doTopRecoil = false; + // Flag if W mass term is already accounted for (true) or not (false). + recoilDeadCone = settingsPtr->flag("TimeShower:recoilDeadCone"); + // All ok. + return true; + } + + // Allow a veto after an FSR emission + bool canVetoFSREmission() override { return doTopRecoil; } + + // Access the event after an FSR emission, specifically inside top decay. + bool doVetoFSREmission(int sizeOld, const Event& event, int iSys, bool inResonance) override { + // Check that we are inside a resonance decay. + if (!inResonance) + return false; + + // Check that it is a top decay. + int iTop = partonSystemsPtr->getInRes(iSys); + if (iTop == 0 || event[iTop].idAbs() != 6) + return false; + + // Skip first emission, where ME corrections are already made. + int sizeOut = partonSystemsPtr->sizeOut(iSys); + if (sizeOut == 2) + return false; + + // Location of trial new particles: radiator, emitted, recoiler. + int iRad = sizeOld; + int iEmt = sizeOld + 1; + int iRec = sizeOld + 2; + + // The above partons are after emission; + // alternatively use the ones before. + if (useOldDipole) { + iRad = event[iRad].mother1(); + iRec = event[iRec].mother1(); + } + + // Check if newly emitted gluon matches (anti)top colour line. + if (event[iEmt].id() != 21) + return false; + if (event[iTop].id() == 6) { + if (event[iEmt].col() != event[iTop].col()) + return false; + } else { + if (event[iEmt].acol() != event[iTop].acol()) + return false; + } + + // Recoiler should now be a W, else something is wrong. + if (event[iRec].idAbs() != 24) { + return false; + } + + // Denominator: eikonal weight with W as recoiler. + double pRadRec = event[iRad].p() * event[iRec].p(); + double pRadEmt = event[iRad].p() * event[iEmt].p(); + double pRecEmt = event[iRec].p() * event[iEmt].p(); + double wtW = 2. * pRadRec / (pRadEmt * pRecEmt) - pow2(event[iRad].m() / pRadEmt); + // If recoilDeadCone = on, include W mass term in denominator. + if (recoilDeadCone) + wtW -= pow2(event[iRec].m() / pRecEmt); + + // Numerator: eikonal weight with top as recoiler. + double pRadTop = event[iRad].p() * event[iTop].p(); + double pTopEmt = event[iTop].p() * event[iEmt].p(); + double wtT = + 2. * pRadTop / (pRadEmt * pTopEmt) - pow2(event[iRad].m() / pRadEmt) - pow2(event[iTop].m() / pTopEmt); + + // Histogram weight ratio. + wtCorr->fill(wtT / wtW); + + // List relevant properties. + if (doList) { + partonSystemsPtr->list(); + event.list(); + } + //std::cout << "BEGIN TOP TEST: " << (wtT / wtW) << " | END TOP TEST" << endl; + + // Accept/reject emission. Smooth suppression or step function. + return (wtT < wtW * rndmPtr->flat()); + } + + private: + // Options and Histograms. + bool doTopRecoil, useOldDipole, doList, recoilDeadCone; + Hist* wtCorr; + }; + +} // namespace Pythia8 diff --git a/GeneratorInterface/Pythia8Interface/test/TopRecoilHook_test_cfg.py b/GeneratorInterface/Pythia8Interface/test/TopRecoilHook_test_cfg.py new file mode 100644 index 0000000000000..7f8b07665c20c --- /dev/null +++ b/GeneratorInterface/Pythia8Interface/test/TopRecoilHook_test_cfg.py @@ -0,0 +1,92 @@ +import sys +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +#import pythia8 + +options = VarParsing.VarParsing ('standard') +options.register('runOnly', '', VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "Run only specified analysis") +options.register('yodafile', 'test_toprecoil.yoda', VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "Name of yoda output file") +options.register('recoiltoTop','on',VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "TopRecoilHook setting") +options.register('recoiltoBottom','off',VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "RecoilToColor setting") +options.setDefault('maxEvents', 1000) +options.register('alphaSvalue', 0.1365,VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "AlphaS value setting") +options.register('topmass', 172.5,VarParsing.VarParsing.multiplicity.singleton,VarParsing.VarParsing.varType.string, "Top mass setting") +if(hasattr(sys, "argv")): + options.parseArguments() +print(options) + +process = cms.Process("runRivetAnalysis") + +from Configuration.Generator.Pythia8CommonSettings_cfi import * +from Configuration.Generator.Pythia8CUEP8M1Settings_cfi import * +from Configuration.Generator.Pythia8aMCatNLOSettings_cfi import * +from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper +#randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService) +#randSvc.populate() + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') + +randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService) +randSvc.populate() + +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents)) + +process.source = cms.Source("EmptySource") + +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.generator = cms.EDFilter("Pythia8GeneratorFilter", + comEnergy = cms.double(13000.0), + crossSection = cms.untracked.double(421.1), + filterEfficiency = cms.untracked.double(1), + maxEventsToPrint = cms.untracked.int32(0), + pythiaHepMCVerbosity = cms.untracked.bool(False), + pythiaPylistVerbosity = cms.untracked.int32(1), + PythiaParameters = cms.PSet( + pythia8CommonSettingsBlock, + pythia8CUEP8M1SettingsBlock, + pythia8aMCatNLOSettingsBlock, + processParameters = cms.vstring( + 'Main:timesAllowErrors = 10000', + 'ParticleDecays:limitTau0 = on', + 'ParticleDecays:tauMax = 10', + 'Tune:ee 7', + 'Tune:pp 14', # Monash tune + 'Top:gg2ttbar = on', + 'Top:qqbar2ttbar = on', + '6:m0 = %s'%options.topmass, # top mass' + 'TopRecoilHook:doTopRecoilIn = %s'%options.recoiltoTop, + 'TimeShower:recoilToColoured = %s'%options.recoiltoBottom, + 'TimeShower:alphaSvalue = %s' %options.alphaSvalue + ), + parameterSets = cms.vstring('processParameters',) + ) +) + +process.load("GeneratorInterface.RivetInterface.rivetAnalyzer_cfi") + +#pythia.Settings.listAll() + +if options.runOnly: + process.rivetAnalyzer.AnalysisNames = cms.vstring(options.runOnly) +else: + process.rivetAnalyzer.AnalysisNames = cms.vstring( + 'CMS_2018_I1663958', # diff xs lepton+jets + 'CMS_2018_I1662081', # event variables lepton+jets + 'MC_TOPMASS_LJETS', # MC analysis for lepton+jets top mass + 'CMS_2018_I1690148', # jet substructure + 'MC_BFRAG_LJETS', # b fragmentation + 'CMS_2018_I1703993', # diff xs dilepton + 'CMS_2019_I1764472', #boosted top mass + 'MC_TOPMASS_LSMT', #dilepton invariant mass, soft muon +primary + 'ATLAS_2019_I1724098', #missing momentum analysis + ) +process.rivetAnalyzer.OutputFile = options.yodafile +process.rivetAnalyzer.HepMCCollection = cms.InputTag("generator:unsmeared") +process.rivetAnalyzer.CrossSection = 831.76 # NNLO (arXiv:1303.6254) + +process.p = cms.Path(process.generator*process.rivetAnalyzer) + + From 34fa8190194125d3c1816d59d1a274163f8df9e1 Mon Sep 17 00:00:00 2001 From: Valdis Slokenbergs Date: Fri, 21 Jul 2023 16:32:32 +0200 Subject: [PATCH 2/9] Rest of backport to 13_2 --- .../plugins/Pythia8Hadronizer.cc | 46 +++++++++---------- .../Pythia8Interface/src/Py8InterfaceBase.cc | 5 ++ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc index fbeca29a6c45e..a810aa7b36170 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc +++ b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc @@ -19,6 +19,7 @@ using namespace Pythia8; #include "GeneratorInterface/Pythia8Interface/plugins/ReweightUserHooks.h" #include "GeneratorInterface/Pythia8Interface/interface/CustomHook.h" +#include "GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h" // PS matchning prototype // @@ -29,7 +30,6 @@ using namespace Pythia8; // Emission Veto Hooks // #include "Pythia8Plugins/PowhegHooks.h" -#include "Pythia8Plugins/PowhegHooksVincia.h" #include "GeneratorInterface/Pythia8Interface/plugins/EmissionVetoHook1.h" // Resonance scale hook @@ -133,7 +133,6 @@ class Pythia8Hadronizer : public Py8InterfaceBase { // Emission Veto Hooks // std::shared_ptr fEmissionVetoHook; - std::shared_ptr fEmissionVetoHookVincia; std::shared_ptr fEmissionVetoHook1; // Resonance scale hook @@ -152,6 +151,9 @@ class Pythia8Hadronizer : public Py8InterfaceBase { //Generic customized hooks vector std::shared_ptr fCustomHooksVector; + //RecoilToTop userhook + std::shared_ptr fTopRecoilHook; + int EV1_nFinal; bool EV1_vetoOn; int EV1_maxVetoCount; @@ -386,10 +388,7 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook1); } - bool VinciaShower = fMasterGen->settings.mode("PartonShowers:Model") == 2; - - if ((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && - !VinciaShower) { + if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) { if (fJetMatchingHook.get() || fEmissionVetoHook1.get()) throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible " @@ -402,13 +401,6 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook); } - if (fMasterGen->settings.mode("POWHEG:veto") > 0 && VinciaShower) { - edm::LogInfo("Pythia8Interface") << "Turning on Vincia Emission Veto Hook from pythia8 code"; - if (!fEmissionVetoHookVincia.get()) - fEmissionVetoHookVincia.reset(new PowhegHooksVincia()); - (fUserHooksVector->hooks).push_back(fEmissionVetoHookVincia); - } - bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales"); if (PowhegRes) { edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface"; @@ -425,6 +417,14 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { (fUserHooksVector->hooks).push_back(fPowhegHooksBB4L); } + bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn"); + if (TopRecoilHook1) { + edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface"; + if (!fTopRecoilHook.get()) + fTopRecoilHook.reset(new TopRecoilHook()); + (fUserHooksVector->hooks).push_back(fTopRecoilHook); + } + //adapted from main89.cc in pythia8 examples bool internalMatching = fMasterGen->settings.flag("JetMatching:merge"); bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void"); @@ -555,10 +555,7 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { } } - bool VinciaShower = fMasterGen->settings.mode("PartonShowers:Model") == 2; - - if ((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && - !VinciaShower) { + if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) { if (fJetMatchingHook.get() || fEmissionVetoHook1.get()) throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible " @@ -571,13 +568,6 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook); } - if (fMasterGen->settings.mode("POWHEG:veto") > 0 && VinciaShower) { - edm::LogInfo("Pythia8Interface") << "Turning on Vincia Emission Veto Hook from pythia8 code"; - if (!fEmissionVetoHookVincia.get()) - fEmissionVetoHookVincia.reset(new PowhegHooksVincia()); - (fUserHooksVector->hooks).push_back(fEmissionVetoHookVincia); - } - bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales"); if (PowhegRes) { edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface"; @@ -594,6 +584,14 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { (fUserHooksVector->hooks).push_back(fPowhegHooksBB4L); } + bool TopRecoilHook1 = fMasterGen->settings.flag("TopRecoilHook:doTopRecoilIn"); + if (TopRecoilHook1) { + edm::LogInfo("Pythia8Interface") << "Turning on RecoilToTop hook from Pythia8Interface"; + if (!fTopRecoilHook.get()) + fTopRecoilHook.reset(new TopRecoilHook()); + (fUserHooksVector->hooks).push_back(fTopRecoilHook); + } + //adapted from main89.cc in pythia8 examples bool internalMatching = fMasterGen->settings.flag("JetMatching:merge"); bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void"); diff --git a/GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc b/GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc index 35a271c548e7b..99f8ec98dfcd1 100644 --- a/GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc +++ b/GeneratorInterface/Pythia8Interface/src/Py8InterfaceBase.cc @@ -104,6 +104,11 @@ namespace gen { fMasterGen->settings.addParm("PTFilter:quarkRapidity", 10.0, true, true, 0.0, 10.); fMasterGen->settings.addParm("PTFilter:quarkPt", -.1, true, true, -.1, 100.); + //add settings for RecoilToTop tool + fMasterGen->settings.addFlag("TopRecoilHook:doTopRecoilIn", false); + fMasterGen->settings.addFlag("TopRecoilHook:useOldDipoleIn", false); + fMasterGen->settings.addFlag("TopRecoilHook:doListIn", false); + //add settings for powheg resonance scale calculation fMasterGen->settings.addFlag("POWHEGres:calcScales", false); fMasterGen->settings.addFlag("POWHEG:bb4l", false); From f4e5c6c32bfb7cf287c90726888e4cc838961404 Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Thu, 27 Jul 2023 15:21:30 +0200 Subject: [PATCH 3/9] Update TopRecoilHook.h Fix suggested by PR 42313. Removes useless check. --- GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h index c07c84ef9e4c9..309089939325c 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -33,11 +33,7 @@ namespace Pythia8 { } // Destructor prints histogram. - ~TopRecoilHook() override { - if (doTopRecoil) - ; - delete wtCorr; - } + ~TopRecoilHook() override { delete wtCorr; } // Initialise. Only use hook for simple showers with recoilToColoured = off. bool initAfterBeams() override { From d1c3b31c1f0bef557afcd412a1d17f93746bd5fd Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:40:03 +0200 Subject: [PATCH 4/9] Update GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h Co-authored-by: Andrea Perrotta --- GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h | 1 - 1 file changed, 1 deletion(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h index 309089939325c..2518abeea025e 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -117,7 +117,6 @@ namespace Pythia8 { partonSystemsPtr->list(); event.list(); } - //std::cout << "BEGIN TOP TEST: " << (wtT / wtW) << " | END TOP TEST" << endl; // Accept/reject emission. Smooth suppression or step function. return (wtT < wtW * rndmPtr->flat()); From 81dde92486885f44f184837655d7740fa27ae199 Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:40:26 +0200 Subject: [PATCH 5/9] Update GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h Co-authored-by: Andrea Perrotta --- GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h index 2518abeea025e..0da9fc895ac95 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -33,7 +33,7 @@ namespace Pythia8 { } // Destructor prints histogram. - ~TopRecoilHook() override { delete wtCorr; } + ~TopRecoilHook() override { delete wtCorr; } // Initialise. Only use hook for simple showers with recoilToColoured = off. bool initAfterBeams() override { From 3d398a730e5835eaead18d054ce692ed343268ae Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:48:17 -0400 Subject: [PATCH 6/9] Restore extra backport changes PowhegHooksVincia removed because of potential error with PR #42020, however this commit exactly copies the file from the 13_1 backport. Hopefully this remedies the issue --- .../plugins/Pythia8Hadronizer.cc | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc index a810aa7b36170..18181e47303e7 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc +++ b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc @@ -30,6 +30,7 @@ using namespace Pythia8; // Emission Veto Hooks // #include "Pythia8Plugins/PowhegHooks.h" +#include "Pythia8Plugins/PowhegHooksVincia.h" #include "GeneratorInterface/Pythia8Interface/plugins/EmissionVetoHook1.h" // Resonance scale hook @@ -133,6 +134,7 @@ class Pythia8Hadronizer : public Py8InterfaceBase { // Emission Veto Hooks // std::shared_ptr fEmissionVetoHook; + std::shared_ptr fEmissionVetoHookVincia; std::shared_ptr fEmissionVetoHook1; // Resonance scale hook @@ -388,7 +390,10 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook1); } - if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) { + bool VinciaShower = fMasterGen->settings.mode("PartonShowers:Model") == 2; + + if ((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && + !VinciaShower) { if (fJetMatchingHook.get() || fEmissionVetoHook1.get()) throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible " @@ -401,6 +406,13 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook); } + if (fMasterGen->settings.mode("POWHEG:veto") > 0 && VinciaShower) { + edm::LogInfo("Pythia8Interface") << "Turning on Vincia Emission Veto Hook from pythia8 code"; + if (!fEmissionVetoHookVincia.get()) + fEmissionVetoHookVincia.reset(new PowhegHooksVincia()); + (fUserHooksVector->hooks).push_back(fEmissionVetoHookVincia); + } + bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales"); if (PowhegRes) { edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface"; @@ -555,7 +567,10 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { } } - if (fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) { + bool VinciaShower = fMasterGen->settings.mode("PartonShowers:Model") == 2; + + if ((fMasterGen->settings.mode("POWHEG:veto") > 0 || fMasterGen->settings.mode("POWHEG:MPIveto") > 0) && + !VinciaShower) { if (fJetMatchingHook.get() || fEmissionVetoHook1.get()) throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") << " Attempt to turn on PowhegHooks by pythia8 settings but there are incompatible hooks on \n Incompatible " @@ -568,6 +583,13 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { (fUserHooksVector->hooks).push_back(fEmissionVetoHook); } + if (fMasterGen->settings.mode("POWHEG:veto") > 0 && VinciaShower) { + edm::LogInfo("Pythia8Interface") << "Turning on Vincia Emission Veto Hook from pythia8 code"; + if (!fEmissionVetoHookVincia.get()) + fEmissionVetoHookVincia.reset(new PowhegHooksVincia()); + (fUserHooksVector->hooks).push_back(fEmissionVetoHookVincia); + } + bool PowhegRes = fMasterGen->settings.flag("POWHEGres:calcScales"); if (PowhegRes) { edm::LogInfo("Pythia8Interface") << "Turning on resonance scale setting from CMSSW Pythia8Interface"; @@ -591,7 +613,6 @@ bool Pythia8Hadronizer::initializeForExternalPartons() { fTopRecoilHook.reset(new TopRecoilHook()); (fUserHooksVector->hooks).push_back(fTopRecoilHook); } - //adapted from main89.cc in pythia8 examples bool internalMatching = fMasterGen->settings.flag("JetMatching:merge"); bool internalMerging = !(fMasterGen->settings.word("Merging:Process") == "void"); From 80979230303cedc3e6b2ccda483e28a8e1cc9516 Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:41:16 -0400 Subject: [PATCH 7/9] Update Pythia8Hadronizer.cc --- .../Pythia8Interface/plugins/Pythia8Hadronizer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc index 18181e47303e7..5412d0bf6fe64 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc +++ b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc @@ -17,9 +17,9 @@ using namespace Pythia8; #include "GeneratorInterface/Pythia8Interface/interface/Py8InterfaceBase.h" -#include "GeneratorInterface/Pythia8Interface/plugins/ReweightUserHooks.h" +#include "ReweightUserHooks.h" #include "GeneratorInterface/Pythia8Interface/interface/CustomHook.h" -#include "GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h" +#include "TopRecoilHook.h" // PS matchning prototype // From cce687939364d682045095b1214e70774b7bdb91 Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:49:15 -0400 Subject: [PATCH 8/9] Update TopRecoilHook.h --- GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h index 0da9fc895ac95..5773710f2862f 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -33,7 +33,11 @@ namespace Pythia8 { } // Destructor prints histogram. - ~TopRecoilHook() override { delete wtCorr; } + ~TopRecoilHook() override { + if (doTopRecoil) + ; + delete wtCorr; + } // Initialise. Only use hook for simple showers with recoilToColoured = off. bool initAfterBeams() override { From a4bc408195600abf211c9681eb76b30a72ebe64a Mon Sep 17 00:00:00 2001 From: vslokenb <108902248+vslokenb@users.noreply.github.com> Date: Fri, 13 Oct 2023 18:00:38 -0400 Subject: [PATCH 9/9] Update GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h Co-authored-by: Andrea Perrotta --- GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h index 5773710f2862f..0da9fc895ac95 100644 --- a/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h +++ b/GeneratorInterface/Pythia8Interface/plugins/TopRecoilHook.h @@ -33,11 +33,7 @@ namespace Pythia8 { } // Destructor prints histogram. - ~TopRecoilHook() override { - if (doTopRecoil) - ; - delete wtCorr; - } + ~TopRecoilHook() override { delete wtCorr; } // Initialise. Only use hook for simple showers with recoilToColoured = off. bool initAfterBeams() override {