10 #include <boost/algorithm/string/trim.hpp> 21 std::memcpy(
value,
str.c_str(), len);
29 extern struct UPPRIV {
35 extern struct MEMAIN {
43 extern struct OUTTREE {
77 std::map<std::string, std::string>::const_iterator
pos =
params.find(
var);
80 return parseParameter<T>(
pos->second);
88 static std::map<std::string, std::string>
parseHeader(
const std::vector<std::string> &
header) {
89 std::map<std::string, std::string>
params;
91 for (std::vector<std::string>::const_iterator iter =
header.begin(); iter !=
header.end(); ++iter) {
97 if (
pos != std::string::npos)
101 if (
pos == std::string::npos)
113 template <
typename T>
121 throw cms::Exception(
"Generator|PartonShowerVeto") <<
"The MGParamCMS header does not specify the jet " 122 "matching parameter \"" 125 "is requested by the CMSSW configuration." 132 if (
mode ==
"inclusive") {
135 }
else if (
mode ==
"exclusive") {
138 }
else if (
mode ==
"auto")
141 throw cms::Exception(
"Generator|LHEInterface") <<
"MGFastJet jet matching scheme requires \"mode\" " 142 "parameter to be set to either \"inclusive\", " 143 "\"exclusive\" or \"auto\"." 158 std::vector<std::string> elems;
159 std::stringstream
ss(list_excres);
162 while (std::getline(
ss,
item,
',')) {
163 elems.push_back(
item);
217 throw cms::Exception(
"Generator|PartonShowerVeto") <<
"Run not initialized in JetMatchingMGFastJet" << std::endl;
219 for (
int i = 0;
i < 3;
i++) {
231 for (
int i = 0;
i < hepeup.
NUP;
i++) {
252 int NPartons =
typeIdx[0].size();
266 std::map<std::string, std::string>
parameters;
268 std::vector<std::string>
header =
runInfo->findHeader(
"MGRunCard");
270 throw cms::Exception(
"Generator|PartonShowerVeto") <<
"In order to use MGFastJet jet matching, " 271 "the input file has to contain the corresponding " 279 std::vector<Param>
params;
280 std::vector<Param>
values;
281 for (std::map<std::string, std::string>::const_iterator iter =
mgParams.begin(); iter !=
mgParams.end(); ++iter) {
282 params.push_back(
" " + iter->first);
283 values.push_back(iter->second);
295 for (std::map<std::string, std::string>::const_iterator iter = mgInfoCMS.begin(); iter != mgInfoCMS.end(); ++iter) {
296 std::cout <<
"mgInfoCMS: " << iter->first <<
" " << iter->second << std::endl;
318 int NPartons =
typeIdx[0].size();
323 int ClusSeqNJets = 0;
325 fastjet::ClusterSequence ClusSequence(*jetInput, *
fJetFinder);
335 if (ClusSeqNJets < NPartons)
338 double localQcutSq =
qCutSq;
342 if (ClusSeqNJets > NPartons)
348 fClusJets = ClusSequence.exclusive_jets(NPartons);
349 ClusSeqNJets = NPartons;
355 std::vector<fastjet::PseudoJet> MatchingInput;
357 std::vector<bool> jetAssigned;
358 jetAssigned.assign(
fClusJets.size(),
false);
365 MatchingInput.clear();
367 for (
int i = 0;
i < ClusSeqNJets;
i++) {
377 MatchingInput.push_back(fastjet::PseudoJet(exjet.px(), exjet.py(), exjet.pz(), exjet.e()));
378 MatchingInput.back().set_user_index(
i);
382 MatchingInput.push_back(
388 int NBefore = MatchingInput.size();
397 fastjet::ClusterSequence ClusSeq(MatchingInput, *
fJetFinder);
399 const std::vector<fastjet::PseudoJet> &
output = ClusSeq.jets();
400 int NClusJets =
output.size() - NBefore;
414 if (NClusJets >= NBefore) {
426 const std::vector<fastjet::ClusterSequence::history_element> &history = ClusSeq.history();
429 for (
unsigned int i = NBefore;
i <
output.size();
i++) {
430 int hidx =
output[
i].cluster_sequence_history_index();
431 double dNext = history[hidx].dij;
432 if (dNext < localQcutSq) {
437 int parent1 = history[hidx].parent1;
438 int parent2 = history[hidx].parent2;
439 if (parent1 < 0 || parent2 < 0)
444 int pidx = MatchingInput[parent1].user_index();
445 jetAssigned[pidx] =
true;
463 std::vector<double> MergingScale;
464 MergingScale.clear();
465 for (
int nj = 0; nj < 4; nj++) {
466 double dmscale2 = ClusSequence.exclusive_dmerge(nj);
467 double dmscale =
sqrt(dmscale2);
468 MergingScale.push_back(dmscale);
470 fDJROutput.open(
"events.tree", std::ios_base::app);
471 double dNJets = (double)NPartons;
472 fDJROutput <<
" " << dNJets <<
" " << MergingScale[0] <<
" " << MergingScale[1] <<
" " << MergingScale[2] <<
" " 473 << MergingScale[3] << std::endl;
struct gen::OUTTREE outtree_
struct gen::MEMAIN memain_
fastjet::JetDefinition * fJetFinder
JetMatchingMGFastJet(const edm::ParameterSet ¶ms)
double getJetEtaMax() const override
static T getParameter(const std::map< std::string, std::string > ¶ms, const std::string &var, const T &defValue=T())
static void updateOrDie(const std::map< std::string, std::string > ¶ms, T ¶m, const std::string &name)
void beforeHadronisation(const lhef::LHEEvent *) override
int match(const lhef::LHEEvent *partonLevel, const std::vector< fastjet::PseudoJet > *jetInput) override
std::vector< FiveVector > PUP
Abs< T >::type abs(const T &t)
bool initAfterBeams() override
std::vector< std::pair< int, int > > MOTHUP
static std::map< std::string, std::string > parseHeader(const std::vector< std::string > &header)
std::vector< fastjet::PseudoJet > fClusJets
static T parseParameter(const std::string &value)
std::vector< fastjet::PseudoJet > fPtSortedJets
std::map< std::string, std::string > mgParams
const HEPEUP * getHEPEUP() const
void init(const lhef::LHERunInfo *runInfo) override
static std::atomic< unsigned int > counter
struct gen::UPPRIV uppriv_
std::vector< int > typeIdx[3]