CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
gen::JetMatchingMadgraph Class Reference

#include <JetMatchingMadgraph.h>

Inheritance diagram for gen::JetMatchingMadgraph:
gen::JetMatching

Public Member Functions

 JetMatchingMadgraph (const edm::ParameterSet &params)
 
 ~JetMatchingMadgraph ()
 
- Public Member Functions inherited from gen::JetMatching
const std::vector
< JetPartonMatch > & 
getMatchSummary () const
 
bool isMatchingDone ()
 
 JetMatching (const edm::ParameterSet &params)
 
void resetMatchingStatus ()
 
virtual ~JetMatching ()
 

Private Member Functions

void beforeHadronisation (const lhef::LHEEvent *event)
 
void beforeHadronisationExec ()
 
std::set< std::string > capabilities () const
 
template<typename 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 > &params, 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 > &params, T &param, const std::string &name)
 

Private Attributes

bool eventInitialized
 
bool exclusive
 
std::map< std::string,
std::string > 
mgParams
 
bool runInitialized
 
bool soup
 

Additional Inherited Members

- Static Public Member Functions inherited from gen::JetMatching
static std::auto_ptr< JetMatchingcreate (const edm::ParameterSet &params)
 
- Protected Attributes inherited from gen::JetMatching
bool fMatchingStatus
 
std::vector< JetPartonMatchmatchSummary
 

Detailed Description

Definition at line 9 of file JetMatchingMadgraph.h.

Constructor & Destructor Documentation

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, edm::hlt::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.

125  :
126  JetMatching(params),
127  runInitialized(false)
128 {
129  std::string mode = params.getParameter<std::string>("mode");
130  if (mode == "inclusive") {
131  soup = false;
132  exclusive = false;
133  } else if (mode == "exclusive") {
134  soup = false;
135  exclusive = true;
136  } else if (mode == "auto")
137  soup = true;
138  else
139  throw cms::Exception("Generator|LHEInterface")
140  << "Madgraph jet matching scheme requires \"mode\" "
141  "parameter to be set to either \"inclusive\", "
142  "\"exclusive\" or \"auto\"." << std::endl;
143 
144  memain_.etcjet = 0.;
145  memain_.rclmax = 0.0;
146  memain_.clfact = 0.0;
147  memain_.ktsche = 0.0;
148  memain_.etaclmax = params.getParameter<double>("MEMAIN_etaclmax");
149  memain_.qcut = params.getParameter<double>("MEMAIN_qcut");
150  memain_.minjets = params.getParameter<int>("MEMAIN_minjets");
151  memain_.maxjets = params.getParameter<int>("MEMAIN_maxjets");
152  memain_.showerkt = params.getParameter<double>("MEMAIN_showerkt");
153  memain_.nqmatch = params.getParameter<int>("MEMAIN_nqmatch");
154  outtree_.flag = params.getParameter<int>("outTree_flag");
155  std::string list_excres = params.getParameter<std::string>("MEMAIN_excres");
156  std::vector<std::string> elems;
157  std::stringstream ss(list_excres);
158  std::string item;
159  int index=0;
160  while(std::getline(ss, item, ',')) {
161  elems.push_back(item);
162  memain_.excres[index]=std::atoi(item.c_str());
163  index++;
164  }
166 
167 
168 
169 }
T getParameter(std::string const &) const
struct gen::MEMAIN memain_
JetMatching(const edm::ParameterSet &params)
Definition: JetMatching.cc:18
int mode
Definition: AMPTWrapper.h:139
struct gen::OUTTREE outtree_
gen::JetMatchingMadgraph::~JetMatchingMadgraph ( )

Definition at line 171 of file JetMatchingMadgraph.cc.

172 {
173 }

Member Function Documentation

void gen::JetMatchingMadgraph::beforeHadronisation ( const lhef::LHEEvent event)
privatevirtual

Reimplemented from gen::JetMatching.

Definition at line 291 of file JetMatchingMadgraph.cc.

