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
|
||||
*/
|
||||
@PluginDef(
|
||||
group = "inr.numass",
|
||||
name = "numass",
|
||||
dependsOn = ["hep.dataforge:functions", "hep.dataforge:MINUIT", "hep.dataforge:actions"],
|
||||
support = false,
|
||||
info = "Numass data analysis tools"
|
||||
group = "inr.numass",
|
||||
name = "numass",
|
||||
dependsOn = ["hep.dataforge:functions", "hep.dataforge:MINUIT", "hep.dataforge:actions"],
|
||||
support = false,
|
||||
info = "Numass data analysis tools"
|
||||
)
|
||||
class NumassPlugin : BasicPlugin() {
|
||||
|
||||
@ -58,20 +58,21 @@ class NumassPlugin : BasicPlugin() {
|
||||
}
|
||||
|
||||
private val tasks = listOf(
|
||||
NumassFitScanSummaryTask,
|
||||
NumassFitSummaryTask,
|
||||
selectTask,
|
||||
analyzeTask,
|
||||
mergeTask,
|
||||
mergeEmptyTask,
|
||||
monitorTableTask,
|
||||
subtractEmptyTask,
|
||||
transformTask,
|
||||
filterTask,
|
||||
fitTask,
|
||||
plotFitTask,
|
||||
histogramTask,
|
||||
fitScanTask
|
||||
NumassFitScanSummaryTask,
|
||||
NumassFitSummaryTask,
|
||||
selectTask,
|
||||
analyzeTask,
|
||||
mergeTask,
|
||||
mergeEmptyTask,
|
||||
monitorTableTask,
|
||||
subtractEmptyTask,
|
||||
transformTask,
|
||||
filterTask,
|
||||
fitTask,
|
||||
plotFitTask,
|
||||
histogramTask,
|
||||
fitScanTask,
|
||||
sliceTask
|
||||
)
|
||||
|
||||
@Provides(Task.TASK_TARGET)
|
||||
@ -109,7 +110,10 @@ class NumassPlugin : BasicPlugin() {
|
||||
BivariateFunction { E: Double, U: Double ->
|
||||
val D = E - U
|
||||
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")
|
||||
|
||||
return TransmissionInterpolator
|
||||
.fromFile(context, transmissionFile, transXName, transYName, nSmooth, w, stitchBorder)
|
||||
.fromFile(context, transmissionFile, transXName, transYName, nSmooth, w, stitchBorder)
|
||||
} else if (an.hasMeta("transBuildAction")) {
|
||||
val transBuild = an.getMeta("transBuildAction")
|
||||
try {
|
||||
return TransmissionInterpolator.fromAction(context, transBuild, transXName, transYName, nSmooth, w, stitchBorder)
|
||||
return TransmissionInterpolator.fromAction(
|
||||
context,
|
||||
transBuild,
|
||||
transXName,
|
||||
transYName,
|
||||
nSmooth,
|
||||
w,
|
||||
stitchBorder
|
||||
)
|
||||
} catch (ex: InterruptedException) {
|
||||
throw RuntimeException("Transmission builder failed")
|
||||
}
|
||||
@ -281,7 +293,11 @@ class NumassPlugin : BasicPlugin() {
|
||||
return if (an.hasMeta(ValuesAdapter.ADAPTER_KEY)) {
|
||||
Adapters.buildAdapter(an.getMeta(ValuesAdapter.ADAPTER_KEY))
|
||||
} 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
|
||||
*/
|
||||
@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()
|
||||
frame.configure(meta)
|
||||
frame.configureValue("title", title)
|
||||
|
@ -51,7 +51,7 @@ fun main(args: Array<String>) {
|
||||
hvs.forEach { hv ->
|
||||
val points = loader.points.filter {
|
||||
it.voltage == hv
|
||||
}.map { it.channels[0]!! }.toList()
|
||||
}.toList()
|
||||
if (!points.isEmpty()) {
|
||||
putStatic(
|
||||
"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.COUNT_KEY
|
||||
import inr.numass.data.analyzers.SmartAnalyzer
|
||||
import inr.numass.data.analyzers.countInWindow
|
||||
import inr.numass.data.api.MetaBlock
|
||||
import inr.numass.data.api.NumassPoint
|
||||
import inr.numass.data.api.NumassSet
|
||||
@ -317,7 +318,7 @@ val histogramTask = task("histogram") {
|
||||
.filter { points == null || points.contains(it.voltage) }
|
||||
.groupBy { it.voltage }
|
||||
.mapValues {
|
||||
analyzer.getAmplitudeSpectrum(MetaBlock(it.value))
|
||||
analyzer.getAmplitudeSpectrum(MetaBlock(it.value), meta.getMetaOrEmpty("analyzer"))
|
||||
}
|
||||
.forEach { u, spectrum ->
|
||||
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") {
|
||||
model { meta ->
|
||||
dependsOn(filterTask, meta)
|
||||
|
Loading…
Reference in New Issue
Block a user