Fixes in DataNode logic
This commit is contained in:
parent
0af120d72f
commit
3f04679207
@ -15,11 +15,15 @@ import inr.numass.storage.NumassStorage
|
|||||||
import inr.numass.utils.UnderflowCorrection
|
import inr.numass.utils.UnderflowCorrection
|
||||||
|
|
||||||
File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1")
|
File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1")
|
||||||
|
//File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_2_wide")
|
||||||
|
//File rootDir = new File("D:\\Work\\Numass\\data\\2017_01\\Fill_2_wide")
|
||||||
|
|
||||||
NumassStorage storage = NumassStorage.buildLocalNumassRoot(rootDir, true);
|
NumassStorage storage = NumassStorage.buildLocalNumassRoot(rootDir, true);
|
||||||
|
|
||||||
Collection<NMPoint> data = NumassDataUtils.joinSpectra(
|
Collection<NMPoint> data = NumassDataUtils.joinSpectra(
|
||||||
StorageUtils.loaderStream(storage).filter { it.key.matches("set_.{2,3}") }.map {
|
StorageUtils.loaderStream(storage)
|
||||||
|
.filter { it.key.matches("set_.{2,3}") }
|
||||||
|
.map {
|
||||||
println "loading ${it.key}"
|
println "loading ${it.key}"
|
||||||
it.value
|
it.value
|
||||||
}
|
}
|
||||||
@ -77,7 +81,7 @@ def printPoint(Iterable<NMPoint> data, List us, int binning = 20, normalize = fa
|
|||||||
|
|
||||||
println "\n# spectra\n"
|
println "\n# spectra\n"
|
||||||
|
|
||||||
printPoint(data, [16200d, 16400d, 16800d, 17000d, 17200d])
|
printPoint(data, [16200d, 16400d, 16800d, 17000d, 17200d, 17700d])
|
||||||
|
|
||||||
println()
|
println()
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ public class NumassFitScanSummaryTask extends AbstractTask<Table> {
|
|||||||
Action<FitState, Table> action = new FitSummaryAction();
|
Action<FitState, Table> action = new FitSummaryAction();
|
||||||
DataNode<FitState> input = data.getCheckedNode("fitscan", FitState.class);
|
DataNode<FitState> input = data.getCheckedNode("fitscan", FitState.class);
|
||||||
input.nodeStream().filter(it -> it.dataSize(false) > 0).forEach(node ->
|
input.nodeStream().filter(it -> it.dataSize(false) > 0).forEach(node ->
|
||||||
builder.putData(node.getName(), action.run(model.getContext(), node, model.meta()).getData()));
|
builder.putData(node.getName(), action.run(model.getContext(), node, model.meta()).getData())
|
||||||
|
);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.utils;
|
package inr.numass.utils;
|
||||||
|
|
||||||
import hep.dataforge.io.reports.Logable;
|
|
||||||
import hep.dataforge.meta.Meta;
|
|
||||||
import hep.dataforge.tables.ListTable;
|
import hep.dataforge.tables.ListTable;
|
||||||
import hep.dataforge.tables.Table;
|
import hep.dataforge.tables.Table;
|
||||||
import inr.numass.storage.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import inr.numass.storage.RawNMPoint;
|
|
||||||
import org.apache.commons.math3.analysis.ParametricUnivariateFunction;
|
import org.apache.commons.math3.analysis.ParametricUnivariateFunction;
|
||||||
import org.apache.commons.math3.exception.DimensionMismatchException;
|
import org.apache.commons.math3.exception.DimensionMismatchException;
|
||||||
import org.apache.commons.math3.fitting.SimpleCurveFitter;
|
import org.apache.commons.math3.fitting.SimpleCurveFitter;
|
||||||
@ -26,31 +23,31 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class UnderflowCorrection {
|
public class UnderflowCorrection {
|
||||||
|
|
||||||
private final static int CUTOFF = -200;
|
// private final static int CUTOFF = -200;
|
||||||
|
|
||||||
public double get(Logable log, Meta meta, NMPoint point) {
|
// public double get(Logable log, Meta meta, NMPoint point) {
|
||||||
if (point.getUset() >= meta.getDouble("underflow.threshold", 17000)) {
|
// if (point.getUset() >= meta.getDouble("underflow.threshold", 17000)) {
|
||||||
if (meta.hasValue("underflow.function")) {
|
// if (meta.hasValue("underflow.function")) {
|
||||||
return TritiumUtils.pointExpression(meta.getString("underflow.function"), point);
|
// return TritiumUtils.pointExpression(meta.getString("underflow.function"), point);
|
||||||
} else {
|
// } else {
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
try {
|
// try {
|
||||||
int xLow = meta.getInt("underflow.lowerBorder", meta.getInt("lowerWindow"));
|
// int xLow = meta.getInt("underflow.lowerBorder", meta.getInt("lowerWindow"));
|
||||||
int xHigh = meta.getInt("underflow.upperBorder", 800);
|
// int xHigh = meta.getInt("underflow.upperBorder", 800);
|
||||||
int binning = meta.getInt("underflow.binning", 20);
|
// int binning = meta.getInt("underflow.binning", 20);
|
||||||
int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);
|
// int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);
|
||||||
long norm = point.getCountInWindow(xLow, upper);
|
// long norm = point.getCountInWindow(xLow, upper);
|
||||||
double[] fitRes = getUnderflowExpParameters(point, xLow, xHigh, binning);
|
// double[] fitRes = getUnderflowExpParameters(point, xLow, xHigh, binning);
|
||||||
double correction = fitRes[0] * fitRes[1] * (Math.exp(xLow / fitRes[1]) - 1d) / norm + 1d;
|
// double correction = fitRes[0] * fitRes[1] * (Math.exp(xLow / fitRes[1]) - 1d) / norm + 1d;
|
||||||
return correction;
|
// return correction;
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
log.reportError("Failed to calculate underflow parameters for point {} with message:", point.getUset(), ex.getMessage());
|
// log.reportError("Failed to calculate underflow parameters for point {} with message:", point.getUset(), ex.getMessage());
|
||||||
return 1d;
|
// return 1d;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Table fitAllPoints(Iterable<NMPoint> data, int xLow, int xHigh, int binning) {
|
public Table fitAllPoints(Iterable<NMPoint> data, int xLow, int xHigh, int binning) {
|
||||||
ListTable.Builder builder = new ListTable.Builder("U", "amp", "expConst");
|
ListTable.Builder builder = new ListTable.Builder("U", "amp", "expConst");
|
||||||
@ -70,7 +67,7 @@ public class UnderflowCorrection {
|
|||||||
double sigma = fitRes[1];
|
double sigma = fitRes[1];
|
||||||
|
|
||||||
//builder.row(point.getUset(), a, sigma, (a * sigma * (Math.exp(xLow / sigma) - 1) - a*xLow) / norm + 1d);
|
//builder.row(point.getUset(), a, sigma, (a * sigma * (Math.exp(xLow / sigma) - 1) - a*xLow) / norm + 1d);
|
||||||
builder.row(point.getUset(), a, sigma, a * sigma * (Math.exp(xLow / sigma) - Math.exp(CUTOFF / sigma)) / norm + 1d);
|
builder.row(point.getUset(), a, sigma, a * sigma * Math.exp(xLow / sigma) / norm + 1d);
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user