CMS 3D CMS Logo

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

#include <JetMatchingMadgraph.h>

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

Public Member Functions

 JetMatchingMadgraph (const edm::ParameterSet &params)
 
template<>
std::string parseParameter (const std::string &value)
 
template<>
bool parseParameter (const std::string &value_)
 
 ~JetMatchingMadgraph ()
 
- Public Member Functions inherited from gen::JetMatching
virtual const std::vector< int > * getPartonList ()
 
virtual bool initAfterBeams ()
 
bool isMatchingDone ()
 
 JetMatching (const edm::ParameterSet &params)
 
void resetMatchingStatus ()
 
virtual ~JetMatching ()
 

Protected Member Functions

virtual void beforeHadronisation (const lhef::LHEEvent *event)
 
virtual void beforeHadronisationExec ()
 
std::set< std::string > capabilities () const
 
virtual double getJetEtaMax () const
 
template<typename T >
T getParameter (const std::string &var, const T &defValue=T()) const
 
virtual void init (const lhef::LHERunInfo *runInfo)
 
virtual int match (const lhef::LHEEvent *partonLevel, const std::vector< fastjet::PseudoJet > *jetInput)
 

Static Protected 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)
 

Protected Attributes

bool eventInitialized
 
bool exclusive
 
std::map< std::string,
std::string > 
mgParams
 
bool runInitialized
 
bool soup
 
- Protected Attributes inherited from gen::JetMatching
bool fMatchingStatus
 

Additional Inherited Members

- Static Public Member Functions inherited from gen::JetMatching
static std::auto_ptr< JetMatchingcreate (const edm::ParameterSet &params)
 

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(), cmsHarvester::index, gen::MEMAIN::ktsche, gen::MEMAIN::maxjets, gen::memain_, gen::MEMAIN::minjets, alignBH_cfg::mode, gen::MEMAIN::nexcres, gen::MEMAIN::nqmatch, gen::outtree_, gen::MEMAIN::qcut, gen::MEMAIN::rclmax, gen::MEMAIN::showerkt, soup, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

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::OUTTREE outtree_
struct gen::MEMAIN memain_
JetMatching(const edm::ParameterSet &params)
Definition: JetMatching.cc:18
gen::JetMatchingMadgraph::~JetMatchingMadgraph ( )

Definition at line 171 of file JetMatchingMadgraph.cc.

172 {
173 }

Member Function Documentation

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

Reimplemented from gen::JetMatching.

Definition at line 296 of file JetMatchingMadgraph.cc.

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

297 {
298  if (!runInitialized)
299  throw cms::Exception("Generator|PartonShowerVeto")
300  << "Run not initialized in JetMatchingMadgraph"
301  << std::endl;
302 
303 
304  if (uppriv_.ickkw)
305  {
306  std::vector<std::string> comments = event->getComments();
307  if (comments.size() == 1)
308  {
309  std::istringstream ss(comments[0].substr(1));
310  for(int i = 0; i < 1000; i++)
311  {
312  double pt;
313  ss >> pt;
314  if (!ss.good())
315  break;
316  pypart_.ptpart[i] = pt;
317  }
318  }
319  else
320  {
321  edm::LogWarning("Generator|LHEInterface")
322  << "Expected exactly one comment line per "
323  "event containing MadGraph parton scale "
324  "information."
325  << std::endl;
326 
327  const lhef::HEPEUP *hepeup = event->getHEPEUP();
328  for(int i = 2; i < hepeup->NUP; i++)
329  {
330  double mt2 =
331  hepeup->PUP[i][0] * hepeup->PUP[i][0] +
332  hepeup->PUP[i][1] * hepeup->PUP[i][1] +
333  hepeup->PUP[i][4] * hepeup->PUP[i][4];
334  pypart_.ptpart[i - 2] = std::sqrt(mt2);
335  }
336  }
337  }
338 
339  // mgevnt_();
340  eventInitialized = true;
341 }
int i
Definition: DBlmapReader.cc:9
struct gen::PYPART pypart_
double ptpart[1000]
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< FiveVector > PUP
Definition: LesHouches.h:248
struct gen::UPPRIV uppriv_
void gen::JetMatchingMadgraph::beforeHadronisationExec ( )
protectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 343 of file JetMatchingMadgraph.cc.

References eventInitialized, and gen::mgevnt_().

