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 ()(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::unique_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::unique_ptr< HepMC::IO_BaseClass > iobc_
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 35 of file Herwig7Hadronizer.cc.

Constructor & Destructor Documentation

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

Definition at line 79 of file Herwig7Hadronizer.cc.

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

79  :
82  eventsToPrint(pset.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
83  handlerDirectory_(pset.getParameter<std::string>("eventHandlers")),
84  runFileName(pset.getParameter<std::string>("run"))
85 {
88 }
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 ( )
override

Definition at line 90 of file Herwig7Hadronizer.cc.

91 {
92 }

Member Function Documentation

void Herwig7Hadronizer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
const char* Herwig7Hadronizer::classname ( ) const
inline

Definition at line 54 of file Herwig7Hadronizer.cc.

54 { return "Herwig7Hadronizer"; }
bool Herwig7Hadronizer::decay ( )

Definition at line 255 of file Herwig7Hadronizer.cc.

256 {
257  return true;
258 }
bool Herwig7Hadronizer::declareSpecialSettings ( const std::vector< std::string >  )
inline

Definition at line 44 of file Herwig7Hadronizer.cc.

References SelectingProcedure_cff::decay, and myMessageLogger_cff::statistics.

44 { return true; }
bool Herwig7Hadronizer::declareStableParticles ( const std::vector< int > &  pdgIds)

Definition at line 130 of file Herwig7Hadronizer.cc.

131 {
132  return false;
133 }
void Herwig7Hadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 63 of file Herwig7Hadronizer.cc.

void setPEGRandomEngine(CLHEP::HepRandomEngine *)
void Herwig7Hadronizer::finalizeEvent ( )

Definition at line 238 of file Herwig7Hadronizer.cc.

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

239 {
240  eventInfo().reset(new GenEventInfoProduct(event().get()));
241  eventInfo()->setBinningValues(
242  std::vector<double>(1, pthat(thepegEvent)));
243 
244  if (eventsToPrint) {
245  eventsToPrint--;
246  event()->print();
247  }
248 
249  if (iobc_.get())
250  iobc_->write_event(event().get());
251 
252  edm::LogInfo("Generator|Herwig7Hadronizer") << "Event produced";
253 }
static double pthat(const ThePEG::EventPtr &event)
std::unique_ptr< HepMC::IO_BaseClass > iobc_
unsigned int eventsToPrint
std::unique_ptr< HepMC::GenEvent > & event()
std::unique_ptr< GenEventInfoProduct > & eventInfo()
ThePEG::EventPtr thepegEvent
Definition: event.py:1
bool Herwig7Hadronizer::generatePartonsAndHadronize ( )

Definition at line 144 of file Herwig7Hadronizer.cc.

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

145 {
146  edm::LogInfo("Generator|Herwig7Hadronizer") << "Start production";
147 
148  try {
149  thepegEvent = eg_->shoot();
150  } catch (std::exception& exc) {
151  edm::LogWarning("Generator|Herwig7Hadronizer") << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
152  return false;
153  }
154 
155  if (!thepegEvent) {
156  edm::LogWarning("Generator|Herwig7Hadronizer") << "thepegEvent not initialized";
157  return false;
158  }
159 
161  if (!event().get()) {
162  edm::LogWarning("Generator|Herwig7Hadronizer") << "genEvent not initialized";
163  return false;
164  }
165 
166  return true;
167 }
ThePEG::EGPtr eg_
static std::unique_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
std::unique_ptr< HepMC::GenEvent > & event()
ThePEG::EventPtr thepegEvent
std::unique_ptr< GenLumiInfoHeader > Herwig7Hadronizer::getGenLumiInfoHeader ( ) const
overridevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 205 of file Herwig7Hadronizer.cc.

References genWeightsTable_cfi::genLumiInfoHeader, and thepegEvent.

205  {
206  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
207 
208  if (thepegEvent)
209  {
210  int weights_number = thepegEvent->optionalWeights().size();
211 
212  if(weights_number > 1){
213  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
214  genLumiInfoHeader->weightNames().push_back("nominal");
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++)
217  {
218  genLumiInfoHeader->weightNames().push_back(it->first);
219  }
220  }
221  }
222 
223  return genLumiInfoHeader;
224 }
ThePEG::EventPtr thepegEvent
bool Herwig7Hadronizer::hadronize ( )

Definition at line 169 of file Herwig7Hadronizer.cc.

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

170 {
171  if (!haveEvt) {
172  try {
173  thepegEvent = eg_->shoot();
174  haveEvt = true;
175  } catch (std::exception& exc) {
176  edm::LogWarning("Generator|Herwig7Hadronizer") << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
177  return false;
178  }
179  }
180  int evtnum = lheEvent()->evtnum();
181  if (evtnum == -1) {
182  edm::LogError("Generator|Herwig7Hadronizer") << "Event number not set in lhe file, needed for correctly aligning Herwig and LHE events!";
183  return false;
184  } else if (thepegEvent->number() == evtnum) {
185  edm::LogError("Herwig7 interface") << "Herwig does not seem to be generating events in order, did you set /Herwig/EventHandlers/FxFxLHReader:AllowedToReOpen Yes?";
186  return false;
187  } else if (thepegEvent->number() == evtnum) {
188  haveEvt = false;
189  if (!thepegEvent) {
190  edm::LogWarning("Generator|Herwig7Hadronizer") << "thepegEvent not initialized";
191  return false;
192  }
193 
195  if (!event().get()) {
196  edm::LogWarning("Generator|Herwig7Hadronizer") << "genEvent not initialized";
197  return false;
198  }
199  return true;
200  }
201  edm::LogWarning("Generator|Herwig7Hadronizer") << "Event " << evtnum << " not generated (likely skipped in merging)";
202  return false;
203 }
ThePEG::EGPtr eg_
lhef::LHEEvent * lheEvent()
static std::unique_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
std::unique_ptr< HepMC::GenEvent > & event()
ThePEG::EventPtr thepegEvent
int evtnum() const
Definition: LHEEvent.h:58
bool Herwig7Hadronizer::initializeForExternalPartons ( )

Definition at line 112 of file Herwig7Hadronizer.cc.

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

113 {
115  {
116  std::ifstream runFile(runFileName+".run");
117  if (runFile.fail()) //required for showering of LHE files
118  {
120  }
121  if (!initGenerator())
122  {
123  edm::LogInfo("Generator|Herwig7Hadronizer") << "No run step for Herwig chosen. Program will be aborted.";
124  exit(0);
125  }
126  }
127  return true;
128 }
void initRepository(const edm::ParameterSet &params)
unsigned int firstLumiBlock
edm::ParameterSet paramSettings
unsigned int currentLumiBlock
const std::string runFileName
bool Herwig7Hadronizer::initializeForInternalPartons ( )

Definition at line 94 of file Herwig7Hadronizer.cc.

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

95 {
97  {
98  std::ifstream runFile(runFileName+".run");
99  if (runFile.fail()) //required for showering of LHE files
100  {
102  }
103  if (!initGenerator())
104  {
105  edm::LogInfo("Generator|Herwig7Hadronizer") << "No run step for Herwig chosen. Program will be aborted.";
106  exit(0);
107  }
108  }
109  return true;
110 }
void initRepository(const edm::ParameterSet &params)
unsigned int firstLumiBlock
edm::ParameterSet paramSettings
unsigned int currentLumiBlock
const std::string runFileName
void Herwig7Hadronizer::randomizeIndex ( edm::LuminosityBlock const &  lumi,
CLHEP::HepRandomEngine *  rengine 
)

Definition at line 226 of file Herwig7Hadronizer.cc.

References currentLumiBlock, firstLumiBlock, edm::LuminosityBlockBase::id(), and edm::LuminosityBlockID::luminosityBlock().

227 {
228  BaseHadronizer::randomizeIndex(lumi, rengine);
229 
230  if (firstLumiBlock==0)
231  {
232  firstLumiBlock=lumi.id().luminosityBlock();
233  }
234  currentLumiBlock=lumi.id().luminosityBlock();
235 
236 }
unsigned int firstLumiBlock
unsigned int currentLumiBlock
bool Herwig7Hadronizer::readSettings ( int  )
inline

Definition at line 40 of file Herwig7Hadronizer.cc.

40 { return true; }
bool Herwig7Hadronizer::residualDecay ( )

Definition at line 260 of file Herwig7Hadronizer.cc.

261 {
262  return true;
263 }
void Herwig7Hadronizer::statistics ( )

Definition at line 135 of file Herwig7Hadronizer.cc.

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

136 {
137  if(eg_){
139  eg_->integratedXSec() / ThePEG::picobarn,
140  eg_->integratedXSecErr() / ThePEG::picobarn));
141  }
142 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
ThePEG::EGPtr eg_

Member Data Documentation

unsigned int Herwig7Hadronizer::currentLumiBlock =0
private
unsigned int Herwig7Hadronizer::eventsToPrint
private

Definition at line 65 of file Herwig7Hadronizer.cc.

Referenced by finalizeEvent().

unsigned int Herwig7Hadronizer::firstLumiBlock =0
private
const std::string Herwig7Hadronizer::handlerDirectory_
private

Definition at line 71 of file Herwig7Hadronizer.cc.

bool Herwig7Hadronizer::haveEvt = false
private

Definition at line 68 of file Herwig7Hadronizer.cc.

Referenced by hadronize().

edm::ParameterSet Herwig7Hadronizer::paramSettings
private
std::shared_ptr<lhef::LHEProxy> Herwig7Hadronizer::proxy_
private

Definition at line 70 of file Herwig7Hadronizer.cc.

const std::string Herwig7Hadronizer::runFileName
private
ThePEG::EventPtr Herwig7Hadronizer::thepegEvent
private