diff --git a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt index 7359b87f..58678074 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt @@ -19,7 +19,7 @@ import hep.dataforge.actions.ActionManager import hep.dataforge.context.* import hep.dataforge.fx.FXPlugin import hep.dataforge.fx.plots.PlotContainer -import hep.dataforge.maths.MathPlugin +import hep.dataforge.maths.functions.FunctionLibrary import hep.dataforge.meta.Meta import hep.dataforge.plots.jfreechart.JFreeChartFrame import hep.dataforge.stat.models.ModelManager @@ -41,7 +41,7 @@ import org.apache.commons.math3.util.FastMath @PluginDef( group = "inr.numass", name = "numass", - dependsOn = arrayOf("hep.dataforge:math", "hep.dataforge:MINUIT", "hep.dataforge:actions", "hep.dataforge:io.dir"), + dependsOn = arrayOf("hep.dataforge:functions", "hep.dataforge:MINUIT", "hep.dataforge:actions", "hep.dataforge:io.dir"), support = false, info = "Numass data analysis tools" ) @@ -51,7 +51,7 @@ class NumassPlugin : BasicPlugin() { // StorageManager.buildFrom(context); super.attach(context) loadModels(context[ModelManager::class.java]) - loadMath(MathPlugin.buildFrom(context)) + loadMath(FunctionLibrary.buildFrom(context)) context.get(ActionManager::class.java).apply { putTask(NumassFitScanTask::class.java) @@ -71,28 +71,28 @@ class NumassPlugin : BasicPlugin() { } - private fun loadMath(math: MathPlugin) { - math.registerBivariate("numass.trap.lowFields") { Ei, Ef -> 3.92e-5 * FastMath.exp(-(Ei - Ef) / 300.0) + 1.97e-4 - 6.818e-9 * Ei } + private fun loadMath(math: FunctionLibrary) { + math.addBivariate("numass.trap.lowFields") { Ei, Ef -> 3.92e-5 * FastMath.exp(-(Ei - Ef) / 300.0) + 1.97e-4 - 6.818e-9 * Ei } - math.registerBivariate("numass.trap.nominal") { Ei, Ef -> + math.addBivariate("numass.trap.nominal") { Ei, Ef -> //return 1.64e-5 * FastMath.exp(-(Ei - Ef) / 300d) + 1.1e-4 - 4e-9 * Ei; 1.2e-4 - 4.5e-9 * Ei } - math.registerBivariate("numass.resolutionTail") { meta -> + math.addBivariateFactory("numass.resolutionTail") { meta -> 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 } } - math.registerBivariate("numass.resolutionTail.2017") { meta -> + math.addBivariateFactory("numass.resolutionTail.2017") { meta -> BivariateFunction { E: Double, U: Double -> val D = E - U 0.99797 - 3.05346E-7 * D - 5.45738E-10 * Math.pow(D, 2.0) - 6.36105E-14 * Math.pow(D, 3.0) } } - math.registerBivariate("numass.resolutionTail.2017.mod") { meta -> + math.addBivariateFactory("numass.resolutionTail.2017.mod") { meta -> BivariateFunction { E: Double, U: Double -> val D = E - U val factor = 7.33 - E / 1000.0 / 3.0 diff --git a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt index e4056aec..6ede3191 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassResolution.kt @@ -6,7 +6,7 @@ package inr.numass.models.sterile import hep.dataforge.context.Context -import hep.dataforge.maths.MathPlugin +import hep.dataforge.maths.functions.FunctionLibrary import hep.dataforge.meta.Meta import hep.dataforge.stat.parametric.AbstractParametricBiFunction import hep.dataforge.values.Values @@ -27,7 +27,7 @@ class NumassResolution(context: Context, meta: Meta) : AbstractParametricBiFunct meta.hasValue("tail") -> { val tailFunctionStr = meta.getString("tail") if (tailFunctionStr.startsWith("function::")) { - MathPlugin.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10)) + FunctionLibrary.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10)) } else { BivariateFunction { E, U -> val binding = HashMap() diff --git a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt index f2cddb0d..61b03b91 100644 --- a/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt +++ b/numass-main/src/main/kotlin/inr/numass/models/sterile/NumassTransmission.kt @@ -6,7 +6,7 @@ package inr.numass.models.sterile import hep.dataforge.context.Context -import hep.dataforge.maths.MathPlugin +import hep.dataforge.maths.functions.FunctionLibrary import hep.dataforge.meta.Meta import hep.dataforge.stat.parametric.AbstractParametricBiFunction import hep.dataforge.values.Values @@ -30,7 +30,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun if (meta.hasValue("trapping")) { val trapFuncStr = meta.getString("trapping") trapFunc = if (trapFuncStr.startsWith("function::")) { - MathPlugin.buildFrom(context).buildBivariateFunction(trapFuncStr.substring(10)) + FunctionLibrary.buildFrom(context).buildBivariateFunction(trapFuncStr.substring(10)) } else { BivariateFunction { Ei: Double, Ef: Double -> val binding = HashMap() @@ -41,7 +41,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun } } else { LoggerFactory.getLogger(javaClass).warn("Trapping function not defined. Using default") - trapFunc = MathPlugin.buildFrom(context).buildBivariateFunction("numass.trap.nominal") + trapFunc = FunctionLibrary.buildFrom(context).buildBivariateFunction("numass.trap.nominal") } } @@ -59,7 +59,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun } private fun getTrapFunction(context: Context, meta: Meta): BivariateFunction { - return MathPlugin.buildFrom(context).buildBivariateFunction(meta) + return FunctionLibrary.buildFrom(context).buildBivariateFunction(meta) } override fun derivValue(parName: String, eIn: Double, eOut: Double, set: Values): Double { diff --git a/numass-main/src/test/java/inr/numass/NumassTest.java b/numass-main/src/test/java/inr/numass/NumassTest.java index dde49118..e0118778 100644 --- a/numass-main/src/test/java/inr/numass/NumassTest.java +++ b/numass-main/src/test/java/inr/numass/NumassTest.java @@ -6,7 +6,7 @@ package inr.numass; import hep.dataforge.context.Context; -import hep.dataforge.maths.MathPlugin; +import hep.dataforge.maths.functions.FunctionLibrary; import org.junit.Test; /** @@ -24,7 +24,7 @@ public class NumassTest { @Test public void testBuildContext() { Context context = Numass.buildContext(); - MathPlugin.buildFrom(context); + FunctionLibrary.Companion.buildFrom(context); } } diff --git a/numass-main/src/test/java/inr/numass/models/TestModels.kt b/numass-main/src/test/java/inr/numass/models/TestModels.kt index 8378a20d..47996a54 100644 --- a/numass-main/src/test/java/inr/numass/models/TestModels.kt +++ b/numass-main/src/test/java/inr/numass/models/TestModels.kt @@ -7,7 +7,7 @@ package inr.numass.models import hep.dataforge.context.Context import hep.dataforge.kodex.step -import hep.dataforge.maths.MathPlugin +import hep.dataforge.maths.functions.FunctionLibrary import hep.dataforge.meta.Meta import hep.dataforge.meta.MetaBuilder import hep.dataforge.stat.fit.ParamSet @@ -79,7 +79,7 @@ private fun oldModel(context: Context, meta: Meta): ParametricFunction { //Adding trapping energy dependence if (meta.hasValue("transmission.trapping")) { - val trap = MathPlugin.buildFrom(context).buildBivariateFunction(meta.getString("transmission.trapping")) + val trap = FunctionLibrary.buildFrom(context).buildBivariateFunction(meta.getString("transmission.trapping")) sp.setTrappingFunction(trap) }