13 #include <boost/shared_ptr.hpp>
14 #include <boost/algorithm/string/trim.hpp>
16 #include <HepMC/GenEvent.h>
31 Param(
const std::string &str)
35 std::memcpy(
value, str.c_str(), len);
79 std::istringstream ss(value);
89 if (!result.empty() && result[0] ==
'\'')
90 result = result.substr(1);
91 if (!result.empty() && result[result.length() - 1] ==
'\'')
92 result.resize(result.length() - 1);
99 std::string
value(value_);
101 value.begin(), (int(*)(int))std::toupper);
102 return value ==
"T" || value ==
"Y" || value==
"True" ||
103 value ==
"1" || value ==
".TRUE.";
108 const std::map<std::string, std::string> ¶ms,
109 const std::string &var,
const T &defValue)
111 std::map<std::string, std::string>::const_iterator
pos =
113 if (pos == params.end())
115 return parseParameter<T>(pos->second);
120 const T &defValue)
const
127 runInitialized(
false)
130 if (mode ==
"inclusive") {
133 }
else if (mode ==
"exclusive") {
136 }
else if (mode ==
"auto")
140 <<
"Madgraph jet matching scheme requires \"mode\" "
141 "parameter to be set to either \"inclusive\", "
142 "\"exclusive\" or \"auto\"." << std::endl;
155 std::string list_excres = params.
getParameter<std::string>(
"MEMAIN_excres");
156 std::vector<std::string> elems;
157 std::stringstream ss(list_excres);
160 while(std::getline(ss, item,
',')) {
161 elems.push_back(item);
177 std::set<std::string>
result;
178 result.insert(
"psFinalState");
179 result.insert(
"hepevt");
180 result.insert(
"pythia6");
184 static std::map<std::string, std::string>
187 std::map<std::string, std::string> params;
189 for(std::vector<std::string>::const_iterator iter = header.begin();
190 iter != header.end(); ++iter) {
191 std::string
line = *iter;
192 if (line.empty() || line[0] ==
'#')
196 if (pos != std::string::npos)
199 pos = line.find(
'=');
200 if (pos == std::string::npos)
204 boost::algorithm::trim_copy(line.substr(pos + 1));
206 boost::algorithm::trim_copy(line.substr(0, pos));
216 const std::map<std::string, std::string> ¶ms,
217 T ¶m,
const std::string &
name)
224 <<
"The MGParamCMS header does not specify the jet "
225 "matching parameter \"" << name <<
"\", but it "
226 "is requested by the CMSSW configuration."
236 std::map<std::string, std::string>
parameters;
241 <<
"In order to use MadGraph jet matching, "
242 "the input file has to contain the corresponding "
243 "MadGraph headers." << std::endl;
249 std::vector<Param> params;
250 std::vector<Param>
values;
251 for(std::map<std::string, std::string>::const_iterator iter =
253 params.push_back(
" " + iter->first);
254 values.push_back(iter->second);
265 std::map<std::string, std::string> mgInfoCMS =
parseHeader(header);
267 for(std::map<std::string, std::string>::const_iterator iter =
268 mgInfoCMS.begin(); iter != mgInfoCMS.end(); ++iter) {
269 std::cout<<
"mgInfoCMS: "<<iter->first<<
" "<<iter->second<<std::endl;
283 int nparam = params.size();
284 mginit_(&nparam, ¶ms.front(), &values.front());
295 <<
"Run not initialized in JetMatchingMadgraph"
300 std::vector<std::string>
comments =
event->getComments();
301 if (comments.size() == 1) {
302 std::istringstream ss(comments[0].substr(1));
303 for(
int i = 0;
i < 1000;
i++) {
312 <<
"Expected exactly one comment line per "
313 "event containing MadGraph parton scale "
318 for(
int i = 2;
i < hepeup->
NUP;
i++) {
320 hepeup->
PUP[
i][0] * hepeup->
PUP[
i][0] +
321 hepeup->
PUP[
i][1] * hepeup->
PUP[
i][1] +
322 hepeup->
PUP[
i][4] * hepeup->
PUP[
i][4];
340 const HepMC::GenEvent *finalState,
341 bool showeredFinalState)
343 if (!showeredFinalState)
345 <<
"MadGraph matching expected parton shower "
346 "final state." << std::endl;
350 <<
"Run not initialized in JetMatchingMadgraph"
355 <<
"Event not initialized in JetMatchingMadgraph"
T getParameter(std::string const &) const
struct gen::MEMAEV memaev_
struct gen::UPPRIV uppriv_
void init(const lhef::LHERunInfo *runInfo)
struct gen::PYPART pypart_
void beforeHadronisation(const lhef::LHEEvent *event)
static T parseParameter(const std::string &value)
static void updateOrDie(const std::map< std::string, std::string > ¶ms, T ¶m, const std::string &name)
static T getParameter(const std::map< std::string, std::string > ¶ms, const std::string &var, const T &defValue=T())
std::vector< FiveVector > PUP
int match(const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState)
struct gen::MEMAIN memain_
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::map< std::string, std::string > parseHeader(const std::vector< std::string > &header)
JetMatchingMadgraph(const edm::ParameterSet ¶ms)
std::map< std::string, std::string > mgParams
void mginit_(int *npara, Param *params, Param *values)
std::set< std::string > capabilities() const
void beforeHadronisationExec()
std::vector< std::string > findHeader(const std::string &tag) const
struct gen::OUTTREE outtree_