From 4dc5e758ff8737e2b3ec170378ae33478005c254 Mon Sep 17 00:00:00 2001 From: Hannah Date: Tue, 16 Jul 2024 09:45:22 +0200 Subject: [PATCH] Make Pythia8 Photon Flux more configurable. --- .../python/Pythia8PhotonFluxSettings_cfi.py | 32 +++++++ .../Pythia8_GammaNucleus_5p36TeV_cfi.py | 28 +++++++ .../plugins/Pythia8Hadronizer.cc | 84 +++++++++---------- .../test/pythia8ex2_ConvertToMain70_cfg.py | 31 +------ ...pythia8ex2_ConvertToMain70_cfg_Fragment.py | 28 +------ 5 files changed, 106 insertions(+), 97 deletions(-) create mode 100644 Configuration/Generator/python/Pythia8PhotonFluxSettings_cfi.py create mode 100644 Configuration/Generator/python/Pythia8_GammaNucleus_5p36TeV_cfi.py diff --git a/Configuration/Generator/python/Pythia8PhotonFluxSettings_cfi.py b/Configuration/Generator/python/Pythia8PhotonFluxSettings_cfi.py new file mode 100644 index 0000000000000..aafbe40ea2294 --- /dev/null +++ b/Configuration/Generator/python/Pythia8PhotonFluxSettings_cfi.py @@ -0,0 +1,32 @@ +import FWCore.ParameterSet.Config as cms + +# configuration for photon flux in PbPb +PhotonFlux_PbPb = cms.PSet( + beamTypeA = cms.int32(1000822080), + beamTypeB = cms.int32(1000822080), + radiusA = cms.untracked.double(6.636), + radiusB = cms.untracked.double(6.636), + zA = cms.untracked.int32(82), + zB = cms.untracked.int32(82) +) + +# configuration for photon flux in OO +PhotonFlux_OO = cms.PSet( + beamTypeA = cms.int32(80160), + beamTypeB = cms.int32(80160), + radiusA = cms.untracked.double(3.02), + radiusB = cms.untracked.double(3.02), + zA = cms.untracked.int32(8), + zB = cms.untracked.int32(8) +) + +# configuration for photon flux in XeXe +# radius from charged particle raa: https://arxiv.org/pdf/1809.00201.pdf +PhotonFlux_XeXe = cms.PSet( + beamTypeA = cms.int32(5418), + beamTypeB = cms.int32(5418), + radiusA = cms.untracked.double(5.4), + radiusB = cms.untracked.double(5.4), + zA = cms.untracked.int32(54), + zB = cms.untracked.int32(54) +) diff --git a/Configuration/Generator/python/Pythia8_GammaNucleus_5p36TeV_cfi.py b/Configuration/Generator/python/Pythia8_GammaNucleus_5p36TeV_cfi.py new file mode 100644 index 0000000000000..f03ac636f4d8a --- /dev/null +++ b/Configuration/Generator/python/Pythia8_GammaNucleus_5p36TeV_cfi.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.Generator.Pythia8PhotonFluxSettings_cfi import PhotonFlux_PbPb + +generator = cms.EDFilter("Pythia8GeneratorFilter", + maxEventsToPrint = cms.untracked.int32(1), + pythiaPylistVerbosity = cms.untracked.int32(1), + filterEfficiency = cms.untracked.double(1.0), + pythiaHepMCVerbosity = cms.untracked.bool(False), + comEnergy = cms.double(5360.), + PhotonFlux = PhotonFlux_PbPb, + PythiaParameters = cms.PSet( + parameterSets = cms.vstring('pythia8_example02'), + pythia8_example02 = cms.vstring( + 'HardQCD:all = on', + 'PhaseSpace:pTHatMin = 10.', + 'PhotonParton:all = on', + 'MultipartonInteractions:pT0Ref = 3.0', + 'PDF:beamA2gamma = on', + 'PDF:proton2gammaSet = 0', + 'PDF:useHardNPDFB = on', + 'PDF:gammaFluxApprox2bMin = 13.272', + 'PDF:beam2gammaApprox = 2', + 'Photon:sampleQ2 = off', + 'Photon:ProcessType = 3' + ) + ) +) +ProductionFilterSequence = cms.Sequence(generator) diff --git a/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc b/GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc index 8ab327e596292..e160077a06ef2 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 // @@ -30,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 @@ -80,25 +79,31 @@ using namespace gen; //Insert class for use w/ PDFPtr for proton-photon flux //parameters hardcoded according to main70.cc in PYTHIA8 v3.10 class Nucleus2gamma2 : public Pythia8::PDF { +private: + double radius; + int z; + public: // Constructor. - Nucleus2gamma2(int idBeamIn) : Pythia8::PDF(idBeamIn) {} + Nucleus2gamma2(int idBeamIn, double R = -1.0, int Z = -1) : Pythia8::PDF(idBeamIn), radius(R), z(Z) {} - // Update the photon flux. void xfUpdate(int, double x, double) override { - // lead - double radius = 0; // radius in [fm] - double z = 0; - if (idBeam == 1000822080) { - radius = 6.636; - z = 82; + if (z == -1) { + // lead + if (idBeam == 1000822080) + z = 82; } - // oxygen - else if (idBeam == 80160) { - radius = 3.02; - z = 8; + if (radius == -1) { + // lead + if (idBeam == 1000822080) + radius = 6.636; } + if (z < 0 || radius < 0) + throw edm::Exception(edm::errors::Configuration, "Pythia8Interface") + << " Invalid photon flux input parameters: beam ID= " << idBeam << " , radius= " << radius << " , z= " << z + << "\n"; + // Minimum impact parameter (~2*radius) [fm]. double bmin = 2 * radius; @@ -153,8 +158,7 @@ class Pythia8Hadronizer : public Py8InterfaceBase { //PDFPtr for the photonFlux //Following main70.cc example in PYTHIA8 v3.10 - bool doProtonPhotonFlux = false; - Pythia8::PDFPtr photonFlux = nullptr; + edm::ParameterSet photonFluxParams; //helper class to allow multiple user hooks simultaneously std::shared_ptr fUserHooksVector; @@ -176,7 +180,6 @@ class Pythia8Hadronizer : public Py8InterfaceBase { // Emission Veto Hooks // std::shared_ptr fEmissionVetoHook; - std::shared_ptr fEmissionVetoHookVincia; std::shared_ptr fEmissionVetoHook1; // Resonance scale hook @@ -226,7 +229,6 @@ Pythia8Hadronizer::Pythia8Hadronizer(const edm::ParameterSet ¶ms) comEnergy(params.getParameter("comEnergy")), LHEInputFileName(params.getUntrackedParameter("LHEInputFileName", "")), fInitialState(PP), - doProtonPhotonFlux(params.getUntrackedParameter("doProtonPhotonFlux", false)), UserHooksSet(false), nME(-1), nMEFiltered(-1), @@ -262,6 +264,10 @@ Pythia8Hadronizer::Pythia8Hadronizer(const edm::ParameterSet ¶ms) // avoid filling weights twice (from v8.30x) toHepMC.set_store_weights(false); + if (params.exists("PhotonFlux")) { + photonFluxParams = params.getParameter("PhotonFlux"); + } + // Reweight user hook // if (params.exists("reweightGen")) { @@ -414,9 +420,18 @@ bool Pythia8Hadronizer::initializeForInternalPartons() { fMasterGen->settings.word("Beams:LHEF", lheFile_); } - if (doProtonPhotonFlux) { - photonFlux = make_shared(1000822080); - fMasterGen->setPhotonFluxPtr(photonFlux, nullptr); + if (!photonFluxParams.empty()) { + const auto &beamTypeA = photonFluxParams.getParameter("beamTypeA"); + const auto &beamTypeB = photonFluxParams.getParameter("beamTypeB"); + const auto &radiusA = photonFluxParams.getUntrackedParameter("radiusA", -1.0); + const auto &radiusB = photonFluxParams.getUntrackedParameter("radiusB", -1.0); + const auto &zA = photonFluxParams.getUntrackedParameter("zA", -1); + const auto &zB = photonFluxParams.getUntrackedParameter("zB", -1); + Pythia8::PDFPtr photonFluxA = + fMasterGen->settings.flag("PDF:beamA2gamma") ? make_shared(beamTypeA, radiusA, zA) : nullptr; + Pythia8::PDFPtr photonFluxB = + fMasterGen->settings.flag("PDF:beamB2gamma") ? make_shared(beamTypeB, radiusB, zB) : nullptr; + fMasterGen->setPhotonFluxPtr(photonFluxA, photonFluxB); } if (!fUserHooksVector.get()) @@ -438,10 +453,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 " @@ -454,13 +466,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"; @@ -615,10 +620,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 " @@ -631,13 +633,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"; @@ -661,6 +656,7 @@ 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"); diff --git a/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg.py b/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg.py index 579672d942cc2..99b12b5a86d2a 100644 --- a/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg.py +++ b/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg.py @@ -1,4 +1,5 @@ import FWCore.ParameterSet.Config as cms +from Configuration.Generator.Pythia8PhotonFluxSettings_cfi import PhotonFlux_PbPb process = cms.Process("PROD") @@ -12,36 +13,13 @@ filterEfficiency = cms.untracked.double(1.0), pythiaHepMCVerbosity = cms.untracked.bool(False), comEnergy = cms.double(5360.), - doProtonPhotonFlux = cms.untracked.bool(True), - #PPbarInitialState = cms.PSet(), - #SLHAFileForPythia8 = cms.string('Configuration/Generator/data/CSA07SUSYBSM_LM9p_sftsdkpyt_slha.out'), - #reweightGen = cms.PSet( # flat in pT - # pTRef = cms.double(15.0), - # power = cms.double(4.5) - #), - #reweightGenRap = cms.PSet( # flat in eta - # yLabSigmaFunc = cms.string("15.44/pow(x,0.0253)-12.56"), - # yLabPower = cms.double(2.), - # yCMSigmaFunc = cms.string("5.45/pow(x+64.84,0.34)"), - # yCMPower = cms.double(2.), - # pTHatMin = cms.double(15.), - # pTHatMax = cms.double(3000.) - #), - #reweightGenPtHatRap = cms.PSet( # flat in Pt and eta - # yLabSigmaFunc = cms.string("15.44/pow(x,0.0253)-12.56"), - # yLabPower = cms.double(2.), - # yCMSigmaFunc = cms.string("5.45/pow(x+64.84,0.34)"), - # yCMPower = cms.double(2.), - # pTHatMin = cms.double(15.), - # pTHatMax = cms.double(3000.) - #), + PhotonFlux = PhotonFlux_PbPb, PythiaParameters = cms.PSet( pythia8_example02 = cms.vstring('HardQCD:all = on', - 'PhaseSpace:pTHatMin = 10.',#CM Edit 20->10 + 'PhaseSpace:pTHatMin = 10.', 'PhotonParton:all = on',#Added from main70 'MultipartonInteractions:pT0Ref = 3.0',#Added from main70 'PDF:beamA2gamma = on',#Added from main70 - #This option below crashes - debug 'PDF:proton2gammaSet = 0',#Added from main70 'PDF:useHardNPDFB = on', 'PDF:gammaFluxApprox2bMin = 13.272', @@ -52,9 +30,6 @@ ) ) -# in order to use lhapdf PDF add a line like this to pythia8_example02: -# 'PDF:pSet = LHAPDF6:CT10' - process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger = cms.Service("MessageLogger", cerr = cms.untracked.PSet( diff --git a/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg_Fragment.py b/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg_Fragment.py index 98d9c6105bdb7..b23f83e03bcfb 100644 --- a/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg_Fragment.py +++ b/GeneratorInterface/Pythia8Interface/test/pythia8ex2_ConvertToMain70_cfg_Fragment.py @@ -1,4 +1,5 @@ import FWCore.ParameterSet.Config as cms +from Configuration.Generator.Pythia8PhotonFluxSettings_cfi import PhotonFlux_PbPb _generator = cms.EDFilter("Pythia8GeneratorFilter", maxEventsToPrint = cms.untracked.int32(1), @@ -6,36 +7,13 @@ filterEfficiency = cms.untracked.double(1.0), pythiaHepMCVerbosity = cms.untracked.bool(False), comEnergy = cms.double(5360.), - doProtonPhotonFlux = cms.untracked.bool(True), - #PPbarInitialState = cms.PSet(), - #SLHAFileForPythia8 = cms.string('Configuration/Generator/data/CSA07SUSYBSM_LM9p_sftsdkpyt_slha.out'), - #reweightGen = cms.PSet( # flat in pT - # pTRef = cms.double(15.0), - # power = cms.double(4.5) - #), - #reweightGenRap = cms.PSet( # flat in eta - # yLabSigmaFunc = cms.string("15.44/pow(x,0.0253)-12.56"), - # yLabPower = cms.double(2.), - # yCMSigmaFunc = cms.string("5.45/pow(x+64.84,0.34)"), - # yCMPower = cms.double(2.), - # pTHatMin = cms.double(15.), - # pTHatMax = cms.double(3000.) - #), - #reweightGenPtHatRap = cms.PSet( # flat in Pt and eta - # yLabSigmaFunc = cms.string("15.44/pow(x,0.0253)-12.56"), - # yLabPower = cms.double(2.), - # yCMSigmaFunc = cms.string("5.45/pow(x+64.84,0.34)"), - # yCMPower = cms.double(2.), - # pTHatMin = cms.double(15.), - # pTHatMax = cms.double(3000.) - #), + PhotonFlux = PhotonFlux_PbPb, PythiaParameters = cms.PSet( pythia8_example02 = cms.vstring('HardQCD:all = on', - 'PhaseSpace:pTHatMin = 10.',#CM Edit 20->10 + 'PhaseSpace:pTHatMin = 10.', 'PhotonParton:all = on',#Added from main70 'MultipartonInteractions:pT0Ref = 3.0',#Added from main70 'PDF:beamA2gamma = on',#Added from main70 - #This option below crashes - debug 'PDF:proton2gammaSet = 0',#Added from main70 'PDF:useHardNPDFB = on', 'PDF:gammaFluxApprox2bMin = 13.272',