[no commit message]

This commit is contained in:
darksnake 2016-07-28 15:48:37 +03:00
parent 23e2997b0f
commit af157dc3fa
3 changed files with 44 additions and 12 deletions

View File

@ -57,7 +57,7 @@ setDefault(Locale.US);
//ModularSpectrum beta = new ModularSpectrum(new BetaSpectrum(), 8.3e-5, 13990d, 18600d); //ModularSpectrum beta = new ModularSpectrum(new BetaSpectrum(), 8.3e-5, 13990d, 18600d);
//beta.setCaching(false) //beta.setCaching(false)
Meta cfg = new GrindMetaBuilder().meta{ Meta cfg = new GrindMetaBuilder().meta(){
resolution(width: 8.3e-5) resolution(width: 8.3e-5)
}.build(); }.build();

View File

@ -54,6 +54,7 @@ import inr.numass.models.RangedNamedSetSpectrum;
import inr.numass.models.ResolutionFunction; import inr.numass.models.ResolutionFunction;
import inr.numass.models.TransmissionInterpolator; import inr.numass.models.TransmissionInterpolator;
import inr.numass.models.VariableLossSpectrum; import inr.numass.models.VariableLossSpectrum;
import inr.numass.models.sterile.SterileNeutrinoSpectrum;
import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.BivariateFunction;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.FastMath;
@ -206,6 +207,13 @@ public class NumassPlugin extends BasicPlugin {
}); });
manager.addModel("sterile", (context, meta) -> { manager.addModel("sterile", (context, meta) -> {
SterileNeutrinoSpectrum sp = new SterileNeutrinoSpectrum(meta);
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel(spectrum, getAdapter(meta));
});
manager.addModel("sterile-old", (context, meta) -> {
double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5 double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5
double from = meta.getDouble("from", 13900d); double from = meta.getDouble("from", 13900d);
double to = meta.getDouble("to", 18700d); double to = meta.getDouble("to", 18700d);
@ -227,7 +235,7 @@ public class NumassPlugin extends BasicPlugin {
switch (meta.getString("trappingFunction", "default")) { switch (meta.getString("trappingFunction", "default")) {
case "run2016": case "run2016":
sp.setTrappingFunction((Ei, Ef) -> { sp.setTrappingFunction((Ei, Ef) -> {
return 6.2e-5 * FastMath.exp(-(Ei - Ef) / 350d) + 1.97e-4 - 6.818e-9 * Ei; return 3.92e-5 * FastMath.exp(-(Ei - Ef) / 300d) + 1.97e-4 - 6.818e-9 * Ei;
}); });
break; break;
default: default:

View File

@ -12,10 +12,10 @@ import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.fitting.parametric.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.fitting.parametric.ParametricBiFunction; import hep.dataforge.fitting.parametric.ParametricBiFunction;
import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassIntegrator; import inr.numass.NumassIntegrator;
import inr.numass.NumassContext;
import inr.numass.models.FSS; import inr.numass.models.FSS;
import java.util.stream.DoubleStream; import java.util.stream.DoubleStream;
import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.BivariateFunction;
@ -56,8 +56,9 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
* variables:Eout,U; parameters: "X", "trap" * variables:Eout,U; parameters: "X", "trap"
*/ */
private final ParametricBiFunction resolution; private final ParametricBiFunction resolution;
private boolean useMC; private boolean useMC;
private boolean fast;
public SterileNeutrinoSpectrum(Context context, Meta configuration) { public SterileNeutrinoSpectrum(Context context, Meta configuration) {
super(list); super(list);
@ -69,13 +70,14 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
transmission = new NumassTransmission(configuration.getNodeOrEmpty("transmission")); transmission = new NumassTransmission(configuration.getNodeOrEmpty("transmission"));
resolution = new NumassResolution(configuration.getNode("resolution", Meta.empty())); resolution = new NumassResolution(configuration.getNode("resolution", Meta.empty()));
this.useMC = configuration.getBoolean("useMC",false); this.useMC = configuration.getBoolean("useMC", false);
this.fast = configuration.getBoolean("fast", true);
} }
public SterileNeutrinoSpectrum(Meta configuration) { public SterileNeutrinoSpectrum(Meta configuration) {
this(GlobalContext.instance(),configuration); this(GlobalContext.instance(), configuration);
} }
public SterileNeutrinoSpectrum() { public SterileNeutrinoSpectrum() {
this(GlobalContext.instance(), Meta.empty()); this(GlobalContext.instance(), Meta.empty());
} }
@ -120,9 +122,10 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
/** /**
* Random E generator * Random E generator
*
* @param a * @param a
* @param b * @param b
* @return * @return
*/ */
private double rndE(double a, double b) { private double rndE(double a, double b) {
return rnd.nextDouble() * (b - a) + a; return rnd.nextDouble() * (b - a) + a;
@ -179,12 +182,13 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
/** /**
* Direct Gauss-Legandre integration * Direct Gauss-Legandre integration
*
* @param u * @param u
* @param sourceFunction * @param sourceFunction
* @param transmissionFunction * @param transmissionFunction
* @param resolutionFunction * @param resolutionFunction
* @param set * @param set
* @return * @return
*/ */
private double integrateDirect( private double integrateDirect(
double u, double u,
@ -214,7 +218,20 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
BivariateFunction transRes = (eIn, usp) -> { BivariateFunction transRes = (eIn, usp) -> {
UnivariateFunction integrand = (eOut) -> transmissionFunction.value(eIn, eOut, set) * resolutionFunction.value(eOut, usp, set); UnivariateFunction integrand = (eOut) -> transmissionFunction.value(eIn, eOut, set) * resolutionFunction.value(eOut, usp, set);
return NumassIntegrator.getDefaultIntegrator().integrate(integrand, usp, eIn);
double border = u + 30;
double firstPart = NumassIntegrator.getFastInterator().integrate(integrand, usp, Math.min(eIn, border));
double secondPart;
if (eIn > border) {
if(fast){
secondPart = NumassIntegrator.getFastInterator().integrate(integrand, border, eIn);
} else {
secondPart = NumassIntegrator.getDefaultIntegrator().integrate(integrand, border, eIn);
}
} else {
secondPart = 0;
}
return firstPart + secondPart;
}; };
UnivariateFunction integrand = (eIn) -> { UnivariateFunction integrand = (eIn) -> {
@ -222,7 +239,14 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
return fsSource.value(eIn) * (p0 * resolutionFunction.value(eIn, u, set) + transRes.value(eIn, u)); return fsSource.value(eIn) * (p0 * resolutionFunction.value(eIn, u, set) + transRes.value(eIn, u));
}; };
return NumassIntegrator.getDefaultIntegrator().integrate(integrand, u, eMax); UnivariateIntegrator integrator;
if (fast && eMax - u < 500) {
integrator = NumassIntegrator.getFastInterator();
} else {
integrator = NumassIntegrator.getDefaultIntegrator();
}
return integrator.integrate(integrand, u, eMax);
} }
} }