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;
69 std::shared_ptr<lhef::LHEProxy>
proxy_;
74 unsigned int firstLumiBlock=0;
75 unsigned int currentLumiBlock=0;
81 eventsToPrint(pset.getUntrackedParameter<unsigned
int>(
"eventsToPrint", 0)),
82 handlerDirectory_(pset.getParameter<
std::
string>(
"eventHandlers")),
83 runFileName(pset.getParameter<
std::
string>(
"run"))
101 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"No run step for Herwig chosen. Program will be aborted.";
110 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"No run step for Herwig chosen. Program will be aborted.";
119 edm::LogError(
"Herwig7 interface") <<
"Read in of LHE files is not supported in this way. You can read them manually if necessary.";
132 eg_->integratedXSec() / ThePEG::picobarn,
133 eg_->integratedXSecErr() / ThePEG::picobarn));
139 edm::LogInfo(
"Generator|Herwig7Hadronizer") <<
"Start production";
144 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
149 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"thepegEvent not initialized";
154 if (!
event().
get()) {
155 edm::LogWarning(
"Generator|Herwig7Hadronizer") <<
"genEvent not initialized";
165 edm::LogError(
"Herwig7 interface") <<
"Read in of LHE files is not supported in this way. You can read them manually if necessary.";
170 auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
174 int weights_number =
thepegEvent->optionalWeights().size();
176 if(weights_number > 1){
177 genLumiInfoHeader->weightNames().reserve(weights_number + 1);
178 genLumiInfoHeader->weightNames().push_back(
"nominal");
179 std::map<std::string,double> weights_map =
thepegEvent->optionalWeights();
180 for (std::map<std::string,double>::iterator it = weights_map.begin(); it != weights_map.end(); it++)
182 genLumiInfoHeader->weightNames().push_back(it->first);
187 return genLumiInfoHeader;
192 BaseHadronizer::randomizeIndex(lumi, rengine);
216 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)
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)