build fix
This commit is contained in:
parent
8ddf4a30f3
commit
1aa7f0edf5
@ -32,7 +32,6 @@ import hep.dataforge.tables.Adapters;
|
|||||||
import hep.dataforge.tables.NavigableValuesSource;
|
import hep.dataforge.tables.NavigableValuesSource;
|
||||||
import hep.dataforge.tables.ValuesAdapter;
|
import hep.dataforge.tables.ValuesAdapter;
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,13 +62,12 @@ public class PlotFitResultAction extends OneToOneAction<FitResult, FitResult> {
|
|||||||
throw new RuntimeException("No adapter defined for data interpretation");
|
throw new RuntimeException("No adapter defined for data interpretation");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
|
|
||||||
|
|
||||||
PlotFrame frame = PlotUtils.getPlotManager(context)
|
PlotFrame frame = PlotUtils.getPlotManager(context)
|
||||||
.getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty()));
|
.getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty()));
|
||||||
|
|
||||||
XYFunctionPlot fit = new XYFunctionPlot("fit");
|
XYFunctionPlot fit = new XYFunctionPlot("fit",(x) -> model.getSpectrum().value(x, input.getParameters()));
|
||||||
fit.setDensity(100, false);
|
fit.setDensity(100);
|
||||||
fit.setSmoothing(true);
|
fit.setSmoothing(true);
|
||||||
// ensuring all data points are calculated explicitly
|
// ensuring all data points are calculated explicitly
|
||||||
StreamSupport.stream(data.spliterator(), false)
|
StreamSupport.stream(data.spliterator(), false)
|
||||||
|
@ -48,7 +48,7 @@ public class Numass {
|
|||||||
.ln()
|
.ln()
|
||||||
.text("\t")
|
.text("\t")
|
||||||
.content(
|
.content(
|
||||||
MarkupUtils.INSTANCE.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
||||||
)
|
)
|
||||||
.ln()
|
.ln()
|
||||||
.text("***Allowed actions***", "red")
|
.text("***Allowed actions***", "red")
|
||||||
@ -60,7 +60,7 @@ public class Numass {
|
|||||||
am.getAllActions()
|
am.getAllActions()
|
||||||
.map(name -> am.optAction(name).get())
|
.map(name -> am.optAction(name).get())
|
||||||
.map(ActionDescriptor::build).forEach(descriptor ->
|
.map(ActionDescriptor::build).forEach(descriptor ->
|
||||||
builder.text("\t").content(MarkupUtils.INSTANCE.markupDescriptor(descriptor))
|
builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor))
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.text("***End of actions list***", "red");
|
builder.text("***End of actions list***", "red");
|
||||||
|
@ -126,7 +126,7 @@ class NumassIO : BasicIOManager() {
|
|||||||
// String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete"));
|
// String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete"));
|
||||||
outputFile = dir.resolve(fileName)
|
outputFile = dir.resolve(fileName)
|
||||||
|
|
||||||
return if (context.getBoolean("numass.consoleOutput", false)!!) {
|
return if (context.getBoolean("numass.consoleOutput", false)) {
|
||||||
TeeOutputStream(Files.newOutputStream(outputFile), System.out)
|
TeeOutputStream(Files.newOutputStream(outputFile), System.out)
|
||||||
} else {
|
} else {
|
||||||
Files.newOutputStream(outputFile)
|
Files.newOutputStream(outputFile)
|
||||||
@ -153,10 +153,8 @@ fun FitResult.display(context: Context, stage: String = "fit") {
|
|||||||
|
|
||||||
val func = { x: Double -> model.spectrum.value(x, parameters) }
|
val func = { x: Double -> model.spectrum.value(x, parameters) }
|
||||||
|
|
||||||
val fit = XYFunctionPlot("fit")
|
val fit = XYFunctionPlot("fit",func)
|
||||||
fit.setDensity(100, false)
|
fit.density = 100
|
||||||
fit.setSmoothing(true)
|
|
||||||
fit.setFunction(func)
|
|
||||||
// ensuring all data points are calculated explicitly
|
// ensuring all data points are calculated explicitly
|
||||||
data.rows.map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) }
|
data.rows.map { dp -> Adapters.getXValue(adapter, dp).doubleValue() }.sorted().forEach { fit.calculateIn(it) }
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
math.registerBivariate("numass.resolutionTail") { meta ->
|
math.registerBivariate("numass.resolutionTail") { meta ->
|
||||||
val alpha = meta.getDouble("tailAlpha", 0.0)!!
|
val alpha = meta.getDouble("tailAlpha", 0.0)
|
||||||
val beta = meta.getDouble("tailBeta", 0.0)!!
|
val beta = meta.getDouble("tailBeta", 0.0)
|
||||||
BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 }
|
BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
manager.addModel("scatter") { context, meta ->
|
manager.addModel("scatter") { context, meta ->
|
||||||
val A = meta.getDouble("resolution", 8.3e-5)!!//8.3e-5
|
val A = meta.getDouble("resolution", 8.3e-5)//8.3e-5
|
||||||
val from = meta.getDouble("from", 0.0)!!
|
val from = meta.getDouble("from", 0.0)
|
||||||
val to = meta.getDouble("to", 0.0)!!
|
val to = meta.getDouble("to", 0.0)
|
||||||
|
|
||||||
val sp: ModularSpectrum
|
val sp: ModularSpectrum
|
||||||
sp = if (from == to) {
|
sp = if (from == to) {
|
||||||
@ -138,27 +138,27 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager.addModel("scatter-empiric") { context, meta ->
|
manager.addModel("scatter-empiric") { context, meta ->
|
||||||
val eGun = meta.getDouble("eGun", 19005.0)!!
|
val eGun = meta.getDouble("eGun", 19005.0)
|
||||||
|
|
||||||
val interpolator = buildInterpolator(context, meta, eGun)
|
val interpolator = buildInterpolator(context, meta, eGun)
|
||||||
|
|
||||||
val loss = EmpiricalLossSpectrum(interpolator, eGun + 5)
|
val loss = EmpiricalLossSpectrum(interpolator, eGun + 5)
|
||||||
val spectrum = NBkgSpectrum(loss)
|
val spectrum = NBkgSpectrum(loss)
|
||||||
|
|
||||||
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!!
|
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)
|
||||||
|
|
||||||
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.addModel("scatter-empiric-variable") { context, meta ->
|
manager.addModel("scatter-empiric-variable") { context, meta ->
|
||||||
val eGun = meta.getDouble("eGun", 19005.0)!!
|
val eGun = meta.getDouble("eGun", 19005.0)
|
||||||
|
|
||||||
//builder transmisssion with given data, annotation and smoothing
|
//builder transmisssion with given data, annotation and smoothing
|
||||||
val interpolator = buildInterpolator(context, meta, eGun)
|
val interpolator = buildInterpolator(context, meta, eGun)
|
||||||
|
|
||||||
val loss = VariableLossSpectrum.withData(interpolator, eGun + 5)
|
val loss = VariableLossSpectrum.withData(interpolator, eGun + 5)
|
||||||
|
|
||||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||||
|
|
||||||
val spectrum: NBkgSpectrum
|
val spectrum: NBkgSpectrum
|
||||||
if (tritiumBackground == 0.0) {
|
if (tritiumBackground == 0.0) {
|
||||||
@ -167,17 +167,17 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground)
|
spectrum = CustomNBkgSpectrum.tritiumBkgSpectrum(loss, tritiumBackground)
|
||||||
}
|
}
|
||||||
|
|
||||||
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!!
|
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)
|
||||||
|
|
||||||
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.addModel("scatter-analytic-variable") { context, meta ->
|
manager.addModel("scatter-analytic-variable") { context, meta ->
|
||||||
val eGun = meta.getDouble("eGun", 19005.0)!!
|
val eGun = meta.getDouble("eGun", 19005.0)
|
||||||
|
|
||||||
val loss = VariableLossSpectrum.withGun(eGun + 5)
|
val loss = VariableLossSpectrum.withGun(eGun + 5)
|
||||||
|
|
||||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||||
|
|
||||||
val spectrum: NBkgSpectrum
|
val spectrum: NBkgSpectrum
|
||||||
if (tritiumBackground == 0.0) {
|
if (tritiumBackground == 0.0) {
|
||||||
@ -190,18 +190,18 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager.addModel("scatter-empiric-experimental") { context, meta ->
|
manager.addModel("scatter-empiric-experimental") { context, meta ->
|
||||||
val eGun = meta.getDouble("eGun", 19005.0)!!
|
val eGun = meta.getDouble("eGun", 19005.0)
|
||||||
|
|
||||||
//builder transmisssion with given data, annotation and smoothing
|
//builder transmisssion with given data, annotation and smoothing
|
||||||
val interpolator = buildInterpolator(context, meta, eGun)
|
val interpolator = buildInterpolator(context, meta, eGun)
|
||||||
|
|
||||||
val smoothing = meta.getDouble("lossSmoothing", 0.3)!!
|
val smoothing = meta.getDouble("lossSmoothing", 0.3)
|
||||||
|
|
||||||
val loss = ExperimentalVariableLossSpectrum.withData(interpolator, eGun + 5, smoothing)
|
val loss = ExperimentalVariableLossSpectrum.withData(interpolator, eGun + 5, smoothing)
|
||||||
|
|
||||||
val spectrum = NBkgSpectrum(loss)
|
val spectrum = NBkgSpectrum(loss)
|
||||||
|
|
||||||
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!!
|
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)
|
||||||
|
|
||||||
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
manager.addModel("gun") { context, meta ->
|
manager.addModel("gun") { context, meta ->
|
||||||
val gsp = GunSpectrum()
|
val gsp = GunSpectrum()
|
||||||
|
|
||||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||||
|
|
||||||
val spectrum: NBkgSpectrum
|
val spectrum: NBkgSpectrum
|
||||||
if (tritiumBackground == 0.0) {
|
if (tritiumBackground == 0.0) {
|
||||||
@ -234,10 +234,10 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
val transXName = an.getString("transXName", "Uset")
|
val transXName = an.getString("transXName", "Uset")
|
||||||
val transYName = an.getString("transYName", "CR")
|
val transYName = an.getString("transYName", "CR")
|
||||||
|
|
||||||
val stitchBorder = an.getDouble("stitchBorder", eGun - 7)!!
|
val stitchBorder = an.getDouble("stitchBorder", eGun - 7)
|
||||||
val nSmooth = an.getInt("nSmooth", 15)!!
|
val nSmooth = an.getInt("nSmooth", 15)
|
||||||
|
|
||||||
val w = an.getDouble("w", 0.8)!!
|
val w = an.getDouble("w", 0.8)
|
||||||
|
|
||||||
if (an.hasValue("transFile")) {
|
if (an.hasValue("transFile")) {
|
||||||
val transmissionFile = an.getString("transFile")
|
val transmissionFile = an.getString("transFile")
|
||||||
|
@ -141,10 +141,10 @@ object NumassUtils {
|
|||||||
set.points.forEach { point ->
|
set.points.forEach { point ->
|
||||||
val pointMeta = MetaBuilder("point")
|
val pointMeta = MetaBuilder("point")
|
||||||
.putValue("voltage", point.voltage)
|
.putValue("voltage", point.voltage)
|
||||||
.putValue("index", point.getMeta().getInt("external_meta.point_index", -1))
|
.putValue("index", point.meta.getInt("external_meta.point_index", -1))
|
||||||
.putValue("run", point.getMeta().getString("external_meta.session", ""))
|
.putValue("run", point.meta.getString("external_meta.session", ""))
|
||||||
.putValue("group", point.getMeta().getString("external_meta.group", ""))
|
.putValue("group", point.meta.getString("external_meta.group", ""))
|
||||||
val pointName = "point_" + point.getMeta().getInt("external_meta.point_index", point.hashCode())!!
|
val pointName = "point_" + point.meta.getInt("external_meta.point_index", point.hashCode())
|
||||||
builder.putData(pointName, point, pointMeta)
|
builder.putData(pointName, point, pointMeta)
|
||||||
}
|
}
|
||||||
set.hvData.ifPresent { hv -> builder.putData("hv", hv, Meta.empty()) }
|
set.hvData.ifPresent { hv -> builder.putData("hv", hv, Meta.empty()) }
|
||||||
|
@ -85,8 +85,8 @@ class TransformDataAction : OneToOneAction<Table, Table>() {
|
|||||||
.mapToDouble { cor -> cor.relativeErr(point) }
|
.mapToDouble { cor -> cor.relativeErr(point) }
|
||||||
.reduce { d1, d2 -> d1 * d1 + d2 * d2 }.orElse(0.0)
|
.reduce { d1, d2 -> d1 * d1 + d2 * d2 }.orElse(0.0)
|
||||||
)
|
)
|
||||||
val originalCR = point.getDouble(COUNT_RATE_KEY)!!
|
val originalCR = point.getDouble(COUNT_RATE_KEY)
|
||||||
val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY)!!
|
val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY)
|
||||||
cr.add(originalCR * correctionFactor)
|
cr.add(originalCR * correctionFactor)
|
||||||
if (relativeCorrectionError == 0.0) {
|
if (relativeCorrectionError == 0.0) {
|
||||||
crErr.add(originalCRErr * correctionFactor)
|
crErr.add(originalCRErr * correctionFactor)
|
||||||
|
@ -40,8 +40,8 @@ class NumassResolution(context: Context, meta: Meta) : AbstractParametricBiFunct
|
|||||||
}
|
}
|
||||||
meta.hasValue("tailAlpha") -> {
|
meta.hasValue("tailAlpha") -> {
|
||||||
//add polynomial function here
|
//add polynomial function here
|
||||||
val alpha = meta.getDouble("tailAlpha")!!
|
val alpha = meta.getDouble("tailAlpha")
|
||||||
val beta = meta.getDouble("tailBeta", 0.0)!!
|
val beta = meta.getDouble("tailBeta", 0.0)
|
||||||
BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 }
|
BivariateFunction { E: Double, U: Double -> 1 - (E - U) * (alpha + E / 1000.0 * beta) / 1000.0 }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun
|
|||||||
private val trapFunc: BivariateFunction
|
private val trapFunc: BivariateFunction
|
||||||
//private val lossCache = HashMap<Double, UnivariateFunction>()
|
//private val lossCache = HashMap<Double, UnivariateFunction>()
|
||||||
|
|
||||||
private val adjustX: Boolean = meta.getBoolean("adjustX", false)!!
|
private val adjustX: Boolean = meta.getBoolean("adjustX", false)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (meta.hasValue("trapping")) {
|
if (meta.hasValue("trapping")) {
|
||||||
|
@ -51,7 +51,7 @@ class NumassFitScanSummaryTask : AbstractTask<Table>() {
|
|||||||
input.forEach { key, fitRes ->
|
input.forEach { key, fitRes ->
|
||||||
val pars = fitRes.parameters
|
val pars = fitRes.parameters
|
||||||
|
|
||||||
val u2Val = pars.getDouble("U2")!! / pars.getError("U2")
|
val u2Val = pars.getDouble("U2") / pars.getError("U2")
|
||||||
|
|
||||||
val limit: Double
|
val limit: Double
|
||||||
if (Math.abs(u2Val) < 3) {
|
if (Math.abs(u2Val) < 3) {
|
||||||
|
@ -209,8 +209,8 @@ val filterTask = task("filter") {
|
|||||||
}
|
}
|
||||||
pipe<Table, Table> { data ->
|
pipe<Table, Table> { data ->
|
||||||
if (meta.hasValue("from") || meta.hasValue("to")) {
|
if (meta.hasValue("from") || meta.hasValue("to")) {
|
||||||
val uLo = meta.getDouble("from", 0.0)!!
|
val uLo = meta.getDouble("from", 0.0)
|
||||||
val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY)!!
|
val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY)
|
||||||
this.log.report("Filtering finished")
|
this.log.report("Filtering finished")
|
||||||
TableTransform.filter(data, NumassPoint.HV_KEY, uLo, uHi)
|
TableTransform.filter(data, NumassPoint.HV_KEY, uLo, uHi)
|
||||||
} else if (meta.hasValue("condition")) {
|
} else if (meta.hasValue("condition")) {
|
||||||
@ -264,10 +264,8 @@ val plotFitTask = task("plotFit") {
|
|||||||
val frame = PlotUtils.getPlotManager(context)
|
val frame = PlotUtils.getPlotManager(context)
|
||||||
.getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty()))
|
.getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty()))
|
||||||
|
|
||||||
val fit = XYFunctionPlot("fit").apply {
|
val fit = XYFunctionPlot("fit", function).apply {
|
||||||
setFunction(function)
|
density = 100
|
||||||
setDensity(100, false)
|
|
||||||
setSmoothing(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.add(fit)
|
frame.add(fit)
|
||||||
|
Loading…
Reference in New Issue
Block a user