13 #include "boost/algorithm/string.hpp" 16 #include <unordered_map> 24 num(0), sumw(0), sumw2(0), sumPDF(), sumScale(), sumNamed(), sumPS() {}
30 std::vector<long double> sumPDF, sumScale, sumNamed, sumPS;
33 num = 0; sumw = 0; sumw2 = 0;
34 sumPDF.clear(); sumScale.clear(); sumNamed.clear(), sumPS.clear();
38 void incGenOnly(
double w) {
39 num++; sumw +=
w; sumw2 += (w*
w);
42 void incPSOnly(
double w0,
const std::vector<double> & wPS) {
44 if (sumPS.empty()) sumPS.resize(wPS.size(), 0);
45 for (
unsigned int i = 0,
n = wPS.size();
i <
n; ++
i) sumPS[
i] += (w0 * wPS[
i]);
49 void incLHE(
double w0,
const std::vector<double> & wScale,
const std::vector<double> & wPDF,
const std::vector<double> & wNamed,
const std::vector<double> & wPS) {
53 if (!wScale.empty()) {
54 if (sumScale.empty()) sumScale.resize(wScale.size(), 0);
55 for (
unsigned int i = 0,
n = wScale.size();
i <
n; ++
i) sumScale[
i] += (w0 * wScale[
i]);
58 if (sumPDF.empty()) sumPDF.resize(wPDF.size(), 0);
59 for (
unsigned int i = 0, n = wPDF.size();
i <
n; ++
i) sumPDF[
i] += (w0 * wPDF[
i]);
61 if (!wNamed.empty()) {
62 if (sumNamed.empty()) sumNamed.resize(wNamed.size(), 0);
63 for (
unsigned int i = 0, n = wNamed.size();
i <
n; ++
i) sumNamed[
i] += (w0 * wNamed[
i]);
69 num += other.num; sumw += other.sumw; sumw2 += other.sumw2;
70 if (sumScale.empty() && !other.sumScale.empty()) sumScale.resize(other.sumScale.size(),0);
71 if (sumPDF.empty() && !other.sumPDF.empty()) sumPDF.resize(other.sumPDF.size(),0);
72 if (sumNamed.empty() && !other.sumNamed.empty()) sumNamed.resize(other.sumNamed.size(),0);
73 if (sumPS.empty() && !other.sumPS.empty()) sumPS.resize(other.sumPS.size(),0);
74 for (
unsigned int i = 0, n = sumScale.size();
i <
n; ++
i) sumScale[
i] += other.sumScale[
i];
75 for (
unsigned int i = 0, n = sumPDF.size();
i <
n; ++
i) sumPDF[
i] += other.sumPDF[
i];
76 for (
unsigned int i = 0, n = sumNamed.size();
i <
n; ++
i) sumNamed[
i] += other.sumNamed[
i];
77 for (
unsigned int i = 0, n = sumPS.size();
i <
n; ++
i) sumPS[
i] += other.sumPS[
i];
82 struct DynamicWeightChoice {
85 std::vector<std::string> scaleWeightIDs;
88 std::vector<std::string> pdfWeightIDs;
94 if (match != std::string::npos) {
97 return std::stof(pre) *
std::pow(10.0
f, std::stof(post));
99 return std::stof(str);
103 struct ScaleVarWeight {
105 std::pair<float,float> scales;
107 wid(id), label(text), scales(stof_fortrancomp(muR), stof_fortrancomp(muF)) {}
108 bool operator<(
const ScaleVarWeight & other) {
return (scales == other.scales ? wid < other.wid : scales < other.scales); }
110 struct PDFSetWeights {
111 std::vector<std::string> wids;
112 std::pair<unsigned int,unsigned int> lhaIDs;
113 PDFSetWeights(
const std::string & wid,
unsigned int lhaID) : wids(1,wid), lhaIDs(lhaID,lhaID) {}
114 bool operator<(
const PDFSetWeights & other)
const {
return lhaIDs < other.lhaIDs; }
117 lhaIDs.second = lhaID;
119 bool maybe_add(
const std::string & wid,
unsigned int lhaID) {
120 if (lhaID == lhaIDs.second+1) {
135 lheLabel_(params.getParameter<
edm::InputTag>(
"lheInfo")),
138 namedWeightIDs_(params.getParameter<
std::vector<
std::
string>>(
"namedWeightIDs")),
139 namedWeightLabels_(params.getParameter<
std::vector<
std::
string>>(
"namedWeightLabels")),
140 lheWeightPrecision_(params.getParameter<int32_t>(
"lheWeightPrecision")),
141 maxPdfWeights_(params.getParameter<uint32_t>(
"maxPdfWeights")),
142 debug_(params.getUntrackedParameter<
bool>(
"debug",
false)), debugRun_(debug_.
load()),
143 hasIssuedWarning_(
false)
145 produces<nanoaod::FlatTable>();
146 produces<nanoaod::FlatTable>(
"LHEScale");
147 produces<nanoaod::FlatTable>(
"LHEPdf");
148 produces<nanoaod::FlatTable>(
"LHENamed");
149 produces<nanoaod::FlatTable>(
"PS");
150 produces<nanoaod::MergeableCounterTable,edm::Transition::EndRun>();
151 if (namedWeightIDs_.size() != namedWeightLabels_.size()) {
152 throw cms::Exception(
"Configuration",
"Size mismatch between namedWeightIDs & namedWeightLabels");
156 uint32_t
lhaid = pdfps.getParameter<uint32_t>(
"lhaid");
157 preferredPDFLHAIDs_.push_back(lhaid);
159 lhaNameToID_[name+
".LHgrid"] =
lhaid;
175 auto out = std::make_unique<nanoaod::FlatTable>(1,
"genWeight",
true);
176 out->setDoc(
"generator weight");
181 std::unique_ptr<nanoaod::FlatTable> lheScaleTab, lhePdfTab, lheNamedTab;
182 std::unique_ptr<nanoaod::FlatTable> genPSTab;
187 const DynamicWeightChoice * weightChoice = runCache(iEvent.
getRun().
index());
189 fillLHEWeightTables(counter, weightChoice, weight, *lheInfo, *genInfo, lheScaleTab, lhePdfTab, lheNamedTab, genPSTab);
192 fillOnlyPSWeightTable(counter, weight, *genInfo, genPSTab);
197 if (!hasIssuedWarning_.exchange(
true)) {
198 edm::LogWarning(
"LHETablesProducer") <<
"No LHEEventProduct, so there will be no LHE Tables\n";
210 const DynamicWeightChoice * weightChoice,
214 std::unique_ptr<nanoaod::FlatTable> & outScale,
215 std::unique_ptr<nanoaod::FlatTable> & outPdf,
216 std::unique_ptr<nanoaod::FlatTable> & outNamed,
217 std::unique_ptr<nanoaod::FlatTable> & outPS )
const 219 bool lheDebug = debug_.exchange(
false);
221 const std::vector<std::string> & scaleWeightIDs = weightChoice->scaleWeightIDs;
222 const std::vector<std::string> & pdfWeightIDs = weightChoice->pdfWeightIDs;
226 std::vector<double> wScale(scaleWeightIDs.size(), 1), wPDF(pdfWeightIDs.size(), 1), wNamed(namedWeightIDs_.size(), 1);
228 if (lheDebug) printf(
"Weight %+9.5f rel %+9.5f for id %s\n",
weight.wgt,
weight.wgt/w0,
weight.id.c_str());
230 auto mScale =
std::find(scaleWeightIDs.begin(), scaleWeightIDs.end(),
weight.id);
231 if (mScale != scaleWeightIDs.end()) wScale[mScale-scaleWeightIDs.begin()] =
weight.wgt/w0;
233 auto mPDF =
std::find(pdfWeightIDs.begin(), pdfWeightIDs.end(),
weight.id);
234 if (mPDF != pdfWeightIDs.end()) wPDF[mPDF-pdfWeightIDs.begin()] =
weight.wgt/w0;
236 auto mNamed =
std::find(namedWeightIDs_.begin(), namedWeightIDs_.end(),
weight.id);
237 if (mNamed != namedWeightIDs_.end()) wNamed[mNamed-namedWeightIDs_.begin()] =
weight.wgt/w0;
240 int vectorSize = genProd.
weights().size() == 14 ? 4 : 1;
241 std::vector<double> wPS(vectorSize, 1);
242 if (vectorSize > 1 ) {
243 for (
unsigned int i=6;
i<10;
i++){
248 outPS->addColumn<
float>(
"", wPS, vectorSize > 1 ?
"PS weights (w_var / w_nominal); [0] is ISR=0.5 FSR=1; [1] is ISR=1 FSR=0.5; [2] is ISR=2 FSR=1; [3] is ISR=1 FSR=2 " :
"dummy PS weight (1.0) ",
nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
258 for (
unsigned int i = 0, n = wNamed.size();
i <
n; ++
i) {
259 outNamed->addColumnValue<
float>(namedWeightLabels_[
i], wNamed[
i],
"LHE weight for id "+namedWeightIDs_[
i]+
", relative to nominal",
nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
262 counter->incLHE(genWeight, wScale, wPDF, wNamed, wPS);
269 std::unique_ptr<nanoaod::FlatTable> & outPS )
const 271 int vectorSize = genProd.
weights().size() == 14 ? 4 : 1;
273 std::vector<double> wPS(vectorSize, 1);
274 if (vectorSize > 1 ){
275 for (
unsigned int i=6;
i<10;
i++){
276 wPS[
i-6] = (genProd.
weights()[
i])/genWeight;
281 outPS->addColumn<
float>(
"", wPS, vectorSize > 1 ?
"PS weights (w_var / w_nominal); [0] is ISR=0.5 FSR=1; [1] is ISR=1 FSR=0.5; [2] is ISR=2 FSR=1; [3] is ISR=1 FSR=2 " :
"dummy PS weight (1.0) " ,
nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
283 counter->incGenOnly(genWeight);
284 counter->incPSOnly(genWeight,wPS);
293 bool lheDebug = debugRun_.exchange(
false);
294 auto weightChoice = std::make_shared<DynamicWeightChoice>();
299 std::vector<ScaleVarWeight> scaleVariationIDs;
300 std::vector<PDFSetWeights> pdfSetWeightIDs;
302 std::regex weightgroupmg26x(
"<weightgroup\\s+(?:name|type)=\"(.*)\"\\s+combine=\"(.*)\"\\s*>");
303 std::regex weightgroup(
"<weightgroup\\s+combine=\"(.*)\"\\s+(?:name|type)=\"(.*)\"\\s*>");
304 std::regex endweightgroup(
"</weightgroup>");
305 std::regex scalewmg26x(
"<weight\\s+(?:.*\\s+)?id=\"(\\d+)\"\\s*(?:lhapdf=\\d+|dyn=\\s*-?\\d+)?\\s*((?:[mM][uU][rR]|renscfact)=\"(\\S+)\"\\s+(?:[mM][uU][Ff]|facscfact)=\"(\\S+)\")(\\s+.*)?</weight>");
306 std::regex scalew(
"<weight\\s+(?:.*\\s+)?id=\"(\\d+)\">\\s*(?:lhapdf=\\d+|dyn=\\s*-?\\d+)?\\s*((?:mu[rR]|renscfact)=(\\S+)\\s+(?:mu[Ff]|facscfact)=(\\S+)(\\s+.*)?)</weight>");
307 std::regex pdfw(
"<weight\\s+id=\"(\\d+)\">\\s*(?:PDF set|lhapdf|PDF|pdfset)\\s*=\\s*(\\d+)\\s*(?:\\s.*)?</weight>");
308 std::regex pdfwOld(
"<weight\\s+(?:.*\\s+)?id=\"(\\d+)\">\\s*Member \\s*(\\d+)\\s*(?:.*)</weight>");
309 std::regex pdfwmg26x(
"<weight\\s+id=\"(\\d+)\"\\s*MUR=\"(?:\\S+)\"\\s*MUF=\"(?:\\S+)\"\\s*(?:PDF set|lhapdf|PDF|pdfset)\\s*=\\s*\"(\\d+)\"\\s*>\\s*(?:PDF=(\\d+)\\s*MemberID=(\\d+))?\\s*(?:\\s.*)?</weight>");
312 if (iter->tag() !=
"initrwgt") {
313 if (lheDebug)
std::cout <<
"Skipping LHE header with tag" << iter->tag() << std::endl;
316 if (lheDebug)
std::cout <<
"Found LHE header with tag" << iter->tag() << std::endl;
317 std::vector<std::string>
lines = iter->lines();
318 bool missed_weightgroup=
false;
320 for (
unsigned int iLine = 0, nLines = lines.size(); iLine < nLines; ++iLine) {
321 boost::replace_all(lines[iLine],
"<",
"<");
322 boost::replace_all(lines[iLine],
">",
">");
323 if(std::regex_search(lines[iLine],groups,weightgroupmg26x)){
327 for (
unsigned int iLine = 0, nLines = lines.size(); iLine < nLines; ++iLine) {
329 if (std::regex_search(lines[iLine], groups, ismg26x ? weightgroupmg26x : weightgroup) ) {
331 if (ismg26x) groupname = groups.str(1);
332 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a weight group for '" << groupname <<
"'" << std::endl;
333 if (groupname.find(
"scale_variation") == 0 || groupname ==
"Central scale variation") {
334 if (lheDebug)
std::cout <<
">>> Looks like scale variation for theory uncertainties" << std::endl;
335 for ( ++iLine; iLine < nLines; ++iLine) {
336 if (lheDebug)
std::cout <<
" " << lines[iLine];
337 if (std::regex_search(lines[iLine], groups, ismg26x ? scalewmg26x : scalew)) {
338 if (lheDebug)
std::cout <<
" >>> Scale weight " << groups[1].str() <<
" for " << groups[3].str() <<
" , " << groups[4].str() <<
" , " << groups[5].str() << std::endl;
339 scaleVariationIDs.emplace_back(groups.str(1), groups.str(2), groups.str(3), groups.str(4));
340 }
else if (std::regex_search(lines[iLine], endweightgroup)) {
341 if (lheDebug)
std::cout <<
">>> Looks like the end of a weight group" << std::endl;
342 if (!missed_weightgroup){
344 }
else missed_weightgroup=
false;
345 }
else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
346 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
347 if (ismg26x) missed_weightgroup=
true;
352 }
else if (groupname ==
"PDF_variation" || groupname.find(
"PDF_variation ") == 0) {
353 if (lheDebug)
std::cout <<
">>> Looks like a new-style block of PDF weights for one or more pdfs" << std::endl;
354 for ( ++iLine; iLine < nLines; ++iLine) {
355 if (lheDebug)
std::cout <<
" " << lines[iLine];
356 if (std::regex_search(lines[iLine], groups, pdfw)) {
357 unsigned int lhaID = std::stoi(groups.str(2));
358 if (lheDebug)
std::cout <<
" >>> PDF weight " << groups.str(1) <<
" for " << groups.str(2) <<
" = " << lhaID << std::endl;
359 if (pdfSetWeightIDs.empty() || ! pdfSetWeightIDs.back().maybe_add(groups.str(1),lhaID)) {
360 pdfSetWeightIDs.emplace_back(groups.str(1),lhaID);
362 }
else if (std::regex_search(lines[iLine], endweightgroup)) {
363 if (lheDebug)
std::cout <<
">>> Looks like the end of a weight group" << std::endl;
364 if (!missed_weightgroup){
366 }
else missed_weightgroup=
false;
367 }
else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
368 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
369 if (ismg26x) missed_weightgroup=
true;
374 }
else if (groupname ==
"PDF_variation1" || groupname ==
"PDF_variation2") {
375 if (lheDebug)
std::cout <<
">>> Looks like a new-style block of PDF weights for multiple pdfs" << std::endl;
376 unsigned int lastid = 0;
377 for ( ++iLine; iLine < nLines; ++iLine) {
378 if (lheDebug)
std::cout <<
" " << lines[iLine];
379 if (std::regex_search(lines[iLine], groups, pdfw)) {
380 unsigned int id = std::stoi(groups.str(1));
381 unsigned int lhaID = std::stoi(groups.str(2));
382 if (lheDebug)
std::cout <<
" >>> PDF weight " << groups.str(1) <<
" for " << groups.str(2) <<
" = " << lhaID << std::endl;
383 if (
id != (lastid+1) || pdfSetWeightIDs.empty()) {
384 pdfSetWeightIDs.emplace_back(groups.str(1),lhaID);
386 pdfSetWeightIDs.back().add(groups.str(1),lhaID);
389 }
else if (std::regex_search(lines[iLine], endweightgroup)) {
390 if (lheDebug)
std::cout <<
">>> Looks like the end of a weight group" << std::endl;
391 if(!missed_weightgroup) {
393 }
else missed_weightgroup=
false;
394 }
else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
395 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
396 if (ismg26x) missed_weightgroup=
true;
401 }
else if (lhaNameToID_.find(groupname) != lhaNameToID_.end()) {
402 if (lheDebug)
std::cout <<
">>> Looks like an old-style PDF weight for an individual pdf" << std::endl;
403 unsigned int firstLhaID = lhaNameToID_.find(groupname)->second;
405 for ( ++iLine; iLine < nLines; ++iLine) {
406 if (lheDebug)
std::cout <<
" " << lines[iLine];
407 if (std::regex_search(lines[iLine], groups, ismg26x ? pdfwmg26x : pdfwOld)) {
408 unsigned int member = 0;
410 member = std::stoi(groups.str(2));
412 if (!groups.str(4).empty()){
413 member = std::stoi(groups.str(4));
416 unsigned int lhaID = member+firstLhaID;
417 if (lheDebug)
std::cout <<
" >>> PDF weight " << groups.str(1) <<
" for " << member <<
" = " << lhaID << std::endl;
420 pdfSetWeightIDs.emplace_back(groups.str(1),lhaID);
423 pdfSetWeightIDs.back().add(groups.str(1),lhaID);
425 }
else if (std::regex_search(lines[iLine], endweightgroup)) {
426 if (lheDebug)
std::cout <<
">>> Looks like the end of a weight group" << std::endl;
427 if (!missed_weightgroup) {
429 }
else missed_weightgroup=
false;
430 }
else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
431 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
432 if (ismg26x) missed_weightgroup=
true;
438 for ( ++iLine; iLine < nLines; ++iLine) {
439 if (lheDebug)
std::cout <<
" " << lines[iLine];
440 if (std::regex_search(lines[iLine], groups, endweightgroup)) {
441 if (lheDebug)
std::cout <<
">>> Looks like the end of a weight group" << std::endl;
442 if (!missed_weightgroup){
444 }
else missed_weightgroup=
false;
445 }
else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
446 if (lheDebug)
std::cout <<
">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
447 if (ismg26x) missed_weightgroup=
true;
458 std::sort(scaleVariationIDs.begin(), scaleVariationIDs.end());
459 if (lheDebug)
std::cout <<
"Found " << scaleVariationIDs.size() <<
" scale variations: " << std::endl;
460 std::stringstream scaleDoc; scaleDoc <<
"LHE scale variation weights (w_var / w_nominal); ";
461 for (
unsigned int isw = 0, nsw = scaleVariationIDs.size(); isw < nsw; ++isw) {
462 const auto & sw = scaleVariationIDs[isw];
463 if (isw) scaleDoc <<
"; ";
464 scaleDoc <<
"[" << isw <<
"] is " << sw.label;
465 weightChoice->scaleWeightIDs.push_back(sw.wid);
466 if (lheDebug) printf(
" id %s: scales ren = % .2f fact = % .2f text = %s\n", sw.wid.c_str(), sw.scales.first, sw.scales.second, sw.label.c_str());
468 if (!scaleVariationIDs.empty()) weightChoice->scaleWeightsDoc = scaleDoc.str();
472 std::cout <<
"Found " << pdfSetWeightIDs.size() <<
" PDF set errors: " << std::endl;
473 for (
const auto & pw : pdfSetWeightIDs) printf(
"lhaIDs %6d - %6d (%3lu weights: %s, ... )\n", pw.lhaIDs.first, pw.lhaIDs.second, pw.wids.size(), pw.wids.front().c_str());
476 std::stringstream pdfDoc; pdfDoc <<
"LHE pdf variation weights (w_var / w_nominal) for LHA IDs ";
478 for (uint32_t
lhaid : preferredPDFLHAIDs_) {
479 for (
const auto & pw : pdfSetWeightIDs) {
480 if (pw.lhaIDs.first !=
lhaid && pw.lhaIDs.first != (
lhaid+1))
continue;
481 if (pw.wids.size() == 1)
continue;
482 pdfDoc << pw.lhaIDs.first <<
" - " << pw.lhaIDs.second;
483 weightChoice->pdfWeightIDs = pw.wids;
484 if (maxPdfWeights_ < pw.wids.size()) {
485 weightChoice->pdfWeightIDs.resize(maxPdfWeights_);
486 pdfDoc <<
", truncated to the first " << maxPdfWeights_ <<
" replicas";
488 weightChoice->pdfWeightsDoc = pdfDoc.str();
501 return std::make_unique<Counter>();
505 streamCache(
id)->clear();
509 return std::make_shared<Counter>();
513 runCounter->merge(*streamCache(
id));
520 auto out = std::make_unique<nanoaod::MergeableCounterTable>();
521 out->addInt(
"genEventCount",
"event count", runCounter->num);
522 out->addFloat(
"genEventSumw",
"sum of gen weights", runCounter->sumw);
523 out->addFloat(
"genEventSumw2",
"sum of gen (weight^2)", runCounter->sumw2);
525 double norm = runCounter->sumw ? 1.0/runCounter->sumw : 1;
526 auto sumScales = runCounter->sumScale;
for (
auto &
val : sumScales)
val *= norm;
527 out->addVFloat(
"LHEScaleSumw",
"Sum of genEventWeight * LHEScaleWeight[i], divided by genEventSumw", sumScales);
528 auto sumPDFs = runCounter->sumPDF;
for (
auto &
val : sumPDFs)
val *= norm;
529 out->addVFloat(
"LHEPdfSumw",
"Sum of genEventWeight * LHEPdfWeight[i], divided by genEventSumw", sumPDFs);
530 if (!runCounter->sumNamed.empty()) {
531 for (
unsigned int i = 0, n = namedWeightLabels_.size();
i <
n; ++
i) {
532 out->addFloat(
"LHESumw_"+namedWeightLabels_[
i],
"Sum of genEventWeight * LHEWeight_"+namedWeightLabels_[i]+
", divided by genEventSumw", runCounter->sumNamed[i] * norm);
543 desc.
add<
edm::InputTag>(
"lheInfo",
edm::InputTag(
"externalLHEProducer"))->setComment(
"tag for the LHE information (LHEEventProduct and LHERunInfoProduct)");
547 prefpdf.
add<uint32_t>(
"lhaid");
548 desc.
addVPSet(
"preferredPDFs", prefpdf, std::vector<edm::ParameterSet>())->
setComment(
"LHA PDF Ids of the preferred PDF sets, in order of preference (the first matching one will be used)");
549 desc.
add<std::vector<std::string>>(
"namedWeightIDs")->setComment(
"set of LHA weight IDs for named LHE weights");
550 desc.
add<std::vector<std::string>>(
"namedWeightLabels")->setComment(
"output names for the namedWeightIDs (in the same order)");
551 desc.
add<int32_t>(
"lheWeightPrecision")->setComment(
"Number of bits in the mantissa for LHE weights");
552 desc.
add<uint32_t>(
"maxPdfWeights")->setComment(
"Maximum number of PDF weights to save (to crop NN replicas)");
553 desc.
addOptionalUntracked<
bool>(
"debug")->setComment(
"dump out all LHE information for one event");
554 descriptions.
add(
"genWeightsTable", desc);
double originalXWGTUP() const
T getParameter(std::string const &) const
bool getByLabel(std::string const &label, Handle< PROD > &result) const
void setComment(std::string const &value)
void streamBeginRun(edm::StreamID id, edm::Run const &, edm::EventSetup const &) const override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::unordered_map< std::string, uint32_t > lhaNameToID_
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void globalEndRunProduce(edm::Run &iRun, edm::EventSetup const &, Counter const *runCounter) const override
#define DEFINE_FWK_MODULE(type)
void streamEndRunSummary(edm::StreamID id, edm::Run const &, edm::EventSetup const &, Counter *runCounter) const override
const edm::EDGetTokenT< GenEventInfoProduct > genTag_
std::shared_ptr< DynamicWeightChoice > globalBeginRun(edm::Run const &iRun, edm::EventSetup const &) const override
headers_const_iterator headers_end() const
Run const & getRun() const
std::atomic< bool > hasIssuedWarning_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::unique_ptr< Counter > beginStream(edm::StreamID) const override
const std::vector< WGT > & weights() const
std::function< unsigned int(align::ID)> Counter
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
headers_const_iterator headers_begin() const
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
const edm::EDGetTokenT< LHEEventProduct > lheTag_
void fillOnlyPSWeightTable(Counter *counter, double genWeight, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outPS) const
const edm::InputTag lheLabel_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void fillLHEWeightTables(Counter *counter, const DynamicWeightChoice *weightChoice, double genWeight, const LHEEventProduct &lheProd, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outScale, std::unique_ptr< nanoaod::FlatTable > &outPdf, std::unique_ptr< nanoaod::FlatTable > &outNamed, std::unique_ptr< nanoaod::FlatTable > &outPS) const
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
std::vector< std::string > namedWeightLabels_
~GenWeightsTableProducer() override
GenWeightsTableProducer(edm::ParameterSet const ¶ms)
std::shared_ptr< Counter > globalBeginRunSummary(edm::Run const &, edm::EventSetup const &) const override
void put(std::unique_ptr< PROD > product)
Put a new product.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int maxPdfWeights_
const edm::EDGetTokenT< LHERunInfoProduct > lheRunTag_
std::vector< uint32_t > preferredPDFLHAIDs_
std::vector< double > & weights()
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::vector< std::string > namedWeightIDs_
void globalEndRunSummary(edm::Run const &, edm::EventSetup const &, Counter *runCounter) const override
Power< A, B >::type pow(const A &a, const B &b)
def merge(dictlist, TELL=False)