From f37f6a9db8faeec07d881cbfb206e592b3ec124b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Brochet?= Date: Wed, 18 May 2016 14:10:50 +0200 Subject: [PATCH] Protect against MC events without weight --- src/EventProducer.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/EventProducer.cc b/src/EventProducer.cc index 6a3e078..74a9653 100644 --- a/src/EventProducer.cc +++ b/src/EventProducer.cc @@ -199,6 +199,10 @@ void EventProducer::beginRun(const edm::Run& iRun, const edm::EventSetup& eventS std::cout << "Number of scales variation weights: " << m_scale_variations_matching.size() << std::endl; #endif + if (!m_scale_variations_matching.empty() && m_scale_variations_matching.size() != 6) { + std::cout << "\033[0;31m" << "Warning: invalid number of scale variation (6 was expected, only " << m_scale_variations_matching.size() << " found)." << "\033[0m" << std::endl; + } + break; } @@ -298,6 +302,16 @@ void EventProducer::produce(edm::Event& event_, const edm::EventSetup& eventSetu ht += std::sqrt(lhe_particles[iparticle][0]*lhe_particles[iparticle][0] + lhe_particles[iparticle][1]*lhe_particles[iparticle][1]); } + // Handle PDF & scale weights + + // No weight on some events... + if (lhe_info->weights().empty()) { + std::cout << "Warning: no weight for this event." << std::endl; + // Set scale weights to 1. PDF weights are already set to 1 by default + scale_weights.resize(6, 1); + goto end; + } + if (isLO && !scalup_decision_taken) { scalup_decision_taken = true;