CMS 3D CMS Logo

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)
 
 ~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<>
std::string parseParameter (const std::string &value)
 
template<>
bool 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< JetMatchingcreate (const edm::ParameterSet &params)
 

Detailed Description

Definition at line 8 of file JetMatchingMadgraph.h.

Constructor & Destructor Documentation

◆ JetMatchingMadgraph()

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

Definition at line 110 of file JetMatchingMadgraph.cc.

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  }

References gen::MEMAIN::clfact, gen::MEMAIN::etaclmax, gen::MEMAIN::etcjet, Exception, exclusive, gen::MEMAIN::excres, gen::OUTTREE::flag, B2GTnPMonitor_cfi::item, gen::MEMAIN::ktsche, gen::MEMAIN::maxjets, gen::memain_, gen::MEMAIN::minjets, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, gen::MEMAIN::nexcres, gen::MEMAIN::nqmatch, gen::outtree_, CalibrationSummaryClient_cfi::params, gen::MEMAIN::qcut, gen::MEMAIN::rclmax, gen::MEMAIN::showerkt, soup, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~JetMatchingMadgraph()

gen::JetMatchingMadgraph::~JetMatchingMadgraph ( )
override

Definition at line 151 of file JetMatchingMadgraph.cc.

151 {}

Member Function Documentation

◆ beforeHadronisation()

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

Reimplemented from gen::JetMatching.

Definition at line 259 of file JetMatchingMadgraph.cc.

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  }

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

◆ beforeHadronisationExec()

void gen::JetMatchingMadgraph::beforeHadronisationExec ( )
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 293 of file JetMatchingMadgraph.cc.

293  {
294  mgevnt_();
295  eventInitialized = true;
296  return;
297  }

References eventInitialized, and gen::mgevnt_().

◆ capabilities()

std::set< std::string > gen::JetMatchingMadgraph::capabilities ( ) const
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 155 of file JetMatchingMadgraph.cc.

155  {
156  std::set<std::string> result;
157  result.insert("psFinalState");
158  result.insert("hepevt");
159  result.insert("pythia6");
160  return result;
161  }

References mps_fire::result.

◆ getJetEtaMax()

double gen::JetMatchingMadgraph::getJetEtaMax ( ) const
overrideprotectedvirtual

Implements gen::JetMatching.

Definition at line 153 of file JetMatchingMadgraph.cc.

153 { return memain_.etaclmax; }

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

◆ getParameter() [1/2]

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.

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  }

References CalibrationSummaryClient_cfi::params, and trigObjTnPSource_cfi::var.

Referenced by getParameter(), and updateOrDie().

◆ getParameter() [2/2]

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.

106  {
107  return getParameter(mgParams, var, defValue);
108  }

References getParameter(), mgParams, and trigObjTnPSource_cfi::var.

◆ init()

void gen::JetMatchingMadgraph::init ( const lhef::LHERunInfo runInfo)
overrideprotectedvirtual

Reimplemented from gen::JetMatching.

Definition at line 206 of file JetMatchingMadgraph.cc.

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 
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  }

References gather_cfg::cout, gen::MEMAIN::etaclmax, lhef::LHERunInfo::findHeader(), RecoTauValidation_cfi::header, gen::UPPRIV::ickkw, gen::MEMAIN::maxjets, gen::MEMAIN::mektsc, gen::memain_, gen::mginit_(), mgParams, gen::MEMAIN::minjets, gen::MEMAIN::nqmatch, CalibrationSummaryClient_cfi::params, gen::parseHeader(), gen::MEMAIN::qcut, runInitialized, gen::MEMAIN::showerkt, updateOrDie(), gen::uppriv_, and contentValuesCheck::values.

◆ match()

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.

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  }

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 PbPb_ZMuSkimMuonDPG_cff::veto.

◆ parseParameter() [1/3]

template<typename T >
T gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)
staticprotected

Definition at line 71 of file JetMatchingMadgraph.cc.

71  {
72  std::istringstream ss(value);
73  T result;
74  ss >> result;
75  return result;
76  }

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

◆ parseParameter() [2/3]

template<>
std::string gen::JetMatchingMadgraph::parseParameter ( const std::string &  value)
staticprotected

Definition at line 79 of file JetMatchingMadgraph.cc.

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  }

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

◆ parseParameter() [3/3]

template<>
bool gen::JetMatchingMadgraph::parseParameter ( const std::string &  value_)
staticprotected

Definition at line 89 of file JetMatchingMadgraph.cc.

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  }

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

◆ updateOrDie()

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.

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  }

References Exception, getParameter(), Skims_PA_cff::name, and CalibrationSummaryClient_cfi::params.

Referenced by init().

Member Data Documentation

◆ eventInitialized

bool gen::JetMatchingMadgraph::eventInitialized
protected

Definition at line 44 of file JetMatchingMadgraph.h.

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

◆ exclusive

bool gen::JetMatchingMadgraph::exclusive
protected

Definition at line 46 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().

◆ mgParams

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

Definition at line 41 of file JetMatchingMadgraph.h.

Referenced by getParameter(), and init().

◆ runInitialized

