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_
 
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 76 of file Herwig7Hadronizer.cc.

79  eventsToPrint(pset.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
80  handlerDirectory_(pset.getParameter<std::string>("eventHandlers")),
81  runFileName(pset.getParameter<std::string>("run")) {
84 }

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

◆ ~Herwig7Hadronizer()

Herwig7Hadronizer::~Herwig7Hadronizer ( )
override

Definition at line 86 of file Herwig7Hadronizer.cc.

86 {}

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 164 of file Herwig7Hadronizer.cc.

164 { 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 109 of file Herwig7Hadronizer.cc.

109 { 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.

◆ finalizeEvent()

void Herwig7Hadronizer::finalizeEvent ( )

Definition at line 149 of file Herwig7Hadronizer.cc.

149  {
150  eventInfo() = std::make_unique<GenEventInfoProduct>(event().get());
151  eventInfo()->setBinningValues(std::vector<double>(1, pthat(thepegEvent)));
152 
153  if (eventsToPrint) {
154  eventsToPrint--;
155  event()->print();
156  }
157 
158  if (iobc_.get())
159  iobc_->write_event(event().get());
160 
161  edm::LogInfo("Generator|Herwig7Hadronizer") << "Event produced";
162 }

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

◆ generatePartonsAndHadronize()

bool Herwig7Hadronizer::generatePartonsAndHadronize ( )

Definition at line 118 of file Herwig7Hadronizer.cc.

118  {
119  edm::LogInfo("Generator|Herwig7Hadronizer") << "Start production";
120 
121  try {
122  thepegEvent = eg_->shoot();
123  } catch (std::exception& exc) {
124  edm::LogWarning("Generator|Herwig7Hadronizer")
125  << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
126  return false;
127  }
128 
129  if (!thepegEvent) {
130  edm::LogWarning("Generator|Herwig7Hadronizer") << "thepegEvent not initialized";
131  return false;
132  }
133 
135  if (!event().get()) {
136  edm::LogWarning("Generator|Herwig7Hadronizer") << "genEvent not initialized";
137  return false;
138  }
139 
140  return true;
141 }

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

◆ getGenLumiInfoHeader()

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

Reimplemented from gen::BaseHadronizer.

Definition at line 168 of file Herwig7Hadronizer.cc.

168  {
169  auto genLumiInfoHeader = BaseHadronizer::getGenLumiInfoHeader();
170 
171  if (thepegEvent) {
172  int weights_number = thepegEvent->optionalWeights().size();
173 
174  if (weights_number > 1) {
175  genLumiInfoHeader->weightNames().reserve(weights_number + 1);
176  genLumiInfoHeader->weightNames().push_back("nominal");
177  std::map<std::string, double> weights_map = thepegEvent->optionalWeights();
178  for (std::map<std::string, double>::iterator it = weights_map.begin(); it != weights_map.end(); it++) {
179  genLumiInfoHeader->weightNames().push_back(it->first);
180  }
181  }
182  }
183 
184  return genLumiInfoHeader;
185 }

References genWeightsTable_cfi::genLumiInfoHeader, and thepegEvent.

◆ hadronize()

bool Herwig7Hadronizer::hadronize ( )

Definition at line 143 of file Herwig7Hadronizer.cc.

143  {
144  edm::LogError("Herwig7 interface")
145  << "Read in of LHE files is not supported in this way. You can read them manually if necessary.";
146  return false;
147 }

◆ initializeForExternalPartons()

bool Herwig7Hadronizer::initializeForExternalPartons ( )

Definition at line 103 of file Herwig7Hadronizer.cc.

103  {
104  edm::LogError("Herwig7 interface")
105  << "Read in of LHE files is not supported in this way. You can read them manually if necessary.";
106  return false;
107 }

◆ initializeForInternalPartons()

bool Herwig7Hadronizer::initializeForInternalPartons ( )

Definition at line 88 of file Herwig7Hadronizer.cc.

88  {
90  std::ifstream runFile(runFileName + ".run");
91  if (runFile.fail()) //required for showering of LHE files
92  {
94  }
95  if (!initGenerator()) {
96  edm::LogInfo("Generator|Herwig7Hadronizer") << "No run step for Herwig chosen. Program will be aborted.";
97  exit(0);
98  }
99  }
100  return true;
101 }

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

◆ randomizeIndex()

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

Definition at line 187 of file Herwig7Hadronizer.cc.

187  {
188  BaseHadronizer::randomizeIndex(lumi, rengine);
189 
190  if (firstLumiBlock == 0) {
191  firstLumiBlock = lumi.id().luminosityBlock();
192  }
193  currentLumiBlock = lumi.id().luminosityBlock();
194 }

References currentLumiBlock, and firstLumiBlock.

◆ readSettings()

bool Herwig7Hadronizer::readSettings ( int  )
inline

Definition at line 41 of file Herwig7Hadronizer.cc.

41 { return true; }

◆ residualDecay()

bool Herwig7Hadronizer::residualDecay ( )

Definition at line 166 of file Herwig7Hadronizer.cc.

166 { return true; }

◆ statistics()

void Herwig7Hadronizer::statistics ( )

Definition at line 111 of file Herwig7Hadronizer.cc.

111  {
112  if (eg_) {
114  GenRunInfoProduct::XSec(eg_->integratedXSec() / ThePEG::picobarn, eg_->integratedXSecErr() / ThePEG::picobarn));
115  }
116 }

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

Member Data Documentation

◆ currentLumiBlock

unsigned int Herwig7Hadronizer::currentLumiBlock = 0
private

Definition at line 73 of file Herwig7Hadronizer.cc.

Referenced by initializeForInternalPartons(), and randomizeIndex().

◆ eventsToPrint

unsigned int Herwig7Hadronizer::eventsToPrint
private

Definition at line 63 of file Herwig7Hadronizer.cc.

Referenced by finalizeEvent().

◆ firstLumiBlock

unsigned int Herwig7Hadronizer::firstLumiBlock = 0
private

Definition at line 72 of file Herwig7Hadronizer.cc.

Referenced by initializeForInternalPartons(), and randomizeIndex().

◆ handlerDirectory_

const std::string Herwig7Hadronizer::handlerDirectory_
private

Definition at line 68 of file Herwig7Hadronizer.cc.

◆ paramSettings

edm::ParameterSet Herwig7Hadronizer::paramSettings
private

Definition at line 69 of file Herwig7Hadronizer.cc.

Referenced by Herwig7Hadronizer(), and initializeForInternalPartons().

◆ proxy_

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

Definition at line 67 of file Herwig7Hadronizer.cc.

◆ runFileName

const std::string Herwig7Hadronizer::runFileName
private

Definition at line 70 of file Herwig7Hadronizer.cc.

Referenced by initializeForInternalPartons().

◆ thepegEvent

ThePEG::EventPtr Herwig7Hadronizer::thepegEvent
private
genWeightsTable_cfi.genLumiInfoHeader
genLumiInfoHeader
Definition: genWeightsTable_cfi.py:5
Herwig7Interface::Herwig7Interface
Herwig7Interface(const edm::ParameterSet &params)
Definition: Herwig7Interface.cc:50
GenRunInfoProduct::setInternalXSec
void setInternalXSec(const XSec &xsec)
Definition: GenRunInfoProduct.h:26
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
Herwig7Hadronizer::eventsToPrint
unsigned int eventsToPrint
Definition: Herwig7Hadronizer.cc:63
gen::BaseHadronizer::eventInfo
std::unique_ptr< GenEventInfoProduct > & eventInfo()
Definition: BaseHadronizer.h:87
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
Herwig7Interface::initRepository
void initRepository(const edm::ParameterSet &params)
Definition: Herwig7Interface.cc:83
GenRunInfoProduct::XSec
Definition: GenRunInfoProduct.h:32
Herwig7Hadronizer::thepegEvent
ThePEG::EventPtr thepegEvent
Definition: Herwig7Hadronizer.cc:65
Herwig7Interface::initGenerator
bool initGenerator()
Definition: Herwig7Interface.cc:190
Herwig7Interface::iobc_
std::auto_ptr< HepMC::IO_BaseClass > iobc_
Definition: Herwig7Interface.h:59
Herwig7Interface::setPEGRandomEngine
void setPEGRandomEngine(CLHEP::HepRandomEngine *)
Definition: Herwig7Interface.cc:74
Herwig7Hadronizer::paramSettings
edm::ParameterSet paramSettings
Definition: Herwig7Hadronizer.cc:69
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
Herwig7Interface::pthat
static double pthat(const ThePEG::EventPtr &event)
Definition: Herwig7Interface.cc:230
gen::BaseHadronizer::event
std::unique_ptr< HepMC::GenEvent > & event()
Definition: BaseHadronizer.h:86
gen::BaseHadronizer::BaseHadronizer
BaseHadronizer(edm::ParameterSet const &ps)
Definition: BaseHadronizer.cc:12
Herwig7Hadronizer::handlerDirectory_
const std::string handlerDirectory_
Definition: Herwig7Hadronizer.cc:68
Herwig7Hadronizer::runFileName
const std::string runFileName
Definition: Herwig7Hadronizer.cc:70
Herwig7Hadronizer::currentLumiBlock
unsigned int currentLumiBlock
Definition: Herwig7Hadronizer.cc:73
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
Herwig7Interface::convert
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
Definition: Herwig7Interface.cc:226
event
Definition: event.py:1
Herwig7Interface::eg_
ThePEG::EGPtr eg_
Definition: Herwig7Interface.h:48
lumi
Definition: LumiSectionData.h:20
gen::BaseHadronizer::runInfo
GenRunInfoProduct & runInfo()
Definition: BaseHadronizer.h:85
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
Herwig7Hadronizer::firstLumiBlock
unsigned int firstLumiBlock
Definition: Herwig7Hadronizer.cc:72