[no commit message]

This commit is contained in:
Alexander Nozik 2016-07-24 21:44:57 +03:00
parent 8c42e44c98
commit 06e7bb762d
28 changed files with 315 additions and 176 deletions

View File

@ -17,8 +17,8 @@ package hep.dataforge.plotfit;
import hep.dataforge.actions.OneToOneAction; import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.datafitter.FitState; import hep.dataforge.fitting.FitState;
import hep.dataforge.datafitter.models.XYModel; import hep.dataforge.fitting.models.XYModel;
import hep.dataforge.description.NodeDef; import hep.dataforge.description.NodeDef;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef; import hep.dataforge.description.ValueDef;

View File

@ -19,7 +19,7 @@ import hep.dataforge.actions.ActionUtils;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import static hep.dataforge.context.GlobalContext.out; import static hep.dataforge.context.GlobalContext.out;
import hep.dataforge.data.FileDataFactory; import hep.dataforge.data.FileDataFactory;
import hep.dataforge.datafitter.MINUITPlugin; import hep.dataforge.fitting.MINUITPlugin;
import hep.dataforge.io.IOManager; import hep.dataforge.io.IOManager;
import hep.dataforge.io.MetaFileReader; import hep.dataforge.io.MetaFileReader;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;

View File

@ -19,11 +19,11 @@ import hep.dataforge.actions.ActionManager;
import hep.dataforge.context.BasicPlugin; import hep.dataforge.context.BasicPlugin;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.context.PluginDef; import hep.dataforge.context.PluginDef;
import hep.dataforge.datafitter.FitManager; import hep.dataforge.fitting.FitManager;
import hep.dataforge.datafitter.FitPlugin; import hep.dataforge.fitting.FitPlugin;
import hep.dataforge.datafitter.models.ModelManager; import hep.dataforge.fitting.models.ModelManager;
import hep.dataforge.datafitter.models.WeightedXYModel; import hep.dataforge.fitting.models.WeightedXYModel;
import hep.dataforge.datafitter.models.XYModel; import hep.dataforge.fitting.models.XYModel;
import hep.dataforge.meta.Meta; import hep.dataforge.meta.Meta;
import hep.dataforge.plotfit.PlotFitResultAction; import hep.dataforge.plotfit.PlotFitResultAction;
import hep.dataforge.plots.PlotDataAction; import hep.dataforge.plots.PlotDataAction;

View File

@ -16,11 +16,11 @@
package inr.numass.actions; package inr.numass.actions;
import hep.dataforge.actions.OneToOneAction; import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.datafitter.FitState; import hep.dataforge.fitting.FitState;
import hep.dataforge.datafitter.FitTaskResult; import hep.dataforge.fitting.FitTaskResult;
import hep.dataforge.datafitter.Param; import hep.dataforge.fitting.Param;
import hep.dataforge.datafitter.ParamSet; import hep.dataforge.fitting.ParamSet;
import hep.dataforge.datafitter.models.Histogram; import hep.dataforge.fitting.models.Histogram;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.PrintFunction; import hep.dataforge.io.PrintFunction;
@ -34,7 +34,7 @@ import hep.dataforge.plots.PlotsPlugin;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.XYPlotFrame;
import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableData;
import hep.dataforge.plots.data.PlottableXYFunction; import hep.dataforge.plots.data.PlottableXYFunction;
import hep.dataforge.simulation.GaussianParameterGenerator; import hep.dataforge.generators.GaussianParameterGenerator;
import hep.dataforge.tables.ListTable; import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.MapPoint;
import hep.dataforge.tables.Table; import hep.dataforge.tables.Table;

View File

@ -19,7 +19,7 @@ import hep.dataforge.actions.GroupBuilder;
import hep.dataforge.actions.ManyToOneAction; import hep.dataforge.actions.ManyToOneAction;
import hep.dataforge.context.Context; import hep.dataforge.context.Context;
import hep.dataforge.data.DataNode; import hep.dataforge.data.DataNode;
import hep.dataforge.datafitter.FitState; import hep.dataforge.fitting.FitState;
import hep.dataforge.description.TypedActionDef; import hep.dataforge.description.TypedActionDef;
import hep.dataforge.io.ColumnedDataWriter; import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.io.reports.Reportable; import hep.dataforge.io.reports.Reportable;

View File