bool gen::JetMatchingMadgraph::runInitialized
protected

Definition at line 43 of file JetMatchingMadgraph.h.

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

◆ soup

bool gen::JetMatchingMadgraph::soup
protected

Definition at line 45 of file JetMatchingMadgraph.h.

Referenced by JetMatchingMadgraph(), and match().

mps_fire.i
i
Definition: mps_fire.py:355
gen::JetMatchingMadgraph::updateOrDie
static void updateOrDie(const std::map< std::string, std::string > &params, T &param, const std::string &name)
Definition: JetMatchingMadgraph.cc:189
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
gen::outtree_
struct gen::OUTTREE outtree_
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
gen::MEMAEV::iexc
int iexc
Definition: JetMatchingMadgraph.cc:61
gen::JetMatchingMadgraph::mgParams
std::map< std::string, std::string > mgParams
Definition: JetMatchingMadgraph.h:41
gen::MEMAIN::rclmax
double rclmax
Definition: JetMatchingMadgraph.cc:50
gen::MEMAIN::mektsc
int mektsc
Definition: JetMatchingMadgraph.cc:52
gen::MEMAIN::etcjet
double etcjet
Definition: JetMatchingMadgraph.cc:50
gen::JetMatchingMadgraph::getParameter
static T getParameter(const std::map< std::string, std::string > &params, const std::string &var, const T &defValue=T())
Definition: JetMatchingMadgraph.cc:96
gen::JetMatchingMadgraph::runInitialized
bool runInitialized
Definition: JetMatchingMadgraph.h:43
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
gen::MEMAIN::nqmatch
int nqmatch
Definition: JetMatchingMadgraph.cc:53
gen::MEMAIN::ktsche
int ktsche
Definition: JetMatchingMadgraph.cc:51
gen::MEMAIN::clfact
double clfact
Definition: JetMatchingMadgraph.cc:50
lhef::HEPEUP::NUP
int NUP
Definition: LesHouches.h:184
gen::MEMAIN::qcut
double qcut
Definition: JetMatchingMadgraph.cc:50
gen::MEMAIN::maxjets
int maxjets
Definition: JetMatchingMadgraph.cc:51
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
gen::mgveto_
void mgveto_(int *veto)
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
gen::memain_
struct gen::MEMAIN memain_
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
gen::parseHeader
static std::map< std::string, std::string > parseHeader(const std::vector< std::string > &header)
Definition: JetMatchingMadgraph.cc:163
edm::LogWarning
Definition: MessageLogger.h:141
indexGen.comments
comments
Definition: indexGen.py:75
MT2Analyzer.mt2
mt2
Definition: MT2Analyzer.py:251
gen::MEMAIN::minjets
int minjets
Definition: JetMatchingMadgraph.cc:51
createfilelist.int
int
Definition: createfilelist.py:10
gen::MEMAIN::etaclmax
double etaclmax
Definition: JetMatchingMadgraph.cc:50
value
Definition: value.py:1
gen::PYPART::ptpart
double ptpart[1000]
Definition: JetMatchingMadgraph.cc:66
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
gen::JetMatchingMadgraph::exclusive
bool exclusive
Definition: JetMatchingMadgraph.h:46
gen::JetMatching::fMatchingStatus
bool fMatchingStatus
Definition: JetMatching.h:86
gen::mginit_
void mginit_(int *npara, Param *params, Param *values)
lhef::HEPEUP
Definition: LesHouches.h:138
gen::mgevnt_
void mgevnt_(void)
gen::uppriv_
struct gen::UPPRIV uppriv_
gen::MEMAIN::showerkt
double showerkt
Definition: JetMatchingMadgraph.cc:50
T
long double T
Definition: Basic3DVectorLD.h:48
gen::memaev_
struct gen::MEMAEV memaev_
gen::pypart_
struct gen::PYPART pypart_
relativeConstraints.value
value
Definition: relativeConstraints.py:53
gen::MEMAIN::excres
int excres[30]
Definition: JetMatchingMadgraph.cc:52
Exception
Definition: hltDiff.cc:246
gen::MEMAIN::nexcres
int nexcres
Definition: JetMatchingMadgraph.cc:52
gen::JetMatchingMadgraph::soup
bool soup
Definition: JetMatchingMadgraph.h:45
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
gen::MEMAEV::nljets
int nljets
Definition: JetMatchingMadgraph.cc:61
mps_fire.result
result
Definition: mps_fire.py:303
cms::Exception
Definition: Exception.h:70
gen::JetMatchingMadgraph::eventInitialized
bool eventInitialized
Definition: JetMatchingMadgraph.h:44
gen::UPPRIV::ickkw
int ickkw
Definition: JetMatchingMadgraph.cc:46
lhef::LHERunInfo::findHeader
std::vector< std::string > findHeader(const std::string &tag) const
Definition: LHERunInfo.cc:436
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
lhef::HEPEUP::PUP
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
gen::OUTTREE::flag
int flag
Definition: JetMatchingMadgraph.cc:57
gen::JetMatching::JetMatching
JetMatching(const edm::ParameterSet &params)
Definition: JetMatching.cc:15