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

View File

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

View File

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

View File

@ -5,12 +5,13 @@ import hep.dataforge.context.Global
import hep.dataforge.grind.Grind import hep.dataforge.grind.Grind
import hep.dataforge.grind.GrindShell import hep.dataforge.grind.GrindShell
import hep.dataforge.grind.helpers.PlotHelper import hep.dataforge.grind.helpers.PlotHelper
import hep.dataforge.meta.Meta
import hep.dataforge.plots.fx.FXPlotManager import hep.dataforge.plots.fx.FXPlotManager
import hep.dataforge.stat.fit.ParamSet import hep.dataforge.stat.fit.ParamSet
import hep.dataforge.utils.MetaMorph import hep.dataforge.utils.MetaMorph
import hep.dataforge.values.Values
import inr.numass.NumassPlugin 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() Context ctx = Global.instance()
ctx.pluginManager().load(FXPlotManager) ctx.pluginManager().load(FXPlotManager)
@ -18,29 +19,40 @@ ctx.pluginManager().load(NumassPlugin.class)
new GrindShell(ctx).eval { new GrindShell(ctx).eval {
SterileNeutrinoSpectrum sp1 = new SterileNeutrinoSpectrum(context, Meta.empty()); def fssStream = getClass().getResourceAsStream("/data/FS.txt")
SterileNeutrinoSpectrum sp2 = new SterileNeutrinoSpectrum(context, Grind.buildMeta(useFSS: false)); def fss = new FSS(fssStream)
def beta = new NumassBeta();
def params = MetaMorph.morph(ParamSet, def params = MetaMorph.morph(ParamSet,
Grind.buildMeta("params") { Grind.buildMeta("params") {
N(value: 6e5, err: 1e5, lower: 0)
bkg(value: 2, err: 0.1)
E0(value: 18575, err: 0.1) E0(value: 18575, err: 0.1)
mnu2(value: 0, err: 0.01) mnu2(value: 0, err: 0.01)
msterile2(value: 1000**2, err: 1) msterile2(value: 1000**2, err: 1)
U2(value: 0, err: 1e-3) U2(value: 0, err: 1e-3)
X(value: 0, err: 0.01, lower: 0)
trap(value: 0, err: 0.05)
} }
) )
def fsBeta = { double eIn, Values set ->
def xs = (1..400).collect{18000 + it*2} double res = 0;
for (int i = 0; i < fss.size(); i++) {
def sp1Points = xs.collect { sp1.value(it, params) } res += fss.getP(i) * beta.value(fss.getE(i), eIn, set);
def sp2Points = xs.collect { sp2.value(it, params) } }
return res;
};
(plots as PlotHelper).plot(xs,sp1Points,"FSS") def xs = (1..400).collect{18500 + it/4}
(plots as PlotHelper).plot(xs,sp2Points,"noFSS")
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 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. * Created by darksnake on 11-Aug-16.
*/ */
FileBasedWorkspace.build(Paths.get("D:/Work/Numass/sterile2016/workspace.groovy")).runTask("numass.prepare", "fill_2").computeAll()
new GrindWorkspaceBuilder().read {
new File("D:\\Work\\Numass\\sterile2016\\workspace.groovy")
}.runTask("numass.prepare", "fill_2").computeAll()