From 677f4de91fb7720325a673bf054d7ff86736b4b3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 20 May 2017 19:46:44 +0300 Subject: [PATCH] Meta merger update using hidden values --- .../numass/actions/ReadLegacyDataAction.java | 1 - .../models/sterile/NumassResolution.java | 31 ++++++++++--------- .../inr/numass/utils/ExpressionUtils.java | 6 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java b/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java index 888cf79c..b69aba0f 100644 --- a/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ReadLegacyDataAction.java @@ -52,7 +52,6 @@ public class ReadLegacyDataAction extends OneToOneAction { if (meta.hasMeta("debunch")) { DebunchAction debunch = new DebunchAction(); Laminate laminate = new Laminate(meta.getMeta("debunch")) - .setValueContext(context) .setDescriptor(debunch.getDescriptor()); raw = debunch.execute(context, name, raw, laminate); } diff --git a/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java b/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java index fcb4e418..3b526314 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/NumassResolution.java @@ -34,24 +34,25 @@ public class NumassResolution extends AbstractParametricBiFunction { super(list); this.resA = meta.getDouble("A", 8.3e-5); this.resB = meta.getDouble("B", 0); - if (meta.hasValue("tailAlpha")) { - //add polinomial function here + if (meta.hasValue("tail")) { + String tailFunctionStr = meta.getString("tail"); + if (tailFunctionStr.startsWith("function::")) { + tailFunction = MathPlugin.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10)); + } else { + tailFunction = (E, U) -> { + Map binding = new HashMap<>(); + binding.put("E", E); + binding.put("U", U); + binding.put("D", U - E); + return ExpressionUtils.function(tailFunctionStr, binding); + }; + } + } else if (meta.hasValue("tailAlpha")) { + //add polynomial function here double alpha = meta.getDouble("tailAlpha"); double beta = meta.getDouble("tailBeta", 0); tailFunction = (double E, double U) -> 1 - (E - U) * (alpha + E / 1000d * beta) / 1000d; - } else if (meta.hasValue("tail")) { - String tailFunctionStr = meta.getString("tail"); - if (tailFunctionStr.startsWith("function::")) { - tailFunction = MathPlugin.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10)); - } else { - tailFunction = (E, U) -> { - Map binding = new HashMap<>(); - binding.put("E", E); - binding.put("U", U); - binding.put("D", U - E); - return ExpressionUtils.function(tailFunctionStr, binding); - }; - } + } else { tailFunction = ResolutionFunction.getConstantTail(); } diff --git a/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java b/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java index 9f1eb62c..4b25ddd0 100644 --- a/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java @@ -34,11 +34,11 @@ public class ExpressionUtils { } private static Script getScript(String expression) { - return cache.computeIfAbsent(expression, expr -> shell.parse(expr)); + return cache.computeIfAbsent(expression, shell::parse); } - public static double function(String expression, Map binding) { + public static double function(String expression, Map binding) { synchronized (cache) { Binding b = new Binding(binding); Script script = getScript(expression); @@ -47,7 +47,7 @@ public class ExpressionUtils { } } - public static boolean condition(String expression, Map binding){ + public static boolean condition(String expression, Map binding){ synchronized (cache) { Binding b = new Binding(binding); Script script = getScript(expression);