From fffff2f1f30b80e354f2e440ecfb64485c158b6b Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 9 Mar 2022 14:54:44 +0100 Subject: [PATCH] Tighten check for the number of weights --- .../EventGenerator/plugins/GenWeightValidation.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Validation/EventGenerator/plugins/GenWeightValidation.cc b/Validation/EventGenerator/plugins/GenWeightValidation.cc index f864810f9372a..a753e8fc81df0 100644 --- a/Validation/EventGenerator/plugins/GenWeightValidation.cc +++ b/Validation/EventGenerator/plugins/GenWeightValidation.cc @@ -122,17 +122,18 @@ void GenWeightValidation::dqmBeginRun(const edm::Run&, const edm::EventSetup&) { void GenWeightValidation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { weights_ = wmanager_.weightsCollection(iEvent); - if (weights_.at(idxGenEvtInfo_).empty()) - return; // no weights in GenEventInfo + unsigned weightsSize = weights_.at(idxGenEvtInfo_).size(); + if (weightsSize < 2) + return; // no baseline weight in GenEventInfo weight_ = weights_.at(idxGenEvtInfo_)[0] / std::abs(weights_.at(idxGenEvtInfo_)[0]); nEvt_->Fill(0.5, weight_); - nlogWgt_->Fill(std::log10(weights_.at(idxGenEvtInfo_).size()), weight_); + nlogWgt_->Fill(std::log10(weightsSize), weight_); - for (unsigned idx = 0; idx < weights_.at(idxGenEvtInfo_).size(); idx++) + for (unsigned idx = 0; idx < weightsSize; idx++) wgtVal_->Fill(weights_.at(idxGenEvtInfo_)[idx] / weights_.at(idxGenEvtInfo_)[1], weight_); - if ((int)weights_.at(idxGenEvtInfo_).size() <= idxMax_) + if ((int)weightsSize <= idxMax_) return; // no PS weights in GenEventInfo edm::Handle ptcls;