CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~ThePEGHadronizer ()
 
- 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)
 
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
 
 ~BaseHadronizer ()
 

Private Member Functions

virtual 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  :
64  ThePEGInterface(pset),
65  BaseHadronizer(pset),
66  eventsToPrint(pset.getUntrackedParameter<unsigned int>("eventsToPrint", 0)),
67  handlerDirectory_(pset.getParameter<std::string>("eventHandlers"))
68 {
69  initRepository(pset);
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 ( )
virtual

Definition at line 73 of file ThePEGHadronizer.cc.

74 {
75 }

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 219 of file ThePEGHadronizer.cc.

220 {
221  return true;
222 }
bool ThePEGHadronizer::declareSpecialSettings ( const std::vector< std::string >  )
inline

Definition at line 39 of file ThePEGHadronizer.cc.

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

Definition at line 101 of file ThePEGHadronizer.cc.

102 {
103  return false;
104 }
virtual void ThePEGHadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 53 of file ThePEGHadronizer.cc.

References ThePEGInterface::setPEGRandomEngine().

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

Definition at line 197 of file ThePEGHadronizer.cc.

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

198 {
199  HepMC::PdfInfo pdf;
200  clearAuxiliary(event().get(), &pdf);
201  fillAuxiliary(event().get(), &pdf, thepegEvent);
202  event()->set_pdf_info(pdf);
203 
204  eventInfo().reset(new GenEventInfoProduct(event().get()));
205  eventInfo()->setBinningValues(
206  std::vector<double>(1, pthat(thepegEvent)));
207 
208  if (eventsToPrint) {
209  eventsToPrint--;
210  event()->print();
211  }
212 
213  if (iobc_.get())
214  iobc_->write_event(event().get());
215 
216  edm::LogInfo("Generator|ThePEGHadronizer") << "Event produced";
217 }
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)
static void fillAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)
bool ThePEGHadronizer::generatePartonsAndHadronize ( )

Definition at line 113 of file ThePEGHadronizer.cc.

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

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

144 {
145  edm::LogInfo("Generator|ThePEGHadronizer") << "Start production";
146 
148 
149  //need to copy lhe event here unfortunately because of interface mismatch
150  proxy_->loadEvent(boost::shared_ptr<lhef::LHEEvent>(new lhef::LHEEvent(*lheEvent())));
151 
152  //dummy for now
153  double mergeweight = 1.0;
154 
155  try {
156  thepegEvent = eg_->shoot();
157  } catch (std::exception& exc) {
158  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an exception, event skipped: " << exc.what();
159  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
160  return false;
161  } catch (...) {
162  edm::LogWarning("Generator|ThePEGHadronizer") << "EGPtr::shoot() thrown an unknown exception, event skipped";
163  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
164  return false;
165  }
166 
167  if (!thepegEvent) {
168  edm::LogWarning("Generator|ThePEGHadronizer") << "thepegEvent not initialized";
169  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
170  return false;
171  }
172 
174  if (!event().get()) {
175  edm::LogWarning("Generator|ThePEGHadronizer") << "genEvent not initialized";
176  lheEvent()->count( lhef::LHERunInfo::kSelected, 1.0, mergeweight );
177  return false;
178  }
179 
180  //Fill LHE weight (since it's not otherwise propagated)
181  event()->weights()[0] *= lheEvent()->getHEPEUP()->XWGTUP;
182 
183  HepMC::PdfInfo pdf;
184  clearAuxiliary(event().get(), &pdf);
185  lheEvent()->fillPdfInfo(&pdf);
186  fillAuxiliary(event().get(), &pdf, thepegEvent);
187  event()->set_pdf_info(pdf);
188 
189  // update LHE matching statistics
190  //
191  lheEvent()->count( lhef::LHERunInfo::kAccepted, 1.0, mergeweight );
192 
193  return true;
194 
195 }
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 83 of file ThePEGHadronizer.cc.

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

84 {
86 
87  std::ostringstream ss;
88  ss << proxy_->getID();
89 
90  std::ostringstream logstream;
91  ThePEG::Repository::exec("set " + handlerDirectory_ +
92  "/LHEReader:ProxyID " + ss.str(), logstream);
93  edm::LogInfo("Generator|LHEInterface") << logstream.str();
94 
95  proxy_->loadRunInfo(getLHERunInfo());
96 
97  initGenerator();
98  return true;
99 }
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 77 of file ThePEGHadronizer.cc.

References ThePEGInterface::initGenerator().

78 {
79  initGenerator();
80  return true;
81 }
bool ThePEGHadronizer::readSettings ( int  )
inline

Definition at line 35 of file ThePEGHadronizer.cc.

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

Definition at line 224 of file ThePEGHadronizer.cc.

225 {
226  return true;
227 }
void ThePEGHadronizer::statistics ( )

Definition at line 106 of file ThePEGHadronizer.cc.

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

107 {
109  eg_->integratedXSec() / ThePEG::picobarn,
110  eg_->integratedXSecErr() / ThePEG::picobarn));
111 }
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().