diff --git a/numass-main/src/main/groovy/inr/numass/scripts/FindExIonRatio.groovy b/numass-main/src/main/groovy/inr/numass/scripts/FindExIonRatio.groovy index 2eea6052..e1fbc9f5 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/FindExIonRatio.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/FindExIonRatio.groovy @@ -43,7 +43,7 @@ UnivariateIntegrator integrator = NumassContext.defaultIntegrator; double border = 13.6; -UnivariateFunction ratioFunction = {e->integrator.integrate(scatterFunction, 0 , e) / integrator.integrate(scatterFunction, e, 100)} +UnivariateFunction ratioFunction = {e->integrator.integrate(0, e, scatterFunction) / integrator.integrate(e, 100, scatterFunction)} double ratio = ratioFunction.value(border); println "The true excitation to ionization ratio with border energy $border is $ratio"; @@ -83,7 +83,7 @@ UnivariateFunction integral = {double u -> return 0d; } else { UnivariateFunction integrand = {double e -> resolutionValue.value(u-e) * newScatterFunction.value(e)}; - return integrator.integrate(integrand, 0d, u) + return integrator.integrate(0d, u, integrand) } } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/LossNormCalculation.groovy b/numass-main/src/main/groovy/inr/numass/scripts/LossNormCalculation.groovy index 78b1264a..afee80a4 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/LossNormCalculation.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/LossNormCalculation.groovy @@ -6,9 +6,8 @@ package inr.numass.scripts -import hep.dataforge.maths.integration.GaussRuleIntegrator; -import hep.dataforge.maths.integration.UnivariateIntegrator; -import inr.numass.models.LossCalculator; +import hep.dataforge.maths.integration.GaussRuleIntegrator +import hep.dataforge.maths.integration.UnivariateIntegrator import org.apache.commons.math3.analysis.UnivariateFunction UnivariateIntegrator integrator = new GaussRuleIntegrator(400); @@ -42,6 +41,6 @@ UnivariateFunction func = {double eps -> //caclulating lorentz integral analythically double tailNorm = (Math.atan((ionPos - cutoff) * 2d / ionW) + 0.5 * Math.PI) * ionW / 2d; -final double norm = integrator.integrate(func, 0d, cutoff) + tailNorm; +final double norm = integrator.integrate(0d, cutoff, func) + tailNorm; println 1/norm; \ No newline at end of file diff --git a/numass-main/src/main/groovy/inr/numass/scripts/LossTailCalculation.groovy b/numass-main/src/main/groovy/inr/numass/scripts/LossTailCalculation.groovy index 147d00ad..766166ce 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/LossTailCalculation.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/LossTailCalculation.groovy @@ -24,11 +24,11 @@ def cutoff = 20d UnivariateFunction loss = LossCalculator.getSingleScatterFunction(exPos, ionPos, exW, ionW, exIonRatio); -println integrator.integrate(loss,0,600); -println integrator.integrate(loss,0, cutoff); -println integrator.integrate(loss,cutoff,600d); +println integrator.integrate(0, 600, loss); +println integrator.integrate(0, cutoff, loss); +println integrator.integrate(cutoff, 600d, loss); -println (integrator.integrate(loss,0,cutoff) + integrator.integrate(loss,cutoff,3000d)); +println (integrator.integrate(0, cutoff, loss) + integrator.integrate(cutoff, 3000d, loss)); //double tailValue = (Math.atan((ionPos-cutoff)*2d/ionW) + 0.5*Math.PI)*ionW/2; //println tailValue //println integrator.integrate(loss,0,100); diff --git a/numass-main/src/main/groovy/inr/numass/scripts/TestExperimentalVariableLossSpectrum.groovy b/numass-main/src/main/groovy/inr/numass/scripts/TestExperimentalVariableLossSpectrum.groovy index ed3f14c5..3b9790fc 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/TestExperimentalVariableLossSpectrum.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/TestExperimentalVariableLossSpectrum.groovy @@ -15,17 +15,14 @@ */ package inr.numass.scripts +import hep.dataforge.io.PrintFunction import hep.dataforge.maths.integration.UnivariateIntegrator import hep.dataforge.plots.data.PlottableXYFunction import hep.dataforge.plots.jfreechart.JFreeChartFrame +import hep.dataforge.stat.fit.ParamSet import inr.numass.models.ExperimentalVariableLossSpectrum import org.apache.commons.math3.analysis.UnivariateFunction -import inr.numass.Numass -import hep.dataforge.stat.fit.ParamSet -import hep.dataforge.io.PrintFunction - - //double exPos = 12.94 //double exW = 1.31 //double ionPos = 14.13 @@ -50,17 +47,17 @@ UnivariateIntegrator integrator = NumassContext.defaultIntegrator UnivariateFunction exFunc = lsp.excitation(params.getValue("exPos"), params.getValue("exW")); frame.add(PlottableXYFunction.plotFunction("ex", exFunc, 0d, 50d, 500)); -println "excitation norm factor " + integrator.integrate(exFunc, 0, 50) +println "excitation norm factor " + integrator.integrate(0, 50, exFunc) UnivariateFunction ionFunc = lsp.ionization(params.getValue("ionPos"), params.getValue("ionW")); frame.add(PlottableXYFunction.plotFunction("ion", ionFunc, 0d, 50d, 500)); -println "ionization norm factor " + integrator.integrate(ionFunc, 0, 200) +println "ionization norm factor " + integrator.integrate(0, 200, ionFunc) UnivariateFunction sumFunc = lsp.singleScatterFunction(params); frame.add(PlottableXYFunction.plotFunction("sum", sumFunc, 0d, 50d, 500)); -println "sum norm factor " + integrator.integrate(sumFunc, 0, 100) +println "sum norm factor " + integrator.integrate(0, 100, sumFunc) PrintFunction.printFunctionSimple(new PrintWriter(System.out), sumFunc, 0d, 50d, 100) diff --git a/numass-main/src/main/groovy/inr/numass/scripts/temp/FSSEffect.groovy b/numass-main/src/main/groovy/inr/numass/scripts/temp/FSSEffect.groovy new file mode 100644 index 00000000..161d15e0 --- /dev/null +++ b/numass-main/src/main/groovy/inr/numass/scripts/temp/FSSEffect.groovy @@ -0,0 +1,46 @@ +package inr.numass.scripts.temp + +import hep.dataforge.context.Context +import hep.dataforge.context.Global +import hep.dataforge.grind.Grind +import hep.dataforge.grind.GrindShell +import hep.dataforge.grind.helpers.PlotHelper +import hep.dataforge.meta.Meta +import hep.dataforge.plots.fx.FXPlotManager +import hep.dataforge.stat.fit.ParamSet +import hep.dataforge.utils.MetaMorph +import inr.numass.NumassPlugin +import inr.numass.models.sterile.SterileNeutrinoSpectrum + +Context ctx = Global.instance() +ctx.pluginManager().load(FXPlotManager) +ctx.pluginManager().load(NumassPlugin.class) + + +new GrindShell(ctx).eval { + SterileNeutrinoSpectrum sp1 = new SterileNeutrinoSpectrum(context, Meta.empty()); + SterileNeutrinoSpectrum sp2 = new SterileNeutrinoSpectrum(context, Grind.buildMeta(useFSS: false)); + + def params = MetaMorph.morph(ParamSet, + Grind.buildMeta("params") { + N(value: 6e5, err: 1e5, lower: 0) + bkg(value: 2, err: 0.1) + E0(value: 18575, err: 0.1) + mnu2(value: 0, err: 0.01) + msterile2(value: 1000**2, err: 1) + U2(value: 0, err: 1e-3) + X(value: 0, err: 0.01, lower: 0) + trap(value: 0, err: 0.05) + } + ) + + + def xs = (1..400).collect{18000 + it*2} + + def sp1Points = xs.collect { sp1.value(it, params) } + def sp2Points = xs.collect { sp2.value(it, params) } + + + (plots as PlotHelper).plot(xs,sp1Points,"FSS") + (plots as PlotHelper).plot(xs,sp2Points,"noFSS") +} \ No newline at end of file diff --git a/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java b/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java index e2aa23eb..2b148dd2 100644 --- a/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java @@ -22,7 +22,7 @@ public class CustomNBkgSpectrum extends NBkgSpectrum { UnivariateFunction differentialBkgFunction = NumassUtils.tritiumBackgroundFunction(amplitude); UnivariateFunction integralBkgFunction = (x) -> NumassIntegrator.getDefaultIntegrator() - .integrate(differentialBkgFunction, x, 18580d); + .integrate(x, 18580d, differentialBkgFunction); return new CustomNBkgSpectrum(source, integralBkgFunction); } diff --git a/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java b/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java index a4803a50..6ffe618d 100644 --- a/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/EmpiricalLossSpectrum.java @@ -65,7 +65,7 @@ public class EmpiricalLossSpectrum extends AbstractParametricFunction { return LossCalculator.instance().getLossValue(probs, Ei, Ef); }; UnivariateFunction integrand = (double x) -> transmission.value(x) * lossFunction.value(x, U - shift); - return noLossProb * transmission.value(U - shift) + integrator.integrate(integrand, U, eMax); + return noLossProb * transmission.value(U - shift) + integrator.integrate(U, eMax, integrand); } @Override diff --git a/numass-main/src/main/java/inr/numass/models/GunSpectrum.java b/numass-main/src/main/java/inr/numass/models/GunSpectrum.java index 7a2fde67..8e754b86 100644 --- a/numass-main/src/main/java/inr/numass/models/GunSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/GunSpectrum.java @@ -70,7 +70,7 @@ public class GunSpectrum extends AbstractParametricFunction { } else if (pos - cutoff * sigma > U * (1 + resA)) { return 0; } else { - return integrator.integrate(integrand, pos - cutoff * sigma, pos + cutoff * sigma); + return integrator.integrate(pos - cutoff * sigma, pos + cutoff * sigma, integrand); } } @@ -148,7 +148,7 @@ public class GunSpectrum extends AbstractParametricFunction { } else if (pos - cutoff * sigma > U * (1 + resA)) { return 1; } else { - return integrator.integrate(integrand, pos - cutoff * sigma, pos + cutoff * sigma); + return integrator.integrate(pos - cutoff * sigma, pos + cutoff * sigma, integrand); } } diff --git a/numass-main/src/main/java/inr/numass/models/LossCalculator.java b/numass-main/src/main/java/inr/numass/models/LossCalculator.java index 7459de04..3101b989 100644 --- a/numass-main/src/main/java/inr/numass/models/LossCalculator.java +++ b/numass-main/src/main/java/inr/numass/models/LossCalculator.java @@ -123,7 +123,7 @@ public class LossCalculator { double cutoff = 25d; //caclulating lorentz integral analythically double tailNorm = (Math.atan((ionPos - cutoff) * 2d / ionW) + 0.5 * Math.PI) * ionW / 2d; - final double norm = integrator.integrate(func, 0d, cutoff) + tailNorm; + final double norm = integrator.integrate(0d, cutoff, func) + tailNorm; return (e) -> func.value(e) / norm; } @@ -385,7 +385,7 @@ public class LossCalculator { return 0; } }; - return integrator.integrate(integrand, 5d, margin); + return integrator.integrate(5d, margin, integrand); }; return FunctionCaching.cacheUnivariateFunction(0, margin, 200, res); diff --git a/numass-main/src/main/java/inr/numass/models/LossResConvolution.java b/numass-main/src/main/java/inr/numass/models/LossResConvolution.java index e5b88f54..fe59f326 100644 --- a/numass-main/src/main/java/inr/numass/models/LossResConvolution.java +++ b/numass-main/src/main/java/inr/numass/models/LossResConvolution.java @@ -38,7 +38,7 @@ class LossResConvolution implements BivariateFunction { public double value(final double Ein, final double U) { UnivariateFunction integrand = (double Eout) -> loss.value(Ein, Eout) * res.value(Eout, U); //Энергия в принципе не может быть больше начальной и меньше напряжения - return NumassIntegrator.getDefaultIntegrator().integrate(integrand, U, Ein); + return NumassIntegrator.getDefaultIntegrator().integrate(U, Ein, integrand); } } diff --git a/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java b/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java index 0398c1d4..b110f9ec 100644 --- a/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java +++ b/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java @@ -58,7 +58,7 @@ class TransmissionConvolution extends AbstractParametricFunction { } return trans.value(E, U) * spectrum.derivValue(parName, E, set); }; - return NumassIntegrator.getDefaultIntegrator().integrate(integrand, Math.max(U, min), max + 1d); + return NumassIntegrator.getDefaultIntegrator().integrate(Math.max(U, min), max + 1d, integrand); } @Override @@ -80,6 +80,6 @@ class TransmissionConvolution extends AbstractParametricFunction { } return trans.value(E, U) * spectrum.value(E, set); }; - return NumassIntegrator.getDefaultIntegrator().integrate(integrand, Math.max(U, min), max + 1d); + return NumassIntegrator.getDefaultIntegrator().integrate(Math.max(U, min), max + 1d, integrand); } } diff --git a/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java b/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java index ed3c7a45..8f083e66 100644 --- a/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java @@ -106,7 +106,7 @@ public class VariableLossSpectrum extends AbstractParametricFunction { } else { integrator = NumassIntegrator.getDefaultIntegrator(); } - return noLossProb * transmission.value(U - shift, set) + integrator.integrate(integrand, U, eMax); + return noLossProb * transmission.value(U - shift, set) + integrator.integrate(U, eMax, integrand); } public UnivariateFunction singleScatterFunction(ValueProvider set) { diff --git a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java index 92bb2a65..8f71a662 100644 --- a/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/sterile/SterileNeutrinoSpectrum.java @@ -132,7 +132,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { double eMax = set.getDouble("E0") + 5d; - if (u > eMax) { + if (u >= eMax) { return 0; } @@ -163,7 +163,7 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { integrator = NumassIntegrator.getHighDensityIntegrator(); } - return integrator.integrate(eIn -> fsSource.value(eIn) * transResFunction.value(eIn, u, set), u, eMax); + return integrator.integrate(u, eMax, eIn -> fsSource.value(eIn) * transResFunction.value(eIn, u, set)); } private class TransRes extends AbstractParametricBiFunction { @@ -201,13 +201,13 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { UnivariateFunction integrand = (eOut) -> transFunc.value(eIn, eOut, set) * resolution.value(eOut, u, set); double border = u + 30; - double firstPart = NumassIntegrator.getFastInterator().integrate(integrand, u, Math.min(eIn, border)); + double firstPart = NumassIntegrator.getFastInterator().integrate(u, Math.min(eIn, border), integrand); double secondPart; if (eIn > border) { if (fast) { - secondPart = NumassIntegrator.getDefaultIntegrator().integrate(integrand, border, eIn); + secondPart = NumassIntegrator.getDefaultIntegrator().integrate(border, eIn, integrand); } else { - secondPart = NumassIntegrator.getHighDensityIntegrator().integrate(integrand, border, eIn); + secondPart = NumassIntegrator.getHighDensityIntegrator().integrate(border, eIn, integrand); } } else { secondPart = 0; diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java index 3aa7b105..ab7a3123 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanSummaryTask.java @@ -12,6 +12,7 @@ import hep.dataforge.data.DataNode; import hep.dataforge.data.DataSet; import hep.dataforge.description.TypedActionDef; import hep.dataforge.meta.Laminate; +import hep.dataforge.meta.Meta; import hep.dataforge.stat.fit.FitResult; import hep.dataforge.stat.fit.ParamSet; import hep.dataforge.stat.fit.UpperLimitGenerator; @@ -41,12 +42,11 @@ public class NumassFitScanSummaryTask extends AbstractTask