344 {
345  mgevnt_();
346  eventInitialized = true;
347  return;
348 }
void mgevnt_(void)
std::set< std::string > gen::JetMatchingMadgraph::capabilities ( ) const
protectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 180 of file JetMatchingMadgraph.cc.

References query::result.

181 {
182  std::set<std::string> result;
183  result.insert("psFinalState");
184  result.insert("hepevt");
185  result.insert("pythia6");
186  return result;
187 }
tuple result
Definition: query.py:137
double gen::JetMatchingMadgraph::getJetEtaMax ( ) const
protectedvirtual

Implements gen::JetMatching.

Definition at line 175 of file JetMatchingMadgraph.cc.

References gen::MEMAIN::etaclmax, and gen::memain_.

176 {
177  return memain_.etaclmax;
178 }
struct gen::MEMAIN memain_
template<typename T >
T gen::JetMatchingMadgraph::getParameter ( const std::map< std::string, std::string > &  params,
const std::string &  var,
const T defValue = T() 
)
staticprotected

Definition at line 107 of file JetMatchingMadgraph.cc.

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
protected

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)
protectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 237 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.

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

Implements gen::JetMatching.

Definition at line 355 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, soup, and TriggerAnalyzer::veto.

356 {
357 /*
358  if (!showeredFinalState)
359  throw cms::Exception("Generator|LHEInterface")
360  << "MadGraph matching expected parton shower "
361  "final state." << std::endl;
362 */
363 
364  if (!runInitialized)
365  throw cms::Exception("Generator|LHEInterface")
366  << "Run not initialized in JetMatchingMadgraph"
367  << std::endl;
368 
369  if (!eventInitialized)
370  throw cms::Exception("Generator|LHEInterface")
371  << "Event not initialized in JetMatchingMadgraph"
372  << std::endl;
373 
374  if (soup)
376  else
378 
379  int veto = 0;
380  mgveto_(&veto);
381  fMatchingStatus=true;
382  eventInitialized = false;
383 
384  return veto;
385 }
struct gen::MEMAIN memain_
struct gen::MEMAEV memaev_
void mgveto_(int *veto)
template<typename T >
T gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)
staticprotected

Definition at line 77 of file JetMatchingMadgraph.cc.

References query::result, and contentValuesCheck::ss.

78 {
79  std::istringstream ss(value);
80  T result;
81  ss >> result;
82  return result;
83 }
tuple result
Definition: query.py:137
long double T
template<>
std::string gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)

Definition at line 86 of file JetMatchingMadgraph.cc.

References query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

87 {
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);
93  return result;
94 }
tuple result
Definition: query.py:137
template<>
bool gen::JetMatchingMadgraph::parseParameter ( const std::string &  value_)

Definition at line 97 of file JetMatchingMadgraph.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, create_public_lumi_plots::transform, and relativeConstraints::value.

98 {
99  std::string value(value_);
100  std::transform(value.begin(), value.end(),
101  value.begin(), (int(*)(int))std::toupper);
102  return value == "T" || value == "Y" || value=="True" ||
103  value == "1" || value == ".TRUE.";
104 }
template<typename T >
void gen::JetMatchingMadgraph::updateOrDie ( const std::map< std::string, std::string > &  params,
T param,
const std::string &  name 
)
staticprotected

Definition at line 220 of file JetMatchingMadgraph.cc.

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

Referenced by init().

223 {
224  if (param < 0){
225  param = getParameter(params, name, param);
226  }
227  if (param < 0)
228  throw cms::Exception("Generator|PartonShowerVeto")
229  << "The MGParamCMS header does not specify the jet "
230  "matching parameter \"" << name << "\", but it "
231  "is requested by the CMSSW configuration."
232  << std::endl;
233 }
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
protected

Definition at line 46 of file JetMatchingMadgraph.h.

Referenced by beforeHadronisation(), beforeHadronisationExec(), and match().

bool gen::JetMatchingMadgraph::exclusive
protected

Definition at line 48 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().

std::map<std::string, std::string> gen::JetMatchingMadgraph::mgParams
protected

Definition at line 43 of file JetMatchingMadgraph.h.

Referenced by getParameter(), and init().

bool gen::JetMatchingMadgraph::runInitialized
protected

Definition at line 45 of file JetMatchingMadgraph.h.

Referenced by beforeHadronisation(), init(), and match().

bool gen::JetMatchingMadgraph::soup
protected

Definition at line 47 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().