From 5f8d4031d15c86f243244df7aa1ee5a1e9c9a1ac Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 23 Nov 2016 18:21:27 +0300 Subject: [PATCH] fixed underflow calculation and viewer export --- .../main/java/inr/numass/utils/UnderflowCorrection.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java index 1307de30..9a84b1e5 100644 --- a/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java +++ b/numass-main/src/main/java/inr/numass/utils/UnderflowCorrection.java @@ -59,16 +59,16 @@ public class UnderflowCorrection { } return builder.build(); } - + public Table fitAllPoints(NumassData data, int xLow, int xHigh, int upper, int binning) { ListTable.Builder builder = new ListTable.Builder("U", "amp", "expConst", "correction"); for (NMPoint point : data.getNMPoints()) { - long norm = point.getCountInWindow(xLow, upper); + double norm = ((double) point.getCountInWindow(xLow, upper))/point.getLength(); double[] fitRes = getUnderflowExpParameters(point, xLow, xHigh, binning); builder.row(point.getUset(), fitRes[0], fitRes[1], fitRes[0] * fitRes[1] * (Math.exp(xLow / fitRes[1]) - 1d) / norm + 1d); } return builder.build(); - } + } /** * Calculate underflow exponent parameters using (xLow, xHigh) window for @@ -90,7 +90,8 @@ public class UnderflowCorrection { .map(p -> new WeightedObservedPoint( 1d / p.getValue() * point.getLength() * point.getLength(), //weight p.getKey(), // x - p.getValue() / binning / point.getLength())) //y + p.getValue() / binning / point.getLength())//y + ) .collect(Collectors.toList()); SimpleCurveFitter fitter = SimpleCurveFitter.create(new ExponentFunction(), new double[]{1d, 200d}); return fitter.fit(points);