diff --git a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt index f7217ccc..d8182bb7 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/storage/NumassDataFactory.kt @@ -35,11 +35,11 @@ class NumassDataFactory : DataFactory(NumassSet::class.java) { override fun fill(builder: DataNodeEditor, context: Context, meta: Meta) { runBlocking { - val storage = NumassDirectory.read(context,meta.getString("path")) as Storage + val storage = NumassDirectory.read(context, meta.getString("path")) as Storage storage.sequence().forEach { pair -> val value = pair.second if (value is NumassSet) { - builder.putStatic(pair.first.unescaped, value) + builder.putStatic(pair.first.unescaped, value, value.meta) } } } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt index d9bbcc1f..79492706 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/MergeDataAction.kt @@ -45,12 +45,11 @@ object MergeDataAction : ManyToOneAction("numass.merge", Table::cl override fun buildGroups(context: Context, input: DataNode, actionMeta: Meta): List> { val meta = inputMeta(context, input.meta, actionMeta) - val groups: List> = if (meta.hasValue("grouping.byValue")) { + return if (meta.hasValue("grouping.byValue")) { super.buildGroups(context, input, actionMeta) } else { GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, input.name)).group(input) } - return groups } override fun execute(context: Context, nodeName: String, data: Map, meta: Laminate): Table { diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/PointSliceSpectrum.kt b/numass-main/src/main/kotlin/inr/numass/scripts/PointSliceSpectrum.kt index ad5477eb..3dbb7cfd 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/PointSliceSpectrum.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/PointSliceSpectrum.kt @@ -23,7 +23,7 @@ fun main(args: Array) { } //val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") - val storage = NumassDirectory.read(context, "Fill_3_events") ?: error("Storage not found") + val storage = NumassDirectory.read(context, "Fill_3") ?: error("Storage not found") val analyzer = SmartAnalyzer() @@ -34,7 +34,7 @@ fun main(args: Array) { // "window.up" to 1600 } - val set = storage.provide("set_58", NumassSet::class.java).nullable ?: error("Set does not exist") + val set = storage.provide("set_4", NumassSet::class.java).nullable ?: error("Set does not exist") val frame = displayChart("slices").apply { plots.setType() diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitAllWithPower.kt b/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitAllWithPower.kt index e33c04f7..f0288b80 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitAllWithPower.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitAllWithPower.kt @@ -36,7 +36,7 @@ import inr.numass.data.storage.NumassDirectory import inr.numass.displayChart import inr.numass.subthreshold.Threshold -fun main(args: Array) { +fun main() { val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) { rootDir = "D:\\Work\\Numass\\sterile\\2017_05_frames" dataDir = "D:\\Work\\Numass\\data\\2017_05_frames" @@ -54,7 +54,7 @@ fun main(args: Array) { "xLow" to 1000 "xHigh" to 1300 "upper" to 6000 - "binning" to 20 + "binning" to 32 //"reference" to 18600 } diff --git a/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitWithPower.kt b/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitWithPower.kt index f50f3171..97ed14d1 100644 --- a/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitWithPower.kt +++ b/numass-main/src/main/kotlin/inr/numass/scripts/threshold/FitWithPower.kt @@ -35,19 +35,24 @@ import inr.numass.subthreshold.Threshold fun main(args: Array) { val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) { - rootDir = "D:\\Work\\Numass\\sterile\\2017_05" - dataDir = "D:\\Work\\Numass\\data\\2017_05" + rootDir = "D:\\Work\\Numass\\sterile\\2017_05_frames" + dataDir = "D:\\Work\\Numass\\data\\2017_05_frames" output = FXOutputManager() + DirectoryOutput() } - val storage = NumassDirectory.read(context, "Fill_2") as? FileStorage ?: error("Storage not found") + val storage = NumassDirectory.read(context, "Fill_3") as? FileStorage ?: error("Storage not found") val meta = buildMeta { - "delta" to -200 + "delta" to -300 "method" to "pow" "t0" to 15e3 - "window.lo" to 400 - "window.up" to 1600 +// "window.lo" to 400 +// "window.up" to 1600 + "xLow" to 1000 + "xHigh" to 1300 + "upper" to 6000 + "binning" to 32 + //"reference" to 18600 } val frame = displayChart("correction").apply { diff --git a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt index 598943ab..d2889193 100644 --- a/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt +++ b/numass-main/src/main/kotlin/inr/numass/tasks/NumassTasks.kt @@ -1,10 +1,7 @@ package inr.numass.tasks import hep.dataforge.configure -import hep.dataforge.data.CustomDataFilter -import hep.dataforge.data.DataSet -import hep.dataforge.data.DataTree -import hep.dataforge.data.DataUtils +import hep.dataforge.data.* import hep.dataforge.io.output.stream import hep.dataforge.io.render import hep.dataforge.meta.Meta @@ -22,6 +19,7 @@ import hep.dataforge.stat.fit.FitResult import hep.dataforge.stat.models.XYModel import hep.dataforge.tables.* import hep.dataforge.useMeta +import hep.dataforge.useValue import hep.dataforge.values.ValueType import hep.dataforge.values.Values import hep.dataforge.values.asValue @@ -50,10 +48,17 @@ import java.util.stream.StreamSupport import kotlin.collections.HashMap import kotlin.collections.set +private val filterForward = DataFilter.byMetaValue("iteration_info.reverse") { + !(it?.boolean ?: false) +} +private val filterReverse = DataFilter.byMetaValue("iteration_info.reverse") { + it?.boolean ?: false +} val selectTask = task("select") { descriptor { info = "Select data from initial data pool" + value("forward", types = listOf(ValueType.BOOLEAN), info = "Select only forward or only backward sets") } model { meta -> data("*") @@ -61,9 +66,18 @@ val selectTask = task("select") { } transform { data -> logger.info("Starting selection from data node with size ${data.size}") - CustomDataFilter(meta).filter(data.checked(NumassSet::class.java)).also { - logger.info("Selected ${it.size} elements") + var res = data.checked(NumassSet::class.java).filter(CustomDataFilter(meta)) + + meta.useValue("forward") { + res = if (it.boolean) { + res.filter(filterForward) + } else { + res.filter(filterReverse) + } } + + logger.info("Selected ${res.size} elements") + res } } @@ -362,7 +376,15 @@ val histogramTask = task("histogram") { }.sumByStep(NumassAnalyzer.CHANNEL_KEY, meta.getDouble("binning", 16.0)) //apply binning // send raw table to the output - context.output.render(table, stage = "numass.histogram", name = name, meta = meta) + context.output.render(table, stage = "numass.histogram", name = name) { + update(meta) + data.toSortedMap().forEach { name, set -> + putNode("data", buildMeta { + "name" to name + set.meta.useMeta("iteration_info"){"iteration" to it} + }) + } + } if (meta.getBoolean("plot", false)) { context.plotFrame("$name.plot", stage = "numass.histogram") { @@ -379,7 +401,6 @@ val histogramTask = task("histogram") { } } - return@join table } } @@ -397,8 +418,8 @@ val sliceTask = task("slice") { val analyzer = SmartAnalyzer() val slices = HashMap() val formatBuilder = TableFormatBuilder() - formatBuilder.addColumn("set",ValueType.STRING) - formatBuilder.addColumn("time",ValueType.TIME) + formatBuilder.addColumn("set", ValueType.STRING) + formatBuilder.addColumn("time", ValueType.TIME) meta.getMetaList("range").forEach { val range = IntRange(it.getInt("from"), it.getInt("to")) val name = it.getString("name", range.toString())