13 #include <boost/algorithm/string/classification.hpp>
14 #include <boost/algorithm/string/split.hpp>
16 #include <HepMC/GenEvent.h>
17 #include <HepMC/GenParticle.h>
18 #include <HepMC/GenVertex.h>
19 #include <HepMC/PdfInfo.h>
20 #include <HepMC/HerwigWrapper.h>
21 #include <HepMC/HEPEVT_Wrapper.h>
22 #include <HepMC/IO_HERWIG.h>
23 #include "HepPID/ParticleIDTranslations.hh"
45 void hwuidt_(
int *iopt,
int *ipdg,
int *iwig,
char nwig[8]);
50 inline bool call_hwmsct() {
56 int pdgToHerwig(
int ipdg,
char *nwig) {
59 hwuidt_(&iopt, &ipdg, &iwig, nwig);
60 return ipdg ? iwig : 0;
63 bool markStable(
int pdgId) {
65 if (!pdgToHerwig(pdgId, nwig))
72 #define qcd_1994 qcd_1994_
74 void qcd_1994(
double &,
double &,
double *,
int &);
77 #define qcd_2006 qcd_2006_
79 void qcd_2006(
double &,
double &,
int &,
double *,
double *,
double *,
double *,
double *);
83 void hwwarn_(
const char *method,
int *
id);
95 herwigVerbosity(params.getUntrackedParameter<int>(
"herwigVerbosity", 0)),
96 hepmcVerbosity(params.getUntrackedParameter<int>(
"hepmcVerbosity", 0)),
98 printCards(params.getUntrackedParameter<bool>(
"printCards",
false)),
99 comEnergy(params.getParameter<double>(
"comEnergy")),
100 survivalProbability(params.getParameter<double>(
"survivalProbability")),
101 diffTopology(params.getParameter<int>(
"diffTopology")),
102 h1fit(params.getParameter<int>(
"h1fit")),
103 useJimmy(params.getParameter<bool>(
"useJimmy")),
104 doMPInteraction(params.getParameter<bool>(
"doMPInteraction")),
105 numTrials(params.getUntrackedParameter<int>(
"numTrialsMPI", 100)),
106 doPDGConvert(
false) {
107 if (params.
exists(
"doPDGConvert"))
133 <<
"Initializing PomwigHadronizer\n"
134 <<
"----------------------------------------------\n";
145 hwbmch.PART1[0] =
'E';
146 hwbmch.PART1[1] =
'-';
147 hwbmch.PART2[0] =
'E';
148 hwbmch.PART2[1] =
'-';
151 hwbmch.PART1[0] =
'E';
152 hwbmch.PART1[1] =
'-';
153 hwbmch.PART2[0] =
'P';
154 hwbmch.PART2[1] =
' ';
157 hwbmch.PART1[0] =
'P';
158 hwbmch.PART1[1] =
' ';
159 hwbmch.PART2[0] =
'E';
160 hwbmch.PART2[1] =
'-';
163 hwbmch.PART1[0] =
'P';
164 hwbmch.PART1[1] =
' ';
165 hwbmch.PART2[0] =
'P';
166 hwbmch.PART2[1] =
' ';
170 <<
" Invalid Diff. Topology. Must be DPE(diffTopology = 0), SD particle 1 (diffTopology = 1), SD particle "
171 "2 (diffTopology = 2) and Non diffractive (diffTopology = 3)";
174 for (
int i = 2;
i < 8; ++
i) {
175 hwbmch.PART1[
i] =
' ';
176 hwbmch.PART2[
i] =
' ';
182 hwevnt.MAXER = 100000000;
188 for (
unsigned int i = 0;
i < 2;
i++) {
189 hwpram.MODPDF[
i] = -111;
190 std::memcpy(
hwprch.AUTPDF[
i],
"HWLHAPDF", 8);
197 <<
"Reading HERWIG parameters\n"
198 <<
"------------------------------------\n";
204 <<
"Herwig 6 did not accept the following: \"" << *
line <<
"\"." << std::endl;
234 int nstru = hwpram.NSTRU;
236 if ((nstru == 9) || (nstru == 10)) {
237 if ((ifit <= 0) || (ifit >= 7)) {
239 <<
" Attempted to set non existant H1 1997 fit index. Has to be 1...6";
243 <<
" IFIT = " << ifit;
248 }
else if ((nstru >= 12) && (nstru <= 15)) {
249 bool isPom = (nstru == 12) || (nstru == 14);
250 bool isFitA = (nstru == 12) || (nstru == 13);
251 ifit = (isFitA) ? 1 : 2;
253 std::string aux_1((isPom) ?
"Pomeron" :
"Reggeon");
255 <<
" IFIT = " << ifit;
263 qcd_2006(xp, Q2, ifit, xpq, f2, fl, c2, cl);
266 <<
" Only running Pomeron H1 1997 (NSTRU=9), H1 2006 fit A (NSTRU=12) and H1 2006 fit B (NSTRU=14) or "
267 "Reggeon H1 1997 (NSTRU=10), H1 2006 fit A (NSTRU=13) and H1 2006 fit B (NSTRU=15)";
274 for (std::vector<int>::const_iterator iter = pdgIds.begin(); iter != pdgIds.end(); ++iter)
275 if (!markStable(*iter))
281 double RNWGT = 1. / hwevnt.NWGTS;
282 double AVWGT = hwevnt.WGTSUM * RNWGT;
284 double xsec = 1.0e3 * AVWGT;
330 event()->set_signal_process_id(hwproc.IPROC);
332 event()->weights().push_back(hwevnt.EVWGT);
349 event() = std::make_unique<HepMC::GenEvent>();
350 if (!
conv.fill_next_event(
event().
get()))
351 throw cms::Exception(
"PomwigError") <<
"HepMC Conversion problems in event." << std::endl;
355 for (HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end();
357 if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
358 (*part)->set_pdg_id(HepPID::translateHerwigtoPDT((*part)->pdg_id()));
bool declareStableParticles(const std::vector< int > &pdgIds)
Log< level::Info, true > LogVerbatim
void mysetpdfpath_(const char *path)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static void fixHepMCEventTimeOrdering(HepMC::GenEvent *event)
gen::ParameterCollector parameters
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
static const std::vector< std::string > theSharedResources
bool callWithTimeout(unsigned int secs, void(*fn)())
void hwwarn_(const char *method, int *id)
bool initializeForInternalPartons()
std::unique_ptr< HepMC::GenEvent > & event()
bool give(const std::string &line)
static const std::string kFortranInstance
bool generatePartonsAndHadronize()
void hwuidt_(int *iopt, int *ipdg, int *iwig, char nwig[8])
T getParameter(std::string const &) const
~PomwigHadronizer() override
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
const_iterator end() const
void setHerwigRandomEngine(CLHEP::HepRandomEngine *v)
const_iterator begin() const
double survivalProbability
PomwigHadronizer(const edm::ParameterSet ¶ms)
static const std::string kHerwig6
bool initializeForExternalPartons()
static HepMC::HEPEVT_Wrapper wrapper