CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Hadronisation.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 
4 #include <boost/shared_ptr.hpp>
5 
6 #include <HepMC/GenEvent.h>
7 
12 
16 
18  "GeneratorInterfaceLHEHadronisation");
19 
20 namespace {
21  class NoHadronisation : public lhef::Hadronisation {
22  public:
23  NoHadronisation(const edm::ParameterSet &params) :
24  Hadronisation(params) {}
25  ~NoHadronisation() {}
26 
27  private:
28  void doInit() {}
29  std::auto_ptr<HepMC::GenEvent> doHadronisation()
30  { return getRawEvent()->asHepMCEvent(); }
31 };
32 
33 } // anonymous namespae
34 
35 namespace lhef {
36 
38  psRequested(false),
39  psAsHepMC(true)
40 {
41 }
42 
44 {
45 }
46 
48 {
49  doInit();
50 }
51 
52 bool Hadronisation::setEvent(const boost::shared_ptr<LHEEvent> &event)
53 {
54  bool newRunInfo = !rawEvent ||
55  (rawEvent->getRunInfo() != event->getRunInfo() &&
56  *rawEvent->getRunInfo() != *event->getRunInfo());
57  rawEvent = event;
58  if (newRunInfo) {
59  this->newRunInfo(event->getRunInfo());
60  return true;
61  } else
62  return false;
63 }
64 
66 {
67 }
68 
69 std::set<std::string> Hadronisation::capabilities() const
70 {
71  return std::set<std::string>();
72 }
73 
75  const std::set<std::string> &capabilities)
76 {
77  psRequested = false;
78  psAsHepMC = false;
79  for(std::set<std::string>::const_iterator iter = capabilities.begin();
80  iter != capabilities.end(); ++iter) {
81  if (*iter == "hepmc")
82  psAsHepMC = true;
83  else if (*iter == "psFinalState")
84  psRequested = true;
85  else if (*iter == "matchSummary")
86  /* nothing */;
87  else if (!this->capabilities().count(*iter))
88  throw cms::Exception("Generator|LHEInterface")
89  << "JetMatching expected capability \""
90  << *iter << "\", but hadronizer does not "
91  "support it." << std::endl;
92  }
93 }
94 
95 std::auto_ptr<Hadronisation> Hadronisation::create(
96  const edm::ParameterSet &params)
97 {
98  std::string name = params.getParameter<std::string>("generator");
99 
100  if (name == "None")
101  return std::auto_ptr<Hadronisation>(
102  new NoHadronisation(params));
103 
104  std::auto_ptr<Hadronisation> plugin(
105  Factory::get()->create(name + "Hadronisation", params));
106 
107  if (!plugin.get())
108  throw cms::Exception("InvalidGenerator")
109  << "Unknown MC generator \"" << name << "\""
110  " specified for hadronisation in LHEProducer."
111  << std::endl;
112 
113  edm::LogInfo("Generator|LHEInterface")
114  << "Using " << name << " to hadronize LHE input." << std::endl;
115 
116  return plugin;
117 }
118 
119 std::auto_ptr<HepMC::GenEvent> Hadronisation::hadronize()
120 {
121  std::auto_ptr<HepMC::GenEvent> event = this->doHadronisation();
122  if (!event.get())
123  return event;
124 
125  const HepMC::GenVertex *signalVertex = event->signal_process_vertex();
126  if (!signalVertex) {
127  signalVertex = LHEEvent::findSignalVertex(event.get());
128  event->set_signal_process_vertex(
129  const_cast<HepMC::GenVertex*>(signalVertex));
130  }
131 
132  return event;
133 }
134 
135 void Hadronisation::newRunInfo(const boost::shared_ptr<LHERunInfo> &runInfo)
136 {
137 }
138 
140  const boost::shared_ptr<HepMC::GenEvent> &event)
141 {
142  if (event.get()) {
143  const HepMC::GenVertex *signalVertex =
144  event->signal_process_vertex();
145  if (!signalVertex) {
146  signalVertex = LHEEvent::findSignalVertex(event.get(), false);
147  event->set_signal_process_vertex(
148  const_cast<HepMC::GenVertex*>(signalVertex));
149  }
150  }
151 
152  return sigShower.emit(event);
153 }
154 
155 } // namespace lhef
T getParameter(std::string const &) const
virtual std::set< std::string > capabilities() const
bool showeredEvent(const boost::shared_ptr< HepMC::GenEvent > &event)
virtual void newRunInfo(const boost::shared_ptr< LHERunInfo > &runInfo)
virtual std::auto_ptr< HepMC::GenEvent > doHadronisation()=0
Hadronisation(const edm::ParameterSet &params)
tuple plugin
Definition: pfTaus_cff.py:103
const boost::shared_ptr< LHEEvent > & getRawEvent() const
Definition: Hadronisation.h:59
virtual void matchingCapabilities(const std::set< std::string > &capabilities)
std::auto_ptr< HepMC::GenEvent > hadronize()
virtual ~Hadronisation()
boost::shared_ptr< LHEEvent > rawEvent
Definition: Hadronisation.h:72
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
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
static std::auto_ptr< Hadronisation > create(const edm::ParameterSet &params)
virtual void doInit()=0
sigc::signal< bool, const boost::shared_ptr< HepMC::GenEvent > & > sigShower
Definition: Hadronisation.h:67
bool setEvent(const boost::shared_ptr< LHEEvent > &event)
static const HepMC::GenVertex * findSignalVertex(const HepMC::GenEvent *event, bool status3=true)
Definition: LHEEvent.cc:453
T get(const Candidate &c)
Definition: component.h:56