#include <JetMatchingMadgraph.h>
Public Member Functions | |
JetMatchingMadgraph (const edm::ParameterSet ¶ms) | |
~JetMatchingMadgraph () | |
Private Member Functions | |
void | beforeHadronisation (const lhef::LHEEvent *event) |
void | beforeHadronisationExec () |
std::set< std::string > | capabilities () const |
template<typename T > | |
T | getParameter (const std::string &var, const T &defValue=T()) const |
void | init (const lhef::LHERunInfo *runInfo) |
int | match (const HepMC::GenEvent *partonLevel, const HepMC::GenEvent *finalState, bool showeredFinalState) |
Static Private Member Functions | |
template<typename T > | |
static T | getParameter (const std::map< std::string, std::string > ¶ms, const std::string &var, const T &defValue=T()) |
template<typename T > | |
static T | parseParameter (const std::string &value) |
template<typename T > | |
static void | updateOrDie (const std::map< std::string, std::string > ¶ms, T ¶m, const std::string &name) |
Private Attributes | |
bool | eventInitialized |
bool | exclusive |
std::map< std::string, std::string > | mgParams |
bool | runInitialized |
bool | soup |
Definition at line 9 of file JetMatchingMadgraph.h.
gen::JetMatchingMadgraph::JetMatchingMadgraph | ( | const edm::ParameterSet & | params | ) |
Definition at line 125 of file JetMatchingMadgraph.cc.
References gen::MEMAIN::clfact, gen::MEMAIN::etaclmax, gen::MEMAIN::etcjet, Exception, exclusive, gen::MEMAIN::excres, gen::OUTTREE::flag, edm::ParameterSet::getParameter(), getHLTprescales::index, gen::MEMAIN::ktsche, gen::MEMAIN::maxjets, gen::memain_, gen::MEMAIN::minjets, mode, gen::MEMAIN::nexcres, gen::MEMAIN::nqmatch, gen::outtree_, gen::MEMAIN::qcut, gen::MEMAIN::rclmax, gen::MEMAIN::showerkt, and soup.
: JetMatching(params), runInitialized(false) { std::string mode = params.getParameter<std::string>("mode"); if (mode == "inclusive") { soup = false; exclusive = false; } else if (mode == "exclusive") { soup = false; exclusive = true; } else if (mode == "auto") soup = true; else throw cms::Exception("Generator|LHEInterface") << "Madgraph jet matching scheme requires \"mode\" " "parameter to be set to either \"inclusive\", " "\"exclusive\" or \"auto\"." << std::endl; memain_.etcjet = 0.; memain_.rclmax = 0.0; memain_.clfact = 0.0; memain_.ktsche = 0.0; memain_.etaclmax = params.getParameter<double>("MEMAIN_etaclmax"); memain_.qcut = params.getParameter<double>("MEMAIN_qcut"); memain_.minjets = params.getParameter<int>("MEMAIN_minjets"); memain_.maxjets = params.getParameter<int>("MEMAIN_maxjets"); memain_.showerkt = params.getParameter<double>("MEMAIN_showerkt"); memain_.nqmatch = params.getParameter<int>("MEMAIN_nqmatch"); outtree_.flag = params.getParameter<int>("outTree_flag"); std::string list_excres = params.getParameter<std::string>("MEMAIN_excres"); std::vector<std::string> elems; std::stringstream ss(list_excres); std::string item; int index=0; while(std::getline(ss, item, ',')) { elems.push_back(item); memain_.excres[index]=std::atoi(item.c_str()); index++; } memain_.nexcres=index; }
gen::JetMatchingMadgraph::~JetMatchingMadgraph | ( | ) |
Definition at line 171 of file JetMatchingMadgraph.cc.
{ }
void gen::JetMatchingMadgraph::beforeHadronisation | ( | const lhef::LHEEvent * | event | ) | [private, virtual] |
Reimplemented from gen::JetMatching.
Definition at line 291 of file JetMatchingMadgraph.cc.
References indexGen::comments, eventInitialized, Exception, i, gen::UPPRIV::ickkw, lhef::HEPEUP::NUP, gen::PYPART::ptpart, lhef::HEPEUP::PUP, gen::pypart_, runInitialized, mathSSE::sqrt(), and gen::uppriv_.
{ if (!runInitialized) throw cms::Exception("Generator|PartonShowerVeto") << "Run not initialized in JetMatchingMadgraph" << std::endl; if (uppriv_.ickkw) { std::vector<std::string> comments = event->getComments(); if (comments.size() == 1) { std::istringstream ss(comments[0].substr(1)); for(int i = 0; i < 1000; i++) { double pt; ss >> pt; if (!ss.good()) break; pypart_.ptpart[i] = pt; } } else { edm::LogWarning("Generator|LHEInterface") << "Expected exactly one comment line per " "event containing MadGraph parton scale " "information." << std::endl; const lhef::HEPEUP *hepeup = event->getHEPEUP(); for(int i = 2; i < hepeup->NUP; i++) { double mt2 = hepeup->PUP[i][0] * hepeup->PUP[i][0] + hepeup->PUP[i][1] * hepeup->PUP[i][1] + hepeup->PUP[i][4] * hepeup->PUP[i][4]; pypart_.ptpart[i - 2] = std::sqrt(mt2); } } } // mgevnt_(); eventInitialized = true; }
void gen::JetMatchingMadgraph::beforeHadronisationExec | ( | ) | [private, virtual] |
Reimplemented from gen::JetMatching.
Definition at line 332 of file JetMatchingMadgraph.cc.
References eventInitialized, and gen::mgevnt_().
{ mgevnt_(); eventInitialized = true; return; }
std::set< std::string > gen::JetMatchingMadgraph::capabilities | ( | ) | const [private, virtual] |
Reimplemented from gen::JetMatching.
Definition at line 175 of file JetMatchingMadgraph.cc.
References query::result.
T gen::JetMatchingMadgraph::getParameter | ( | const std::string & | var, |
const T & | defValue = T() |
||
) | const [private] |
Definition at line 119 of file JetMatchingMadgraph.cc.
References getParameter(), and mgParams.
{ return getParameter(mgParams, var, defValue); }
T gen::JetMatchingMadgraph::getParameter | ( | const std::map< std::string, std::string > & | params, |
const std::string & | var, | ||
const T & | defValue = T() |
||
) | [static, private] |
Definition at line 107 of file JetMatchingMadgraph.cc.
References pos.
Referenced by getParameter(), and updateOrDie().
{ std::map<std::string, std::string>::const_iterator pos = params.find(var); if (pos == params.end()) return defValue; return parseParameter<T>(pos->second); }
void gen::JetMatchingMadgraph::init | ( | const lhef::LHERunInfo * | runInfo | ) | [private, virtual] |
Reimplemented from gen::JetMatching.
Definition at line 232 of file JetMatchingMadgraph.cc.
References gather_cfg::cout, gen::MEMAIN::etaclmax, lhef::LHERunInfo::findHeader(), gen::UPPRIV::ickkw, gen::MEMAIN::maxjets, gen::MEMAIN::mektsc, gen::memain_, gen::mginit_(), mgParams, gen::MEMAIN::minjets, gen::MEMAIN::nqmatch, Parameters::parameters, gen::parseHeader(), gen::MEMAIN::qcut, runInitialized, gen::MEMAIN::showerkt, updateOrDie(), gen::uppriv_, and makeHLTPrescaleTable::values.
{ // read MadGraph run card std::map<std::string, std::string> parameters; std::vector<std::string> header = runInfo->findHeader("MGRunCard"); if (header.empty()) throw cms::Exception("Generator|PartonShowerVeto") << "In order to use MadGraph jet matching, " "the input file has to contain the corresponding " "MadGraph headers." << std::endl; mgParams = parseHeader(header); // set variables in common block std::vector<Param> params; std::vector<Param> values; for(std::map<std::string, std::string>::const_iterator iter = mgParams.begin(); iter != mgParams.end(); ++iter) { params.push_back(" " + iter->first); values.push_back(iter->second); } // set MG matching parameters uppriv_.ickkw = getParameter<int>("ickkw", 0); memain_.mektsc = getParameter<int>("ktscheme", 0); header = runInfo->findHeader("MGParamCMS"); std::map<std::string, std::string> mgInfoCMS = parseHeader(header); for(std::map<std::string, std::string>::const_iterator iter = mgInfoCMS.begin(); iter != mgInfoCMS.end(); ++iter) { std::cout<<"mgInfoCMS: "<<iter->first<<" "<<iter->second<<std::endl; } updateOrDie(mgInfoCMS, memain_.etaclmax, "etaclmax"); updateOrDie(mgInfoCMS, memain_.qcut, "qcut"); updateOrDie(mgInfoCMS, memain_.minjets, "minjets"); updateOrDie(mgInfoCMS, memain_.maxjets, "maxjets"); updateOrDie(mgInfoCMS, memain_.showerkt, "showerkt"); updateOrDie(mgInfoCMS, memain_.nqmatch, "nqmatch"); // run Fortran initialization code int nparam = params.size(); mginit_(&nparam, ¶ms.front(), &values.front()); runInitialized = true; }
int gen::JetMatchingMadgraph::match | ( | const HepMC::GenEvent * | partonLevel, |
const HepMC::GenEvent * | finalState, | ||
bool | showeredFinalState | ||
) | [private, virtual] |
Implements gen::JetMatching.
Definition at line 339 of file JetMatchingMadgraph.cc.
References eventInitialized, Exception, exclusive, gen::JetMatching::fMatchingStatus, gen::MEMAEV::iexc, gen::MEMAIN::maxjets, gen::memaev_, gen::memain_, gen::mgveto_(), gen::MEMAEV::nljets, runInitialized, and soup.
{ if (!showeredFinalState) throw cms::Exception("Generator|LHEInterface") << "MadGraph matching expected parton shower " "final state." << std::endl; if (!runInitialized) throw cms::Exception("Generator|LHEInterface") << "Run not initialized in JetMatchingMadgraph" << std::endl; if (!eventInitialized) throw cms::Exception("Generator|LHEInterface") << "Event not initialized in JetMatchingMadgraph" << std::endl; if (soup) memaev_.iexc = (memaev_.nljets < memain_.maxjets); else memaev_.iexc = exclusive; int veto = 0; mgveto_(&veto); fMatchingStatus=true; eventInitialized = false; return veto; }
bool gen::JetMatchingMadgraph::parseParameter | ( | const std::string & | value | ) | [static, private] |
Definition at line 77 of file JetMatchingMadgraph.cc.
References query::result.
void gen::JetMatchingMadgraph::updateOrDie | ( | const std::map< std::string, std::string > & | params, |
T & | param, | ||
const std::string & | name | ||
) | [static, private] |
Definition at line 215 of file JetMatchingMadgraph.cc.
References Exception, and getParameter().
Referenced by init().
{ if (param < 0){ param = getParameter(params, name, param); } if (param < 0) throw cms::Exception("Generator|PartonShowerVeto") << "The MGParamCMS header does not specify the jet " "matching parameter \"" << name << "\", but it " "is requested by the CMSSW configuration." << std::endl; }
bool gen::JetMatchingMadgraph::eventInitialized [private] |
Definition at line 41 of file JetMatchingMadgraph.h.
Referenced by beforeHadronisation(), beforeHadronisationExec(), and match().
bool gen::JetMatchingMadgraph::exclusive [private] |
Definition at line 43 of file JetMatchingMadgraph.h.
Referenced by JetMatchingMadgraph(), and match().
std::map<std::string, std::string> gen::JetMatchingMadgraph::mgParams [private] |
Definition at line 38 of file JetMatchingMadgraph.h.
Referenced by getParameter(), and init().
bool gen::JetMatchingMadgraph::runInitialized [private] |
Definition at line 40 of file JetMatchingMadgraph.h.
Referenced by beforeHadronisation(), init(), and match().
bool gen::JetMatchingMadgraph::soup [private] |
Definition at line 42 of file JetMatchingMadgraph.h.
Referenced by JetMatchingMadgraph(), and match().