Skip to content

Commit

Permalink
Merge pull request #44549 from hjbossi/confiPythiaPhotonFlux
Browse files Browse the repository at this point in the history
Make PYTHIA 8 photon flux more configurable.
  • Loading branch information
cmsbuild authored Apr 15, 2024
2 parents c1c8916 + 5455ef6 commit 9abdd79
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 72 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)
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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),
PhotonFlux = PhotonFlux_PbPb,
PythiaParameters = cms.PSet(
parameterSets = cms.vstring('pythia8_example02'),
pythia8_example02 = cms.vstring(
Expand Down
53 changes: 35 additions & 18 deletions GeneratorInterface/Pythia8Interface/plugins/Pythia8Hadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,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 @@ -152,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 Down Expand Up @@ -224,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 @@ -260,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 @@ -412,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 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 9abdd79

Please sign in to comment.