From 4b22e22a28f2201cb494351d552fa8dee4d91143 Mon Sep 17 00:00:00 2001 From: darksnake Date: Wed, 23 Nov 2016 18:32:06 +0300 Subject: [PATCH] add count rate to tritium utils expression --- .../java/inr/numass/actions/PrepareDataAction.java | 10 +++++++--- .../main/java/inr/numass/utils/ExpressionUtils.java | 2 +- .../src/main/java/inr/numass/utils/TritiumUtils.java | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) 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 b8f3fbb7..6b7920a5 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -45,7 +45,7 @@ import static inr.numass.utils.TritiumUtils.evaluateExpression; @ValueDef(name = "lowerWindow", type = "NUMBER", def = "0", info = "Base for the window lowerWindow bound") @ValueDef(name = "lowerWindowSlope", type = "NUMBER", def = "0", info = "Slope for the window lowerWindow bound") @ValueDef(name = "upperWindow", type = "NUMBER", info = "Upper bound for window") -@ValueDef(name = "deadTime", type = "[NUMBER, STRING]", def = "0", info = "Dead time in s. Could be an expression.") +@ValueDef(name = "deadTime", type = "[NUMBER, STRING]", info = "Dead time in s. Could be an expression.") @ValueDef(name = "correction", info = "An expression to correct count number depending on potential `U`, point length `T` and point itself as `point`") @NodeDef(name = "correction", multiple = true, target = "method::inr.numass.actions.PrepareDataAction.makeCorrection") @@ -207,12 +207,16 @@ public class PrepareDataAction extends OneToOneAction { @Override public double corr(NMPoint point) { double deadTime = deadTimeFunction.apply(point); - double factor = deadTime / point.getLength() * point.getEventsCount(); + if (deadTime > 0) { + double factor = deadTime / point.getLength() * point.getEventsCount(); // double total = point.getEventsCount(); // double time = point.getLength(); // return 1d/(1d - factor); - return (1d - Math.sqrt(1d - 4d * factor)) / 2d / factor; + return (1d - Math.sqrt(1d - 4d * factor)) / 2d / factor; + } else { + return 1d; + } } } 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 091cdcdb..8324a503 100644 --- a/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/ExpressionUtils.java @@ -26,7 +26,7 @@ public class ExpressionUtils { ImportCustomizer importCustomizer = new ImportCustomizer(); // import static com.mrhaki.blog.Type.* importCustomizer.addStaticStars("java.lang.Math"); - importCustomizer.addStaticStars("org.apache.commons.math3.util.FastMath"); + //importCustomizer.addStaticStars("org.apache.commons.math3.util.FastMath"); CompilerConfiguration configuration = new CompilerConfiguration(); configuration.addCompilationCustomizers(importCustomizer); // Create shell and execute script. diff --git a/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java b/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java index 750c7751..340c2d02 100644 --- a/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java +++ b/numass-main/src/main/java/inr/numass/utils/TritiumUtils.java @@ -137,6 +137,7 @@ public class TritiumUtils { Map exprParams = new HashMap<>(); exprParams.put("T", point.getLength()); exprParams.put("U", point.getUread()); + exprParams.put("cr", ((double) point.getEventsCount()) / point.getLength()); exprParams.put("point", point); return ExpressionUtils.evaluate(expression, exprParams); }