Skip to content

Commit

Permalink
Fix mistake in making LHE weights optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Aug 3, 2020
1 parent 3180b59 commit 2622c40
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions PhysicsTools/NanoAOD/plugins/LHEWeightsTableProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ class LHEWeightsTableProducer : public edm::global::EDProducer<edm::LuminosityBl
void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {
edm::Handle<GenWeightProduct> lheWeightHandle;
bool foundLheWeights = false;
if (foundLheWeights) {
for (auto& token : lheWeightTokens_) {
iEvent.getByToken(token, lheWeightHandle);
if (lheWeightHandle.isValid()) {
break;
}
for (auto& token : lheWeightTokens_) {
iEvent.getByToken(token, lheWeightHandle);
if (lheWeightHandle.isValid()) {
foundLheWeights = true;
break;
}
}

Expand All @@ -72,8 +71,10 @@ class LHEWeightsTableProducer : public edm::global::EDProducer<edm::LuminosityBl
auto const& weightInfos = *luminosityBlockCache(iEvent.getLuminosityBlock().index());

auto lheWeightTables = std::make_unique<std::vector<nanoaod::FlatTable>>();
if (foundLheWeights)
if (foundLheWeights) {
std::cout << "Adding LHEweights\n";
addWeightGroupToTable(lheWeightTables, "LHE", weightInfos.at(inLHE), lheWeights);
}
addWeightGroupToTable(lheWeightTables, "Gen", weightInfos.at(inGen), genWeights);

iEvent.put(std::move(lheWeightTables));
Expand All @@ -87,6 +88,8 @@ class LHEWeightsTableProducer : public edm::global::EDProducer<edm::LuminosityBl
for (auto& type : gen::allWeightTypes)
typeCount[type] = 0;

std::cout << "Adding type " << typeName << std::endl;

for (const auto& groupInfo : weightInfos) {
std::string entryName = typeName;
gen::WeightType weightType = groupInfo.group->weightType();
Expand All @@ -96,7 +99,7 @@ class LHEWeightsTableProducer : public edm::global::EDProducer<edm::LuminosityBl

auto& weights = allWeights.at(groupInfo.index);
label.append("; ");
if (weightType == gen::WeightType::kScaleWeights && groupInfo.group->isWellFormed() &&
if (false && weightType == gen::WeightType::kScaleWeights && groupInfo.group->isWellFormed() &&
groupInfo.group->nIdsContained() < 10) {
weights = orderedScaleWeights(weights, dynamic_cast<const gen::ScaleWeightGroupInfo*>(groupInfo.group));
label.append(
Expand Down

0 comments on commit 2622c40

Please sign in to comment.