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/HerwigWrapper.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*);
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" ) )
139 <<
"Initializing PomwigHadronizer\n"
140 <<
"----------------------------------------------\n";
151 hwbmch.PART1[0] =
'E';
152 hwbmch.PART1[1] =
'-';
153 hwbmch.PART2[0] =
'E';
154 hwbmch.PART2[1] =
'-';
157 hwbmch.PART1[0] =
'E';
158 hwbmch.PART1[1] =
'-';
159 hwbmch.PART2[0] =
'P';
160 hwbmch.PART2[1] =
' ';
163 hwbmch.PART1[0] =
'P';
164 hwbmch.PART1[1] =
' ';
165 hwbmch.PART2[0] =
'E';
166 hwbmch.PART2[1] =
'-';
169 hwbmch.PART1[0] =
'P';
170 hwbmch.PART1[1] =
' ';
171 hwbmch.PART2[0] =
'P';
172 hwbmch.PART2[1] =
' ';
176 <<
" Invalid Diff. Topology. Must be DPE(diffTopology = 0), SD particle 1 (diffTopology = 1), SD particle 2 (diffTopology = 2) and Non diffractive (diffTopology = 3)";
179 for(
int i=2;
i<8;++
i){
180 hwbmch.PART1[
i] =
' ';
181 hwbmch.PART2[
i] =
' ';}
186 hwevnt.MAXER = 100000000;
192 for(
unsigned int i = 0;
i < 2;
i++) {
193 hwpram.MODPDF[
i] = -111;
194 std::memcpy(
hwprch.AUTPDF[
i],
"HWLHAPDF", 8);
201 <<
"Reading HERWIG parameters\n"
202 <<
"------------------------------------\n";
209 <<
"Herwig 6 did not accept the following: \""
210 << *
line <<
"\"." << std::endl;
241 int nstru = hwpram.NSTRU;
243 if((nstru == 9)||(nstru == 10)){
244 if((ifit <= 0)||(ifit >= 7)){
246 <<
" Attempted to set non existant H1 1997 fit index. Has to be 1...6";
250 <<
" IFIT = " << ifit;
255 }
else if((nstru >= 12)&&(nstru <= 15)){
256 bool isPom = (nstru == 12)||(nstru == 14);
257 bool isFitA = (nstru == 12)||(nstru == 13);
262 <<
" IFIT = "<< ifit;
270 qcd_2006(xp,Q2,ifit,xpq,f2,fl,c2,cl);
273 <<
" 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)";
281 for(std::vector<int>::const_iterator iter = pdgIds.begin();
282 iter != pdgIds.end(); ++iter)
283 if (!markStable(*iter))
290 double RNWGT = 1. / hwevnt.NWGTS;
291 double AVWGT = hwevnt.WGTSUM * RNWGT;
293 double xsec = 1.0e3 * AVWGT;
333 if (!hwevnt.IERROR)
return true;
343 event()->set_signal_process_id(hwproc.IPROC);
345 event()->weights().push_back(hwevnt.EVWGT);
363 event().reset(
new HepMC::GenEvent);
364 if (!
conv.fill_next_event(
event().
get()))
366 <<
"HepMC Conversion problems in event." << std::endl;
370 for ( HepMC::GenEvent::particle_iterator
part =
event()->particles_begin();
part !=
event()->particles_end(); ++
part) {
371 if ((*part)->pdg_id() != HepPID::translateHerwigtoPDT((*part)->pdg_id()))
372 (*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)
volatile std::atomic< bool > shutdown_flag false
bool initializeForExternalPartons()
static HepMC::HEPEVT_Wrapper wrapper