CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Herwig7Hadronizer Class Reference
Inheritance diagram for Herwig7Hadronizer:
Herwig7Interface gen::BaseHadronizer

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
const char * classname () const
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string >)
 
bool declareStableParticles (const std::vector< int > &pdgIds)
 
void finalizeEvent ()
 
bool generatePartonsAndHadronize ()
 
std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const override
 
bool hadronize ()
 
 Herwig7Hadronizer (const edm::ParameterSet &params)
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons ()
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
bool readSettings (int)
 
bool residualDecay ()
 
void statistics ()
 
 ~Herwig7Hadronizer () override
 
- Public Member Functions inherited from Herwig7Interface
 Herwig7Interface (const edm::ParameterSet &params)
 
void setPEGRandomEngine (CLHEP::HepRandomEngine *)
 
 ~Herwig7Interface () noexcept
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer () noexcept(false)
 

Private Member Functions

void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 

Private Attributes

unsigned int currentLumiBlock = 0
 
unsigned int eventsToPrint
 
unsigned int firstLumiBlock = 0
 
const std::string handlerDirectory_
 
bool haveEvt = false
 
edm::ParameterSet paramSettings
 
std::shared_ptr< lhef::LHEProxyproxy_
 
const std::string runFileName
 
ThePEG::EventPtr thepegEvent
 

Additional Inherited Members

- Public Attributes inherited from Herwig7Interface
ThePEG::EGPtr eg_
 
- Protected Member Functions inherited from Herwig7Interface
void callHerwigGenerator ()
 
void createInputFile (const edm::ParameterSet &params)
 
void flushRandomNumberGenerator ()
 
bool initGenerator ()
 
void initRepository (const edm::ParameterSet &params)
 
- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr< HepMC::GenEvent > & event ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Static Protected Member Functions inherited from Herwig7Interface
static std::auto_ptr< HepMC::GenEventconvert (const ThePEG::EventPtr &event)
 
static double pthat (const ThePEG::EventPtr &event)
 
- Protected Attributes inherited from Herwig7Interface
std::shared_ptr< Herwig::HerwigUIProviderHwUI_
 
std::auto_ptr< HepMC::IO_BaseClass > iobc_
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 36 of file Herwig7Hadronizer.cc.

Constructor & Destructor Documentation

◆ Herwig7Hadronizer()

Herwig7Hadronizer::Herwig7Hadronizer ( const edm::ParameterSet params)

Definition at line 77 of file Herwig7Hadronizer.cc.

References Herwig7Interface::initRepository(), paramSettings, and muonDTDigis_cfi::pset.

80  eventsToPrint(pset.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
81  handlerDirectory_(pset.getParameter<std::string>("eventHandlers")),
82  runFileName(pset.getParameter<std::string>("run")) {
85 }
void initRepository(const edm::ParameterSet &params)
BaseHadronizer(edm::ParameterSet const &ps)
unsigned int eventsToPrint
edm::ParameterSet paramSettings
Herwig7Interface(const edm::ParameterSet &params)
const std::string handlerDirectory_
const std::string runFileName

◆ ~Herwig7Hadronizer()

Herwig7Hadronizer::~Herwig7Hadronizer ( )
override

Definition at line 87 of file Herwig7Hadronizer.cc.

87 {}

Member Function Documentation

◆ beginLuminosityBlock()

void Herwig7Hadronizer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)

◆ classname()

const char* Herwig7Hadronizer::classname ( ) const
inline

Definition at line 55 of file Herwig7Hadronizer.cc.

55 { return "Herwig7Hadronizer"; }

◆ decay()

bool Herwig7Hadronizer::decay ( )

Definition at line 207 of file Herwig7Hadronizer.cc.

207 { return true; }

◆ declareSpecialSettings()

bool Herwig7Hadronizer::declareSpecialSettings ( const std::vector< std::string >  )
inline

Definition at line 45 of file Herwig7Hadronizer.cc.

45 { return true; }

◆ declareStableParticles()

bool Herwig7Hadronizer::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 119 of file Herwig7Hadronizer.cc.

119 { return false; }

◆ doSetRandomEngine()

void Herwig7Hadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 61 of file Herwig7Hadronizer.cc.

References Herwig7Interface::setPEGRandomEngine(), and findQualityFiles::v.

void setPEGRandomEngine(CLHEP::HepRandomEngine *)

◆ finalizeEvent()

void Herwig7Hadronizer::finalizeEvent ( )

Definition at line 192 of file Herwig7Hadronizer.cc.

References gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), eventsToPrint, Herwig7Interface::iobc_, Herwig7Interface::pthat(), and thepegEvent.

