From df6efa6d05c7e240d89b99f86ab8fbd7ef572872 Mon Sep 17 00:00:00 2001 From: "hadaq@countinghouse" Date: Tue, 10 Jun 2014 16:11:11 +0200 Subject: [PATCH] updated hmon files --- hmon/HPlot.pm | 6 +- hmon/QA.pm | 14 +- hmon/hmon_busynew.pl | 6 +- hmon/hmon_diamond.pl | 21 +- hmon/hmon_endpoints.pl | 70 +- hmon/hmon_hadplot.sh | 1456 +--------------------------- hmon/hmon_hodo.pl | 12 +- hmon/hmon_hodo_hist.pl | 222 ++++- hmon/hmon_mdchv_plottemplate.pl | 54 +- hmon/hmon_pionadc.pl | 110 ++- hmon/hmon_pionovfl.pl | 125 +++ hmon/hmon_pionpileup.pl | 125 +++ hmon/hmon_pionrate.pl | 157 +-- hmon/hmon_pionts.pl | 126 +++ hmon/hmon_rate2.pl | 6 + hmon/hmon_starthist.pl | 104 +- hmon/hmon_trgsource.pl | 30 +- hmon/index.cgi | 17 +- hmon/monitor.cgi | 3 + hmon/permanent/hmon_archiver.pl | 0 hmon/permanent/hmon_mdchv.pl | 108 ++- hmon/permanent/hmon_mdcpressure.pl | 4 +- hmon/permanent/hmon_pionsupply.pl | 19 +- hmon/start.sh | 9 +- 24 files changed, 1062 insertions(+), 1742 deletions(-) mode change 100644 => 100755 hmon/hmon_diamond.pl mode change 100755 => 120000 hmon/hmon_hadplot.sh create mode 100755 hmon/hmon_pionovfl.pl create mode 100755 hmon/hmon_pionpileup.pl create mode 100755 hmon/hmon_pionts.pl mode change 100644 => 100755 hmon/hmon_starthist.pl mode change 100755 => 100644 hmon/permanent/hmon_archiver.pl diff --git a/hmon/HPlot.pm b/hmon/HPlot.pm index 6230a67..26af668 100755 --- a/hmon/HPlot.pm +++ b/hmon/HPlot.pm @@ -135,7 +135,8 @@ sub PlotInit { elsif($p->{$name}->{type} == TYPE_BARGRAPH) { plot_write($fh,"set style fill solid 1.00 border -1"); plot_write($fh,"set grid noxtics ytics"); - plot_write($fh,"set boxwidth 4 absolute"); + plot_write($fh,"set boxwidth ".($p->{$name}->{curvewidth}||4)." absolute"); + plot_write($fh,"set style histogram gap ".($p->{$name}->{bargap}||1)); if(defined $p->{$name}->{bartitle} && scalar @{$p->{$name}->{bartitle}}) { plot_write($fh,"set xtics (",1); for(my $j=0; $j{$name}->{bartitle}};$j++) { @@ -199,7 +200,7 @@ sub PlotDraw { if($p->{$name}->{type} == TYPE_BARGRAPH) { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=0; $i< $p->{$name}->{entries}; $i++) { - plot_write($p->{$name}->{fh},$p->{$name}->{value}->[$j]->[$i]+1E-9); + plot_write($p->{$name}->{fh},' '.$p->{$name}->{value}->[$j]->[$i]); } plot_write($p->{$name}->{fh},"e"); } @@ -207,7 +208,6 @@ sub PlotDraw { if($p->{$name}->{type} == TYPE_HEATMAP) { -# for(my $s=0; $s<=$p->{$name}->{showvalues}; $s++) { for(my $j=0; $j<$p->{$name}->{curves}; $j++) { for(my $i=0; $i< $p->{$name}->{entries}; $i++) { plot_write($p->{$name}->{fh},($p->{$name}->{value}->[$j]->[$i]||0)." ",1); diff --git a/hmon/QA.pm b/hmon/QA.pm index c6ad492..9e22721 100644 --- a/hmon/QA.pm +++ b/hmon/QA.pm @@ -11,7 +11,7 @@ our $cats = {'main'=>"Main", 'rate'=>"Rate", 'server'=>"Srv", 'eb'=>"EB", -# 'mdc'=>"MDC", + 'mdc'=>"MDC", 'endp'=>"Endp", 'feeerr'=>"Fee", 'other'=>"Other", @@ -24,7 +24,7 @@ our $entries->{'cats'} = ["main", "rate", "server", "eb", -# "mdc", + "mdc", "endp", "feeerr", "pion", @@ -34,15 +34,15 @@ our $entries->{'cats'} = ["main", # Order of entries in each cat $entries->{'main'} = ['time', 'rate','onlineqa','up']; $entries->{'daq'} = ['trbnet', 'timeouts', 'busy','readout']; -$entries->{'trg'} = ['spill', 'source']; #, 'accepted', 'ptrate', 'start' +$entries->{'trg'} = ['spill', 'source','pt1rate', 'start']; #, 'accepted' $entries->{'rate'} = ['pt1','start','hodo','pion1','pion2']; $entries->{'server'} = ['fill', 'cpu', 'icinga', 'etrax', 'pwrsup']; $entries->{'eb'} = ['run', 'rate','bytes', 'lostevt', 'errbits']; -#$entries->{'mdc'} = ['token', 'blocked', 'temp', 'linkqual', 'voltage']; -$entries->{'endp'} = ['rich', 'tof', 'rpc', 'other']; #'mdc' +$entries->{'mdc'} = ['token', 'blocked', 'temp', 'linkqual', 'voltage']; +$entries->{'endp'} = ['mdc','rich', 'tof', 'rpc', 'other']; $entries->{'feeerr'} = ['rich', 'trb', 'feeerr','trginp','trgqual']; -$entries->{'other'} = ['speech','rich']; #'magnet','mdcinvalid','shower' -$entries->{'pion'} = ['nxstatus', 'HV', 'cooling']; +$entries->{'other'} = ['speech','rich','mdcinvalid']; #'magnet','shower' +$entries->{'pion'} = ['nxstatus', 'HV', 'HVcurr', 'cooling']; our $QAServer = "hades33"; diff --git a/hmon/hmon_busynew.pl b/hmon/hmon_busynew.pl index 65d07e3..dd27ca6 100755 --- a/hmon/hmon_busynew.pl +++ b/hmon/hmon_busynew.pl @@ -101,12 +101,12 @@ while (1) { if (defined $old) { foreach my $b (keys %$o) { for my $v (0..7) { - my $tdiff = $o->{$b}->{time}->[$v] - $old->{$b}->{time}->[$v]; + my $tdiff = ($o->{$b}->{time}->[$v]||0) - ($old->{$b}->{time}->[$v]||0); if ($tdiff < 0) { $tdiff += 2**16;} $tdiff *= 16; - my $vdiff = $o->{$b}->{value}->[$v] - $old->{$b}->{value}->[$v]; + my $vdiff = ($o->{$b}->{value}->[$v]||0) - ($old->{$b}->{value}->[$v]||0); if ($vdiff < 0) { $vdiff += 2**32;} - $diff->{$b}->[$v] = $vdiff/($tdiff|1); + $diff->{$b}->[$v] = $vdiff/($tdiff||1); } } diff --git a/hmon/hmon_diamond.pl b/hmon/hmon_diamond.pl old mode 100644 new mode 100755 index bb06b48..a97b324 --- a/hmon/hmon_diamond.pl +++ b/hmon/hmon_diamond.pl @@ -77,28 +77,28 @@ Hmon::WriteFile("DiamondRate",$str); # 4 1 19 1 1 1 1 1 2 5000 03 # 4 2 20 1 1 9 9 1 6 5000 0b # 4 3 21 2 1 7 7 2 5 5000 19 -# 4 4 22 2 3 13 13 6 8 5003 1f -# 4 5 23 1 3 7 7 5 5 5003 09 !!!!!! +# 4 4 22 2 3 13 13 6 2 5003 13 +# 4 5 23 1 3 7 7 5 5 5003 09 # 4 6 24 1 2 13 13 3 8 5002 0f # 5 1 25 2 1 5 5 2 4 5000 17 -# 5 2 26 2 3 11 11 6 7 5003 1d +# 5 2 26 2 3 11 11 6 3 5003 15 # 5 3 27 1 1 5 5 1 4 5000 07 # 5 4 28 1 3 9 9 5 4 5003 07 -# 5 5 29 2 3 1 3 6 3 5003 15 -# 5 6 30 2 3 3 5 6 4 5003 17 +# 5 5 29 2 3 1 3 6 7 5003 1d +# 5 6 30 2 3 3 5 6 4 5003 1b # 6 1 31 2 1 1 1 2 2 5000 13 # 6 2 32 2 1 3 3 2 3 5000 15 # 6 3 33 1 3 13 13 5 2 5003 03 # 6 4 34 1 3 11 11 5 3 5003 05 -# 6 5 35 2 3 9 9 6 6 5003 1b -# 6 6 36 2 3 7 7 6 5 5003 19 !!!!!! +# 6 5 35 2 3 9 9 6 4 5003 17 +# 6 6 36 2 3 7 7 6 5 5003 19 my $fpga = [[0, 2, 2, 2, 2, 2 ],[0, 0, 0, 2, 2, 2 ],[0, 0, 2, 2, 2, 2 ], [0, 0, 0, 3, 3, 2 ],[0, 3, 0, 3, 3, 3 ],[0, 0, 3, 3, 3, 3 ]]; my $chan = [[0x1f,0x17,0x07,0x03,0x19,0x1d],[0x1d,0x1b,0x0f,0x05,0x15,0x1f],[0x05,0x0d,0x13,0x1b,0x0d,0x0b], - [0x03,0x0b,0x19,0x1f,0x09,0x0f],[0x17,0x1d,0x07,0x07,0x15,0x17],[0x13,0x15,0x03,0x05,0x1b,0x19]]; + [0x03,0x0b,0x19,0x13,0x09,0x0f],[0x17,0x15,0x07,0x07,0x1d,0x1b],[0x13,0x15,0x03,0x05,0x17,0x19]]; my $old; my $oldtime = time(); @@ -106,12 +106,13 @@ my $time = time(); my $diff; my $iter = 0; +$ENV{'DAQOPSERVER'} = "xboxp:6"; trb_init_ports() or die trb_strerror(); while (1) { my $o; - foreach my $b (0x5000,0x5002,0x5003) { + foreach my $b (0x50f0,0x50f2,0x50f3) { my $t = trb_register_read_mem($b,0xc000,0,33); $o->{$b} = $t->{$b}; } @@ -129,7 +130,7 @@ while (1) { for my $x (0..5) { for my $y (0..5) { - HPlot::PlotFill('DiamondRate',$diff->{$fpga->[$y]->[$x]+0x5000}->[$chan->[$y]->[$x]],$x+1,$y+1); + HPlot::PlotFill('DiamondRate',$diff->{$fpga->[$y]->[$x]+0x50f0}->[$chan->[$y]->[$x]],$x+1,$y+1); } } HPlot::PlotDraw('DiamondRate'); diff --git a/hmon/hmon_endpoints.pl b/hmon/hmon_endpoints.pl index 0f97d9f..cd4fbe9 100755 --- a/hmon/hmon_endpoints.pl +++ b/hmon/hmon_endpoints.pl @@ -24,33 +24,33 @@ while(1) { my @all_boards =(); my @mdc_boards =( ###OEPS - # 0x2010,0x2011,0x2012,0x2013,0x2014,0x2015,0x2016,0x2017,0x2018,0x2019,0x201a, - # 0x201b,0x201c,0x201d,0x2020,0x2021,0x2022,0x2023,0x2024,0x2025,0x2026,0x2027, - # 0x2028,0x2029,0x202a,0x202b,0x202c,0x202d,0x2030,0x2031,0x2032,0x2033,0x2034, - # 0x2035,0x2036,0x2037,0x2038,0x2039,0x203a,0x203b,0x203c,0x203d,0x2040,0x2041, - # 0x2042,0x2043,0x2044,0x2045,0x2046,0x2047,0x2048,0x2049,0x204a,0x204b,0x204c, - # 0x204d,0x2050,0x2051,0x2052,0x2053,0x2054,0x2055,0x2056,0x2057,0x2058,0x2059, - # 0x205a,0x205b,0x205c,0x205d,0x2100,0x2101,0x2102,0x2103,0x2104,0x2105,0x2106, - # 0x2107,0x2108,0x2109,0x210a,0x210b,0x210c,0x210d,0x210e,0x210f,0x2110,0x2111, - # 0x2112,0x2113,0x2114,0x2115,0x2116,0x2117,0x2118,0x2119,0x211a,0x211b,0x211c, - # 0x211d,0x211e,0x211f,0x2120,0x2121,0x2122,0x2123,0x2124,0x2125,0x2126,0x2127, - # 0x2128,0x2129,0x212a,0x212b,0x212c,0x212d,0x212e,0x212f,0x2130,0x2131,0x2132, - # 0x2133,0x2134,0x2135,0x2136,0x2137,0x2139,0x213a,0x213b,0x213c,0x213d,0x213e, - # 0x213f,0x2140,0x2141,0x2142,0x2143,0x2144,0x2145,0x2146,0x2147,0x2148,0x2149, - # 0x214a,0x214b,0x214c,0x214d,0x214e,0x214f,0x2150,0x2151,0x2152,0x2153,0x2154, - # 0x2155,0x2156,0x2157,0x2158,0x2159,0x215a,0x215b,0x215c,0x215d,0x215e,0x215f, - # 0x2200,0x2201,0x2202,0x2203,0x2204,0x2205,0x2206,0x2207,0x2208,0x2209,0x220a, - # 0x220b,0x220c,0x220d,0x220e,0x220f,0x2220,0x2221,0x2222,0x2223,0x2224,0x2225, - # 0x2226,0x2227,0x2228,0x2229,0x222a,0x222b,0x222c,0x222d,0x222e,0x222f,0x2240, - # 0x2241,0x2242,0x2243,0x2244,0x2245,0x2246,0x2247,0x2248,0x2249,0x224a,0x224b, - # 0x224c,0x224d,0x224e,0x224f,0x2250,0x2251,0x2252,0x2253,0x2254,0x2255,0x2256, - # 0x2257,0x2258,0x2259,0x225a,0x225b,0x225c,0x225d,0x225e,0x225f,0x2300,0x2301, - # 0x2302,0x2303,0x2304,0x2305,0x2306,0x2307,0x2308,0x2309,0x230a,0x230b,0x230c, - # 0x230d,0x230e,0x230f,0x2320,0x2321,0x2322,0x2323,0x2324,0x2325,0x2326,0x2327, - # 0x2328,0x2329,0x232a,0x232b,0x232c,0x232d,0x232e,0x232f,0x2340,0x2341,0x2342, - # 0x2343,0x2344,0x2345,0x2346,0x2347,0x2348,0x2349,0x234a,0x234c,0x234d,0x234e, - # 0x234f,0x2350,0x2351,0x2352,0x2353,0x2354,0x2355,0x2356,0x2357,0x2358,0x2359, - # 0x235a,0x235b,0x235c,0x235d,0x235e,0x235f, + 0x2010,0x2011,0x2012,0x2013,0x2014,0x2015,0x2016,0x2017,0x2018,0x2019,0x201a, + 0x201b,0x201c,0x201d,0x2020,0x2021,0x2022,0x2023,0x2024,0x2025,0x2026,0x2027, + 0x2028,0x2029,0x202a,0x202b,0x202c,0x202d,0x2030,0x2031,0x2032,0x2033,0x2034, + 0x2035,0x2036,0x2037,0x2038,0x2039,0x203a,0x203b,0x203c,0x203d,0x2040,0x2041, + 0x2042,0x2043,0x2044,0x2045,0x2046,0x2047,0x2048,0x2049,0x204a,0x204b,0x204c, + 0x204d,0x2050,0x2051,0x2052,0x2053,0x2054,0x2055,0x2056,0x2057,0x2058,0x2059, + 0x205a,0x205b,0x205c,0x205d,0x2100,0x2101,0x2102,0x2103,0x2104,0x2105,0x2106, + 0x2107,0x2108,0x2109,0x210a,0x210b,0x210c,0x210d,0x210e,0x210f,0x2110,0x2111, + 0x2112,0x2113,0x2114,0x2115,0x2116,0x2117,0x2118,0x2119,0x211a,0x211b,0x211c, + 0x211d,0x211e,0x211f,0x2120,0x2121,0x2122,0x2123,0x2124,0x2125,0x2126,0x2127, + 0x2128,0x2129,0x212a,0x212b,0x212c,0x212d,0x212e,0x212f,0x2130,0x2131,0x2132, + 0x2133,0x2134,0x2135,0x2136,0x2137,0x2139,0x213a,0x213b,0x213c,0x213d,0x213e, + 0x213f,0x2140,0x2141,0x2142,0x2143,0x2144,0x2145,0x2146,0x2147,0x2148,0x2149, + 0x214a,0x214b,0x214c,0x214d,0x214e,0x214f,0x2150,0x2151,0x2152,0x2153,0x2154, + 0x2155,0x2156,0x2157,0x2158,0x2159,0x215a,0x215b,0x215c,0x215d,0x215e,0x215f, + 0x2200,0x2201,0x2202,0x2203,0x2204,0x2205,0x2206,0x2207,0x2208,0x2209,0x220a, + 0x220b,0x220c,0x220d,0x220e,0x220f,0x2220,0x2221,0x2222,0x2223,0x2224,0x2225, + 0x2226,0x2227,0x2228,0x2229,0x222a,0x222b,0x222c,0x222d,0x222e,0x222f,0x2240, + 0x2241,0x2242,0x2243,0x2244,0x2245,0x2246,0x2247,0x2248,0x2249,0x224a,0x224b, + 0x224c,0x224d,0x224e,0x224f,0x2250,0x2251,0x2252,0x2253,0x2254,0x2255,0x2256, + 0x2257,0x2258,0x2259,0x225a,0x225b,0x225c,0x225d,0x225e,0x225f,0x2300,0x2301, + 0x2302,0x2303,0x2304,0x2305,0x2306,0x2307,0x2308,0x2309,0x230a,0x230b,0x230c, + 0x230d,0x230e,0x230f,0x2320,0x2321,0x2322,0x2323,0x2324,0x2325,0x2326,0x2327, + 0x2328,0x2329,0x232a,0x232b,0x232c,0x232d,0x232e,0x232f,0x2340,0x2341,0x2342, + 0x2343,0x2344,0x2345,0x2346,0x2347,0x2348,0x2349,0x234a,0x234c,0x234d,0x234e, + 0x234f,0x2350,0x2351,0x2352,0x2353,0x2354,0x2355,0x2356,0x2357,0x2358,0x2359, + 0x235a,0x235b,0x235c,0x235d,0x235e,0x235f, # ###MDC Concentrator 0x1000,0x1001,0x1002,0x1003,0x1004,0x1010,0x1011,0x1012,0x1013,0x1014,0x1020, 0x1021,0x1022,0x1023,0x1024,0x1030,0x1031,0x1032,0x1033,0x1034,0x1040,0x1041,0x1042,0x1043,0x1044,0x1050, @@ -106,9 +106,9 @@ while(1) { #start/veto hub 0x8800,0x8801, #fw -# 0x4400,0x4410,0x4420, + 0x4400,0x4410,0x4420, #fw hub -# 0x8700,0x8701, + 0x8700,0x8701, #Pion 0x8900,0x3800,0x3801, 0x8910,0x3810,0x3811, @@ -148,12 +148,12 @@ while(1) { my $qastate = QA::GetQAState('below',$num_mdc_missing,@QA::MdcEndpMissingLimits); -# Hmon::Speak('mdcmiss',"$num_mdc_missing MDC Frontends missing") if($qastate > 60); -# QA::WriteQALog($flog,"endp","mdc",$waittime,$qastate,$title,$value,$longtext); -# if($qastate > 60) { -# system("logger -p local1.info -t DAQ Endp \\ $longtext") unless (($timecnt->{mdc}++)%$loggerperiod); -# } -# else {$timecnt->{mdc} = 0;} + Hmon::Speak('mdcmiss',"$num_mdc_missing MDC Frontends missing") if($qastate > 60); + QA::WriteQALog($flog,"endp","mdc",$waittime,$qastate,$title,$value,$longtext); + if($qastate > 60) { + system("logger -p local1.info -t DAQ Endp \\ $longtext") unless (($timecnt->{mdc}++)%$loggerperiod); + } + else {$timecnt->{mdc} = 0;} ###rich my(%rich_mask, @rich_results); diff --git a/hmon/hmon_hadplot.sh b/hmon/hmon_hadplot.sh deleted file mode 100755 index d1e9277..0000000 --- a/hmon/hmon_hadplot.sh +++ /dev/null @@ -1,1455 +0,0 @@ -#!/usr/bin/perl -w -use warnings; - -use FileHandle; -use Time::HiRes qw( gettimeofday usleep time ); -use Getopt::Long; -use Data::Dumper; -use POSIX qw/floor strftime/; - -use constant AXISISTIME => 1; -use constant AXISISNOTIME => 0; -use constant DIFFY => 1; -use constant DIFFX => 1; -use constant NODIFFY => 0; -use constant NODIFFX => 0; -use constant NODELAY => 0; -use constant NO => 0; -use constant YES => 1; -use constant NONEWLINE => 1; - -my $GPbuffer = ""; -my $buffercount = 0; - -my $windowtitle = ""; #Global var to store real name of GUI window - -my $PlotBuffer = {}; -my $PlotBufferCnt = 0; - -my @PlotBufArr = (); - -#my @color = ("#1155bb","#bb1111","#999900","#660000","#006633","#990066","#6633CC","#00CCCC"); -my @color = ("#2222dd","#880000","#00cc00","#ee00dd","#ffcc00","#00cc88","#6633CC","#00CCCC"); -our $write2file = ""; -our $plotendedbefore = 0; - - - -################################################# -# Variables... -################################################# -my $delay = 1000; -my $samples = 100; -my $downscale = 1; -# my $system = 0; -my $address = []; -my $register = []; -my $regoffset = []; -my $regwidth = []; -my $title = []; -my $timeref = []; -my $geom = "700x400"; -my $style = 0; -my $nametmp = ""; -my $regamount = []; -my $xscale = []; -my $yscale = []; -my $xtitle = ""; -my $ytitle = ""; -my $windowname = "No Name"; -my $xistime = AXISISNOTIME; -my $xoverflow = []; -my $yoverflow = []; -my $ydiff = 0; -my $outputcfg = ""; -my $name = "HadPlot"; -my $key ; -my $curvestyle= 'points'; #points, steps, histo or histostacked -my $xticks = 0; #show labels on x-axis -my $yticks = 1; #show labels on y-axis -my $plotoption= ""; #string with additional gnuplot commands -my $curveoption= []; #options for plot command -my $xgrid = 1; -my $ygrid = 1; -my $ymax; -my $ymin; -my $xmin; -my $xmax; - -GetOptions('d=i' => \$delay, - 'n=i' => \$samples, - 'o=i' => \$downscale, - 'a=s' => $address, - 'r=s' => $register, - 'w=i' => $regwidth, - 'p=i' => $regoffset, - 't=s' => $title, - 'm=i' => $regamount, - 'g=s' => \$geom, - 'z=i' => \$style, - 'output=s' => \$outputcfg, - 'windowname=s' => \$windowname, - 'xscale=f' => $xscale, - 'yscale=f' => $yscale, - 'xtitle=s' => \$xtitle, - 'ytitle=s' => \$ytitle, - 'xistime!' => \$xistime, - 'timeref=s' => $timeref, - 'xoverflow=f' => $xoverflow, - 'yoverflow=f' => $yoverflow, - 'ydiff!' => \$ydiff, - 'name=s' => \$name, - 'key!' => \$key, - 'xticks!' => \$xticks, - 'yticks!' => \$yticks, - 'xgrid!' => \$xgrid, - 'ygrid!' => \$ygrid, - 'ymax=i' => \$ymax, - 'ymin=i' => \$ymin, - 'xmax=i' => \$xmax, - 'xmin=i' => \$xmin, - 'curvestyle=s' => \$curvestyle, - 'curveoption=s'=> $curveoption, - 'plotoption=s' => \$plotoption - ); - -for(my $i=0;$i<16;$i++) { - $regoffset->[$i] = 0 unless defined $regoffset->[$i]; - $regwidth->[$i] = 32 unless defined $regwidth->[$i]; - $xoverflow->[$i] = 2**20 unless defined $xoverflow->[$i]; - $yoverflow->[$i] = 2**32 unless defined $yoverflow->[$i]; - $xscale->[$i] = 1 unless defined $xscale->[$i]; - $yscale->[$i] = 1 unless defined $yscale->[$i]; - $title->[$i] = "" unless defined $title->[$i]; - $curveoption->[$i] = "" unless defined $curveoption->[$i]; - } - -for(my $i=0;$i < scalar @{$address};$i++) { - if(!defined($title->[$i])) { - $title->[$i] = hex($address->[$i])." $register->[$i] $regoffset->[$i]..".($regoffset->[$i]+$regwidth->[$i]-1); - } - } - - -$delay *= 1000; -if($style == 1) {$curvestyle="points"; $xticks=1;} -if($style == 2) {$curvestyle="histo"; $xticks=0;} -if($style == 3) {$curvestyle="histo"; $xticks=1;} -if($style == 4) {$curvestyle="histostacked"; $xticks=0;} -if($style == 5) {$curvestyle="histostacked"; $xticks=1;} - - - -#Open Gnuplot -our $fh; -my $fn = "gnuplot -geometry $geom -bg 'ghost white'"; -$fh = new FileHandle ("|$fn") or die "error: no gnuplot"; -$fh->autoflush(1); - - -sub makeTimeString{ - return strftime("set label 100 \"%H:%M:%S\" at screen 0.02,0.02 left tc rgb \"#000044\" font \"monospace,8\"\n", localtime()) - } - -################################################# -# When exiting, close Gnuplot window -################################################# -sub finish { - print $fh "exit;\n"; - close $fh; - exit; -} - -$SIG{INT} = \&finish; -$SIG{PIPE} = \&finish; - - - -my $last_wakeup; - -sub max { - my $a = shift; - my $b = shift; - return $a > $b ? $a : $b; - } - -sub min { - my $a = shift; - my $b = shift; - return $a < $b ? $a : $b; - } - -sub usleep_total { - my $delay = shift; - if(defined $last_wakeup) { - my $time = time(); -# printf "%.0f\n",$delay-($time-$last_wakeup)*1E6; - usleep(max(0,$delay-($time-$last_wakeup)*1E6)); - } - else { - usleep($delay); - } - $last_wakeup = time(); - return $last_wakeup; - } - - -################################################# -# Write to gnuplot -################################################# -sub plot_write { - my ($str,$no) = @_; - if(defined($no) && $no) { - print $fh $str; -# print $str; - } - else { - print $fh $str."\n"; -# print $str."\n"; - } - } - -sub plot_add { - my ($x,$y) = @_; - $x = $x || $PlotBufferCnt; - $PlotBufArr[$PlotBufferCnt]->{x} = $x; - $PlotBufArr[$PlotBufferCnt]->{y} = $y; - - $PlotBufferCnt++; -# $PlotBuffer->{$x} = $y; -# print $x." ".$y."\n"; - } - -sub plot_end { - my ($single) = @_; - for(my $i = 0;$i{y}."\n"; - } - else { - print $fh $PlotBufArr[$i]->{x}." ".$PlotBufArr[$i]->{y}."\n"; - } - } -# foreach my $line (sort keys %{$PlotBuffer}) { -# if($single) { -# print $fh $PlotBuffer->{$line}."\n"; -# # print "plot_end: ".$PlotBuffer->{$line}."\n"; -# } -# else { -# print $fh $line." ".$PlotBuffer->{$line}."\n"; -# # print "plot_end: ".$line." ".$PlotBuffer->{$line}."\n"; -# } -# } - @PlotBufArr = (); - $PlotBuffer = {}; - $PlotBufferCnt = 0; - print $fh "e\n"; - $plotendedbefore = 1 unless $plotendedbefore; - } - - -sub plot_reset { - if($write2file eq ""){ - system("xwininfo -name '$windowtitle' >/dev/null 2>/dev/null"); - #print $?."\n"; - if($? != 0) { - usleep(1E5); - system("xwininfo -name '$windowtitle' >/dev/null 2>/dev/null"); - if($? != 0) { - finish(); - } - } - if ($plotendedbefore != 0) { - $plotendedbefore = 0; -# my $datestring = makeTimeString(); - print $fh makeTimeString(); - print $fh "replot\n"; - } - } - else { - if ($plotendedbefore != 0) { - system("mv $write2file.tmp $write2file"); - plot_write("set out \"$write2file.tmp\"\n"); - $plotendedbefore = 0; -# my $datestring = makeTimeString(); - print $fh makeTimeString(); - print $fh "replot\n"; - -# print "reset\n"; - } - } - } - -sub plot_finished { - my ($store) = @_; - if($write2file ne "") { - if(defined $store) { - if($store->{"initing"} != 2 and $store->{"iteration"} % $store->{"downscale"} == 0) { -# system("mv $write2file.tmp $write2file"); - } - } - else { - if($write2file ne "") { -# system("mv $write2file.tmp $write2file"); - } - } - } - } - -sub plot_init { - my ($xtics) = @_; - $windowtitle = $name ." - ".$windowname; - if ($outputcfg =~ m$PNG.([/\w]*).(\d+).(\d+)$) { - print "Writing PNG to file $1\n"; - $write2file = $1.".png"; - plot_write("set term png size $2,$3 font \"monospace,8\""); - plot_write("set out \"$write2file.tmp\""); - } - elsif ($outputcfg =~ m$SVG.([/\w]*).(\d+).(\d+)$) { - print "Writing SVG to file $1\n"; - $write2file = $1.".svg"; - plot_write("set term svg size ".($2*2).",".($3*2)." dynamic font \"monospace,18\" lw 1.5 \n"); - plot_write("set out \"$write2file.tmp\"\n"); - } - else { - plot_write("set term x11 title '$windowtitle'"); - } - plot_write("set grid"); - plot_write("set xlabel \"$xtitle\""); - plot_write("set ylabel \"$ytitle\""); - - plot_write(makeTimeString()); - - if(defined $xtics) { - plot_write("set xtics $xtics\n"); - } - if(defined $xmin && defined $xmax) { - plot_write("set xrange [$xmin:$xmax]"); - } - if(defined $ymin && defined $ymax) { - plot_write("set yrange [$ymin:$ymax]"); - } - elsif(defined $ymax) { - plot_write("set yrange [:$ymax]"); - } - elsif(defined $ymin) { - plot_write("set yrange [$ymin:]"); - } - if (!defined $key || $key == 0) { - plot_write("unset key"); - } - if($xgrid == 0) { - plot_write("set grid noxtics"); - } - if($ygrid == 0) { - plot_write("set grid noytics"); - } - if($plotoption ne "") { - plot_write($plotoption); - } - } - -sub plot_sleep { - my ($delay) = @_; - my $t = usleep_total($delay); - plot_reset(); - return $t; - } - -sub plot_end_sleep { - my ($delay,$single) = @_; - plot_end($single); - return plot_sleep($delay); - } - -sub plot_storage_end_sleep { - my ($store, $single) = @_; - my $delay = $store->{"delay"}; - my $t; - if($store->{"initing"} == 0) { - if($store->{"iteration"} % $store->{"downscale"} == 0) { - plot_end($single); - $t = usleep_total($delay); - plot_reset(); - } - else { - $t = usleep_total($delay); - } - } - return $t; - } - -sub plot_storage_sleep { - my ($store,$noreset) = @_; - my $t; - my $delay = $store->{"delay"}; - #print $store->{"initing"}.$store->{"iteration"}.$store->{"downscale"}."\n"; - if($store->{"initing"} != 2) { - if($store->{"iteration"} % $store->{"downscale"} == 0) { - $t = usleep_total($delay); - plot_storage_reset() unless $noreset; - } - else { - $t = usleep_total($delay); - } - } - return $t; - } - -sub plot_storage_reset { - my ($store) = @_; - if(defined $store->{"initing"} && $store->{"initing"} != 2) { - if($store->{"iteration"} % $store->{"downscale"} == 0) { - plot_reset(); - } - } - } - -sub plot_storage_end { - my ($store) = @_; - if($store->{"initing"} == 0) { - if($store->{"iteration"} % $store->{"downscale"} == 0) { - plot_end(); - } - } - } - -################################################# -# Writes a new value pair to storage -################################################# -sub store_push { - my ($storage,$x,$y,$divtime) = @_; - my $xval = $x; - my $yval = $y; - my $curtime = time(); - - if ($storage->{"initing"} != 2) { - if (scalar(@{$storage->{"datax"}}) == $storage->{"size"}) { - my $tmp = shift(@{$storage->{"datax"}}); - my $tmpy = shift(@{$storage->{"datay"}}); - $storage->{"totalx"} -= $tmp; -# if($storage->{"initing"} == 0 && (($tmpy <= $storage->{"miny"}) || ($tmpy >= $storage->{"maxy"}))) { -# store_calc_range($storage); -# } - } - if($storage->{"diffx"}) { - if(defined($storage->{"xmax"}) && $x < $storage->{"lastx"}) { - $xval = ($x - $storage->{"lastx"} + $storage->{"xmax"}); - } - else { - $xval = ($x - $storage->{"lastx"}); - } - if(defined($storage->{"last_push"}) && $storage->{"last_push"} != 0) { - while (floor($xval/$storage->{"xmax"}) < floor(($curtime - $storage->{"last_push"})/($storage->{"xmax"}/1E6))){ - $xval += $storage->{"xmax"}; - } - } - } - if($storage->{"diffy"}) { - $yval = $y - $storage->{"lasty"}; - if(defined($storage->{"ymax"}) && $y < $storage->{"lasty"}) { - while($yval < 0) { - $yval += $storage->{"ymax"}; - } - } - if($divtime) { - $yval /= ($xval?$xval:1)/1000000; - } - } - - - if($storage->{"initing"} == 1) { - $storage->{"initing"} = 0; - for(my $i = $storage->{"size"}-1; $i>0; $i--) { - push(@{$storage->{"datax"}},$storage->{"delay"}); - push(@{$storage->{"datay"}},$yval); - $storage->{"totalx"} += $storage->{"delay"}; - } - } - - push(@{$storage->{"datax"}},$xval?$xval:0); - push(@{$storage->{"datay"}},$yval?$yval:0); - $storage->{"totalx"} += $xval?$xval:0; - } - else { - $storage->{"initing"} = 1; - } - - $storage->{"last_push"} = $curtime; - $storage->{"lasty"} = $y; - $storage->{"lastx"} = $x; - } - -################################################# -# Writes storage contents to stream -################################################# -sub store_print { - my $str = ""; - my ($storage) = @_; - if($storage->{"initing"} != 2) { - if($storage->{"iteration"} % $storage->{"downscale"} == 0) { - my $xcnt = - $storage->{"totalx"} /1000000.0; - for (my $i = 0; $i < $storage->{"size"}; $i++) { - my $xval = $storage->{"datax"}->[$i]; #${}[] - my $yval = $storage->{"datay"}->[$i]; - $xval = 0 unless defined($xval); - $yval = 0 unless defined($yval); - $xcnt += $xval/1000000.0; -# $str .= $xcnt." ".$yval."\n"; - $str .= sprintf "%.3f %.2f\n", $xcnt,$yval; - #plot_write($xcnt/1000000.0." ".$yval); - } - plot_write($str,1); -# print $str; - plot_end(1); - } - $storage->{"iteration"}++; - } - } - - -################################################# -# Initialize storage -################################################# -sub store_init { - my ($storage,$size,$diffx,$diffy,$delay,$downscale,$xmax,$ymax) = @_; - - $storage->{"datax"} = []; - $storage->{"datay"} = []; - $storage->{"size"} = $size; - $storage->{"diffx"} = $diffx; - $storage->{"diffy"} = $diffy; - $storage->{"delay"} = $delay; - $storage->{"downscale"} = $downscale; - $storage->{"initing"} = 2; - $storage->{"iteration"} = 0; - $storage->{"totalx"} = 0; - $storage->{"xmax"} = $xmax; - $storage->{"ymax"} = $ymax; - $storage->{"maxy"} = 0; - $storage->{"miny"} = 1E100; - $storage->{"last_push"} = 0; - $storage->{"last_sleep"} = 0; - } - -################################################# -# Help Message -################################################# -sub help { - print <[$i])) || ($title->[$i] eq "")) { -# $title->[$i] = hex($address->[$i])." ".$register->[$i]." ".$regoff->[$i]."..".($regoff->[$i]+$regwidth->[$i]-1); -# } - if (!(defined $regamount->[$i])) { - $regamount->[$i] = 1; - } - } - $ymin = $regoff->[0]; - $ymax = $regoff->[0]+$regwidth->[0]; - plot_init(256); -# if ($style == 0) { -# plot_write("plot",1); -# for(my $i = 0; $i[$i]\" ",1); -# plot_write(", ",1) unless $i == scalar(@{$address})-1; -# } -# plot_write(""); -# } -# elsif($style == 1) { - plot_write("set xtics rotate by 90 offset .7,-2 scale 0 "); - plot_write("set style fill solid 1.00 border -1"); - plot_write("set boxwidth 1 absolute"); - plot_write("unset key"); - plot_write('set format x "%x"'); - plot_write("plot ",1); - for(my $i = 0; $i[$i]\" ",1); #using 2:xticlabels(1) - plot_write(", ",1) unless $i == scalar(@{$address})-1; - } - plot_write(""); -# } - while(1) { - for(my $i = 0; $i[$i] == 1) { - $c = "trbcmd r $address->[$i] $register->[$i] | sort"; - } - else { - $c = "trbcmd rm $address->[$i] $register->[$i] $regamount->[$i] 0"; - } - my @out = qx($c); - my $addr = undef; - my $cnt = 0; - foreach my $s (@out) { - if($s =~ /^H:\s*0x(\w\w\w\w)/) { - $addr = $1; - } - if($s =~ /^0x(\w\w\w\w)\s*0x(\w{8})/) { - $addr = hex($1) if($regamount->[$i] == 1); - if ($regamount->[$i] == 1) { plot_add($addr,-1); } - else { plot_add("\"$addr.$1\"",-1); } - for(my $j = $regoff->[$i]; $j < $regoff->[$i] + $regwidth->[$i];$j++) { - if(hex($2) & (1<<$j)) { - if ($regamount->[$i] == 1) { plot_add("$addr",$j); } - else { plot_add("\"$addr.$1\"",$j); } - } - } - $cnt++; - } - } - plot_end(1); - } - plot_sleep($delay); - } - } - - - -################################################# -# Generic Register differences -################################################# -sub genreg { - my %oldvals; - - plot_init(undef); - - if($xticks) { - plot_write("set xtics rotate by 90 offset .7,-1.7 scale .7 "); - } - if($curvestyle eq "histo") { - plot_write("set style fill solid 1.00 border -1"); - plot_write("set boxwidth 2 absolute"); - } - elsif($curvestyle eq "histostacked") { - plot_write("set style fill solid 1.00 border -1"); - plot_write("set style histogram rowstacked"); - plot_write("set boxwidth 1 absolute"); - plot_write("set key outside") unless defined $key && $key==0; - plot_write("set autoscale xfix "); - } - - plot_write("plot",1); - for(my $i = 0; $i[$i]\" ",NONEWLINE); - } - elsif ($curvestyle eq "steps") { - plot_write("with histeps title \"$title->[$i]\" ",NONEWLINE); - } - else { - plot_write("with points pt 5 title \"$title->[$i]\" ",NONEWLINE); - } - plot_write(" ".$curveoption->[$i],NONEWLINE); - plot_write(", ",NONEWLINE) unless $i == scalar(@{$address})-1; - } - plot_write(""); - - - while(1) { - for(my $i = 0; $i[$i]) || $regamount->[$i] == 1) { - $c = "trbcmd r $address->[$i] $register->[$i] | sort"; - } - else { - $c = "trbcmd rm $address->[$i] $register->[$i] $regamount->[$i] 0"; - } - my @out = qx($c); - my $addr = undef; - foreach my $s (@out) { - if($s =~ /^H:\s*0x(\w\w\w\w)/) { - $addr = $1; - $cnt = -1; - } - if($s =~ /^0x(\w{4})\s*0x(\w{8})/) { - my $tmp = (hex($2)>>$regoffset->[$i])&(2**$regwidth->[$i]-1); - my $val = 0; - my $board = $1; - if(defined $addr) {$board = $addr;} - $cnt++; - my $reg = $1; - if($ydiff) { - if(defined $oldvals{$i}->{$board.$reg}) { - if ($oldvals{$i}->{$board.$reg} > $tmp) { - $val = $tmp - $oldvals{$i}->{$board.$reg} + 2**$regwidth->[$i]; - } - else { - $val = $tmp - $oldvals{$i}->{$board.$reg}; - } - } - $oldvals{$i}->{$board.$reg} = $tmp; - } - else { - $val = $tmp; - } - if($xticks) { - if (!(defined $regamount->[$i]) || $regamount->[$i] == 1) { - plot_add("\"$board\"",$val/($yscale->[$i]||1)); - } - else { - plot_add("\"$board.$reg\"",$val/($yscale->[$i]||1)); - } - } - else { - plot_add("",$val/($yscale->[$i]||1)); - } - } - } - plot_end(!$xticks); - } - plot_sleep($delay); - } - } - -################################################# -# Generic Histogram -################################################# -sub genhist { - my %storearr; - my %oldvals; -# $xtitle = "Time [s]" unless $xtitle ne ""; - plot_init(); - plot_write("set autoscale fix"); - plot_write("plot",1); - $diff = 0 unless defined($diff); - for(my $i = 0; $i[$i],$yoverflow->[$i]); - plot_write("'-' with lines title \"$title->[$i]\" ",1); - plot_write(", ",1) unless $i == scalar(@{$address})-1; - } - plot_write(""); - - while(1) { - my $a, my $s, my $t; - my $val = 0 , my $time; - plot_storage_reset($storearr{0}); - for(my $i = 0; $i>($regoffset->[$i]))&(2**($regwidth->[$i])-1)); - $time = hex($t)*16; - } - } - store_push($storearr{$i},$time/$xscale->[$i],$val/($yscale->[$i]||1),AXISISTIME); - store_print($storearr{$i}); - } - plot_storage_sleep($storearr{0}); - plot_finished($storearr{0}); - } - } - -################################################# -# Deadtime histogram -################################################# -sub deadtimehist2 { - my %values, my %lastvalues, my %diffvalues; - my @keys = ("33","34","36","31","38","37","3b","35"); - my @keys2 = ("43","44","46","41","48","47","4b","45"); - my @names = ("MDC12","MDC34","TOF","RPC","RICH","SHW","Start","FW"); - my %storearr; - - if ($style != 0) { - for(my $i= 0; $i < scalar(@keys); $i++) { - $storearr{$keys[$i]} = {}; - store_init($storearr{$keys[$i]},$samples,0,0,$delay*.0,$downscale,2**32,2**32); - } - for(my $i= 0; $i < scalar(@keys2); $i++) { - $storearr{$keys2[$i]} = {}; - store_init($storearr{$keys2[$i]},$samples,0,0,$delay*.0,$downscale,2**32,2**32); - } - } - - plot_init(); - plot_write("set key left top Left"); - plot_write("set autoscale fix"); - plot_write("set yrange [-1:101]"); - - if ($style != 0) { - plot_write("plot ",1); - plot_write("\"-\" title \"MDC12\" with lines,",1); - plot_write("\"-\" title \"MDC34\" with lines,",1); - plot_write("\"-\" title \"TOF\" with lines,",1); - plot_write("\"-\" title \"RPC\" with lines,",1); - plot_write("\"-\" title \"RICH\" with lines,",1); - plot_write("\"-\" title \"SHW\" with lines,",1); - plot_write("\"-\" title \"Start\" with lines,",1); - plot_write("\"-\" title \"FW\" with lines"); - } - else { - plot_write("set style fill solid 1.00 border -1"); - plot_write("set grid noxtics ytics"); - plot_write("set boxwidth 2 absolute"); - plot_write("set xtics ('MDC12' 0,'MDC34' 1,'TOF' 2, 'RPC' 3, 'RICH' 4, 'SHW' 5, 'Start' 6, 'FW' 7) offset 2,0 scale 0"); - plot_write("set style histogram title offset character 0, 0, 0"); - plot_write("set style data histograms"); - plot_write("plot \"-\" title 'incl. busy' lt rgb \"#1155bb\", \"-\" title 'excl. busy' lt rgb \"#bb1111\""); - } - my $cmd = sprintf("trbcmd -n-1 -s%d rmt 0x8001 0x4031 31 0",$delay/1000); - if($style != 0) { - $cmd = sprintf("trbcmd -n-1 -s%d rmt 0x8001 0x4031 12 0",$delay/1000); - } - open(FTRB, "$cmd|"); - - while(my $a = ) { - if($a =~ /^0x\w{2}(\w{2})\s*0x(\w{8})\s*0x(\w{4})/) { - $values{$1} = hex($2); - $values{"50"} = hex($3)*16; - } - if ($a eq "---\n") { - $diffvalues{"50"} = 1E6; - if (defined $lastvalues{"50"}) { - if ($values{"50"} > $lastvalues{"50"}) { - $diffvalues{"50"} = $values{"50"} - $lastvalues{"50"}; - } - else { - $diffvalues{"50"} = $values{"50"} - $lastvalues{"50"} + 2**20; - } - } - #$diffvalues{"50"} = $values{"50"} - $lastvalues{"50"} if defined $lastvalues{"50"}; - my $time = $diffvalues{"50"}; - foreach my $key (keys %values) { - next unless hex($key)<0x50; - $diffvalues{$key} = 0; - if (defined $lastvalues{$key}) { - if ($values{$key} >= $lastvalues{$key}) { - $diffvalues{$key} = $values{$key} - $lastvalues{$key}; - } - else { - $diffvalues{$key} = $values{$key} - $lastvalues{$key} + 2**32; - } - } - $diffvalues{$key} /= $time if $time; - #print $key." ".$values{$key}." ".$lastvalues{$key}." ".$diffvalues{$key}."\n"; - } - #print "=====\n"; - $diffvalues{"31"} = max($diffvalues{"31"},$diffvalues{"32"}); - $diffvalues{"38"} = max(max($diffvalues{"38"},$diffvalues{"39"}),$diffvalues{"3a"}); - if ($style == 0) { - $diffvalues{"41"} = max($diffvalues{"41"},$diffvalues{"42"}); - $diffvalues{"48"} = max(max($diffvalues{"48"},$diffvalues{"49"}),$diffvalues{"4a"}); - } - %lastvalues = %values; - if($style != 0) { - plot_storage_reset($storearr{$keys[0]}); - for(my $i= 0; $i < scalar(@keys); $i++) { - store_push($storearr{$keys[$i]},$time,$diffvalues{$keys[$i]},0); - store_print($storearr{$keys[$i]}); - } - plot_storage_sleep($storearr{$keys[0]},1); - plot_finished($storearr{$keys[0]}); - } - else { - plot_reset(); - for(my $i= 0; $i < scalar(@keys); $i++) { - plot_add("",$diffvalues{$keys[$i]}); #"\"".$names[$i]."\"", - } - plot_end(1); - for(my $i= 0; $i < scalar(@keys2); $i++) { - plot_add("",$diffvalues{$keys2[$i]}); #"\"".$names[$i]."\"", - } - plot_end(1); - plot_finished(); - } - } - } - } - - -################################################# -# Select Operation -################################################# - -if(!(defined $ARGV[0]) || $ARGV[0] =~ /help/) {help(); exit;} - -if($ARGV[0] =~ /oep5V/) { - $address = [0xfffd,0xfffd]; - $register = [0x8010,0x8011]; - $regwidth = [12,12]; - $regoffset = [0,0]; - $yscale = [.5,.5]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["5.8V input","5V reg."]; - genreg(); - } - -if($ARGV[0] =~ /oep3.3V/) { - $address = [0xfffd,0xfffd]; - $register = [0x8012,0x8013]; - $regwidth = [12,12]; - $regoffset = [0,0]; - $yscale = [1,1]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["3.8V input","3.3V reg."]; - genreg(); - } - -if($ARGV[0] =~ /oep1.2V/) { - $address = [0xfffd,0xfffd]; - $register = [0x8014,0x8015]; - $regwidth = [12,12]; - $regoffset = [0,0]; - $yscale = [1,1]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["1.8V input","1.2V reg."]; - genreg(); - } - -if($ARGV[0] =~ /oep3V/) { - $address = [0xfffd,0xfffd]; - $register = [0x8016,0x8017]; - $regwidth = [12,12]; - $regoffset = [0,0]; - $yscale = [1,1]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["+3V input","-3V reg."]; - genreg(); - } - -if($ARGV[0] =~ /oepminmaxp3V/) { - $address = [0xfffd,0xfffd]; - $register = [0x801e,0x801e]; - $regwidth = [12,12]; - $regoffset = [0,16]; - $yscale = [1,1]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["+3V minimum","+3V maximum"]; - genreg(); - } - -if($ARGV[0] =~ /oepminmaxn3V/) { - $address = [0xfffd,0xfffd]; - $register = [0x801f,0x801f]; - $regwidth = [12,12]; - $regoffset = [0,16]; - $yscale = [1,1]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["-3V minimum","-3V maximum"]; - genreg(); - } - -if($ARGV[0] =~ /oepminmax5Vin/) { - $address = [0xfffd,0xfffd,0xfffd]; - $register = [0x8018,0x8018,0x8010]; - $regwidth = [12,12,12]; - $regoffset = [0,16,0]; - $yscale = [.5,.5,.5]; - $xtitle = "Board"; - $ytitle = "Voltage [mV]"; - $key = YES; - $windowname = "OEP Voltages"; - $title = ["5Vin minimum","5Vin maximum","5Vin"]; - genreg(); - } - -if($ARGV[0] =~ /oeptemp/) { - oeptemp(($delay)?$delay:5000000,[$name." - OEP Temperature"]); - } - - -if($ARGV[0] =~ /rpcdatarate/) { - $delay = 1000000 unless $delay; - $xticks = 1 ; - $xtitle = "Sender ((Sector mod 3)*4+TRB)"; - $ytitle = "Data Words /1024"; - $windowname = "Data Words sent by RPC"; - $curvestyle = "histo"; - $key = YES; - $ydiff = DIFFY; - $ymin = 0; - $yscale = [512,512]; - $address = [0x8401,0x8411]; - $register = [0x4001,0x4001]; - $regamount = [12,12]; - $title = ["Sector 0,1,2","Sector 3,4,5"]; - $regoffset = [0,0]; - $regwidth = [32,32]; - genreg(); - } - -#hadplot -a 2 -r 1 -p 0 -w 16 -d 5 -o 200 -n 1000 -yoverflow 65536 genhistdiff - -if($ARGV[0] =~ /eventratehighres/) { - $delay = 5000 ; #unless $delay; - $samples = 1000; # unless $samples; - $downscale = 200;# unless $downscale; -# $style = 0 unless $style; - $windowname = "Eventrate High Resolution"; - $xistime = AXISISTIME; - $ydiff = DIFFY; - $xoverflow = [2**20]; - $title = ["Event rate"]; - $address = [0x2]; - $register = [0x1]; - $regoffset = [0]; - $regwidth = [16]; - $yoverflow = [65536]; - genhist(); - } - - -if($ARGV[0] =~ /eventrate/) { - $address = [0x2]; - $register = [0x1]; - $regwidth = [16]; - $regoffset = [0]; - $timeref = [0x2]; - $delay = 100000 unless $delay; - $samples = 500 unless $samples; - $downscale = 10 unless $downscale; - $windowname = "Event rate history"; - $key = NO; - $ytitle = "Event rate [Hz]" if $ytitle eq ""; - $xistime = AXISISTIME; - $ydiff = DIFFY; - $xoverflow = [2**20]; - $yoverflow = [2**16] unless $yoverflow->[0] != 2**32; - genhist(); - } - -if($ARGV[0] =~ /datarate/) { - $address = [0xff7f]; - $register = [0x83f3]; - $regwidth = [32]; - $regoffset = [0]; - $timeref = [0x8000]; - $delay = 100000 unless $delay; - $samples = 500 unless $samples; - $downscale = 5 unless $downscale; - $windowname = "Total data rate history"; - $xtitle = "Time [s]" unless defined $xtitle; - $ytitle = "Data rate [MiByte]" unless defined $ytitle; - $xistime = AXISISTIME; - $ydiff = DIFFY; - $xoverflow = [2**20]; - $yoverflow = [2**12]; - $yscale = [2**20]; - $key = NO; - genhist(); - } - -if($ARGV[0] =~ /busytime/) { - $delay = 100000 unless $delay; - $samples = 100 unless $samples; - $downscale = 5 unless $downscale; - $style = 1; - $windowname = "Busytime history"; - deadtimehist2(); - } - -if($ARGV[0] =~ /busy/) { - $delay = 100000 unless $delay; - $style = 0; - $windowname = "Busy time"; - deadtimehist2(); - } - -if($ARGV[0] =~ /oepspikehist/) { - $delay = 100000 unless $delay; - $samples = 1000 unless $samples; - $downscale = 10 unless $downscale; -# $style = 0 unless $style; - $windowname = "OEP CMS Spikes"; - $ydiff = DIFFY; - $title = ["OEP CMS Spikes"]; - $address = [0xfffd]; - $register = [7]; - $regoffset = [0]; - $regwidth = [16]; - genhist(); - } - -if($ARGV[0] =~ /oepretrhist/) { - $delay = 500000 unless $delay; - $samples = 600 unless $samples; - $downscale = 2 unless $downscale; - $style = 0 unless $style; - $windowname = "OEP Retransmissions"; - $ydiff = DIFFY; - $title = ["Retransmit Received","Retransmit Sent"]; - $address = [0xfffd,0xfffd]; - $register = [4,4]; - $regoffset = [16,24]; - $regwidth = [8,8]; - genhist(); - } - -if($ARGV[0] =~ /oeptokenmisshist/) { - $delay = 500000 unless $delay; - $samples = 2000 unless $samples; - $downscale = 4 unless $downscale; - $style = 0 unless $style; - $windowname = "OEP Token Missing"; - $ydiff = DIFFY; - $title = ["Missing Tokens"]; - $address = [0xfffd]; - $register = [0x9101]; - $regoffset = [0]; - $regwidth = [24]; - genhist(); - } - - -if($ARGV[0] =~ /oeptrgerrhist/) { - $delay = 500000 unless $delay; - $samples = 2000 unless $samples; - $downscale = 2 unless $downscale; - $style = 0 unless $style; - $windowname = "OEP CMS Errors"; - $ydiff = DIFFY; - $title = ["Spikes","Spurious","Invalid","Multiple"]; - $address = [0xfffd,0xfffd,0xfffd,0xfffd]; - $register = [7,7,6,6]; - $regoffset = [0,16,0,16]; - $regwidth = [16,16,16,16]; - genhist(); - } - - -if($ARGV[0] =~ /histdiff/) { - $delay = 1000000 unless $delay; - $samples = 200 unless $samples; - $downscale = 1 unless $downscale; - $style = 0 unless $style; - $ydiff = DIFFY; - genhist(); - } - -if($ARGV[0] =~ /hist/) { - $delay = 1000000 unless $delay; - $samples = 200 unless $samples; - $downscale = 1 unless $downscale; - $style = 0 unless $style; - $ydiff = NODIFFY; - genhist(); - } - -if($ARGV[0] =~ /oepworktime/) { - $delay = 1000000 unless $delay; - $curvestyle = "histostacked"; - $xticks = 0 unless $xticks; - $ymax = $delay*1.1/1000; - $yscale = [1000]; - $xtitle = "OEP"; - $ytitle = "Time [ms]"; - $windowname = "OEP Trigger Handling Times"; - $ydiff = DIFFY; - $title = ["Readout","Waiting","Initialization","Calibration","Idle"]; - $address = [0xfffd,0xfffd,0xfffd,0xfffd,0xfffd]; - $register = [0x9113,0x9114,0x9111,0x9112,0x9110]; - $regoffset = [0,0,0,0,0]; - $regwidth = [32,32,32,32,32]; - genreg(); - } - -if($ARGV[0] =~ /gberate/) { - $delay = 1000000 unless $delay; - $curvestyle = "histostacked"; - $xticks = 1 unless $xticks; - $xtitle = "Sender"; - $ytitle = "Data Rate (kiB)" if $ytitle eq ""; - $windowname = "Gbe Data Rate"; - $key = NO; - $ydiff = DIFFY; - $xgrid = NO; - $address = [0xff7f]; - $register = [0x83f3]; - $regoffset = [10]; - $regwidth = [22]; - genreg(); - } - -if($ARGV[0] =~ /oepwords/) { - $delay = 1000000 unless $delay; - $xticks = 1 unless defined $xticks; - $xtitle = "Sender"; - $ytitle = "Data Words"; - $windowname = "Data Words sent by OEP"; - $yscale = [1]; - $key = NO; - $ydiff = DIFFY; - $address = [0xfffd]; - $register = [0x910B]; - $regoffset = [0]; - $regwidth = [32]; - genreg(); - } - - -if($ARGV[0] =~ /mdcchan/) { - $delay = 1000000 unless $delay; - $xticks = 1; - $xtitle = "Sender"; - $ytitle = "Data Words"; - $windowname = "Data words per TDC channel"; - $yscale = [1]; - $key = NO; - $ydiff = NODIFFY; - if ($ARGV[0] =~ /diff/) { - $ydiff = DIFFY; - } - $address = [$address->[0]?$address->[0]:0xfffd]; - $register = [0xc088]; - $regamount = [96]; - $regoffset = [0]; - $regwidth = [32]; - genreg(); - } - - -if($ARGV[0] =~ /regdiff/) { - $delay = 1000000 unless $delay; -# $xticks = 1 unless $xticks; - $ydiff = DIFFY; -# $key = NO unless defined $key; - $windowname = "General Plot" unless $windowname; - genreg(); - } - -if($ARGV[0] =~ /reg/) { - $delay = 1000000 unless $delay; -# $xticks = 1 unless $xticks; - $ydiff = NODIFFY; -# $key = NO unless defined $key; - $windowname = "General Plot" unless $windowname; - genreg(); - } - -if($ARGV[0] =~ /oeptrgerr/) { - $delay = 1000000 unless $delay; - $xticks = 1 unless defined $xticks; - $xtitle = "Board"; - $ytitle = "# of errors"; - $windowname = "OEP CMS Errors"; - $key = YES; - $ydiff = NODIFFY; - $title = ["Spikes","Spurious","Invalid","Multiple"]; - $address = [0xfffd,0xfffd,0xfffd,0xfffd]; - $register = [7,7,6,6]; - $regoffset = [0,16,0,16]; - $regwidth = [16,16,16,16]; - genreg(); - } - -if($ARGV[0] =~ /oepfill/) { - $delay = 1000000 unless $delay; - $xticks = 1 unless defined $xticks; - $xtitle = "Board"; - $ytitle = "Words in Buffer"; - $windowname = "OEP Buffer Fill Level"; - $key = NO; - $ydiff = NODIFFY; - $address = [0xfffd]; - $register = [0x7100]; - $regoffset = [0]; - $regwidth = [16]; - genreg(); - } - -if($ARGV[0] =~ /showerfill/) { - $delay = 1000000 unless $delay; - $xticks = 1 unless defined $xticks; - $xtitle = "Board"; - $ytitle = "Words in Buffer"; - $windowname = "Shower Data Buffer Fill Level"; - $key = $key || NO; - $ydiff = NODIFFY; - $address = [0xfff7,0xfff7,0xfff7,0xfff7,0xfff7,0xfff7]; - $register = [0x7100,0x7101,0x7102,0x7103,0x7104,0x7105]; - $regoffset = [0,0,0,0,0,0]; - $regwidth = [16,16,16,16,16,16]; - genreg(); - } - -if($ARGV[0] =~ /filllevel/) { - $delay = 1000000 unless $delay; - $xticks = 1 unless defined $xticks; - $xtitle = "Board"; - $ytitle = "Words in Buffer"; - $windowname = "Front-end Data Buffer Fill Level"; - $key = NO; - $ydiff = NODIFFY; - $address = [0xffff,0xffff,0xffff,0xffff,0xffff,0xffff]; - $register = [0x7100,0x7101,0x7102,0x7103,0x7104,0x7105]; - $regoffset = [0,0,0,0,0,0]; - $regwidth = [16,16,16,16,16,16]; - genreg(); - } - -if($ARGV[0] =~ /oepretr/) { - $delay = 1000000 unless $delay; - $windowname = "OEP Retransmissions"; - $key = YES; - $ydiff = NODIFFY; - $title = ["Retransmit Received","Retransmit Sent"]; - $address = [0xfffd,0xfffd]; - $register = [4,4]; - $regoffset = [16,24]; - $regwidth = [8,8]; - genreg(); - } - -if($ARGV[0] =~ /timecmslvl1/) { - $delay = 1000000 unless $delay; - $windowname = "Trigger Delay"; - $key = NO; - $ydiff = NODIFFY; - $ytitle = "Time between CMS and LVL1 [10ns]"; - $address = [0xfffd]; - $register = [2]; - $regoffset = [16]; - $regwidth = [11]; - genreg(); - } - -if($ARGV[0] =~ /oeptokenmiss/) { - $delay = 1000000 unless $delay; - $windowname = "OEP Token Missing"; - $key = NO; - $ydiff = NODIFFY; - $ytitle = "# of missing token"; - $address = [0xfffd]; - $register = [0x9101]; - $regoffset = [0]; - $regwidth = [24]; - genreg(); - } - -if($ARGV[0] =~ /slowcontrolrate/) { - $delay = 1000000 unless $delay; - $samples = 240 unless $samples; - $downscale = 1 unless $downscale; - $style = 0 unless $style; - $windowname = "Slow Control Data Rate"; - $ydiff = DIFFY; - $ytitle = "Slow Control Data / kByte/s"; - $address = [0x8000]; - $register = [0x4012]; - $regoffset = [0]; - $regwidth = [32]; - $yscale = [102.4]; - genhist(); - } - - - -if($ARGV[0] =~ /commonstatus/) { - bitmap(($delay)?$delay:1000000,[0xffff],[0],[1],[0],[20],["Common Status Bits"],0,$name." - Common Status Bit"); - } -if($ARGV[0] =~ /genbit/ || $ARGV[0] =~ /bitmap/) { - bitmap(($delay)?$delay:1000000,$address,$register,$regamount,$regoffset,$regwidth,$title,$style,$name." - ".$windowname); - } - diff --git a/hmon/hmon_hadplot.sh b/hmon/hmon_hadplot.sh new file mode 120000 index 0000000..93c6298 --- /dev/null +++ b/hmon/hmon_hadplot.sh @@ -0,0 +1 @@ +hmon_hadplotnew.sh \ No newline at end of file diff --git a/hmon/hmon_hodo.pl b/hmon/hmon_hodo.pl index 6172559..b7631c8 100755 --- a/hmon/hmon_hodo.pl +++ b/hmon/hmon_hodo.pl @@ -20,8 +20,8 @@ $plot2->{curves} = 16; $plot2->{type} = HPlot::TYPE_HEATMAP; $plot2->{output} = HPlot::OUT_PNG; $plot2->{zlabel} = "Hitrate"; -$plot2->{sizex} = 580; -$plot2->{sizey} = 465; +$plot2->{sizex} = 450; +$plot2->{sizey} = 360; $plot2->{nokey} = 1; $plot2->{buffer} = 1; $plot2->{xmin} = -0.5; @@ -36,7 +36,9 @@ $plot->{name} = "HodoRatePlot"; $plot->{file} = "files/HodoRatePlot"; $plot->{entries} = 16; $plot->{curves} = 2; -$plot->{type} = HPlot::TYPE_HISTORY; +$plot->{style} = 'dots'; +$plot->{curvewidth} = 1; +$plot->{type} = HPlot::TYPE_BARGRAPH; $plot->{output} = HPlot::OUT_PNG; $plot->{xlabel} = "Bar"; $plot->{ylabel} = "Hitrate"; @@ -51,12 +53,12 @@ $plot->{buffer} = 1; HPlot::PlotInit($plot); -my $str = Hmon::MakeTitle(9, 10, "Hodoscope Hit Rate"); +my $str = Hmon::MakeTitle(6, 8, "Hodoscope Hit Rate"); $str .= qq@
\n@; $str .= Hmon::MakeFooter(); Hmon::WriteFile("HodoRate",$str); -$str = Hmon::MakeTitle(9, 8, "Hodoscope Hit Rate"); +$str = Hmon::MakeTitle(8, 8, "Hodoscope Hit Rate"); $str .= qq@
\n@; $str .= Hmon::MakeFooter(); Hmon::WriteFile("HodoRatePlot",$str); diff --git a/hmon/hmon_hodo_hist.pl b/hmon/hmon_hodo_hist.pl index a9f4417..ca41168 100755 --- a/hmon/hmon_hodo_hist.pl +++ b/hmon/hmon_hodo_hist.pl @@ -15,70 +15,266 @@ use List::Util qw[min max]; my $plot = (); $plot->{name} = "HodoHist"; $plot->{file} = "files/HodoHist"; -$plot->{curves} = 8; +$plot->{curves} = 9; +$plot->{titles}->[0] = "Bar 1/2"; +$plot->{titles}->[1] = "Bar 3/4"; +$plot->{titles}->[2] = "Bar 5/6"; +$plot->{titles}->[3] = "Bar 7/8"; +$plot->{titles}->[4] = "Bar 9/10"; +$plot->{titles}->[5] = "Bar 11/12"; +$plot->{titles}->[6] = "Bar 13/14"; +$plot->{titles}->[7] = "Bar 15/16"; +$plot->{titles}->[8] = "Sum"; $plot->{entries} = 200; $plot->{type} = HPlot::TYPE_HISTORY; $plot->{output} = HPlot::OUT_PNG; $plot->{zlabel} = "Hitrate"; -$plot->{sizex} = 880; -$plot->{sizey} = 465; +$plot->{sizex} = 830; +$plot->{sizey} = 415; $plot->{nokey} = 0; $plot->{buffer} = 1; -$plot->{xscale} = 10; +$plot->{xscale} = 5; $plot->{xlabel} = "Time [s]"; $plot->{ylabel} = "Hits [1/s]"; HPlot::PlotInit($plot); +my $plot2 = (); +$plot2->{name} = "ScintiHist"; +$plot2->{file} = "files/ScintiHist"; +$plot2->{curves} = 1; +$plot2->{entries} = 200; +$plot2->{titles}->[0] = "Scintillator"; +$plot2->{type} = HPlot::TYPE_HISTORY; +$plot2->{output} = HPlot::OUT_PNG; +$plot2->{zlabel} = "Hitrate"; +$plot2->{sizex} = 680; +$plot2->{sizey} = 365; +$plot2->{nokey} = 0; +$plot2->{buffer} = 1; +$plot2->{xscale} = 5; +$plot2->{xlabel} = "Time [s]"; +$plot2->{ylabel} = "Hits [1/s]"; +HPlot::PlotInit($plot2); -my $str = Hmon::MakeTitle(12, 10, "Hodoscope Hit History"); +my $plot3 = (); +$plot3->{name} = "HitRatios"; +$plot3->{file} = "files/HitRatios"; +$plot3->{entries} = 4; +$plot3->{curves} = 1; +$plot3->{curvewidth} = 1; +$plot3->{type} = HPlot::TYPE_BARGRAPH; +$plot3->{output} = HPlot::OUT_PNG; +$plot3->{ylabel} = "Hit Ratio (dark rate substracted)"; +$plot3->{sizex} = 450; +$plot3->{sizey} = 360; +$plot3->{buffer} = 1; +$plot3->{nokey} = 1; +$plot3->{ymin} = 0; +$plot3->{ymax} = 2; +$plot3->{bartitle}->[0] = "Pi0 Y"; +$plot3->{bartitle}->[1] = "Pi0 X"; +$plot3->{bartitle}->[2] = "Pi1 Y"; +$plot3->{bartitle}->[3] = "Pi1 X"; +HPlot::PlotInit($plot3); + +my $plot4 = (); +$plot4->{name} = "HitRatioHist"; +$plot4->{file} = "files/HitRatioHist"; +$plot4->{entries} = 200; +$plot4->{curves} = 4; +$plot4->{xscale} = 5; +$plot4->{type} = HPlot::TYPE_HISTORY; +$plot4->{output} = HPlot::OUT_PNG; +$plot4->{ylabel} = "Hit Ratio (dark rate substracted)"; +$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"; +HPlot::PlotInit($plot4); + +my $plot5 = (); +$plot5->{name} = "HitSumHist"; +$plot5->{file} = "files/HitSumHist"; +$plot5->{entries} = 200; +$plot5->{curves} = 5; +$plot5->{xscale} = 5; +$plot5->{type} = HPlot::TYPE_HISTORY; +$plot5->{output} = HPlot::OUT_PNG; +$plot5->{ylabel} = "Hit Rate (dark rate substracted)"; +$plot5->{xlabel} = "Time [s]"; +$plot5->{sizex} = 650; +$plot5->{sizey} = 360; +$plot5->{buffer} = 1; +$plot5->{titles}->[0] = "Pi0 Y"; +$plot5->{titles}->[1] = "Pi0 X"; +$plot5->{titles}->[2] = "Pi1 Y"; +$plot5->{titles}->[3] = "Pi1 X"; +$plot5->{titles}->[4] = "Hodo"; +HPlot::PlotInit($plot5); + + +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(); +Hmon::WriteFile("HitRatios",$str); + +$str = Hmon::MakeTitle(9, 8, "Hit Ratio Hist"); +$str .= qq@
\n@; +$str .= Hmon::MakeFooter(); +Hmon::WriteFile("HitRatioHist",$str); + +$str = Hmon::MakeTitle(9, 8, "Hit Sums"); +$str .= qq@
\n@; +$str .= Hmon::MakeFooter(); +Hmon::WriteFile("HitSumHist",$str); + my $timer = 0; my $old; -my $oldtime = 0; +my $old2; +my $oldtime; my $time = 0; my $diff; +my $diff2; my $iter = 0; +my $offset; +my $histstore; + +$offset->{0x8890} = 0; +$offset->{0x3800} = 0; +$offset->{0x3801} = 0; +$offset->{0x3810} = 0; +$offset->{0x3811} = 0; trb_init_ports() or die trb_strerror(); while (1) { - my $o; - foreach my $b (0x5010,0x5013) { - my $t = trb_registertime_read_mem($b,0xc000,0,33); + my $o, my $o2; my $t; + foreach my $b (0x5010,0x5012,0x5013) { + $t = trb_registertime_read_mem($b,0xc000,0,33); $o->{$b} = $t->{$b}; } + $t = trb_registertime_read(0xfe49,0x8130); + if (defined $t) { + foreach my $b (keys $t) { + $o2->{$b}->{0x8130} = $t->{$b}; + } + } + +# $t = trb_registertime_read(0xfe49,0x841f); +# foreach my $b (keys $t) { +# $o2->{$b}->{0x841f} = $t->{$b}; +# } if (defined $old) { foreach my $b (keys %$o) { for my $v (0..32) { - my $tdiff = $o->{0x5010}->{time}->[0] - $oldtime; + my $tdiff = $o->{$b}->{time}->[0] - ($oldtime->{$b}||0); my $vdiff = ($o->{$b}->{value}->[$v]&0xffffff) - ($old->{$b}->{value}->[$v]&0xffffff); if ($vdiff < 0) { $vdiff += 2**24;} if ($tdiff < 0) { $tdiff += 2**16;} $tdiff *= 16; $diff->{$b}->[$v] = $vdiff/($tdiff||1E6)*1E6; } + $oldtime->{$b} = $o->{$b}->{time}->[0]; } + + foreach my $b (keys %$o2) { + foreach my $a (keys $o2->{$b}) { + my $tdiff = $o2->{$b}->{$a}->{time}->[0] - ($oldtime->{$b}||0); + my $vdiff = ($o2->{$b}->{$a}->{value}->[0]) - ($old2->{$b}->{$a}->{value}->[0]); + if ($vdiff < 0) { $vdiff += 2**32;} + if ($tdiff < 0) { $tdiff += 2**16;} + $tdiff *= 16; + $diff2->{$b}->{$a} = $vdiff/($tdiff||1E6)*1E6; + $oldtime->{$b} = $o2->{$b}->{$a}->{time}->[0]; + } + } + + my @sum = qw(0 0 0 0 0 0 0 0); + my $total = 0; for my $bar (0..7) { for my $x (0..1) { $sum[$bar/2+4] += $diff->{0x5010}->[$bar*2+1+$x*16]; $sum[$bar/2] += $diff->{0x5013}->[$bar*2+1+$x*16]; + $total += $diff->{0x5010}->[$bar*2+1+$x*16]; + $total += $diff->{0x5013}->[$bar*2+1+$x*16]; } } for my $i (0..7) { HPlot::PlotAdd("HodoHist",$sum[$i]/2,$i); +# $total += $sum[$i]/2; } - unless($timer++ % 10) { + HPlot::PlotAdd("ScintiHist",$diff->{0x5012}->[7],0); + HPlot::PlotAdd("HodoHist",$total/2,8); + + + + + 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); + + 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); + + } + else { + HPlot::PlotAdd("HitRatioHist",0,0); + HPlot::PlotAdd("HitRatioHist",0,1); + HPlot::PlotAdd("HitRatioHist",0,2); + HPlot::PlotAdd("HitRatioHist",0,3); + + HPlot::PlotFill("HitRatios",0,0); + HPlot::PlotFill("HitRatios",0,1); + HPlot::PlotFill("HitRatios",0,2); + HPlot::PlotFill("HitRatios",0,3); + + $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; + + } + + 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::PlotDraw('HodoHist'); + HPlot::PlotDraw('ScintiHist'); + HPlot::PlotDraw('HitRatioHist'); + HPlot::PlotDraw('HitRatios'); + HPlot::PlotDraw('HitSumHist'); } } $old = $o; - $oldtime = $o->{0x5010}->{time}->[0]; - usleep(100000); + $old2 = $o2; + usleep(200000); } diff --git a/hmon/hmon_mdchv_plottemplate.pl b/hmon/hmon_mdchv_plottemplate.pl index c580a24..e79a004 100755 --- a/hmon/hmon_mdchv_plottemplate.pl +++ b/hmon/hmon_mdchv_plottemplate.pl @@ -14,7 +14,7 @@ my $title = qq$ Hmon MDC HV Trends - +

Hmon MDC HV Trends

@@ -30,14 +30,52 @@ my $out = $title; foreach my $i (0..3) { $out .= "

Plane ".($i+1)."

"; - $out .= qq%Sector 1

%; - $out .= qq%Sector 2

%; - $out .= qq%Sector 3

%; - $out .= qq%Sector 4

%; - $out .= qq%Sector 5

%; - $out .= qq%Sector 6

%; + $out .= qq%
%; +# $out .= qq%Sector 2

%; +# $out .= qq%Sector 3

%; +# $out .= qq%Sector 4

%; +# $out .= qq%Sector 5

%; +# $out .= qq%Sector 6

%; } my $fh; -open ($fh,"> ".Hmon::HMONDIR."/files/MDCHVtrends.htm") or die; +open ($fh,"> ".Hmon::HMONDIR."/files/MDCHVvoltagetrends.htm") or die; print $fh $out; +close $fh; + + + +$title = qq$ + + + + + + Hmon MDC HV Current Trends + + +
+

Hmon MDC HV Current Trends

+
+
+$; + + $foot = qq$ + + + $; + + $out = $title; + +foreach my $i (0..3) { + $out .= "

Plane ".($i+1)."

"; + $out .= qq%
%; + } + +open ($fh,"> ".Hmon::HMONDIR."/files/MDCHVcurrenttrends.htm") or die; +print $fh $out; +close $fh; + + diff --git a/hmon/hmon_pionadc.pl b/hmon/hmon_pionadc.pl index e5712f9..8090d5a 100755 --- a/hmon/hmon_pionadc.pl +++ b/hmon/hmon_pionadc.pl @@ -3,27 +3,107 @@ use warnings; use strict; use Hmon; +use HADES::TrbNet; +use Data::Dumper; + +trb_init_ports() or die trb_strerror(); my $str = ""; +my $plots = fork(); + + +if($plots) { + while(1) { + my $histname = "ADC"; + my $address = 0; + my $addonfilter = 0; + + $str = Hmon::MakeTitle(9,12,"Pion 1 ADC Values",0); + ########### Hist Start ############################################################### + $address = 0x3800; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "\n"; + + ########### Hist Start ############################################################### + $address = 0x3801; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion1adc",$str); + + # ------------------------------------------------------------------------------------------------- + # + $str = Hmon::MakeTitle(9,12,"Pion 2 ADC Values",0); + ########### Hist Start ############################################################### + $address = 0x3810; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; -$str = Hmon::MakeTitle(9,12,"Pion 1 ADC Values", 0); -$str .= "
\n"; -$str .= "\n"; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("pion1adc",$str); + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= "
"; + $str .= "
\n"; + ########### Hist Start ############################################################### + $address = 0x3811; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; -$str = Hmon::MakeTitle(9,12,"Pion 2 ADC Values", 0); -$str .= "
\n"; -$str .= "\n"; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("pion2adc",$str); + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= "
"; + $str .= "\n"; + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion2adc",$str); + sleep(5); + } +} else { - qx(./hmon_hadplot.sh -d 2000 -a 0x3800 -r 0x8b00 -m 128 -w 32 -p 0 -t "Y Channel" -xtitle "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC1X.700.265" reg >/dev/null & - ./hmon_hadplot.sh -d 2000 -a 0x3801 -r 0x8b00 -m 128 -w 32 -p 0 -t "X Channel" -xtitle "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC1Y.700.265" reg >/dev/null & - ./hmon_hadplot.sh -d 2000 -a 0x3810 -r 0x8b00 -m 128 -w 32 -p 0 -t "Y Channel" -xtitle "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC2X.700.265" reg >/dev/null & - ./hmon_hadplot.sh -d 2000 -a 0x3811 -r 0x8b00 -m 128 -w 32 -p 0 -t "X Channel" -xtitle "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC2Y.700.265" reg >/dev/null &); + qx(./hmon_hadplotnew.sh -d 2000 -a 0x3800 -r 0x8b00 -m 128 -w 32 -p 0 -t "Y Channel" -xtitle "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC1X.700.265" reg >/dev/null & + ./hmon_hadplotnew.sh -d 2000 -a 0x3801 -r 0x8b00 -m 128 -w 32 -p 0 -t "X Channel" -xtitle "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC1Y.700.265" reg >/dev/null & + ./hmon_hadplotnew.sh -d 2000 -a 0x3810 -r 0x8b00 -m 128 -w 32 -p 0 -t "Y Channel" -xtitle "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC2X.700.265" reg >/dev/null & + ./hmon_hadplotnew.sh -d 2000 -a 0x3811 -r 0x8b00 -m 128 -w 32 -p 0 -t "X Channel" -xtitle "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -key -curvestyle steps -xmin -1 -xmax 128 -ymin 0 -ymax 4100 -output "PNG.files/PionADC2Y.700.265" reg >/dev/null &); - + +} diff --git a/hmon/hmon_pionovfl.pl b/hmon/hmon_pionovfl.pl new file mode 100755 index 0000000..bf71752 --- /dev/null +++ b/hmon/hmon_pionovfl.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Hmon; +use HADES::TrbNet; +use Data::Dumper; + +trb_init_ports() or die trb_strerror(); + +my $str = ""; + +my $plots = fork(); + + +if($plots) { + while(1) { + my $histname = "Overflow Rate"; + my $address = 0; + my $filter = 0; + my $addonfilter = 0; + + $str = Hmon::MakeTitle(9,12,"Pion 1 Ovfl Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3800; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + ########### Hist Start ############################################################### + $address = 0x3801; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion1ovfl",$str); + + # ------------------------------------------------------------------------------------------------------ + + + $str = Hmon::MakeTitle(9,12,"Pion 2 Ovfl Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3810; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + + # + # Get Histogram Filter Status + # + ########### Hist Start ############################################################### + $address = 0x3811; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion2ovfl",$str); + sleep(5); + } +} else { + qx(./hmon_hadplotnew.sh -d 1000 -a 0x3800 -r 0x8a00 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion1XOvfl.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3801 -r 0x8a00 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion1YOvfl.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3810 -r 0x8a00 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion2XOvfl.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3811 -r 0x8a00 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion2YOvfl.700.265" regdiff >/dev/null &); +} + + diff --git a/hmon/hmon_pionpileup.pl b/hmon/hmon_pionpileup.pl new file mode 100755 index 0000000..66dbc2f --- /dev/null +++ b/hmon/hmon_pionpileup.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Hmon; +use HADES::TrbNet; +use Data::Dumper; + +trb_init_ports() or die trb_strerror(); + +my $str = ""; + +my $plots = fork(); + + +if($plots) { + while(1) { + my $histname = "Pileup Rate"; + my $address = 0; + my $filter = 0; + my $addonfilter = 0; + + $str = Hmon::MakeTitle(9,12,"Pion 1 Pileup Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3800; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + ########### Hist Start ############################################################### + $address = 0x3801; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion1pileup",$str); + + # ------------------------------------------------------------------------------------------------------ + + + $str = Hmon::MakeTitle(9,12,"Pion 2 Pileup Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3810; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + + # + # Get Histogram Filter Status + # + ########### Hist Start ############################################################### + $address = 0x3811; + $filter = trb_register_read($address, 0x8400); + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($filter->{$address} & 0x80000000) == 0) { + if (($addonfilter->{$address} & 0x80000000) > 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion2pileup",$str); + sleep(5); + } +} else { + qx(./hmon_hadplotnew.sh -d 1000 -a 0x3800 -r 0x8900 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion1XPileup.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3801 -r 0x8900 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion1YPileup.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3810 -r 0x8900 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion2XPileup.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3811 -r 0x8900 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion2YPileup.700.265" regdiff >/dev/null &); +} + + diff --git a/hmon/hmon_pionrate.pl b/hmon/hmon_pionrate.pl index 3a57ab7..b54d090 100755 --- a/hmon/hmon_pionrate.pl +++ b/hmon/hmon_pionrate.pl @@ -14,70 +14,97 @@ my $plots = fork(); if($plots) { - while(1) { - my $filter; - - $str = Hmon::MakeTitle(9,12,"Pion 1 Rates",0); - # - # Get Histogram Filter Status - # - $filter = trb_register_read(0x3800, 0x8400); - print Dumper $filter; - if (($filter->{0x3800} & 0x80000000) > 0) { - $str .= "All Data"; - } else { - $str .= "Event Buffer Data"; - } - $str .= "\n"; - - # Get Histogram Filter Status - # - $filter = trb_register_read(0x3801, 0x8400); - if (($filter->{0x3801} & 0x80000000) > 0) { - $str .= "All Data"; - } else { - $str .= "Event Buffer Data"; - } - $str .= "\n"; - - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("pion1rate",$str); - - # --------------------------------------------------------------------------------------------------------- - # - $str = Hmon::MakeTitle(9,12,"Pion 2 Rates",0); - # - # Get Histogram Filter Status - # - $filter = trb_register_read(0x3810, 0x8400); - if (($filter->{0x3810} & 0x80000000) > 0) { - $str .= "All Data"; - } else { - $str .= "Event Buffer Data"; - } - $str .= "
\n"; - - # - # Get Histogram Filter Status - # - $filter = trb_register_read(0x3811, 0x8400); - if (($filter->{0x3811} & 0x80000000) > 0) { - $str .= "All Data"; - } else { - $str .= "Event Buffer Data"; - } - $str .= "\n"; + while(1) { + my $histname = "Hit Rate"; + my $address = 0; + my $addonfilter = 0; + + $str = Hmon::MakeTitle(9,12,"Pion 1 Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3800; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "\n"; + + ########### Hist Start ############################################################### + $address = 0x3801; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion1rate",$str); - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("pion2rate",$str); - sleep(5); + # --------------------------------------------------------------------------------------------------------- + + $str = Hmon::MakeTitle(9,12,"Pion 2 Rates",0); + + ########### Hist Start ############################################################### + $address = 0x3810; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "
\n"; + + ########### Hist Start ############################################################### + $address = 0x3811; + $addonfilter = trb_register_read($address, 0x8420); + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} (TS Cut Level2)"; + } else { + $str .= "${histname} (TS Cut)"; + } + } else { + $str .= "${histname}"; + } + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion2rate",$str); + sleep(5); } - } -else{ - qx(./hmon_hadplot.sh -d 1000 -a 0x3800 -r 0x8800 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -output "PNG.files/Pion1X.700.265" regdiff >/dev/null & - ./hmon_hadplot.sh -d 1000 -a 0x3801 -r 0x8800 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion1Y.700.265" regdiff >/dev/null & - ./hmon_hadplot.sh -d 1000 -a 0x3810 -r 0x8800 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (5cm) UP (5cm)" -output "PNG.files/Pion2X.700.265" regdiff >/dev/null & - ./hmon_hadplot.sh -d 1000 -a 0x3811 -r 0x8800 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion2Y.700.265" regdiff >/dev/null &); - } - - +} else { + qx(./hmon_hadplotnew.sh -d 1000 -a 0x3800 -r 0x8800 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion1X.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3801 -r 0x8800 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion1Y.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3810 -r 0x8800 -m 128 -w 32 -p 0 -t "Y Channels" -key -xtitle "DOWN (-5cm) UP (5cm)" -output "PNG.files/Pion2X.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3811 -r 0x8800 -m 128 -w 32 -p 0 -t "X Channels" -key -xtitle "RIGHT (-5cm) LEFT (5cm)" -output "PNG.files/Pion2Y.700.265" regdiff >/dev/null &); +} + + diff --git a/hmon/hmon_pionts.pl b/hmon/hmon_pionts.pl new file mode 100755 index 0000000..042b29d --- /dev/null +++ b/hmon/hmon_pionts.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Hmon; +use HADES::TrbNet; +use Data::Dumper; + +trb_init_ports() or die trb_strerror(); + +my $str = ""; + +my $plots = fork(); +my @rangestr = ("0.5μs", + " 1μs", + " 2μs", + " 4μs", + " 8μs", + " 16μs" + ); + +if($plots) { + while(1) { + my $histname = "Timestamp"; + my $address = 0; + my $addonfilter = 0; + my $range = 0; + my $Range; + + $str = Hmon::MakeTitle(9,12,"Pion 1 Timestamps",0); + + ########### Hist Start ############################################################### + $address = 0x3800; + $addonfilter = trb_register_read($address, 0x8420); + $range = trb_register_read($address, 0x8421); + $Range = $rangestr[$range->{$address}]; + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} ${Range} (TS Cut Level2)"; + } else { + $str .= "${histname} ${Range} (TS Cut)"; + } + } else { + $str .= "${histname} ${Range}"; + } + $str .= ""; + $str .= "\n"; + + ########### Hist Start ############################################################### + $address = 0x3801; + $addonfilter = trb_register_read($address, 0x8420); + $range = trb_register_read($address, 0x8421); + $Range = $rangestr[$range->{$address}]; + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} ${Range} (TS Cut Level2)"; + } else { + $str .= "${histname} ${Range} (TS Cut)"; + } + } else { + $str .= "${histname} ${Range}"; + } + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion1ts",$str); + + # --------------------------------------------------------------------------------------------------------- + + $str = Hmon::MakeTitle(9,12,"Pion 2 Timestamps",0); + + ########### Hist Start ############################################################### + $address = 0x3810; + $addonfilter = trb_register_read($address, 0x8420); + $range = trb_register_read($address, 0x8421); + $Range = $rangestr[$range->{$address}]; + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} ${Range} (TS Cut Level2)"; + } else { + $str .= "${histname} ${Range} (TS Cut)"; + } + } else { + $str .= "${histname} ${Range}"; + } + $str .= ""; + $str .= "
\n"; + + ########### Hist Start ############################################################### + $address = 0x3811; + $addonfilter = trb_register_read($address, 0x8420); + $range = trb_register_read($address, 0x8421); + $Range = $rangestr[$range->{$address}]; + $str .= ""; + + if (($addonfilter->{$address} & 0x80000000) != 0) { + if (($addonfilter->{$address} & 0x40000000) != 0) { + $str .= "${histname} ${Range} (TS Cut Level2)"; + } else { + $str .= "${histname} ${Range} (TS Cut)"; + } + } else { + $str .= "${histname} ${Range}"; + } + $str .= ""; + $str .= "\n"; + + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("pion2ts",$str); + sleep(5); + } +} else { + qx(./hmon_hadplotnew.sh -d 1000 -a 0x3800 -r 0x8c00 -m 512 -w 32 -p 0 -t "Y Timestamps" -key -output "PNG.files/Pion1YTS.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3801 -r 0x8c00 -m 512 -w 32 -p 0 -t "X Timestamps" -key -output "PNG.files/Pion1XTS.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3810 -r 0x8c00 -m 512 -w 32 -p 0 -t "Y Timestamps" -key -output "PNG.files/Pion2YTS.700.265" regdiff >/dev/null & + ./hmon_hadplotnew.sh -d 1000 -a 0x3811 -r 0x8c00 -m 512 -w 32 -p 0 -t "X Timestamps" -key -output "PNG.files/Pion2XTS.700.265" regdiff >/dev/null &); +} + + diff --git a/hmon/hmon_rate2.pl b/hmon/hmon_rate2.pl index 6c9488f..3673031 100755 --- a/hmon/hmon_rate2.pl +++ b/hmon/hmon_rate2.pl @@ -134,6 +134,12 @@ while (1) { $longtext = sprintf("Trigger Rate from Start: %i Hz",$store{0xa009}); QA::WriteQALog($fqa, "rate", "start", 10, $state, 'Start Rate', $shorttext, $longtext); + + $state = QA::OK; + $shorttext = QA::SciNotation(($store{0xa03c}-220)/(($store{0xa037}-780)||1)); + $longtext = sprintf("Trigger Rate from PT1/TOF vs. Hodoscope: %.2f",($store{0xa03c}-220)/(($store{0xa037}-780)||1)); + QA::WriteQALog($fqa, "trg", "pt1rate", 10, + $state, 'Hodo/PT1', $shorttext, $longtext); sleep 1; } diff --git a/hmon/hmon_starthist.pl b/hmon/hmon_starthist.pl old mode 100644 new mode 100755 index 2c4fea7..9e7fc0f --- a/hmon/hmon_starthist.pl +++ b/hmon/hmon_starthist.pl @@ -14,6 +14,15 @@ my $plots = fork(); if($plots) { my $i = 0; + + $str = Hmon::MakeTitle(10,8,"Hodo Fine Histogram",0); + $str .= qq@ + + @; + $str .= Hmon::MakeFooter(); + Hmon::WriteFile("HodoFineHist",$str); + + while(1) { my $binning = trb_register_read(3,0xa0c8) or sleep 5 and next; my $offset = trb_register_read(3,0xa0c6) or sleep 5 and next; @@ -58,50 +67,57 @@ if($plots) { } } else { - qx(./hmon_hadplot.sh -d 3000 \\ - -a 0x0003 -r 42216 -m 500 -p 0 -w 32 -t "X 1" \\ - -a 0x0003 -r 42716 -m 500 -p 0 -w 32 -t "X 2" \\ - -a 0x0003 -r 43216 -m 500 -p 0 -w 32 -t "X 3" \\ - -a 0x0003 -r 43716 -m 500 -p 0 -w 32 -t "X 4" \\ - -a 0x0003 -r 44216 -m 500 -p 0 -w 32 -t "X 5" \\ - -a 0x0003 -r 44716 -m 500 -p 0 -w 32 -t "X 6" \\ - -a 0x0003 -r 45216 -m 500 -p 0 -w 32 -t "X 7" \\ - -a 0x0003 -r 45716 -m 500 -p 0 -w 32 -t "X 8" \\ - -output "PNG.files/starthistx0.760.365" -curvestyle steps -key genreg 2>/dev/null & - -./hmon_hadplot.sh -d 3000 \\ - -a 0x0003 -r 46216 -m 500 -p 0 -w 32 -t "Y 1" \\ - -a 0x0003 -r 46716 -m 500 -p 0 -w 32 -t "Y 2" \\ - -a 0x0003 -r 47216 -m 500 -p 0 -w 32 -t "Y 3" \\ - -a 0x0003 -r 47716 -m 500 -p 0 -w 32 -t "Y 4" \\ - -a 0x0003 -r 48216 -m 500 -p 0 -w 32 -t "Y 5" \\ - -a 0x0003 -r 48716 -m 500 -p 0 -w 32 -t "Y 6" \\ - -a 0x0003 -r 49216 -m 500 -p 0 -w 32 -t "Y 7" \\ - -a 0x0003 -r 49716 -m 500 -p 0 -w 32 -t "Y 8" \\ --output "PNG.files/starthisty0.760.365" -curvestyle steps -key genreg 2>/dev/null & - -./hmon_hadplot.sh -d 3000 \\ - -a 0x0003 -r 42216 -m 500 -p 0 -w 32 -t "X 1" \\ - -a 0x0003 -r 42716 -m 500 -p 0 -w 32 -t "X 2" \\ - -a 0x0003 -r 43216 -m 500 -p 0 -w 32 -t "X 3" \\ - -a 0x0003 -r 43716 -m 500 -p 0 -w 32 -t "X 4" \\ - -a 0x0003 -r 44216 -m 500 -p 0 -w 32 -t "X 5" \\ - -a 0x0003 -r 44716 -m 500 -p 0 -w 32 -t "X 6" \\ - -a 0x0003 -r 45216 -m 500 -p 0 -w 32 -t "X 7" \\ - -a 0x0003 -r 45716 -m 500 -p 0 -w 32 -t "X 8" \\ - -output "PNG.files/starthiststackedx0.760.365" -curvestyle histostacked -key genreg 2>/dev/null & - -./hmon_hadplot.sh -d 3000 \\ - -a 0x0003 -r 46216 -m 500 -p 0 -w 32 -t "Y 1" \\ - -a 0x0003 -r 46716 -m 500 -p 0 -w 32 -t "Y 2" \\ - -a 0x0003 -r 47216 -m 500 -p 0 -w 32 -t "Y 3" \\ - -a 0x0003 -r 47716 -m 500 -p 0 -w 32 -t "Y 4" \\ - -a 0x0003 -r 48216 -m 500 -p 0 -w 32 -t "Y 5" \\ - -a 0x0003 -r 48716 -m 500 -p 0 -w 32 -t "Y 6" \\ - -a 0x0003 -r 49216 -m 500 -p 0 -w 32 -t "Y 7" \\ - -a 0x0003 -r 49716 -m 500 -p 0 -w 32 -t "Y 8" \\ --output "PNG.files/starthiststackedy0.760.365" -curvestyle histostacked -key genreg 2>/dev/null & - + 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" \\ + -output "PNG.files/hodofinehist.760.365" -curvestyle steps -key genreg 2>/dev/null & ); + +# qx(./hmon_hadplot_old.sh -d 3000 \\ +# -a 0x0003 -r 42216 -m 500 -p 0 -w 32 -t "X 1" \\ +# -a 0x0003 -r 42716 -m 500 -p 0 -w 32 -t "X 2" \\ +# -a 0x0003 -r 43216 -m 500 -p 0 -w 32 -t "X 3" \\ +# -a 0x0003 -r 43716 -m 500 -p 0 -w 32 -t "X 4" \\ +# -a 0x0003 -r 44216 -m 500 -p 0 -w 32 -t "X 5" \\ +# -a 0x0003 -r 44716 -m 500 -p 0 -w 32 -t "X 6" \\ +# -a 0x0003 -r 45216 -m 500 -p 0 -w 32 -t "X 7" \\ +# -a 0x0003 -r 45716 -m 500 -p 0 -w 32 -t "X 8" \\ +# -output "PNG.files/starthistx0.760.365" -curvestyle steps -key genreg 2>/dev/null & +# +# ./hmon_hadplot_old.sh -d 3000 \\ +# -a 0x0003 -r 46216 -m 500 -p 0 -w 32 -t "Y 1" \\ +# -a 0x0003 -r 46716 -m 500 -p 0 -w 32 -t "Y 2" \\ +# -a 0x0003 -r 47216 -m 500 -p 0 -w 32 -t "Y 3" \\ +# -a 0x0003 -r 47716 -m 500 -p 0 -w 32 -t "Y 4" \\ +# -a 0x0003 -r 48216 -m 500 -p 0 -w 32 -t "Y 5" \\ +# -a 0x0003 -r 48716 -m 500 -p 0 -w 32 -t "Y 6" \\ +# -a 0x0003 -r 49216 -m 500 -p 0 -w 32 -t "Y 7" \\ +# -a 0x0003 -r 49716 -m 500 -p 0 -w 32 -t "Y 8" \\ +# -output "PNG.files/starthisty0.760.365" -curvestyle steps -key genreg 2>/dev/null & +# +# ./hmon_hadplot_old.sh -d 3000 \\ +# -a 0x0003 -r 42216 -m 500 -p 0 -w 32 -t "X 1" \\ +# -a 0x0003 -r 42716 -m 500 -p 0 -w 32 -t "X 2" \\ +# -a 0x0003 -r 43216 -m 500 -p 0 -w 32 -t "X 3" \\ +# -a 0x0003 -r 43716 -m 500 -p 0 -w 32 -t "X 4" \\ +# -a 0x0003 -r 44216 -m 500 -p 0 -w 32 -t "X 5" \\ +# -a 0x0003 -r 44716 -m 500 -p 0 -w 32 -t "X 6" \\ +# -a 0x0003 -r 45216 -m 500 -p 0 -w 32 -t "X 7" \\ +# -a 0x0003 -r 45716 -m 500 -p 0 -w 32 -t "X 8" \\ +# -output "PNG.files/starthiststackedx0.760.365" -curvestyle histostacked -key genreg 2>/dev/null & +# +# ./hmon_hadplot_old.sh -d 3000 \\ +# -a 0x0003 -r 46216 -m 500 -p 0 -w 32 -t "Y 1" \\ +# -a 0x0003 -r 46716 -m 500 -p 0 -w 32 -t "Y 2" \\ +# -a 0x0003 -r 47216 -m 500 -p 0 -w 32 -t "Y 3" \\ +# -a 0x0003 -r 47716 -m 500 -p 0 -w 32 -t "Y 4" \\ +# -a 0x0003 -r 48216 -m 500 -p 0 -w 32 -t "Y 5" \\ +# -a 0x0003 -r 48716 -m 500 -p 0 -w 32 -t "Y 6" \\ +# -a 0x0003 -r 49216 -m 500 -p 0 -w 32 -t "Y 7" \\ +# -a 0x0003 -r 49716 -m 500 -p 0 -w 32 -t "Y 8" \\ +# -output "PNG.files/starthiststackedy0.760.365" -curvestyle histostacked -key genreg 2>/dev/null & +# +# ); } diff --git a/hmon/hmon_trgsource.pl b/hmon/hmon_trgsource.pl index 1d2bee5..5023855 100755 --- a/hmon/hmon_trgsource.pl +++ b/hmon/hmon_trgsource.pl @@ -88,9 +88,18 @@ while (1) { $lastoutofspill = $outofspill; $outofspill = ($rStat->{0x3}->[2] || 0) & 0x10; - + my $trgacc = 0; + +# printf("%i\n",$rh->{3}->[30]); $rh->{3}->[0] <<= 2; #shift to align with outputs - $rh->{3}->[30] = 200000000/($rh->{3}->[30] || 1) if $rh->{3}->[30]; + if (($rh->{3}->[30]&0xffffff) != 0) { + $rh->{3}->[30] = 200000000./((($rh->{3}->[30]&0xffffff)+1)|| 1); + } + else { + $rh->{3}->[30] = 0; + } + +# printf("%i\n",$rh->{3}->[30]); #Decode downscaling for (my $i = 0; $i<8; $i++) { @@ -105,8 +114,7 @@ while (1) { my $accmsg = ""; my $acclmsg = ""; my $trgprov = 0; - my $trgacc = 0; - + if($rh->{3}->[30]) { $qastate = QA::NOTE; $msg .= sprintf("%sHz ",QA::SciNotation($rh->{3}->[30])); @@ -229,10 +237,14 @@ my $longmsgcheck = $longmsg; my $startmsg = ""; my $startlongmsg = ""; - foreach my $i (0..7) { - $startsum += $rStat->{3}->[$i+0x8] ; - } +# foreach my $i (0..7) { +# $startsum += $rStat->{3}->[$i+0x8] ; +# } +# $spillsum += $startsum; +# + $startsum = $rStat->{3}->[0x29]; $spillsum += $startsum; + ###################################### ## QA check for spill sum on Start if ($lastspillsum < 0 || $lastspillsum > 50000000) { @@ -246,8 +258,8 @@ my $longmsgcheck = $longmsg; $spillsum = 0; } $startmsg = sprintf("%s / %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum)); - $startlongmsg = sprintf("Start counts per second %s/s - Start counts per spill %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum)); - QA::WriteQALog($fqa, "trg", "start", 10, $qastatstart, "Start Count", $startmsg, $startlongmsg); + $startlongmsg = sprintf("Hodo counts per second %s/s - Hodo counts per spill %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum)); + QA::WriteQALog($fqa, "trg", "start", 10, $qastatstart, "Hodo Count", $startmsg, $startlongmsg); diff --git a/hmon/index.cgi b/hmon/index.cgi index cb68eff..4174278 100755 --- a/hmon/index.cgi +++ b/hmon/index.cgi @@ -49,14 +49,18 @@ function openwin(url) { @@ -65,8 +69,8 @@ function openwin(url) {
  • Eventrate histogram (10s)
  • Eventrate histogram (60s)
  • Eventrate histogram (10m)
  • -
  • Start counts per spill
  • -
  • Ratio of accepted PT3 per spill
  • +
  • Recorded events per spill
  • Start hit count histograms
  • @@ -90,12 +94,13 @@ function openwin(url) { -