References indexGen::comments, eventInitialized, edm::hlt::Exception, i, gen::UPPRIV::ickkw, lhef::HEPEUP::NUP, ExpressReco_HICollisions_FallBack::pt, gen::PYPART::ptpart, lhef::HEPEUP::PUP, gen::pypart_, runInitialized, mathSSE::sqrt(), and gen::uppriv_.

292 {
293  if (!runInitialized)
294  throw cms::Exception("Generator|PartonShowerVeto")
295  << "Run not initialized in JetMatchingMadgraph"
296  << std::endl;
297 
298 
299  if (uppriv_.ickkw) {
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++) {
304  double pt;
305  ss >> pt;
306  if (!ss.good())
307  break;
308  pypart_.ptpart[i] = pt;
309  }
310  } else {
311  edm::LogWarning("Generator|LHEInterface")
312  << "Expected exactly one comment line per "
313  "event containing MadGraph parton scale "
314  "information."
315  << std::endl;
316 
317  const lhef::HEPEUP *hepeup = event->getHEPEUP();
318  for(int i = 2; i < hepeup->NUP; i++) {
319  double mt2 =
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];
323  pypart_.ptpart[i - 2] = std::sqrt(mt2);
324  }
325  }
326  }
327 
328  // mgevnt_();
329  eventInitialized = true;
330 }
int i
Definition: DBlmapReader.cc:9
struct gen::UPPRIV uppriv_
struct gen::PYPART pypart_
double ptpart[1000]
T sqrt(T t)
Definition: SSEVec.h:28
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
void gen::JetMatchingMadgraph::beforeHadronisationExec ( )
privatevirtual

Reimplemented from gen::JetMatching.

Definition at line 332 of file JetMatchingMadgraph.cc.

References eventInitialized, and gen::mgevnt_().

333 {
334  mgevnt_();
335  eventInitialized = true;
336  return;
337 }
void mgevnt_(void)
std::set< std::string > gen::JetMatchingMadgraph::capabilities ( ) const
privatevirtual

Reimplemented from gen::JetMatching.

Definition at line 175 of file JetMatchingMadgraph.cc.

References query::result.

176 {
177  std::set<std::string> result;
178  result.insert("psFinalState");
179  result.insert("hepevt");
180  result.insert("pythia6");
181  return result;
182 }
tuple result
Definition: query.py:137
template<typename T >
T gen::JetMatchingMadgraph::getParameter ( const std::map< std::string, std::string > &  params,
const std::string &  var,
const T &  defValue = T() 
)
staticprivate

Definition at line 107 of file JetMatchingMadgraph.cc.

References pos.

Referenced by getParameter(), and updateOrDie().

110 {
111  std::map<std::string, std::string>::const_iterator pos =
112  params.find(var);
113  if (pos == params.end())
114  return defValue;
115  return parseParameter<T>(pos->second);
116 }
template<typename T >
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.

121 {
122  return getParameter(mgParams, var, defValue);
123 }
static T getParameter(const std::map< std::string, std::string > &params, const std::string &var, const T &defValue=T())
std::map< std::string, std::string > mgParams
void gen::JetMatchingMadgraph::init ( const lhef::LHERunInfo runInfo)
privatevirtual

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, ExpressReco_HICollisions_FallBack::parameters, gen::parseHeader(), gen::MEMAIN::qcut, runInitialized, gen::MEMAIN::showerkt, updateOrDie(), gen::uppriv_, and makeHLTPrescaleTable::values.

