Working on function libraries
This commit is contained in:
parent
85bf98fa71
commit
320ee2f5b0
@ -19,7 +19,7 @@ import hep.dataforge.actions.ActionManager
|
|||||||
import hep.dataforge.context.*
|
import hep.dataforge.context.*
|
||||||
import hep.dataforge.fx.FXPlugin
|
import hep.dataforge.fx.FXPlugin
|
||||||
import hep.dataforge.fx.plots.PlotContainer
|
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.meta.Meta
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame
|
||||||
import hep.dataforge.stat.models.ModelManager
|
import hep.dataforge.stat.models.ModelManager
|
||||||
@ -41,7 +41,7 @@ import org.apache.commons.math3.util.FastMath
|
|||||||
@PluginDef(
|
@PluginDef(
|
||||||
group = "inr.numass",
|
group = "inr.numass",
|
||||||
name = "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,
|
support = false,
|
||||||
info = "Numass data analysis tools"
|
info = "Numass data analysis tools"
|
||||||
)
|
)
|
||||||
@ -51,7 +51,7 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
// StorageManager.buildFrom(context);
|
// StorageManager.buildFrom(context);
|
||||||
super.attach(context)
|
super.attach(context)
|
||||||
loadModels(context[ModelManager::class.java])
|
loadModels(context[ModelManager::class.java])
|
||||||
loadMath(MathPlugin.buildFrom(context))
|
loadMath(FunctionLibrary.buildFrom(context))
|
||||||
|
|
||||||
context.get(ActionManager::class.java).apply {
|
context.get(ActionManager::class.java).apply {
|
||||||
putTask(NumassFitScanTask::class.java)
|
putTask(NumassFitScanTask::class.java)
|
||||||
@ -71,28 +71,28 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadMath(math: MathPlugin) {
|
private fun loadMath(math: FunctionLibrary) {
|
||||||
math.registerBivariate("numass.trap.lowFields") { Ei, Ef -> 3.92e-5 * FastMath.exp(-(Ei - Ef) / 300.0) + 1.97e-4 - 6.818e-9 * Ei }
|
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;
|
//return 1.64e-5 * FastMath.exp(-(Ei - Ef) / 300d) + 1.1e-4 - 4e-9 * Ei;
|
||||||
1.2e-4 - 4.5e-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 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 }
|
||||||
}
|
}
|
||||||
|
|
||||||
math.registerBivariate("numass.resolutionTail.2017") { meta ->
|
math.addBivariateFactory("numass.resolutionTail.2017") { meta ->
|
||||||
BivariateFunction { E: Double, U: Double ->
|
BivariateFunction { E: Double, U: Double ->
|
||||||
val D = E - U
|
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)
|
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 ->
|
BivariateFunction { E: Double, U: Double ->
|
||||||
val D = E - U
|
val D = E - U
|
||||||
val factor = 7.33 - E / 1000.0 / 3.0
|
val factor = 7.33 - E / 1000.0 / 3.0
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
package inr.numass.models.sterile
|
package inr.numass.models.sterile
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.maths.MathPlugin
|
import hep.dataforge.maths.functions.FunctionLibrary
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.stat.parametric.AbstractParametricBiFunction
|
import hep.dataforge.stat.parametric.AbstractParametricBiFunction
|
||||||
import hep.dataforge.values.Values
|
import hep.dataforge.values.Values
|
||||||
@ -27,7 +27,7 @@ class NumassResolution(context: Context, meta: Meta) : AbstractParametricBiFunct
|
|||||||
meta.hasValue("tail") -> {
|
meta.hasValue("tail") -> {
|
||||||
val tailFunctionStr = meta.getString("tail")
|
val tailFunctionStr = meta.getString("tail")
|
||||||
if (tailFunctionStr.startsWith("function::")) {
|
if (tailFunctionStr.startsWith("function::")) {
|
||||||
MathPlugin.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10))
|
FunctionLibrary.buildFrom(context).buildBivariateFunction(tailFunctionStr.substring(10))
|
||||||
} else {
|
} else {
|
||||||
BivariateFunction { E, U ->
|
BivariateFunction { E, U ->
|
||||||
val binding = HashMap<String, Any>()
|
val binding = HashMap<String, Any>()
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
package inr.numass.models.sterile
|
package inr.numass.models.sterile
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.maths.MathPlugin
|
import hep.dataforge.maths.functions.FunctionLibrary
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.stat.parametric.AbstractParametricBiFunction
|
import hep.dataforge.stat.parametric.AbstractParametricBiFunction
|
||||||
import hep.dataforge.values.Values
|
import hep.dataforge.values.Values
|
||||||
@ -30,7 +30,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun
|
|||||||
if (meta.hasValue("trapping")) {
|
if (meta.hasValue("trapping")) {
|
||||||
val trapFuncStr = meta.getString("trapping")
|
val trapFuncStr = meta.getString("trapping")
|
||||||
trapFunc = if (trapFuncStr.startsWith("function::")) {
|
trapFunc = if (trapFuncStr.startsWith("function::")) {
|
||||||
MathPlugin.buildFrom(context).buildBivariateFunction(trapFuncStr.substring(10))
|
FunctionLibrary.buildFrom(context).buildBivariateFunction(trapFuncStr.substring(10))
|
||||||
} else {
|
} else {
|
||||||
BivariateFunction { Ei: Double, Ef: Double ->
|
BivariateFunction { Ei: Double, Ef: Double ->
|
||||||
val binding = HashMap<String, Any>()
|
val binding = HashMap<String, Any>()
|
||||||
@ -41,7 +41,7 @@ class NumassTransmission(context: Context, meta: Meta) : AbstractParametricBiFun
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LoggerFactory.getLogger(javaClass).warn("Trapping function not defined. Using default")
|
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 {
|
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 {
|
override fun derivValue(parName: String, eIn: Double, eOut: Double, set: Values): Double {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
package inr.numass;
|
package inr.numass;
|
||||||
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.maths.MathPlugin;
|
import hep.dataforge.maths.functions.FunctionLibrary;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +24,7 @@ public class NumassTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testBuildContext() {
|
public void testBuildContext() {
|
||||||
Context context = Numass.buildContext();
|
Context context = Numass.buildContext();
|
||||||
MathPlugin.buildFrom(context);
|
FunctionLibrary.Companion.buildFrom(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package inr.numass.models
|
|||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.kodex.step
|
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.Meta
|
||||||
import hep.dataforge.meta.MetaBuilder
|
import hep.dataforge.meta.MetaBuilder
|
||||||
import hep.dataforge.stat.fit.ParamSet
|
import hep.dataforge.stat.fit.ParamSet
|
||||||
@ -79,7 +79,7 @@ private fun oldModel(context: Context, meta: Meta): ParametricFunction {
|
|||||||
//Adding trapping energy dependence
|
//Adding trapping energy dependence
|
||||||
|
|
||||||
if (meta.hasValue("transmission.trapping")) {
|
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)
|
sp.setTrappingFunction(trap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user