Threshold calculation for 2017_11
This commit is contained in:
parent
ac9ff50ff2
commit
4723ea5af7
@ -29,7 +29,6 @@ import inr.numass.models.NBkgSpectrum
|
|||||||
import inr.numass.models.ResolutionFunction
|
import inr.numass.models.ResolutionFunction
|
||||||
import inr.numass.utils.DataModelUtils
|
import inr.numass.utils.DataModelUtils
|
||||||
|
|
||||||
import static hep.dataforge.context.Global.out
|
|
||||||
import static java.util.Locale.setDefault
|
import static java.util.Locale.setDefault
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package inr.numass.models;
|
|
||||||
|
|
||||||
import hep.dataforge.stat.parametric.AbstractParametricFunction;
|
|
||||||
import hep.dataforge.stat.parametric.ParametricFunction;
|
|
||||||
import hep.dataforge.utils.MultiCounter;
|
|
||||||
import hep.dataforge.values.ValueProvider;
|
|
||||||
import hep.dataforge.values.Values;
|
|
||||||
|
|
||||||
import static hep.dataforge.names.NamesUtils.combineNamesWithEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Darksnake
|
|
||||||
*/
|
|
||||||
public class NBkgSpectrum extends AbstractParametricFunction {
|
|
||||||
|
|
||||||
private static final String[] list = {"N", "bkg"};
|
|
||||||
|
|
||||||
public MultiCounter counter = new MultiCounter(this.getClass().getName());
|
|
||||||
private final ParametricFunction source;
|
|
||||||
|
|
||||||
public NBkgSpectrum(ParametricFunction source) {
|
|
||||||
super(combineNamesWithEquals(source.namesAsArray(), list));
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double derivValue(String parName, double x, Values set) {
|
|
||||||
this.counter.increase(parName);
|
|
||||||
switch (parName) {
|
|
||||||
case "N":
|
|
||||||
return source.value(x, set);
|
|
||||||
case "bkg":
|
|
||||||
return 1;
|
|
||||||
default:
|
|
||||||
return getN(set) * source.derivValue(parName, x, set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getBkg(ValueProvider set) {
|
|
||||||
return set.getDouble("bkg");
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getN(ValueProvider set) {
|
|
||||||
return set.getDouble("N");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean providesDeriv(String name) {
|
|
||||||
switch (name) {
|
|
||||||
case "N":
|
|
||||||
return true;
|
|
||||||
case "bkg":
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return this.source.providesDeriv(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double value(double x, Values set) {
|
|
||||||
this.counter.increase("value");
|
|
||||||
return getN(set) * source.value(x, set) + getBkg(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected double getDefaultParameter(String name) {
|
|
||||||
switch (name) {
|
|
||||||
case "bkg":
|
|
||||||
return 0;
|
|
||||||
case "N":
|
|
||||||
return 1;
|
|
||||||
default:
|
|
||||||
return super.getDefaultParameter(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -21,6 +21,7 @@ import hep.dataforge.context.Context
|
|||||||
import hep.dataforge.data.DataNode
|
import hep.dataforge.data.DataNode
|
||||||
import hep.dataforge.description.NodeDef
|
import hep.dataforge.description.NodeDef
|
||||||
import hep.dataforge.description.TypedActionDef
|
import hep.dataforge.description.TypedActionDef
|
||||||
|
import hep.dataforge.io.render
|
||||||
import hep.dataforge.meta.Laminate
|
import hep.dataforge.meta.Laminate
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.tables.ListTable
|
import hep.dataforge.tables.ListTable
|
||||||
@ -44,11 +45,10 @@ object MergeDataAction : ManyToOneAction<Table, Table>("numass.merge", Table::cl
|
|||||||
|
|
||||||
override fun buildGroups(context: Context, input: DataNode<Table>, actionMeta: Meta): List<DataNode<Table>> {
|
override fun buildGroups(context: Context, input: DataNode<Table>, actionMeta: Meta): List<DataNode<Table>> {
|
||||||
val meta = inputMeta(context, input.meta, actionMeta)
|
val meta = inputMeta(context, input.meta, actionMeta)
|
||||||
val groups: List<DataNode<Table>>
|
val groups: List<DataNode<Table>> = if (meta.hasValue("grouping.byValue")) {
|
||||||
if (meta.hasValue("grouping.byValue")) {
|
super.buildGroups(context, input, actionMeta)
|
||||||
groups = super.buildGroups(context, input, actionMeta)
|
|
||||||
} else {
|
} else {
|
||||||
groups = GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, input.name)).group(input)
|
GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, input.name)).group(input)
|
||||||
}
|
}
|
||||||
return groups
|
return groups
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ object MergeDataAction : ManyToOneAction<Table, Table>("numass.merge", Table::cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
override fun afterGroup(context: Context, groupName: String, outputMeta: Meta, output: Table) {
|
||||||
context.output[name, groupName].render(output,outputMeta)
|
context.output.render(output, name = groupName, stage = name, meta = outputMeta)
|
||||||
super.afterGroup(context, groupName, outputMeta, output)
|
super.afterGroup(context, groupName, outputMeta, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package inr.numass.models
|
||||||
|
|
||||||
|
import hep.dataforge.names.NamesUtils.combineNamesWithEquals
|
||||||
|
import hep.dataforge.stat.parametric.AbstractParametricFunction
|
||||||
|
import hep.dataforge.stat.parametric.ParametricFunction
|
||||||
|
import hep.dataforge.utils.MultiCounter
|
||||||
|
import hep.dataforge.values.ValueProvider
|
||||||
|
import hep.dataforge.values.Values
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darksnake
|
||||||
|
*/
|
||||||
|
open class NBkgSpectrum(private val source: ParametricFunction) : AbstractParametricFunction(*combineNamesWithEquals(source.namesAsArray(), *list)) {
|
||||||
|
|
||||||
|
var counter = MultiCounter(this.javaClass.name)
|
||||||
|
|
||||||
|
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||||
|
this.counter.increase(parName)
|
||||||
|
return when (parName) {
|
||||||
|
"N" -> source.value(x, set)
|
||||||
|
"bkg" -> 1.0
|
||||||
|
else -> getN(set) * source.derivValue(parName, x, set)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getBkg(set: ValueProvider): Double {
|
||||||
|
return set.getDouble("bkg")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getN(set: ValueProvider): Double {
|
||||||
|
return set.getDouble("N")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun providesDeriv(name: String): Boolean {
|
||||||
|
return when (name) {
|
||||||
|
"N","bkg" -> true
|
||||||
|
else -> this.source.providesDeriv(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun value(x: Double, set: Values): Double {
|
||||||
|
this.counter.increase("value")
|
||||||
|
return getN(set) * source.value(x, set) + getBkg(set)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDefaultParameter(name: String): Double {
|
||||||
|
return when (name) {
|
||||||
|
"bkg" -> 0.0
|
||||||
|
"N" -> 1.0
|
||||||
|
else -> super.getDefaultParameter(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private val list = arrayOf("N", "bkg")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,16 +30,16 @@ class NBkgSpectrumWithCorrection(val source: ParametricFunction) : AbstractParam
|
|||||||
|
|
||||||
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||||
return when (parName) {
|
return when (parName) {
|
||||||
"bkg" -> 0.0
|
"bkg" -> 1.0
|
||||||
"N" -> (1.0 + x * set.l + x * x * set.q) * source.value(x, set)
|
"N" -> source.value(x, set)
|
||||||
"L" -> set.n * x * source.value(x, set)
|
"L" -> x / 1e3 * source.value(x, set)
|
||||||
"Q" -> set.n * x * x * source.value(x, set)
|
"Q" -> x * x /1e6 * source.value(x, set)
|
||||||
else -> set.n * (1.0 + x * set.l + x * x * set.q) * source.derivValue(parName, x, set)
|
else -> (set.n + x/1e3 * set.l + x * x /1e6 * set.q) * source.derivValue(parName, x, set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun value(x: Double, set: Values): Double {
|
override fun value(x: Double, set: Values): Double {
|
||||||
return set.n * (1.0 + x * set.l + x * x * set.q) * source.value(x, set) + set.bkg
|
return (set.n + x * set.l / 1e3 + x * x / 1e6 * set.q) * source.value(x, set) + set.bkg
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun providesDeriv(name: String): Boolean {
|
override fun providesDeriv(name: String): Boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user