11 #include <boost/shared_ptr.hpp>
12 #include <boost/algorithm/string/classification.hpp>
13 #include <boost/algorithm/string/split.hpp>
15 #include <HepMC/GenEvent.h>
16 #include <HepMC/GenParticle.h>
17 #include <HepMC/GenVertex.h>
18 #include <HepMC/PdfInfo.h>
19 #include <HepMC/HerwigWrapper6_4.h>
20 #include <HepMC/HEPEVT_Wrapper.h>
21 #include <HepMC/IO_HERWIG.h>
22 #include "HepPID/ParticleIDTranslations.hh"
43 void hwuidt_(
int *iopt,
int *ipdg,
int *iwig,
char nwig[8]);
48 static inline bool call_hwmsct()
55 static int pdgToHerwig(
int ipdg,
char *nwig)
59 hwuidt_(&iopt, &ipdg, &iwig, nwig);
60 return ipdg ? iwig : 0;
63 static bool markStable(
int pdgId)
66 if (!pdgToHerwig(pdgId, nwig))
73 #define qcd_1994 qcd_1994_
75 void qcd_1994(
double&,
double&,
double*,
int&);
78 #define qcd_2006 qcd_2006_
80 void qcd_2006(
double&,
double&,
int&,
double*,
double*,
double*,
double*,
double*);
84 void hwwarn_(
const char *method,
int *
id);
93 herwigVerbosity(params.getUntrackedParameter<int>(
"herwigVerbosity", 0)),
94 hepmcVerbosity(params.getUntrackedParameter<int>(
"hepmcVerbosity", 0)),
96 printCards(params.getUntrackedParameter<bool>(
"printCards",
false)),
97 comEnergy(params.getParameter<double>(
"comEnergy")),
98 survivalProbability(params.getParameter<double>(
"survivalProbability")),
99 diffTopology(params.getParameter<int>(
"diffTopology")),
100 h1fit(params.getParameter<int>(
"h1fit")),
101 useJimmy(params.getParameter<bool>(
"useJimmy")),
102 doMPInteraction(params.getParameter<bool>(
"doMPInteraction")),
103 numTrials(params.getUntrackedParameter<int>(
"numTrialsMPI", 100)),
106 if ( params.
exists(
"doPDGConvert" ) )
138 <<
"Initializing PomwigHadronizer\n"
139 <<
"----------------------------------------------\n";
150 hwbmch.PART1[0] =
'E';
151 hwbmch.PART1[1] =
'-';
152 hwbmch.PART2[0] =
'E';
153 hwbmch.PART2[1] =
'-';
156 hwbmch.PART1[0] =
'E';
157 hwbmch.PART1[1] =
'-';
158 hwbmch.PART2[0] =
'P';
159 hwbmch.PART2[1] =
' ';
162 hwbmch.PART1[0] =
'P';
163 hwbmch.PART1[1] =
' ';
164 hwbmch.PART2[0] =
'E';
165 hwbmch.PART2[1] =
'-';
168 hwbmch.PART1[0] =
'P';
169 hwbmch.PART1[1] =
' ';
170 hwbmch.PART2[0] =
'P';
171 hwbmch.PART2[1] =
' ';
175 <<
" Invalid Diff. Topology. Must be DPE(diffTopology = 0), SD particle 1 (diffTopology = 1), SD particle 2 (diffTopology = 2) and Non diffractive (diffTopology = 3)";
178 for(
int i=2;
i<8;++
i){
179 hwbmch.PART1[
i] =
' ';
180 hwbmch.PART2[
i] =
' ';}
185 hwevnt.MAXER = 100000000;
191 for(
unsigned int i = 0;
i < 2;
i++) {
192 hwpram.MODPDF[
i] = -111;
193 std::memcpy(
hwprch.AUTPDF[
i],
"HWLHAPDF", 8);
200 <<
"Reading HERWIG parameters\n"
201 <<
"------------------------------------\n";
208 <<
"Herwig 6 did not accept the following: \""
209 << *
line <<
"\"." << std::endl;
233 int nstru = hwpram.NSTRU;
235 if((nstru == 9)||(nstru == 10)){
236 if((ifit <= 0)||(ifit >= 7)){
238 <<
" Attempted to set non existant H1 1997 fit index. Has to be 1...6";
240 std::string
aux((nstru == 9)?
"Pomeron":
"Reggeon");
242 <<
" IFIT = " << ifit;
247 }
else if((nstru >= 12)&&(nstru <= 15)){
248 bool isPom = (nstru == 12)||(nstru == 14);
249 bool isFitA = (nstru == 12)||(nstru == 13);
251 std::string aux_0((isFitA)?
"A":
"B");
252 std::string aux_1((isPom)?
"Pomeron":
"Reggeon");
254 <<
" IFIT = "<< ifit;
262 qcd_2006(xp,Q2,ifit,xpq,f2,fl,c2,cl);
265 <<
" Only running Pomeron H1 1997 (NSTRU=9), H1 2006 fit A (NSTRU=12) and H1 2006 fit B (NSTRU=14) or Reggeon H1 1997 (NSTRU=10), H1 2006 fit A (NSTRU=13) and H1 2006 fit B (NSTRU=15)";
273 for(std::vector<int>::const_iterator iter = pdgIds.begin();
274 iter != pdgIds.end(); ++iter)
275 if (!markStable(*iter))
282 double RNWGT = 1. / hwevnt.NWGTS;
283 double AVWGT = hwevnt.WGTSUM * RNWGT;
285 double xsec = 1.0e3 * AVWGT;
325 if (!hwevnt.IERROR)
return true;
335 event()->set_signal_process_id(hwproc.IPROC);
337 event()->weights().push_back(hwevnt.EVWGT);
355 event().reset(
new HepMC::GenEvent);
356 if (!
conv.fill_next_event(
event().
get()))
358 <<
"HepMC Conversion problems in event." << std::endl;
362 for ( HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end(); ++
part) {
363 if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
364 (*part)->set_pdg_id(HepPID::translateHerwigtoPDT((*part)->pdg_id()));
bool declareStableParticles(const std::vector< int > &pdgIds)
T getParameter(std::string const &) const
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)
std::auto_ptr< HepMC::GenEvent > & event()
GenRunInfoProduct & runInfo()
bool callWithTimeout(unsigned int secs, void(*fn)())
void hwwarn_(const char *method, int *id)
bool initializeForInternalPartons()
void qcd_1994(double &, double &, double *, int &)
bool give(const std::string &line)
bool generatePartonsAndHadronize()
void hwuidt_(int *iopt, int *ipdg, int *iwig, char nwig[8])
void qcd_2006(double &, double &, int &, double *, double *, double *, double *, double *)
const_iterator end() const
const_iterator begin() const
double survivalProbability
PomwigHadronizer(const edm::ParameterSet ¶ms)
bool initializeForExternalPartons()
static HepMC::HEPEVT_Wrapper wrapper