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.ValuesAdapter;
|
||||
|
||||
import java.util.function.Function;
|
||||
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");
|
||||
}
|
||||
|
||||
Function<Double, Double> function = (x) -> model.getSpectrum().value(x, input.getParameters());
|
||||
|
||||
PlotFrame frame = PlotUtils.getPlotManager(context)
|
||||
.getPlotFrame(getName(), name, metaData.getMeta("frame", Meta.empty()));
|
||||
|
||||
XYFunctionPlot fit = new XYFunctionPlot("fit");
|
||||
fit.setDensity(100, false);
|
||||
XYFunctionPlot fit = new XYFunctionPlot("fit",(x) -> model.getSpectrum().value(x, input.getParameters()));
|
||||
fit.setDensity(100);
|
||||
fit.setSmoothing(true);
|
||||
// ensuring all data points are calculated explicitly
|
||||
StreamSupport.stream(data.spliterator(), false)
|
||||
|
@ -48,7 +48,7 @@ public class Numass {
|
||||
.ln()
|
||||
.text("\t")
|
||||
.content(
|
||||
MarkupUtils.INSTANCE.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
||||
MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
||||
)
|
||||
.ln()
|
||||
.text("***Allowed actions***", "red")
|
||||
@ -60,7 +60,7 @@ public class Numass {
|
||||
am.getAllActions()
|
||||
.map(name -> am.optAction(name).get())
|
||||
.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");
|
||||
|
@ -126,7 +126,7 @@ class NumassIO : BasicIOManager() {
|
||||
// String output = source.meta().getString("output", this.meta().getString("output", fileName + ".onComplete"));
|
||||
outputFile = dir.resolve(fileName)
|
||||
|
||||
return if (context.getBoolean("numass.consoleOutput", false)!!) {
|
||||
return if (context.getBoolean("numass.consoleOutput", false)) {
|
||||
TeeOutputStream(Files.newOutputStream(outputFile), System.out)
|
||||
} else {
|
||||
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 fit = XYFunctionPlot("fit")
|
||||
fit.setDensity(100, false)
|
||||
fit.setSmoothing(true)
|
||||
fit.setFunction(func)
|
||||
val fit = XYFunctionPlot("fit",func)
|
||||
fit.density = 100
|
||||
// ensuring all data points are calculated explicitly
|
||||
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 ->
|
||||
val alpha = meta.getDouble("tailAlpha", 0.0)!!
|
||||
val beta = meta.getDouble("tailBeta", 0.0)!!
|
||||
val alpha = meta.getDouble("tailAlpha", 0.0)
|
||||
val beta = meta.getDouble("tailBeta", 0.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 ->
|
||||
val A = meta.getDouble("resolution", 8.3e-5)!!//8.3e-5
|
||||
val from = meta.getDouble("from", 0.0)!!
|
||||
val to = meta.getDouble("to", 0.0)!!
|
||||
val A = meta.getDouble("resolution", 8.3e-5)//8.3e-5
|
||||
val from = meta.getDouble("from", 0.0)
|
||||
val to = meta.getDouble("to", 0.0)
|
||||
|
||||
val sp: ModularSpectrum
|
||||
sp = if (from == to) {
|
||||
@ -138,27 +138,27 @@ class NumassPlugin : BasicPlugin() {
|
||||
}
|
||||
|
||||
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 loss = EmpiricalLossSpectrum(interpolator, eGun + 5)
|
||||
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 }
|
||||
}
|
||||
|
||||
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
|
||||
val interpolator = buildInterpolator(context, meta, eGun)
|
||||
|
||||
val loss = VariableLossSpectrum.withData(interpolator, eGun + 5)
|
||||
|
||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||
|
||||
val spectrum: NBkgSpectrum
|
||||
if (tritiumBackground == 0.0) {
|
||||
@ -167,17 +167,17 @@ class NumassPlugin : BasicPlugin() {
|
||||
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 }
|
||||
}
|
||||
|
||||
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 tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||
|
||||
val spectrum: NBkgSpectrum
|
||||
if (tritiumBackground == 0.0) {
|
||||
@ -190,18 +190,18 @@ class NumassPlugin : BasicPlugin() {
|
||||
}
|
||||
|
||||
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
|
||||
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 spectrum = NBkgSpectrum(loss)
|
||||
|
||||
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)!!
|
||||
val weightReductionFactor = meta.getDouble("weightReductionFactor", 2.0)
|
||||
|
||||
WeightedXYModel(meta, getAdapter(meta), spectrum) { dp -> weightReductionFactor }
|
||||
}
|
||||
@ -216,7 +216,7 @@ class NumassPlugin : BasicPlugin() {
|
||||
manager.addModel("gun") { context, meta ->
|
||||
val gsp = GunSpectrum()
|
||||
|
||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)!!
|
||||
val tritiumBackground = meta.getDouble("tritiumBkg", 0.0)
|
||||
|
||||
val spectrum: NBkgSpectrum
|
||||
if (tritiumBackground == 0.0) {
|
||||
@ -234,10 +234,10 @@ class NumassPlugin : BasicPlugin() {
|
||||
val transXName = an.getString("transXName", "Uset")
|
||||
val transYName = an.getString("transYName", "CR")
|
||||
|
||||
val stitchBorder = an.getDouble("stitchBorder", eGun - 7)!!
|
||||
val nSmooth = an.getInt("nSmooth", 15)!!
|
||||
val stitchBorder = an.getDouble("stitchBorder", eGun - 7)
|
||||
val nSmooth = an.getInt("nSmooth", 15)
|
||||
|
||||
val w = an.getDouble("w", 0.8)!!
|
||||
val w = an.getDouble("w", 0.8)
|
||||
|
||||
if (an.hasValue("transFile")) {
|
||||
val transmissionFile = an.getString("transFile")
|
||||
|
@ -141,10 +141,10 @@ object NumassUtils {
|
||||
set.points.forEach { point ->
|
||||
val pointMeta = MetaBuilder("point")
|
||||
.putValue("voltage", point.voltage)
|
||||
.putValue("index", point.getMeta().getInt("external_meta.point_index", -1))
|
||||
.putValue("run", point.getMeta().getString("external_meta.session", ""))
|
||||
.putValue("group", point.getMeta().getString("external_meta.group", ""))
|
||||
val pointName = "point_" + point.getMeta().getInt("external_meta.point_index", point.hashCode())!!
|
||||
.putValue("index", point.meta.getInt("external_meta.point_index", -1))
|
||||
.putValue("run", point.meta.getString("external_meta.session", ""))
|
||||
.putValue("group", point.meta.getString("external_meta.group", ""))
|
||||
val pointName = "point_" + point.meta.getInt("external_meta.point_index", point.hashCode())
|
||||
builder.putData(pointName, point, pointMeta)
|
||||
}
|
||||
set.hvData.ifPresent { hv -> builder.putData("hv", hv, Meta.empty()) }
|
||||
|
@ -85,8 +85,8 @@ class TransformDataAction : OneToOneAction<Table, Table>() {
|
||||
.mapToDouble { cor -> cor.relativeErr(point) }
|
||||
.reduce { d1, d2 -> d1 * d1 + d2 * d2 }.orElse(0.0)
|
||||
)
|
||||
val originalCR = point.getDouble(COUNT_RATE_KEY)!!
|
||||
val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY)!!
|
||||
val originalCR = point.getDouble(COUNT_RATE_KEY)
|
||||
val originalCRErr = point.getDouble(COUNT_RATE_ERROR_KEY)
|
||||
cr.add(originalCR * correctionFactor)
|
||||
if (relativeCorrectionError == 0.0) {
|
||||
crErr.add(originalCRErr * correctionFactor)
|
||||
|
@ -40,8 +40,8 @@ class NumassResolution(context: Context, meta: Meta) : AbstractParametricBiFunct
|
||||
}
|
||||
meta.hasValue("tailAlpha") -> {
|
||||
//add polynomial function here
|
||||
val alpha = meta.getDouble("tailAlpha")!!
|
||||
val beta = meta.getDouble("tailBeta", 0.0)!!
|
||||
val alpha = meta.getDouble("tailAlpha")
|
||||
val beta = meta.getDouble("tailBeta", 0.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 lossCache = HashMap<Double, UnivariateFunction>()
|
||||
|
||||
private val adjustX: Boolean = meta.getBoolean("adjustX", false)!!
|
||||
private val adjustX: Boolean = meta.getBoolean("adjustX", false)
|
||||
|
||||
init {
|
||||
if (meta.hasValue("trapping")) {
|
||||
|
@ -51,7 +51,7 @@ class NumassFitScanSummaryTask : AbstractTask<Table>() {
|
||||
input.forEach { key, fitRes ->
|
||||
val pars = fitRes.parameters
|
||||
|
||||
val u2Val = pars.getDouble("U2")!! / pars.getError("U2")
|
||||
val u2Val = pars.getDouble("U2") / pars.getError("U2")
|
||||
|
||||
val limit: Double
|
||||
if (Math.abs(u2Val) < 3) {
|
||||
|
@ -209,8 +209,8 @@ val filterTask = task("filter") {
|
||||
}
|
||||
pipe<Table, Table> { data ->
|
||||
if (meta.hasValue("from") || meta.hasValue("to")) {
|
||||
val uLo = meta.getDouble("from", 0.0)!!
|
||||
val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY)!!
|
||||
val uLo = meta.getDouble("from", 0.0)
|
||||
val uHi = meta.getDouble("to", java.lang.Double.POSITIVE_INFINITY)
|
||||
this.log.report("Filtering finished")
|
||||
TableTransform.filter(data, NumassPoint.HV_KEY, uLo, uHi)
|
||||
} else if (meta.hasValue("condition")) {
|
||||
@ -264,10 +264,8 @@ val plotFitTask = task("plotFit") {
|
||||
val frame = PlotUtils.getPlotManager(context)
|
||||
.getPlotFrame("numass.plotFit", name, meta.getMeta("frame", Meta.empty()))
|
||||
|
||||
val fit = XYFunctionPlot("fit").apply {
|
||||
setFunction(function)
|
||||
setDensity(100, false)
|
||||
setSmoothing(true)
|
||||
val fit = XYFunctionPlot("fit", function).apply {
|
||||
density = 100
|
||||
}
|
||||
|
||||
frame.add(fit)
|
||||
|
Loading…
Reference in New Issue
Block a user