@@ -76,6 +76,49 @@ namespace CLHEP {
7676
7777using namespace gen ;
7878
79+ // Insert class for use w/ PDFPtr for proton-photon flux
80+ // parameters hardcoded according to main70.cc in PYTHIA8 v3.10
81+ class Nucleus2gamma2 : public Pythia8 ::PDF {
82+ private:
83+ double radius;
84+ int z;
85+
86+ public:
87+ // Constructor.
88+ Nucleus2gamma2 (int idBeamIn, double R = -1.0 , int Z = -1 ) : Pythia8::PDF(idBeamIn), radius(R), z(Z) {}
89+
90+ void xfUpdate (int , double x, double ) override {
91+ if (z == -1 ) {
92+ // lead
93+ if (idBeam == 1000822080 )
94+ z = 82 ;
95+ }
96+ if (radius == -1 ) {
97+ // lead
98+ if (idBeam == 1000822080 )
99+ radius = 6.636 ;
100+ }
101+
102+ if (z < 0 || radius < 0 )
103+ throw edm::Exception (edm::errors::Configuration, " Pythia8Interface" )
104+ << " Invalid photon flux input parameters: beam ID= " << idBeam << " , radius= " << radius << " , z= " << z
105+ << " \n " ;
106+
107+ // Minimum impact parameter (~2*radius) [fm].
108+ double bmin = 2 * radius;
109+
110+ // Per-nucleon mass for lead.
111+ double m2 = pow2 (0.9314 );
112+ double alphaEM = 0.007297353080 ;
113+ double hbarc = 0.197 ;
114+ double xi = x * sqrt (m2) * bmin / hbarc;
115+ double bK0 = besselK0 (xi);
116+ double bK1 = besselK1 (xi);
117+ double intB = xi * bK1 * bK0 - 0.5 * pow2 (xi) * (pow2 (bK1) - pow2 (bK0));
118+ xgamma = 2 . * alphaEM * pow2 (z) / M_PI * intB;
119+ }
120+ };
121+
79122class Pythia8HepMC3Hadronizer : public Py8HMC3InterfaceBase {
80123public:
81124 Pythia8HepMC3Hadronizer (const edm::ParameterSet ¶ms);
@@ -113,6 +156,10 @@ class Pythia8HepMC3Hadronizer : public Py8HMC3InterfaceBase {
113156 double fBeam1PZ ;
114157 double fBeam2PZ ;
115158
159+ // PDFPtr for the photonFlux
160+ // Following main70.cc example in PYTHIA8 v3.10
161+ edm::ParameterSet photonFluxParams;
162+
116163 // helper class to allow multiple user hooks simultaneously
117164 std::shared_ptr<UserHooksVector> fUserHooksVector ;
118165 bool UserHooksSet;
@@ -217,6 +264,10 @@ Pythia8HepMC3Hadronizer::Pythia8HepMC3Hadronizer(const edm::ParameterSet ¶ms
217264 // avoid filling weights twice (from v8.30x)
218265 toHepMC.set_store_weights (false );
219266
267+ if (params.exists (" PhotonFlux" )) {
268+ photonFluxParams = params.getParameter <edm::ParameterSet>(" PhotonFlux" );
269+ }
270+
220271 // Reweight user hook
221272 //
222273 if (params.exists (" reweightGen" )) {
@@ -368,6 +419,20 @@ bool Pythia8HepMC3Hadronizer::initializeForInternalPartons() {
368419 fMasterGen ->settings .word (" Beams:LHEF" , lheFile_);
369420 }
370421
422+ if (!photonFluxParams.empty ()) {
423+ const auto &beamTypeA = photonFluxParams.getParameter <int >(" beamTypeA" );
424+ const auto &beamTypeB = photonFluxParams.getParameter <int >(" beamTypeB" );
425+ const auto &radiusA = photonFluxParams.getUntrackedParameter <double >(" radiusA" , -1.0 );
426+ const auto &radiusB = photonFluxParams.getUntrackedParameter <double >(" radiusB" , -1.0 );
427+ const auto &zA = photonFluxParams.getUntrackedParameter <int >(" zA" , -1 );
428+ const auto &zB = photonFluxParams.getUntrackedParameter <int >(" zB" , -1 );
429+ Pythia8::PDFPtr photonFluxA =
430+ fMasterGen ->settings .flag (" PDF:beamA2gamma" ) ? make_shared<Nucleus2gamma2>(beamTypeA, radiusA, zA) : nullptr ;
431+ Pythia8::PDFPtr photonFluxB =
432+ fMasterGen ->settings .flag (" PDF:beamB2gamma" ) ? make_shared<Nucleus2gamma2>(beamTypeB, radiusB, zB) : nullptr ;
433+ fMasterGen ->setPhotonFluxPtr (photonFluxA, photonFluxB);
434+ }
435+
371436 if (!fUserHooksVector .get ())
372437 fUserHooksVector = std::make_shared<UserHooksVector>();
373438 (fUserHooksVector ->hooks ).clear ();
0 commit comments