CMS 3D CMS Logo

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

Public Member Functions

const char * classname () const
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string >)
 
bool declareStableParticles (const std::vector< int > &pdgIds)
 
void finalizeEvent ()
 
bool generatePartonsAndHadronize ()
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons ()
 
bool readSettings (int)
 
bool residualDecay ()
 
void statistics ()
 
 ThePEGHadronizer (const edm::ParameterSet &params)
 
 ~ThePEGHadronizer () override
 
- Public Member Functions inherited from ThePEGInterface
void setPEGRandomEngine (CLHEP::HepRandomEngine *)
 
 ThePEGInterface (const edm::ParameterSet &params)
 
virtual ~ThePEGInterface ()
 
- 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
 
HepMC::GenEvent * getGenEvent ()
 
GenEventInfoProductgetGenEventInfo ()
 
virtual GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
const boost::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 (HepMC::GenEvent *event)
 
void resetEventInfo (GenEventInfoProduct *eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (lhef::LHEEvent *event)
 
void setLHERunInfo (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 eventsToPrint
 
const std::string handlerDirectory_
 
boost::shared_ptr< lhef::LHEProxyproxy_
 
ThePEG::EventPtr thepegEvent
 

Additional Inherited Members

- Protected Member Functions inherited from ThePEGInterface
std::string dataFile (const std::string &fileName) const
 
std::string dataFile (const edm::ParameterSet &pset, const std::string &paramName) const
 
void flushRandomNumberGenerator ()
 
void initGenerator ()
 
void initRepository (const edm::ParameterSet &params) const
 
- Protected Member Functions inherited from gen::BaseHadronizer
std::auto_ptr< HepMC::GenEvent > & event ()
 
std::auto_ptr< GenEventInfoProduct > & eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Static Protected Member Functions inherited from ThePEGInterface
static void clearAuxiliary (HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
 
static std::auto_ptr< HepMC::GenEvent > convert (const ThePEG::EventPtr &event)
 
static void fillAuxiliary (HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)
 
static double pthat (const ThePEG::EventPtr &event)
 
- Protected Attributes inherited from ThePEGInterface
ThePEG::EGPtr eg_
 
std::auto_ptr< HepMC::IO_BaseClass > iobc_
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 30 of file ThePEGHadronizer.cc.

Constructor & Destructor Documentation

ThePEGHadronizer::ThePEGHadronizer ( const edm::ParameterSet params)

Definition at line 63 of file ThePEGHadronizer.cc.

References ThePEGInterface::initRepository().

63  :
66  eventsToPrint(pset.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
67  handlerDirectory_(pset.getParameter<std::string>("eventHandlers"))
68 {
70 
71 }
unsigned int eventsToPrint
void initRepository(const edm::ParameterSet &params) const
ThePEGInterface(const edm::ParameterSet &params)
BaseHadronizer(edm::ParameterSet const &ps)
const std::string handlerDirectory_
ThePEGHadronizer::~ThePEGHadronizer ( )
inlineoverride

Definition at line 33 of file ThePEGHadronizer.cc.

33 {};

Member Function Documentation

const char* ThePEGHadronizer::classname ( ) const
inline

Definition at line 49 of file ThePEGHadronizer.cc.

49 { return "ThePEGHadronizer"; }
bool ThePEGHadronizer::decay ( )

Definition at line 215 of file ThePEGHadronizer.cc.

216 {
217  return true;
218 }
bool ThePEGHadronizer::declareSpecialSettings ( const std::vector< std::string >  )
inline

Definition at line 39 of file ThePEGHadronizer.cc.

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

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

Definition at line 97 of file ThePEGHadronizer.cc.

98 {
99  return false;
100 }
void ThePEGHadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 53 of file ThePEGHadronizer.cc.

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

Definition at line 193 of file ThePEGHadronizer.cc.

References ThePEGInterface::clearAuxiliary(), gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), eventsToPrint, ThePEGInterface::fillAuxiliary(), ThePEGInterface::iobc_, ThePEGInterface::pthat(), and thepegEvent.

194 {
195  HepMC::PdfInfo pdf;
196  clearAuxiliary(event().get(), &pdf);
197  fillAuxiliary(event().get(), &pdf, thepegEvent);
198  event()->set_pdf_info(pdf);
199 
200  eventInfo().reset(new GenEventInfoProduct(event().get()));
201  eventInfo()->setBinningValues(
202  std::vector<double>(1, pthat(thepegEvent)));
203 
204  if (eventsToPrint) {
205  eventsToPrint--;
206  event()->print();
207  }
208 
209  if (iobc_.get())
210  iobc_->write_event(event().get());
211 
212  edm::LogInfo("Generator|ThePEGHadronizer") << "Event produced";
213 }
unsigned int eventsToPrint
static double pthat(const ThePEG::EventPtr &event)
std::auto_ptr< HepMC::GenEvent > & event()
ThePEG::EventPtr thepegEvent
std::auto_ptr< HepMC::IO_BaseClass > iobc_
std::auto_ptr< GenEventInfoProduct > & eventInfo()
static void clearAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
Definition: event.py:1
static void fillAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)
bool ThePEGHadronizer::generatePartonsAndHadronize ( )

Definition at line 109 of file ThePEGHadronizer.cc.

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

110 {
111  edm::LogInfo("Generator|ThePEGHadronizer") << "Start production";
112 
114 
115  try {
116  thepegEvent = eg_->shoot();
117  } catch (std::exception& exc) {
118  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
119  return false;
120  } catch (...) {
121  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an unknown exception, event skipped";
122  return false;
123  }
124 
125  if (!thepegEvent) {
126  edm::LogWarning("Generator|ThePEGHadronizer") << "thepegEvent not initialized";
127  return false;
128  }
129 
131  if (!event().get()) {
132  edm::LogWarning("Generator|ThePEGHadronizer") << "genEvent not initialized";
133  return false;
134  }
135 
136  return true;
137 }
std::auto_ptr< HepMC::GenEvent > & event()
void flushRandomNumberGenerator()
ThePEG::EventPtr thepegEvent
ThePEG::EGPtr eg_
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
bool ThePEGHadronizer::hadronize ( )

Definition at line 139 of file ThePEGHadronizer.cc.

References ThePEGInterface::clearAuxiliary(), ThePEGInterface::convert(), lhef::LHEEvent::count(), ThePEGInterface::eg_, gen::BaseHadronizer::event(), cppFunctionSkipper::exception, ThePEGInterface::fillAuxiliary(), lhef::LHEEvent::fillPdfInfo(), ThePEGInterface::flushRandomNumberGenerator(), lhef::LHEEvent::getHEPEUP(), lhef::LHERunInfo::kAccepted, lhef::LHERunInfo::kSelected, gen::BaseHadronizer::lheEvent(), proxy_, thepegEvent, and lhef::HEPEUP::XWGTUP.

140 {
141  edm::LogInfo("Generator|ThePEGHadronizer") << "Start production";
142 
144 
145  //need to copy lhe event here unfortunately because of interface mismatch
146  proxy_->loadEvent(boost::shared_ptr<lhef::LHEEvent>(new lhef::LHEEvent(*lheEvent())));
147 
148  //dummy for now
149  double mergeweight = 1.0;
150 
151  try {
152  thepegEvent = eg_->shoot();
153  } catch (std::exception& exc) {
154  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
155  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
156  return false;
157  } catch (...) {
158  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an unknown exception, event skipped";
159  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
160  return false;
161  }
162 
163  if (!thepegEvent) {
164  edm::LogWarning("Generator|ThePEGHadronizer") << "thepegEvent not initialized";
165  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
166  return false;
167  }
168 
170  if (!event().get()) {
171  edm::LogWarning("Generator|ThePEGHadronizer") << "genEvent not initialized";
172  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
173  return false;
174  }
175 
176  //Fill LHE weight (since it's not otherwise propagated)
177  event()->weights()[0] *= lheEvent()->getHEPEUP()->XWGTUP;
178 
179  HepMC::PdfInfo pdf;
180  clearAuxiliary(event().get(), &pdf);
181  lheEvent()->fillPdfInfo(&pdf);
182  fillAuxiliary(event().get(), &pdf, thepegEvent);
183  event()->set_pdf_info(pdf);
184 
185  // update LHE matching statistics
186  //
187  lheEvent()->count( lhef::LHERunInfo::kAccepted, 1.0, mergeweight );
188 
189  return true;
190 
191 }
void count(LHERunInfo::CountMode count, double weight=1.0, double matchWeight=1.0)
Definition: LHEEvent.cc:207
const HEPEUP * getHEPEUP() const
Definition: LHEEvent.h:43
std::auto_ptr< HepMC::GenEvent > & event()
lhef::LHEEvent * lheEvent()
void fillPdfInfo(HepMC::PdfInfo *info) const
Definition: LHEEvent.cc:221
void flushRandomNumberGenerator()
ThePEG::EventPtr thepegEvent
ThePEG::EGPtr eg_
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
boost::shared_ptr< lhef::LHEProxy > proxy_
double XWGTUP
Definition: LesHouches.h:196
static void clearAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
static void fillAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)
bool ThePEGHadronizer::initializeForExternalPartons ( )

Definition at line 79 of file ThePEGHadronizer.cc.

References lhef::LHEProxy::create(), gen::BaseHadronizer::getLHERunInfo(), handlerDirectory_, ThePEGInterface::initGenerator(), and proxy_.

80 {
82 
83  std::ostringstream ss;
84  ss << proxy_->getID();
85 
86  std::ostringstream logstream;
87  ThePEG::Repository::exec("set " + handlerDirectory_ +
88  "/LHEReader:ProxyID " + ss.str(), logstream);
89  edm::LogInfo("Generator|LHEInterface") << logstream.str();
90 
91  proxy_->loadRunInfo(getLHERunInfo());
92 
93  initGenerator();
94  return true;
95 }
const std::string handlerDirectory_
boost::shared_ptr< lhef::LHEProxy > proxy_
const boost::shared_ptr< lhef::LHERunInfo > & getLHERunInfo() const
static boost::shared_ptr< LHEProxy > create()
Definition: LHEProxy.cc:41
bool ThePEGHadronizer::initializeForInternalPartons ( )

Definition at line 73 of file ThePEGHadronizer.cc.

References ThePEGInterface::initGenerator().

74 {
75  initGenerator();
76  return true;
77 }
bool ThePEGHadronizer::readSettings ( int  )
inline

Definition at line 35 of file ThePEGHadronizer.cc.

35 { return true; }
bool ThePEGHadronizer::residualDecay ( )

Definition at line 220 of file ThePEGHadronizer.cc.

221 {
222  return true;
223 }
void ThePEGHadronizer::statistics ( )

Definition at line 102 of file ThePEGHadronizer.cc.

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

103 {
105  eg_->integratedXSec() / ThePEG::picobarn,
106  eg_->integratedXSecErr() / ThePEG::picobarn));
107 }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
ThePEG::EGPtr eg_

Member Data Documentation

unsigned int ThePEGHadronizer::eventsToPrint
private

Definition at line 55 of file ThePEGHadronizer.cc.

Referenced by finalizeEvent().

const std::string ThePEGHadronizer::handlerDirectory_
private

Definition at line 60 of file ThePEGHadronizer.cc.

Referenced by initializeForExternalPartons().

boost::shared_ptr<lhef::LHEProxy> ThePEGHadronizer::proxy_
private

Definition at line 59 of file ThePEGHadronizer.cc.

Referenced by hadronize(), and initializeForExternalPartons().

ThePEG::EventPtr ThePEGHadronizer::thepegEvent
private

Definition at line 57 of file ThePEGHadronizer.cc.

Referenced by finalizeEvent(), generatePartonsAndHadronize(), and hadronize().