Minor fixes
This commit is contained in:
parent
a0087c2e17
commit
15423b0f26
@ -14,10 +14,11 @@ description = "A bse package with minimal dependencies for numass"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
compile "hep.dataforge:dataforge-storage" //project(':dataforge-storage')
|
||||||
|
compile "hep.dataforge:kodex"
|
||||||
compile 'com.google.protobuf:protobuf-java:3.5.0'
|
compile 'com.google.protobuf:protobuf-java:3.5.0'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.github.robtimus/sftp-fs
|
// https://mvnrepository.com/artifact/com.github.robtimus/sftp-fs
|
||||||
compile group: 'com.github.robtimus', name: 'sftp-fs', version: '1.1.1'
|
compile group: 'com.github.robtimus', name: 'sftp-fs', version: '1.1.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
protobuf {
|
protobuf {
|
||||||
|
@ -74,3 +74,9 @@ task underflow(dependsOn: classes, type: JavaExec) {
|
|||||||
classpath = sourceSets.main.runtimeClasspath
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task scanTreeStartScript(type: CreateStartScripts, dependsOn: installDist) {
|
||||||
|
applicationName = 'scanTree'
|
||||||
|
classpath = fileTree('build/install/numass-main/lib')
|
||||||
|
mainClassName = 'inr.numass.scripts.ScanTreeKt'
|
||||||
|
outputDir = file('build/install/numass-main/bin')
|
||||||
|
}
|
@ -21,7 +21,7 @@ import inr.numass.data.api.NumassPoint
|
|||||||
@ValueDefs(
|
@ValueDefs(
|
||||||
ValueDef(name = "normalize", type = arrayOf(ValueType.BOOLEAN), def = "true", info = "Normalize t0 dependencies"),
|
ValueDef(name = "normalize", type = arrayOf(ValueType.BOOLEAN), def = "true", info = "Normalize t0 dependencies"),
|
||||||
ValueDef(name = "t0", type = arrayOf(ValueType.NUMBER), def = "30e3", info = "The default t0 in nanoseconds"),
|
ValueDef(name = "t0", type = arrayOf(ValueType.NUMBER), def = "30e3", info = "The default t0 in nanoseconds"),
|
||||||
ValueDef(name = "window.lo", type = arrayOf(ValueType.NUMBER), def = "500", info = "Lower boundary for amplitude window"),
|
ValueDef(name = "window.lo", type = arrayOf(ValueType.NUMBER), def = "0", info = "Lower boundary for amplitude window"),
|
||||||
ValueDef(name = "window.up", type = arrayOf(ValueType.NUMBER), def = "10000", info = "Upper boundary for amplitude window"),
|
ValueDef(name = "window.up", type = arrayOf(ValueType.NUMBER), def = "10000", info = "Upper boundary for amplitude window"),
|
||||||
ValueDef(name = "binNum", type = arrayOf(ValueType.NUMBER), def = "1000", info = "Number of bins for time histogram"),
|
ValueDef(name = "binNum", type = arrayOf(ValueType.NUMBER), def = "1000", info = "Number of bins for time histogram"),
|
||||||
ValueDef(name = "binSize", type = arrayOf(ValueType.NUMBER), info = "Size of bin for time histogram. By default is defined automatically")
|
ValueDef(name = "binSize", type = arrayOf(ValueType.NUMBER), info = "Size of bin for time histogram. By default is defined automatically")
|
||||||
@ -39,8 +39,8 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
|
|
||||||
|
|
||||||
//val t0 = inputMeta.getDouble("t0", 30e3);
|
//val t0 = inputMeta.getDouble("t0", 30e3);
|
||||||
val loChannel = inputMeta.getInt("window.lo", 500);
|
// val loChannel = inputMeta.getInt("window.lo", 500);
|
||||||
val upChannel = inputMeta.getInt("window.up", 10000);
|
// val upChannel = inputMeta.getInt("window.up", 10000);
|
||||||
val pm = context.getFeature(PlotPlugin::class.java);
|
val pm = context.getFeature(PlotPlugin::class.java);
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class TimeAnalyzerAction : OneToOneAction<NumassPoint, Table>() {
|
|||||||
|
|
||||||
pm.getPlotFrame(getName(), "stat-method").add(statPlot)
|
pm.getPlotFrame(getName(), "stat-method").add(statPlot)
|
||||||
|
|
||||||
(1..100).map { 1000 * it }.map { t ->
|
(1..100).map { inputMeta.getDouble("t0Step", 1000.0) * it }.map { t ->
|
||||||
val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t))
|
val result = analyzer.analyze(input, inputMeta.builder.setValue("t0", t))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package inr.numass.scripts
|
package inr.numass.scripts
|
||||||
|
|
||||||
|
import hep.dataforge.fx.plots.PlotManager
|
||||||
import hep.dataforge.kodex.buildMeta
|
import hep.dataforge.kodex.buildMeta
|
||||||
import inr.numass.data.analyzers.NumassAnalyzer
|
import inr.numass.actions.TimeAnalyzerAction
|
||||||
import inr.numass.data.analyzers.SmartAnalyzer
|
|
||||||
import inr.numass.data.api.SimpleNumassPoint
|
import inr.numass.data.api.SimpleNumassPoint
|
||||||
import inr.numass.data.buildBunchChain
|
import inr.numass.data.buildBunchChain
|
||||||
import inr.numass.data.buildSimpleEventChain
|
import inr.numass.data.buildSimpleEventChain
|
||||||
@ -12,13 +12,15 @@ import java.time.Instant
|
|||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
PlotManager().startGlobal()
|
||||||
|
|
||||||
val cr = 10.0
|
val cr = 10.0
|
||||||
val length = 1e12.toLong()
|
val length = 1e12.toLong()
|
||||||
val num = 20;
|
val num = 60;
|
||||||
|
|
||||||
val blocks = (1..num).map {
|
val blocks = (1..num).map {
|
||||||
val regularChain = buildSimpleEventChain(cr)
|
val regularChain = buildSimpleEventChain(cr)
|
||||||
val bunchChain = buildBunchChain(20.0, 0.01, 5.0)
|
val bunchChain = buildBunchChain(40.0, 0.01, 5.0)
|
||||||
|
|
||||||
val generator = mergeEventChains(regularChain, bunchChain)
|
val generator = mergeEventChains(regularChain, bunchChain)
|
||||||
generateBlock(Instant.now().plusNanos(it * length), length, generator)
|
generateBlock(Instant.now().plusNanos(it * length), length, generator)
|
||||||
@ -27,14 +29,19 @@ fun main(args: Array<String>) {
|
|||||||
val point = SimpleNumassPoint(10000.0, blocks)
|
val point = SimpleNumassPoint(10000.0, blocks)
|
||||||
|
|
||||||
val meta = buildMeta {
|
val meta = buildMeta {
|
||||||
"t0.crFraction" to 0.1
|
"t0" to 1e7
|
||||||
|
"t0Step" to 4e6
|
||||||
|
"normalize" to false
|
||||||
|
"t0.crFraction" to 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
println("actual count rate: ${point.events.count().toDouble() / point.length.seconds}")
|
println("actual count rate: ${point.events.count().toDouble() / point.length.seconds}")
|
||||||
|
|
||||||
val res = SmartAnalyzer().analyze(point, meta)
|
TimeAnalyzerAction().simpleRun(point,meta)
|
||||||
.getDouble(NumassAnalyzer.COUNT_RATE_KEY)
|
|
||||||
|
|
||||||
println("estimated count rate: $res")
|
// val res = SmartAnalyzer().analyze(point, meta)
|
||||||
|
// .getDouble(NumassAnalyzer.COUNT_RATE_KEY)
|
||||||
|
//
|
||||||
|
// println("estimated count rate: $res")
|
||||||
|
|
||||||
}
|
}
|
103
numass-main/src/main/kotlin/inr/numass/scripts/ScanTree.kt
Normal file
103
numass-main/src/main/kotlin/inr/numass/scripts/ScanTree.kt
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
package inr.numass.scripts
|
||||||
|
|
||||||
|
import hep.dataforge.io.XMLMetaWriter
|
||||||
|
import hep.dataforge.kodex.buildMeta
|
||||||
|
import hep.dataforge.kodex.global
|
||||||
|
import hep.dataforge.kodex.useValue
|
||||||
|
import hep.dataforge.meta.Meta
|
||||||
|
import hep.dataforge.meta.MetaBuilder
|
||||||
|
import hep.dataforge.meta.MetaUtils
|
||||||
|
import hep.dataforge.storage.api.Storage
|
||||||
|
import inr.numass.data.storage.NumassDataLoader
|
||||||
|
import inr.numass.data.storage.NumassStorageFactory
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
private fun createSummaryNode(storage: Storage): MetaBuilder {
|
||||||
|
global.logger.info("Reading content of shelf {}", storage.fullName)
|
||||||
|
|
||||||
|
val builder = MetaBuilder("shelf")
|
||||||
|
.setValue("name", storage.name)
|
||||||
|
.setValue("path", storage.fullName)
|
||||||
|
storage.shelves().filter { it.name.startsWith("Fill") }.forEach {
|
||||||
|
builder.putNode(createSummaryNode(it))
|
||||||
|
}
|
||||||
|
storage.loaders().filterIsInstance(NumassDataLoader::class.java).forEach { set ->
|
||||||
|
|
||||||
|
global.logger.info("Reading content of set {}", set.fullName)
|
||||||
|
|
||||||
|
val setBuilder = MetaBuilder("set")
|
||||||
|
.setValue("name", set.name)
|
||||||
|
.setValue("path", set.fullName)
|
||||||
|
|
||||||
|
if (set.name.endsWith("bad")) {
|
||||||
|
setBuilder.setValue("bad", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
set.points.forEach { point ->
|
||||||
|
val pointBuilder = MetaBuilder("point")
|
||||||
|
.setValue("index", point.index)
|
||||||
|
.setValue("hv", point.voltage)
|
||||||
|
.setValue("startTime", point.startTime)
|
||||||
|
// .setNode("meta", point.meta)
|
||||||
|
|
||||||
|
point.meta.useValue("acquisition_time") {
|
||||||
|
pointBuilder.setValue("length", it.doubleValue())
|
||||||
|
}
|
||||||
|
|
||||||
|
point.meta.useValue("events") {
|
||||||
|
pointBuilder.setValue("count", it.listValue().stream().mapToInt { it.intValue() }.sum())
|
||||||
|
}
|
||||||
|
|
||||||
|
setBuilder.putNode(pointBuilder)
|
||||||
|
}
|
||||||
|
builder.putNode(setBuilder)
|
||||||
|
}
|
||||||
|
return builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateStatistics(summary: Meta, hv: Double): Meta {
|
||||||
|
var totalLength = 0.0
|
||||||
|
var totalCount = 0L
|
||||||
|
MetaUtils.nodeStream(summary).map { it.value }.filter { it.name == "point" && it.getDouble("hv") == hv }.forEach {
|
||||||
|
totalCount += it.getInt("count")
|
||||||
|
totalLength += it.getDouble("length")
|
||||||
|
}
|
||||||
|
return buildMeta("point") {
|
||||||
|
"hv" to hv
|
||||||
|
"time" to totalLength
|
||||||
|
"count" to totalCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val directory = if (args.isNotEmpty()) {
|
||||||
|
args.first()
|
||||||
|
} else {
|
||||||
|
"."
|
||||||
|
}
|
||||||
|
|
||||||
|
val path = Paths.get(directory)
|
||||||
|
|
||||||
|
val output = File(directory, "summary.xml")
|
||||||
|
output.createNewFile()
|
||||||
|
|
||||||
|
|
||||||
|
val storage = NumassStorageFactory.buildLocal(global, path, true, false)
|
||||||
|
val summary = createSummaryNode(storage)
|
||||||
|
|
||||||
|
global.logger.info("Writing output meta")
|
||||||
|
output.outputStream().use {
|
||||||
|
XMLMetaWriter().write(it, summary)
|
||||||
|
}
|
||||||
|
global.logger.info("Calculating statistics")
|
||||||
|
val statistics = MetaBuilder("statistics")
|
||||||
|
(14000..18600).step(100).map { it.toDouble() }.forEach {
|
||||||
|
statistics.putNode(calculateStatistics(summary, it))
|
||||||
|
}
|
||||||
|
|
||||||
|
File(directory, "statistics.xml").outputStream().use {
|
||||||
|
XMLMetaWriter().write(it, statistics)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'io.ratpack:ratpack-gradle:1.4.6'
|
classpath 'io.ratpack:ratpack-gradle:1.4.6'
|
||||||
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
|
classpath 'com.github.jengelman.gradle.plugins:shadow:2.+'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user