Some fixes
This commit is contained in:
parent
45794a515d
commit
edef7762f3
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package inr.numass.data.analyzers
|
package inr.numass.data.analyzers
|
||||||
|
|
||||||
|
import hep.dataforge.description.ValueDef
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.values.ValueMap
|
import hep.dataforge.values.ValueMap
|
||||||
|
import hep.dataforge.values.ValueType
|
||||||
import hep.dataforge.values.Values
|
import hep.dataforge.values.Values
|
||||||
import inr.numass.data.api.NumassBlock
|
import inr.numass.data.api.NumassBlock
|
||||||
import inr.numass.data.api.SignalProcessor
|
import inr.numass.data.api.SignalProcessor
|
||||||
@ -26,15 +28,25 @@ import inr.numass.data.api.SignalProcessor
|
|||||||
* A simple event counter
|
* A simple event counter
|
||||||
* Created by darksnake on 07.07.2017.
|
* 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) {
|
class SimpleAnalyzer @JvmOverloads constructor(private val processor: SignalProcessor? = null) : AbstractAnalyzer(processor) {
|
||||||
|
|
||||||
|
|
||||||
override fun analyze(block: NumassBlock, config: Meta): Values {
|
override fun analyze(block: NumassBlock, config: Meta): Values {
|
||||||
val loChannel = config.getInt("window.lo", 0)
|
val loChannel = config.getInt("window.lo", 0)
|
||||||
val upChannel = config.getInt("window.up", Integer.MAX_VALUE)
|
val upChannel = config.getInt("window.up", Integer.MAX_VALUE)
|
||||||
|
|
||||||
val count = getEvents(block, config).count()
|
val count = getEvents(block, config).count()
|
||||||
val length = block.length.toNanos().toDouble() / 1e9
|
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
|
val countRateError = Math.sqrt(count.toDouble()) / length
|
||||||
|
|
||||||
return ValueMap.of(AbstractAnalyzer.NAME_LIST,
|
return ValueMap.of(AbstractAnalyzer.NAME_LIST,
|
||||||
|
@ -209,13 +209,13 @@ fun pointExpression(expression: String, point: Values): Double {
|
|||||||
fun JFreeChartFrame.addSetMarkers(sets: Collection<NumassSet>) {
|
fun JFreeChartFrame.addSetMarkers(sets: Collection<NumassSet>) {
|
||||||
val jfcPlot = chart.xyPlot
|
val jfcPlot = chart.xyPlot
|
||||||
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
|
val paint = Color(0.0f, 0.0f, 1.0f, 0.1f)
|
||||||
sets.stream().forEach {
|
sets.stream().forEach { set ->
|
||||||
val start = it.startTime;
|
val start = set.startTime;
|
||||||
val stop = it.meta.optValue("end_time").map { it.time }
|
val stop = set.meta.optValue("end_time").map { it.time }
|
||||||
.orElse(start.plusSeconds(300))
|
.orElse(start.plusSeconds(300))
|
||||||
.minusSeconds(60)
|
.minusSeconds(60)
|
||||||
val marker = IntervalMarker(start.toEpochMilli().toDouble(), stop.toEpochMilli().toDouble(), paint)
|
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.labelFont = Font("Verdana", Font.BOLD, 20);
|
||||||
marker.labelOffset = RectangleInsets(30.0, 30.0, 30.0, 30.0)
|
marker.labelOffset = RectangleInsets(30.0, 30.0, 30.0, 30.0)
|
||||||
runLater { jfcPlot.addDomainMarker(marker) }
|
runLater { jfcPlot.addDomainMarker(marker) }
|
||||||
|
@ -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!")
|
||||||
|
}
|
@ -52,7 +52,7 @@ fun main(args: Array<String>) {
|
|||||||
//def sets = (20..28).collect { "set_$it" }
|
//def sets = (20..28).collect { "set_$it" }
|
||||||
|
|
||||||
val loaders = sets.map { set ->
|
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 }
|
}.filter { it != null }
|
||||||
|
|
||||||
val joined = NumassDataUtils.join("sum", loaders)
|
val joined = NumassDataUtils.join("sum", loaders)
|
||||||
|
@ -170,14 +170,10 @@ val subtractEmptyTask = task("dif") {
|
|||||||
putNode("data", input.meta)
|
putNode("data", input.meta)
|
||||||
putNode("empty", empty.meta)
|
putNode("empty", empty.meta)
|
||||||
}
|
}
|
||||||
val res = DataUtils.combine(input, empty, Table::class.java, resMeta) { mergeData, emptyData ->
|
val res = DataUtils.combine(context, input, empty, Table::class.java, resMeta) { mergeData, emptyData ->
|
||||||
subtractSpectrum(mergeData, emptyData, context.logger)
|
val dif = subtractSpectrum(mergeData, emptyData, context.logger)
|
||||||
}
|
context.output["numass.merge", input.name + "_subtract"].render(NumassUtils.wrap(dif, resMeta))
|
||||||
|
dif
|
||||||
res.goal.onComplete { r, _ ->
|
|
||||||
if (r != null) {
|
|
||||||
context.output.get("numass.merge", input.name + "_subtract").render(NumassUtils.wrap(r, resMeta))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.putData(input.name, res)
|
builder.putData(input.name, res)
|
||||||
|
Loading…
Reference in New Issue
Block a user