minor fixes

This commit is contained in:
Alexander Nozik 2016-08-26 19:21:43 +03:00
parent 6a184dddda
commit a5c485a2c1
19 changed files with 466 additions and 463 deletions

View File

@ -36,7 +36,7 @@ task listActions(dependsOn: classes, type: JavaExec) {
task workspace(dependsOn: classes, type: JavaExec) {
main 'inr.numass.workspace.NumassGrindLauncher'
classpath = sourceSets.main.runtimeClasspath
args "-c \"D:\\Work\\Numass\\sterile2016\\workspace.groovy\" numass.fitsum sum".split()
args "-c \"D:\\Work\\Numass\\sterile2016\\workspace.groovy\" numass.fitsum sum_down".split()
description "Run workspace task"
group "numass"

View File

@ -31,10 +31,10 @@ class NumassWorkspaceSpec extends WorkspaceSpec {
NumassWorkspaceSpec() {
//load tasks
super.loadTask(NumassPrepareTask)
super.loadTask(NumassTableFilterTask)
super.loadTask(NumassFitScanTask)
super.loadTask(NumassFitScanSummaryTask)
super.task(NumassPrepareTask)
super.task(NumassTableFilterTask)
super.task(NumassFitScanTask)
super.task(NumassFitScanSummaryTask)
}

View File

@ -19,43 +19,20 @@ import hep.dataforge.actions.ActionManager;
import hep.dataforge.context.BasicPlugin;
import hep.dataforge.context.Context;
import hep.dataforge.context.PluginDef;
import hep.dataforge.maths.MathPlugin;
import hep.dataforge.meta.Meta;
import hep.dataforge.plotfit.PlotFitResultAction;
import hep.dataforge.plots.PlotDataAction;
import hep.dataforge.stat.fit.FitManager;
import hep.dataforge.stat.fit.FitPlugin;
import hep.dataforge.stat.models.ModelManager;
import hep.dataforge.stat.models.WeightedXYModel;
import hep.dataforge.stat.models.XYModel;
import hep.dataforge.maths.MathPlugin;
import hep.dataforge.meta.Meta;
import hep.dataforge.plotfit.PlotFitResultAction;
import hep.dataforge.plots.PlotDataAction;
import hep.dataforge.tables.PointAdapter;
import hep.dataforge.tables.XYAdapter;
import inr.numass.actions.AdjustErrorsAction;
import inr.numass.actions.FindBorderAction;
import inr.numass.actions.MergeDataAction;
import inr.numass.actions.MonitorCorrectAction;
import inr.numass.actions.PrepareDataAction;
import inr.numass.actions.ReadNumassDataAction;
import inr.numass.actions.ReadNumassStorageAction;
import inr.numass.actions.ShowEnergySpectrumAction;
import inr.numass.actions.ShowLossSpectrumAction;
import inr.numass.actions.SlicingAction;
import inr.numass.actions.SubstractSpectrumAction;
import inr.numass.actions.SummaryAction;
import inr.numass.models.BetaSpectrum;
import inr.numass.models.CustomNBkgSpectrum;
import inr.numass.models.EmpiricalLossSpectrum;
import inr.numass.models.ExperimentalVariableLossSpectrum;
import inr.numass.models.GaussSourceSpectrum;
import inr.numass.models.GunSpectrum;
import inr.numass.models.ModularSpectrum;
import inr.numass.models.NBkgSpectrum;
import inr.numass.models.RangedNamedSetSpectrum;
import inr.numass.models.ResolutionFunction;
import inr.numass.models.TransmissionInterpolator;
import inr.numass.models.VariableLossSpectrum;
import inr.numass.actions.*;
import inr.numass.models.*;
import inr.numass.models.sterile.SterileNeutrinoSpectrum;
import org.apache.commons.math3.analysis.BivariateFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.util.FastMath;
@ -88,7 +65,6 @@ public class NumassPlugin extends BasicPlugin {
actions.registerAction(PlotFitResultAction.class);
actions.registerAction(ShowLossSpectrumAction.class);
actions.registerAction(AdjustErrorsAction.class);
actions.registerAction(ReadNumassStorageAction.class);
actions.registerAction(ShowEnergySpectrumAction.class);
actions.registerAction(SubstractSpectrumAction.class);
}
@ -121,7 +97,7 @@ public class NumassPlugin extends BasicPlugin {
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
double from = an.getDouble("from", 14400d);
double to = an.getDouble("to", 19010d);
RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt"));
RangedNamedSetSpectrum beta = new BetaSpectrum(getClass().getResourceAsStream("/data/FS.txt"));
ModularSpectrum sp = new ModularSpectrum(beta, A, from, to);
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
@ -226,55 +202,6 @@ public class NumassPlugin extends BasicPlugin {
return new XYModel(spectrum, getAdapter(meta));
});
manager.addModel("sterile-old", (context, meta) -> {
double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5
double from = meta.getDouble("from", 13900d);
double to = meta.getDouble("to", 18700d);
context.getReport().report("Setting up tritium model with real transmission function");
BivariateFunction resolutionTail;
if (meta.hasValue("resolution.tailAlpha")) {
resolutionTail = ResolutionFunction.getAngledTail(meta.getDouble("resolution.tailAlpha"), meta.getDouble("resolution.tailBeta", 0));
} else {
resolutionTail = ResolutionFunction.getRealTail();
}
RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt"));
ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, resolutionTail), from, to);
if (meta.getBoolean("caching", false)) {
context.getReport().report("Caching turned on");
sp.setCaching(true);
}
//Adding trapping energy dependence
if (meta.hasValue("transmission.trapping")) {
BivariateFunction trap = MathPlugin.buildFrom(context).buildBivariateFunction(meta.getString("transmussion.trapping"));
sp.setTrappingFunction(trap);
}
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel(spectrum, getAdapter(meta));
});
manager.addModel("modularbeta-unadeabatic", (context, an) -> {
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
double from = an.getDouble("from", 14400d);
double to = an.getDouble("to", 19010d);
BivariateFunction reolutionTail = (double E, double U) -> {
double x = E - U;
if (x > 1500) {
return 0.98;
} else //Intercept = 1.00051, Slope = -1.3552E-5
{
return 1.00051 - 1.3552E-5 * x;
}
};
RangedNamedSetSpectrum beta = new BetaSpectrum(context.io().getFile("FS.txt"));
ModularSpectrum sp = new ModularSpectrum(beta, new ResolutionFunction(A, reolutionTail), from, to);
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
return new XYModel(spectrum, getAdapter(an));
});
manager.addModel("gun", (context, an) -> {
GunSpectrum gsp = new GunSpectrum();

View File

@ -1,93 +0,0 @@
/*
* 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.actions;
import hep.dataforge.actions.GenericAction;
import hep.dataforge.computation.WorkManager.Callback;
import hep.dataforge.data.Data;
import hep.dataforge.data.DataFilter;
import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataSet;
import hep.dataforge.description.TypedActionDef;
import hep.dataforge.description.ValueDef;
import hep.dataforge.meta.Meta;
import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.commons.StorageUtils;
import inr.numass.storage.NumassData;
import inr.numass.storage.NumassDataLoader;
import inr.numass.storage.NumassStorage;
import inr.numass.storage.SetDirectionUtility;
import java.util.concurrent.CompletableFuture;
/**
*
* @author Alexander Nozik
*/
@TypedActionDef(name = "readStorage",
outputType = NumassData.class, info = "Read numass storage data")
@ValueDef(name = "uri", info = "The path to Numass storage")
//@NodeDef(name = "debunch", target = "class::inr.numass.actions.DebunchAction", info = "If given, governs debunching")
public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
@Override
public DataNode<NumassData> run(DataNode<Void> data, Meta actionMeta) {
try {
NumassStorage storage = NumassStorage.buildNumassRoot(actionMeta.getString("uri"), true, false);
DataFilter filter = new DataFilter().configure(actionMeta);
boolean forwardOnly = actionMeta.getBoolean("forwardOnly", false);
boolean reverseOnly = actionMeta.getBoolean("reverseOnly", false);
//FIXME make Work actually submitted only when calculation starts
CompletableFuture<DataSet<NumassData>> future = getContext().workManager()
.<DataSet<NumassData>>post(getName(), (Callback callback) -> {
//FIXME remove in later revisions
SetDirectionUtility.load(getContext());
DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
callback.setMaxProgress(StorageUtils.loaderStream(storage).count());
StorageUtils.loaderStream(storage).forEach(pair -> {
Loader loader = pair.getValue();
if (loader instanceof NumassData) {
NumassDataLoader nd = (NumassDataLoader) loader;
Data<NumassData> datum = Data.buildStatic(nd);
if (filter.acceptData(pair.getKey(), datum)) {
boolean accept = true;
if (forwardOnly || reverseOnly) {
boolean reversed = nd.isReversed();
accept = (reverseOnly && reversed) || (forwardOnly && !reversed);
}
if (accept) {
builder.putData(pair.getKey(), datum);
}
}
}
callback.increaseProgress(1d);
});
if (actionMeta.getBoolean("loadLegacy", false)) {
logger().info("Loading legacy files");
storage.legacyFiles().forEach(nd -> {
Data<NumassData> datum = Data.buildStatic(nd);
if (filter.acceptData(nd.getName(), datum)) {
builder.putData("legacy." + nd.getName(), datum);
}
});
}
//FIXME remove in later revisions
SetDirectionUtility.save(getContext());
return builder.build();
});
return future.get();
} catch (Exception ex) {
throw new RuntimeException("Failed to load storage", ex);
}
}
}

View File

@ -19,15 +19,18 @@ import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.stat.parametric.AbstractParametricFunction;
import hep.dataforge.values.NamedValueSet;
import hep.dataforge.values.ValueProvider;
import java.io.File;
import static java.lang.Math.abs;
import static java.lang.Math.exp;
import static java.lang.Math.sqrt;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import static java.lang.Math.*;
/**
*
* @author Darksnake
*/
@Deprecated
public class BetaSpectrum extends AbstractParametricFunction implements RangedNamedSetSpectrum {
static final double K = 1E-23;
@ -39,10 +42,17 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa
super(list);
}
public BetaSpectrum(File FSSFile) {
public BetaSpectrum(InputStream FSStream) {
super(list);
if (FSStream != null) {
this.fss = new FSS(FSStream);
}
}
public BetaSpectrum(File FSSFile) throws FileNotFoundException {
super(list);
if (FSSFile != null) {
this.fss = new FSS(FSSFile);
this.fss = new FSS(new FileInputStream(FSSFile));
}
}
@ -197,11 +207,11 @@ public class BetaSpectrum extends AbstractParametricFunction implements RangedNa
// P(rootsterile)+ (1-P)root
}
public void setFSS(File FSSFile) {
public void setFSS(File FSSFile) throws FileNotFoundException {
if (FSSFile == null) {
this.fss = null;
} else {
this.fss = new FSS(FSSFile);
this.fss = new FSS(new FileInputStream(FSSFile));
}
}

View File

@ -19,23 +19,19 @@ import hep.dataforge.io.IOUtils;
import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.PointSource;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
/**
*
* @author Darksnake
*/
public class FSS{
public class FSS {
private final ArrayList<Double> ps = new ArrayList<>();
private final ArrayList<Double> es = new ArrayList<>();
private double norm;
public FSS(File FSSFile) {
try {
PointSource data = IOUtils.readColumnedData(FSSFile,"E","P");
public FSS(InputStream stream) {
PointSource data = IOUtils.readColumnedData(stream, "E", "P");
norm = 0;
for (DataPoint dp : data) {
es.add(dp.getDouble("E"));
@ -43,35 +39,32 @@ public class FSS{
ps.add(p);
norm += p;
}
if(ps.isEmpty()) {
if (ps.isEmpty()) {
throw new RuntimeException("Error reading FSS FILE. No points.");
}
} catch (FileNotFoundException ex) {
throw new RuntimeException("Error reading FSS FILE. File not found.");
}
}
public double getE(int n){
public double getE(int n) {
return this.es.get(n);
}
public double getP(int n){
public double getP(int n) {
return this.ps.get(n) / norm;
}
public boolean isEmpty(){
public boolean isEmpty() {
return ps.isEmpty();
}
public int size(){
public int size() {
return ps.size();
}
public double[] getPs(){
return ps.stream().mapToDouble(p->p).toArray();
public double[] getPs() {
return ps.stream().mapToDouble(p -> p).toArray();
}
public double[] getEs(){
return es.stream().mapToDouble(p->p).toArray();
public double[] getEs() {
return es.stream().mapToDouble(p -> p).toArray();
}
}

View File

@ -8,9 +8,8 @@ package inr.numass.models.sterile;
import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.stat.parametric.AbstractParametricBiFunction;
import hep.dataforge.values.NamedValueSet;
import static java.lang.Math.abs;
import static java.lang.Math.exp;
import static java.lang.Math.sqrt;
import static java.lang.Math.*;
/**
* A bi-function for beta-spectrum calculation taking energy and final state as
@ -197,9 +196,7 @@ public class NumassBeta extends AbstractParametricBiFunction {
protected double getDefaultParameter(String name) {
switch (name) {
case "mnu2":
return 0;
case "U2":
return 0;
case "msterile2":
return 0;
default:

View File

@ -10,16 +10,20 @@ import hep.dataforge.context.GlobalContext;
import hep.dataforge.description.NodeDef;
import hep.dataforge.description.ValueDef;
import hep.dataforge.exceptions.NotDefinedException;
import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.meta.Meta;
import hep.dataforge.stat.parametric.AbstractParametricBiFunction;
import hep.dataforge.stat.parametric.AbstractParametricFunction;
import hep.dataforge.stat.parametric.ParametricBiFunction;
import hep.dataforge.maths.integration.UnivariateIntegrator;
import hep.dataforge.meta.Meta;
import hep.dataforge.values.NamedValueSet;
import inr.numass.NumassIntegrator;
import inr.numass.models.FSS;
import org.apache.commons.math3.analysis.UnivariateFunction;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
/**
* Compact all-in-one model for sterile neutrino spectrum
*
@ -27,21 +31,15 @@ import org.apache.commons.math3.analysis.UnivariateFunction;
*/
@NodeDef(name = "resolution")
@NodeDef(name = "transmission")
@ValueDef(name = "fssFile")
@ValueDef(name = "fssFile", info = "The name for external FSS file. By default internal FSS file is used")
@ValueDef(name = "useFSS", type = "BOOLEAN")
public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
private static final String[] list = {"X", "trap", "E0", "mnu2", "msterile2", "U2"};
// private final RandomGenerator rnd;
// private RealDistribution fssDistribution;
private FSS fss;
/**
* variables:Eo offset,Ein; parameters: "mnu2", "msterile2", "U2"
*/
private final ParametricBiFunction source = new NumassBeta();
/**
* variables:Ein,Eout; parameters: "A"
*/
@ -50,26 +48,32 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
* variables:Eout,U; parameters: "X", "trap"
*/
private final ParametricBiFunction resolution;
/**
* auxiliary function for trans-res convolution
*/
private final ParametricBiFunction transRes;
// private boolean useMC;
private FSS fss;
// private boolean useMC;
private boolean fast;
public SterileNeutrinoSpectrum(Context context, Meta configuration) {
super(list);
// rnd = new SynchronizedRandomGenerator(new JDKRandomGenerator());
if (configuration.getBoolean("useFSS", true)) {
InputStream fssStream;
if (configuration.hasValue("fssFile")) {
fss = new FSS(context.io().getFile(configuration.getString("fssFile")));
// fssDistribution = new EnumeratedRealDistribution(rnd, fss.getEs(), fss.getPs());
try {
fssStream = new FileInputStream(context.io().getFile(configuration.getString("fssFile")));
} catch (FileNotFoundException e) {
throw new RuntimeException("Could not locate FSS file");
}
} else {
fssStream = getClass().getResourceAsStream("/data/FS.txt");
}
fss = new FSS(fssStream);
}
transmission = new NumassTransmission(context, configuration.getNodeOrEmpty("transmission"));
resolution = new NumassResolution(configuration.getNode("resolution", Meta.empty()));
// this.useMC = configuration.getBoolean("useMC", false);
this.fast = configuration.getBoolean("fast", true);
transRes = new TransRes();
}
@ -103,96 +107,18 @@ public class SterileNeutrinoSpectrum extends AbstractParametricFunction {
return integrate(u, source, transRes, set);
}
// private int numCalls(double u) {
// return 100000;
// }
//
// private boolean useDirect() {
// return !useMC;
// }
@Override
public boolean providesDeriv(String name) {
return source.providesDeriv(name) && transmission.providesDeriv(name) && resolution.providesDeriv(name);
}
// /**
// * Random E generator
// *
// * @param a
// * @param b
// * @return
// */
// private double rndE(double a, double b) {
// return rnd.nextDouble() * (b - a) + a;
// }
//
// private double integrate(
// double u,
// ParametricBiFunction sourceFunction,
// ParametricBiFunction transmissionFunction,
// ParametricBiFunction resolutionFunction,
// NamedValueSet set) {
// if (useDirect()) {
// return integrateDirect(u, sourceFunction, transmissionFunction, resolutionFunction, set);
// } else {
// return integrateRandom(u, sourceFunction, transmissionFunction, resolutionFunction, set);
// }
// }
// /**
// * Monte-Carlo integration of spectrum
// *
// * @param u
// * @param sourceFunction
// * @param transmissionFunction
// * @param resolutionFunction
// * @param set
// * @return
// */
// private double integrateRandom(
// double u,
// ParametricBiFunction sourceFunction,
// ParametricBiFunction transmissionFunction,
// ParametricBiFunction resolutionFunction,
// NamedValueSet set) {
//
// int num = numCalls(u);
// double eMax = set.getDouble("E0") + 5d;
// if (u > eMax) {
// return 0;
// }
//
// double sum = DoubleStream.generate(() -> {
// // generate final state
// double fs;
// if (fssDistribution != null) {
// fs = fssDistribution.sample();
// } else {
// fs = 0;
// }
//
// double eIn = rndE(u, eMax);
//
// double eOut = rndE(u, eIn);
//
// double res = sourceFunction.value(fs, eIn, set)
// * transmissionFunction.value(eIn, eOut, set)
// * resolutionFunction.value(eOut, u, set);
//
// if (Double.isNaN(res)) {
// throw new Error();
// }
// return res;
// }).parallel().limit(num).sum();
// //triangle surface
// return Math.pow(eMax - u, 2d) / 2d * sum / num;
// }
/**
* Direct Gauss-Legandre integration
*
* @param u
* @param sourceFunction
* @param transmissionFunction
* @param resolutionFunction
* @param transResFunction
* @param set
* @return
*/

View File

@ -8,24 +8,24 @@ package inr.numass.utils;
import inr.numass.storage.NMEvent;
import inr.numass.storage.NMPoint;
import inr.numass.storage.RawNMPoint;
import static java.lang.Math.max;
import java.util.ArrayList;
import java.util.List;
import static java.lang.Math.max;
/**
*
* @author Alexander Nozik <altavir@gmail.com>
*/
public class PileUpSimulator {
private final static double us = 1e-6;//microsecond
private double uSet = 0;
private final double pointLength;
private final NMEventGenerator generator;
private final List<NMEvent> generated = new ArrayList<>();
private final List<NMEvent> pileup = new ArrayList<>();
private final List<NMEvent> registred = new ArrayList<>();
private double uSet = 0;
public PileUpSimulator(double countRate, double length) {
generator = new NMEventGenerator(countRate);
@ -96,8 +96,9 @@ public class PileUpSimulator {
* @param delay
* @return
*/
private boolean nextEventRegistered(double delay) {
double prob = 1d - 1d / (1d + Math.pow(delay / 6.2, 75.91));
private boolean nextEventRegistered(short prevChanel, double delay) {
double average = 6.76102 - 4.31897E-4 * prevChanel + 7.88429E-8 * prevChanel * prevChanel;
double prob = 1d - 1d / (1d + Math.pow(delay / average, 75.91));
return random(prob);
}
@ -120,7 +121,7 @@ public class PileUpSimulator {
//not counting double pileups
if (last != null) {
double delay = (next.getTime() - lastRegisteredTime) / us; //time between events in microseconds
if (nextEventRegistered(delay)) {
if (nextEventRegistered(last.getChanel(), delay)) {
//just register new event
registred.add(next);
lastRegisteredTime = next.getTime();

View File

@ -7,8 +7,7 @@ package inr.numass.workspace;
import hep.dataforge.actions.Action;
import hep.dataforge.actions.ManyToOneAction;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.context.Context;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataSet;
import hep.dataforge.description.TypedActionDef;
@ -19,9 +18,8 @@ import hep.dataforge.stat.fit.ParamSet;
import hep.dataforge.stat.fit.UpperLimitGenerator;
import hep.dataforge.tables.ListTable;
import hep.dataforge.tables.Table;
import hep.dataforge.workspace.GenericTask;
import hep.dataforge.workspace.AbstractTask;
import hep.dataforge.workspace.TaskModel;
import hep.dataforge.workspace.TaskState;
import java.io.OutputStream;
import java.util.Map;
@ -29,21 +27,21 @@ import java.util.Map;
/**
* @author Alexander Nozik
*/
public class NumassFitScanSummaryTask extends GenericTask {
public class NumassFitScanSummaryTask extends AbstractTask<Table> {
@Override
protected void transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
DataSet.Builder<Table> builder = DataSet.builder(Table.class);
Action<FitState, Table> action = new FitSummaryAction().withContext(context);
DataNode<FitState> data = state.getData().getCheckedNode("fitscan", FitState.class);
data.nodeStream().forEach(node ->
builder.putData(node.getName(), action.run((DataNode<FitState>) node, config).getData()));
Action<FitState, Table> action = new FitSummaryAction().withContext(model.getWorkspace().getContext());
DataNode<FitState> input = data.getCheckedNode("fitscan", FitState.class);
input.nodeStream().forEach(node ->
builder.putData(node.getName(), action.run((DataNode<FitState>) node, model.meta()).getData()));
// if (data.nodeStream().count() > 1) {
//merge tables if there is more than one
// }
state.finish(builder.build());
return builder.build();
}
@Override

View File

@ -6,8 +6,7 @@
package inr.numass.workspace;
import hep.dataforge.actions.Action;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.context.Context;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataTree;
import hep.dataforge.meta.Meta;
@ -16,22 +15,23 @@ import hep.dataforge.stat.fit.FitAction;
import hep.dataforge.stat.fit.FitState;
import hep.dataforge.tables.Table;
import hep.dataforge.values.Value;
import hep.dataforge.workspace.GenericTask;
import hep.dataforge.workspace.AbstractTask;
import hep.dataforge.workspace.TaskModel;
import hep.dataforge.workspace.TaskState;
/**
* @author Alexander Nozik
*/
public class NumassFitScanTask extends GenericTask {
public class NumassFitScanTask extends AbstractTask<FitState> {
@Override
protected void transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
protected DataNode<FitState> run(TaskModel model, ProgressCallback callback, DataNode<?> data) {
Meta config = model.meta();
String scanParameter = config.getString("scanPar", "msterile2");
Value scanValues = config.getValue("scanValues", Value.of("[2.5e5, 1e6, 2.25e6, 4e6, 6.25e6, 9e6]"));
Action<Table, FitState> action = new FitAction().withContext(context).withParentProcess(callback.workName());
Action<Table, FitState> action = new FitAction().withContext(model.getContext()).withParentProcess(callback.workName());
DataTree.Builder<FitState> resultBuilder = DataTree.builder(FitState.class);
DataNode<?> sourceNode = state.getData().getNode("prepare").get();
DataNode<?> sourceNode = data.getNode("prepare").get();
if (config.hasNode("merge")) {
//use merged data and ignore raw data
@ -41,11 +41,11 @@ public class NumassFitScanTask extends GenericTask {
//do fit
Meta fitConfig = config.getMeta("fit");
sourceNode.forEachDataWithType(Table.class, data -> {
sourceNode.forEachDataWithType(Table.class, d -> {
for (int i = 0; i < scanValues.listValue().size(); i++) {
Value val = scanValues.listValue().get(i);
MetaBuilder overrideMeta = new MetaBuilder(fitConfig);
overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", data.getName(), scanParameter, val.stringValue()));
overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", d.getName(), scanParameter, val.stringValue()));
if (overrideMeta.hasNode("params." + scanParameter)) {
overrideMeta.setValue("params." + scanParameter + ".value", val);
@ -54,13 +54,13 @@ public class NumassFitScanTask extends GenericTask {
.filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val));
}
// Data<Table> newData = new Data<Table>(data.getGoal(),data.type(),overrideMeta);
DataNode node = action.run(DataNode.of("fit_" + i, data, Meta.empty()), overrideMeta);
resultBuilder.putData(data.getName() + ".fit_" + i, node.getData());
DataNode node = action.run(DataNode.of("fit_" + i, d, Meta.empty()), overrideMeta);
resultBuilder.putData(d.getName() + ".fit_" + i, node.getData());
}
});
state.finish(resultBuilder.build());
return resultBuilder.build();
}
@Override

View File

@ -6,29 +6,32 @@
package inr.numass.workspace;
import hep.dataforge.actions.Action;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context;
import hep.dataforge.data.DataNode;
import hep.dataforge.data.DataTree;
import hep.dataforge.data.*;
import hep.dataforge.meta.Meta;
import hep.dataforge.meta.Template;
import hep.dataforge.storage.api.Loader;
import hep.dataforge.storage.commons.StorageUtils;
import hep.dataforge.tables.Table;
import hep.dataforge.tables.TransformTableAction;
import hep.dataforge.workspace.GenericTask;
import hep.dataforge.workspace.AbstractTask;
import hep.dataforge.workspace.TaskModel;
import hep.dataforge.workspace.TaskState;
import inr.numass.actions.MergeDataAction;
import inr.numass.actions.MonitorCorrectAction;
import inr.numass.actions.PrepareDataAction;
import inr.numass.actions.ReadNumassStorageAction;
import inr.numass.storage.NumassData;
import inr.numass.storage.NumassDataLoader;
import inr.numass.storage.NumassStorage;
import inr.numass.storage.SetDirectionUtility;
import java.net.URI;
/**
* Prepare data task
*
* @author Alexander Nozik
*/
public class NumassPrepareTask extends GenericTask {
public class NumassPrepareTask extends AbstractTask<Table> {
/*
<action type="readStorage" uri="file://D:\Work\Numass\data\2016_04\T2_data\">
@ -46,27 +49,27 @@ public class NumassPrepareTask extends GenericTask {
<action type="merge" mergeName="${numass.setName}"/>
*/
@Override
@SuppressWarnings("unchecked")
protected void transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
protected DataNode<Table> run(TaskModel model, ProgressCallback callback, DataNode<?> input) {
Meta config = model.meta();
Context context = model.getContext();
//acquiring initial data. Data node could not be empty
Meta dataMeta = config.getNode("data");
DataNode<NumassData> data = runAction(new ReadNumassStorageAction(), callback, context, DataNode.empty(), dataMeta);
state.setData("data", data);
URI storageUri = input.getCheckedData("dataRoot", URI.class).get();
DataNode<NumassData> data = readData(callback, context, storageUri, dataMeta);
//preparing table data
Meta prepareMeta = config.getNode("prepare");
DataNode<Table> tables = runAction(new PrepareDataAction(), callback, context, data, prepareMeta);
state.setData("prepare", tables);
if (config.hasNode("monitor")) {
Meta monitorMeta = config.getNode("monitor");
tables = runAction(new MonitorCorrectAction(), callback, context, tables, monitorMeta);
state.setData("monitor", tables);
}
//merging if needed
if (config.hasNode("merge")) {
DataTree.Builder resultBuilder = DataTree.builder(Table.class);
// tables.dataStream().forEach(d -> resultBuilder.putData(d));
DataTree.Builder<Table> resultBuilder = DataTree.builder(Table.class);
DataNode<Table> finalTables = tables;
config.getNodes("merge").forEach(mergeNode -> {
Meta mergeMeta = Template.compileTemplate(mergeNode, config);
@ -78,15 +81,61 @@ public class NumassPrepareTask extends GenericTask {
tables = resultBuilder.build();
}
if (config.hasNode("transform")) {
Meta filterMeta = config.getNode("transform");
tables = runAction(new TransformTableAction(), callback, context, tables, filterMeta);
return tables;
}
state.finish(tables);
@Override
protected TaskModel transformModel(TaskModel model) {
String rootName = model.meta().getString("data.root", "dataRoot");
model.data(rootName, "dataRoot");
return super.transformModel(model);
}
private <T, R> DataNode<R> runAction(Action<T, R> action, WorkManager.Callback callback, Context context, DataNode<T> data, Meta meta) {
private DataNode<NumassData> readData(ProgressCallback callback, Context context, URI numassRoot, Meta meta) {
NumassStorage storage = NumassStorage.buildNumassRoot(numassRoot, true, false);
DataFilter filter = new DataFilter().configure(meta);
boolean forwardOnly = meta.getBoolean("forwardOnly", false);
boolean reverseOnly = meta.getBoolean("reverseOnly", false);
SetDirectionUtility.load(context);
DataSet.Builder<NumassData> builder = DataSet.builder(NumassData.class);
callback.setMaxProgress(StorageUtils.loaderStream(storage).count());
StorageUtils.loaderStream(storage).forEach(pair -> {
Loader loader = pair.getValue();
if (loader instanceof NumassData) {
NumassDataLoader nd = (NumassDataLoader) loader;
Data<NumassData> datum = Data.buildStatic(nd);
if (filter.acceptData(pair.getKey(), datum)) {
boolean accept = true;
if (forwardOnly || reverseOnly) {
boolean reversed = nd.isReversed();
accept = (reverseOnly && reversed) || (forwardOnly && !reversed);
}
if (accept) {
builder.putData(pair.getKey(), datum);
}
}
}
callback.increaseProgress(1d);
});
if (meta.getBoolean("loadLegacy", false)) {
storage.legacyFiles().forEach(nd -> {
Data<NumassData> datum = Data.buildStatic(nd);
if (filter.acceptData(nd.getName(), datum)) {
builder.putData("legacy." + nd.getName(), datum);
}
});
}
//FIXME remove in later revisions
SetDirectionUtility.save(context);
return builder.build();
}
private <T, R> DataNode<R> runAction(Action<T, R> action, ProgressCallback callback, Context context, DataNode<T> data, Meta meta) {
return action.withContext(context).withParentProcess(callback.workName()).run(data, meta);
}

View File

@ -1,22 +1,19 @@
package inr.numass.workspace;
import hep.dataforge.actions.Action;
import hep.dataforge.actions.OneToOneAction;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.context.Context;
import hep.dataforge.data.DataNode;
import hep.dataforge.description.TypedActionDef;
import hep.dataforge.meta.Laminate;
import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.tables.Table;
import hep.dataforge.workspace.GenericTask;
import hep.dataforge.workspace.SingleActionTask;
import hep.dataforge.workspace.TaskModel;
import hep.dataforge.workspace.TaskState;
/**
* Created by darksnake on 13-Aug-16.
*/
public class NumassTableFilterTask extends GenericTask<Table> {
public class NumassTableFilterTask extends SingleActionTask<Table, Table> {
@Override
public String getName() {
@ -24,9 +21,8 @@ public class NumassTableFilterTask extends GenericTask<Table> {
}
@Override
protected void transform(WorkManager.Callback callback, Context context, TaskState state, Meta config) {
DataNode<Table> sourceNode = (DataNode<Table>) state.getData().getNode("prepare").get();
state.finish(new FilterTableAction().withContext(context).run(sourceNode, config));
protected DataNode<Table> gatherNode(DataNode<?> data) {
return data.getCheckedNode("prepare", Table.class);
}
@Override
@ -37,12 +33,18 @@ public class NumassTableFilterTask extends GenericTask<Table> {
return model;
}
@Override
protected Action<Table, Table> getAction(TaskModel model) {
return new FilterTableAction();
}
@TypedActionDef(name = "filterTable", inputType = Table.class, outputType = Table.class)
private class FilterTableAction extends OneToOneAction<Table, Table> {
@Override
protected Table execute(String name, Laminate inputMeta, Table input) {
double uLo = inputMeta.getDouble("filter.from", 0);
double uHi = inputMeta.getDouble("filter.to", Double.POSITIVE_INFINITY);
getLogger().debug("Filtering finished");
return input.filter("Uset", uLo, uHi);
}
}

View File

@ -0,0 +1,193 @@
0.000 0.008
0.097 0.005
0.197 0.028
0.297 0.055
0.397 0.056
0.497 0.218
0.597 0.191
0.697 0.434
0.797 0.429
0.897 0.688
0.997 1.300
1.097 1.078
1.197 2.793
1.297 3.715
1.397 4.480
1.497 7.176
1.597 6.825
1.697 5.171
1.797 6.187
1.897 5.023
1.997 3.334
2.097 2.239
2.197 1.493
2.297 1.008
2.397 1.562
2.647 0.940
2.897 0.518
3.147 0.249
3.397 0.116
3.647 0.055
3.897 0.036
4.397 0.007
4.897 0.001
20.881 0.003
21.881 0.021
22.881 0.109
23.881 0.385
24.881 0.973
25.881 1.833
26.881 2.671
27.881 3.093
28.881 2.913
29.881 2.276
30.881 1.503
31.881 0.882
32.881 0.727
33.881 1.389
34.881 2.175
35.881 2.086
36.881 1.310
37.881 0.676
38.725 0.010
38.881 0.416
39.881 0.370
40.881 0.350
41.881 0.269
42.732 0.965
42.881 0.166
43.405 0.029
43.881 0.091
43.963 0.372
44.147 0.128
44.881 0.043
45.881 0.016
46.881 0.004
47.913 0.129
50.599 1.216
52.553 0.440
55.109 0.065
55.852 0.154
57.004 0.159
58.092 0.000
58.592 0.001
59.092 0.003
59.592 0.010
60.092 0.026
60.592 0.058
61.092 0.126
61.592 0.206
62.092 0.301
62.592 0.377
63.092 0.418
63.592 0.377
64.092 0.301
64.386 0.003
64.592 0.206
64.886 0.007
65.092 0.126
65.386 0.023
65.592 0.058
65.886 0.060
66.092 0.026
66.386 0.133
66.592 0.010
66.886 0.288
67.092 0.003
67.386 0.471
67.592 0.001
67.886 0.688
68.092 0.000
68.386 0.863
68.886 0.956
69.386 0.863
69.886 0.688
70.386 0.471
70.886 0.288
71.386 0.133
71.725 0.306
71.886 0.060
72.386 0.023
72.886 0.007
73.386 0.003
74.820 0.245
76.169 0.088
76.868 0.100
77.221 0.273
79.427 0.020
80.865 0.238
81.965 0.137
83.429 0.151
84.170 0.212
84.218 0.112
86.123 0.014
87.374 0.010
88.259 0.009
88.876 0.013
89.871 0.026
90.690 0.023
91.784 0.052
93.247 0.178
94.333 0.133
96.192 0.026
96.701 0.054
97.543 0.023
98.514 0.005
98.840 0.010
100.263 0.014
100.784 0.003
101.620 0.003
102.426 0.005
102.842 0.001
103.170 0.001
103.594 0.006
104.236 0.002
105.008 0.001
105.799 0.002
106.990 0.006
108.711 0.010
109.189 0.008
109.975 0.007
111.148 0.005
112.339 0.013
113.145 0.010
113.882 0.005
114.892 0.002
115.612 0.002
116.455 0.001
117.594 0.005
118.481 0.023
119.245 0.023
120.360 0.009
121.764 0.013
123.594 0.009
124.247 0.005
125.709 0.012
127.715 0.003
129.373 0.002
130.271 0.004
132.887 0.060
133.402 0.025
134.813 0.082
135.371 0.006
136.379 0.005
136.916 0.003
138.243 0.008
139.737 0.010
141.093 0.006
142.461 0.047
144.001 0.004
144.391 0.007
147.073 0.021
148.311 0.015
148.895 0.001
150.849 0.004
151.442 0.001
152.854 0.000
154.169 0.002
156.093 0.001
157.003 0.003
158.134 0.003
159.271 0.002
162.054 0.007
164.173 0.002

View File

@ -22,18 +22,21 @@ import hep.dataforge.meta.Meta;
import hep.dataforge.meta.MetaBuilder;
import hep.dataforge.storage.filestorage.FileStorage;
import hep.dataforge.storage.filestorage.VFSUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileType;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileType;
import static org.apache.commons.vfs2.FileType.FOLDER;
import org.slf4j.LoggerFactory;
/**
* The file storage containing numass data directories or zips.
@ -51,6 +54,17 @@ public class NumassStorage extends FileStorage {
public static final String NUMASS_DATA_LOADER_TYPE = "numassData";
public static final String GROUP_META_FILE = "numass_group_meta";
protected NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
super(parent, path, config);
super.refresh();
//TODO read meta from numass_group_meta to .numass element
}
protected NumassStorage(FileObject dir, Meta config) throws StorageException {
super(dir, config);
super.refresh();
}
/**
* Create root numass storage
*
@ -91,34 +105,30 @@ public class NumassStorage extends FileStorage {
return new NumassStorage(parent, path, meta);
}
public static NumassStorage buildNumassRoot(String uri, boolean readOnly, boolean monitor) throws StorageException {
public static NumassStorage buildNumassRoot(String uri, boolean readOnly, boolean monitor) {
try {
Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", readOnly)
.setValue("monitor", monitor);
return new NumassStorage(VFSUtils.getRemoteFile(uri), meta);
} catch (FileSystemException ex) {
return new NumassStorage(VFSUtils.getFile(uri), meta);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
protected NumassStorage(FileStorage parent, String path, Meta config) throws StorageException {
super(parent, path, config);
super.refresh();
//TODO read meta from numass_group_meta to .numass element
public static NumassStorage buildNumassRoot(URI uri, boolean readOnly, boolean monitor) {
try {
Meta meta = new MetaBuilder("storage")
.setValue("type", "file.numass")
.setValue("readOnly", readOnly)
.setValue("monitor", monitor);
return new NumassStorage(VFSUtils.getFile(uri), meta);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
protected NumassStorage(FileObject dir, Meta config) throws StorageException {
super(dir, config);
super.refresh();
}
// protected NumassStorage(FileObject dir, boolean readOnly) throws StorageException {
// super(dir, null);
// super.setReadOnly(readOnly);
// super.refresh();
// }
@Override
protected void updateDirectoryLoaders() {
try {
@ -163,10 +173,7 @@ public class NumassStorage extends FileStorage {
/**
* Read nm.zip content and write it as a new nm.zip file
*
* @param path
* @param fileName
* @param stream
* @param size
*/
@SuppressWarnings("unchecked")
public void pushNumassData(String fileName, ByteBuffer data) throws StorageException {
@ -229,6 +236,10 @@ public class NumassStorage extends FileStorage {
public static final String FILE_NAME_KEY = "fileName";
public static final String FILE_SIZE_KEY = "fileSize";
public NumassDataPointEvent(Meta meta) {
super(meta);
}
public static NumassDataPointEvent build(String source, String fileName, int fileSize) {
return new NumassDataPointEvent(builder(source, fileName, fileSize).buildEventMeta());
}
@ -240,10 +251,6 @@ public class NumassStorage extends FileStorage {
.setMetaValue(FILE_SIZE_KEY, fileSize);
}
public NumassDataPointEvent(Meta meta) {
super(meta);
}
public int getFileSize() {
return meta().getInt(FILE_SIZE_KEY, 0);
}

View File

@ -15,43 +15,36 @@
*/
package inr.numass.viewer;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context;
import hep.dataforge.context.GlobalContext;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.fx.ConsoleFragment;
import hep.dataforge.fx.work.WorkManagerFragment;
import inr.numass.NumassProperties;
import inr.numass.storage.NumassData;
import inr.numass.storage.NumassStorage;
import java.io.File;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.*;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.TreeTableView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.stage.DirectoryChooser;
import javafx.util.Pair;
import org.controlsfx.control.StatusBar;
import java.io.File;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* FXML Controller class
*
@ -59,24 +52,15 @@ import org.controlsfx.control.StatusBar;
*/
public class MainViewerController implements Initializable {
public static MainViewerController build(NumassStorage root) {
MainViewerController res = new MainViewerController();
res.setRootStorage(root);
return res;
}
// private ConsoleFragment consoleFragment;
// private WorkManagerFragment processFragment = WorkManagerFragment.attachToContext(GlobalContext.instance());
@FXML
private ToggleButton consoleButton;
@FXML
private Button loadDirectoryButton;
private MspViewController mspController;
@FXML
private AnchorPane mspPlotPane;
//main pane views
@FXML
private AnchorPane numassLoaderViewContainer;
@ -84,7 +68,6 @@ public class MainViewerController implements Initializable {
private TreeTableView<NumassLoaderTreeBuilder.TreeItemValue> numassLoaderDataTree;
@FXML
private StatusBar statusBar;
//tabs
@FXML
private TabPane tabPane;
@ -103,7 +86,14 @@ public class MainViewerController implements Initializable {
@FXML
private ToggleButton processManagerButton;
public static MainViewerController build(NumassStorage root) {
MainViewerController res = new MainViewerController();
res.setRootStorage(root);
return res;
}
// private Popup progressPopup;
/**
* Initializes the controller class.
*
@ -139,7 +129,7 @@ public class MainViewerController implements Initializable {
}
private void loadDirectory(String path) {
getContext().workManager().submit("viewer.loadDirectory", (WorkManager.Callback callback) -> {
getContext().workManager().submit("viewer.loadDirectory", (ProgressCallback callback) -> {
callback.updateTitle("Load storage (" + path + ")");
callback.setProgress(-1);
callback.updateMessage("Building numass storage tree...");
@ -162,7 +152,7 @@ public class MainViewerController implements Initializable {
public void setRootStorage(NumassStorage root) {
getContext().workManager().cleanup();
getContext().workManager().submit("viewer.storage.load", (WorkManager.Callback callback) -> {
getContext().workManager().submit("viewer.storage.load", (ProgressCallback callback) -> {
callback.updateTitle("Fill data to UI (" + root.getName() + ")");
callback.setProgress(-1);
Platform.runLater(() -> statusBar.setProgress(-1));

View File

@ -20,8 +20,9 @@ package inr.numass.viewer;
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.exceptions.StorageException;
import hep.dataforge.plots.PlotUtils;
import hep.dataforge.plots.data.DynamicPlottable;
@ -33,13 +34,14 @@ import hep.dataforge.storage.api.Storage;
import hep.dataforge.tables.DataPoint;
import hep.dataforge.tables.MapPoint;
import hep.dataforge.values.Value;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.StreamSupport;
import javafx.application.Platform;
import javafx.scene.layout.AnchorPane;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.StreamSupport;
/**
* FXML Controller class
*
@ -85,7 +87,7 @@ public class MspViewController {
public void fillMspData(Storage rootStorage) {
if (rootStorage != null) {
context.workManager().submit("viewer.msp.fill", (WorkManager.Callback callback) -> {
context.workManager().submit("viewer.msp.fill", (ProgressCallback callback) -> {
try {
// callback.updateTitle("Fill msp data (" + rootStorage.getName() + ")");

View File

@ -15,14 +15,10 @@
*/
package inr.numass.viewer;
import hep.dataforge.computation.WorkManager;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.exceptions.StorageException;
import inr.numass.storage.NumassData;
import inr.numass.storage.NumassStorage;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.control.TreeItem;
@ -32,13 +28,18 @@ import javafx.scene.input.MouseEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
/**
*
* @author darksnake
*/
public class NumassLoaderTreeBuilder {
public void build(WorkManager.Callback callback,
public void build(ProgressCallback callback,
TreeTableView<TreeItemValue> numassLoaderDataTree,
NumassStorage rootStorage,
Consumer<NumassData> numassViewBuilder) throws StorageException {
@ -81,7 +82,7 @@ public class NumassLoaderTreeBuilder {
}
private TreeItem<TreeItemValue> buildNode(NumassStorage storage,
Consumer<NumassData> numassViewBuilder, WorkManager.Callback callback) throws StorageException {
Consumer<NumassData> numassViewBuilder, ProgressCallback callback) throws StorageException {
TreeItem<TreeItemValue> node = new TreeItem<>(buildValue(storage));
node.getChildren().setAll(buildChildren(storage, numassViewBuilder, callback));
return node;
@ -92,7 +93,7 @@ public class NumassLoaderTreeBuilder {
}
private List<TreeItem<TreeItemValue>> buildChildren(NumassStorage storage,
Consumer<NumassData> numassViewBuilder, WorkManager.Callback callback) throws StorageException {
Consumer<NumassData> numassViewBuilder, ProgressCallback callback) throws StorageException {
List<TreeItem<TreeItemValue>> list = new ArrayList<>();
storage.shelves().values().stream().forEach(subStorage -> {

View File

@ -21,7 +21,7 @@ package inr.numass.viewer;
* and open the template in the editor.
*/
import hep.dataforge.computation.WorkManager;
import hep.dataforge.computation.ProgressCallback;
import hep.dataforge.context.Context;
import hep.dataforge.io.ColumnedDataWriter;
import hep.dataforge.meta.Meta;
@ -214,7 +214,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
public void loadData(NumassData data) {
this.data = data;
if (data != null) {
context.workManager().<List<NMPoint>>submit("viewer.numass.load", (WorkManager.Callback callback) -> {
context.workManager().<List<NMPoint>>submit("viewer.numass.load", (ProgressCallback callback) -> {
callback.updateTitle("Load numass data (" + data.getName() + ")");
points = data.getNMPoints();
@ -239,7 +239,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
}
private void setupHVPane(Supplier<Table> hvData) {
context.workManager().submit("viewer.numass.hv", (WorkManager.Callback callback) -> {
context.workManager().submit("viewer.numass.hv", (ProgressCallback callback) -> {
Table t = hvData.get();
Platform.runLater(() -> {
if (t != null) {
@ -343,7 +343,7 @@ public class NumassLoaderViewComponent extends AnchorPane implements Initializab
detectorPlot.removePlot();
}
context.workManager().submit("viewer.numass.load.detector", (WorkManager.Callback callback) -> {
context.workManager().submit("viewer.numass.load.detector", (ProgressCallback callback) -> {
Meta plottableConfig = new MetaBuilder("plot")
.setValue("connectionType", "step")
.setValue("thickness", 2)