From 696971563a6a296d983ad19d9674d59d6ebb5bf7 Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 1 Mar 2024 11:48:51 +0100 Subject: [PATCH] adapted LUT for START Detector and Jan fixed bugs in rate calculation --- hmon/hmon_startrate.pl | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/hmon/hmon_startrate.pl b/hmon/hmon_startrate.pl index afa0856..a9c9e01 100755 --- a/hmon/hmon_startrate.pl +++ b/hmon/hmon_startrate.pl @@ -576,26 +576,26 @@ HPlot::PlotDrawFork('StartDutyFactorY_0'); my $channels_x_1 = [ - { pch => 1, tdc => 2, ch => 7}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 3, tdc => 2, ch => 6}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 5, tdc => 2, ch => 5}, # pch: physical channel. The thing which will be plotted - { pch => 7, tdc => 2, ch => 4}, # tdc: tdc number - { pch => 9, tdc => 2, ch => 3}, # ch: channel in the TDC - { pch => 11, tdc => 2, ch => 2}, - { pch => 13, tdc => 2, ch => 1}, - { pch => 15, tdc => 2, ch => 0} + { pch => 2, tdc => 2, ch => 7}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. + { pch => 4, tdc => 2, ch => 6}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! + { pch => 6, tdc => 2, ch => 5}, # pch: physical channel. The thing which will be plotted + { pch => 8, tdc => 2, ch => 4}, # tdc: tdc number + { pch => 10, tdc => 2, ch => 3}, # ch: channel in the TDC + { pch => 12, tdc => 2, ch => 2}, + { pch => 14, tdc => 2, ch => 1}, + { pch => 16, tdc => 2, ch => 0} ]; my $channels_x_0 = [ - { pch => 2 , tdc => 0, ch => 0 }, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 4 , tdc => 0, ch => 1 }, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 6 , tdc => 0, ch => 2 }, - { pch => 8 , tdc => 0, ch => 3 }, - { pch => 10, tdc => 0, ch => 4 }, - { pch => 12, tdc => 0, ch => 5 }, - { pch => 14, tdc => 0, ch => 6 }, - { pch => 16, tdc => 0, ch => 7 } + { pch => 1 , tdc => 0, ch => 0 }, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. + { pch => 3 , tdc => 0, ch => 1 }, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! + { pch => 5 , tdc => 0, ch => 2 }, + { pch => 7 , tdc => 0, ch => 3 }, + { pch => 9, tdc => 0, ch => 4 }, + { pch => 11, tdc => 0, ch => 5 }, + { pch => 13, tdc => 0, ch => 6 }, + { pch => 15, tdc => 0, ch => 7 } ]; my $channels_y_1 = [ @@ -898,7 +898,7 @@ while(1) { # HPlot::PlotAdd("StartSpillSumX_0", $total_x_0,0); # changed W.K 01.02.22 max_x and total_x for whole detector - HPlot::PlotAdd("StartDutyFactorX_0", ($avgRate_x_0+$avgRate_x_1)/($maxTotalX||1),0); + HPlot::PlotAdd("StartDutyFactorX_0", ($avgRate_x_0+$avgRate_x_1)/$maxTotalX,0); HPlot::PlotAdd("StartSpillPeakX_0", $maxTotalX,0); HPlot::PlotAdd("StartSpillSumX_0", $total_x_0+$total_x_1,0); # end changed @@ -915,7 +915,7 @@ while(1) { $str .= "
Last Sum".QA::SciNotation( $total_x_0+$total_x_1); # end changed - $str .= "Last Duty".sprintf("%0.3f",($avgRate_x_0+$avgRate_x_1)/($maxTotalX||1)); + $str .= "Last Duty".sprintf("%0.3f",($avgRate_x_0+$avgRate_x_1)/$maxTotalX); $str .= "
Last Duration".$length_x_0; $str .= "Last Break".$offtime_x_0." s"; # $str .= "
Last Max".QA::SciNotation($max_x_0)." Hz (100ms)"; @@ -936,7 +936,7 @@ while(1) { # HPlot::PlotAdd("StartSpillPeakY_0", $max_y_0,0); # HPlot::PlotAdd("StartSpillSumY_0", $total_y_0,0); # changed W.K 01.02.22 - HPlot::PlotAdd("StartDutyFactorY_0", ($avgRate_y_0+$avgRate_y_1)/($maxTotalY||1),0); + HPlot::PlotAdd("StartDutyFactorY_0", ($avgRate_y_0+$avgRate_y_1)/$maxTotalY,0); HPlot::PlotAdd("StartSpillPeakY_0",$maxTotalY,0); HPlot::PlotAdd("StartSpillSumY_0", $total_y_0+$total_y_1,0); # end changed @@ -956,7 +956,7 @@ while(1) { $str .= "
Last Sum".QA::SciNotation($total_y_0+$total_y_1); # end changed - $str .= "Last Duty".sprintf("%0.3f",($avgRate_y_0+$avgRate_y_1)/($maxTotalY||1)); + $str .= "Last Duty".sprintf("%0.3f",($avgRate_y_0+$avgRate_y_1)/$maxTotalY); $str .= "
Last Duration".$length_y_0; $str .= "Last Break".$offtime_y_0." s"; # $str .= "
Last Max".QA::SciNotation($max_y_0)." Hz (100ms)"; @@ -1049,7 +1049,7 @@ sub calculate_rates{ my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch}); $trbnet += $trbnet_endpoint_offset; my $hits = $current_readout->{$trbnet}->{value}->[$channel]//0; - my $hitdiff = ($hits & 0xffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xffffff); + my $hitdiff = ($hits & 0xfffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); $hitdiff +=2**24 if $hitdiff < 0; my $time = $current_readout->{$trbnet}->{time}->[$channel]; my $tdiff = ($time//0) - ($old->{$trbnet}->{time}->[$channel]//0); @@ -1089,7 +1089,7 @@ sub calculate_diff_time_and_sum { #print Dumper $old; #exit; # vdiff is difference in read out values (Read: ValueDifference) - my $vdiff = ($hits & 0xffffff) - (($old->{$trbnet}->{value}->[$channel]//0) & 0xffffff); + my $vdiff = ($hits & 0xfffffff) - (($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); $vdiff += 2**24 if $vdiff < 0; my $diff = $vdiff/($tdiff||1E6)*1E6; #print "vdiff: $vdiff, diff: $diff, tdiff: $tdiff\n"; @@ -1113,7 +1113,7 @@ sub calculate_weighted_sum_difference_from_mean{ my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch}); $trbnet += $trbnet_endpoint_offset; my $hits = $current_readout->{$trbnet}->{value}->[$channel]//0; - my $hitdiff = ($hits & 0xffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xffffff); + my $hitdiff = ($hits & 0xfffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); printf("%04x %04x\n",$trbnet,$channel) unless defined $hits; $hitdiff +=2**24 if $hitdiff < 0; my $time = $current_readout->{$trbnet}->{time}->[$channel]//0; -- 2.43.0