From 908ce49afa81a1285d202afdca80561372da9581 Mon Sep 17 00:00:00 2001 From: "hadaq@countinghouse" Date: Tue, 8 Jul 2014 16:52:03 +0200 Subject: [PATCH] Latest changes to hmon --- hmon/QA.pm | 2 +- hmon/hmon_hodo_hist.pl | 186 +++++++++++++++++++++++++----- hmon/hmon_logRpc.sh | 29 +++++ hmon/hmon_micro.pl | 60 ++++++++++ hmon/hmon_nxyter_status.pl | 86 ++++++++------ hmon/hmon_rate2.pl | 64 +++++++--- hmon/hmon_rpctof.pl | 63 ++++++++++ hmon/hmon_spill.pl | 3 +- hmon/hmon_starthist.pl | 6 +- hmon/hmon_trgsource.pl | 4 +- hmon/index.cgi | 2 +- hmon/permanent/hmon_archiver.pl | 0 hmon/permanent/hmon_eb_run.pl | 45 ++++++-- hmon/permanent/hmon_magnet.pl | 4 +- hmon/permanent/hmon_pionsupply.pl | 2 +- hmon/permanent/hmon_qa.pl | 2 +- 16 files changed, 456 insertions(+), 102 deletions(-) create mode 100755 hmon/hmon_logRpc.sh create mode 100755 hmon/hmon_micro.pl create mode 100755 hmon/hmon_rpctof.pl mode change 100644 => 100755 hmon/permanent/hmon_archiver.pl diff --git a/hmon/QA.pm b/hmon/QA.pm index 5852b8d..957ca2f 100644 --- a/hmon/QA.pm +++ b/hmon/QA.pm @@ -87,7 +87,7 @@ our @PionLvCurrLimits = (4,5,6); our @LimitTriggerPerSpill = (1000, 0, 0); -our $AcceleratorCycle = 12; +our $AcceleratorCycle = 7; use constant {CTSAddress => 0x0003}; ############################################################################### diff --git a/hmon/hmon_hodo_hist.pl b/hmon/hmon_hodo_hist.pl index 37eddf7..f2ddca0 100755 --- a/hmon/hmon_hodo_hist.pl +++ b/hmon/hmon_hodo_hist.pl @@ -36,6 +36,7 @@ $plot->{buffer} = 1; $plot->{xscale} = 5; $plot->{xlabel} = "Time [s]"; $plot->{ylabel} = "Hits [1/s]"; +$plot->{storable} = 1; HPlot::PlotInit($plot); my $plot3 = (); @@ -57,6 +58,7 @@ $plot3->{bartitle}->[0] = "Pi0 Y"; $plot3->{bartitle}->[1] = "Pi0 X"; $plot3->{bartitle}->[2] = "Pi1 Y"; $plot3->{bartitle}->[3] = "Pi1 X"; +$plot3->{storable} = 1; HPlot::PlotInit($plot3); my $plot4 = (); @@ -72,19 +74,19 @@ $plot4->{xlabel} = "Time [s]"; $plot4->{sizex} = 650; $plot4->{sizey} = 360; $plot4->{ymin} = 0; -$plot4->{ymax} = 2; $plot4->{buffer} = 1; -$plot4->{titles}->[0] = "Pi0 Y / Hodo"; -$plot4->{titles}->[1] = "Pi0 X / Hodo"; -$plot4->{titles}->[2] = "Pi1 Y / Hodo"; -$plot4->{titles}->[3] = "Pi1 X / Hodo"; +$plot4->{titles}->[0] = "Pi0 Y / Start"; +$plot4->{titles}->[1] = "Pi0 X / Start"; +$plot4->{titles}->[2] = "Pi1 Y / Start"; +$plot4->{titles}->[3] = "Pi1 X / Start"; +$plot4->{storable} = 1; HPlot::PlotInit($plot4); my $plot5 = (); $plot5->{name} = "HitSumHist"; $plot5->{file} = "files/HitSumHist"; $plot5->{entries} = 200; -$plot5->{curves} = 5; +$plot5->{curves} = 6; $plot5->{xscale} = 5; $plot5->{type} = HPlot::TYPE_HISTORY; $plot5->{output} = HPlot::OUT_PNG; @@ -98,19 +100,75 @@ $plot5->{titles}->[1] = "Pi0 X"; $plot5->{titles}->[2] = "Pi1 Y"; $plot5->{titles}->[3] = "Pi1 X"; $plot5->{titles}->[4] = "Hodo"; +$plot5->{titles}->[5] = "Start"; +$plot5->{storable} = 1; HPlot::PlotInit($plot5); +my $plot6 = (); +$plot6->{name} = "SpillSumHist"; +$plot6->{file} = "files/SpillSumHist"; +$plot6->{entries} = 30; +$plot6->{curves} = 4; +$plot6->{type} = HPlot::TYPE_HISTORY; +$plot6->{output} = HPlot::OUT_PNG; +$plot6->{ylabel} = "Hit Rate per spill (dark rate substracted)"; +$plot6->{xlabel} = "Spills"; +$plot6->{sizex} = 650; +$plot6->{sizey} = 360; +$plot6->{buffer} = 1; +$plot6->{titles}->[0] = "Pi1 Y"; +$plot6->{titles}->[1] = "Pi1 X"; +$plot6->{titles}->[2] = "Start"; +$plot6->{titles}->[3] = "Hodo"; +$plot6->{storable} = 1; +HPlot::PlotInit($plot6); + + +my $plot7 = (); +$plot7->{name} = "HitSumHistInner"; +$plot7->{file} = "files/HitSumHistInner"; +$plot7->{entries} = 200; +$plot7->{curves} = 4; +$plot7->{xscale} = 5; +$plot7->{type} = HPlot::TYPE_HISTORY; +$plot7->{output} = HPlot::OUT_PNG; +$plot7->{ylabel} = "Hit Rate (dark rate substracted)"; +$plot7->{xlabel} = "Time [s]"; +$plot7->{sizex} = 1050; +$plot7->{sizey} = 360; +$plot7->{buffer} = 1; +$plot7->{titles}->[0] = "Pi1 Y"; +$plot7->{titles}->[1] = "Pi1 X"; +$plot7->{titles}->[2] = "Hodo"; +$plot7->{titles}->[3] = "Start"; +$plot7->{storable} = 1; +HPlot::PlotInit($plot7); + +my $plot8 = (); +$plot8->{name} = "HitSumHistInnerShort"; +$plot8->{file} = "files/HitSumHistInnerShort"; +$plot8->{entries} = 100; +$plot8->{curves} = 4; +$plot8->{xscale} = 5; +$plot8->{type} = HPlot::TYPE_HISTORY; +$plot8->{output} = HPlot::OUT_PNG; +$plot8->{ylabel} = "Hit Rate (dark rate substracted)"; +$plot8->{xlabel} = "Time [s]"; +$plot8->{sizex} = 650; +$plot8->{sizey} = 360; +$plot8->{buffer} = 1; +$plot8->{titles}->[0] = "Pi1 Y"; +$plot8->{titles}->[1] = "Pi1 X"; +$plot8->{titles}->[2] = "Hodo"; +$plot8->{titles}->[3] = "Start"; +$plot8->{storable} = 1; +HPlot::PlotInit($plot8); my $str = Hmon::MakeTitle(11, 9, "Hodoscope Hit History"); $str .= qq@
\n@; $str .= Hmon::MakeFooter(); Hmon::WriteFile("HodoHist",$str); -#$str = Hmon::MakeTitle(9, 8, "Scintillator Hit History"); -#$str .= qq@
\n@; -#$str .= Hmon::MakeFooter(); -#Hmon::WriteFile("ScintiHist",$str); - $str = Hmon::MakeTitle(6, 8, "Hit Ratios"); $str .= qq@
\n@; $str .= Hmon::MakeFooter(); @@ -126,6 +184,21 @@ $str .= qq@
\n@; $str .= Hmon::MakeFooter(); Hmon::WriteFile("HitSumHist",$str); +$str = Hmon::MakeTitle(14, 8, "Hit Sums Inner"); +$str .= qq@
\n@; +$str .= Hmon::MakeFooter(); +Hmon::WriteFile("HitSumHistInner",$str); + +$str = Hmon::MakeTitle(9, 8, "Hit Sums Inner Short"); +$str .= qq@
\n@; +$str .= Hmon::MakeFooter(); +Hmon::WriteFile("HitSumHistInnerShort",$str); + +$str = Hmon::MakeTitle(9, 8, "Spill Sums"); +$str .= qq@
\n@; +$str .= Hmon::MakeFooter(); +Hmon::WriteFile("SpillSumHist",$str); + my $timer = 0; my $old; my $old2; @@ -136,21 +209,30 @@ my $diff2; my $iter = 0; my $offset; my $histstore; +my $spillsum; +$offset->{0x8880} = 0; $offset->{0x8890} = 0; $offset->{0x3800} = 0; $offset->{0x3801} = 0; $offset->{0x3810} = 0; $offset->{0x3811} = 0; +$spillsum->{0x8880} = 0; +$spillsum->{0x8890} = 0; +$spillsum->{0x3810} = 0; +$spillsum->{0x3811} = 0; + trb_init_ports() or die trb_strerror(); while (1) { my $o, my $o2; my $t; - foreach my $b (0x5010,0x5011,0x5012,0x5013) { + foreach my $b (0xfe48, 0xfe4e) { $t = trb_registertime_read_mem($b,0xc000,0,33); - $o->{$b} = $t->{$b}; + foreach my $a (keys %$t) { + $o->{$a} = $t->{$a}; + } } $t = trb_registertime_read(0xfe49,0x8130); if (defined $t) { @@ -206,20 +288,32 @@ while (1) { # HPlot::PlotAdd("ScintiHist",$diff->{0x5012}->[7],0); HPlot::PlotAdd("HodoHist",$total/2,8); - - + my $totalstart = 0; + for my $f (0..3) { + next if ($f == 1); + for my $s (0..15) { + $totalstart += $diff->{0x5000+$f}->[$s*2+1]; + } + } +# print $totalstart; - if($total > 300) { - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3800}->{0x8130}||0)-$offset->{0x3800})/(($total-$offset->{0x8890})||1),0); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3801}->{0x8130}||0)-$offset->{0x3801})/(($total-$offset->{0x8890})||1),1); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3810}->{0x8130}||0)-$offset->{0x3810})/(($total-$offset->{0x8890})||1),2); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3811}->{0x8130}||0)-$offset->{0x3811})/(($total-$offset->{0x8890})||1),3); + if($total > 1000) { + HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3800}->{0x8130}||0)-$offset->{0x3800})/(($totalstart-$offset->{0x8880})||1),0); + HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3801}->{0x8130}||0)-$offset->{0x3801})/(($totalstart-$offset->{0x8880})||1),1); + HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3810}->{0x8130}||0)-$offset->{0x3810})/(($totalstart-$offset->{0x8880})||1),2); + HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3811}->{0x8130}||0)-$offset->{0x3811})/(($totalstart-$offset->{0x8880})||1),3); - HPlot::PlotFill("HitRatios",(($diff2->{0x3800}->{0x8130}||0)-$offset->{0x3800})/(($total-$offset->{0x8890})||1),0); - HPlot::PlotFill("HitRatios",(($diff2->{0x3801}->{0x8130}||0)-$offset->{0x3801})/(($total-$offset->{0x8890})||1),1); - HPlot::PlotFill("HitRatios",(($diff2->{0x3810}->{0x8130}||0)-$offset->{0x3810})/(($total-$offset->{0x8890})||1),2); - HPlot::PlotFill("HitRatios",(($diff2->{0x3811}->{0x8130}||0)-$offset->{0x3811})/(($total-$offset->{0x8890})||1),3); + HPlot::PlotFill("HitRatios",(($diff2->{0x3800}->{0x8130}||0)-$offset->{0x3800})/(($totalstart-$offset->{0x8880})||1),0); + HPlot::PlotFill("HitRatios",(($diff2->{0x3801}->{0x8130}||0)-$offset->{0x3801})/(($totalstart-$offset->{0x8880})||1),1); + HPlot::PlotFill("HitRatios",(($diff2->{0x3810}->{0x8130}||0)-$offset->{0x3810})/(($totalstart-$offset->{0x8880})||1),2); + HPlot::PlotFill("HitRatios",(($diff2->{0x3811}->{0x8130}||0)-$offset->{0x3811})/(($totalstart-$offset->{0x8880})||1),3); + $spillsum->{0x3800} += (($diff2->{0x3800}->{0x8130}||0)-$offset->{0x3800})/5; + $spillsum->{0x3801} += (($diff2->{0x3801}->{0x8130}||0)-$offset->{0x3801})/5; + $spillsum->{0x3810} += (($diff2->{0x3810}->{0x8130}||0)-$offset->{0x3810})/5; + $spillsum->{0x3811} += (($diff2->{0x3811}->{0x8130}||0)-$offset->{0x3811})/5; + $spillsum->{0x8880} += (($totalstart||0)-$offset->{0x8880})/5; + $spillsum->{0x8890} += (($total||0)-$offset->{0x8890})/5/2; } else { HPlot::PlotAdd("HitRatioHist",0,0); @@ -232,30 +326,64 @@ while (1) { HPlot::PlotFill("HitRatios",0,2); HPlot::PlotFill("HitRatios",0,3); + $offset->{0x8880} += (($totalstart||0) - $offset->{0x8880})/32; $offset->{0x8890} += (($total||0) - $offset->{0x8890})/32; $offset->{0x3800} += (($diff2->{0x3800}->{0x8130}) - $offset->{0x3800})/32; $offset->{0x3801} += (($diff2->{0x3801}->{0x8130}) - $offset->{0x3801})/32; $offset->{0x3810} += (($diff2->{0x3810}->{0x8130}) - $offset->{0x3810})/32; $offset->{0x3811} += (($diff2->{0x3811}->{0x8130}) - $offset->{0x3811})/32; + if($spillsum->{0x3810} != 0) { + HPlot::PlotAdd('SpillSumHist',$spillsum->{0x3810},0); + HPlot::PlotAdd('SpillSumHist',$spillsum->{0x3811},1); + HPlot::PlotAdd('SpillSumHist',$spillsum->{0x8880},2); + HPlot::PlotAdd('SpillSumHist',$spillsum->{0x8890},3); + $spillsum->{0x8880} = 0; + $spillsum->{0x8890} = 0; + $spillsum->{0x3810} = 0; + $spillsum->{0x3811} = 0; + } } HPlot::PlotAdd('HitSumHist',(($diff2->{0x3800}->{0x8130})||0)-$offset->{0x3800},0); HPlot::PlotAdd('HitSumHist',(($diff2->{0x3801}->{0x8130})||0)-$offset->{0x3801},1); HPlot::PlotAdd('HitSumHist',(($diff2->{0x3810}->{0x8130})||0)-$offset->{0x3810},2); HPlot::PlotAdd('HitSumHist',(($diff2->{0x3811}->{0x8130})||0)-$offset->{0x3811},3); - HPlot::PlotAdd('HitSumHist',($total||0)-$offset->{0x8890},4); - - unless($timer++ % 5) { + HPlot::PlotAdd('HitSumHist',(($total||0)-$offset->{0x8890})/2,4); + HPlot::PlotAdd('HitSumHist',($totalstart||0)-$offset->{0x8880},5); + + HPlot::PlotAdd('HitSumHistInner',(($diff2->{0x3810}->{0x8130})||0)-$offset->{0x3810},0); + HPlot::PlotAdd('HitSumHistInner',(($diff2->{0x3811}->{0x8130})||0)-$offset->{0x3811},1); + HPlot::PlotAdd('HitSumHistInner',(($total||0)-$offset->{0x8890})/2,2); + HPlot::PlotAdd('HitSumHistInner',($totalstart||0)-$offset->{0x8880},3); + + HPlot::PlotAdd('HitSumHistInnerShort',(($diff2->{0x3810}->{0x8130})||0)-$offset->{0x3810},0); + HPlot::PlotAdd('HitSumHistInnerShort',(($diff2->{0x3811}->{0x8130})||0)-$offset->{0x3811},1); + HPlot::PlotAdd('HitSumHistInnerShort',(($total||0)-$offset->{0x8890})/2,2); + HPlot::PlotAdd('HitSumHistInnerShort',($totalstart||0)-$offset->{0x8880},3); + + + if($timer %5 == 0) { HPlot::PlotDraw('HodoHist'); -# HPlot::PlotDraw('ScintiHist'); + } + if($timer %5 == 1) { HPlot::PlotDraw('HitRatioHist'); + } + if($timer %5 == 2) { HPlot::PlotDraw('HitRatios'); + } + if($timer %5 == 3) { HPlot::PlotDraw('HitSumHist'); + HPlot::PlotDraw('HitSumHistInner'); + } + if($timer %5 == 4) { + HPlot::PlotDraw('HitSumHistInnerShort'); + HPlot::PlotDraw('SpillSumHist'); } + $timer++; } $old = $o; $old2 = $o2; - usleep(200000); + usleep(200000); #Change also scale for SpillSum!! } diff --git a/hmon/hmon_logRpc.sh b/hmon/hmon_logRpc.sh new file mode 100755 index 0000000..f25dbcc --- /dev/null +++ b/hmon/hmon_logRpc.sh @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Data::Dumper; +use Hmon; +use QA; +use HADES::TrbNet; +use POSIX qw(strftime); +my $fh; + + +trb_init_ports() or die trb_strerror(); + +while (1) { + my $o = trb_register_read_mem(0x0003,0xa01e,0,6); + + my $str = ""; + $str .= strftime("%Y.%m.%d %H:%M:%S",localtime())."\t"; + $str .= time()."\t"; + for my $i (0..5) { + $str .= sprintf("%u\t",$o->{3}->[$i]); + } + $str .= "\n"; + open($fh, ">>",Hmon::HMONDIR."/archive/rpcscalerlog.csv"); + print $fh $str; + close $fh; + sleep(1); + } \ No newline at end of file diff --git a/hmon/hmon_micro.pl b/hmon/hmon_micro.pl new file mode 100755 index 0000000..203e3b8 --- /dev/null +++ b/hmon/hmon_micro.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl -w + +use warnings; +use Time::HiRes qw(usleep); +use Data::Dumper; +use Hmon; +use QA; +use HADES::TrbNet; +use HPlot; + + +my $plot = (); +$plot->{name} = "SpillStructure"; +$plot->{file} = "files/SpillStructure"; +$plot->{entries} = 1023; +$plot->{type} = HPlot::TYPE_HISTORY; +$plot->{output} = HPlot::OUT_PNG; +$plot->{titles}->[0] = ""; +$plot->{xlabel} = "Sample (default: 1 ms)"; +$plot->{ylabel} = "Hits / bin"; +$plot->{sizex} = 1050; +$plot->{sizey} = 270; +$plot->{nokey} = 1; +$plot->{buffer} = 1; +HPlot::PlotInit($plot); +my $str = Hmon::MakeTitle(14,6,"Spill Structure",0); + $str .= qq@@; + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("SpillStructure",$str); + +# my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; + +trb_init_ports() or die trb_strerror(); + +while (1) { + trb_register_setbit(0x8880,0xcf8f,1); + my $a = trb_register_read(0x8880,0xcf82); + my $length = $a->{0x8880}; + if($length > 0 && $length < 1E6) { + $length = $length/100*1024; + if($length < 500000) {$length = 500000;} + usleep($length); + } + else { sleep(5); next;} + my $o = trb_register_read_mem(0x8880,0xcfa0,1,1024); +# print Dumper $o; + my $last = $o->{0x8880}->[0]; + for my $i (1..1023) { + my $val = $o->{0x8880}->[$i]; + next unless defined $val; + $val &= 0x00ffffff; + if (defined $last) { + while($last > $val) {$val += 0x40000;} + HPlot::PlotFill('SpillStructure',($val-$last),$i,0) + } + $last = $val; + } + HPlot::PlotDraw('SpillStructure'); + } + diff --git a/hmon/hmon_nxyter_status.pl b/hmon/hmon_nxyter_status.pl index 45c4184..5e2ff60 100755 --- a/hmon/hmon_nxyter_status.pl +++ b/hmon/hmon_nxyter_status.pl @@ -13,38 +13,58 @@ trb_init_ports() or die trb_strerror(); while (1) { - # Default Output Values - my $title = "NX Status"; - my $shorttext = ""; - my $longtext = "Status of all Nxyter FEBs"; - my $status = QA::OK; - - # Read Status Register of all Nxyter - my $rh_status = trb_register_read(0xfe49, 0x810c) - or sleep $SLEEP_TIME and next; - - my $error_ctr = 0; - my $error_msg = ""; - - foreach my $board (sort {$a <=> $b} keys %$rh_status) { - if ($rh_status->{$board} > 0) { - $error_msg = $error_msg . - sprintf " - 0x%04x: 0x%02x", $board, $rh_status->{$board}; - $error_ctr++; + # Default Output Values + my $title = "NX Status"; + my $shorttext = ""; + my $longtext = "Status of all Nxyter FEBs -- "; + my $status = QA::OK; + + # Read Status Register of all Nxyter + my $rh_status = trb_register_read(0xfe49, 0x810c) + or sleep $SLEEP_TIME and next; + + my $status_receiver_ctr = 0; + my $status_validate_ctr = 0; + my $status_evtbuffer_ctr = 0; + my $status_receiver = "DataReceiver: "; + my $status_validate = "DataValidate: "; + my $status_evtbuffer = "EventBuffer: "; + + foreach my $board (sort {$a <=> $b} keys %$rh_status) { + if (($rh_status->{$board} & 0x01) != 0) { + $status_receiver = $status_receiver . + sprintf " 0x%04x", $board; + $status_receiver_ctr++; + } + if (($rh_status->{$board} & 0x02) != 0) { + $status_validate = $status_validate . + sprintf " 0x%04x", $board; + $status_validate_ctr++; + } + if (($rh_status->{$board} & 0x04) != 0) { + $status_evtbuffer = $status_evtbuffer . + sprintf " 0x%04x", $board; + $status_evtbuffer_ctr++; + } + } + + # Create Output Messages + if (($status_receiver_ctr > 0) || ($status_evtbuffer_ctr > 0) ) { + $status = QA::FATAL; + } elsif ($status_validate_ctr > 0) { + $status = QA::NOTE; + } + + if ($status != QA::OK) { + $shorttext = "R:${status_receiver_ctr} V:${status_validate_ctr} E:${status_evtbuffer_ctr}"; + $longtext = $longtext . " ${status_receiver} -- ${status_validate} -- ${status_evtbuffer} "; + } else { + $shorttext = "OK"; + $longtext = $longtext . "all is fine"; } - } - - # Create Output Messages - if (($error_ctr > 0)) { - $shorttext = "Errors: ${error_ctr}"; - - $longtext = "Errors on: "; - $longtext = $longtext . $error_msg; - $status = QA::WARN; - } - - QA::WriteQALog($flog, "pion", "nxstatus", $SLEEP_TIME * 2, - $status, $title, $shorttext, $longtext); - - sleep $SLEEP_TIME; + + QA::WriteQALog($flog, "pion", "nxstatus", $SLEEP_TIME * 2, + $status, $title, $shorttext, $longtext); + + sleep $SLEEP_TIME; } diff --git a/hmon/hmon_rate2.pl b/hmon/hmon_rate2.pl index a24f31c..726fbe1 100755 --- a/hmon/hmon_rate2.pl +++ b/hmon/hmon_rate2.pl @@ -3,7 +3,9 @@ use warnings; use strict; use Hmon; +use Data::Dumper; use HADES::TrbNet; +use List::Util qw[min max]; use QA; trb_init_ports() or die trb_strerror(); @@ -11,6 +13,24 @@ trb_init_ports() or die trb_strerror(); my $flog = Hmon::OpenLogfile(); my $fqa = QA::OpenQAFile(); +my $offset; + +sub getCorrected { + my ($val,$cor) = @_; + my $value = max($val-$cor,0); + if ($value < $cor/20) {$value = 0;} + return QA::SciNotation($value); + } + +sub getCorrectedValue { + my ($val,$cor) = @_; + my $value = max($val-$cor,0); + if ($value < $cor/20) {$value = 0;} + return $value; + } + + + while (1) { my $rh_rate; $rh_rate = trb_register_read_mem(0x0003, 0xa001, 0, 0xff) or sleep 5 and next; @@ -104,42 +124,52 @@ while (1) { my $shorttext; my $longtext; my $state; + my $oos; + + #Out of spill? + if($store{0xa029} < 20) { + for my $b (0xa029, 0xa02a, 0xa02b, 0xa024, 0xa009, 0xa03c, 0xa037) { + $offset->{$b} = ($offset->{$b}||0) + (($store{$b}||0) - ($offset->{$b}||0))/10; + } +# print Dumper $offset; + } + $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa029})."Hz"; - $longtext = sprintf("Trigger Rate from Hodoscope %i Hz",$store{0xa029}); + $shorttext = QA::SciNotation($store{0xa029})." / ".getCorrected($store{0xa029},$offset->{0xa029}); + $longtext = sprintf("Trigger Rate from Hodoscope %i Hz / %i Hz after offset correction",$store{0xa029}, getCorrectedValue($store{0xa029},$offset->{0xa029}) ); QA::WriteQALog($fqa, "rate", "hodo", 10, $state, 'Hodo Rate', $shorttext, $longtext); $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa02a})."Hz"; - $longtext = sprintf("Trigger Rate from Pion 1: %i Hz",$store{0xa02a}); - QA::WriteQALog($fqa, "rate", "pion1", 10, - $state, 'Pion1 Rate', $shorttext, $longtext); - - $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa02b})."Hz"; - $longtext = sprintf("Trigger Rate from Pion 2: %i Hz",$store{0xa02b}); + $shorttext = QA::SciNotation($store{0xa02a})." / ".getCorrected($store{0xa02a},$offset->{0xa02a}); + $longtext = sprintf("Trigger Rate from Pion 2: %i Hz / %i Hz after offset correction",$store{0xa02a}, getCorrectedValue($store{0xa02a},$offset->{0xa02a}) ); QA::WriteQALog($fqa, "rate", "pion2", 10, $state, 'Pion2 Rate', $shorttext, $longtext); + + $state = QA::OK; + $shorttext = QA::SciNotation($store{0xa02b})." / ".getCorrected($store{0xa02b},$offset->{0xa02b}); + $longtext = sprintf("Trigger Rate from Pion 1: %i Hz / %i Hz after offset correction",$store{0xa02b}, getCorrectedValue($store{0xa02b},$offset->{0xa02b}) ); + QA::WriteQALog($fqa, "rate", "pion1", 10, + $state, 'Pion1 Rate', $shorttext, $longtext); $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa024})."Hz"; - $longtext = sprintf("Trigger Rate from PT1: %i Hz",$store{0xa024}); + $shorttext = QA::SciNotation($store{0xa024})." / ".getCorrected($store{0xa024},$offset->{0xa024}); + $longtext = sprintf("Trigger Rate from PT1: %i Hz / %i Hz after offset correction",$store{0xa024}, getCorrectedValue($store{0xa024},$offset->{0xa024})); QA::WriteQALog($fqa, "rate", "pt1", 10, $state, 'PT1 Rate', $shorttext, $longtext); $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa009})."Hz"; - $longtext = sprintf("Trigger Rate from Start: %i Hz",$store{0xa009}); + $shorttext = QA::SciNotation($store{0xa009})." / ".getCorrected($store{0xa009},$offset->{0xa009}); + $longtext = sprintf("Trigger Rate from Start: %i Hz / %i Hz after offset correction",$store{0xa009}, getCorrectedValue($store{0xa009},$offset->{0xa009})); QA::WriteQALog($fqa, "rate", "start", 10, $state, 'Start Rate', $shorttext, $longtext); $state = QA::OK; - $shorttext = QA::SciNotation(($store{0xa03c}-8)/(($store{0xa037}-2100)||1)); - $longtext = sprintf("Trigger Rate from PT1/TOF vs. Hodoscope: %.2f",($store{0xa03c}-8)/(($store{0xa037}-2100)||1)); + $shorttext = sprintf('%.2f',getCorrectedValue($store{0xa024},$offset->{0xa024})/(getCorrectedValue($store{0xa009},$offset->{0xa009})||1)); + $longtext = "Trigger Rate from PT1 vs. Start: ".$shorttext; QA::WriteQALog($fqa, "trg", "pt1rate", 10, - $state, 'Hodo/PT1', $shorttext, $longtext); + $state, 'Start/PT1', $shorttext, $longtext); sleep 1; } diff --git a/hmon/hmon_rpctof.pl b/hmon/hmon_rpctof.pl new file mode 100755 index 0000000..735b5bf --- /dev/null +++ b/hmon/hmon_rpctof.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w + +use warnings; +use Time::HiRes qw(usleep); +use Data::Dumper; +use Hmon; +use QA; +use HADES::TrbNet; +use HPlot; + + +my $plot = (); +$plot->{name} = "RpcTofRate"; +$plot->{file} = "files/RpcTofRate"; +$plot->{entries} = 60; +$plot->{curves} = 2; +$plot->{type} = HPlot::TYPE_HISTORY; +$plot->{output} = HPlot::OUT_PNG; +$plot->{titles}->[0] = "Current"; +$plot->{titles}->[1] = "Average"; +$plot->{xlabel} = "Time [s]"; +$plot->{ylabel} = "Count"; +$plot->{sizex} = 650; +$plot->{sizey} = 370; +$plot->{nokey} = 0; +$plot->{buffer} = 1; +$plot->{storable}= 1; +HPlot::PlotInit($plot); +my $str = Hmon::MakeTitle(9,8,"RpcTofRate",0); + $str .= qq@@; + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("RpcTofRate",$str); + +# my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; + +trb_init_ports() or die trb_strerror(); + +my @values; + +while (1) { + my $o = trb_register_read_mem(0x3,0xa018,0,12); + my $value = 0; + my $average = 0; + + for my $v (@{$o->{3}}) { + $value += $v; + } + + + push(@values,$value); + shift(@values) if (scalar @values) >= 15; + + for my $v (@values) { + $average += $v; + } + $average /= scalar @values; + + HPlot::PlotAdd('RpcTofRate',($value),0); + HPlot::PlotAdd('RpcTofRate',($average),1); + HPlot::PlotDraw('RpcTofRate'); + sleep(1); + } + diff --git a/hmon/hmon_spill.pl b/hmon/hmon_spill.pl index 720e95f..791c9cd 100755 --- a/hmon/hmon_spill.pl +++ b/hmon/hmon_spill.pl @@ -34,6 +34,7 @@ $plot->{ylabel} = "Recorded Events / Spill (1000)"; $plot->{sizex} = 630; $plot->{sizey} = 220; $plot->{nokey} = 1; +$plot->{storable} = 1; HPlot::PlotInit($plot); my $str = Hmon::MakeTitle(8,5,"Recorded Events per Spill (1000)",0); $str .= qq@@; @@ -115,7 +116,7 @@ while (1) { $errtime++; } elsif ($errtime > 1) { - $errtime--; + $errtime-=2; } $qastate = QA::WARN if $errtime > 10; ##################### diff --git a/hmon/hmon_starthist.pl b/hmon/hmon_starthist.pl index 3556c37..49bb985 100755 --- a/hmon/hmon_starthist.pl +++ b/hmon/hmon_starthist.pl @@ -68,9 +68,9 @@ if($plots) { } else { qx(./hmon_hadplot_old.sh -d 3000 \\ - -a 0x0003 -r 53216 -m 500 -p 0 -w 32 -t "Hodo" \\ - -a 0x0003 -r 53716 -m 500 -p 0 -w 32 -t "PionC" \\ - -ytitle "Hits / 10 us" \\ + -a 0x0003 -r 41216 -m 500 -p 0 -w 32 -t "MuxA" \\ + -a 0x0003 -r 41716 -m 500 -p 0 -w 32 -t "MuxB" \\ + -ytitle "Hits / bin" \\ -output "PNG.files/hodofinehist.760.365" -curvestyle steps -key genreg 2>/dev/null & ); diff --git a/hmon/hmon_trgsource.pl b/hmon/hmon_trgsource.pl index 030a273..5a213a4 100755 --- a/hmon/hmon_trgsource.pl +++ b/hmon/hmon_trgsource.pl @@ -201,8 +201,8 @@ my $longmsgcheck = $longmsg; if($outofspill && !$lastoutofspill ) { $lastaccpt3 = $pt3sum / ($accpt3sum||1)*100; - HPlot::PlotAdd("Pt3AcceptRatio",$lastaccpt3); - HPlot::PlotDraw("Pt3AcceptRatio"); + HPlot::PlotAdd("Pt1AcceptRatio",$lastaccpt3); + HPlot::PlotDraw("Pt1AcceptRatio"); $pt3sum = 0; $accpt3sum = 0; } diff --git a/hmon/index.cgi b/hmon/index.cgi index 2fea507..fc69823 100755 --- a/hmon/index.cgi +++ b/hmon/index.cgi @@ -72,7 +72,7 @@ function openwin(url) {
  • Recorded events per spill
  • -
  • Start hit count histograms
  • +
  • Spill Structure from Start
  • CTS mux output histograms
  • CTS mux output ratio histo.
  • diff --git a/hmon/permanent/hmon_archiver.pl b/hmon/permanent/hmon_archiver.pl old mode 100644 new mode 100755 diff --git a/hmon/permanent/hmon_eb_run.pl b/hmon/permanent/hmon_eb_run.pl index 493859c..304f4fb 100755 --- a/hmon/permanent/hmon_eb_run.pl +++ b/hmon/permanent/hmon_eb_run.pl @@ -23,6 +23,9 @@ my @ebrates = (); my ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = (0,0,0); my ($cnterrtype9,$cnterrtypeE) = (50,50); my $lasttotalbytes = 21; +my @ebrecvhist; +my @byteshist; + sub cntbits32 { return (unpack('%32b*', pack('i',$_[0]))); @@ -62,8 +65,8 @@ while(1) { my $evtrate = 0; my $qastatedisc = QA::OK; my $qamsgdisc = ""; - my $evtavgspill, my $evtavg3; - my $byteavg3, my $byteavgspill; + my $evtavgspill; + my $ebavgbytes; my $ebavgrate = 0; my $trbneterr = 0; my $sumtype1 = 0; @@ -85,8 +88,7 @@ while(1) { $events = $res; pop(@evtrates) if scalar @evtrates >= $QA::AcceleratorCycle * 2; unshift(@evtrates,$evtrate); - $evtavg3 = $evtrates[0] + $evtrates[1] + $evtrates[2]; - $evtavg3 /= 3; + $evtavgspill += $_ for @evtrates; $evtavgspill /= scalar @evtrates; @@ -117,9 +119,23 @@ while(1) { $ebavgrate += $_ for @ebrates; $ebavgrate /= scalar @ebrates; + pop(@byteshist) if scalar @byteshist >= $QA::AcceleratorCycle * 2; + unshift(@byteshist,$totalbytes); + $ebavgbytes += $_ for @byteshist; + $ebavgbytes /= scalar @byteshist; + my $totalrateavg = 0; + + $totalrateavg += $_ for @ebrates; + my $act = cntbits32($actmask); my $sent = cntbits32($sentmask); + + pop(@ebrecvhist) if scalar @ebrecvhist >= $QA::AcceleratorCycle * 2; + unshift(@ebrecvhist,$recvmask); + + for my $m (@ebrecvhist) { $recvmask |= $m;} my $recv = cntbits32($recvmask); + my $mismatch_sr = 0; my $mismatch_sa = 0; for(my $i=0;$i<16;$i++) { @@ -175,7 +191,8 @@ while(1) { } if ($qamsg eq "") {$qamsg = "No error found";} if ($qastate == QA::OK) { - $qamsg .= sprintf(". Total rate: %i, 2-spill average: %i, total per EB: %i", $totalrate,$ebavgrate,$totalrate/($recv || $totalrate || 1)); + $qamsg .= sprintf(". Total rate: %i, 4-spill average: %i, total per EB: %i", + $totalrate,$ebavgrate,$totalrate/($recv || $totalrate || 1)); } $qamsgdisc = "Discarded events: $totaldiscarded - ".$qamsgdisc; @@ -205,8 +222,8 @@ while(1) { $ratetype9 = $sumtype9 - $oldsumtype9 unless ($oldsumtype9 > $sumtype9); $ratetypeE = $sumtypeE - $oldsumtypeE unless ($oldsumtypeE > $sumtypeE); - $cnterrtype9 += -0.8+$ratetype9 if $evtrate > $act*32; - $cnterrtypeE += -0.8+$ratetypeE if $evtrate > $act*32; + $cnterrtype9 += -0.8+$ratetype9 ;#if $evtrate > $act*32; + $cnterrtypeE += -0.8+$ratetypeE ;#if $evtrate > $act*32; if($oldsumtype1 > $sumtype1) { $cnterrtype9 = 50; $cnterrtypeE = 50; @@ -215,14 +232,19 @@ while(1) { $qastate = QA::OK; # $qastate = QA::WARN if $ebavgrate <= 0; - my $evtavgshort = sprintf("%i MB - %i kB",$totalbytes/1024,$totalbytes/($totalrate || $totalbytes || 1)); - my $evtavglong = sprintf("%i MB/s - %i kB/evt - %i Evt/EB/s",$totalbytes/1024,$totalbytes/($totalrate || $totalbytes || 1),$totalrate/($recv || $totalrate || 1)); - $evtavglong .= sprintf(" - MDC Calib Evt: %i (%i/s) - Status Evt: %i (%i/s)", + my $evtavgshort = sprintf("%i MB - %i kB",$ebavgbytes/1024,$ebavgbytes/($ebavgrate || $ebavgbytes || 1)); + my $evtavglong = sprintf("Current: %i MB/s - %i kB/evt / Averaged: %i MB/s - %i kB/evt
    %i Evt/EB/s", + $totalbytes/1024, + $totalbytes/($totalrate || $totalbytes || 1), + $ebavgbytes/1024, + $ebavgbytes/($ebavgrate || $ebavgbytes || 1), + $totalrate/($recv || $totalrate || 1)); + $evtavglong .= sprintf("
    MDC Calib Evt: %i (%i/s) - Status Evt: %i (%i/s)", $sumtype9,$ratetype9,$sumtypeE,$ratetypeE); if($cnterrtypeE < 30 || $cnterrtype9 < 30) { $qastate = QA::WARN_2; - $evtavglong .= " - Number of special triggers is not correct (debug $cnterrtype9 $cnterrtypeE)"; + $evtavglong .= "
    Number of special triggers is not correct (debug $cnterrtype9 $cnterrtypeE)"; } if($totalbytes < 20 && $lasttotalbytes <20) { $qastate = QA::WARN_2; @@ -230,6 +252,7 @@ while(1) { if($trbneterr == 0) { QA::WriteQALog($fqa,"eb","bytes",5,$qastate,"Data Rate",$evtavgshort,$evtavglong); +# print $evtavglong."\n"; } else { QA::WriteQALog($fqa,"eb","bytes",30,QA::NA,"Data Rate","N/A","N/A"); diff --git a/hmon/permanent/hmon_magnet.pl b/hmon/permanent/hmon_magnet.pl index e8b72ff..052b767 100755 --- a/hmon/permanent/hmon_magnet.pl +++ b/hmon/permanent/hmon_magnet.pl @@ -9,7 +9,7 @@ use QA; use Getopt::Long; use Data::Dumper; -my $magnet_on = 0; +my $magnet_on = 1; my %range_list = ( 'Time' => {}, @@ -32,7 +32,7 @@ my %range_list = ( 'FI1400' => {'min' => 0.36 , 'max' =>0.49 }, 'PSUI_rbk' => {'min' => 2495 , 'max' =>2497 }, 'PSUV_rbk' => {'min' => 0 , 'max' =>1 }, - 'BBI' => {'min' => -450 , 'max' =>-419.0}, + 'BBI' => {'min' => 419 , 'max' =>450 }, 'LL1708' => {'min' => 55.2 , 'max' =>63.0 }, 'TP1240' => {'min' => 75.5 , 'max' =>85.0 , 'cal_max' => 2}, 'PI2610' => {'min' => 1.7 , 'max' =>3.1 }, diff --git a/hmon/permanent/hmon_pionsupply.pl b/hmon/permanent/hmon_pionsupply.pl index 879289e..7eb2a2c 100755 --- a/hmon/permanent/hmon_pionsupply.pl +++ b/hmon/permanent/hmon_pionsupply.pl @@ -99,7 +99,7 @@ while(1) { $state = QA::WARN if($val[47]>-15 || $val[53]>-15); - QA::WriteQALog($flog, "pion", "cooling", 30, + QA::WriteQALog($flog, "pion", "cooling", 120, $state, 'Pion Cool', $shorttext, $longtext); } diff --git a/hmon/permanent/hmon_qa.pl b/hmon/permanent/hmon_qa.pl index f66575d..d72a48c 100755 --- a/hmon/permanent/hmon_qa.pl +++ b/hmon/permanent/hmon_qa.pl @@ -43,7 +43,7 @@ while($a = ) { #Generate output file at most once per second if($oldtime < time) { $oldtime = scalar time(); - $str = Hmon::MakeTitle(7,11,"Tactical Overview",1); + $str = Hmon::MakeTitle(7,12,"Tactical Overview",1); $str .= "
    "; foreach my $c (@{$entries->{'cats'}}) { $str .= "
    $cats->{$c}
    \n"; -- 2.43.0