CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 () override
 
- 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

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

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::unique_ptr
< JetMatching
create (const edm::ParameterSet &params)
 

Detailed Description

Definition at line 8 of file JetMatchingMadgraph.h.

Constructor & Destructor Documentation

gen::JetMatchingMadgraph::JetMatchingMadgraph ( const edm::ParameterSet params)

Definition at line 110 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(), B2GTnPMonitor_cfi::item, gen::MEMAIN::ktsche, gen::MEMAIN::maxjets, gen::memain_, gen::MEMAIN::minjets, universalConfigTemplate::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.

111  : JetMatching(params), runInitialized(false) {
112  std::string mode = params.getParameter<std::string>("mode");
113  if (mode == "inclusive") {
114  soup = false;
115  exclusive = false;
116  } else if (mode == "exclusive") {
117  soup = false;
118  exclusive = true;
119  } else if (mode == "auto")
120  soup = true;
121  else
122  throw cms::Exception("Generator|LHEInterface") << "Madgraph jet matching scheme requires \"mode\" "
123  "parameter to be set to either \"inclusive\", "
124  "\"exclusive\" or \"auto\"."
125  << std::endl;
126 
127  memain_.etcjet = 0.;
128  memain_.rclmax = 0.0;
129  memain_.clfact = 0.0;
130  memain_.ktsche = 0.0;
131  memain_.etaclmax = params.getParameter<double>("MEMAIN_etaclmax");
132  memain_.qcut = params.getParameter<double>("MEMAIN_qcut");
133  memain_.minjets = params.getParameter<int>("MEMAIN_minjets");
134  memain_.maxjets = params.getParameter<int>("MEMAIN_maxjets");
135  memain_.showerkt = params.getParameter<double>("MEMAIN_showerkt");
136  memain_.nqmatch = params.getParameter<int>("MEMAIN_nqmatch");
137  outtree_.flag = params.getParameter<int>("outTree_flag");
138  std::string list_excres = params.getParameter<std::string>("MEMAIN_excres");
139  std::vector<std::string> elems;
140  std::stringstream ss(list_excres);
142  int index = 0;
143  while (std::getline(ss, item, ',')) {
144  elems.push_back(item);
145  memain_.excres[index] = std::atoi(item.c_str());
146  index++;
147  }
149  }
struct gen::OUTTREE outtree_
struct gen::MEMAIN memain_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
JetMatching(const edm::ParameterSet &params)
Definition: JetMatching.cc:17
gen::JetMatchingMadgraph::~JetMatchingMadgraph ( )
override

Definition at line 151 of file JetMatchingMadgraph.cc.

151 {}

Member Function Documentation

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

Reimplemented from gen::JetMatching.

Definition at line 259 of file JetMatchingMadgraph.cc.

References eventInitialized, Exception, mps_fire::i, gen::UPPRIV::ickkw, lhef::HEPEUP::NUP, DiDispStaMuonMonitor_cfi::pt, gen::PYPART::ptpart, lhef::HEPEUP::PUP, gen::pypart_, runInitialized, mathSSE::sqrt(), contentValuesCheck::ss, and gen::uppriv_.

259  {
260  if (!runInitialized)
261  throw cms::Exception("Generator|PartonShowerVeto") << "Run not initialized in JetMatchingMadgraph" << std::endl;
262 
263  if (uppriv_.ickkw) {
264  std::vector<std::string> comments = event->getComments();
265  if (comments.size() == 1) {
266  std::istringstream ss(comments[0].substr(1));
267  for (int i = 0; i < 1000; i++) {
268  double pt;
269  ss >> pt;
270  if (!ss.good())
271  break;
272  pypart_.ptpart[i] = pt;
273  }
274  } else {
275  edm::LogWarning("Generator|LHEInterface") << "Expected exactly one comment line per "
276  "event containing MadGraph parton scale "
277  "information."
278  << std::endl;
279 
280  const lhef::HEPEUP *hepeup = event->getHEPEUP();
281  for (int i = 2; i < hepeup->NUP; i++) {
282  double mt2 = hepeup->PUP[i][0] * hepeup->PUP[i][0] + hepeup->PUP[i][1] * hepeup->PUP[i][1] +
283  hepeup->PUP[i][4] * hepeup->PUP[i][4];
284  pypart_.ptpart[i - 2] = std::sqrt(mt2);
285  }
286  }
287  }
288 
289  // mgevnt_();
290  eventInitialized = true;
291  }
struct gen::PYPART pypart_
double ptpart[1000]
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
Log< level::Warning, false > LogWarning
struct gen::UPPRIV uppriv_
void gen::JetMatchingMadgraph::beforeHadronisationExec ( )
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 293 of file JetMatchingMadgraph.cc.

