Made ActionManager optional. ActionUtils searches all plugins for exported actions.
This commit is contained in:
parent
237ad3b6c3
commit
0a261ad466
@ -81,9 +81,9 @@ ListTable data = readData("c:\\Users\\Darksnake\\Dropbox\\PlayGround\\RUN23.DAT"
|
|||||||
|
|
||||||
FitState state = new FitState(data, model, allPars);
|
FitState state = new FitState(data, model, allPars);
|
||||||
|
|
||||||
FitState res = fm.runDefaultTask(state, "E0", "N", "bkg");
|
FitState res = fm.runDefaultStage(state, "E0", "N", "bkg");
|
||||||
|
|
||||||
res = fm.runDefaultTask(res, "E0", "N", "bkg", "mnu2");
|
res = fm.runDefaultStage(res, "E0", "N", "bkg", "mnu2");
|
||||||
|
|
||||||
res.print(out);
|
res.print(out);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ res.print(out);
|
|||||||
//
|
//
|
||||||
//// fm.setPriorProb(new GaussianPrior("X", 0.47, 0.47*0.03));
|
//// fm.setPriorProb(new GaussianPrior("X", 0.47, 0.47*0.03));
|
||||||
//// fm.setPriorProb(new MultivariateGaussianPrior(allPars.getSubSet("X","trap")));
|
//// fm.setPriorProb(new MultivariateGaussianPrior(allPars.getSubSet("X","trap")));
|
||||||
//res = fm.runTask(res, "MINUIT", "run", "E0", "N", "bkg", "mnu2");
|
//res = fm.runStage(res, "MINUIT", "run", "E0", "N", "bkg", "mnu2");
|
||||||
////
|
////
|
||||||
//res.print(onComplete);
|
//res.print(onComplete);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package inr.numass.scripts
|
|||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.grind.Grind
|
import hep.dataforge.grind.Grind
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.stat.fit.FitPlugin
|
import hep.dataforge.stat.fit.FitManager
|
||||||
import hep.dataforge.stat.fit.ParamSet
|
import hep.dataforge.stat.fit.ParamSet
|
||||||
import hep.dataforge.stat.models.XYModel
|
import hep.dataforge.stat.models.XYModel
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
@ -17,7 +17,7 @@ Locale.setDefault(Locale.US);
|
|||||||
new NumassPlugin().startGlobal();
|
new NumassPlugin().startGlobal();
|
||||||
|
|
||||||
|
|
||||||
def fm = Global.instance().provide("fitting", FitPlugin.class).getFitManager();
|
def fm = Global.instance().provide("fitting", FitManager.class).getFitManager();
|
||||||
def mm = fm.modelManager
|
def mm = fm.modelManager
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ FitState state = new FitState(data, model, allPars);
|
|||||||
//new PlotFitResultAction().eval(state);
|
//new PlotFitResultAction().eval(state);
|
||||||
|
|
||||||
|
|
||||||
FitState res = fm.runTask(state, "QOW", FitStage.TASK_RUN, "N", "bkg", "E0", "U2");
|
FitState res = fm.runStage(state, "QOW", FitStage.TASK_RUN, "N", "bkg", "E0", "U2");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ FittingIOUtils.printSpectrum(new PrintWriter(System.out), spectrum, allPars, 184
|
|||||||
//// allPars.setParValue("X", 0.4);
|
//// allPars.setParValue("X", 0.4);
|
||||||
// FitState state = FitTaskManager.buildState(data, model, allPars);
|
// FitState state = FitTaskManager.buildState(data, model, allPars);
|
||||||
//
|
//
|
||||||
// FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "pos", "sigma");
|
// FitState res = fm.runStage(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "pos", "sigma");
|
||||||
//
|
//
|
||||||
// res.print(onComplete());
|
// res.print(onComplete());
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ List<NMPoint> pileup = new ArrayList<>();
|
|||||||
lowerChannel = 400;
|
lowerChannel = 400;
|
||||||
upperChannel = 1800;
|
upperChannel = 1800;
|
||||||
|
|
||||||
PileUpSimulator buildSimulator(NMPoint point, double cr, NMPoint reference = null, boolean extrapolate = true, double scale = 1d) {
|
PileUpSimulator buildSimulator(NMPoint point, double cr, NMPoint reference = null, boolean extrapolate = false, double scale = 1d) {
|
||||||
def cfg = Grind.buildMeta(cr: cr) {
|
def cfg = Grind.buildMeta(cr: cr) {
|
||||||
pulser(mean: 3450, sigma: 86.45, freq: 66.43)
|
pulser(mean: 3450, sigma: 86.45, freq: 66.43)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ FittingIOUtils.printSpectrum(Global.out(), spectrum, allPars, 14000, 18600.0, 40
|
|||||||
////new PlotFitResultAction().eval(state);
|
////new PlotFitResultAction().eval(state);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//FitState res = fm.runTask(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "E0", "U2", "trap");
|
//FitState res = fm.runStage(state, "QOW", FitTask.TASK_RUN, "N", "bkg", "E0", "U2", "trap");
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -95,7 +95,7 @@ FitState state = fm.buildState(data, model, allPars);
|
|||||||
// fm.checkDerivs();
|
// fm.checkDerivs();
|
||||||
// res.print(Out.onComplete);
|
// res.print(Out.onComplete);
|
||||||
// fm.checkFitDerivatives();
|
// fm.checkFitDerivatives();
|
||||||
FitState res = fm.runDefaultTask(state, "U2", "N", "trap");
|
FitState res = fm.runDefaultStage(state, "U2", "N", "trap");
|
||||||
|
|
||||||
res.print(out);
|
res.print(out);
|
||||||
|
|
||||||
|
@ -19,16 +19,13 @@ import hep.dataforge.actions.ActionManager;
|
|||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.context.Global;
|
import hep.dataforge.context.Global;
|
||||||
import hep.dataforge.description.ActionDescriptor;
|
import hep.dataforge.description.ActionDescriptor;
|
||||||
import hep.dataforge.description.DescriptorFormatter;
|
|
||||||
import hep.dataforge.description.DescriptorUtils;
|
import hep.dataforge.description.DescriptorUtils;
|
||||||
import hep.dataforge.description.TextDescriptorFormatter;
|
|
||||||
import hep.dataforge.exceptions.DescriptorException;
|
import hep.dataforge.exceptions.DescriptorException;
|
||||||
|
import hep.dataforge.io.markup.MarkupBuilder;
|
||||||
|
import hep.dataforge.io.markup.MarkupUtils;
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Darksnake
|
* @author Darksnake
|
||||||
*/
|
*/
|
||||||
public class Numass {
|
public class Numass {
|
||||||
@ -44,22 +41,30 @@ public class Numass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void printDescription(Context context, boolean allowANSI) throws DescriptorException {
|
public static void printDescription(Context context, boolean allowANSI) throws DescriptorException {
|
||||||
PrintWriter writer = new PrintWriter(context.io().out());
|
|
||||||
|
|
||||||
DescriptorFormatter formatter = new TextDescriptorFormatter(writer, allowANSI);
|
MarkupBuilder builder = new MarkupBuilder()
|
||||||
writer.println("***Data description***");
|
.addText("***Data description***", "red")
|
||||||
writer.print(" ");
|
.ln()
|
||||||
formatter.showDescription(
|
.addText("\t")
|
||||||
DescriptorUtils.buildDescriptor(
|
.addContent(
|
||||||
DescriptorUtils.findAnnotatedElement("method::hep.dataforge.data.DataManager.read")
|
MarkupUtils.markupDescriptor(DescriptorUtils.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
||||||
));
|
)
|
||||||
writer.println("***Allowed actions***");
|
.ln()
|
||||||
|
.addText("***Allowed actions***", "red")
|
||||||
|
.ln();
|
||||||
|
|
||||||
|
|
||||||
|
for (ActionDescriptor descriptor : context.getPlugin(ActionManager.class).list()) {
|
||||||
|
builder
|
||||||
|
.addText("\t")
|
||||||
|
.addContent(
|
||||||
|
MarkupUtils.markupDescriptor(descriptor)
|
||||||
|
);
|
||||||
|
|
||||||
for (ActionDescriptor descriptor : ActionManager.buildFrom(context).list()) {
|
|
||||||
writer.print(" ");
|
|
||||||
formatter.showDescription(descriptor);
|
|
||||||
}
|
}
|
||||||
writer.println("***End of actions list***");
|
builder.addText("***End of actions list***", "red");
|
||||||
writer.flush();
|
|
||||||
|
|
||||||
|
context.io().getMarkupRenderer().render(builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import hep.dataforge.plots.fx.FXPlotUtils;
|
|||||||
import hep.dataforge.plots.fx.PlotContainer;
|
import hep.dataforge.plots.fx.PlotContainer;
|
||||||
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
import hep.dataforge.plots.jfreechart.JFreeChartFrame;
|
||||||
import hep.dataforge.stat.fit.FitManager;
|
import hep.dataforge.stat.fit.FitManager;
|
||||||
import hep.dataforge.stat.fit.FitPlugin;
|
|
||||||
import hep.dataforge.stat.models.ModelManager;
|
import hep.dataforge.stat.models.ModelManager;
|
||||||
import hep.dataforge.stat.models.WeightedXYModel;
|
import hep.dataforge.stat.models.WeightedXYModel;
|
||||||
import hep.dataforge.stat.models.XYModel;
|
import hep.dataforge.stat.models.XYModel;
|
||||||
@ -74,11 +73,13 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
// StorageManager.buildFrom(context);
|
// StorageManager.buildFrom(context);
|
||||||
super.attach(context);
|
super.attach(context);
|
||||||
context.setIO(new NumassIO());
|
context.setIO(new NumassIO());
|
||||||
FitManager fm = context.provide("fitting", FitPlugin.class).getFitManager();
|
FitManager fm = context.provide("fitting", FitManager.class);
|
||||||
loadModels(fm.getModelManager());
|
loadModels(fm.getModelManager());
|
||||||
loadMath(MathPlugin.buildFrom(context));
|
loadMath(MathPlugin.buildFrom(context));
|
||||||
|
|
||||||
ActionManager actions = ActionManager.buildFrom(context);
|
ActionManager actions = new ActionManager();
|
||||||
|
actions.attach(context);
|
||||||
|
|
||||||
actions.register(SlicingAction.class);
|
actions.register(SlicingAction.class);
|
||||||
actions.register(PrepareDataAction.class);
|
actions.register(PrepareDataAction.class);
|
||||||
actions.register(ReadLegacyDataAction.class);
|
actions.register(ReadLegacyDataAction.class);
|
||||||
@ -88,7 +89,6 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
actions.register(SummaryAction.class);
|
actions.register(SummaryAction.class);
|
||||||
actions.register(PlotDataAction.class);
|
actions.register(PlotDataAction.class);
|
||||||
actions.register(PlotFitResultAction.class);
|
actions.register(PlotFitResultAction.class);
|
||||||
actions.register(ShowLossSpectrumAction.class);
|
|
||||||
actions.register(AdjustErrorsAction.class);
|
actions.register(AdjustErrorsAction.class);
|
||||||
actions.register(ShowEnergySpectrumAction.class);
|
actions.register(ShowEnergySpectrumAction.class);
|
||||||
actions.register(SubstractSpectrumAction.class);
|
actions.register(SubstractSpectrumAction.class);
|
||||||
@ -124,16 +124,16 @@ public class NumassPlugin extends BasicPlugin {
|
|||||||
*/
|
*/
|
||||||
private void loadModels(ModelManager manager) {
|
private void loadModels(ModelManager manager) {
|
||||||
|
|
||||||
manager.addModel("modularbeta", (context, an) -> {
|
// manager.addModel("modularbeta", (context, an) -> {
|
||||||
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
|
// double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
|
||||||
double from = an.getDouble("from", 14400d);
|
// double from = an.getDouble("from", 14400d);
|
||||||
double to = an.getDouble("to", 19010d);
|
// double to = an.getDouble("to", 19010d);
|
||||||
RangedNamedSetSpectrum beta = new BetaSpectrum(getClass().getResourceAsStream("/data/FS.txt"));
|
// RangedNamedSetSpectrum beta = new BetaSpectrum(getClass().getResourceAsStream("/data/FS.txt"));
|
||||||
ModularSpectrum sp = new ModularSpectrum(beta, A, from, to);
|
// ModularSpectrum sp = new ModularSpectrum(beta, A, from, to);
|
||||||
NBkgSpectrum spectrum = new NBkgSpectrum(sp);
|
// NBkgSpectrum spectrum = new NBkgSpectrum(sp);
|
||||||
|
//
|
||||||
return new XYModel(spectrum, getAdapter(an));
|
// return new XYModel(spectrum, getAdapter(an));
|
||||||
});
|
// });
|
||||||
|
|
||||||
manager.addModel("scatter", (context, an) -> {
|
manager.addModel("scatter", (context, an) -> {
|
||||||
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
|
double A = an.getDouble("resolution", 8.3e-5);//8.3e-5
|
||||||
|
@ -62,6 +62,7 @@ public class TestModels {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private static ParametricFunction oldModel(Context context, Meta meta) {
|
private static ParametricFunction oldModel(Context context, Meta meta) {
|
||||||
double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5
|
double A = meta.getDouble("resolution", meta.getDouble("resolution.width", 8.3e-5));//8.3e-5
|
||||||
double from = meta.getDouble("from", 13900d);
|
double from = meta.getDouble("from", 13900d);
|
||||||
|
@ -52,11 +52,11 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
//do fit
|
//do fit
|
||||||
|
|
||||||
Meta fitConfig = config.getMeta("fit");
|
Meta fitConfig = config.getMeta("fit");
|
||||||
sourceNode.forEachDataWithType(Table.class, d -> {
|
sourceNode.dataStream().forEach(table -> {
|
||||||
for (int i = 0; i < scanValues.listValue().size(); i++) {
|
for (int i = 0; i < scanValues.listValue().size(); i++) {
|
||||||
Value val = scanValues.listValue().get(i);
|
Value val = scanValues.listValue().get(i);
|
||||||
MetaBuilder overrideMeta = new MetaBuilder(fitConfig);
|
MetaBuilder overrideMeta = new MetaBuilder(fitConfig);
|
||||||
overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", d.getName(), scanParameter, val.stringValue()));
|
overrideMeta.setValue("@resultName", String.format("%s[%s=%s]", table.getName(), scanParameter, val.stringValue()));
|
||||||
|
|
||||||
if (overrideMeta.hasMeta("params." + scanParameter)) {
|
if (overrideMeta.hasMeta("params." + scanParameter)) {
|
||||||
overrideMeta.setValue("params." + scanParameter + ".value", val);
|
overrideMeta.setValue("params." + scanParameter + ".value", val);
|
||||||
@ -65,8 +65,8 @@ public class NumassFitScanTask extends AbstractTask<FitState> {
|
|||||||
.filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val));
|
.filter(par -> par.getString("name") == scanParameter).forEach(par -> par.setValue("value", val));
|
||||||
}
|
}
|
||||||
// Data<Table> newData = new Data<Table>(data.getGoal(),data.type(),overrideMeta);
|
// Data<Table> newData = new Data<Table>(data.getGoal(),data.type(),overrideMeta);
|
||||||
DataNode node = action.run(model.getContext(), DataNode.of("fit_" + i, d, Meta.empty()), overrideMeta);
|
DataNode<FitState> node = action.run(model.getContext(), DataNode.of("fit_" + i, table, Meta.empty()), overrideMeta);
|
||||||
resultBuilder.putData(d.getName() + ".fit_" + i, node.getData());
|
resultBuilder.putData(table.getName() + ".fit_" + i, node.getData());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class PileUpSimulator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean nextEventRegistered(short prevChanel, double delay) {
|
private boolean nextEventRegistered(short prevChanel, double delay) {
|
||||||
double average = 6.76102 - 4.31897E-4 * prevChanel + 7.88429E-8 * prevChanel * prevChanel;
|
double average = 6.76102 - 4.31897E-4 * prevChanel + 7.88429E-8 * prevChanel * prevChanel + 0.2;
|
||||||
double prob = 1d - 1d / (1d + Math.pow(delay / average, 75.91));
|
double prob = 1d - 1d / (1d + Math.pow(delay / average, 75.91));
|
||||||
return random(prob);
|
return random(prob);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user