CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ThePEGHadronisation.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <sstream>
4 #include <memory>
5 #include <assert.h>
6 
7 #include <boost/shared_ptr.hpp>
8 
9 #include <HepMC/GenEvent.h>
10 #include <HepMC/GenParticle.h>
11 #include <HepMC/PdfInfo.h>
12 
13 #include <ThePEG/Repository/Repository.h>
14 #include <ThePEG/EventRecord/Event.h>
15 #include <ThePEG/Config/ThePEG.h>
16 #include <ThePEG/LesHouches/LesHouchesReader.h>
17 
21 
24 
29 
31 
32 namespace CLHEP {
33  class HepRandomEngine;
34 }
35 
36 using namespace std;
37 using namespace ThePEG;
38 using namespace lhef;
39 
40 namespace lhef {
41 
43  public:
46 
47  private:
48 
49  virtual void doSetRandomEngine(CLHEP::HepRandomEngine* v) override { setPEGRandomEngine(v); }
50 
51  void doInit();
52  std::auto_ptr<HepMC::GenEvent> doHadronisation();
53  void newRunInfo(const boost::shared_ptr<LHERunInfo> &runInfo);
54 
55  void initLHE();
56 
57  boost::shared_ptr<LHEProxy> proxy_;
58 
60 };
61 
62 void ThePEGHadronisation::initLHE()
63 {
64  ostringstream ss;
65  ss << proxy_->getID();
66 
67  ostringstream logstream;
68  ThePEG::Repository::exec("set " + handlerDirectory_ +
69  "/LHEReader:ProxyID " + ss.str(), logstream);
70  edm::LogInfo("Generator|LHEInterface") << logstream.str();
71 }
72 
73 ThePEGHadronisation::ThePEGHadronisation(const edm::ParameterSet &params) :
74  ThePEGInterface(params),
75  Hadronisation(params),
76  handlerDirectory_(params.getParameter<string>("eventHandlers"))
77 {
78  initRepository(params);
80  initLHE();
81 }
82 
84 {
85 }
86 
88 {
89 }
90 
91 std::auto_ptr<HepMC::GenEvent> ThePEGHadronisation::doHadronisation()
92 {
93  edm::LogInfo("Generator|LHEInterface") << "Start production";
94 
95  proxy_->loadEvent(getRawEvent());
96 
97  ThePEG::EventPtr thepegEvent;
98  try {
100  thepegEvent = eg_->shoot();
101  } catch(ThePEG::Stop) {
102  // no event
103  }
104 
105  if (!thepegEvent) {
106  edm::LogWarning("Generator|LHEInterface")
107  << "thepegEvent not initialized";
108  return std::auto_ptr<HepMC::GenEvent>();
109  }
110 
111  std::auto_ptr<HepMC::GenEvent> event = convert(thepegEvent);
112  if (!event.get())
113  return event;
114 
115  HepMC::PdfInfo pdf;
116  clearAuxiliary(event.get(), &pdf);
117  getRawEvent()->fillPdfInfo(&pdf);
118  fillAuxiliary(event.get(), &pdf, thepegEvent);
119  event->set_pdf_info(pdf);
120 
121  return event;
122 }
123 
125  const boost::shared_ptr<LHERunInfo> &runInfo)
126 {
127  proxy_->loadRunInfo(runInfo);
128  initGenerator();
129 }
130 
132 
133 } // namespace lhef
void initRepository(const edm::ParameterSet &params) const
void newRunInfo(const boost::shared_ptr< LHERunInfo > &runInfo)
DEFINE_LHE_HADRONISATION_PLUGIN(ThePEGHadronisation)
const boost::shared_ptr< LHEEvent > & getRawEvent() const
Definition: Hadronisation.h:65
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
void flushRandomNumberGenerator()
std::auto_ptr< HepMC::GenEvent > doHadronisation()
ThePEG::EGPtr eg_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static std::auto_ptr< HepMC::GenEvent > convert(const ThePEG::EventPtr &event)
const std::string handlerDirectory_
boost::shared_ptr< LHEProxy > proxy_
static void clearAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf)
static boost::shared_ptr< LHEProxy > create()
Definition: LHEProxy.cc:41
static void fillAuxiliary(HepMC::GenEvent *hepmc, HepMC::PdfInfo *pdf, const ThePEG::EventPtr &event)