12 #include <boost/shared_ptr.hpp>
13 #include <boost/algorithm/string/trim.hpp>
15 #include <HepMC/GenEvent.h>
30 Param(
const std::string &str)
34 std::memcpy(
value, str.c_str(), len);
41 extern void mginit_(
int *npara, Param *params, Param *
values);
74 void init(
const boost::shared_ptr<LHERunInfo> &runInfo);
77 double match(
const HepMC::GenEvent *partonLevel,
78 const HepMC::GenEvent *finalState,
79 bool showeredFinalState);
99 std::istringstream ss(value);
109 if (!result.empty() && result[0] ==
'\'')
110 result = result.substr(1);
111 if (!result.empty() && result[result.length() - 1] ==
'\'')
112 result.resize(result.length() - 1);
119 std::string
value(value_);
121 value.begin(), (int(*)(int))std::toupper);
122 return value ==
"T" || value ==
"Y" ||
123 value ==
"1" || value ==
".TRUE.";
128 const T &defValue)
const
130 std::map<std::string, std::string>::const_iterator
pos =
134 return parseParameter<T>(pos->second);
139 using namespace lhef;
143 runInitialized(
false)
146 if (mode ==
"inclusive") {
149 }
else if (mode ==
"exclusive") {
152 }
else if (mode ==
"auto")
156 <<
"Madgraph jet matching scheme requires \"mode\" "
157 "parameter to be set to either \"inclusive\", "
158 "\"exclusive\" or \"auto\"." << std::endl;
177 std::set<std::string>
result;
178 result.insert(
"psFinalState");
179 result.insert(
"hepevt");
180 result.insert(
"pythia6");
190 std::map<std::string, std::string>
parameters;
192 std::vector<std::string>
header = runInfo->findHeader(
"MGRunCard");
195 <<
"In order to use MadGraph jet matching, "
196 "the input file has to contain the corresponding "
197 "MadGraph headers." << std::endl;
200 for(std::vector<std::string>::const_iterator iter = header.begin();
201 iter != header.end(); ++iter) {
202 std::string
line = *iter;
203 if (line.empty() || line[0] ==
'#')
207 if (pos != std::string::npos)
210 pos = line.find(
'=');
211 if (pos == std::string::npos)
215 boost::algorithm::trim_copy(line.substr(pos + 1));
217 boost::algorithm::trim_copy(line.substr(0, pos));
224 std::vector<Param> params;
225 std::vector<Param>
values;
226 for(std::map<std::string, std::string>::const_iterator iter =
228 params.push_back(
" " + iter->first);
229 values.push_back(iter->second);
239 int nparam = params.size();
240 mginit_(&nparam, ¶ms.front(), &values.front());
245 const boost::shared_ptr<LHEEvent> &
event)
249 <<
"Run not initialized in JetMatchingMadgraph"
253 std::vector<std::string>
comments =
event->getComments();
254 if (comments.size() == 1) {
255 std::istringstream ss(comments[0].substr(1));
256 for(
int i = 0;
i < 1000;
i++) {
265 <<
"Expected exactly one comment line per "
266 "event containing MadGraph parton scale "
270 const HEPEUP *hepeup =
event->getHEPEUP();
271 for(
int i = 2;
i < hepeup->
NUP;
i++) {
273 hepeup->
PUP[
i][0] * hepeup->
PUP[
i][0] +
274 hepeup->
PUP[
i][1] * hepeup->
PUP[
i][1] +
275 hepeup->
PUP[
i][4] * hepeup->
PUP[
i][4];
286 const HepMC::GenEvent *finalState,
287 bool showeredFinalState)
289 if (!showeredFinalState)
291 <<
"MadGraph matching expected parton shower "
292 "final state." << std::endl;
296 <<
"Run not initialized in JetMatchingMadgraph"
301 <<
"Event not initialized in JetMatchingMadgraph"
313 return veto ? 0.0 : 1.0;
struct lhef::MEMAEV memaev_
T getParameter(std::string const &) const
struct lhef::UPPRIV uppriv_
static T parseParameter(const std::string &value)
void beforeHadronisation(const boost::shared_ptr< LHEEvent > &event)
void mginit_(int *npara, Param *params, Param *values)
struct lhef::PYPART pypart_
std::vector< FiveVector > PUP
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
struct lhef::MEMAIN memain_
JetMatchingMadgraph(const edm::ParameterSet ¶ms)
double match(const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState)
T getParameter(const std::string &var, const T &defValue=T()) const
#define DEFINE_LHE_JETMATCHING_PLUGIN(T)
std::set< std::string > capabilities() const
std::map< std::string, std::string > mgParams
void init(const boost::shared_ptr< LHERunInfo > &runInfo)