Identity to MetaMorph

This commit is contained in:
Alexander Nozik 2017-02-25 11:06:05 +03:00
parent 5cf68cc21f
commit 55bc38a0bf
3 changed files with 28 additions and 26 deletions

View File

@ -15,17 +15,17 @@
*/
package inr.numass.scripts
import hep.dataforge.stat.fit.FitManager
import hep.dataforge.stat.fit.FitState
import hep.dataforge.stat.fit.MINUITPlugin
import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.context.Global
import hep.dataforge.io.ColumnedDataWriter
import hep.dataforge.meta.Meta
import hep.dataforge.stat.fit.*
import hep.dataforge.stat.models.XYModel
import hep.dataforge.tables.ListTable
import inr.numass.NumassPlugin
import inr.numass.data.SpectrumDataAdapter
import inr.numass.data.SpectrumGenerator
import inr.numass.models.BetaSpectrum
import inr.numass.models.ModularSpectrum
import inr.numass.models.NBkgSpectrum
import inr.numass.models.sterile.SterileNeutrinoSpectrum
import inr.numass.utils.DataModelUtils
import inr.numass.utils.TritiumUtils
@ -39,19 +39,19 @@ import static java.util.Locale.setDefault
setDefault(Locale.US);
new MINUITPlugin().startGlobal();
// global.loadModule(new MINUITModule());
new NumassPlugin().startGlobal()
FitManager fm = new FitManager();
ModularSpectrum beta = new ModularSpectrum(new BetaSpectrum(), 8.3e-5, 13990d, 18600d);
SterileNeutrinoSpectrum sp = new SterileNeutrinoSpectrum(Global.instance(), Meta.empty());
//beta.setCaching(false);
NBkgSpectrum spectrum = new NBkgSpectrum(beta);
XYModel model = new XYModel("tritium", spectrum, new SpectrumDataAdapter());
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
XYModel model = new XYModel(spectrum, new SpectrumDataAdapter());
ParamSet allPars = new ParamSet();
allPars.setParValue("N", 9e5);
allPars.setParValue("N", 2e6/100);
//значение 6е-6 соответствует полной интенстивности 6е7 распадов в секунду
//Проблема была в переполнении счетчика событий в генераторе. Заменил на long. Возможно стоит поставить туда число с плавающей точкой
allPars.setParError("N", 6);
@ -62,14 +62,14 @@ allPars.setParValue("E0", 18575.0);
allPars.setParError("E0", 2);
allPars.setParValue("mnu2", 0d);
allPars.setParError("mnu2", 1d);
allPars.setParValue("msterile2", 1000 * 1000);
allPars.setParValue("msterile2", 8000 * 8000);
allPars.setParValue("U2", 0);
allPars.setParError("U2", 1e-4);
allPars.setParDomain("U2", -1d, 1d);
allPars.setParValue("X", 0);
allPars.setParError("X", 0.01);
allPars.setParDomain("X", 0d, Double.POSITIVE_INFINITY);
allPars.setParValue("trap", 1d);
allPars.setParValue("trap", 0d);
allPars.setParError("trap", 0.01d);
allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
@ -79,16 +79,19 @@ allPars.setParDomain("trap", 0d, Double.POSITIVE_INFINITY);
// ListTable config = OldDataReader.readConfig(configName);
SpectrumGenerator generator = new SpectrumGenerator(model, allPars, 12316);
ListTable data = generator.generateData(DataModelUtils.getUniformSpectrumConfiguration(14000d, 18500, 2000, 90));
ListTable data = generator.generateData(DataModelUtils.getUniformSpectrumConfiguration(5000d, 18500, 604800/100*100, 100));
data = TritiumUtils.correctForDeadTime(data, new SpectrumDataAdapter(), 1e-8);
data = TritiumUtils.correctForDeadTime(data, new SpectrumDataAdapter(), 10e-9);
// data = data.filter("X", Value.of(15510.0), Value.of(18610.0));
// allPars.setParValue("X", 0.4);
ColumnedDataWriter.writeDataSet(System.out,data,"--- DATA ---");
FitState state = new FitState(data, model, allPars);
//new PlotFitResultAction().eval(state);
FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "E0", "U2", "trap");
FitState res = fm.runTask(state, "QOW", FitStage.TASK_RUN, "N", "bkg", "E0", "U2");

View File

@ -6,26 +6,23 @@
package inr.numass.scripts
import hep.dataforge.io.ColumnedDataWriter
import hep.dataforge.storage.commons.StorageUtils
import hep.dataforge.tables.Table
import inr.numass.storage.NMPoint
import inr.numass.storage.NumassDataUtils
import inr.numass.storage.NumassStorage
import inr.numass.utils.UnderflowCorrection
File rootDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1")
File rootDir = new File("D:\\temp\\2016-sample\\")
NumassStorage storage = NumassStorage.buildLocalNumassRoot(rootDir, true);
Collection<NMPoint> data = NumassDataUtils.joinSpectra(
StorageUtils.loaderStream(storage).filter { it.key.matches("set_.{2,3}") }.map {
StorageUtils.loaderStream(storage).filter { it.key.matches("set_.*") }.map {
println "loading ${it.key}"
it.value
}
)
data = NumassDataUtils.substractReferencePoint(data, 18600d);
data = NumassDataUtils.substractReferencePoint(data, 16050d);
//println "Empty files:"
//Collection<NMPoint> emptySpectra = NumassDataUtils.joinSpectra(
@ -77,10 +74,10 @@ def printPoint(Iterable<NMPoint> data, List us, int binning = 20, normalize = fa
println "\n# spectra\n"
printPoint(data, [16200d, 16400d, 16800d, 17000d, 17200d])
printPoint(data, [16550d, 17050d, 17550d])
println()
Table t = new UnderflowCorrection().fitAllPoints(data, 400, 700, 3100, 20);
ColumnedDataWriter.writeDataSet(System.out, t, "underflow parameters")
//Table t = new UnderflowCorrection().fitAllPoints(data, 400, 700, 3100, 20);
//ColumnedDataWriter.writeDataSet(System.out, t, "underflow parameters")

View File

@ -19,6 +19,8 @@ import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.MapPoint;
import hep.dataforge.tables.Table;
import inr.numass.data.SpectrumDataAdapter;
import java.util.Scanner;
/**
@ -29,7 +31,7 @@ public class DataModelUtils {
public static Table getUniformSpectrumConfiguration(double from, double to, double time, int numpoints) {
assert to != from;
final String[] list = {"x", "time"};
final String[] list = {SpectrumDataAdapter.X_VALUE_KEY, "time"};
ListTable.Builder res = new ListTable.Builder(list);
for (int i = 0; i < numpoints; i++) {