Working on unified output. Minor fixes.

This commit is contained in:
darksnake 2016-10-29 03:10:11 +03:00
parent e6aac38c1e
commit d9e5ff90ec
4 changed files with 31 additions and 14 deletions

View File

@ -14,7 +14,7 @@ import inr.numass.utils.UnderflowCorrection
//File dataDir = new File("D:\\Work\\Numass\\data\\2016_04\\T2_data\\Fill_2_2\\set_7_b2a3433e54010000")
//File dataDir = new File("D:\\Work\\Numass\\data\\2016_04\\T2_data\\Fill_2_2\\set_6_e26d123e54010000")
File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_1\\set_10")
File dataDir = new File("D:\\Work\\Numass\\data\\2016_10\\Fill_2_wide\\\\set_21")
if(!dataDir.exists()){
println "dataDir directory does not exist"
}

View File

@ -101,7 +101,7 @@ public class NumassPlugin extends BasicPlugin {
}
private void loadMath(MathPlugin math) {
math.registerBivariate("numass.trap2016", (Ei, Ef) -> {
math.registerBivariate("numass.trap.lowFields", (Ei, Ef) -> {
return 3.92e-5 * FastMath.exp(-(Ei - Ef) / 300d) + 1.97e-4 - 6.818e-9 * Ei;
});

View File

@ -6,12 +6,17 @@
package inr.numass.models.sterile;
import hep.dataforge.context.Context;
import hep.dataforge.stat.parametric.AbstractParametricBiFunction;
import hep.dataforge.maths.MathPlugin;
import hep.dataforge.meta.Meta;
import hep.dataforge.stat.parametric.AbstractParametricBiFunction;
import hep.dataforge.values.NamedValueSet;
import inr.numass.models.LossCalculator;
import inr.numass.utils.ExpressionUtils;
import org.apache.commons.math3.analysis.BivariateFunction;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
/**
*
@ -28,10 +33,30 @@ public class NumassTransmission extends AbstractParametricBiFunction {
super(list);
this.calculator = LossCalculator.instance();
if (meta.hasValue("trapping")) {
trapFunc = MathPlugin.buildFrom(context).buildBivariateFunction(meta.getString("trapping"));
String trapFuncStr = meta.getString("trapping");
if (trapFuncStr.startsWith("function::")) {
trapFunc = MathPlugin.buildFrom(context).buildBivariateFunction(trapFuncStr.substring(10));
} else {
trapFunc = getTrapFunction(context, meta.getNodeOrEmpty("trapping"));
trapFunc = (Ei, Ef) -> {
Map<String, Object> binding = new HashMap<>();
binding.put("Ei", Ei);
binding.put("Ef", Ef);
return ExpressionUtils.evaluate(trapFuncStr, binding);
};
}
} else {
LoggerFactory.getLogger(getClass()).warn("Trapping function not defined. Using default");
trapFunc = MathPlugin.buildFrom(context).buildBivariateFunction("numass.trap.nominal");
}
}
public static double getX(double eIn, NamedValueSet set) {
//From our article
return set.getDouble("X") * Math.log(eIn / ION_POTENTIAL) * eIn * ION_POTENTIAL / 1.9580741410115568e6;
}
public static double p0(double eIn, NamedValueSet set) {
return LossCalculator.instance().getLossProbability(0, getX(eIn, set));
}
private BivariateFunction getTrapFunction(Context context, Meta meta) {
@ -55,15 +80,6 @@ public class NumassTransmission extends AbstractParametricBiFunction {
return true;
}
public static double getX(double eIn, NamedValueSet set) {
//From our article
return set.getDouble("X") * Math.log(eIn / ION_POTENTIAL) * eIn * ION_POTENTIAL / 1.9580741410115568e6;
}
public static double p0(double eIn, NamedValueSet set) {
return LossCalculator.instance().getLossProbability(0, getX(eIn, set));
}
@Override
public double value(double eIn, double eOut, NamedValueSet set) {
//calculate X taking into account its energy dependence

View File

@ -26,6 +26,7 @@ public class ExpressionUtils {
ImportCustomizer importCustomizer = new ImportCustomizer();
// import static com.mrhaki.blog.Type.*
importCustomizer.addStaticStars("java.lang.Math");
importCustomizer.addStaticStars("org.apache.commons.math3.util.FastMath");
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.addCompilationCustomizers(importCustomizer); // Create shell and execute script.