From 7563739fe1f26dd189639a052c7ba69afe662212 Mon Sep 17 00:00:00 2001 From: Abelardo Moralejo Date: Fri, 19 Apr 2024 09:51:07 +0200 Subject: [PATCH] Avoid crash in log message if no FF events were found --- lstchain/scripts/lstchain_r0_to_r0g.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lstchain/scripts/lstchain_r0_to_r0g.py b/lstchain/scripts/lstchain_r0_to_r0g.py index 11ccdbce9f..212a16c5e8 100644 --- a/lstchain/scripts/lstchain_r0_to_r0g.py +++ b/lstchain/scripts/lstchain_r0_to_r0g.py @@ -202,13 +202,14 @@ def main(): # If a relevant fraction of FF-like events were not tagged as FF...: max_frac = 0.1 - if ((num_FF_like_with_no_FF_type / num_FF_like > max_frac) & - (use_flatfield_heuristic == False)): - log.warn('More than %d percent of FF-like events ' - 'have wrong event_type!', int(100*max_frac)) - log.warn('You should use heuristic identification of FF events!') - else: - log.info('R0 to R0G conversion finished successfully!') + if num_FF_like > 0: + if ((num_FF_like_with_no_FF_type / num_FF_like > max_frac) & + (use_flatfield_heuristic == False)): + log.warn('More than %d percent of FF-like events ' + 'have wrong event_type!', int(100*max_frac)) + log.warn('You should use heuristic identification of FF events!') + else: + log.info('R0 to R0G conversion finished successfully!') def get_event_type(wf_hg, offset, evtype):