References eventInitialized, and gen::mgevnt_().

293  {
294  mgevnt_();
295  eventInitialized = true;
296  return;
297  }
void mgevnt_(void)
std::set< std::string > gen::JetMatchingMadgraph::capabilities ( ) const
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 155 of file JetMatchingMadgraph.cc.

References mps_fire::result.

155  {
156  std::set<std::string> result;
157  result.insert("psFinalState");
158  result.insert("hepevt");
159  result.insert("pythia6");
160  return result;
161  }
tuple result
Definition: mps_fire.py:311
double gen::JetMatchingMadgraph::getJetEtaMax ( ) const
overrideprotectedvirtual

Implements gen::JetMatching.

Definition at line 153 of file JetMatchingMadgraph.cc.

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

153 { return memain_.etaclmax; }
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 96 of file JetMatchingMadgraph.cc.

Referenced by getParameter(), and updateOrDie().

98  {
99  std::map<std::string, std::string>::const_iterator pos = params.find(var);
100  if (pos == params.end())
101  return defValue;
102  return parseParameter<T>(pos->second);
103  }
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
template<typename T >
T gen::JetMatchingMadgraph::getParameter ( const std::string &  var,
const T defValue = T() 
) const
protected

Definition at line 106 of file JetMatchingMadgraph.cc.

References getParameter(), and mgParams.

106  {
107  return getParameter(mgParams, var, defValue);
108  }
static T getParameter(const std::map< std::string, std::string > &params, const std::string &var, const T &defValue=T())
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
std::map< std::string, std::string > mgParams
void gen::JetMatchingMadgraph::init ( const lhef::LHERunInfo runInfo)
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 206 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, submitPVValidationJobs::params, gen::parseHeader(), gen::MEMAIN::qcut, runInitialized, gen::MEMAIN::showerkt, updateOrDie(), gen::uppriv_, and makeHLTPrescaleTable::values.

206  {
207  // read MadGraph run card
208 
209  std::map<std::string, std::string> parameters;
210 
211  std::vector<std::string> header = runInfo->findHeader("MGRunCard");
212  if (header.empty())
213  throw cms::Exception("Generator|PartonShowerVeto") << "In order to use MadGraph jet matching, "
214  "the input file has to contain the corresponding "
215  "MadGraph headers."
216  << std::endl;
217 
218  mgParams = parseHeader(header);
219 
220  // set variables in common block
221 
222  std::vector<Param> params;
223  std::vector<Param> values;
224  for (std::map<std::string, std::string>::const_iterator iter = mgParams.begin(); iter != mgParams.end(); ++iter) {
225  params.push_back(" " + iter->first);
226  values.push_back(iter->second);
227  }
228 
229  // set MG matching parameters
230 
231  uppriv_.ickkw = getParameter<int>("ickkw", 0);
232  memain_.mektsc = getParameter<int>("ktscheme", 0);
233 
234  header = runInfo->findHeader("MGParamCMS");
235 
236  std::map<std::string, std::string> mgInfoCMS = parseHeader(header);
237 
238  for (std::map<std::string, std::string>::const_iterator iter = mgInfoCMS.begin(); iter != mgInfoCMS.end(); ++iter) {
239  std::cout << "mgInfoCMS: " << iter->first << " " << iter->second << std::endl;
240  }
241 
242  updateOrDie(mgInfoCMS, memain_.etaclmax, "etaclmax");
243  updateOrDie(mgInfoCMS, memain_.qcut, "qcut");
244  updateOrDie(mgInfoCMS, memain_.minjets, "minjets");
245  updateOrDie(mgInfoCMS, memain_.maxjets, "maxjets");
246  updateOrDie(mgInfoCMS, memain_.showerkt, "showerkt");
247  updateOrDie(mgInfoCMS, memain_.nqmatch, "nqmatch");
248 
249  // run Fortran initialization code
250 
251  int nparam = params.size();
252  mginit_(&nparam, &params.front(), &values.front());
253  runInitialized = true;
254  }
struct gen::MEMAIN memain_
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:144
std::vector< std::string > findHeader(const std::string &tag) const
Definition: LHERunInfo.cc:434
struct gen::UPPRIV uppriv_
int gen::JetMatchingMadgraph::match ( const lhef::LHEEvent partonLevel,
const std::vector< fastjet::PseudoJet > *  jetInput 
)
overrideprotectedvirtual

