[no commit message]
This commit is contained in:
parent
6d938f3380
commit
63ca107233
@ -54,7 +54,8 @@ new MINUITPlugin().startGlobal();
|
|||||||
FitManager fm = new FitManager();
|
FitManager fm = new FitManager();
|
||||||
|
|
||||||
ResolutionFunction resolution = new ResolutionFunction(8.3e-5);
|
ResolutionFunction resolution = new ResolutionFunction(8.3e-5);
|
||||||
resolution.setTailFunction(ResolutionFunction.getRealTail());
|
//resolution.setTailFunction(ResolutionFunction.getRealTail());
|
||||||
|
resolution.setTailFunction(ResolutionFunction.getAngledTail(0.00325));
|
||||||
ModularTritiumSpectrum beta = new ModularTritiumSpectrum(resolution, 18395d, 18580d, null);
|
ModularTritiumSpectrum beta = new ModularTritiumSpectrum(resolution, 18395d, 18580d, null);
|
||||||
beta.setCaching(false);
|
beta.setCaching(false);
|
||||||
|
|
||||||
@ -64,9 +65,9 @@ XYModel model = new XYModel("tritium", spectrum, new SpectrumDataAdapter());
|
|||||||
ParamSet allPars = new ParamSet();
|
ParamSet allPars = new ParamSet();
|
||||||
|
|
||||||
|
|
||||||
allPars.setPar("N", 6e7, 1e5, 0, Double.POSITIVE_INFINITY);
|
allPars.setPar("N", 6e9, 1e5, 0, Double.POSITIVE_INFINITY);
|
||||||
|
|
||||||
allPars.setPar("bkg", 2, 0.1 );
|
allPars.setPar("bkg", 0.002, 0.005 );
|
||||||
|
|
||||||
allPars.setPar("E0", 18575.0, 0.1 );
|
allPars.setPar("E0", 18575.0, 0.1 );
|
||||||
|
|
||||||
@ -85,18 +86,18 @@ allPars.setPar("trap", 1, 0.01, 0d, Double.POSITIVE_INFINITY);
|
|||||||
int seed = 12316
|
int seed = 12316
|
||||||
SpectrumGenerator generator = new SpectrumGenerator(model, allPars, seed);
|
SpectrumGenerator generator = new SpectrumGenerator(model, allPars, seed);
|
||||||
|
|
||||||
def config = DataModelUtils.getUniformSpectrumConfiguration(18400d, 18580, 1e7, 60)
|
def config = DataModelUtils.getUniformSpectrumConfiguration(18530d, 18580, 1e7, 60)
|
||||||
//def config = DataModelUtils.getSpectrumConfigurationFromResource("/data/run23.cfg")
|
//def config = DataModelUtils.getSpectrumConfigurationFromResource("/data/run23.cfg")
|
||||||
|
|
||||||
ListPointSet data = generator.generateExactData(config);
|
ListPointSet data = generator.generateExactData(config);
|
||||||
|
|
||||||
FitState state = new FitState(data, model, allPars);
|
FitState state = new FitState(data, model, allPars);
|
||||||
|
|
||||||
println("Simulating data with real tail. Seed = ${seed}")
|
println("Simulating data with real tail")
|
||||||
|
|
||||||
println("Fitting data with real parameters")
|
println("Fitting data with real parameters")
|
||||||
|
|
||||||
FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg","E0", "mnu2");
|
FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "E0", "mnu2");
|
||||||
res.print(out());
|
res.print(out());
|
||||||
|
|
||||||
def mnu2 = res.getParameters().getValue("mnu2");
|
def mnu2 = res.getParameters().getValue("mnu2");
|
||||||
@ -104,7 +105,7 @@ def mnu2 = res.getParameters().getValue("mnu2");
|
|||||||
println("Setting constant tail and fitting")
|
println("Setting constant tail and fitting")
|
||||||
resolution.setTailFunction(ResolutionFunction.getConstantTail());
|
resolution.setTailFunction(ResolutionFunction.getConstantTail());
|
||||||
|
|
||||||
res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg","E0", "mnu2");
|
res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg","E0","mnu2");
|
||||||
res.print(out());
|
res.print(out());
|
||||||
|
|
||||||
def diff = res.getParameters().getValue("mnu2") - mnu2;
|
def diff = res.getParameters().getValue("mnu2") - mnu2;
|
||||||
|
@ -25,6 +25,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.plots.PlotsPlugin;
|
import hep.dataforge.plots.PlotsPlugin;
|
||||||
import hep.dataforge.plots.XYPlotFrame;
|
import hep.dataforge.plots.XYPlotFrame;
|
||||||
@ -42,12 +43,8 @@ import hep.dataforge.points.PointSet;
|
|||||||
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.")
|
@ValueDef(name = "plotTitle", def = "", info = "The title of the plot.")
|
||||||
public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
||||||
|
|
||||||
public PlotFitResultAction(Context context, Meta annotation) {
|
|
||||||
super(context, annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FitState execute(Logable log, String name, Meta metaData, FitState input) {
|
protected FitState execute(Context context,Logable log, String name, Laminate metaData, FitState input) {
|
||||||
|
|
||||||
PointSet data = input.getDataSet();
|
PointSet data = input.getDataSet();
|
||||||
if (!(input.getModel() instanceof XYModel)) {
|
if (!(input.getModel() instanceof XYModel)) {
|
||||||
@ -68,7 +65,7 @@ public class PlotFitResultAction extends OneToOneAction<FitState, FitState> {
|
|||||||
UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters());
|
UnivariateFunction function = (double x) -> model.getSpectrum().value(x, input.getParameters());
|
||||||
|
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin
|
||||||
.buildFrom(getContext()).buildPlotFrame(getName(), name,
|
.buildFrom(context).buildPlotFrame(getName(), name,
|
||||||
metaData.getNode("plot", null));
|
metaData.getNode("plot", null));
|
||||||
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
|
//JFreeChartFrame.drawFrame(reader.getString("plotTitle", "Fit result plot for "+input.getName()), null);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass;
|
package inr.numass;
|
||||||
|
|
||||||
import hep.dataforge.actions.RunManager;
|
import hep.dataforge.actions.ActionUtils;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import static hep.dataforge.context.GlobalContext.out;
|
import static hep.dataforge.context.GlobalContext.out;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
@ -42,6 +42,13 @@ import org.apache.commons.cli.ParseException;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import static java.util.Locale.setDefault;
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
import static java.util.Locale.setDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -107,7 +114,7 @@ public class Main {
|
|||||||
|
|
||||||
applyCLItoContext(line, context);
|
applyCLItoContext(line, context);
|
||||||
|
|
||||||
return RunManager.executeAction(context, config);
|
return ActionUtils.runConfig(context, config);
|
||||||
} else {
|
} else {
|
||||||
Workbench.main(args);
|
Workbench.main(args);
|
||||||
return null;
|
return null;
|
||||||
|
@ -12,6 +12,7 @@ import hep.dataforge.points.ListPointSet;
|
|||||||
import hep.dataforge.points.MapPoint;
|
import hep.dataforge.points.MapPoint;
|
||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,12 +26,8 @@ import hep.dataforge.points.PointSet;
|
|||||||
@TypedActionDef(name = "adjustErrors", inputType = PointSet.class, outputType = PointSet.class)
|
@TypedActionDef(name = "adjustErrors", inputType = PointSet.class, outputType = PointSet.class)
|
||||||
public class AdjustErrorsAction extends OneToOneAction<PointSet, PointSet> {
|
public class AdjustErrorsAction extends OneToOneAction<PointSet, PointSet> {
|
||||||
|
|
||||||
public AdjustErrorsAction(Context context, Meta annotation) {
|
|
||||||
super(context, annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, String name,Meta meta, PointSet input) {
|
protected PointSet execute(Context context, Logable log, String name, Laminate meta, PointSet input) {
|
||||||
List<DataPoint> points = new ArrayList<>();
|
List<DataPoint> points = new ArrayList<>();
|
||||||
for (DataPoint dp : input) {
|
for (DataPoint dp : input) {
|
||||||
points.add(evalPoint(meta, dp));
|
points.add(evalPoint(meta, dp));
|
||||||
|
@ -21,7 +21,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Laminate;
|
||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.data.RawNMFile;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.data.RawNMPoint;
|
||||||
import inr.numass.debunch.DebunchReport;
|
import inr.numass.debunch.DebunchReport;
|
||||||
@ -40,19 +40,15 @@ import java.io.PrintWriter;
|
|||||||
@ValueDef(name = "maxcr", type = "NUMBER", def = "100", info = "Maximum count rate for debunching")
|
@ValueDef(name = "maxcr", type = "NUMBER", def = "100", info = "Maximum count rate for debunching")
|
||||||
public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
|
public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
|
||||||
|
|
||||||
public DebunchAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RawNMFile execute(Logable log, String name, Meta reader, RawNMFile source) throws ContentException {
|
protected RawNMFile execute(Context context, Logable log, String name, Laminate meta, RawNMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
int upper = source.meta().getInt("upperchanel", this.meta().getInt("upperchanel", RawNMPoint.MAX_CHANEL));
|
int upper = meta.getInt("upperchanel", RawNMPoint.MAX_CHANEL);
|
||||||
int lower = source.meta().getInt("lowerchanel", this.meta().getInt("lowerchanel", 0));
|
int lower = meta.getInt("lowerchanel", 0);
|
||||||
double rejectionprob = source.meta().getDouble("rejectprob", this.meta().getDouble("rejectprob", 1e-5));
|
double rejectionprob = meta.getDouble("rejectprob", 1e-5);
|
||||||
double framelength = source.meta().getDouble("framelength", this.meta().getDouble("framelength", 5));
|
double framelength = meta.getDouble("framelength", 5);
|
||||||
double maxCR = source.meta().getDouble("maxcr", this.meta().getDouble("maxcr", 100d));
|
double maxCR = meta.getDouble("maxcr", 100d);
|
||||||
|
|
||||||
RawNMFile res = new RawNMFile(source.getName());
|
RawNMFile res = new RawNMFile(source.getName());
|
||||||
res.setHead(source.getHead());
|
res.setHead(source.getHead());
|
||||||
@ -71,7 +67,7 @@ public class DebunchAction extends OneToOneAction<RawNMFile, RawNMFile> {
|
|||||||
});
|
});
|
||||||
log.log("File {} completed", source.getName());
|
log.log("File {} completed", source.getName());
|
||||||
|
|
||||||
log.getLog().print(new PrintWriter(buildActionOutput(name)));
|
log.getLog().print(new PrintWriter(buildActionOutput(context, name)));
|
||||||
|
|
||||||
// res.configure(source.meta());
|
// res.configure(source.meta());
|
||||||
return res;
|
return res;
|
||||||
|
@ -21,6 +21,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.data.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.data.NMPoint;
|
||||||
@ -33,17 +34,13 @@ import java.io.OutputStream;
|
|||||||
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
@TypedActionDef(name = "findBorder", inputType = NMFile.class, outputType = NMFile.class)
|
||||||
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
||||||
|
|
||||||
public FindBorderAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
int upperBorder = meta().getInt("upper", 4096);
|
int upperBorder = meta.getInt("upper", 4096);
|
||||||
int lowerBorder = meta().getInt("lower", 0);
|
int lowerBorder = meta.getInt("lower", 0);
|
||||||
double substractReference = meta().getDouble("reference", 0);
|
double substractReference = meta.getDouble("reference", 0);
|
||||||
|
|
||||||
NMPoint referencePoint = null;
|
NMPoint referencePoint = null;
|
||||||
if (substractReference > 0) {
|
if (substractReference > 0) {
|
||||||
@ -55,7 +52,7 @@ public class FindBorderAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
|
|
||||||
BorderData bData = new BorderData(source, upperBorder, lowerBorder, referencePoint);
|
BorderData bData = new BorderData(source, upperBorder, lowerBorder, referencePoint);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(name);
|
OutputStream stream = buildActionOutput(context, name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, bData, String.format("%s : lower = %d upper = %d", source.getName(), lowerBorder, upperBorder));
|
ColumnedDataWriter.writeDataSet(stream, bData, String.format("%s : lower = %d upper = %d", source.getName(), lowerBorder, upperBorder));
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import java.util.Collection;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -48,17 +47,13 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
public static final String MERGE_NAME = "mergeName";
|
public static final String MERGE_NAME = "mergeName";
|
||||||
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr"};
|
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr"};
|
||||||
|
|
||||||
public MergeDataAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected List<DataNode<PointSet>> buildGroups(DataNode input) {
|
protected List<DataNode<PointSet>> buildGroups(Context context, DataNode input, Meta actionMeta) {
|
||||||
Meta meta = inputMeta(input.meta());
|
Meta meta = inputMeta(context, input.meta(), actionMeta);
|
||||||
List<DataNode<PointSet>> groups;
|
List<DataNode<PointSet>> groups;
|
||||||
if (meta.hasValue("grouping.byValue")) {
|
if (meta.hasValue("grouping.byValue")) {
|
||||||
groups = super.buildGroups(input);
|
groups = super.buildGroups(context, input, actionMeta);
|
||||||
} else {
|
} else {
|
||||||
groups = GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, "merge")).group(input);
|
groups = GroupBuilder.byValue(MERGE_NAME, meta.getString(MERGE_NAME, "merge")).group(input);
|
||||||
}
|
}
|
||||||
@ -66,19 +61,14 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, DataNode<PointSet> input) {
|
protected PointSet execute(Context context, Logable log, String nodeName, Map<String, PointSet> data, Meta meta) {
|
||||||
return mergeOne(log, input);
|
PointSet res = mergeDataSets(nodeName, data.values());
|
||||||
}
|
|
||||||
|
|
||||||
private PointSet mergeOne(Logable log, DataNode<PointSet> input) {
|
|
||||||
List<PointSet> data = input.stream().<PointSet>map(item -> item.getValue().get()).collect(Collectors.toList());
|
|
||||||
PointSet res = mergeDataSets(input.getName(), data);
|
|
||||||
return res.sort("Uset", true);
|
return res.sort("Uset", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterGroup(Logable log, String groupName, Meta outputMeta, PointSet output) {
|
protected void afterGroup(Context context, Logable log, String groupName, Meta outputMeta, PointSet output) {
|
||||||
OutputStream stream = buildActionOutput(groupName);
|
OutputStream stream = buildActionOutput(context, groupName);
|
||||||
ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString());
|
ColumnedDataWriter.writeDataSet(stream, output, outputMeta.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +86,7 @@ public class MergeDataAction extends ManyToOneAction<PointSet, PointSet> {
|
|||||||
} else {
|
} else {
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MetaBuilder builder = super.outputMeta(input);
|
MetaBuilder builder = super.outputMeta(input);
|
||||||
/*
|
/*
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.actions;
|
package inr.numass.actions;
|
||||||
|
|
||||||
import hep.dataforge.actions.ActionResult;
|
|
||||||
import hep.dataforge.actions.OneToOneAction;
|
import hep.dataforge.actions.OneToOneAction;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
@ -26,6 +25,7 @@ import hep.dataforge.description.ValueDef;
|
|||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.values.Value;
|
import hep.dataforge.values.Value;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -51,15 +51,12 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
private static final String[] monitorNames = {"Timestamp", "Total", "CR", "CRerr"};
|
private static final String[] monitorNames = {"Timestamp", "Total", "CR", "CRerr"};
|
||||||
|
|
||||||
CopyOnWriteArrayList<DataPoint> monitorPoints = new CopyOnWriteArrayList<>();
|
CopyOnWriteArrayList<DataPoint> monitorPoints = new CopyOnWriteArrayList<>();
|
||||||
|
//FIXME remove from state
|
||||||
public MonitorCorrectAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, String name, Meta reader, PointSet sourceData) throws ContentException {
|
protected PointSet execute(Context context, Logable log, String name, Laminate meta, PointSet sourceData) throws ContentException {
|
||||||
|
|
||||||
double monitor = reader.getDouble("monitorPoint", Double.NaN);
|
double monitor = meta.getDouble("monitorPoint", Double.NaN);
|
||||||
|
|
||||||
TreeMap<LocalDateTime, DataPoint> index = getMonitorIndex(monitor, sourceData);
|
TreeMap<LocalDateTime, DataPoint> index = getMonitorIndex(monitor, sourceData);
|
||||||
if (index.isEmpty()) {
|
if (index.isEmpty()) {
|
||||||
@ -116,7 +113,7 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
point.putValue("Corrected", Value.of(dp.getValue("Corrected").doubleValue() / corrFactor));
|
point.putValue("Corrected", Value.of(dp.getValue("Corrected").doubleValue() / corrFactor));
|
||||||
point.putValue("CRerr", Value.of(err));
|
point.putValue("CRerr", Value.of(err));
|
||||||
}
|
}
|
||||||
if (meta().getBoolean("calculateRelative", false)) {
|
if (meta.getBoolean("calculateRelative", false)) {
|
||||||
point.putValue("relCR", point.getValue("CR").doubleValue() / norm);
|
point.putValue("relCR", point.getValue("CR").doubleValue() / norm);
|
||||||
point.putValue("relCRerr", point.getValue("CRerr").doubleValue() / norm);
|
point.putValue("relCRerr", point.getValue("CRerr").doubleValue() / norm);
|
||||||
}
|
}
|
||||||
@ -133,7 +130,7 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
// }
|
// }
|
||||||
PointSet data = new ListPointSet(dataList);
|
PointSet data = new ListPointSet(dataList);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(name);
|
OutputStream stream = buildActionOutput(context, name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, head);
|
ColumnedDataWriter.writeDataSet(stream, data, head);
|
||||||
|
|
||||||
@ -141,14 +138,14 @@ public class MonitorCorrectAction extends OneToOneAction<PointSet, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterAction(String name, PointSet res) {
|
protected void afterAction(Context context, String name, PointSet res, Laminate meta) {
|
||||||
printMonitorData();
|
printMonitorData(context, meta);
|
||||||
super.afterAction(name, res); //To change body of generated methods, choose Tools | Templates.
|
super.afterAction(context, name, res, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMonitorData() {
|
private void printMonitorData(Context context, Meta meta) {
|
||||||
String monitorFileName = meta().getString("monitorFile", "monitor");
|
String monitorFileName = meta.getString("monitorFile", "monitor");
|
||||||
OutputStream stream = buildActionOutput(monitorFileName);
|
OutputStream stream = buildActionOutput(context, monitorFileName);
|
||||||
ListPointSet data = new ListPointSet(monitorPoints);
|
ListPointSet data = new ListPointSet(monitorPoints);
|
||||||
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
ColumnedDataWriter.writeDataSet(stream, data.sort("Timestamp", true), "Monitor points", monitorNames);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import hep.dataforge.exceptions.ContentException;
|
|||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.XMLMetaWriter;
|
import hep.dataforge.io.XMLMetaWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.data.NMFile;
|
||||||
import inr.numass.data.NMPoint;
|
import inr.numass.data.NMPoint;
|
||||||
@ -50,24 +51,20 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
|
|||||||
|
|
||||||
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr", "Timestamp"};
|
public static String[] parnames = {"Uset", "Uread", "Length", "Total", "Window", "Corrected", "CR", "CRerr", "Timestamp"};
|
||||||
|
|
||||||
public PrepareDataAction(Context context, Meta an) {
|
private int getLowerBorder(Meta meta, double Uset) throws ContentException {
|
||||||
super(context, an);
|
double b = meta.getDouble("lowerWindow", 0);
|
||||||
}
|
double a = meta.getDouble("lowerWindowSlope", 0);
|
||||||
|
|
||||||
private int getLowerBorder(Meta source, double Uset) throws ContentException {
|
|
||||||
double b = source.getDouble("lowerWindow", this.meta().getDouble("lowerWindow", 0));
|
|
||||||
double a = source.getDouble("lowerWindowSlope", this.meta().getDouble("lowerWindowSlope", 0));
|
|
||||||
|
|
||||||
return (int) (b + Uset * a);
|
return (int) (b + Uset * a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ListPointSet execute(Logable log, String name, Meta reader, NMFile dataFile) {
|
protected ListPointSet execute(Context context, Logable log, String name, Laminate meta, NMFile dataFile) {
|
||||||
// log.logString("File %s started", dataFile.getName());
|
// log.logString("File %s started", dataFile.getName());
|
||||||
|
|
||||||
int upper = dataFile.meta().getInt("upperWindow", this.meta().getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1));
|
int upper = meta.getInt("upperWindow", RawNMPoint.MAX_CHANEL - 1);
|
||||||
|
|
||||||
double deadTime = dataFile.meta().getDouble("deadTime", this.meta().getDouble("deadTime", 0));
|
double deadTime = meta.getDouble("deadTime", 0);
|
||||||
// double bkg = source.meta().getDouble("background", this.meta().getDouble("background", 0));
|
// double bkg = source.meta().getDouble("background", this.meta().getDouble("background", 0));
|
||||||
|
|
||||||
List<DataPoint> dataList = new ArrayList<>();
|
List<DataPoint> dataList = new ArrayList<>();
|
||||||
@ -77,7 +74,7 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
|
|||||||
double Uset = point.getUset();
|
double Uset = point.getUset();
|
||||||
double Uread = point.getUread();
|
double Uread = point.getUread();
|
||||||
double time = point.getLength();
|
double time = point.getLength();
|
||||||
int a = getLowerBorder(dataFile.meta(), Uset);
|
int a = getLowerBorder(meta, Uset);
|
||||||
int b = Math.min(upper, RawNMPoint.MAX_CHANEL);
|
int b = Math.min(upper, RawNMPoint.MAX_CHANEL);
|
||||||
|
|
||||||
// analyzer.setMonitorCorrector(corrector);
|
// analyzer.setMonitorCorrector(corrector);
|
||||||
@ -110,11 +107,11 @@ public class PrepareDataAction extends OneToOneAction<NMFile, PointSet> {
|
|||||||
} else {
|
} else {
|
||||||
head = dataFile.getName();
|
head = dataFile.getName();
|
||||||
}
|
}
|
||||||
head = head + "\n" + new XMLMetaWriter().writeString(meta(), null) + "\n";
|
head = head + "\n" + new XMLMetaWriter().writeString(meta, null) + "\n";
|
||||||
|
|
||||||
ListPointSet data = new ListPointSet(dataList, format);
|
ListPointSet data = new ListPointSet(dataList, format);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(name);
|
OutputStream stream = buildActionOutput(context, name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, head);
|
ColumnedDataWriter.writeDataSet(stream, data, head);
|
||||||
// log.logString("File %s completed", dataFile.getName());
|
// log.logString("File %s completed", dataFile.getName());
|
||||||
|
@ -22,7 +22,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Laminate;
|
||||||
import static inr.numass.NumassIO.getNumassData;
|
import static inr.numass.NumassIO.getNumassData;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.data.NMFile;
|
||||||
import inr.numass.data.RawNMFile;
|
import inr.numass.data.RawNMFile;
|
||||||
@ -41,21 +41,20 @@ import java.io.File;
|
|||||||
@NodeDef(name = "debunch", target = "class::inr.numass.actions.DebunchAction", info = "If given, governs debunching")
|
@NodeDef(name = "debunch", target = "class::inr.numass.actions.DebunchAction", info = "If given, governs debunching")
|
||||||
public class ReadNumassDataAction extends OneToOneAction<File, NMFile> {
|
public class ReadNumassDataAction extends OneToOneAction<File, NMFile> {
|
||||||
|
|
||||||
public ReadNumassDataAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, String name, Meta reader, File source) throws ContentException {
|
protected NMFile execute(Context context, Logable log, String name, Laminate meta, File source) throws ContentException {
|
||||||
// log.logString("File '%s' started", source.getName());
|
// log.logString("File '%s' started", source.getName());
|
||||||
RawNMFile raw = getNumassData(source, meta());
|
RawNMFile raw = getNumassData(source, meta);
|
||||||
if (meta().getBoolean("paw", false)) {
|
if (meta.getBoolean("paw", false)) {
|
||||||
raw.generatePAW(buildActionOutput(name + ".paw"));
|
raw.generatePAW(buildActionOutput(context, name + ".paw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta().hasNode("debunch")) {
|
if (meta.getNodeNames(false).contains("debunch")) {
|
||||||
DebunchAction debunch = new DebunchAction(getContext(), meta().getNode("debunch"));
|
DebunchAction debunch = new DebunchAction();
|
||||||
raw = debunch.execute(log, name, null, raw);
|
Laminate laminate = new Laminate(meta.getNode("debunch"))
|
||||||
|
.setValueContext(context)
|
||||||
|
.setDescriptor(debunch.getDescriptor());
|
||||||
|
raw = debunch.execute(context, log, name, laminate, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMFile result = new NMFile(raw);
|
NMFile result = new NMFile(raw);
|
||||||
|
@ -33,6 +33,7 @@ import hep.dataforge.maths.GridCalculator;
|
|||||||
import hep.dataforge.maths.NamedDoubleSet;
|
import hep.dataforge.maths.NamedDoubleSet;
|
||||||
import hep.dataforge.maths.NamedMatrix;
|
import hep.dataforge.maths.NamedMatrix;
|
||||||
import hep.dataforge.maths.integration.UnivariateIntegrator;
|
import hep.dataforge.maths.integration.UnivariateIntegrator;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.meta.MetaBuilder;
|
import hep.dataforge.meta.MetaBuilder;
|
||||||
import hep.dataforge.plots.PlotsPlugin;
|
import hep.dataforge.plots.PlotsPlugin;
|
||||||
@ -65,12 +66,8 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
|
|
||||||
private static final String[] names = {"X", "exPos", "ionPos", "exW", "ionW", "exIonRatio"};
|
private static final String[] names = {"X", "exPos", "ionPos", "exW", "ionW", "exIonRatio"};
|
||||||
|
|
||||||
public ShowLossSpectrumAction(Context context, Meta annotation) {
|
|
||||||
super(context, annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FitState execute(Logable log, String name, Meta reader, FitState input) {
|
protected FitState execute(Context context, Logable log, String name, Laminate meta, FitState input) {
|
||||||
ParamSet pars = input.getParameters();
|
ParamSet pars = input.getParameters();
|
||||||
if (!pars.names().contains(names)) {
|
if (!pars.names().contains(names)) {
|
||||||
LoggerFactory.getLogger(getClass()).error("Wrong input FitState. Must be loss spectrum fit.");
|
LoggerFactory.getLogger(getClass()).error("Wrong input FitState. Must be loss spectrum fit.");
|
||||||
@ -79,7 +76,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
|
|
||||||
UnivariateFunction scatterFunction;
|
UnivariateFunction scatterFunction;
|
||||||
boolean calculateRatio = false;
|
boolean calculateRatio = false;
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(context)
|
||||||
.buildPlotFrame(getName(), name + ".loss",
|
.buildPlotFrame(getName(), name + ".loss",
|
||||||
new MetaBuilder("plot")
|
new MetaBuilder("plot")
|
||||||
.setValue("plotTitle", "Differential scattering crossection for " + name)
|
.setValue("plotTitle", "Differential scattering crossection for " + name)
|
||||||
@ -104,15 +101,15 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
double ionRatio = -1;
|
double ionRatio = -1;
|
||||||
double ionRatioError = -1;
|
double ionRatioError = -1;
|
||||||
if (calculateRatio) {
|
if (calculateRatio) {
|
||||||
threshold = reader.getDouble("ionThreshold", 17);
|
threshold = meta.getDouble("ionThreshold", 17);
|
||||||
ionRatio = calcultateIonRatio(pars, threshold);
|
ionRatio = calcultateIonRatio(pars, threshold);
|
||||||
log.log("The ionization ratio (using threshold {}) is {}", threshold, ionRatio);
|
log.log("The ionization ratio (using threshold {}) is {}", threshold, ionRatio);
|
||||||
ionRatioError = calultateIonRatioError(name, input, threshold);
|
ionRatioError = calultateIonRatioError(context, name, input, threshold);
|
||||||
log.log("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError);
|
log.log("the ionization ration standard deviation (using threshold {}) is {}", threshold, ionRatioError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.getBoolean("printResult", false)) {
|
if (meta.getBoolean("printResult", false)) {
|
||||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(buildActionOutput(name), Charset.forName("UTF-8")));
|
PrintWriter writer = new PrintWriter(new OutputStreamWriter(buildActionOutput(context, name), Charset.forName("UTF-8")));
|
||||||
// writer.println("*** FIT PARAMETERS ***");
|
// writer.println("*** FIT PARAMETERS ***");
|
||||||
input.print(writer);
|
input.print(writer);
|
||||||
// for (Param param : pars.getSubSet(names).getParams()) {
|
// for (Param param : pars.getSubSet(names).getParams()) {
|
||||||
@ -168,7 +165,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
writer.println();
|
writer.println();
|
||||||
PrintFunction.printFunctionSimple(writer, scatterFunction, 0, 100, 500);
|
PrintFunction.printFunctionSimple(writer, scatterFunction, 0, 100, 500);
|
||||||
|
|
||||||
if (meta().getBoolean("showSpread", false)) {
|
if (meta.getBoolean("showSpread", false)) {
|
||||||
writer.println("***SPECTRUM SPREAD***");
|
writer.println("***SPECTRUM SPREAD***");
|
||||||
writer.println();
|
writer.println();
|
||||||
|
|
||||||
@ -208,14 +205,14 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
return exProb / ionProb;
|
return exProb / ionProb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double calultateIonRatioError(String dataNeme, FitState state, double threshold) {
|
public double calultateIonRatioError(Context context, String dataNeme, FitState state, double threshold) {
|
||||||
ParamSet parameters = state.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
ParamSet parameters = state.getParameters().getSubSet(new String[]{"exPos", "ionPos", "exW", "ionW", "exIonRatio"});
|
||||||
NamedMatrix covariance = state.getCovariance();
|
NamedMatrix covariance = state.getCovariance();
|
||||||
return calultateIonRatioError(dataNeme, parameters, covariance, threshold);
|
return calultateIonRatioError(context, dataNeme, parameters, covariance, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("Unchecked")
|
@SuppressWarnings("Unchecked")
|
||||||
public double calultateIonRatioError(String name, NamedDoubleSet parameters, NamedMatrix covariance, double threshold) {
|
public double calultateIonRatioError(Context context, String name, NamedDoubleSet parameters, NamedMatrix covariance, double threshold) {
|
||||||
int number = 10000;
|
int number = 10000;
|
||||||
|
|
||||||
double[] res = new GaussianParameterGenerator(parameters, covariance)
|
double[] res = new GaussianParameterGenerator(parameters, covariance)
|
||||||
@ -227,7 +224,7 @@ public class ShowLossSpectrumAction extends OneToOneAction<FitState, FitState> {
|
|||||||
|
|
||||||
Histogram hist = new Histogram(0.3, 0.5, 0.002);
|
Histogram hist = new Histogram(0.3, 0.5, 0.002);
|
||||||
hist.fill(res);
|
hist.fill(res);
|
||||||
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(getContext())
|
XYPlotFrame frame = (XYPlotFrame) PlotsPlugin.buildFrom(context)
|
||||||
.buildPlotFrame(getName(), name + ".ionRatio",
|
.buildPlotFrame(getName(), name + ".ionRatio",
|
||||||
new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name)
|
new MetaBuilder("plot").setValue("plotTitle", "Ion ratio Distribution for " + name)
|
||||||
);
|
);
|
||||||
|
@ -21,6 +21,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.plots.fx.FXPlotUtils;
|
import hep.dataforge.plots.fx.FXPlotUtils;
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
@ -45,28 +46,24 @@ import org.jfree.ui.RectangleEdge;
|
|||||||
@TypedActionDef(name = "showSpectrum", inputType = NMFile.class, outputType = NMFile.class)
|
@TypedActionDef(name = "showSpectrum", inputType = NMFile.class, outputType = NMFile.class)
|
||||||
public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
||||||
|
|
||||||
public ShowSpectrumAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException {
|
||||||
log.log("File {} started", source.getName());
|
log.log("File {} started", source.getName());
|
||||||
|
|
||||||
List<NMPoint> printPoints = new ArrayList<>();
|
List<NMPoint> printPoints = new ArrayList<>();
|
||||||
List<NMPoint> showPoints = new ArrayList<>();
|
List<NMPoint> showPoints = new ArrayList<>();
|
||||||
|
|
||||||
for (NMPoint point : source.getNMPoints()) {
|
for (NMPoint point : source.getNMPoints()) {
|
||||||
if (toPrint(point)) {
|
if (toPrint(point, meta)) {
|
||||||
printPoints.add(point);
|
printPoints.add(point);
|
||||||
}
|
}
|
||||||
if (toShow(point)) {
|
if (toShow(point, meta)) {
|
||||||
showPoints.add(point);
|
showPoints.add(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int chanelsPerBin = meta().getInt("binning", 1); // биннинг
|
int chanelsPerBin = meta.getInt("binning", 1); // биннинг
|
||||||
boolean normalize = meta().getBoolean("normalize", false); // нормировка на время набора точки
|
boolean normalize = meta.getBoolean("normalize", false); // нормировка на время набора точки
|
||||||
|
|
||||||
if (showPoints.size() > 0) {
|
if (showPoints.size() > 0) {
|
||||||
showSpectra(showPoints, source.getName(), chanelsPerBin, normalize);
|
showSpectra(showPoints, source.getName(), chanelsPerBin, normalize);
|
||||||
@ -75,7 +72,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
if (printPoints.size() > 0) {
|
if (printPoints.size() > 0) {
|
||||||
ESpectrum data = new ESpectrum(printPoints, chanelsPerBin, normalize);
|
ESpectrum data = new ESpectrum(printPoints, chanelsPerBin, normalize);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(name);
|
OutputStream stream = buildActionOutput(context, name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, data, source.getName());
|
ColumnedDataWriter.writeDataSet(stream, data, source.getName());
|
||||||
|
|
||||||
@ -85,11 +82,9 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean toPrint(NMPoint point) throws ContentException {
|
private boolean toPrint(NMPoint point, Meta meta) throws ContentException {
|
||||||
Meta root = this.meta();
|
if (meta.hasNode("print")) {
|
||||||
|
List<? extends Meta> cfg = meta.getNodes("print");
|
||||||
if (root.hasNode("print")) {
|
|
||||||
List<? extends Meta> cfg = meta().getNodes("print");
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
for (Meta e : cfg) {
|
for (Meta e : cfg) {
|
||||||
double from = e.getDouble("from", 0);
|
double from = e.getDouble("from", 0);
|
||||||
@ -98,15 +93,13 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return root.getBoolean("print", false);
|
return meta.getBoolean("print", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean toShow(NMPoint point) throws ContentException {
|
private boolean toShow(NMPoint point, Meta meta) throws ContentException {
|
||||||
Meta root = this.meta();
|
if (meta.hasNode("show")) {
|
||||||
|
List<? extends Meta> cfg = meta.getNodes("show");
|
||||||
if (root.hasNode("show")) {
|
|
||||||
List<? extends Meta> cfg = meta().getNodes("show");
|
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
for (Meta e : cfg) {
|
for (Meta e : cfg) {
|
||||||
double from = e.getDouble("from", 0);
|
double from = e.getDouble("from", 0);
|
||||||
@ -115,7 +108,7 @@ public class ShowSpectrumAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return root.getBoolean("show", false);
|
return meta.getBoolean("show", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import hep.dataforge.description.TypedActionDef;
|
|||||||
import hep.dataforge.exceptions.ContentException;
|
import hep.dataforge.exceptions.ContentException;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.io.log.Logable;
|
import hep.dataforge.io.log.Logable;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import inr.numass.data.NMFile;
|
import inr.numass.data.NMFile;
|
||||||
import inr.numass.data.RawNMPoint;
|
import inr.numass.data.RawNMPoint;
|
||||||
@ -39,22 +40,18 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
|
|
||||||
public static final String name = "slicing";
|
public static final String name = "slicing";
|
||||||
|
|
||||||
public SlicingAction(Context context, Meta an) {
|
|
||||||
super(context, an);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Logable log, String name, Meta reader, NMFile source) throws ContentException {
|
protected NMFile execute(Context context, Logable log, String name, Laminate meta, NMFile source) throws ContentException {
|
||||||
boolean normalize;
|
boolean normalize;
|
||||||
Map<String, Pair<Integer, Integer>> slicingConfig;
|
Map<String, Pair<Integer, Integer>> slicingConfig;
|
||||||
|
|
||||||
LinkedHashMap<String, Pair<Integer, Integer>> res = new LinkedHashMap<>();
|
LinkedHashMap<String, Pair<Integer, Integer>> res = new LinkedHashMap<>();
|
||||||
List<? extends Meta> list = meta().getNode("sliceconfig").getNodes("slicepoint");
|
List<? extends Meta> list = meta.getNode("sliceconfig").getNodes("slicepoint");
|
||||||
|
|
||||||
for (Meta slice : list) {
|
for (Meta slice : list) {
|
||||||
String title = slice.getString("title", slice.getName());
|
String title = slice.getString("title", slice.getName());
|
||||||
@ -64,7 +61,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
}
|
}
|
||||||
slicingConfig = res;
|
slicingConfig = res;
|
||||||
|
|
||||||
normalize = meta().getBoolean("normalize", false);
|
normalize = meta.getBoolean("normalize", false);
|
||||||
|
|
||||||
if (slicingConfig == null) {
|
if (slicingConfig == null) {
|
||||||
throw new RuntimeException("Slice configuration not defined");
|
throw new RuntimeException("Slice configuration not defined");
|
||||||
@ -73,7 +70,7 @@ public class SlicingAction extends OneToOneAction<NMFile, NMFile> {
|
|||||||
|
|
||||||
SlicedData sData = new SlicedData(source, slicingConfig, normalize);
|
SlicedData sData = new SlicedData(source, slicingConfig, normalize);
|
||||||
|
|
||||||
OutputStream stream = buildActionOutput(name);
|
OutputStream stream = buildActionOutput(context, name);
|
||||||
|
|
||||||
ColumnedDataWriter.writeDataSet(stream, sData, null);
|
ColumnedDataWriter.writeDataSet(stream, sData, null);
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package inr.numass.actions;
|
|||||||
import hep.dataforge.actions.ManyToOneAction;
|
import hep.dataforge.actions.ManyToOneAction;
|
||||||
import hep.dataforge.actions.GroupBuilder;
|
import hep.dataforge.actions.GroupBuilder;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.data.Data;
|
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.points.Format;
|
import hep.dataforge.points.Format;
|
||||||
import hep.dataforge.points.DataPoint;
|
import hep.dataforge.points.DataPoint;
|
||||||
@ -34,8 +33,7 @@ import java.io.OutputStream;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import hep.dataforge.points.PointSet;
|
import hep.dataforge.points.PointSet;
|
||||||
import java.util.function.Consumer;
|
import java.util.Map;
|
||||||
import javafx.util.Pair;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -46,17 +44,13 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
|
|
||||||
public static final String SUMMARY_NAME = "sumName";
|
public static final String SUMMARY_NAME = "sumName";
|
||||||
|
|
||||||
public SummaryAction(Context context, Meta annotation) {
|
|
||||||
super(context, annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected List<DataNode<PointSet>> buildGroups(DataNode input) {
|
protected List<DataNode<PointSet>> buildGroups(Context context, DataNode input, Meta actionMeta) {
|
||||||
Meta meta = inputMeta(input.meta());
|
Meta meta = inputMeta(context, input.meta(), actionMeta);
|
||||||
List<DataNode<PointSet>> groups;
|
List<DataNode<PointSet>> groups;
|
||||||
if (meta.hasValue("grouping.byValue")) {
|
if (meta.hasValue("grouping.byValue")) {
|
||||||
groups = super.buildGroups(input);
|
groups = super.buildGroups(context, input, actionMeta);
|
||||||
} else {
|
} else {
|
||||||
groups = GroupBuilder.byValue(SUMMARY_NAME, meta.getString(SUMMARY_NAME, "summary")).group(input);
|
groups = GroupBuilder.byValue(SUMMARY_NAME, meta.getString(SUMMARY_NAME, "summary")).group(input);
|
||||||
}
|
}
|
||||||
@ -64,8 +58,8 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PointSet execute(Logable log, DataNode<FitState> input) {
|
protected PointSet execute(Context context, Logable log, String nodeName, Map<String, FitState> input, Meta meta) {
|
||||||
String[] parNames = meta().getStringArray("parnames");
|
String[] parNames = meta.getStringArray("parnames");
|
||||||
String[] names = new String[2 * parNames.length + 2];
|
String[] names = new String[2 * parNames.length + 2];
|
||||||
names[0] = "file";
|
names[0] = "file";
|
||||||
for (int i = 0; i < parNames.length; i++) {
|
for (int i = 0; i < parNames.length; i++) {
|
||||||
@ -81,25 +75,22 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
double[] av = new double[parNames.length];
|
double[] av = new double[parNames.length];
|
||||||
Arrays.fill(av, 0);
|
Arrays.fill(av, 0);
|
||||||
|
|
||||||
input.stream().forEach(new Consumer<Pair<String, Data<? extends FitState>>>() {
|
input.forEach((String key, FitState value) -> {
|
||||||
@Override
|
FitState state = value;
|
||||||
public void accept(Pair<String, Data<? extends FitState>> item) {
|
Value[] values = new Value[names.length];
|
||||||
FitState state = item.getValue().get();
|
values[0] = Value.of(key);
|
||||||
Value[] values = new Value[names.length];
|
for (int i = 0; i < parNames.length; i++) {
|
||||||
values[0] = Value.of(item.getKey());
|
Value val = Value.of(state.getParameters().getValue(parNames[i]));
|
||||||
for (int i = 0; i < parNames.length; i++) {
|
values[2 * i + 1] = val;
|
||||||
Value val = Value.of(state.getParameters().getValue(parNames[i]));
|
Value err = Value.of(state.getParameters().getError(parNames[i]));
|
||||||
values[2 * i + 1] = val;
|
values[2 * i + 2] = err;
|
||||||
Value err = Value.of(state.getParameters().getError(parNames[i]));
|
double weight = 1 / err.doubleValue() / err.doubleValue();
|
||||||
values[2 * i + 2] = err;
|
av[i] += val.doubleValue() * weight;
|
||||||
double weight = 1 / err.doubleValue() / err.doubleValue();
|
weights[i] += weight;
|
||||||
av[i] += val.doubleValue() * weight;
|
|
||||||
weights[i] += weight;
|
|
||||||
}
|
|
||||||
values[values.length - 1] = Value.of(state.getChi2());
|
|
||||||
DataPoint point = new MapPoint(names, values);
|
|
||||||
res.add(point);
|
|
||||||
}
|
}
|
||||||
|
values[values.length - 1] = Value.of(state.getChi2());
|
||||||
|
DataPoint point = new MapPoint(names, values);
|
||||||
|
res.add(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
Value[] averageValues = new Value[names.length];
|
Value[] averageValues = new Value[names.length];
|
||||||
@ -117,11 +108,11 @@ public class SummaryAction extends ManyToOneAction<FitState, PointSet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterGroup(Logable log, String groupName, Meta outputMeta, PointSet output) {
|
protected void afterGroup(Context context, Logable log, String groupName, Meta outputMeta, PointSet output) {
|
||||||
OutputStream stream = buildActionOutput(groupName);
|
OutputStream stream = buildActionOutput(context, groupName);
|
||||||
ColumnedDataWriter.writeDataSet(stream, output, groupName);
|
ColumnedDataWriter.writeDataSet(stream, output, groupName);
|
||||||
|
|
||||||
super.afterGroup(log, groupName, outputMeta, output);
|
super.afterGroup(context, log, groupName, outputMeta, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,12 @@ public class ResolutionFunction implements BivariateFunction {
|
|||||||
|
|
||||||
return (double x, double y) -> f.value(x - y);
|
return (double x, double y) -> f.value(x - y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BivariateFunction getConstantTail(){
|
public static BivariateFunction getAngledTail(double dropPerKv) {
|
||||||
|
return (double E, double U) -> 1 - (E - U) * dropPerKv/1000d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BivariateFunction getConstantTail() {
|
||||||
return new ConstantTailFunction();
|
return new ConstantTailFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.models;
|
package inr.numass.models;
|
||||||
|
|
||||||
import hep.dataforge.actions.RunManager;
|
import hep.dataforge.actions.ActionUtils;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
import hep.dataforge.io.ColumnedDataReader;
|
import hep.dataforge.io.ColumnedDataReader;
|
||||||
@ -48,7 +48,7 @@ public class TransmissionInterpolator implements UnivariateFunction {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation,
|
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation,
|
||||||
String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
|
String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
|
||||||
DataNode<PointSet> node = RunManager.executeAction(context, actionAnnotation);
|
DataNode<PointSet> node = ActionUtils.runConfig(context, actionAnnotation);
|
||||||
PointSet data = node.getData().get();
|
PointSet data = node.getData().get();
|
||||||
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
|
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import de.jensd.shichimifx.utils.ConsoleDude;
|
|||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.actions.ActionManager;
|
import hep.dataforge.actions.ActionManager;
|
||||||
import hep.dataforge.actions.ActionStateListener;
|
import hep.dataforge.actions.ActionStateListener;
|
||||||
import hep.dataforge.actions.RunManager;
|
import hep.dataforge.actions.ActionUtils;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.context.GlobalContext;
|
import hep.dataforge.context.GlobalContext;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
||||||
@ -147,7 +147,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public StagePane getStagePane(String stage) {
|
public synchronized StagePane getStagePane(String stage) {
|
||||||
if (!stages.containsKey(stage)) {
|
if (!stages.containsKey(stage)) {
|
||||||
Tab stageTab = new Tab(stage);
|
Tab stageTab = new Tab(stage);
|
||||||
StagePane stageTabPane = new StagePane();
|
StagePane stageTabPane = new StagePane();
|
||||||
@ -171,9 +171,9 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
private void buildContextPane() {
|
private void buildContextPane() {
|
||||||
Configuration contextValues = new Configuration("context");
|
Configuration contextValues = new Configuration("context");
|
||||||
//TODO add asMeta method to Context and replace map here
|
//TODO add asMeta method to Context and replace map here
|
||||||
for (Map.Entry<String, Value> item : context.getProperties().entrySet()) {
|
context.getProperties().entrySet().stream().forEach((item) -> {
|
||||||
contextValues.setValue(item.getKey(), item.getValue());
|
contextValues.setValue(item.getKey(), item.getValue());
|
||||||
}
|
});
|
||||||
|
|
||||||
contextValues.addObserver(new ConfigChangeListener() {
|
contextValues.addObserver(new ConfigChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -310,9 +310,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
|||||||
//FIXME evaluate error here
|
//FIXME evaluate error here
|
||||||
throw new Error("Empty data");
|
throw new Error("Empty data");
|
||||||
}
|
}
|
||||||
Action action = RunManager.readAction(getContext(), getActionConfiguration());
|
ActionUtils.runAction(getContext(), data, getActionConfiguration()).compute();
|
||||||
// action.addListener(this);
|
|
||||||
action.run(data).compute();
|
|
||||||
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
||||||
}, "actions").start();
|
}, "actions").start();
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,20 @@ public class StagePane extends TabPane implements Named {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void closeAll() {
|
public void closeAll() {
|
||||||
for (OutputTab tab : tabs.values()) {
|
tabs.values().stream().map((tab) -> {
|
||||||
tab.close();
|
tab.close();
|
||||||
|
return tab;
|
||||||
|
}).forEach((tab) -> {
|
||||||
Platform.runLater(() -> getTabs().remove(tab));
|
Platform.runLater(() -> getTabs().remove(tab));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeTab(String name) {
|
public synchronized void closeTab(String name) {
|
||||||
tabs.get(name).close();
|
tabs.get(name).close();
|
||||||
Platform.runLater(() -> getTabs().remove(tabs.get(name)));
|
Platform.runLater(() -> getTabs().remove(tabs.get(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextOutputTab buildTextOutput(String name) {
|
public synchronized TextOutputTab buildTextOutput(String name) {
|
||||||
if (tabs.containsKey(name)) {
|
if (tabs.containsKey(name)) {
|
||||||
closeTab(name);
|
closeTab(name);
|
||||||
}
|
}
|
||||||
@ -49,7 +51,7 @@ public class StagePane extends TabPane implements Named {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotFrame buildPlotOutput(String name, Meta meta) {
|
public synchronized PlotFrame buildPlotOutput(String name, Meta meta) {
|
||||||
if (tabs.containsKey(name)) {
|
if (tabs.containsKey(name)) {
|
||||||
closeTab(name);
|
closeTab(name);
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,18 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass.workbench;
|
package inr.numass.workbench;
|
||||||
|
|
||||||
import hep.dataforge.fx.DataOutputPane;
|
import hep.dataforge.fx.FXDataOutputPane;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A text output tab. Basically it is attached to IOManager::out
|
* A text output tab. Basically it is attached to IOManager::out
|
||||||
|
*
|
||||||
* @author Alexander Nozik <altavir@gmail.com>
|
* @author Alexander Nozik <altavir@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class TextOutputTab extends OutputTab {
|
public class TextOutputTab extends OutputTab {
|
||||||
|
|
||||||
private final DataOutputPane out;
|
private final FXDataOutputPane out;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new stream output tab
|
* Create new stream output tab
|
||||||
@ -26,7 +27,8 @@ public class TextOutputTab extends OutputTab {
|
|||||||
*/
|
*/
|
||||||
public TextOutputTab(String name) {
|
public TextOutputTab(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
out = new DataOutputPane();
|
// out = new DataOutputPane();
|
||||||
|
out = new FXDataOutputPane();
|
||||||
setContent(out);
|
setContent(out);
|
||||||
setOnClosed((Event event) -> close());
|
setOnClosed((Event event) -> close());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user