Skip to content

Commit

Permalink
Merge pull request #45468 from hjbossi/main/CMSSW_13_0_HeavyIon_X
Browse files Browse the repository at this point in the history
Make Pythia8 Photon Flux more configurable.
  • Loading branch information
cmsbuild authored Jul 18, 2024
2 parents e539398 + 4dc5e75 commit 61ff178
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 97 deletions.
32 changes: 32 additions & 0 deletions Configuration/Generator/python/Pythia8PhotonFluxSettings_cfi.py
Original file line number Diff line number Diff line change
@@ -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)
)
28 changes: 28 additions & 0 deletions Configuration/Generator/python/Pythia8_GammaNucleus_5p36TeV_cfi.py
Original file line number Diff line number Diff line change
@@ -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)
84 changes: 40 additions & 44 deletions GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<UserHooksVector> fUserHooksVector;
Expand All @@ -176,7 +180,6 @@ class Pythia8Hadronizer : public Py8InterfaceBase {
// Emission Veto Hooks
//
std::shared_ptr<PowhegHooks> fEmissionVetoHook;
std::shared_ptr<PowhegHooksVincia> fEmissionVetoHookVincia;
std::shared_ptr<EmissionVetoHook1> fEmissionVetoHook1;

// Resonance scale hook
Expand Down Expand Up @@ -226,7 +229,6 @@ Pythia8Hadronizer::Pythia8Hadronizer(const edm::ParameterSet &params)
comEnergy(params.getParameter<double>("comEnergy")),
LHEInputFileName(params.getUntrackedParameter<std::string>("LHEInputFileName", "")),
fInitialState(PP),
doProtonPhotonFlux(params.getUntrackedParameter<bool>("doProtonPhotonFlux", false)),
UserHooksSet(false),
nME(-1),
nMEFiltered(-1),
Expand Down Expand Up @@ -262,6 +264,10 @@ Pythia8Hadronizer::Pythia8Hadronizer(const edm::ParameterSet &params)
// avoid filling weights twice (from v8.30x)
toHepMC.set_store_weights(false);

if (params.exists("PhotonFlux")) {
photonFluxParams = params.getParameter<edm::ParameterSet>("PhotonFlux");
}

// Reweight user hook
//
if (params.exists("reweightGen")) {
Expand Down Expand Up @@ -414,9 +420,18 @@ bool Pythia8Hadronizer::initializeForInternalPartons() {
fMasterGen->settings.word("Beams:LHEF", lheFile_);
}

if (doProtonPhotonFlux) {
photonFlux = make_shared<Nucleus2gamma2>(1000822080);
fMasterGen->setPhotonFluxPtr(photonFlux, nullptr);
if (!photonFluxParams.empty()) {
const auto &beamTypeA = photonFluxParams.getParameter<int>("beamTypeA");
const auto &beamTypeB = photonFluxParams.getParameter<int>("beamTypeB");
const auto &radiusA = photonFluxParams.getUntrackedParameter<double>("radiusA", -1.0);
const auto &radiusB = photonFluxParams.getUntrackedParameter<double>("radiusB", -1.0);
const auto &zA = photonFluxParams.getUntrackedParameter<int>("zA", -1);
const auto &zB = photonFluxParams.getUntrackedParameter<int>("zB", -1);
Pythia8::PDFPtr photonFluxA =
fMasterGen->settings.flag("PDF:beamA2gamma") ? make_shared<Nucleus2gamma2>(beamTypeA, radiusA, zA) : nullptr;
Pythia8::PDFPtr photonFluxB =
fMasterGen->settings.flag("PDF:beamB2gamma") ? make_shared<Nucleus2gamma2>(beamTypeB, radiusB, zB) : nullptr;
fMasterGen->setPhotonFluxPtr(photonFluxA, photonFluxB);
}

if (!fUserHooksVector.get())
Expand All @@ -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 "
Expand All @@ -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";
Expand Down Expand Up @@ -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 "
Expand All @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Generator.Pythia8PhotonFluxSettings_cfi import PhotonFlux_PbPb

process = cms.Process("PROD")

Expand All @@ -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',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
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.),
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',
Expand Down

0 comments on commit 61ff178

Please sign in to comment.