Skip to content

Commit 405f584

Browse files
authored
Merge pull request #47253 from hqucms/xpog/fix-ps-wgt
[NANO] Fix PS weight parsing
2 parents e767d8d + 4ac2ce7 commit 405f584

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc

+14-9
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
519519
for (int i = 0; i < vectorSize; i++) {
520520
wPS.push_back(genWeights.at(i + 2) / nominal);
521521
}
522-
psWeightDocStr = "All PS weights (w_var / w_nominal)";
522+
psWeightDocStr = ((int)genWeightChoice->psWeightIDs.size() == vectorSize)
523+
? genWeightChoice->psWeightsDoc
524+
: "All PS weights (w_var / w_nominal)";
523525
} else {
524526
if (!psWeightWarning_.exchange(true))
525527
edm::LogWarning("LHETablesProducer")
@@ -530,8 +532,8 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
530532
wPS.push_back(genWeights.at(i) / nominal);
531533
}
532534
psWeightDocStr =
533-
"PS weights (w_var / w_nominal); [0] is ISR=2 FSR=1; [1] is ISR=1 FSR=2"
534-
"[2] is ISR=0.5 FSR=1; [3] is ISR=1 FSR=0.5;";
535+
"PS weights (w_var / w_nominal); default (maybe incorrect) order is: "
536+
"[0] is ISR=2 FSR=1; [1] is ISR=1 FSR=2; [2] is ISR=0.5 FSR=1; [3] is ISR=1 FSR=0.5;";
535537
}
536538
} else {
537539
wPS.push_back(1.0);
@@ -989,7 +991,7 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
989991

990992
std::regex scalew("LHE,\\s+id\\s+=\\s+(\\d+),\\s+(.+)\\,\\s+mur=(\\S+)\\smuf=(\\S+)");
991993
std::regex pdfw("LHE,\\s+id\\s+=\\s+(\\d+),\\s+(.+),\\s+Member\\s+(\\d+)\\s+of\\ssets\\s+(\\w+\\b)");
992-
std::regex mainPSw("sr(Def|:murfac=)(Hi|Lo|_dn|_up|0.5|2.0)");
994+
std::regex mainPSw("sr(Def|:murfac=|\\.murfac=)(Hi|Lo|_dn|_up|0\\.5|2\\.0)");
993995
std::smatch groups;
994996
auto weightNames = genLumiInfoHead->weightNames();
995997
std::unordered_map<std::string, uint32_t> knownPDFSetsFromGenInfo_;
@@ -1017,7 +1019,8 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
10171019
} else if (line == "Baseline") {
10181020
weightChoice->psBaselineID = weightIter;
10191021
} else if (line.find("isr") != std::string::npos || line.find("fsr") != std::string::npos) {
1020-
weightChoice->matchPS_alt = line.find("sr:") != std::string::npos; // (f/i)sr: for new weights
1022+
weightChoice->matchPS_alt = line.find("sr:") != std::string::npos ||
1023+
line.find("sr.") != std::string::npos; // (f/i)sr: for new weights
10211024
if (keepAllPSWeights_) {
10221025
weightChoice->psWeightIDs.push_back(weightIter); // PS variations
10231026
} else if (std::regex_search(line, groups, mainPSw)) {
@@ -1031,18 +1034,20 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
10311034
weightIter++;
10321035
}
10331036
if (keepAllPSWeights_) {
1034-
weightChoice->psWeightsDoc = "All PS weights (w_var / w_nominal)";
1037+
weightChoice->psWeightsDoc = "All PS weights (w_var / w_nominal) ";
10351038
} else if (weightChoice->psWeightIDs.size() == 4) {
1036-
weightChoice->psWeightsDoc =
1037-
"PS weights (w_var / w_nominal); [0] is ISR=2 FSR=1; [1] is ISR=1 FSR=2"
1038-
"[2] is ISR=0.5 FSR=1; [3] is ISR=1 FSR=0.5;";
1039+
weightChoice->psWeightsDoc = "PS weights (w_var / w_nominal) ";
10391040
for (int i = 0; i < 4; i++) {
10401041
if (static_cast<int>(weightChoice->psWeightIDs[i]) == -1)
10411042
weightChoice->setMissingWeight(i);
10421043
}
10431044
} else {
10441045
weightChoice->psWeightsDoc = "dummy PS weight (1.0) ";
10451046
}
1047+
for (unsigned i = 0; i < weightChoice->psWeightIDs.size(); ++i) {
1048+
weightChoice->psWeightsDoc +=
1049+
"[" + std::to_string(i) + "] " + weightNames.at(weightChoice->psWeightIDs.at(i)) + "; ";
1050+
}
10461051

10471052
weightChoice->scaleWeightIDs.clear();
10481053
weightChoice->pdfWeightIDs.clear();

0 commit comments

Comments
 (0)