From c173343d141a4a1d8cd517e82804a98bf35f1c33 Mon Sep 17 00:00:00 2001 From: darksnake Date: Fri, 23 Dec 2016 16:53:33 +0300 Subject: [PATCH] u transformation for PrepareData --- .../inr/numass/actions/PrepareDataAction.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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 74b0822a..f6079bd4 100644 --- a/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java +++ b/numass-main/src/main/java/inr/numass/actions/PrepareDataAction.java @@ -29,11 +29,14 @@ import hep.dataforge.tables.*; import inr.numass.storage.NMPoint; import inr.numass.storage.NumassData; import inr.numass.storage.RawNMPoint; +import inr.numass.utils.ExpressionUtils; import java.io.OutputStream; import java.time.Instant; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; @@ -49,6 +52,7 @@ import static inr.numass.utils.TritiumUtils.pointExpression; @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`") +@ValueDef(name = "utransform", info = "Expression for voltage transformation. Uses U as input") @NodeDef(name = "correction", multiple = true, target = "method::inr.numass.actions.PrepareDataAction.makeCorrection") public class PrepareDataAction extends OneToOneAction { @@ -83,12 +87,24 @@ public class PrepareDataAction extends OneToOneAction { corrections.add((point) -> pointExpression(correction, point)); } + Function utransform; + if (meta.hasValue("utransform")) { + String func = meta.getString("utransform"); + utransform = u -> { + Map binding = new HashMap<>(); + binding.put("U", u); + return ExpressionUtils.function(func, binding); + }; + } else { + utransform = Function.identity(); + } + List dataList = new ArrayList<>(); for (NMPoint point : dataFile.getNMPoints()) { long total = point.getEventsCount(); - double uset = point.getUset(); - double uread = point.getUread(); + double uset = utransform.apply(point.getUset()); + double uread = utransform.apply(point.getUread()); double time = point.getLength(); int a = getLowerBorder(meta, uset); int b = Math.min(upper, RawNMPoint.MAX_CHANEL);