Limited number of warnings when reading in negative weights in LHE file
@@ -122,6 +122,8 @@ def parse_lhe_file(
k_factor = k_factor / n_events_runcard
# Loop over events
+ n_negative_weights_warnings = 0
+
# Option one: XML parsing
if parse_events_as_xml:
@@ -138,8 +140,13 @@ def parse_lhe_file(
# Negative weights?
n_negative_weights = np.sum(np.array(list(weights.values())) < 0.0)
if n_negative_weights > 0:
+ if n_negative_weights_warnings < 5:
+ n_negative_weights_warnings += 1
logger.warning("Found %s negative weights in event: %s", n_negative_weights, weights)
+ if n_negative_weights_warnings >= 5:
+ logger.warning("Skipping warnings about negative weights from now on...")
+
if weight_names_all_events is None:
weight_names_all_events = list(weights.keys())
weights = list(weights.values())
@@ -216,8 +223,13 @@ def parse_lhe_file(
# Negative weights?
n_negative_weights = np.sum(np.array(list(weights.values())) < 0.0)
if n_negative_weights > 0:
+ if n_negative_weights_warnings < 5:
+ n_negative_weights_warnings += 1
logger.warning("Found %s negative weights in event: %s", n_negative_weights, weights)
+ if n_negative_weights_warnings >= 5:
+ logger.warning("Skipping warnings about negative weights from now on...")
+
if weight_names_all_events is None:
weight_names_all_events = list(weights.keys())
weights = list(weights.values())
