Incomplete. Trying to implement one-to-many actions.
This commit is contained in:
parent
068b85c7eb
commit
b97ac722ed
@ -3,7 +3,7 @@ package inr.numass
|
|||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.grind.GrindWorkspaceBuilder
|
import hep.dataforge.grind.GrindWorkspaceBuilder
|
||||||
import hep.dataforge.grind.terminal.GrindTerminal
|
import hep.dataforge.grind.terminal.GrindTerminal
|
||||||
import inr.numass.workspace.*
|
import inr.numass.tasks.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by darksnake on 29-Aug-16.
|
* Created by darksnake on 29-Aug-16.
|
||||||
|
@ -2,7 +2,7 @@ package inr.numass.scripts
|
|||||||
|
|
||||||
import hep.dataforge.grind.GrindWorkspaceBuilder
|
import hep.dataforge.grind.GrindWorkspaceBuilder
|
||||||
import hep.dataforge.tables.Table
|
import hep.dataforge.tables.Table
|
||||||
import inr.numass.workspace.*
|
import inr.numass.tasks.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by darksnake on 26-Dec-16.
|
* Created by darksnake on 26-Dec-16.
|
||||||
|
@ -81,7 +81,7 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
ActionManager actions = ActionManager.buildFrom(context);
|
ActionManager actions = ActionManager.buildFrom(context);
|
||||||
actions.register(SlicingAction.class);
|
actions.register(SlicingAction.class);
|
||||||
actions.register(PrepareDataAction.class);
|
actions.register(PrepareDataAction.class);
|
||||||
actions.register(ReadNumassDataAction.class);
|
actions.register(ReadLegacyDataAction.class);
|
||||||
actions.register(MergeDataAction.class);
|
actions.register(MergeDataAction.class);
|
||||||
actions.register(FindBorderAction.class);
|
actions.register(FindBorderAction.class);
|
||||||
actions.register(MonitorCorrectAction.class);
|
actions.register(MonitorCorrectAction.class);
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package inr.numass.actions;
|
||||||
|
|
||||||
|
import hep.dataforge.actions.OneToOneAction;
|
||||||
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.description.TypedActionDef;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
|
import inr.numass.storage.NumassStorage;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO generalize and move to dataforge-stoage
|
||||||
|
* Create a Storage from given URI object
|
||||||
|
* Created by darksnake on 29-Jan-17.
|
||||||
|
*/
|
||||||
|
@TypedActionDef(name = "buildStorage", inputType = URI.class, outputType = NumassStorage.class)
|
||||||
|
public class BuildStorageAction extends OneToOneAction<URI, NumassStorage> {
|
||||||
|
@Override
|
||||||
|
protected NumassStorage execute(Context context, String name, URI input, Laminate inputMeta) {
|
||||||
|
return NumassStorage.buildNumassRoot(input, inputMeta.getBoolean("readOnly", true), inputMeta.getBoolean("monitor", false));
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ package inr.numass.actions;
|
|||||||
import hep.dataforge.actions.ManyToOneAction;
|
import hep.dataforge.actions.ManyToOneAction;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Laminate;
|
||||||
import inr.numass.storage.NMPoint;
|
import inr.numass.storage.NMPoint;
|
||||||
import inr.numass.storage.NumassData;
|
import inr.numass.storage.NumassData;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import java.util.stream.IntStream;
|
|||||||
public class JoinNumassDataAction extends ManyToOneAction<NumassData, NumassData> {
|
public class JoinNumassDataAction extends ManyToOneAction<NumassData, NumassData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NumassData execute(Context context, String nodeName, Map<String, NumassData> input, Meta meta) {
|
protected NumassData execute(Context context, String nodeName, Map<String, NumassData> input, Laminate meta) {
|
||||||
throw new UnsupportedOperationException("not implemented");
|
throw new UnsupportedOperationException("not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import hep.dataforge.data.DataNode;
|
|||||||
import hep.dataforge.description.NodeDef;
|
import hep.dataforge.description.NodeDef;
|
||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.tables.*;
|
import hep.dataforge.tables.*;
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public class MergeDataAction extends ManyToOneAction<Table, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Table execute(Context context, String nodeName, Map<String, Table> data, Meta meta) {
|
protected Table execute(Context context, String nodeName, Map<String, Table> data, Laminate meta) {
|
||||||
Table res = mergeDataSets(nodeName, data.values());
|
Table res = mergeDataSets(nodeName, data.values());
|
||||||
return new ListTable(res.getFormat(), TableTransform.sort(res, "Uset", true));
|
return new ListTable(res.getFormat(), TableTransform.sort(res, "Uset", true));
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import static inr.numass.NumassIO.getNumassData;
|
|||||||
def = "2.468555393226049", type = "NUMBER")
|
def = "2.468555393226049", type = "NUMBER")
|
||||||
@ValueDef(name = "noUset", info = "If 'true', then Uset = Uread")
|
@ValueDef(name = "noUset", info = "If 'true', then Uset = Uread")
|
||||||
@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<Binary, NMFile> {
|
public class ReadLegacyDataAction extends OneToOneAction<Binary, NMFile> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NMFile execute(Context context, String name, Binary source, Laminate meta) throws ContentException {
|
protected NMFile execute(Context context, String name, Binary source, Laminate meta) throws ContentException {
|
@ -0,0 +1,60 @@
|
|||||||
|
package inr.numass.actions;
|
||||||
|
|
||||||
|
import hep.dataforge.actions.OneToManyAction;
|
||||||
|
import hep.dataforge.context.Context;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
|
import hep.dataforge.meta.Meta;
|
||||||
|
import hep.dataforge.storage.api.Loader;
|
||||||
|
import inr.numass.debunch.DebunchReport;
|
||||||
|
import inr.numass.debunch.FrameAnalizer;
|
||||||
|
import inr.numass.storage.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by darksnake on 29-Jan-17.
|
||||||
|
*/
|
||||||
|
public class ReadStorageAction extends OneToManyAction<NumassStorage, NumassData> {
|
||||||
|
@Override
|
||||||
|
protected Map<String, Meta> prepareMeta(Context context, String inputName, Laminate meta) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected NumassData execute(Context context, String inputName, String outputName, NumassStorage input, Laminate meta) {
|
||||||
|
try(Loader loader = input.getLoader(outputName)) {
|
||||||
|
if (loader instanceof NumassDataLoader) {
|
||||||
|
NumassDataLoader nd = (NumassDataLoader) loader;
|
||||||
|
return buildData(context, nd, meta);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Numass loader expected");
|
||||||
|
}
|
||||||
|
} catch (Exception ex){
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private NumassData buildData(Context context, NumassDataLoader loader, Meta meta) {
|
||||||
|
if (meta.hasNode("debunch")) {
|
||||||
|
return loader.applyRawTransformation(rp -> debunch(context, rp, meta.getMeta("debunch")));
|
||||||
|
} else {
|
||||||
|
return loader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private NMPoint debunch(Context context, RawNMPoint point, Meta meta) {
|
||||||
|
int upper = meta.getInt("upperchanel", RawNMPoint.MAX_CHANEL);
|
||||||
|
int lower = meta.getInt("lowerchanel", 0);
|
||||||
|
double rejectionprob = meta.getDouble("rejectprob", 1e-10);
|
||||||
|
double framelength = meta.getDouble("framelength", 1);
|
||||||
|
double maxCR = meta.getDouble("maxcr", 500d);
|
||||||
|
|
||||||
|
double cr = point.selectChanels(lower, upper).getCR();
|
||||||
|
if (cr < maxCR) {
|
||||||
|
DebunchReport report = new FrameAnalizer(rejectionprob, framelength, lower, upper).debunchPoint(point);
|
||||||
|
return new NMPoint(report.getPoint());
|
||||||
|
} else {
|
||||||
|
return new NMPoint(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ import hep.dataforge.data.DataNode;
|
|||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.description.ValueDef;
|
import hep.dataforge.description.ValueDef;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitState;
|
||||||
import hep.dataforge.tables.*;
|
import hep.dataforge.tables.*;
|
||||||
@ -55,7 +56,7 @@ public class SummaryAction extends ManyToOneAction<FitState, Table> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Table execute(Context context,String nodeName, Map<String, FitState> input, Meta meta) {
|
protected Table execute(Context context, String nodeName, Map<String, FitState> input, Laminate meta) {
|
||||||
String[] parNames;
|
String[] parNames;
|
||||||
if (meta.hasValue("parnames")) {
|
if (meta.hasValue("parnames")) {
|
||||||
parNames = meta.getStringArray("parnames");
|
parNames = meta.getStringArray("parnames");
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.actions.ManyToOneAction;
|
import hep.dataforge.actions.ManyToOneAction;
|
||||||
@ -12,7 +12,7 @@ import hep.dataforge.data.DataNode;
|
|||||||
import hep.dataforge.data.DataSet;
|
import hep.dataforge.data.DataSet;
|
||||||
import hep.dataforge.description.TypedActionDef;
|
import hep.dataforge.description.TypedActionDef;
|
||||||
import hep.dataforge.io.ColumnedDataWriter;
|
import hep.dataforge.io.ColumnedDataWriter;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Laminate;
|
||||||
import hep.dataforge.stat.fit.FitState;
|
import hep.dataforge.stat.fit.FitState;
|
||||||
import hep.dataforge.stat.fit.ParamSet;
|
import hep.dataforge.stat.fit.ParamSet;
|
||||||
import hep.dataforge.stat.fit.UpperLimitGenerator;
|
import hep.dataforge.stat.fit.UpperLimitGenerator;
|
||||||
@ -57,7 +57,7 @@ public class NumassFitScanSummaryTask extends AbstractTask<Table> {
|
|||||||
private class FitSummaryAction extends ManyToOneAction<FitState, Table> {
|
private class FitSummaryAction extends ManyToOneAction<FitState, Table> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Table execute(Context context, String nodeName, Map<String, FitState> input, Meta meta) {
|
protected Table execute(Context context, String nodeName, Map<String, FitState> input, Laminate meta) {
|
||||||
ListTable.Builder builder = new ListTable.Builder("msterile2", "U2", "U2err", "U2limit", "E0", "trap");
|
ListTable.Builder builder = new ListTable.Builder("msterile2", "U2", "U2err", "U2limit", "E0", "trap");
|
||||||
input.forEach((key, fitRes) -> {
|
input.forEach((key, fitRes) -> {
|
||||||
ParamSet pars = fitRes.getParameters();
|
ParamSet pars = fitRes.getParameters();
|
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.actions.ActionUtils;
|
import hep.dataforge.actions.ActionUtils;
|
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.GenericAction;
|
import hep.dataforge.actions.GenericAction;
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.data.Data;
|
import hep.dataforge.data.Data;
|
||||||
import hep.dataforge.data.DataNode;
|
import hep.dataforge.data.DataNode;
|
@ -1,4 +1,4 @@
|
|||||||
package inr.numass.workspace;
|
package inr.numass.tasks;
|
||||||
|
|
||||||
import hep.dataforge.actions.Action;
|
import hep.dataforge.actions.Action;
|
||||||
import hep.dataforge.actions.OneToOneAction;
|
import hep.dataforge.actions.OneToOneAction;
|
Loading…
Reference in New Issue
Block a user