Some fixes

This commit is contained in:
Alexander Nozik 2018-10-29 16:50:56 +03:00
parent 45794a515d
commit edef7762f3
5 changed files with 58 additions and 14 deletions

View File

@ -16,8 +16,10 @@
package inr.numass.data.analyzers
import hep.dataforge.description.ValueDef
import hep.dataforge.meta.Meta
import hep.dataforge.values.ValueMap
import hep.dataforge.values.ValueType
import hep.dataforge.values.Values
import inr.numass.data.api.NumassBlock
import inr.numass.data.api.SignalProcessor
@ -26,15 +28,25 @@ import inr.numass.data.api.SignalProcessor
* A simple event counter
* Created by darksnake on 07.07.2017.
*/
@ValueDef(key = "deadTime", type = [ValueType.NUMBER], def = "0.0", info = "Dead time in nanoseconds for correction")
class SimpleAnalyzer @JvmOverloads constructor(private val processor: SignalProcessor? = null) : AbstractAnalyzer(processor) {
override fun analyze(block: NumassBlock, config: Meta): Values {
val loChannel = config.getInt("window.lo", 0)
val upChannel = config.getInt("window.up", Integer.MAX_VALUE)
val count = getEvents(block, config).count()
val length = block.length.toNanos().toDouble() / 1e9
val countRate = count.toDouble() / length
val deadTime = config.getDouble("deadTime", 0.0)
val countRate = if (deadTime > 0) {
val mu = count.toDouble() / length
mu / (1.0 - deadTime * 1e-9 * mu)
} else {
count.toDouble() / length
}
val countRateError = Math.sqrt(count.toDouble()) / length
return ValueMap.of(AbstractAnalyzer.NAME_LIST,

View File

@ -209,13 +209,13 @@ fun pointExpression(expression: String, point: Values): Double {
fun JFreeChartFrame.addSetMarkers(sets: Collection<NumassSet>) {
val jfcPlot = chart.xyPlot
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
sets.stream().forEach {
val start = it.startTime;
val stop = it.meta.optValue("end_time").map { it.time }
sets.stream().forEach { set ->
val start = set.startTime;
val stop = set.meta.optValue("end_time").map { it.time }
.orElse(start.plusSeconds(300))
.minusSeconds(60)
val marker = IntervalMarker(start.toEpochMilli().toDouble(), stop.toEpochMilli().toDouble(), paint)
marker.label = it.name
marker.label = set.name
marker.labelFont = Font("Verdana", Font.BOLD, 20);
marker.labelOffset = RectangleInsets(30.0, 30.0, 30.0, 30.0)
runLater { jfcPlot.addDomainMarker(marker) }

View File

@ -0,0 +1,36 @@
package inr.numass.scripts.analysis
import hep.dataforge.context.Global
import hep.dataforge.plots.plotData
import hep.dataforge.tables.Adapters
import hep.dataforge.tables.Table
import hep.dataforge.workspace.FileBasedWorkspace
import inr.numass.displayChart
import java.io.File
fun main(args: Array<String>) {
// val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) {
// output = FXOutputManager()
// rootDir = "D:\\Work\\Numass\\sterile2017_11"
// dataDir = "D:\\Work\\Numass\\data\\2017_11"
// properties {
// "cache.enabled" to false
// }
// }
val configPath = File("D:\\Work\\Numass\\sterile2017_11\\workspace.groovy").toPath()
val workspace = FileBasedWorkspace.build(Global, configPath)
workspace.context.setValue("cache.enabled", false)
val result = workspace.runTask("dif", "adiab_19").first().get() as Table
displayChart("Adiabacity").apply {
plotData("Adiabacity_19", result, Adapters.buildXYAdapter("voltage", "cr"))
}
println("Complete!")
}

View File

@ -52,7 +52,7 @@ fun main(args: Array<String>) {
//def sets = (20..28).collect { "set_$it" }
val loaders = sets.map { set ->
storage.provide("loader::$set", NumassSet::class.java).orElse(null)
storage.provide("$set", NumassSet::class.java).orElse(null)
}.filter { it != null }
val joined = NumassDataUtils.join("sum", loaders)

View File

@ -170,14 +170,10 @@ val subtractEmptyTask = task("dif") {
putNode("data", input.meta)
putNode("empty", empty.meta)
}
val res = DataUtils.combine(input, empty, Table::class.java, resMeta) { mergeData, emptyData ->
subtractSpectrum(mergeData, emptyData, context.logger)
}
res.goal.onComplete { r, _ ->
if (r != null) {
context.output.get("numass.merge", input.name + "_subtract").render(NumassUtils.wrap(r, resMeta))
}
val res = DataUtils.combine(context, input, empty, Table::class.java, resMeta) { mergeData, emptyData ->
val dif = subtractSpectrum(mergeData, emptyData, context.logger)
context.output["numass.merge", input.name + "_subtract"].render(NumassUtils.wrap(dif, resMeta))
dif
}
builder.putData(input.name, res)