Polinomial corrections to spectrum.
This commit is contained in:
commit
ac9ff50ff2
@ -5,69 +5,68 @@ import hep.dataforge.meta.buildMeta
|
|||||||
import hep.dataforge.nullable
|
import hep.dataforge.nullable
|
||||||
import hep.dataforge.plots.PlotGroup
|
import hep.dataforge.plots.PlotGroup
|
||||||
import hep.dataforge.plots.data.DataPlot
|
import hep.dataforge.plots.data.DataPlot
|
||||||
import hep.dataforge.toList
|
|
||||||
import inr.numass.NumassPlugin
|
import inr.numass.NumassPlugin
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer
|
import inr.numass.data.analyzers.NumassAnalyzer
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
import inr.numass.data.analyzers.SmartAnalyzer
|
||||||
import inr.numass.data.analyzers.withBinning
|
import inr.numass.data.analyzers.withBinning
|
||||||
import inr.numass.data.api.NumassSet
|
import inr.numass.data.api.NumassSet
|
||||||
import inr.numass.data.api.SimpleBlock
|
|
||||||
import inr.numass.data.storage.NumassDirectory
|
import inr.numass.data.storage.NumassDirectory
|
||||||
import inr.numass.displayChart
|
import inr.numass.displayChart
|
||||||
import kotlinx.coroutines.experimental.runBlocking
|
|
||||||
import java.time.Duration
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Investigating slices of single point for differences at the beginning and end
|
* Investigating slices of single point for differences at the beginning and end
|
||||||
*/
|
*/
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val context = buildContext("NUMASS", NumassPlugin::class.java) {
|
val context = buildContext("NUMASS", NumassPlugin::class.java) {
|
||||||
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
rootDir = "D:\\Work\\Numass\\sterile\\2017_05"
|
||||||
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
dataDir = "D:\\Work\\Numass\\data\\2017_05_frames"
|
||||||
}
|
}
|
||||||
//val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
|
//val rootDir = File("D:\\Work\\Numass\\data\\2017_05\\Fill_2")
|
||||||
|
|
||||||
val storage = NumassDirectory.read(context, "Fill_3b") ?: error("Storage not found")
|
val storage = NumassDirectory.read(context, "Fill_3_events") ?: error("Storage not found")
|
||||||
|
|
||||||
|
|
||||||
val analyzer = SmartAnalyzer()
|
val analyzer = SmartAnalyzer()
|
||||||
|
|
||||||
val meta = buildMeta {
|
val meta = buildMeta {
|
||||||
"t0" to 15e3
|
"t0" to 15e3
|
||||||
"window.lo" to 400
|
// "window.lo" to 400
|
||||||
"window.up" to 1600
|
// "window.up" to 1600
|
||||||
}
|
}
|
||||||
|
|
||||||
val set = storage.provide("set_17", NumassSet::class.java).nullable ?: error("Set does not exist")
|
val set = storage.provide("set_58", NumassSet::class.java).nullable ?: error("Set does not exist")
|
||||||
|
|
||||||
val frame = displayChart("slices").apply {
|
val frame = displayChart("slices").apply {
|
||||||
plots.setType<DataPlot>()
|
plots.setType<DataPlot>()
|
||||||
plots.configureValue("showLine", true)
|
plots.configureValue("showLine", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
listOf(0,58,103).forEach { index ->
|
listOf(10, 58, 103).forEach { index ->
|
||||||
val group = PlotGroup("point_$index")
|
val group = PlotGroup("point_$index")
|
||||||
group.setType<DataPlot>()
|
group.setType<DataPlot>()
|
||||||
val point = set.find { it.index == index } ?: error("Point not found")
|
val point = set.find { it.index == index } ?: error("Point not found")
|
||||||
|
|
||||||
|
|
||||||
val blockSizes = point.meta.getValue("events").list.map { it.int }
|
// val blockSizes = point.meta.getValue("events").list.map { it.int }
|
||||||
val startTimes = point.meta.getValue("start_time").list.map { it.time }
|
// val startTimes = point.meta.getValue("start_time").list.map { it.time }
|
||||||
|
|
||||||
|
group.add(DataPlot.plot("spectrum", analyzer.getAmplitudeSpectrum(point, meta).withBinning(32), NumassAnalyzer.AMPLITUDE_ADAPTER))
|
||||||
|
|
||||||
runBlocking {
|
// runBlocking {
|
||||||
val events = point.events.toList()
|
// val events = point.events.toList()
|
||||||
var startIndex = 0
|
// var startIndex = 0
|
||||||
val blocks = blockSizes.zip(startTimes).map { (size, startTime) ->
|
// val blocks = blockSizes.zip(startTimes).map { (size, startTime) ->
|
||||||
SimpleBlock.produce(startTime, Duration.ofSeconds(5)) {
|
// SimpleBlock.produce(startTime, Duration.ofSeconds(5)) {
|
||||||
events.subList(startIndex, startIndex + size)
|
// events.subList(startIndex, startIndex + size)
|
||||||
}.also { startIndex += size }
|
// }.also { startIndex += size }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
blocks.forEachIndexed { index, block ->
|
// blocks.forEachIndexed { index, block ->
|
||||||
group.add(DataPlot.plot("block_$index", analyzer.getAmplitudeSpectrum(block).withBinning(20), NumassAnalyzer.AMPLITUDE_ADAPTER))
|
// group.add(DataPlot.plot("block_$index", analyzer.getAmplitudeSpectrum(block).withBinning(20), NumassAnalyzer.AMPLITUDE_ADAPTER) {
|
||||||
}
|
// "visible" to false
|
||||||
}
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
frame.add(group)
|
frame.add(group)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 Alexander Nozik.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package inr.numass.scripts.threshold
|
||||||
|
|
||||||
|
import hep.dataforge.buildContext
|
||||||
|
import hep.dataforge.fx.output.FXOutputManager
|
||||||
|
import hep.dataforge.io.DirectoryOutput
|
||||||
|
import hep.dataforge.io.plus
|
||||||
|
import hep.dataforge.meta.buildMeta
|
||||||
|
import hep.dataforge.nullable
|
||||||
|
import hep.dataforge.plots.data.DataPlot
|
||||||
|
import hep.dataforge.plots.jfreechart.JFreeChartPlugin
|
||||||
|
import hep.dataforge.plots.plotData
|
||||||
|
import hep.dataforge.storage.files.FileStorage
|
||||||
|
import hep.dataforge.tables.Adapters
|
||||||
|
import inr.numass.NumassPlugin
|
||||||
|
import inr.numass.data.NumassDataUtils
|
||||||
|
import inr.numass.data.api.NumassSet
|
||||||
|
import inr.numass.data.storage.NumassDirectory
|
||||||
|
import inr.numass.displayChart
|
||||||
|
import inr.numass.subthreshold.Threshold
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val context = buildContext("NUMASS", NumassPlugin::class.java, JFreeChartPlugin::class.java) {
|
||||||
|
rootDir = "D:\\Work\\Numass\\sterile\\2017_11"
|
||||||
|
dataDir = "D:\\Work\\Numass\\data\\2017_11"
|
||||||
|
output = FXOutputManager() + DirectoryOutput()
|
||||||
|
}
|
||||||
|
|
||||||
|
val storage = NumassDirectory.read(context, "Fill_2") as? FileStorage ?: error("Storage not found")
|
||||||
|
|
||||||
|
val meta = buildMeta {
|
||||||
|
"delta" to -150
|
||||||
|
"method" to "pow"
|
||||||
|
"t0" to 15e3
|
||||||
|
// "window.lo" to 400
|
||||||
|
// "window.up" to 1600
|
||||||
|
"xLow" to 450
|
||||||
|
"xHigh" to 700
|
||||||
|
"upper" to 3100
|
||||||
|
"binning" to 20
|
||||||
|
}
|
||||||
|
|
||||||
|
val frame = displayChart("correction").apply {
|
||||||
|
plots.setType<DataPlot>()
|
||||||
|
}
|
||||||
|
|
||||||
|
val sets = (36..42).map { "set_$it" }.map { setName ->
|
||||||
|
storage.provide(setName, NumassSet::class.java).nullable ?: error("Set does not exist")
|
||||||
|
}
|
||||||
|
val name = "fill_2[36-42]"
|
||||||
|
|
||||||
|
val sum = NumassDataUtils.join(name, sets)
|
||||||
|
|
||||||
|
val correctionTable = Threshold.calculateSubThreshold(sum, meta).filter {
|
||||||
|
it.getDouble("correction") in (1.0..1.2)
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.plotData("${name}_cor", correctionTable, Adapters.buildXYAdapter("U", "correction"))
|
||||||
|
frame.plotData("${name}_a", correctionTable, Adapters.buildXYAdapter("U", "a"))
|
||||||
|
frame.plotData("${name}_beta", correctionTable, Adapters.buildXYAdapter("U", "beta"))
|
||||||
|
}
|
@ -74,11 +74,6 @@ object Threshold {
|
|||||||
analyzer.getAmplitudeSpectrum(input, this.meta)
|
analyzer.getAmplitudeSpectrum(input, this.meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// val id = buildMeta {
|
|
||||||
// +meta.getMeta("data")
|
|
||||||
// +meta.getMeta("analyze")
|
|
||||||
// }
|
|
||||||
// return context.getFeature(CachePlugin::class.java).cacheNode("subThreshold", id, spectra)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user