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); }