192  {
193  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
194  eventInfo()->setBinningValues(std::vector<double>(1, pthat(thepegEvent)));
195 
196  if (eventsToPrint) {
197  eventsToPrint--;
198  event()->print();
199  }
200 
201  if (iobc_.get())
202  iobc_->write_event(event().get());
203 
204  edm::LogInfo("Generator|Herwig7Hadronizer") << "Event produced";
205 }
static double pthat(const ThePEG::EventPtr &event)
std::auto_ptr< HepMC::IO_BaseClass > iobc_
unsigned int eventsToPrint
std::unique_ptr< HepMC::GenEvent > & event()
Log< level::Info, false > LogInfo
std::unique_ptr< GenEventInfoProduct > & eventInfo()
ThePEG::EventPtr thepegEvent
Definition: event.py:1

◆ generatePartonsAndHadronize()

bool Herwig7Hadronizer::generatePartonsAndHadronize ( )

Definition at line 128 of file Herwig7Hadronizer.cc.

References Herwig7Interface::convert(), Herwig7Interface::eg_, gen::BaseHadronizer::event(), cppFunctionSkipper::exception, and thepegEvent.

128  {
129  edm::LogInfo("Generator|Herwig7Hadronizer") << "Start production";
130 
131  try {
132  thepegEvent = eg_->shoot();
133  } catch (std::exception& exc) {
134  edm::LogWarning("Generator|Herwig7Hadronizer")
135  << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
136  return false;
137  }
138 
139  if (!thepegEvent) {
140  edm::LogWarning("Generator|Herwig7Hadronizer") << "thepegEvent not initialized";
141  return false;
142  }
143 
145  if (!event().get()) {
146  edm::LogWarning("Generator|Herwig7Hadronizer") << "genEvent not initialized";
147  return false;
148  }
149 
150  return true;
151 }
ThePEG::EGPtr eg_
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
std::unique_ptr< HepMC::GenEvent > & event()
Log< level::Info, false > LogInfo
ThePEG::EventPtr thepegEvent
Log< level::Warning, false > LogWarning

◆ getGenLumiInfoHeader()

std::unique_ptr< GenLumiInfoHeader > Herwig7Hadronizer::getGenLumiInfoHeader ( ) const
overridevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 211 of file Herwig7Hadronizer.cc.

References genWeightsTable_cfi::genLumiInfoHeader, and thepegEvent.

211  {
212  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
213 
214  if (thepegEvent) {
215  int weights_number = thepegEvent->optionalWeights().size();
216 
217  if (weights_number > 1) {
218  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
219  genLumiInfoHeader->weightNames().push_back("nominal");
220  std::map<std::string, double> weights_map = thepegEvent->optionalWeights();
221  for (std::map<std::string, double>::iterator it = weights_map.begin(); it != weights_map.end(); it++) {
222  genLumiInfoHeader->weightNames().push_back(it->first);
223  }
224  }
225  }
226 
227  return genLumiInfoHeader;
228 }
ThePEG::EventPtr thepegEvent

◆ hadronize()

bool Herwig7Hadronizer::hadronize ( )

Definition at line 153 of file Herwig7Hadronizer.cc.

References Herwig7Interface::convert(), Herwig7Interface::eg_, gen::BaseHadronizer::event(), lhef::LHEEvent::evtnum(), cppFunctionSkipper::exception, haveEvt, gen::BaseHadronizer::lheEvent(), and thepegEvent.

153  {
154  if (!haveEvt) {
155  try {
156  thepegEvent = eg_->shoot();
157  haveEvt = true;
158  } catch (std::exception& exc) {
159  edm::LogWarning("Generator|Herwig7Hadronizer")
160  << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
161  return false;
162  }
163  }
164  int evtnum = lheEvent()->evtnum();
165  if (evtnum == -1) {
166  edm::LogError("Generator|Herwig7Hadronizer")
167  << "Event number not set in lhe file, needed for correctly aligning Herwig and LHE events!";
168  return false;
169  }
170  if (thepegEvent->number() < evtnum) {
171  edm::LogError("Herwig7 interface") << "Herwig does not seem to be generating events in order, did you set "
172  "/Herwig/EventHandlers/FxFxLHReader:AllowedToReOpen Yes?";
173  return false;
174  } else if (thepegEvent->number() == evtnum) {
175  haveEvt = false;
176  if (!thepegEvent) {
177  edm::LogWarning("Generator|Herwig7Hadronizer") << "thepegEvent not initialized";
178  return false;
179  }
180 
182  if (!event().get()) {
183  edm::LogWarning("Generator|Herwig7Hadronizer") << "genEvent not initialized";
184  return false;
185  }
186  return true;
187  }
188  edm::LogWarning("Generator|Herwig7Hadronizer") << "Event " << evtnum << " not generated (likely skipped in merging)";
189  return false;
190 }
Log< level::Error, false > LogError
ThePEG::EGPtr eg_
lhef::LHEEvent * lheEvent()
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
std::unique_ptr< HepMC::GenEvent > & event()
int evtnum() const
Definition: LHEEvent.h:55
ThePEG::EventPtr thepegEvent
Log< level::Warning, false > LogWarning