233 {
234  // read MadGraph run card
235 
236  std::map<std::string, std::string> parameters;
237 
238  std::vector<std::string> header = runInfo->findHeader("MGRunCard");
239  if (header.empty())
240  throw cms::Exception("Generator|PartonShowerVeto")
241  << "In order to use MadGraph jet matching, "
242  "the input file has to contain the corresponding "
243  "MadGraph headers." << std::endl;
244 
245  mgParams = parseHeader(header);
246 
247  // set variables in common block
248 
249  std::vector<Param> params;
250  std::vector<Param> values;
251  for(std::map<std::string, std::string>::const_iterator iter =
252  mgParams.begin(); iter != mgParams.end(); ++iter) {
253  params.push_back(" " + iter->first);
254  values.push_back(iter->second);
255 
256  }
257 
258  // set MG matching parameters
259 
260  uppriv_.ickkw = getParameter<int>("ickkw", 0);
261  memain_.mektsc = getParameter<int>("ktscheme", 0);
262 
263  header = runInfo->findHeader("MGParamCMS");
264 
265  std::map<std::string, std::string> mgInfoCMS = parseHeader(header);
266 
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;
270 
271  }
272 
273 
274  updateOrDie(mgInfoCMS, memain_.etaclmax, "etaclmax");
275  updateOrDie(mgInfoCMS, memain_.qcut, "qcut");
276  updateOrDie(mgInfoCMS, memain_.minjets, "minjets");
277  updateOrDie(mgInfoCMS, memain_.maxjets, "maxjets");
278  updateOrDie(mgInfoCMS, memain_.showerkt, "showerkt");
279  updateOrDie(mgInfoCMS, memain_.nqmatch, "nqmatch");
280 
281  // run Fortran initialization code
282 
283  int nparam = params.size();
284  mginit_(&nparam, &params.front(), &values.front());
285  runInitialized = true;
286 }
struct gen::UPPRIV uppriv_
static void updateOrDie(const std::map< std::string, std::string > &params, T &param, const std::string &name)
struct gen::MEMAIN memain_
static std::map< std::string, std::string > parseHeader(const std::vector< std::string > &header)
std::map< std::string, std::string > mgParams
void mginit_(int *npara, Param *params, Param *values)
tuple cout
Definition: gather_cfg.py:41
std::vector< std::string > findHeader(const std::string &tag) const
Definition: LHERunInfo.cc:390
int gen::JetMatchingMadgraph::match ( const HepMC::GenEvent *  partonLevel,
const HepMC::GenEvent *  finalState,
bool  showeredFinalState 
)
privatevirtual

Implements gen::JetMatching.

Definition at line 339 of file JetMatchingMadgraph.cc.

References eventInitialized, edm::hlt::Exception, exclusive, gen::JetMatching::fMatchingStatus, gen::MEMAEV::iexc, gen::MEMAIN::maxjets, gen::memaev_, gen::memain_, gen::mgveto_(), gen::MEMAEV::nljets, runInitialized, and soup.

342 {
343  if (!showeredFinalState)
344  throw cms::Exception("Generator|LHEInterface")
345  << "MadGraph matching expected parton shower "
346  "final state." << std::endl;
347 
348  if (!runInitialized)
349  throw cms::Exception("Generator|LHEInterface")
350  << "Run not initialized in JetMatchingMadgraph"
351  << std::endl;
352 
353  if (!eventInitialized)
354  throw cms::Exception("Generator|LHEInterface")
355  << "Event not initialized in JetMatchingMadgraph"
356  << std::endl;
357 
358  if (soup)
360  else
362 
363  int veto = 0;
364  mgveto_(&veto);
365  fMatchingStatus=true;
366  eventInitialized = false;
367 
368  return veto;
369 }
struct gen::MEMAEV memaev_
struct gen::MEMAIN memain_
void mgveto_(int *veto)
template<typename T >
T gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)
staticprivate

Definition at line 77 of file JetMatchingMadgraph.cc.

References query::result.

78 {
79  std::istringstream ss(value);
80  T result;
81  ss >> result;
82  return result;
83 }
tuple result
Definition: query.py:137
template<typename T >
void gen::JetMatchingMadgraph::updateOrDie ( const std::map< std::string, std::string > &  params,
T &  param,
const std::string &  name 
)
staticprivate

Definition at line 215 of file JetMatchingMadgraph.cc.

References edm::hlt::Exception, and getParameter().

Referenced by init().

218 {
219  if (param < 0){
220  param = getParameter(params, name, param);
221  }
222  if (param < 0)
223  throw cms::Exception("Generator|PartonShowerVeto")
224  << "The MGParamCMS header does not specify the jet "
225  "matching parameter \"" << name << "\", but it "
226  "is requested by the CMSSW configuration."
227  << std::endl;
228 }
static T getParameter(const std::map< std::string, std::string > &params, const std::string &var, const T &defValue=T())

Member Data Documentation

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().