numass-framework/numass-main/src/main/groovy/inr/numass/scripts/SterileDemo.groovy

82 lines
2.7 KiB
Groovy
Raw Normal View History

2016-07-07 20:40:43 +03:00
/*
* Copyright 2015 Alexander Nozik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2016-08-11 15:45:53 +03:00
package inr.numass.scripts
2016-07-07 20:40:43 +03:00
2016-08-11 15:45:53 +03:00
import hep.dataforge.context.GlobalContext
import hep.dataforge.grind.GrindMetaBuilder
2016-07-07 20:40:43 +03:00
import hep.dataforge.io.FittingIOUtils
2016-07-27 20:18:42 +03:00
import hep.dataforge.meta.Meta
2016-08-11 15:45:53 +03:00
import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.stat.models.XYModel
import hep.dataforge.stat.parametric.ParametricFunction
import inr.numass.data.SpectrumDataAdapter
import inr.numass.models.NBkgSpectrum
import inr.numass.models.sterile.SterileNeutrinoSpectrum
import static java.util.Locale.setDefault
2016-07-07 20:40:43 +03:00
/**
*
* @author Darksnake
*/
setDefault(Locale.US);
2016-07-27 20:18:42 +03:00
//ParametricFunction beta = new BetaSpectrum();
2016-07-25 22:01:37 +03:00
2016-07-27 20:18:42 +03:00
//ModularSpectrum beta = new ModularSpectrum(new BetaSpectrum(), 8.3e-5, 13990d, 18600d);
//beta.setCaching(false)
2016-07-28 15:48:37 +03:00
Meta cfg = new GrindMetaBuilder().meta(){
2016-07-27 20:18:42 +03:00
resolution(width: 8.3e-5)
}.build();
ParametricFunction beta = new SterileNeutrinoSpectrum(cfg);
2016-07-07 20:40:43 +03:00
NBkgSpectrum spectrum = new NBkgSpectrum(beta);
XYModel model = new XYModel(spectrum, new SpectrumDataAdapter());
ParamSet allPars = new ParamSet();
allPars.setPar("N", 6.6579e+05, 1.8e+03, 0d, Double.POSITIVE_INFINITY);
allPars.setPar("bkg", 0.5387, 0.050);
allPars.setPar("E0", 18574.94, 1.4);
allPars.setPar("mnu2", 0d, 1d);
allPars.setPar("msterile2", 1000d * 1000d,0);
allPars.setPar("U2", 0.0, 1e-4, -1d, 1d);
2016-07-27 20:18:42 +03:00
allPars.setPar("X", 0.04, 0.01, 0d, Double.POSITIVE_INFINITY);
2016-07-07 20:40:43 +03:00
allPars.setPar("trap", 1.634, 0.01,0d, Double.POSITIVE_INFINITY);
2016-07-27 20:18:42 +03:00
FittingIOUtils.printSpectrum(GlobalContext.out(), spectrum, allPars, 14000, 18600.0, 400);
2016-07-07 20:40:43 +03:00
//SpectrumGenerator generator = new SpectrumGenerator(model, allPars, 12316);
//
//ListTable data = generator.generateData(DataModelUtils.getUniformSpectrumConfiguration(14000d, 18500, 2000, 90));
//
//data = TritiumUtils.correctForDeadTime(data, new SpectrumDataAdapter(), 1e-8);
//// data = data.filter("X", Value.of(15510.0), Value.of(18610.0));
//// allPars.setParValue("X", 0.4);
//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");
//
//
//
//res.print(out());
//