Files
sics/site_ansto/instrument/pelican/config/hmm/hmm_configuration.tcl

276 lines
10 KiB
Tcl

# Author Jing Chen (jgn@ansto.gove.au)
fileeval $cfPath(hmm)/hmm_configuration_common_1.tcl
source $cfPath(hmm)/hmm_cylindrical_detector_configuration.tcl
set sim_mode [SplitReply [hmm_simulation]]
# Elastic peak index and time of flight channel width
::utility::mkVar elpk int user elpk true detector true true
sicslist setatt elpk link data_set
::utility::mkVar tofw float user tofw true detector true true
sicslist setatt tofw link data_set
proc ::histogram_memory::init_OAT_TABLE {} {
variable INST_NXC "oat_nxc_eff"
variable INST_NYC "oat_nyc_eff"
if [ catch {
OAT_TABLE X -setdata MAX_CHAN 200
OAT_TABLE Y -setdata MAX_CHAN 1024
OAT_TABLE X -setdata BMIN -0.5
OAT_TABLE X -setdata BMAX 199.5
OAT_TABLE Y -setdata BMIN -0.5
OAT_TABLE Y -setdata BMAX 1023.5
set clock_scale 1000
set freq 200
set tbins 1000
set xbins 200
set ybins 64
set period [expr 1.0/$freq]
set tbinwidth_ns [expr $period/$tbins * 1e9]
hmm configure fat_clock_scale $clock_scale
hmm configure fat_frame_frequency $freq
hmm configure fat_frame_source EXTERNAL
# The entries in the time bin array are in nanoseconds/clock_scale because the clock base is in nanoseconds
set tbb0 0.0
set tbb1 [expr $tbb0 + $tbinwidth_ns / $clock_scale]
OAT_TABLE -set X { 199.5 198.5 } NXC $xbins Y { -0.5 15.5 } NYC $ybins T "$tbb0 $tbb1" NTC $tbins
# Use the ::histogram_memory::clock_scale function to make sure that the value in the
# time of flight channel width is consistent with its units
sicslist setatt tofw units [::histogram_memory::clock_scale units]
tofw [expr ($tbb1 - $tbb0) * [::histogram_memory::clock_scale]]
if {$::sim_mode == "true"} {
hmm configure oat_ntc_eff $tbins
hmm configure $INST_NYC $ybins
hmm configure $INST_NXC $xbins
}
} message ] {
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
}
proc CAT_TABLE {args} {
return {
<CAT>
<MESYTEC_MPSD8_CHANNEL_GAINS>
<link_numeric_file filename="../../pelican_mesytec_gains.dat" default_filename="../HMconfig/Default//pelican_mesytec_gains.dat" />
</MESYTEC_MPSD8_CHANNEL_GAINS>
<MESYTEC_MPSD8_THRESHOLDS>
23 23 23 20 20 20 20 20
20 20 20 20 20 20 20 20
20 20 20 20 20 20 20 20
20 20 10 10 10 10 10 10
</MESYTEC_MPSD8_THRESHOLDS>
<WIX APPLY="ENABLE" MIN_RAW="0" MAX_RAW="199" TABLE_SIZE="200">
<link_numeric_file filename="../../pelican_wix.dat" default_filename="../HMconfig/Default/pelican_wix.dat" />
</WIX>
<OFFSET_Y_PER_X APPLY="ENABLE" MIN_RAW="0" MAX_RAW="199" TABLE_SIZE="200" BASE_VAL="0">
<link_numeric_file filename="../../pelican_offset_y_per_x.dat" default_filename="../HMconfig/Default/pelican_offset_y_per_x.dat" />
</OFFSET_Y_PER_X>
<MAGNIFY APPLY="ENABLE" MIN_RAW="0" MAX_RAW="199" TABLE_SIZE="200" DIRECTION="X" MAX_IN="1023" MAX_OUT="1023" RANGE="UNSIGNED">
<link_numeric_file filename="../../pelican_magnify.dat" default_filename="../HMconfig/Default/pelican_magnify.dat" />
</MAGNIFY>
</CAT>
}
}
proc ::histogram_memory::init_CAT_TABLE {} {
CAT_TABLE -set MESYTEC_TUBE_PAIR_RESISTANCE_RATIOS {
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1. 1. 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1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
}
}
##
# @brief Return the detector position
proc ::histogram_memory::detector_posn_degrees {} {
return [SplitReply [stth]]
}
proc ::histogram_memory::pre_count {} {}
proc ::histogram_memory::post_count {} {}
proc ::histogram_memory::isc_initialize {} {
# Instrument specific X and Y dimension names
if [ catch {
::histogram_memory::init_hmm_objs
BAT_TABLE -init
# CAT_TABLE -init
SAT_TABLE -init
OAT_TABLE -init
FAT_TABLE -init
::histogram_memory::ic_initialize
::histogram_memory::set_graphtype "two_theta" "boundaries"
# Width = 25mm spacing * 200 tubes = 5000mm (120 degree coverage)
# Height = 1015mm (tube length)
# Radius = 2400mm
detector_active_height_mm 1015
detector_active_height_mm lock
detector_active_width_mm 5235.9888
detector_active_width_mm lock
detector_radius_mm 2400.0
detector_radius_mm lock
# hmm configure FAT_SIMULATED_EVENT_Y0 $y_bb0
# hmm configure FAT_SIMULATED_EVENT_Y1 $ybbmax
# hmm configure FAT_SIMULATED_EVENT_X0 $x_bb0
# hmm configure FAT_SIMULATED_EVENT_X1 $xbbmax
::histogram_memory::init_OAT_TABLE
::histogram_memory::init_SAT_TABLE
::histogram_memory::init_CAT_TABLE
::histogram_memory::upload_config Filler_defaults
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_pixel_angular_offset
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_pixel_offset
} message ] {
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
}
proc histmem {cmd args} {
set catch_status [ catch {
switch $cmd {
"tbins" {
if {$args == ""} {
set reply [OAT_TABLE -get NTC]
} else {
if {[llength $args] != 2} {
error "There should be two arguments in $args, the number of time bins and the desired frame frequency"
} else {
foreach {numbins freq} $args {}
if { ![string is integer $numbins]} {
error "$numbins should be an integer"
}
if { ![string is double $freq]} {
error "$freq should be a number"
}
set period [expr 1.0/$freq]
set tbinwidth_us [expr $period/$numbins * 1e6]
set clock_scale [::histogram_memory::clock_scale]
set tbb0 0.0
set tbb1 [expr $tbb0 + $tbinwidth_us / $clock_scale]
hmm configure fat_frame_frequency $freq
OAT_TABLE -set T "$tbb0 $tbb1" NTC $numbins
set reply [_histmem loadconf]
}
}
}
"twidth" {
if {$args == ""} {
set tbins [OAT_TABLE -get T]
set tb0 [lindex $tbins 0]
set tb1 [lindex $tbins 1]
set reply [expr {($tb1 - $tb0) / [::histogram_memory::clock_scale]}]
} else {
if {[llength $args] != 2} {
error "There should be two arguments in $args, the desired time bin width and the frame frequency"
} else {
foreach {binw_us freq} $args {}
if { ![string is double $binw_us]} {
error "$binw_us should be a number"
}
if { ![string is double $freq]} {
error "$freq should be a number"
}
set period_us [expr {1e6/$freq}]
set numbins [expr {round(0.5 + $period_us/$binw_us)}]
set clock_scale [::histogram_memory::clock_scale]
set tbinwidth [expr {$binw_us / $clock_scale}]
set tbb0 0.0
set tbb1 [expr $tbb0 + $tbinwidth]
hmm configure fat_frame_frequency $freq
OAT_TABLE -set T "$tbb0 $tbb1" NTC $numbins
set reply [_histmem loadconf]
}
}
}
default {
set reply [eval "_histmem $cmd $args"]
}
}
return $reply
} msg ]
handle_exception $catch_status $msg
}
publish histmem user