Slicer for numass
This commit is contained in:
parent
1881c3419e
commit
12114ffab3
@ -41,11 +41,11 @@ import org.apache.commons.math3.util.FastMath
|
|||||||
* @author Alexander Nozik
|
* @author Alexander Nozik
|
||||||
*/
|
*/
|
||||||
@PluginDef(
|
@PluginDef(
|
||||||
group = "inr.numass",
|
group = "inr.numass",
|
||||||
name = "numass",
|
name = "numass",
|
||||||
dependsOn = ["hep.dataforge:functions", "hep.dataforge:MINUIT", "hep.dataforge:actions"],
|
dependsOn = ["hep.dataforge:functions", "hep.dataforge:MINUIT", "hep.dataforge:actions"],
|
||||||
support = false,
|
support = false,
|
||||||
info = "Numass data analysis tools"
|
info = "Numass data analysis tools"
|
||||||
)
|
)
|
||||||
class NumassPlugin : BasicPlugin() {
|
class NumassPlugin : BasicPlugin() {
|
||||||
|
|
||||||
@ -58,20 +58,21 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val tasks = listOf(
|
private val tasks = listOf(
|
||||||
NumassFitScanSummaryTask,
|
NumassFitScanSummaryTask,
|
||||||
NumassFitSummaryTask,
|
NumassFitSummaryTask,
|
||||||
selectTask,
|
selectTask,
|
||||||
analyzeTask,
|
analyzeTask,
|
||||||
mergeTask,
|
mergeTask,
|
||||||
mergeEmptyTask,
|
mergeEmptyTask,
|
||||||
monitorTableTask,
|
monitorTableTask,
|
||||||
subtractEmptyTask,
|
subtractEmptyTask,
|
||||||
transformTask,
|
transformTask,
|
||||||
filterTask,
|
filterTask,
|
||||||
fitTask,
|
fitTask,
|
||||||
plotFitTask,
|
plotFitTask,
|
||||||
histogramTask,
|
histogramTask,
|
||||||
fitScanTask
|
fitScanTask,
|
||||||
|
sliceTask
|
||||||
)
|
)
|
||||||
|
|
||||||
@Provides(Task.TASK_TARGET)
|
@Provides(Task.TASK_TARGET)
|
||||||
@ -109,7 +110,10 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
BivariateFunction { E: Double, U: Double ->
|
BivariateFunction { E: Double, U: Double ->
|
||||||
val D = E - U
|
val D = E - U
|
||||||
val factor = 7.33 - E / 1000.0 / 3.0
|
val factor = 7.33 - E / 1000.0 / 3.0
|
||||||
return@BivariateFunction 1.0 - (3.05346E-7 * D - 5.45738E-10 * Math.pow(D, 2.0) - 6.36105E-14 * Math.pow(D, 3.0)) * factor
|
return@BivariateFunction 1.0 - (3.05346E-7 * D - 5.45738E-10 * Math.pow(
|
||||||
|
D,
|
||||||
|
2.0
|
||||||
|
) - 6.36105E-14 * Math.pow(D, 3.0)) * factor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,11 +267,19 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
val transmissionFile = an.getString("transFile")
|
val transmissionFile = an.getString("transFile")
|
||||||
|
|
||||||
return TransmissionInterpolator
|
return TransmissionInterpolator
|
||||||
.fromFile(context, transmissionFile, transXName, transYName, nSmooth, w, stitchBorder)
|
.fromFile(context, transmissionFile, transXName, transYName, nSmooth, w, stitchBorder)
|
||||||
} else if (an.hasMeta("transBuildAction")) {
|
} else if (an.hasMeta("transBuildAction")) {
|
||||||
val transBuild = an.getMeta("transBuildAction")
|
val transBuild = an.getMeta("transBuildAction")
|
||||||
try {
|
try {
|
||||||
return TransmissionInterpolator.fromAction(context, transBuild, transXName, transYName, nSmooth, w, stitchBorder)
|
return TransmissionInterpolator.fromAction(
|
||||||
|
context,
|
||||||
|
transBuild,
|
||||||
|
transXName,
|
||||||
|
transYName,
|
||||||
|
nSmooth,
|
||||||
|
w,
|
||||||
|
stitchBorder
|
||||||
|
)
|
||||||
} catch (ex: InterruptedException) {
|
} catch (ex: InterruptedException) {
|
||||||
throw RuntimeException("Transmission builder failed")
|
throw RuntimeException("Transmission builder failed")
|
||||||
}
|
}
|
||||||
@ -281,7 +293,11 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
return if (an.hasMeta(ValuesAdapter.ADAPTER_KEY)) {
|
return if (an.hasMeta(ValuesAdapter.ADAPTER_KEY)) {
|
||||||
Adapters.buildAdapter(an.getMeta(ValuesAdapter.ADAPTER_KEY))
|
Adapters.buildAdapter(an.getMeta(ValuesAdapter.ADAPTER_KEY))
|
||||||
} else {
|
} else {
|
||||||
Adapters.buildXYAdapter(NumassPoint.HV_KEY, NumassAnalyzer.COUNT_RATE_KEY, NumassAnalyzer.COUNT_RATE_ERROR_KEY)
|
Adapters.buildXYAdapter(
|
||||||
|
NumassPoint.HV_KEY,
|
||||||
|
NumassAnalyzer.COUNT_RATE_KEY,
|
||||||
|
NumassAnalyzer.COUNT_RATE_ERROR_KEY
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +319,13 @@ class NumassPlugin : BasicPlugin() {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun displayChart(title: String, context: Context = Global, width: Double = 800.0, height: Double = 600.0, meta: Meta = Meta.empty()): JFreeChartFrame {
|
fun displayChart(
|
||||||
|
title: String,
|
||||||
|
context: Context = Global,
|
||||||
|
width: Double = 800.0,
|
||||||
|
height: Double = 600.0,
|
||||||
|
meta: Meta = Meta.empty()
|
||||||
|
): JFreeChartFrame {
|
||||||
val frame = JFreeChartFrame()
|
val frame = JFreeChartFrame()
|
||||||
frame.configure(meta)
|
frame.configure(meta)
|
||||||
frame.configureValue("title", title)
|
frame.configureValue("title", title)
|
||||||
|
@ -51,7 +51,7 @@ fun main(args: Array<String>) {
|
|||||||
hvs.forEach { hv ->
|
hvs.forEach { hv ->
|
||||||
val points = loader.points.filter {
|
val points = loader.points.filter {
|
||||||
it.voltage == hv
|
it.voltage == hv
|
||||||
}.map { it.channels[0]!! }.toList()
|
}.toList()
|
||||||
if (!points.isEmpty()) {
|
if (!points.isEmpty()) {
|
||||||
putStatic(
|
putStatic(
|
||||||
"point_${hv.toInt()}",
|
"point_${hv.toInt()}",
|
||||||
|
@ -35,6 +35,7 @@ import inr.numass.data.analyzers.NumassAnalyzer
|
|||||||
import inr.numass.data.analyzers.NumassAnalyzer.Companion.CHANNEL_KEY
|
import inr.numass.data.analyzers.NumassAnalyzer.Companion.CHANNEL_KEY
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer.Companion.COUNT_KEY
|
import inr.numass.data.analyzers.NumassAnalyzer.Companion.COUNT_KEY
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
import inr.numass.data.analyzers.SmartAnalyzer
|
||||||
|
import inr.numass.data.analyzers.countInWindow
|
||||||
import inr.numass.data.api.MetaBlock
|
import inr.numass.data.api.MetaBlock
|
||||||
import inr.numass.data.api.NumassPoint
|
import inr.numass.data.api.NumassPoint
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
@ -317,7 +318,7 @@ val histogramTask = task("histogram") {
|
|||||||
.filter { points == null || points.contains(it.voltage) }
|
.filter { points == null || points.contains(it.voltage) }
|
||||||
.groupBy { it.voltage }
|
.groupBy { it.voltage }
|
||||||
.mapValues {
|
.mapValues {
|
||||||
analyzer.getAmplitudeSpectrum(MetaBlock(it.value))
|
analyzer.getAmplitudeSpectrum(MetaBlock(it.value), meta.getMetaOrEmpty("analyzer"))
|
||||||
}
|
}
|
||||||
.forEach { u, spectrum ->
|
.forEach { u, spectrum ->
|
||||||
log.report("Aggregating data from U = $u")
|
log.report("Aggregating data from U = $u")
|
||||||
@ -383,6 +384,58 @@ val histogramTask = task("histogram") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sliceTask = task("slice") {
|
||||||
|
model { meta ->
|
||||||
|
dependsOn(selectTask, meta)
|
||||||
|
configure(meta.getMetaOrEmpty("slice"))
|
||||||
|
configure {
|
||||||
|
meta.useMeta("analyzer") { putNode(it) }
|
||||||
|
setValue("@target", meta.getString("@target", meta.name))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
join<NumassSet, Table> { data ->
|
||||||
|
val analyzer = SmartAnalyzer()
|
||||||
|
val slices = HashMap<String, IntRange>()
|
||||||
|
val formatBuilder = TableFormatBuilder()
|
||||||
|
formatBuilder.addColumn("set",ValueType.STRING)
|
||||||
|
formatBuilder.addColumn("time",ValueType.TIME)
|
||||||
|
meta.getMetaList("range").forEach {
|
||||||
|
val range = IntRange(it.getInt("from"), it.getInt("to"))
|
||||||
|
val name = it.getString("name", range.toString())
|
||||||
|
slices[name] = range
|
||||||
|
formatBuilder.addColumn(name, ValueType.NUMBER)
|
||||||
|
}
|
||||||
|
|
||||||
|
val table = buildTable(formatBuilder.build()) {
|
||||||
|
data.forEach { setName, set ->
|
||||||
|
val point = set.find {
|
||||||
|
it.index == meta.getInt("index", -1) ||
|
||||||
|
it.voltage == meta.getDouble("voltage", -1.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (point != null) {
|
||||||
|
val amplitudeSpectrum = analyzer.getAmplitudeSpectrum(point, meta.getMetaOrEmpty("analyzer"))
|
||||||
|
val map = HashMap<String, Any>()
|
||||||
|
map["set"] = setName
|
||||||
|
map["time"] = point.startTime
|
||||||
|
slices.mapValuesTo(map) { (_, range) ->
|
||||||
|
amplitudeSpectrum.countInWindow(
|
||||||
|
range.start.toShort(),
|
||||||
|
range.endInclusive.toShort()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
row(map)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// send raw table to the output
|
||||||
|
context.output.render(table, stage = "numass.table", name = name, meta = meta)
|
||||||
|
|
||||||
|
return@join table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val fitScanTask = task("fitscan") {
|
val fitScanTask = task("fitscan") {
|
||||||
model { meta ->
|
model { meta ->
|
||||||
dependsOn(filterTask, meta)
|
dependsOn(filterTask, meta)
|
||||||
|
Loading…
Reference in New Issue
Block a user