@ -15,9 +15,9 @@
*/ */
package inr.numass.data; package inr.numass.data;
import hep.dataforge.datafitter.ParamSet; import hep.dataforge.fitting.ParamSet;
import hep.dataforge.datafitter.models.Generator; import hep.dataforge.fitting.models.Generator;
import hep.dataforge.datafitter.models.XYModel; import hep.dataforge.fitting.models.XYModel;
import static hep.dataforge.maths.RandomUtils.getDefaultRandomGenerator; import static hep.dataforge.maths.RandomUtils.getDefaultRandomGenerator;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.ListTable; import hep.dataforge.tables.ListTable;

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.data; package inr.numass.data;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import static hep.dataforge.maths.MatrixOperations.inverse; import static hep.dataforge.maths.MatrixOperations.inverse;
import hep.dataforge.maths.NamedMatrix; import hep.dataforge.maths.NamedMatrix;
import hep.dataforge.tables.DataPoint; import hep.dataforge.tables.DataPoint;

View File

@ -16,13 +16,13 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
import java.io.File; import java.io.File;
import static java.lang.Math.abs;
import static java.lang.Math.exp; import static java.lang.Math.exp;
import static java.lang.Math.sqrt; import static java.lang.Math.sqrt;
import static java.lang.Math.abs;
/** /**
* *
@ -225,7 +225,7 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa
} }
@Override @Override
protected double getDefaultValue(String name) { protected double getDefaultParameter(String name) {
switch (name) { switch (name) {
case "mnu2": case "mnu2":
return 0; return 0;
@ -234,7 +234,7 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa
case "msterile2": case "msterile2":
return 0; return 0;
default: default:
return super.getDefaultValue(name); return super.getDefaultParameter(name);
} }
} }
} }

View File

@ -5,7 +5,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassContext; import inr.numass.NumassContext;
import inr.numass.utils.TritiumUtils; import inr.numass.utils.TritiumUtils;

View File

@ -17,7 +17,7 @@ package inr.numass.models;
import hep.dataforge.exceptions.NamingException; import hep.dataforge.exceptions.NamingException;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.maths.integration.GaussRuleIntegrator; import hep.dataforge.maths.integration.GaussRuleIntegrator;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;

View File

@ -16,8 +16,8 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.BivariateFunction;

View File

@ -21,29 +21,28 @@ import hep.dataforge.tables.PointSource;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import org.apache.commons.math3.util.Pair;
/** /**
* *
* @author Darksnake * @author Darksnake
*/ */
public class FSS{ public class FSS{
private final ArrayList<Pair<Double,Double>> points; private final ArrayList<Double> ps = new ArrayList<>();
private final ArrayList<Double> es = new ArrayList<>();
private double norm; private double norm;
public FSS(File FSSFile) { public FSS(File FSSFile) {
try { try {
PointSource data = IOUtils.readColumnedData(FSSFile,"E","P"); PointSource data = IOUtils.readColumnedData(FSSFile,"E","P");
this.points = new ArrayList<>();
norm = 0; norm = 0;
for (DataPoint dp : data) { for (DataPoint dp : data) {
Double E = dp.getValue("E").doubleValue(); es.add(dp.getDouble("E"));
Double P = dp.getValue("P").doubleValue(); double p = dp.getDouble("P");
this.points.add(new Pair<>(E,P)); ps.add(p);
norm += P; norm += p;
} }
if(points.isEmpty()) { if(ps.isEmpty()) {
throw new Error("Error reading FSS FILE. No points."); throw new Error("Error reading FSS FILE. No points.");
} }
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
@ -51,23 +50,27 @@ public class FSS{
} }
} }
public double getE(int n){
return this.es.get(n);
double getE(int n){
return this.points.get(n).getFirst();
} }
double getP(int n){ public double getP(int n){
return this.points.get(n).getSecond() / norm; return this.ps.get(n) / norm;
} }
boolean isEmpty(){ public boolean isEmpty(){
return points.isEmpty(); return ps.isEmpty();
} }
int size(){ public int size(){
return points.size(); return ps.size();
}
public double[] getPs(){
return ps.stream().mapToDouble(p->p).toArray();
}
public double[] getEs(){
return es.stream().mapToDouble(p->p).toArray();
} }
} }

View File

@ -17,8 +17,8 @@ package inr.numass.models;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.exceptions.NameNotFoundException; import hep.dataforge.exceptions.NameNotFoundException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import static hep.dataforge.names.NamedUtils.combineNamesWithEquals; import static hep.dataforge.names.NamedUtils.combineNamesWithEquals;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
@ -43,6 +43,54 @@ import static java.lang.Double.isNaN;
import static java.lang.Math.abs; import static java.lang.Math.abs;
import static java.lang.Double.isNaN; import static java.lang.Double.isNaN;
import static java.lang.Math.abs; import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
import static java.lang.Double.isNaN;
import static java.lang.Math.abs;
/** /**
* *

View File

@ -16,7 +16,7 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
import static java.lang.Math.exp; import static java.lang.Math.exp;

View File

@ -16,7 +16,7 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassContext; import inr.numass.NumassContext;
@ -24,6 +24,9 @@ import static java.lang.Math.abs;
import static java.lang.Math.exp; import static java.lang.Math.exp;
import static java.lang.Math.sqrt; import static java.lang.Math.sqrt;
import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.UnivariateFunction;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
import static java.lang.Math.abs;
/** /**
* *

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.FunctionCaching; import hep.dataforge.fitting.parametric.FunctionCaching;
import hep.dataforge.maths.integration.GaussRuleIntegrator; import hep.dataforge.maths.integration.GaussRuleIntegrator;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.plots.XYPlotFrame; import hep.dataforge.plots.XYPlotFrame;

View File

@ -15,8 +15,8 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.names.NamedUtils; import hep.dataforge.names.NamedUtils;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;

View File

@ -15,8 +15,8 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import static hep.dataforge.names.NamedUtils.combineNamesWithEquals; import static hep.dataforge.names.NamedUtils.combineNamesWithEquals;
import hep.dataforge.utils.MultiCounter; import hep.dataforge.utils.MultiCounter;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
@ -78,14 +78,14 @@ public class NBkgSpectrum extends AbstractParametricFunction {
} }
@Override @Override
protected double getDefaultValue(String name) { protected double getDefaultParameter(String name) {
switch (name) { switch (name) {
case "bkg": case "bkg":
return 0; return 0;
case "N": case "N":
return 1; return 1;
default: default:
return super.getDefaultValue(name); return super.getDefaultParameter(name);
} }
} }

View File

@ -15,10 +15,10 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import static hep.dataforge.functions.FunctionUtils.getSpectrumDerivativeFunction; import static hep.dataforge.fitting.parametric.FunctionUtils.getSpectrumDerivativeFunction;
import static hep.dataforge.functions.FunctionUtils.getSpectrumFunction; import static hep.dataforge.fitting.parametric.FunctionUtils.getSpectrumFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.maths.MathUtils; import hep.dataforge.maths.MathUtils;
import hep.dataforge.maths.NamedVector; import hep.dataforge.maths.NamedVector;
import hep.dataforge.names.AbstractNamedSet; import hep.dataforge.names.AbstractNamedSet;

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
/** /**
* *

View File

@ -1,92 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inr.numass.models;
import hep.dataforge.functions.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction;
import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassContext;
import org.apache.commons.math3.analysis.BivariateFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
/**
* Compact all-in-one model for sterile neutrino spectrum
* @author Alexander Nozik
*/
public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
private static final String[] list = {"X", "trap", "E0", "mnu2", "msterile2", "U2"};
BetaSpectrum source;
public SterileNeutrinoSpectrum() {
super(list);
}
// /**
// * Transmission function including detector backscattering
// *
// * @param u
// * @param set
// * @return
// */
// private BivariateFunction transmission(double u, NamedValueSet set) {
//
// }
//
// /**
// * Loss function excluding trapping
// *
// * @param u
// * @param set
// * @return
// */
// private BivariateFunction loss(double u, NamedValueSet set) {
//
// }
//
// /**
// * Trapping spectrum
// *
// * @param u
// * @param set
// * @return
// */
// private BivariateFunction trapping(double u, NamedValueSet set) {
//
// }
/**
* Source spectrum including final states
*
* @return
*/
private ParametricFunction source() {
return source;
}
private BivariateFunction convolute(BivariateFunction loss, BivariateFunction resolution) {
return (eIn, u) -> {
UnivariateFunction integrand = (double eOut) -> loss.value(eIn, eOut) * resolution.value(eOut, u);
return NumassContext.defaultIntegrator.integrate(integrand, u, eIn);
};
}
@Override
public double derivValue(String parName, double u, NamedValueSet set) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public double value(double u, NamedValueSet set) {
return 0;
}
@Override
public boolean providesDeriv(String name) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}

