[no commit message]
This commit is contained in:
parent
a41468a2e9
commit
8cc6d0365f
@ -17,7 +17,6 @@ package inr.numass.actions;
|
||||
|
||||
import hep.dataforge.actions.GroupBuilder;
|
||||
import hep.dataforge.actions.ManyToOneAction;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.data.DataNode;
|
||||
import hep.dataforge.stat.fit.FitState;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.tasks;
|
||||
|
||||
import hep.dataforge.actions.ManyToOneAction;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.data.Data;
|
||||
import hep.dataforge.data.DataNode;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
import hep.dataforge.io.reports.Reportable;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.stat.fit.FitState;
|
||||
import hep.dataforge.stat.fit.ParamSet;
|
||||
import hep.dataforge.tables.ListTable;
|
||||
import hep.dataforge.tables.Table;
|
||||
import hep.dataforge.workspace.GenericTask;
|
||||
import hep.dataforge.workspace.TaskModel;
|
||||
import hep.dataforge.workspace.TaskState;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class NumassFitScanSummaryTask extends GenericTask {
|
||||
|
||||
@Override
|
||||
protected TaskState transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
|
||||
return state.finish(new FitSummaryAction().withContext(context).run((DataNode<FitState>) state.getData(), config));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskModel transformModel(TaskModel model) {
|
||||
//Transmit meta as-is
|
||||
model.dependsOn("numass.fitscan", model.meta());
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "numass.fitsum";
|
||||
}
|
||||
|
||||
@TypedActionDef(name = "fitSummary", inputType = FitState.class, outputType = Table.class)
|
||||
private class FitSummaryAction extends ManyToOneAction<FitState, Table> {
|
||||
|
||||
@Override
|
||||
protected Table execute(Reportable log, String nodeName, Map<String, FitState> input, Meta meta) {
|
||||
ListTable.Builder builder = new ListTable.Builder("msterile2", "U2", "U2err", "E0", "trap");
|
||||
input.forEach((key, fitRes) -> {
|
||||
ParamSet pars = fitRes.getParameters();
|
||||
builder.row(pars.getValue("msterile2"),
|
||||
pars.getValue("U2"),
|
||||
pars.getError("U2"),
|
||||
pars.getValue("E0"),
|
||||
pars.getValue("trap"));
|
||||
});
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,15 @@ public class NumassFitScanTask extends GenericTask {
|
||||
Value scanValues = config.getValue("scanValues", Value.of(new String[]{"0.5, 1, 1.5, 2, 2.5, 3"}));
|
||||
Action action = new FitAction().withContext(context).withParentProcess(callback.workName());
|
||||
DataTree.Builder resultBuilder = DataTree.builder(FitState.class);
|
||||
state.getData().forEachWithType(Table.class, (name, data) -> {
|
||||
DataNode<?> sourceNode = state.getData();
|
||||
|
||||
if (config.hasNode("merge")) {
|
||||
//use merged data and ignore raw data
|
||||
sourceNode = sourceNode.getNode("merge").get();
|
||||
}
|
||||
|
||||
//do fit
|
||||
sourceNode.forEachDataWithType(Table.class, (name, data) -> {
|
||||
DataNode res = scanValues.listValue().stream().parallel().map(val -> {
|
||||
MetaBuilder overrideMeta = new MetaBuilder("override");
|
||||
overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", name, scanParameter, val.stringValue()));
|
||||
@ -47,9 +55,10 @@ public class NumassFitScanTask extends GenericTask {
|
||||
(DataSet.Builder builder, DataNode node) -> builder.putData(node.getName(), node.getData()),
|
||||
(DataSet.Builder builder1, DataSet.Builder builder2) -> builder1.putAll(builder2.getDataMap())
|
||||
).build();
|
||||
resultBuilder.putNode(name, res);
|
||||
resultBuilder.putData(name, res.getData());
|
||||
});
|
||||
|
||||
|
||||
state.finish(resultBuilder.build());
|
||||
return state;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
|
||||
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
|
||||
try {
|
||||
ActionUtils.runAction(getContext(), data, getActionConfiguration()).compute();
|
||||
ActionUtils.runAction(getContext(), data, getActionConfiguration()).computeAll();
|
||||
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
||||
} catch (Exception ex) {
|
||||
if (ex instanceof java.util.concurrent.CancellationException) {
|
||||
|
Loading…
Reference in New Issue
Block a user