Dynamic workspaces instead workspace builders

This commit is contained in:
Alexander Nozik 2017-08-20 21:40:40 +03:00
parent 7655237a2c
commit 4ab0cac760
5 changed files with 44 additions and 45 deletions

View File

@ -1,8 +1,9 @@
package inr.numass
import hep.dataforge.context.Global
import hep.dataforge.grind.GrindWorkspaceBuilder
import hep.dataforge.grind.terminal.GrindTerminal
import hep.dataforge.workspace.FileBasedWorkspace
import hep.dataforge.workspace.Workspace
/**
* Created by darksnake on 29-Aug-16.
@ -13,7 +14,7 @@ def cli = new CliBuilder()
cli.c(longOpt: "config", args: 1, "The name of configuration file")
println cli.usage
String cfgPath = cli.parse(args).c;
def cfgPath = cli.parse(args).c;
println "Loading config file from $cfgPath"
println "Starting Grind shell"
@ -21,7 +22,7 @@ println "Starting Grind shell"
try {
GrindTerminal.system().launch {
if (cfgPath) {
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder(context).read(new File(cfgPath))
Workspace numass = FileBasedWorkspace.build(context, new File(cfgPath as String).toPath())
bind("numass", numass)
} else {
println "No configuration path. Provide path via --config option"

View File

@ -1,7 +1,7 @@
package inr.numass
import hep.dataforge.grind.GrindWorkspaceBuilder
import inr.numass.tasks.*
import hep.dataforge.workspace.FileBasedWorkspace
import hep.dataforge.workspace.Workspace
/**
* Created by darksnake on 18-Apr-17.
@ -10,14 +10,6 @@ import inr.numass.tasks.*
cfgPath = "D:\\Work\\Numass\\sterile2016_10\\workspace.groovy"
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder().read(new File(cfgPath)).startup {
it.loadTask(NumassPrepareTask)
it.loadTask(NumassTableFilterTask)
it.loadTask(NumassFitScanTask)
it.loadTask(NumassSubstractEmptySourceTask)
it.loadTask(NumassFitScanSummaryTask)
it.loadTask(NumassFitTask)
it.loadTask(NumassFitSummaryTask)
}
Workspace numass = FileBasedWorkspace.build(context, new File(cfgPath).toPath())
numass.scansum "fill_1"

View File

@ -1,23 +1,18 @@
package inr.numass.scripts
import hep.dataforge.grind.GrindWorkspaceBuilder
import hep.dataforge.tables.Table
import inr.numass.tasks.*
import hep.dataforge.workspace.FileBasedWorkspace
import hep.dataforge.workspace.Workspace
import java.nio.file.Paths
/**
* Created by darksnake on 26-Dec-16.
*/
GrindWorkspaceBuilder numass = new GrindWorkspaceBuilder().read(new File("D:\\Work\\Numass\\sterile2016_10\\workspace.groovy")).startup {
it.loadTask(NumassPrepareTask)
it.loadTask(NumassTableFilterTask)
it.loadTask(NumassFitScanTask)
it.loadTask(NumassSubstractEmptySourceTask)
it.loadTask(NumassFitScanSummaryTask)
it.loadTask(NumassFitTask)
it.loadTask(NumassFitSummaryTask)
}
Workspace numass = FileBasedWorkspace.build(Paths.get("D:/Work/Numass/sterile2016_10/workspace.groovy"))
numass.runTask("prepare", "fill_1_all").forEachDataWithType(Table) {
Table table = it.get();

View File

@ -5,12 +5,13 @@ import hep.dataforge.context.Global
import hep.dataforge.grind.Grind
import hep.dataforge.grind.GrindShell
import hep.dataforge.grind.helpers.PlotHelper
import hep.dataforge.meta.Meta
import hep.dataforge.plots.fx.FXPlotManager
import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.utils.MetaMorph
import hep.dataforge.values.Values
import inr.numass.NumassPlugin
import inr.numass.models.sterile.SterileNeutrinoSpectrum
import inr.numass.models.FSS
import inr.numass.models.sterile.NumassBeta
Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager)
@ -18,29 +19,40 @@ ctx.pluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval {
SterileNeutrinoSpectrum sp1 = new SterileNeutrinoSpectrum(context, Meta.empty());
SterileNeutrinoSpectrum sp2 = new SterileNeutrinoSpectrum(context, Grind.buildMeta(useFSS: false));
def fssStream = getClass().getResourceAsStream("/data/FS.txt")
def fss = new FSS(fssStream)
def beta = new NumassBeta();
def params = MetaMorph.morph(ParamSet,
Grind.buildMeta("params") {
N(value: 6e5, err: 1e5, lower: 0)
bkg(value: 2, err: 0.1)
E0(value: 18575, err: 0.1)
mnu2(value: 0, err: 0.01)
msterile2(value: 1000**2, err: 1)
U2(value: 0, err: 1e-3)
X(value: 0, err: 0.01, lower: 0)
trap(value: 0, err: 0.05)
}
)
def xs = (1..400).collect{18000 + it*2}
def sp1Points = xs.collect { sp1.value(it, params) }
def sp2Points = xs.collect { sp2.value(it, params) }
(plots as PlotHelper).plot(xs,sp1Points,"FSS")
(plots as PlotHelper).plot(xs,sp2Points,"noFSS")
def fsBeta = { double eIn, Values set ->
double res = 0;
for (int i = 0; i < fss.size(); i++) {
res += fss.getP(i) * beta.value(fss.getE(i), eIn, set);
}
return res;
};
def xs = (1..400).collect{18500 + it/4}
def noFssPoints = xs.collect { beta.value(0,it, params) }
def fssPoints = xs.collect { fsBeta(it, params) }
(plots as PlotHelper).plot(xs,fssPoints,"FSS")
(plots as PlotHelper).plot(xs,noFssPoints,"noFSS")
println "U\tFSS\tnoFSS"
for(i in 0..399){
println "${xs[i]}\t${fssPoints[i]}\t${noFssPoints[i]}"
}
}

View File

@ -1,13 +1,12 @@
package inr.numass.scripts.workspace
import hep.dataforge.grind.GrindWorkspaceBuilder
import hep.dataforge.workspace.FileBasedWorkspace
import java.nio.file.Paths
/**
* Created by darksnake on 11-Aug-16.
*/
new GrindWorkspaceBuilder().read {
new File("D:\\Work\\Numass\\sterile2016\\workspace.groovy")
}.runTask("numass.prepare", "fill_2").computeAll()
FileBasedWorkspace.build(Paths.get("D:/Work/Numass/sterile2016/workspace.groovy")).runTask("numass.prepare", "fill_2").computeAll()