diff --git a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java b/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java index 25f69541..9d9c3e57 100644 --- a/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java +++ b/numass-main/src/main/java/inr/numass/actions/ShowLossSpectrumAction.java @@ -40,9 +40,9 @@ import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; import hep.dataforge.tables.XYAdapter; import hep.dataforge.values.NamedValueSet; -import inr.numass.NumassIntegrator; import inr.numass.models.ExperimentalVariableLossSpectrum; import inr.numass.models.LossCalculator; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; import org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator; 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 5a09050f..24ea4e92 100644 --- a/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/CustomNBkgSpectrum.java @@ -7,8 +7,7 @@ package inr.numass.models; import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.values.NamedValueSet; -import inr.numass.NumassIntegrator; -import inr.numass.Numass; +import inr.numass.utils.NumassIntegrator; import inr.numass.utils.TritiumUtils; import org.apache.commons.math3.analysis.UnivariateFunction; 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 d0767af3..0c3aed61 100644 --- a/numass-main/src/main/java/inr/numass/models/GunSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/GunSpectrum.java @@ -16,15 +16,13 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; -import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.maths.integration.UnivariateIntegrator; +import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.values.NamedValueSet; -import inr.numass.NumassIntegrator; -import static java.lang.Math.exp; -import static java.lang.Math.sqrt; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.UnivariateFunction; -import static java.lang.Math.abs; -import static java.lang.Math.abs; + +import static java.lang.Math.*; /** * 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 59ce44b0..e5b88f54 100644 --- a/numass-main/src/main/java/inr/numass/models/LossResConvolution.java +++ b/numass-main/src/main/java/inr/numass/models/LossResConvolution.java @@ -15,7 +15,7 @@ */ package inr.numass.models; -import inr.numass.NumassIntegrator; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; 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 00abd9d9..7e9961a0 100644 --- a/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java +++ b/numass-main/src/main/java/inr/numass/models/TransmissionConvolution.java @@ -18,8 +18,7 @@ package inr.numass.models; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; import hep.dataforge.values.NamedValueSet; -import inr.numass.NumassIntegrator; -import inr.numass.Numass; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; 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 888cb7ac..98fed436 100644 --- a/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java +++ b/numass-main/src/main/java/inr/numass/models/VariableLossSpectrum.java @@ -16,17 +16,17 @@ package inr.numass.models; import hep.dataforge.exceptions.NotDefinedException; +import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricFunction; -import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.ValueProvider; -import inr.numass.NumassIntegrator; -import inr.numass.Numass; -import java.util.List; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction; +import java.util.List; + /** * * @author Darksnake 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 811316e4..1861c12a 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 @@ -16,8 +16,8 @@ import hep.dataforge.stat.parametric.AbstractParametricBiFunction; import hep.dataforge.stat.parametric.AbstractParametricFunction; import hep.dataforge.stat.parametric.ParametricBiFunction; import hep.dataforge.values.NamedValueSet; -import inr.numass.NumassIntegrator; import inr.numass.models.FSS; +import inr.numass.utils.NumassIntegrator; import org.apache.commons.math3.analysis.UnivariateFunction; import java.io.FileInputStream; @@ -148,10 +148,17 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { } UnivariateIntegrator integrator; - if (fast && eMax - u < 500) { - integrator = NumassIntegrator.getFastInterator(); - } else { - integrator = NumassIntegrator.getDefaultIntegrator(); + if(fast){ + if (eMax - u < 300) { + integrator = NumassIntegrator.getFastInterator(); + } else if(eMax - u > 2000){ + integrator = NumassIntegrator.getHighDensityIntegrator(); + } else { + integrator = NumassIntegrator.getDefaultIntegrator(); + } + + } else { + integrator = NumassIntegrator.getHighDensityIntegrator(); } return integrator.integrate(eIn -> fsSource.value(eIn) * transResFunction.value(eIn, u, set), u, eMax); @@ -196,9 +203,9 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction { double secondPart; if (eIn > border) { if (fast) { - secondPart = NumassIntegrator.getFastInterator().integrate(integrand, border, eIn); - } else { secondPart = NumassIntegrator.getDefaultIntegrator().integrate(integrand, border, eIn); + } else { + secondPart = NumassIntegrator.getHighDensityIntegrator().integrate(integrand, border, eIn); } } else { secondPart = 0; diff --git a/numass-main/src/main/java/inr/numass/NumassIntegrator.java b/numass-main/src/main/java/inr/numass/utils/NumassIntegrator.java similarity index 75% rename from numass-main/src/main/java/inr/numass/NumassIntegrator.java rename to numass-main/src/main/java/inr/numass/utils/NumassIntegrator.java index f14f1da0..b4029714 100644 --- a/numass-main/src/main/java/inr/numass/NumassIntegrator.java +++ b/numass-main/src/main/java/inr/numass/utils/NumassIntegrator.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package inr.numass; +package inr.numass.utils; import hep.dataforge.maths.integration.GaussRuleIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator; @@ -14,27 +14,29 @@ import hep.dataforge.maths.integration.UnivariateIntegrator; */ public class NumassIntegrator { + private static double mult = 1.0; + private static UnivariateIntegrator fastInterator; private static UnivariateIntegrator defaultIntegrator; private static UnivariateIntegrator highDensityIntegrator; public static UnivariateIntegrator getFastInterator() { if (fastInterator == null) { - fastInterator = new GaussRuleIntegrator(100); + fastInterator = new GaussRuleIntegrator((int) (mult*100)); } return fastInterator; } public static UnivariateIntegrator getDefaultIntegrator() { if (defaultIntegrator == null) { - defaultIntegrator = new GaussRuleIntegrator(300); + defaultIntegrator = new GaussRuleIntegrator((int) (mult*300)); } return defaultIntegrator; } public static UnivariateIntegrator getHighDensityIntegrator() { if (highDensityIntegrator == null) { - highDensityIntegrator = new GaussRuleIntegrator(500); + highDensityIntegrator = new GaussRuleIntegrator((int) (mult*500)); } return highDensityIntegrator; }