View File

@ -16,7 +16,7 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.names.NameSetContainer; import hep.dataforge.names.NameSetContainer;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;

View File

@ -15,8 +15,8 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassContext; import inr.numass.NumassContext;
import org.apache.commons.math3.analysis.BivariateFunction; import org.apache.commons.math3.analysis.BivariateFunction;

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.maths.NamedVector; import hep.dataforge.maths.NamedVector;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import static java.lang.Math.abs; import static java.lang.Math.abs;

View File

@ -16,8 +16,8 @@
package inr.numass.models; package inr.numass.models;
import hep.dataforge.exceptions.NotDefinedException; import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.functions.AbstractParametricFunction; import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.functions.ParametricFunction; import hep.dataforge.fitting.parametric.ParametricFunction;
import hep.dataforge.maths.integration.UnivariateIntegrator; import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.values.NamedValueSet; import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider; import hep.dataforge.values.ValueProvider;
@ -134,14 +134,14 @@ public class VariableLossSpectrum extends AbstractParametricFunction {
} }
@Override @Override
protected double getDefaultValue(String name) { protected double getDefaultParameter(String name) {
switch (name) { switch (name) {
case "shift": case "shift":
return 0; return 0;
case "X": case "X":
return 0; return 0;
default: default:
return super.getDefaultValue(name); return super.getDefaultParameter(name);
} }
} }

