From 6d6d0a72ee4ec26e3a1805256b7c7d74ae2b6e9a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 30 Nov 2016 12:42:44 +0300 Subject: [PATCH] Fix overflow count --- .../groovy/inr/numass/LaunchGrindShell.groovy | 24 +++++++++++-------- .../inr/numass/actions/PrepareDataAction.java | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy index d9074dab..dacec1c2 100644 --- a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy +++ b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy @@ -19,15 +19,19 @@ println "Loading config file from $cfgPath" //Global.instance().pluginManager().loadPlugin("inr.numass:numass") println "Starting Grind shell" -try { - new GrindShell().launch { - GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder() - .withSpec(NumassWorkspaceSpec) - .from(new File(cfgPath)) - bind("numass", numass) +if(cfgPath) { + try { + new GrindShell().launch { + GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder() + .withSpec(NumassWorkspaceSpec) + .from(new File(cfgPath)) + bind("numass", numass) + } + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + Global.terminate(); } -} catch (Exception ex) { - ex.printStackTrace(); -} finally { - Global.terminate(); +} else{ + println "No configuration path. Provide path via --config option" } \ No newline at end of file diff --git a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java index 6b7920a5..d3320b24 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -97,11 +97,11 @@ public class PrepareDataAction extends OneToOneAction { double correctionFactor = corrections.stream() .mapToDouble(cor -> cor.corr(point)) - .reduce((d1, d2) -> d1 * d2).getAsDouble(); + .reduce((d1, d2) -> d1 * d2).orElse(1); double relativeCorrectionError = Math.sqrt( corrections.stream() .mapToDouble(cor -> cor.relativeErr(point)) - .reduce((d1, d2) -> d1 * d1 + d2 * d2).getAsDouble() + .reduce((d1, d2) -> d1 * d1 + d2 * d2).orElse(0) ); double cr = wind / point.getLength() * correctionFactor;