Minor fixes
This commit is contained in:
parent
23b4fc0246
commit
262d5f44d6
@ -31,7 +31,7 @@ public class NumassDataUtils {
|
|||||||
return new NumassSet() {
|
return new NumassSet() {
|
||||||
@Override
|
@Override
|
||||||
public Stream<NumassPoint> getPoints() {
|
public Stream<NumassPoint> getPoints() {
|
||||||
return sets.stream().flatMap(set -> getPoints());
|
return sets.stream().flatMap(NumassSet::getPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,8 @@ import hep.dataforge.meta.Meta;
|
|||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.utils.MetaHolder;
|
import hep.dataforge.utils.MetaHolder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -20,16 +22,16 @@ public class SimpleNumassPoint extends MetaHolder implements NumassPoint {
|
|||||||
* @param voltage
|
* @param voltage
|
||||||
* @param blocks
|
* @param blocks
|
||||||
*/
|
*/
|
||||||
public SimpleNumassPoint(double voltage, List<NumassBlock> blocks) {
|
public SimpleNumassPoint(double voltage, Collection<NumassBlock> blocks) {
|
||||||
this.blocks = blocks;
|
this.blocks = new ArrayList<>(blocks);
|
||||||
blocks.sort(Comparator.comparing(NumassBlock::getStartTime));
|
this.blocks.sort(Comparator.comparing(NumassBlock::getStartTime));
|
||||||
super.setMeta(new MetaBuilder("point").setValue(HV_KEY, voltage));
|
super.setMeta(new MetaBuilder("point").setValue(HV_KEY, voltage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleNumassPoint(Meta meta, List<NumassBlock> blocks) {
|
public SimpleNumassPoint(Meta meta, Collection<NumassBlock> blocks) {
|
||||||
super(meta);
|
super(meta);
|
||||||
blocks.sort(Comparator.comparing(NumassBlock::getStartTime));
|
this.blocks = new ArrayList<>(blocks);
|
||||||
this.blocks = blocks;
|
this.blocks.sort(Comparator.comparing(NumassBlock::getStartTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,6 +23,9 @@ compileTestKotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileGroovy.dependsOn(compileKotlin)
|
||||||
|
compileGroovy.classpath += files(compileKotlin.destinationDir)
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile group: 'commons-cli', name: 'commons-cli', version: '1.+'
|
compile group: 'commons-cli', name: 'commons-cli', version: '1.+'
|
||||||
compile group: 'commons-io', name: 'commons-io', version: '2.+'
|
compile group: 'commons-io', name: 'commons-io', version: '2.+'
|
||||||
|
@ -7,11 +7,12 @@ import hep.dataforge.grind.Grind
|
|||||||
import hep.dataforge.grind.GrindShell
|
import hep.dataforge.grind.GrindShell
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.plots.fx.FXPlotManager
|
import hep.dataforge.plots.fx.FXPlotManager
|
||||||
import hep.dataforge.storage.commons.StorageUtils
|
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
import inr.numass.actions.TimeAnalyzedAction
|
import inr.numass.actions.TimeAnalyzedAction
|
||||||
|
import inr.numass.data.NumassDataUtils
|
||||||
import inr.numass.data.api.NumassPoint
|
import inr.numass.data.api.NumassPoint
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
|
import inr.numass.data.api.SimpleNumassPoint
|
||||||
import inr.numass.data.storage.NumassStorage
|
import inr.numass.data.storage.NumassStorage
|
||||||
import inr.numass.data.storage.NumassStorageFactory
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
|
|
||||||
@ -31,26 +32,40 @@ new GrindShell(ctx).eval {
|
|||||||
|
|
||||||
Meta meta = Grind.buildMeta(binNum: 200) {
|
Meta meta = Grind.buildMeta(binNum: 200) {
|
||||||
window(lo: 500, up: 1800)
|
window(lo: 500, up: 1800)
|
||||||
|
plot(showErrors: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// def set = "set_43"
|
def sets = (20..31).collect { "set_$it" }
|
||||||
// def loader = storage.provide("loader::$set", NumassSet.class).get();
|
|
||||||
// def data = NumassUtils.pointsToNode(loader).filter { name, data ->
|
|
||||||
// return data.meta().getDouble("voltage",0) < 15000
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
def loaders = sets.collect { set ->
|
||||||
|
storage.provide("loader::$set", NumassSet.class).orElse(null)
|
||||||
|
}.findAll { it != null }
|
||||||
|
|
||||||
def hv = 14000;
|
def hvs = [14000d, 14200d, 14600d, 14800d, 15000d, 15200d, 15400d, 15600d, 15800d, 16000d]
|
||||||
def dataBuilder = DataSet.builder(NumassPoint)
|
|
||||||
|
|
||||||
StorageUtils.loaderStream(storage, false)
|
def all = NumassDataUtils.join("sum", loaders)
|
||||||
.filter { it.value instanceof NumassSet }
|
|
||||||
.forEach { pair ->
|
def builder = DataSet.builder(NumassPoint)
|
||||||
(pair.value as NumassSet).optPoint(hv).ifPresent {
|
|
||||||
dataBuilder.putData(pair.key, it, it.meta);
|
hvs.each { hv ->
|
||||||
|
builder.putStatic("point_${hv as int}", new SimpleNumassPoint(hv, all.points.filter {
|
||||||
|
it.voltage == hv
|
||||||
|
}.collect()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
def data = dataBuilder.build()
|
def data = builder.build()
|
||||||
|
|
||||||
|
// def hv = 14000;
|
||||||
|
// def dataBuilder = DataSet.builder(NumassPoint)
|
||||||
|
//
|
||||||
|
// StorageUtils.loaderStream(storage, false)
|
||||||
|
// .filter { it.value instanceof NumassSet }
|
||||||
|
// .forEach { pair ->
|
||||||
|
// (pair.value as NumassSet).optPoint(hv).ifPresent {
|
||||||
|
// dataBuilder.putData(pair.key, it, it.meta);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// def data = dataBuilder.build()
|
||||||
|
|
||||||
def result = new TimeAnalyzedAction().run(ctx, data, meta);
|
def result = new TimeAnalyzedAction().run(ctx, data, meta);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package inr.numass.actions
|
|||||||
|
|
||||||
import hep.dataforge.actions.OneToOneAction
|
import hep.dataforge.actions.OneToOneAction
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.description.TypedActionDef
|
import hep.dataforge.description.*
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import hep.dataforge.kodex.configure
|
import hep.dataforge.kodex.configure
|
||||||
import hep.dataforge.maths.histogram.UnivariateHistogram
|
import hep.dataforge.maths.histogram.UnivariateHistogram
|
||||||
@ -11,6 +11,7 @@ import hep.dataforge.plots.PlotManager
|
|||||||
import hep.dataforge.plots.data.PlottableData
|
import hep.dataforge.plots.data.PlottableData
|
||||||
import hep.dataforge.tables.Table
|
import hep.dataforge.tables.Table
|
||||||
import hep.dataforge.tables.ValueMap
|
import hep.dataforge.tables.ValueMap
|
||||||
|
import hep.dataforge.values.ValueType
|
||||||
import inr.numass.data.analyzers.TimeAnalyzer
|
import inr.numass.data.analyzers.TimeAnalyzer
|
||||||
import inr.numass.data.api.NumassAnalyzer
|
import inr.numass.data.api.NumassAnalyzer
|
||||||
import inr.numass.data.api.NumassPoint
|
import inr.numass.data.api.NumassPoint
|
||||||
@ -18,6 +19,18 @@ import inr.numass.data.api.NumassPoint
|
|||||||
/**
|
/**
|
||||||
* Plot time analysis graphics
|
* Plot time analysis graphics
|
||||||
*/
|
*/
|
||||||
|
@ValueDefs(
|
||||||
|
ValueDef(name = "normalize", type = arrayOf(ValueType.BOOLEAN), def = "true", info = "Normalize t0 dependencies"),
|
||||||
|
ValueDef(name = "t0", type = arrayOf(ValueType.NUMBER), def = "30e3", info = "The default t0 in nanoseconds"),
|
||||||
|
ValueDef(name = "window.lo", type = arrayOf(ValueType.NUMBER), def = "500", info = "Lower boundary for amplitude window"),
|
||||||
|
ValueDef(name = "window.up", type = arrayOf(ValueType.NUMBER), def = "10000", info = "Upper boundary for amplitude window"),
|
||||||
|
ValueDef(name = "binNum", type = arrayOf(ValueType.NUMBER), def = "1000", info = "Number of bins for time histogram"),
|
||||||
|
ValueDef(name = "binSize", type = arrayOf(ValueType.NUMBER), info = "Size of bin for time histogram. By default is defined automatically")
|
||||||
|
)
|
||||||
|
@NodeDefs(
|
||||||
|
NodeDef(name = "histogram", info = "Configuration for histogram plots"),
|
||||||
|
NodeDef(name = "plot", info = "Configuration for stat plots")
|
||||||
|
)
|
||||||
@TypedActionDef(name = "timeSpectrum", inputType = NumassPoint::class, outputType = Table::class)
|
@TypedActionDef(name = "timeSpectrum", inputType = NumassPoint::class, outputType = Table::class)
|
||||||
class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
||||||
private val analyzer = TimeAnalyzer();
|
private val analyzer = TimeAnalyzer();
|
||||||
@ -25,20 +38,21 @@ class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {
|
override fun execute(context: Context, name: String, input: NumassPoint, inputMeta: Laminate): Table {
|
||||||
val log = getLog(context, name);
|
val log = getLog(context, name);
|
||||||
|
|
||||||
|
|
||||||
|
val t0 = inputMeta.getDouble("t0", 30e3);
|
||||||
val loChannel = inputMeta.getInt("window.lo", 500);
|
val loChannel = inputMeta.getInt("window.lo", 500);
|
||||||
val upChannel = inputMeta.getInt("window.up", 10000);
|
val upChannel = inputMeta.getInt("window.up", 10000);
|
||||||
val pm = context.getFeature(PlotManager::class.java);
|
val pm = context.getFeature(PlotManager::class.java);
|
||||||
|
|
||||||
//TODO use meta parameters
|
|
||||||
|
|
||||||
val trueCR = analyzer.analyze(input, buildMeta {
|
val trueCR = analyzer.analyze(input, buildMeta {
|
||||||
"t0" to 30e3
|
"t0" to t0
|
||||||
"window.lo" to loChannel
|
"window.lo" to loChannel
|
||||||
"window.up" to upChannel
|
"window.up" to upChannel
|
||||||
}).getDouble("cr")
|
}).getDouble("cr")
|
||||||
|
|
||||||
val binNum = inputMeta.getInt("binNum", 1000);
|
val binNum = inputMeta.getInt("binNum", 1000);
|
||||||
val binSize = inputMeta.getDouble("binSize", 1.0 / trueCR * 10 / binNum)
|
val binSize = inputMeta.getDouble("binSize", 1.0 / trueCR * 10 / binNum * 1e6)
|
||||||
|
|
||||||
val histogram = UnivariateHistogram.buildUniform(0.0, binSize * binNum, binSize)
|
val histogram = UnivariateHistogram.buildUniform(0.0, binSize * binNum, binSize)
|
||||||
.fill(analyzer
|
.fill(analyzer
|
||||||
@ -56,7 +70,7 @@ class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
"axisTitle" to "delay"
|
"axisTitle" to "delay"
|
||||||
"axisUnits" to "us"
|
"axisUnits" to "us"
|
||||||
}
|
}
|
||||||
node("xAxis") {
|
node("yAxis") {
|
||||||
"type" to "log"
|
"type" to "log"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,22 +84,33 @@ class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
node("adapter") {
|
node("adapter") {
|
||||||
"y.value" to "count"
|
"y.value" to "count"
|
||||||
}
|
}
|
||||||
}.fillData(histogram)
|
}.apply {
|
||||||
|
configure(inputMeta.getMetaOrEmpty("histogram"))
|
||||||
|
}
|
||||||
|
.fillData(histogram)
|
||||||
)
|
)
|
||||||
|
|
||||||
log.report("The expected count rate for 30 us delay is $trueCR")
|
log.report("The expected count rate for 30 us delay is $trueCR")
|
||||||
|
|
||||||
val statPlotPoints = (1..150).map { 1000 * it }.map { t0 ->
|
val statPlotPoints = (1..150).map { 1000 * it }.map { t ->
|
||||||
val result = analyzer.analyze(input, buildMeta {
|
val result = analyzer.analyze(input, buildMeta {
|
||||||
"t0" to t0
|
"t0" to t
|
||||||
"window.lo" to loChannel
|
"window.lo" to loChannel
|
||||||
"window.up" to upChannel
|
"window.up" to upChannel
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
val norm = if (inputMeta.getBoolean("normalize", true)) {
|
||||||
|
trueCR
|
||||||
|
} else {
|
||||||
|
1.0
|
||||||
|
}
|
||||||
|
|
||||||
ValueMap.ofMap(
|
ValueMap.ofMap(
|
||||||
mapOf(
|
mapOf(
|
||||||
"x" to t0 / 1000,
|
"x" to t / 1000,
|
||||||
"y" to result.getDouble("cr"),
|
"y" to result.getDouble("cr") / norm,
|
||||||
"y.err" to result.getDouble(NumassAnalyzer.COUNT_RATE_ERROR_KEY)
|
"y.err" to result.getDouble(NumassAnalyzer.COUNT_RATE_ERROR_KEY) / norm
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -94,6 +119,9 @@ class TimeAnalyzedAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
PlottableData(name).configure {
|
PlottableData(name).configure {
|
||||||
"showLine" to true
|
"showLine" to true
|
||||||
"thickness" to 4
|
"thickness" to 4
|
||||||
|
"title" to "${name}_${input.voltage}"
|
||||||
|
}.apply {
|
||||||
|
configure(inputMeta.getMetaOrEmpty("plot"))
|
||||||
}.fillData(statPlotPoints)
|
}.fillData(statPlotPoints)
|
||||||
)
|
)
|
||||||
return histogram;
|
return histogram;
|
||||||
|
Loading…
Reference in New Issue
Block a user