From 18cc9112b57db51e86e6cb98161cb6b0c21ff840 Mon Sep 17 00:00:00 2001 From: darksnake Date: Tue, 18 Apr 2017 11:28:25 +0300 Subject: [PATCH 1/4] Fixed plugin loading bug --- numass-main/build.gradle | 9 ++++++++ .../src/main/groovy/inr/numass/RunTask.groovy | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 numass-main/src/main/groovy/inr/numass/RunTask.groovy diff --git a/numass-main/build.gradle b/numass-main/build.gradle index ea851034..7d61967e 100644 --- a/numass-main/build.gradle +++ b/numass-main/build.gradle @@ -36,6 +36,15 @@ task repl(dependsOn: classes, type: JavaExec) { } } +task grindTask(dependsOn: classes, type: JavaExec){ + group "numass" + main 'inr.numass.RunTask' + classpath = sourceSets.main.runtimeClasspath + description "Run a task in a numass workspace" + standardInput = System.in + standardOutput = System.out +} + task simulate(dependsOn: classes, type: JavaExec) { group "numass" main 'inr.numass.scripts.Simulate' diff --git a/numass-main/src/main/groovy/inr/numass/RunTask.groovy b/numass-main/src/main/groovy/inr/numass/RunTask.groovy new file mode 100644 index 00000000..c0a10980 --- /dev/null +++ b/numass-main/src/main/groovy/inr/numass/RunTask.groovy @@ -0,0 +1,23 @@ +package inr.numass + +import hep.dataforge.grind.GrindWorkspaceBuilder +import inr.numass.tasks.* + +/** + * Created by darksnake on 18-Apr-17. + */ + + +cfgPath = "D:\\Work\\Numass\\sterile2016_10\\workspace.groovy" + +GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder().read(new File(cfgPath)).startup { + it.loadTask(NumassPrepareTask) + it.loadTask(NumassTableFilterTask) + it.loadTask(NumassFitScanTask) + it.loadTask(NumassSubstractEmptySourceTask) + it.loadTask(NumassFitScanSummaryTask) + it.loadTask(NumassFitTask) + it.loadTask(NumassFitSummaryTask) +} + +numass.scansum "fill_1" \ No newline at end of file From 05faaf16966ac22aae9f9abadb3d097224740db9 Mon Sep 17 00:00:00 2001 From: darksnake Date: Thu, 20 Apr 2017 14:24:45 +0300 Subject: [PATCH 2/4] ValueProvider updates --- numass-main/src/main/java/inr/numass/Numass.java | 8 +++++--- numass-main/src/main/java/inr/numass/NumassPlugin.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/numass-main/src/main/java/inr/numass/Numass.java b/numass-main/src/main/java/inr/numass/Numass.java index a63e7ffd..ff460201 100644 --- a/numass-main/src/main/java/inr/numass/Numass.java +++ b/numass-main/src/main/java/inr/numass/Numass.java @@ -31,9 +31,11 @@ import hep.dataforge.meta.Meta; public class Numass { public static Context buildContext(Context parent, Meta meta) { - Context numassContext = Global.getContext("numass").withParent(parent).withProperties(meta); - numassContext.pluginManager().load("inr.numass:numass"); - return numassContext; + return Context.builder("NUMASS") + .parent(parent) + .properties(meta) + .plugin(NumassPlugin.class) + .build(); } public static Context buildContext() { diff --git a/numass-main/src/main/java/inr/numass/NumassPlugin.java b/numass-main/src/main/java/inr/numass/NumassPlugin.java index 3074efbe..bd25685d 100644 --- a/numass-main/src/main/java/inr/numass/NumassPlugin.java +++ b/numass-main/src/main/java/inr/numass/NumassPlugin.java @@ -72,7 +72,7 @@ public class NumassPlugin extends BasicPlugin { public void attach(Context context) { // StorageManager.buildFrom(context); super.attach(context); - context.setIO(new NumassIO()); + context.pluginManager().load(new NumassIO()); FitManager fm = context.getFeature(FitManager.class); loadModels(fm.getModelManager()); loadMath(MathPlugin.buildFrom(context)); From b7b9e09d40b8fea7d927acf72a436e12562ec8d1 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 21 Apr 2017 08:00:49 +0300 Subject: [PATCH 3/4] bringing numass up to date --- numass-viewer/build.gradle | 6 +++++- .../src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/numass-viewer/build.gradle b/numass-viewer/build.gradle index 511ae1c6..5cf26bbd 100644 --- a/numass-viewer/build.gradle +++ b/numass-viewer/build.gradle @@ -20,8 +20,12 @@ dependencies { compile 'com.jcraft:jsch:0.1.54' compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.1" - //compile "org.jetbrains.kotlin:kotlin-reflect:1.1.1" + compile "no.tornado:tornadofx:1.7.1" + // https://mvnrepository.com/artifact/org.controlsfx/controlsfx + compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.12' + + } //shadowJar { diff --git a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt index bac2d3d3..d0e5f60e 100644 --- a/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt +++ b/numass-viewer/src/main/kotlin/inr/numass/viewer/NumassLoaderView.kt @@ -50,6 +50,7 @@ class NumassLoaderView : View() { lateinit var main: MainView var data: NumassData? = null + val spectrumData = PlottableData("spectrum") private val detectorPlotPane: AnchorPane by fxid(); private val tabPane: TabPane by fxid(); @@ -175,7 +176,6 @@ class NumassLoaderView : View() { getWorkManager().startWork("viewer.numass.hv") { callback: Work -> val t = hvData.get() Platform.runLater { -// hvPlot.plot.clear() val set = PlottableGroup() for (dp in t) { val block = dp.getString("block", "default") @@ -216,7 +216,6 @@ class NumassLoaderView : View() { } private fun setupSpectrumPane(points: List) { - val spectrumData = PlottableData("spectrum") spectrumPlot.plot.add(spectrumData) val lowChannel = channelSlider.lowValue.toInt() From f5548b7715f5f1a9d19b77b8b8d96f6ed3ec126b Mon Sep 17 00:00:00 2001 From: darksnake Date: Tue, 25 Apr 2017 13:57:08 +0300 Subject: [PATCH 4/4] some fixes --- .../src/main/groovy/inr/numass/LaunchGrindShell.groovy | 2 +- .../java/hep/dataforge/plotfit/PlotFitResultAction.java | 7 ++++--- .../src/main/java/inr/numass/actions/DebunchAction.java | 2 +- .../java/inr/numass/actions/MonitorCorrectAction.java | 2 +- .../src/main/java/inr/numass/tasks/NumassFitScanTask.java | 5 +++-- .../src/main/java/inr/numass/tasks/NumassFitTask.java | 8 ++++---- .../inr/numass/tasks/NumassSubstractEmptySourceTask.java | 5 +++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy index 64e87bac..8208d0ae 100644 --- a/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy +++ b/numass-main/src/main/groovy/inr/numass/LaunchGrindShell.groovy @@ -22,7 +22,7 @@ println "Starting Grind shell" if (cfgPath) { try { - GrindTerminal.dumb().launch { + GrindTerminal.system().launch { GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder(it.shell.context).read(new File(cfgPath)).startup { it.loadTask(NumassPrepareTask) it.loadTask(NumassTableFilterTask) diff --git a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java index b4506623..f3ad3111 100644 --- a/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java +++ b/numass-main/src/main/java/hep/dataforge/plotfit/PlotFitResultAction.java @@ -27,6 +27,7 @@ import hep.dataforge.plots.PlotFrame; import hep.dataforge.plots.PlotUtils; import hep.dataforge.plots.data.PlottableData; import hep.dataforge.plots.data.PlottableXYFunction; +import hep.dataforge.stat.fit.FitResult; import hep.dataforge.stat.fit.FitState; import hep.dataforge.stat.models.XYModel; import hep.dataforge.tables.NavigablePointSource; @@ -41,14 +42,14 @@ import java.util.stream.StreamSupport; @TypedActionDef(name = "plotFit", info = "Plot fit result", inputType = FitState.class, outputType = FitState.class) @NodeDef(name = "adapter", info = "adapter for DataSet being fitted. By default is taken from model.") @ValueDef(name = "plotTitle", def = "", info = "The title of the plot.") -public class PlotFitResultAction extends OneToOneAction { +public class PlotFitResultAction extends OneToOneAction { @Override - protected FitState execute(Context context, String name, FitState input, Laminate metaData) { + protected FitResult execute(Context context, String name, FitResult input, Laminate metaData) { NavigablePointSource data = input.getDataSet(); if (!(input.getModel() instanceof XYModel)) { - getReport(context, name).reportError("The fit model should be instance of XYModel for this action. Action failed!"); + context.getLog(name).reportError("The fit model should be instance of XYModel for this action. Action failed!"); return input; } XYModel model = (XYModel) input.getModel(); diff --git a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java index 535739f6..a4011a9e 100644 --- a/numass-main/src/main/java/inr/numass/actions/DebunchAction.java +++ b/numass-main/src/main/java/inr/numass/actions/DebunchAction.java @@ -65,7 +65,7 @@ public class DebunchAction extends OneToOneAction { }); report(context, name, "File {} completed", source.getName()); - getReport(context, name).print(new PrintWriter(buildActionOutput(context, name))); + context.getLog(name).print(new PrintWriter(buildActionOutput(context, name))); // res.configure(source.meta()); return res; diff --git a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java index aff0cf4a..236d8b64 100644 --- a/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java +++ b/numass-main/src/main/java/inr/numass/actions/MonitorCorrectAction.java @@ -58,7 +58,7 @@ public class MonitorCorrectAction extends OneToOneAction { TreeMap index = getMonitorIndex(monitor, sourceData); if (index.isEmpty()) { - getReport(context, name).reportError("No monitor points found"); + context.getLog(name).reportError("No monitor points found"); return sourceData; } double norm = 0; diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanTask.java index 521ff395..a3b435ca 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassFitScanTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassFitScanTask.java @@ -11,6 +11,7 @@ import hep.dataforge.data.DataTree; import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; import hep.dataforge.stat.fit.FitAction; +import hep.dataforge.stat.fit.FitResult; import hep.dataforge.stat.fit.FitState; import hep.dataforge.tables.Table; import hep.dataforge.values.Value; @@ -40,7 +41,7 @@ public class NumassFitScanTask extends AbstractTask { } else { scanValues = config.getValue("scan.values", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]")); } - Action action = new FitAction(); + Action action = new FitAction(); DataTree.Builder resultBuilder = DataTree.builder(FitState.class); DataNode sourceNode = data.getCheckedNode("prepare", Table.class); @@ -65,7 +66,7 @@ public class NumassFitScanTask extends AbstractTask { .filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val)); } // Data
newData = new Data
(data.getGoal(),data.type(),overrideMeta); - DataNode node = action.run(model.getContext(), DataNode.of("fit_" + i, table, Meta.empty()), overrideMeta); + DataNode node = action.run(model.getContext(), DataNode.of("fit_" + i, table, Meta.empty()), overrideMeta); resultBuilder.putData(table.getName() + ".fit_" + i, node.getData()); } }); diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java index ad6f781c..50613e75 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassFitTask.java @@ -23,7 +23,7 @@ import hep.dataforge.meta.Meta; import hep.dataforge.meta.MetaBuilder; import hep.dataforge.plotfit.PlotFitResultAction; import hep.dataforge.stat.fit.FitAction; -import hep.dataforge.stat.fit.FitState; +import hep.dataforge.stat.fit.FitResult; import hep.dataforge.tables.Table; import hep.dataforge.workspace.SingleActionTask; import hep.dataforge.workspace.TaskModel; @@ -31,7 +31,7 @@ import hep.dataforge.workspace.TaskModel; /** * Created by darksnake on 16-Sep-16. */ -public class NumassFitTask extends SingleActionTask { +public class NumassFitTask extends SingleActionTask { @Override public String getName() { @@ -51,8 +51,8 @@ public class NumassFitTask extends SingleActionTask { } @Override - protected Action getAction(TaskModel model) { - Action action = new FitAction(); + protected Action getAction(TaskModel model) { + Action action = new FitAction(); if (model.meta().getBoolean("fit.plot", false)) { return ActionUtils.compose(action, new PlotFitResultAction()); } else { diff --git a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java index 64dab317..d539c670 100644 --- a/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java +++ b/numass-main/src/main/java/inr/numass/tasks/NumassSubstractEmptySourceTask.java @@ -29,6 +29,7 @@ import hep.dataforge.tables.MapPoint; import hep.dataforge.tables.Table; import hep.dataforge.workspace.AbstractTask; import hep.dataforge.workspace.TaskModel; +import org.slf4j.LoggerFactory; import java.io.OutputStream; import java.util.Optional; @@ -77,7 +78,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask
{ private Data subtractBackground(Data mergeData, Data emptyData) { - return DataUtils.combine(Table.class, mergeData, emptyData, mergeData.meta(), (BiFunction) this::subtractBackground); + return DataUtils.combine(mergeData, emptyData, Table.class, mergeData.meta(), (BiFunction) this::subtractBackground); } private Table subtractBackground(Table merge, Table empty) { @@ -90,7 +91,7 @@ public class NumassSubstractEmptySourceTask extends AbstractTask
{ pointBuilder.putValue("CR", Math.max(0, point.getDouble("CR") - referencePoint.get().getDouble("CR"))); pointBuilder.putValue("CRerr", Math.sqrt(Math.pow(point.getDouble("CRerr"), 2d) + Math.pow(referencePoint.get().getDouble("CRerr"), 2d))); } else { - getLogger().warn("No reference point found for Uset = {}", point.getDouble("Uset")); + LoggerFactory.getLogger(getClass()).warn("No reference point found for Uset = {}", point.getDouble("Uset")); } builder.row(pointBuilder.build()); });