View File

@ -0,0 +1,113 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inr.numass.models.sterile;
import hep.dataforge.context.Context;
import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.fitting.parametric.AbstractParametricFunction;
import hep.dataforge.fitting.parametric.ParametricBiFunction;
import hep.dataforge.meta.Meta;
import hep.dataforge.values.NamedValueSet;
import inr.numass.models.FSS;
import java.util.stream.DoubleStream;
import org.apache.commons.math3.distribution.EnumeratedRealDistribution;
import org.apache.commons.math3.distribution.RealDistribution;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomGenerator;
import org.apache.commons.math3.random.SynchronizedRandomGenerator;
/**
* Compact all-in-one model for sterile neutrino spectrum
*
* @author Alexander Nozik
*/
public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
private static final String[] list = {"X", "trap", "E0", "mnu2", "msterile2", "U2"};
private double eMax;
private final RandomGenerator rnd;
private final RealDistribution fssDistribution;
/**
* variables:Eo offset,Ein; parameters: "mnu2", "msterile2", "U2"
*/
private ParametricBiFunction source;
/**
* variables:Ein,Eout; parameters: "A"
*/
private ParametricBiFunction transmission;
/**
* variables:Eout,U; parameters: "X", "trap"
*/
private ParametricBiFunction resolution;
public SterileNeutrinoSpectrum(Context context, Meta configuration) {
super(list);
this.eMax = 18600;
FSS fss = new FSS(context.io().getFile(configuration.getString("fssFile", "FS.txt")));
rnd = new SynchronizedRandomGenerator(new JDKRandomGenerator());
fssDistribution = new EnumeratedRealDistribution(rnd, fss.getEs(), fss.getPs());
}
@Override
public double derivValue(String parName, double u, NamedValueSet set) {
switch (parName) {
case "U2":
case "msterile2":
case "mnu2":
case "E0":
return integrate(u, source.derivative(parName), transmission, resolution, set);
case "X":
case "trap":
return integrate(u, source, transmission, resolution.derivative(parName), set);
default:
throw new NotDefinedException();
}
}
@Override
public double value(double u, NamedValueSet set) {
return integrate(u, source, transmission, resolution, set);
}
private int numCalls(double u) {
return 100000;
}
@Override
public boolean providesDeriv(String name) {
return source.providesDeriv(name) && transmission.providesDeriv(name) && resolution.providesDeriv(name);
}
private double rndE(double a, double b) {
return rnd.nextDouble() * (b - a) + a;
}
private double integrate(
double u,
ParametricBiFunction sourceFunction,
ParametricBiFunction transmissionFunction,
ParametricBiFunction resolutionFunction,
NamedValueSet set) {
int num = numCalls(u);
double sum = DoubleStream.generate(() -> {
// generate final state
double fs = fssDistribution.sample();
double eIn = rndE(u, eMax);
double eOut = rndE(u, eIn);
return sourceFunction.value(fs, eIn, set)
* transmissionFunction.value(eIn, eOut, set)
* resolutionFunction.value(eOut, u, set);
}).limit(num).parallel().sum();
return Math.pow(eMax - u, 2d) / 2d * sum / num;
}
}

View File

@ -15,7 +15,7 @@
*/ */
package inr.numass.models; package inr.numass.models;
import hep.dataforge.datafitter.ParamSet; import hep.dataforge.fitting.ParamSet;
import hep.dataforge.plots.fx.FXPlotUtils; import hep.dataforge.plots.fx.FXPlotUtils;
/** /**

View File

@ -16,8 +16,8 @@
package inr.numass.run; package inr.numass.run;
import hep.dataforge.context.GlobalContext; import hep.dataforge.context.GlobalContext;
import hep.dataforge.datafitter.MINUITPlugin; import hep.dataforge.fitting.MINUITPlugin;
import hep.dataforge.datafitter.ParamSet; import hep.dataforge.fitting.ParamSet;
import hep.dataforge.exceptions.NamingException; import hep.dataforge.exceptions.NamingException;
import inr.numass.models.BetaSpectrum; import inr.numass.models.BetaSpectrum;
import inr.numass.models.ModularSpectrum; import inr.numass.models.ModularSpectrum;
@ -88,6 +88,70 @@ import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault; import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
import static java.util.Locale.setDefault;
/** /**
* *