diff --git a/build.gradle b/build.gradle index 7ec604c7..a98f9e23 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ allprojects{ dependencies{ compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.10" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.10" + compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: '1.2.10' } diff --git a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt index 2952459a..91f0a383 100644 --- a/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt +++ b/numass-core/src/main/kotlin/inr/numass/data/analyzers/TimeAnalyzer.kt @@ -169,9 +169,14 @@ class TimeAnalyzer @JvmOverloads constructor(private val processor: SignalProces * @return */ fun getEventsWithDelay(block: NumassBlock, config: Meta): Stream> { + val inverted = config.getBoolean("inverted",false) return super.getEvents(block, config).asSequence().zipWithNext { prev, next -> val delay = Math.max(next.timeOffset - prev.timeOffset, 0) - Pair(prev, delay) + if(inverted) { + Pair(next, delay) + } else{ + Pair(prev, delay) + } }.asStream() } diff --git a/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy b/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy new file mode 100644 index 00000000..f78978ff --- /dev/null +++ b/numass-main/src/main/groovy/inr/numass/scripts/temp/TestFXExit.groovy @@ -0,0 +1,30 @@ +/* + * Copyright 2017 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.scripts.temp + +import hep.dataforge.context.Context +import hep.dataforge.context.Global +import hep.dataforge.fx.plots.PlotManager +import hep.dataforge.grind.GrindShell +import hep.dataforge.grind.helpers.PlotHelper + +Context ctx = Global.instance() +ctx.getPluginManager().load(PlotManager) + +new GrindShell(ctx).eval { + (plots as PlotHelper).plotFunction(0,1){Math.sin it} +} \ No newline at end of file diff --git a/numass-main/src/main/groovy/inr/numass/scripts/times/AnalyzePoint.groovy b/numass-main/src/main/groovy/inr/numass/scripts/times/AnalyzePoint.groovy index 15c3f6cf..01359375 100644 --- a/numass-main/src/main/groovy/inr/numass/scripts/times/AnalyzePoint.groovy +++ b/numass-main/src/main/groovy/inr/numass/scripts/times/AnalyzePoint.groovy @@ -13,7 +13,6 @@ import inr.numass.data.NumassDataUtils import inr.numass.data.api.NumassPoint import inr.numass.data.api.NumassSet import inr.numass.data.api.SimpleNumassPoint -import inr.numass.data.storage.NumassStorage import inr.numass.data.storage.NumassStorageFactory /** @@ -26,12 +25,11 @@ ctx.getPluginManager().load(PlotManager) ctx.getPluginManager().load(NumassPlugin) new GrindShell(ctx).eval { - File rootDir = new File("D:\\Work\\Numass\\data\\2017_05\\Fill_2") - NumassStorage storage = NumassStorageFactory.buildLocal(rootDir); + def storage = NumassStorageFactory.buildLocal(ctx, "D:\\Work\\Numass\\data\\2017_05\\Fill_2", true, false); - Meta meta = Grind.buildMeta(binNum: 200) { - window(lo: 500, up: 1800) + Meta meta = Grind.buildMeta(binNum: 200, inverted: true) { + window(lo: 500, up: 3000) plot(showErrors: false) } @@ -44,7 +42,7 @@ new GrindShell(ctx).eval { storage.provide("loader::$set", NumassSet.class).orElse(null) }.findAll { it != null } - def hvs = [14000d, 14200d, 14600d, 14800d, 15000d, 15200d, 15400d, 15600d, 15800d, 16000d] + def hvs = [14000d]//[14000d, 14200d, 14600d, 14800d, 15000d, 15200d, 15400d, 15600d, 15800d] def all = NumassDataUtils.join("sum", loaders) @@ -74,5 +72,5 @@ new GrindShell(ctx).eval { result.computeAll(); - storage.close() +// storage.close() } \ No newline at end of file diff --git a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt index 1c5f64fd..bb7b2465 100644 --- a/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt +++ b/numass-main/src/main/kotlin/inr/numass/NumassPlugin.kt @@ -19,6 +19,7 @@ import hep.dataforge.actions.ActionManager import hep.dataforge.context.BasicPlugin import hep.dataforge.context.Context import hep.dataforge.context.PluginDef +import hep.dataforge.fx.FXPlugin import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.maths.MathPlugin import hep.dataforge.meta.Meta @@ -280,6 +281,6 @@ class NumassPlugin : BasicPlugin() { fun displayJFreeChart(title: String, width: Double = 800.0, height: Double = 600.0, meta: Meta = Meta.empty()): JFreeChartFrame { val frame = JFreeChartFrame(meta) frame.configureValue("title", title) - PlotContainer.display(frame, title, width, height) + FXPlugin().apply { startGlobal() }.display (PlotContainer(frame)) return frame } diff --git a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt index c0b7d660..9dfca90b 100644 --- a/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt +++ b/numass-main/src/main/kotlin/inr/numass/actions/TimeAnalyzerAction.kt @@ -3,7 +3,6 @@ package inr.numass.actions import hep.dataforge.actions.OneToOneAction import hep.dataforge.context.Context import hep.dataforge.description.* -import hep.dataforge.kodex.buildMeta import hep.dataforge.kodex.configure import hep.dataforge.maths.histogram.UnivariateHistogram import hep.dataforge.meta.Laminate @@ -39,17 +38,13 @@ class TimeAnalyzerAction : OneToOneAction() { val log = getLog(context, name); - val t0 = inputMeta.getDouble("t0", 30e3); + //val t0 = inputMeta.getDouble("t0", 30e3); val loChannel = inputMeta.getInt("window.lo", 500); val upChannel = inputMeta.getInt("window.up", 10000); val pm = context.getFeature(PlotPlugin::class.java); - val trueCR = analyzer.analyze(input, buildMeta { - "t0" to t0 - "window.lo" to loChannel - "window.up" to upChannel - }).getDouble("cr") + val trueCR = analyzer.analyze(input, inputMeta).getDouble("cr") log.report("The expected count rate for 30 us delay is $trueCR") @@ -86,11 +81,10 @@ class TimeAnalyzerAction : OneToOneAction() { "showSymbol" to false "showErrors" to false "connectionType" to "step" - node("@adapter") { - "y.value" to "count" - } - }.apply { configure(inputMeta.getMetaOrEmpty("histogram")) } - .fillData(histogram) + }.apply { + adapter = Adapters.buildXYAdapter("x", "count") + configure(inputMeta.getMetaOrEmpty("histogram")) + }.fillData(histogram) histPlot.add(histogramPlot) } @@ -108,11 +102,7 @@ class TimeAnalyzerAction : OneToOneAction() { pm.getPlotFrame(getName(), "stat-method").add(statPlot) (1..100).map { 1000 * it }.map { t -> - val result = analyzer.analyze(input, buildMeta { - "t0" to t - "window.lo" to loChannel - "window.up" to upChannel - }) + val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t)) val norm = if (inputMeta.getBoolean("normalize", true)) { diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt index 1215ac72..acb0662f 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/AmplitudeView.kt @@ -42,7 +42,7 @@ class AmplitudeView( "title" to "count rate" "units" to "Hz" } - "legend.show" to false + "legend.showComponent" to false } val binningProperty = SimpleObjectProperty(20)