5 #include <HepMC/GenEvent.h> 6 #include <HepMC/IO_BaseClass.h> 8 #include <ThePEG/Repository/Repository.h> 9 #include <ThePEG/EventRecord/Event.h> 10 #include <ThePEG/Config/ThePEG.h> 11 #include <ThePEG/LesHouches/LesHouchesReader.h> 28 #include <Herwig/API/HerwigAPI.h> 29 #include "CLHEP/Random/RandomEngine.h" 32 class HepRandomEngine;
41 bool initializeForInternalPartons();
42 bool initializeForExternalPartons();
43 bool declareStableParticles(
const std::vector<int> &pdgIds);
48 bool generatePartonsAndHadronize();
54 const char *
classname()
const {
return "Herwig7Hadronizer"; }
56 std::unique_ptr<GenLumiInfoHeader> getGenLumiInfoHeader()
const override;
70 std::shared_ptr<lhef::LHEProxy>
proxy_;
75 unsigned int firstLumiBlock=0;
76 unsigned int currentLumiBlock=0;
82 eventsToPrint(pset.getUntrackedParameter<unsigned
int>(
"eventsToPrint", 0)),
83 handlerDirectory_(pset.getParameter<
std::
string>(
"eventHandlers")),
84 runFileName(pset.getParameter<
std::
string>(
"run"))
105 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"No run step for Herwig chosen. Program will be aborted.";
123 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"No run step for Herwig chosen. Program will be aborted.";
139 eg_->integratedXSec() / ThePEG::picobarn,
140 eg_->integratedXSecErr() / ThePEG::picobarn));
146 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"Start production";
151 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
156 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"thepegEvent not initialized";
161 if (!
event().
get()) {
162 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"genEvent not initialized";
176 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
182 edm::LogError(
"Generator|Herwig7Hadronizer") <<
"Event number not set in lhe file, needed for correctly aligning Herwig and LHE events!";
185 edm::LogError(
"Herwig7 interface") <<
"Herwig does not seem to be generating events in order, did you set /Herwig/EventHandlers/FxFxLHReader:AllowedToReOpen Yes?";
190 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"thepegEvent not initialized";
195 if (!
event().
get()) {
196 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"genEvent not initialized";
201 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"Event " << evtnum <<
" not generated (likely skipped in merging)";
210 int weights_number =
thepegEvent->optionalWeights().size();
212 if(weights_number > 1){
215 std::map<std::string,double> weights_map =
thepegEvent->optionalWeights();
216 for (std::map<std::string,double>::iterator it = weights_map.begin(); it != weights_map.end(); it++)
228 BaseHadronizer::randomizeIndex(lumi, rengine);
252 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"Event produced";
LuminosityBlockID id() const
~Herwig7Hadronizer() override
bool generatePartonsAndHadronize()
static double pthat(const ThePEG::EventPtr &event)
void initRepository(const edm::ParameterSet ¶ms)
unsigned int firstLumiBlock
std::unique_ptr< HepMC::IO_BaseClass > iobc_
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
bool declareSpecialSettings(const std::vector< std::string >)
bool initializeForExternalPartons()
#define DEFINE_FWK_MODULE(type)
lhef::LHEEvent * lheEvent()
edm::GeneratorFilter< Herwig7Hadronizer, gen::ExternalDecayDriver > Herwig7GeneratorFilter
unsigned int eventsToPrint
static std::unique_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
edm::ParameterSet paramSettings
edm::HadronizerFilter< Herwig7Hadronizer, gen::ExternalDecayDriver > Herwig7HadronizerFilter
bool initializeForInternalPartons()
std::unique_ptr< HepMC::GenEvent > & event()
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
std::shared_ptr< lhef::LHEProxy > proxy_
std::unique_ptr< GenEventInfoProduct > & eventInfo()
LuminosityBlockNumber_t luminosityBlock() const
unsigned int currentLumiBlock
Herwig7Hadronizer(const edm::ParameterSet ¶ms)
ThePEG::EventPtr thepegEvent
const char * classname() const
std::unique_ptr< GenLumiInfoHeader > getGenLumiInfoHeader() const override
const std::string handlerDirectory_
const std::string runFileName
bool declareStableParticles(const std::vector< int > &pdgIds)
void randomizeIndex(edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)