◆ initializeForExternalPartons()

bool Herwig7Hadronizer::initializeForExternalPartons ( )

Definition at line 104 of file Herwig7Hadronizer.cc.

References currentLumiBlock, beamvalidation::exit(), firstLumiBlock, Herwig7Interface::initGenerator(), Herwig7Interface::initRepository(), paramSettings, and runFileName.

104  {
106  std::ifstream runFile(runFileName + ".run");
107  if (runFile.fail()) //required for showering of LHE files
108  {
110  }
111  if (!initGenerator()) {
112  edm::LogInfo("Generator|Herwig7Hadronizer") << "No run step for Herwig chosen. Program will be aborted.";
113  exit(0);
114  }
115  }
116  return true;
117 }
void initRepository(const edm::ParameterSet &params)
unsigned int firstLumiBlock
edm::ParameterSet paramSettings
Log< level::Info, false > LogInfo
unsigned int currentLumiBlock
const std::string runFileName
def exit(msg="")

◆ initializeForInternalPartons()

bool Herwig7Hadronizer::initializeForInternalPartons ( )

Definition at line 89 of file Herwig7Hadronizer.cc.

References currentLumiBlock, beamvalidation::exit(), firstLumiBlock, Herwig7Interface::initGenerator(), Herwig7Interface::initRepository(), paramSettings, and runFileName.

89  {
91  std::ifstream runFile(runFileName + ".run");
92  if (runFile.fail()) //required for showering of LHE files
93  {
95  }
96  if (!initGenerator()) {
97  edm::LogInfo("Generator|Herwig7Hadronizer") << "No run step for Herwig chosen. Program will be aborted.";
98  exit(0);
99  }
100  }
101  return true;
102 }
void initRepository(const edm::ParameterSet &params)
unsigned int firstLumiBlock
edm::ParameterSet paramSettings
Log< level::Info, false > LogInfo
unsigned int currentLumiBlock
const std::string runFileName
def exit(msg="")

◆ randomizeIndex()

void Herwig7Hadronizer::randomizeIndex ( edm::LuminosityBlock const &  lumi,
CLHEP::HepRandomEngine *  rengine 
)

Definition at line 230 of file Herwig7Hadronizer.cc.

References currentLumiBlock, and firstLumiBlock.

230  {
231  BaseHadronizer::randomizeIndex(lumi, rengine);
232 
233  if (firstLumiBlock == 0) {
234  firstLumiBlock = lumi.id().luminosityBlock();
235  }
236  currentLumiBlock = lumi.id().luminosityBlock();
237 }
unsigned int firstLumiBlock
unsigned int currentLumiBlock

◆ readSettings()

bool Herwig7Hadronizer::readSettings ( int  )
inline

Definition at line 41 of file Herwig7Hadronizer.cc.

41 { return true; }

◆ residualDecay()

bool Herwig7Hadronizer::residualDecay ( )

Definition at line 209 of file Herwig7Hadronizer.cc.

209 { return true; }

◆ statistics()

void Herwig7Hadronizer::statistics ( )

Definition at line 121 of file Herwig7Hadronizer.cc.

References Herwig7Interface::eg_, gen::BaseHadronizer::runInfo(), and GenRunInfoProduct::setInternalXSec().

121  {
122  if (eg_) {
124  GenRunInfoProduct::XSec(eg_->integratedXSec() / ThePEG::picobarn, eg_->integratedXSecErr() / ThePEG::picobarn));
125  }
126 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
ThePEG::EGPtr eg_

Member Data Documentation

◆ currentLumiBlock

unsigned int Herwig7Hadronizer::currentLumiBlock = 0
private

◆ eventsToPrint

unsigned int Herwig7Hadronizer::eventsToPrint
private

Definition at line 63 of file Herwig7Hadronizer.cc.

Referenced by finalizeEvent().

◆ firstLumiBlock

unsigned int Herwig7Hadronizer::firstLumiBlock = 0
private

◆ handlerDirectory_

const std::string Herwig7Hadronizer::handlerDirectory_
private

Definition at line 69 of file Herwig7Hadronizer.cc.

◆ haveEvt

bool Herwig7Hadronizer::haveEvt = false
private

Definition at line 66 of file Herwig7Hadronizer.cc.

Referenced by hadronize().

◆ paramSettings

edm::ParameterSet Herwig7Hadronizer::paramSettings
private

◆ proxy_

std::shared_ptr<lhef::LHEProxy> Herwig7Hadronizer::proxy_
private

Definition at line 68 of file Herwig7Hadronizer.cc.

◆ runFileName

const std::string Herwig7Hadronizer::runFileName
private

◆ thepegEvent

ThePEG::EventPtr Herwig7Hadronizer::thepegEvent
private