Implements gen::JetMatching.

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

304  {
305  /*
306  if (!showeredFinalState)
307  throw cms::Exception("Generator|LHEInterface")
308  << "MadGraph matching expected parton shower "
309  "final state." << std::endl;
310 */
311 
312  if (!runInitialized)
313  throw cms::Exception("Generator|LHEInterface") << "Run not initialized in JetMatchingMadgraph" << std::endl;
314 
315  if (!eventInitialized)
316  throw cms::Exception("Generator|LHEInterface") << "Event not initialized in JetMatchingMadgraph" << std::endl;
317 
318  if (soup)
320  else
322 
323  int veto = 0;
324  mgveto_(&veto);
325  fMatchingStatus = true;
326  eventInitialized = false;
327 
328  return veto;
329  }
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 71 of file JetMatchingMadgraph.cc.

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

71  {
72  std::istringstream ss(value);
73  T result;
74  ss >> result;
75  return result;
76  }
tuple result
Definition: mps_fire.py:311
long double T
template<>
std::string gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)

Definition at line 79 of file JetMatchingMadgraph.cc.

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

79  {
81  if (!result.empty() && result[0] == '\'')
82  result = result.substr(1);
83  if (!result.empty() && result[result.length() - 1] == '\'')
84  result.resize(result.length() - 1);
85  return result;
86  }
tuple result
Definition: mps_fire.py:311
template<>
bool gen::JetMatchingMadgraph::parseParameter ( const std::string &  value_)

Definition at line 89 of file JetMatchingMadgraph.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, HcalDetIdTransform::transform(), and relativeConstraints::value.

89  {
90  std::string value(value_);
91  std::transform(value.begin(), value.end(), value.begin(), (int (*)(int))std::toupper);
92  return value == "T" || value == "Y" || value == "True" || value == "1" || value == ".TRUE.";
93  }
unsigned transform(const HcalDetId &id, unsigned transformCode)
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 189 of file JetMatchingMadgraph.cc.

References Exception, and getParameter().

Referenced by init().

191  {
192  if (param < 0) {
193  param = getParameter(params, name, param);
194  }
195  if (param < 0)
196  throw cms::Exception("Generator|PartonShowerVeto") << "The MGParamCMS header does not specify the jet "
197  "matching parameter \""
198  << name
199  << "\", but it "
200  "is requested by the CMSSW configuration."
201  << std::endl;
202  }
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 44 of file JetMatchingMadgraph.h.

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

bool gen::JetMatchingMadgraph::exclusive
protected

Definition at line 46 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().

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

Definition at line 41 of file JetMatchingMadgraph.h.

Referenced by getParameter(), and init().

bool gen::JetMatchingMadgraph::runInitialized
protected

Definition at line 43 of file JetMatchingMadgraph.h.

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

bool gen::JetMatchingMadgraph::soup
protected

Definition at line 45 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().