From: J.Adamczewski-Musch Date: Mon, 17 Oct 2022 08:59:52 +0000 (+0200) Subject: Added script for collab db exports. X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=d4175229ddfed8512475975f8226982c0cac21a8;p=hadesdaq.git Added script for collab db exports. Check in everything else --- diff --git a/beamabort/beam_abort_init_beamCond.trbcmd b/beamabort/beam_abort_init_beamCond.trbcmd index 39923d3..e582a27 100644 --- a/beamabort/beam_abort_init_beamCond.trbcmd +++ b/beamabort/beam_abort_init_beamCond.trbcmd @@ -31,21 +31,21 @@ w 0x0130 0xe01d 0x00000000 #Indiv_Timewindow.29 w 0x0130 0xe01e 0x00000000 #Indiv_Timewindow.30 w 0x0130 0xe01f 0x00000000 #Indiv_Timewindow.31 -w 0x0130 0xe100 40000 -w 0x0130 0xe101 40000 -w 0x0130 0xe102 40000 -w 0x0130 0xe103 40000 -w 0x0130 0xe104 40000 -w 0x0130 0xe105 40000 +w 0x0130 0xe100 600000 +w 0x0130 0xe101 600000 +w 0x0130 0xe102 600000 +w 0x0130 0xe103 600000 +w 0x0130 0xe104 600000 +w 0x0130 0xe105 600000 w 0x0130 0xe106 0x00000000 #Indiv_Limit.6 w 0x0130 0xe107 0x00000000 #Indiv_Limit.7 -w 0x0130 0xe108 40000 -w 0x0130 0xe109 40000 -w 0x0130 0xe10a 40000 -w 0x0130 0xe10b 40000 +w 0x0130 0xe108 600000 +w 0x0130 0xe109 600000 +w 0x0130 0xe10a 600000 +w 0x0130 0xe10b 600000 w 0x0130 0xe10c 0x00000000 #Indiv_Limit.12 -w 0x0130 0xe10d 40000 -w 0x0130 0xe10e 40000 +w 0x0130 0xe10d 600000 +w 0x0130 0xe10e 600000 w 0x0130 0xe10f 0x00000000 #Indiv_Limit.15 w 0x0130 0xe110 0x00000000 #Indiv_Limit.16 w 0x0130 0xe111 0x00000000 #Indiv_Limit.17 diff --git a/control/gui/power/ECAL_Padiwa_Powercycle b/control/gui/power/ECAL_Padiwa_Powercycle index 661ba07..24cb766 100755 --- a/control/gui/power/ECAL_Padiwa_Powercycle +++ b/control/gui/power/ECAL_Padiwa_Powercycle @@ -8,7 +8,7 @@ if [ $myvar == "256" ]; then exit; fi xterm -e bash --login -c ' ssh hadaq@lxhadesdaqp " source /home/hadaq/.bash_profile - echo \"Starting a STS / fRPC Power-Cycle...\" + echo \"Starting a ECal Padiwa Power-Cycle...\" cd /home/hadaq/hadesdaq/utils; PERLLIB=/home/hadaq/EPICS/EPICS-3.15.6/base/lib/perl ./ECAL_LV5_Powercycle.sh; echo Done diff --git a/control/gui/settings/Beam_Abort_Enable b/control/gui/settings/Beam_Abort_Enable deleted file mode 100755 index 9522c8d..0000000 --- a/control/gui/settings/Beam_Abort_Enable +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -xterm -geometry 80x24 -bg orange -fg black -e bash -c ' - ssh hadaq@hadesp33 " - echo Enable Beam Abort - ssh hadeswrp02 /home/hadaq/bin/enable_beam_abort.sh - echo Done - sleep 5 - " -' - - - diff --git a/control/gui/settings/Thresholds_Start b/control/gui/settings/Thresholds_Start index c849586..65133d1 100755 --- a/control/gui/settings/Thresholds_Start +++ b/control/gui/settings/Thresholds_Start @@ -6,6 +6,7 @@ xterm -geometry 80x24 -bg orange -fg black -e bash --login -c ' echo \" Setting Thresholds...\" cd /home/hadaq/trbsoft/hadesdaq/start ./set_threshold_start.sh + /home/hadaq/trbsoft/daqtools/tools/dac_program.pl /home/hadaq/trbsoft/daq/start/threshold/DAC_nino_16ch.db echo \"Done\" sleep 10 " diff --git a/control/mdcLVgui/S0/200x b/control/mdcLVgui/S0/200x index ed8ce15..6e0e776 100755 --- a/control/mdcLVgui/S0/200x +++ b/control/mdcLVgui/S0/200x @@ -10,6 +10,6 @@ PERLLIB=\${EPICS_BASE}lib/perl:~/trbsoft/hadesdaq/nettools:~/trbsoft/daqtools/pe cd ~/trbsoft/hadesdaq/utils && ./MDC_Powercycle_2PSx.pl -P 1 -S 1 - sleep 1 + sleep 10 " ' diff --git a/ecal/addresses_ecal.db b/ecal/addresses_ecal.db index ff240cc..6a7b1b9 100644 --- a/ecal/addresses_ecal.db +++ b/ecal/addresses_ecal.db @@ -38,7 +38,7 @@ 0x6043 125 1 0 0 0x6044 113 1 0 0 0x6045 309 1 0 0 #133 22-01-13 - 0x6046 124 1 0 0 + 0x6046 463 1 0 0 #124 5.3.22 0x6050 122 1 0 0 0x6051 305 1 0 0 diff --git a/evtbuild/start_eb_gbe.sh b/evtbuild/start_eb_gbe.sh index 45d6d4f..c45cfe6 100755 --- a/evtbuild/start_eb_gbe.sh +++ b/evtbuild/start_eb_gbe.sh @@ -1 +1 @@ -./start_eb_gbe.pl -e restart -n 1-16 -d on -p te -b 10; +./start_eb_gbe.pl -e restart -n 1-16 -d on -p te -b 1; diff --git a/evtbuild/start_eb_gbe_2021-test.pl b/evtbuild/start_eb_gbe_2021-test.pl index c1e2118..89fb055 100755 --- a/evtbuild/start_eb_gbe_2021-test.pl +++ b/evtbuild/start_eb_gbe_2021-test.pl @@ -95,7 +95,7 @@ if ($opt_eb eq "start") { &stopEvtBuilders(); } elsif ($opt_eb eq "restart") { &stopEvtBuilders(); - sleep 1; + sleep 10; &writeArgs2file(); &startEvtBuilders(); } @@ -500,9 +500,10 @@ sub startBnet() { my $core_nr = &getCoreNr($cpu, 'input'); # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_inp 1senderlog_$cpu.log 2>&1 & (sleep 2; ~/bin/optimize_taskset.sh) &\""; + my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_inp 1senderlog_$cpu.log 2>&1 &\"" ; + # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_inp >senderlog_$cpu.log 2>&1 & (sleep 2; ~/bin/optimize_taskset.sh) &\""; # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports $cmd_dabc $conf_bnet_inp >senderlog_$cpu.log 2>&1 &\""; @@ -516,7 +517,11 @@ sub startBnet() { $bninpport = $bninpport +1; } # bnet sender/input processes } # end senders + + sleep 1; + # JAM12-2021 -maybe this helps for connection, wait until server sockets of senders are all up? # todo: loop over builders + # reduced to 1 second again, mt for ( my $ebserver=0; $ebserver<$maxbuildservers; $ebserver=$ebserver+1) { print "Starting builder processes on EB server: $ebserver\n"; @@ -542,7 +547,7 @@ sub startBnet() { # no daqdisk demon anymore for raid6- $exports = $exports . "export DAQDISK=0; export OUTDIR=/data01/data; "; - + if ( $EB_Args_href->{$ebproc}->{'LTSM'} ) { # switch on by number of outputs @@ -574,10 +579,7 @@ sub startBnet() { # stick to full storage lustre and tsm- $exports = $exports . " export FSQDEST=4;"; } - - - - + # $exports = $exports . " export FSDPORT=". $EB_Args_href->{$ebproc}->{'LTSM_FSD_PORT'} . ";"; # $exports = $exports . " export FSDSERVER=". $EB_Args_href->{$ebproc}->{'LTSM_FSD_SERVER'} . ";"; my $fsdix=$ebserver % 6; # number of FSD servers used TODO get from configuration @@ -592,10 +594,10 @@ sub startBnet() { my $core_nr = &getCoreNr($cpu, 'build'); #y $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_bld 1builderlog_$cpu.log 2>&1 &\""; @@ -625,7 +627,7 @@ sub startBnet() { sleep (5); # seems also to be fine: michael, 2019-02-18 # sleep (20) # old # need to wait until forking is done, otherwise it does not work via gui control xterm - + } @@ -648,8 +650,8 @@ sub stopEvtBuilders() { #--- Loop over server IPs foreach my $ip (@bnetservers) { - my $exe = "ssh -n $ip -l $username \"/home/hadaq/bin/cleanup_evtbuild.pl; /home/hadaq/bin/ipcrm.pl\""; - + #my $exe = "ssh -n $ip -l $username \"/home/hadaq/bin/cleanup_evtbuild.pl; /home/hadaq/bin/ipcrm.pl\""; + my $exe = "ssh -n $ip -l $username \"/home/hadaq/bin/cleanup_evtbuild.pl\""; if ($opt_verb) { print "Killing running EBs...\n"; print "Exec: $exe\n"; diff --git a/evtbuild/start_eb_gbe_feb22.pl b/evtbuild/start_eb_gbe_feb22.pl index 89fb055..0b94122 100755 --- a/evtbuild/start_eb_gbe_feb22.pl +++ b/evtbuild/start_eb_gbe_feb22.pl @@ -59,7 +59,8 @@ read_config $opt_ebconf => %$temp_args_href; my @bnetservers = ("192.168.100.8","192.168.100.9","192.168.105.114", "192.168.105.115", "192.168.105.116", "192.168.100.10", "192.168.105.11"); - +# JAM 4-02-2022: enable this instead of the above to replace lxhadeb11 by lxhadeb12 +#my @bnetservers = ("192.168.100.8","192.168.100.9","192.168.105.114", "192.168.105.115", "192.168.105.116", "192.168.100.10", "192.168.105.12"); my %IP_GSI_lookup = ( '192.168.100.8' => 'lxhadeb08', @@ -349,10 +350,10 @@ sub startBnet() { my $conf_bnet_bld = " BnetBuilderHadesFSD.head.xml"; # JAM2020- enable this to switch different dabc version: - # my $dabclogin = ". /home/hadaq/soft/dabc/bin/dabclogin.jun20; "; - # my $cmd_dabc = "/home/hadaq/soft/dabc/bin/dabc_exe.jun20 "; - # my $conf_bnet_inp = " BnetInputHades.jun20.xml"; - # my $conf_bnet_bld = " BnetBuilderHadesFSD.jun20.xml"; + # my $dabclogin = ". /home/hadaq/soft/dabc/bin/dabclogin.feb22; "; + # my $cmd_dabc = "/home/hadaq/soft/dabc/bin/dabc_exe.feb22 "; + # my $conf_bnet_inp = " BnetInputHades.feb22.xml"; + # my $conf_bnet_bld = " BnetBuilderHadesFSD.feb22.xml"; # variable master node now: @@ -500,9 +501,13 @@ sub startBnet() { my $core_nr = &getCoreNr($cpu, 'input'); # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_inp 1senderlog_$cpu.log 2>&1 &\"" ; + # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr strace -o strace_out.txt -ebind,open $cmd_dabc $conf_bnet_inp >senderlog_$cpu.log 2>&1 &\"" ; + + # JAM 24-01-22: without senderlog, but keep strace to be safe at EB startup + my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr strace -o strace_out.txt -ebind,open $cmd_dabc $conf_bnet_inp 1senderlog_$cpu.log 2>&1 & (sleep 2; ~/bin/optimize_taskset.sh) &\""; # my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports $cmd_dabc $conf_bnet_inp >senderlog_$cpu.log 2>&1 &\""; diff --git a/hmon/automatic_restart_logger.conf b/hmon/automatic_restart_logger.conf deleted file mode 100644 index d430d81..0000000 --- a/hmon/automatic_restart_logger.conf +++ /dev/null @@ -1,8 +0,0 @@ -log4perl.logger.automatic_restart=DEBUG, A1 -log4perl.appender.A1=Log::Dispatch::FileRotate -log4perl.appender.A1.filename=/home/hadaq/trbsoft/hadesdaq/hmon/logs/automatic_restart.log -log4perl.appender.A1.max= 3 -log4perl.appender.A1.size= 1024000 -log4perl.appender.A1.mode=append -log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout -log4perl.appender.A1.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n diff --git a/hmon/get.json b/hmon/get.json deleted file mode 100644 index 73546fe..0000000 --- a/hmon/get.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "_name" : "DataRate", - "_history" : 100, - "_kind" : "rate", - "time" : "2018-09-25T13:51:07.238Z", - "units" : "MB", - "value" : 262.701 -} \ No newline at end of file diff --git a/hmon/hmon_cosmic_alarms.pl b/hmon/hmon_cosmic_alarms.pl deleted file mode 100644 index 57776cb..0000000 --- a/hmon/hmon_cosmic_alarms.pl +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use Data::Dumper; -use HADES::TrbNet; -use List::Util qw[min max]; -use Email::Sender::Simple qw(sendmail); -use Email::Simple; -use Email::Simple::Creator; - -use Log::Log4perl qw(get_logger); - -################################ -# To disable script: just uncomment -# the following line with "exit" -################################ -exit; -################################ - - -my $HADESDAQ="/home/hadaq/trbsoft/hadesdaq/"; - -Log::Log4perl::init($HADESDAQ . "hmon/automatic_restart_logger.conf"); -my $logger = get_logger("automatic_restart"); - -$logger->info("startup"); - -print STDERR "restarted. The log file is here: -/home/hadaq/trbsoft/hadesdaq/hmon/logs/automatic_restart.log -"; - -trb_init_ports() or die trb_strerror(); - -my $mail_fn = $HADESDAQ . "main/alarm_mail_list.txt"; - -my $number_of_reset_retries = 4; - -my $num_of_entries = 10; # loop 10 times and build average - -# number of MDC OEPs which are allowed to be misssing before alarm -my $max_allowed_mdc_oeps_missing = 1; - -# minimal average DAQ rate allowed before an alarm -my $lower_rate_limit = 150; -my $upper_rate_limit = 450; - - -my $beep_intervall = 10; -my $mail_intervall = 600; - -my $rh_data = {}; - -my $fh; - -open ($fh, "<", "/tmp/mdc_number_missing_boards") || die "could not open /tmp/mdc_number_missing_boards"; -$fh->autoflush(1); - - -my $time_last_beep_alarm=0; -my $time_last_mail_alarm=0; - -my $CURRENT_STATE = "idle"; -my $NEXT_STATE = "idle"; -my $reset_counter = 0; -my $iterator = 0; -while (1) { - - STATE_SWITCH: - for ($CURRENT_STATE) { - if (/idle/) { - last STATE_SWITCH; - } - if (/error/) { - last STATE_SWITCH; - } - if (/reset/) { - if ($reset_counter < $number_of_reset_retries - && $iterator >= $num_of_entries) { - $reset_counter++; - $logger->debug("doing a reset now: number of resets: $reset_counter"); - my $c = q|echo "
Doing an automatic TrbNet reset
" > ~/trbsoft/hadesdaq/hmon/files/note.htt; ssh lxhadesdaqp 'cd ~/trbsoft/daq/main; ./startup_briccolage.sh dont_restart_monitoring'; rm ~/trbsoft/hadesdaq/hmon/files/note.htt|; - #print STDERR localtime() . ": command: $c\n"; - qx($c); - $c=q|ssh lxhadesdaqp '/usr/bin/wget -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt "http://lxhadeb12:8099/Master/BNET/StartRun/execute?prefix=co&oninit=10"'|; - #print STDERR localtime() . ": command: $c\n"; - qx($c); - $iterator = 0; - @{$rh_data->{'rates'}} =(); - last STATE_SWITCH; - } - } - } - - my $daq_rate; - - my $rh_rate = trb_register_read(0x0003, 0xa001) or sleep 5 and next; - - if ( !defined $rh_rate) { - $daq_rate = 0; - } - else { - $daq_rate = $rh_rate->{0x0003} & 0xfffff; # only 20bits - } - - #print STDERR "daq_rate: $daq_rate\n"; - push(@{$rh_data->{'rates'}}, $daq_rate); - $iterator++; - my $num_datapoints = scalar @{$rh_data->{'rates'}}; - #print STDERR "iterator: $iterator: num_data_points: $num_datapoints\n"; - if ($iterator >= $num_of_entries) { - shift @{$rh_data->{'rates'}}; - } - - my $sum = 0; - foreach (@{$rh_data->{'rates'}}) { - $sum += $_; - } - my $average_rate = $sum / $num_of_entries; - #print STDERR "average_rate: $average_rate\n"; - seek($fh, 0, 0); - my $num_mdc_missing = <$fh>; - chomp $num_mdc_missing; - - my $state_string = "num missing: $num_mdc_missing , average_rate: $average_rate"; - #print "state_string: $state\n"; - - if($iterator >= $num_of_entries ) { - # ($average_rate > $upper_rate_limit) || - if ( ($average_rate < $lower_rate_limit) || - ($num_mdc_missing > $max_allowed_mdc_oeps_missing) ) { - my $time = time(); - $logger->debug("going to state in_error: average_rate: $average_rate, mdc_missing: $num_mdc_missing, iterator: $iterator\n"); - $NEXT_STATE = "reset"; - if ($time - $time_last_beep_alarm > $beep_intervall) { - $time_last_beep_alarm=$time; - $logger->debug("beep: state: $state_string"); - my $c; - $c = q|ssh -X hadesp30 'DISPLAY=:1 xterm -iconic -e bash -c "~/bin/bell;"' &|; - print "command: $c\n"; - qx($c); - - $c = "mpv --audio-device=auto ~/Documents/foghorn-daniel_simon.mp3 >/dev/null 2>/dev/null $mail_intervall && $reset_counter >= $number_of_reset_retries) { - - $time_last_mail_alarm = $time; - - my $mail_fh; - open ($mail_fh, "<", "$mail_fn") || print "could not open file: $mail_fn\n"; - - my @mails = <$mail_fh>; - $mail_fh->close; - chomp @mails; - foreach my $cur_mail (@mails) { - - next if($cur_mail=~/^#/ || $cur_mail=~/^\s+/ || $cur_mail=~/^\n/); - next unless $cur_mail=~/\w+@\w+/; - $logger->debug("current mail sent to: $cur_mail" ); - my $reset_counter_str = $reset_counter; - my $email = Email::Simple->create( - header => [ - To => "$cur_mail", - From => '"HADES DAQ" ', - Subject => 'Alarm during cosmic data-taking', - ], - body => "Error Condition: -- MDC-missing-OEPs: $num_mdc_missing -- average DAQ-rate: $average_rate - - lower_limit: $lower_rate_limit: upper_limit: $upper_rate_limit - - if it is outside the limits it might be due to some issue in the RPC. -- number of resets already tried: $reset_counter_str -", - ); - - sendmail($email) or $logger->error("error sending mail to $cur_mail"); - - } # loop over mail addresses - - } # if mail intervall - - } # error condition - else { - if($CURRENT_STATE eq "reset") { - $NEXT_STATE = "idle"; - $reset_counter=0; - $iterator = 0; - @{$rh_data->{'rates'}} =(); - $logger->info("leaving error state after $reset_counter number of resets: state: $state_string"); - } - } - - - if($iterator%60==0) { - $logger->debug("still alive signal: $state_string, state: $CURRENT_STATE, iterator: $iterator"); - } - - } # only if iterator is large enough make error meesages. - - sleep 1; - $CURRENT_STATE = $NEXT_STATE; -} #endless loop - - - diff --git a/hmon/hmon_endpointsOrig.pl b/hmon/hmon_endpointsOrig.pl deleted file mode 100644 index 0167f33..0000000 --- a/hmon/hmon_endpointsOrig.pl +++ /dev/null @@ -1,392 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use POSIX qw(strftime); -use FileHandle; -use Hmon; -use QA; -use Getopt::Long; -use Data::Dumper; - -use HADES::TrbNet; - -trb_init_ports() or die trb_strerror(); -my $flog = QA::OpenQAFile(); -my $waittime = 15; -my $loggerperiod = 12; #times 5 seconds sleep -my $timecnt; - -my $fh; -open ($fh, ">", "/tmp/mdc_number_missing_boards"); -if (!$fh) { - print STDERR "error opening temp file: /tmp/mdc_number_missing_boards\n"; - exit; -} - -while(1) { - my @result = trb_register_read_c(0xffff, 0x0) or sleep 5 and next; - - ####config - my @all_boards =(); - my @mdc_boards =(0x8015,0x8016, - # ###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,0x1051,0x1052,0x1053,0x1054,0x1100,0x1101,0x1102, - 0x1103,0x1104,0x1120,0x1121,0x1122,0x1123,0x1124,0x1140,0x1131,0x1132,0x1133, - 0x1134,0x1140,0x1141,0x1142,0x1143,0x1144,0x1150,0x1151,0x1152,0x1153,0x1154, - ### - ); - - foreach my $p (0..3) { - foreach my $s (0..5) { - foreach my $m (0..15) { - next if($p==0 && $m >=14); - my $address = 0x2000 + $p*0x100 + $s*0x10 + $m; - push (@mdc_boards, $address); - } - } - } - - foreach my $mdc_sec (@QA::mdc_chambers_removed) { - foreach my $m (0..15) { - next if($mdc_sec<0x10 && $m >=14); - my $address = 0x2000 + $mdc_sec*0x10 + $m; - push (@QA::mdc_boards_removed, $address); - } - } - - my @rich_boards =(0x8017,0x8018, - 0x83c0,0x83c1,0x83c2,0x83c3,0x83c4,0x83c5,0x83c6,0x83c7,0x83c8,0x83c9,0x83ca,0x83cb, - 0x7010,0x7011,0x7020,0x7021,0x7030,0x7031,0x7040,0x7041,0x7050,0x7051,0x7060,0x7061, - 0x7100,0x7101,0x7110,0x7111,0x7120,0x7121,0x7130,0x7131,0x7140,0x7141,0x7150,0x7151,0x7160,0x7161,0x7170,0x7171,0x7180,0x7181,0x7190,0x7191, - 0x7200,0x7201,0x7210,0x7211,0x7220,0x7221,0x7230,0x7231,0x7240,0x7241,0x7250,0x7251,0x7260,0x7261,0x7270,0x7271,0x7280,0x7281,0x7290,0x7291, - 0x7300,0x7301,0x7310,0x7311,0x7320,0x7321,0x7330,0x7331,0x7340,0x7341,0x7350,0x7351,0x7360,0x7361,0x7370,0x7371,0x7380,0x7381,0x7390,0x7391, - 0x7400,0x7401,0x7410,0x7411,0x7420,0x7421,0x7430,0x7431,0x7440,0x7441,0x7450,0x7451,0x7460,0x7461,0x7470,0x7471,0x7480,0x7481,0x7490,0x7491, - 0x7500,0x7501,0x7510,0x7511,0x7520,0x7521,0x7530,0x7531,0x7540,0x7541,0x7550,0x7551,0x7560,0x7561,0x7570,0x7571,0x7580,0x7581,0x7590,0x7591, - 0x7600,0x7601,0x7610,0x7611,0x7620,0x7621,0x7630,0x7631,0x7640,0x7641,0x7650,0x7651,0x7660,0x7661,0x7670,0x7671,0x7680,0x7681,0x7690,0x7691, - 0x7700,0x7701,0x7710,0x7711,0x7720,0x7721,0x7730,0x7731,0x7740,0x7741,0x7750,0x7751, - 0x7800,0x7801,0x7810,0x7811,0x7820,0x7821,0x7830,0x7831,0x7840,0x7841,0x7850,0x7851, - 0x7900,0x7901,0x7910,0x7911,0x7920,0x7921,0x7930,0x7931,0x7940,0x7941,0x7950,0x7951, - 0x7a10,0x7a11,0x7a20,0x7a21,0x7a30,0x7a31, - 0x7b10,0x7b11,0x7b20,0x7b21,0x7b30,0x7b31, - - 0x7012,0x7013,0x7022,0x7023,0x7032,0x7033,0x7042,0x7043,0x7052,0x7053,0x7062,0x7063,0x7072,0x7073,0x7082,0x7083,0x7092,0x7093, - 0x7102,0x7103,0x7112,0x7113,0x7122,0x7123,0x7132,0x7133,0x7142,0x7143,0x7152,0x7153,0x7162,0x7163,0x7172,0x7173,0x7182,0x7183,0x7192,0x7193,0x71a2,0x71a3,0x71b2,0x71b3, - 0x7202,0x7203,0x7212,0x7213,0x7222,0x7223,0x7232,0x7233,0x7242,0x7243,0x7252,0x7253,0x7262,0x7263,0x7272,0x7273,0x7282,0x7283,0x7292,0x7293,0x72a2,0x72a3,0x72b2,0x72b3, - 0x7302,0x7303,0x7312,0x7313,0x7322,0x7323,0x7332,0x7333,0x7342,0x7343,0x7352,0x7353,0x7362,0x7363,0x7372,0x7373,0x7382,0x7383,0x7392,0x7393,0x73a2,0x73a3,0x73b2,0x73b3, - 0x7402,0x7403,0x7412,0x7413,0x7422,0x7423,0x7432,0x7433,0x7442,0x7443,0x7452,0x7453,0x7462,0x7463,0x7472,0x7473,0x7482,0x7483,0x7492,0x7493, - 0x7502,0x7503,0x7512,0x7513,0x7522,0x7523,0x7532,0x7533,0x7542,0x7543,0x7552,0x7553,0x7562,0x7563,0x7572,0x7573,0x7582,0x7583,0x7592,0x7593, - 0x7602,0x7603,0x7612,0x7613,0x7622,0x7623,0x7632,0x7633,0x7642,0x7643,0x7652,0x7653,0x7662,0x7663,0x7672,0x7673,0x7682,0x7683,0x7692,0x7693, - 0x7702,0x7703,0x7712,0x7713,0x7722,0x7723,0x7732,0x7733,0x7742,0x7743,0x7752,0x7753, - 0x7802,0x7803,0x7812,0x7813,0x7822,0x7823,0x7832,0x7833,0x7842,0x7843,0x7852,0x7853, - 0x7902,0x7903,0x7912,0x7913,0x7922,0x7923,0x7932,0x7933,0x7942,0x7943,0x7952,0x7953, - 0x7a12,0x7a13,0x7a22,0x7a23,0x7a32,0x7a33, - 0x7b12,0x7b13,0x7b22,0x7b23,0x7b32,0x7b33, - - 0x7014,0x7015,0x7024,0x7025,0x7034,0x7035,0x7044,0x7045,0x7054,0x7055,0x7064,0x7065,0x7074,0x7075,0x7084,0x7085,0x7094,0x7095, - 0x7104,0x7105,0x7114,0x7115,0x7124,0x7125,0x7134,0x7135,0x7144,0x7145,0x7154,0x7155,0x7164,0x7165,0x7174,0x7175,0x7184,0x7185,0x7194,0x7195,0x71a4,0x71a5,0x71b4,0x71b5, - 0x7204,0x7205,0x7214,0x7215,0x7224,0x7225,0x7234,0x7235,0x7244,0x7245,0x7254,0x7255,0x7264,0x7265,0x7274,0x7275,0x7284,0x7285,0x7294,0x7295,0x72a4,0x72a5,0x72b4,0x72b5, - 0x7304,0x7305,0x7314,0x7315,0x7324,0x7325,0x7334,0x7335,0x7344,0x7345,0x7354,0x7355,0x7364,0x7365,0x7374,0x7375,0x7384,0x7385,0x7394,0x7395,0x73a4,0x73a5,0x73b4,0x73b5, - 0x7404,0x7405,0x7414,0x7415,0x7424,0x7425,0x7434,0x7435,0x7444,0x7445,0x7454,0x7455,0x7464,0x7465,0x7474,0x7475,0x7484,0x7485,0x7494,0x7495, - 0x7504,0x7505,0x7514,0x7515,0x7524,0x7525,0x7534,0x7535,0x7544,0x7545,0x7554,0x7555,0x7564,0x7565,0x7574,0x7575,0x7584,0x7585,0x7594,0x7595, - 0x7604,0x7605,0x7614,0x7615,0x7624,0x7625,0x7634,0x7635,0x7644,0x7645,0x7654,0x7655,0x7664,0x7665,0x7674,0x7675,0x7684,0x7685,0x7694,0x7695, - 0x7704,0x7705,0x7714,0x7715,0x7724,0x7725,0x7734,0x7735,0x7744,0x7745,0x7754,0x7755, - 0x7804,0x7805,0x7814,0x7815,0x7824,0x7825,0x7834,0x7835,0x7844,0x7845,0x7854,0x7855, - 0x7904,0x7905,0x7914,0x7915,0x7924,0x7925,0x7934,0x7935,0x7944,0x7945,0x7954,0x7955, - 0x7a14,0x7a15,0x7a24,0x7a25,0x7a34,0x7a35, - 0x7b14,0x7b15,0x7b24,0x7b25,0x7b34,0x7b35, - - 0x7016,0x7017,0x7026,0x7027,0x7036,0x7037,0x7046,0x7047,0x7056,0x7057,0x7066,0x7067, - 0x7106,0x7107,0x7116,0x7117,0x7126,0x7127,0x7136,0x7137,0x7146,0x7147,0x7156,0x7157,0x7166,0x7167,0x7176,0x7177,0x7186,0x7187,0x7196,0x7197, - 0x7206,0x7207,0x7216,0x7217,0x7226,0x7227,0x7236,0x7237,0x7246,0x7247,0x7256,0x7257,0x7266,0x7267,0x7276,0x7277,0x7286,0x7287,0x7296,0x7297, - 0x7306,0x7307,0x7316,0x7317,0x7326,0x7327,0x7336,0x7337,0x7346,0x7347,0x7356,0x7357,0x7366,0x7367,0x7376,0x7377,0x7386,0x7387,0x7396,0x7397, - 0x7406,0x7407,0x7416,0x7417,0x7426,0x7427,0x7436,0x7437,0x7446,0x7447,0x7456,0x7457,0x7466,0x7467,0x7476,0x7477,0x7486,0x7487,0x7496,0x7497, - 0x7506,0x7507,0x7516,0x7517,0x7526,0x7527,0x7536,0x7537,0x7546,0x7547,0x7556,0x7557,0x7566,0x7567,0x7576,0x7577,0x7586,0x7587,0x7596,0x7597, - 0x7606,0x7607,0x7616,0x7617,0x7626,0x7627,0x7636,0x7637,0x7646,0x7647,0x7656,0x7657,0x7666,0x7667,0x7676,0x7677,0x7686,0x7687,0x7696,0x7697, - 0x7706,0x7707,0x7716,0x7717,0x7726,0x7727,0x7736,0x7737,0x7746,0x7747,0x7756,0x7757, - 0x7806,0x7807,0x7816,0x7817,0x7826,0x7827,0x7836,0x7837,0x7846,0x7847,0x7856,0x7857, - 0x7906,0x7907,0x7916,0x7917,0x7926,0x7927,0x7936,0x7937,0x7946,0x7947,0x7956,0x7957, - 0x7a16,0x7a17,0x7a26,0x7a27,0x7a36,0x7a37, - 0x7b16,0x7b17,0x7b26,0x7b27,0x7b36,0x7b37, - - 0x8204,0x8206,0x8212,0x8213,0x8214,0x8215,0x8216,0x8217,0x8221,0x8222,0x8223,0x8224,0x8225,0x8226,0x8227,0x8228,0x8229, - 0x8231,0x8239,0x8241,0x8242,0x8243,0x8244,0x8245,0x8246,0x8247,0x8248,0x8249,0x824a,0x8252,0x8254,0x8256,0x8258,0x8259, - 0x8261,0x8262,0x8263,0x8264,0x8265,0x8266,0x8267,0x8268,0x8269,0x826a,0x8271,0x8279,0x8281,0x8282,0x8283,0x8284,0x8285,0x8286,0x8287,0x8288,0x8289, - 0x8292,0x8293,0x8294,0x8295,0x8296,0x8297,0x82a4,0x82a6, - - #quadratic bkpl - 0x8211,0x8250,0x8291,0x82a5,0x8298,0x825a,0x8218,0x8205, - 0x7860,0x7861,0x7870,0x7871,0x7760,0x7761,0x7770,0x7771, - 0x70a6,0x70a7,0x70b6,0x70b7,0x70a0,0x70a1,0x70b0,0x70b1, - 0x7a00,0x7a01,0x7b00,0x7b01,0x70b4,0x70b5, #0x70a4,0x70a5, - 0x7864,0x7865,0x7764,0x7765, #0x7874,0x7875,0x7774,0x7775, - 0x7b04,0x7b05,0x7b06,0x7b07, #0x7a04,0x7a05,0x7a06,0x7a07, - 0x7a02,0x7a03,0x7b02,0x7b03,0x70b2,0x70b3, #0x70a2,0x70a3, - 0x7762,0x7763,0x7772,0x7773,0x7862,0x7863,0x7872,0x7873, - 0x7766,0x7767,0x7776,0x7777,0x7866,0x7867,0x7876,0x7877, - - - 0x8251,0x8260,0x8240, - 0x71a6,0x71a7,0x71b6,0x71b7,0x71a0,0x71a1,0x71b0,0x71b1, - 0x72a6,0x72a7,0x72b6,0x72b7,0x72a0,0x72a1,0x72b0,0x72b1, - 0x73a6,0x73a7,0x73b6,0x73b7,0x73a0,0x73a1,0x73b0,0x73b1, - 0x7076,0x7077,0x7086,0x7087,0x7096,0x7097, - 0x7070,0x7071,0x7080,0x7081,0x7090,0x7091, - ); - -#TOF -> is TOF, RPC, fRPC, FW - my @tof_boards =( -0x86c0,0x5c00,0x5c01,0x5c02,0x5c03, -0x86c1,0x5c10,0x5c11,0x5c12,0x5c13, -0x86c2,0x5c20,0x5c21,0x5c22,0x5c23, -0x86c3,0x5c30,0x5c31,0x5c32,0x5c33, -0x86c4,0x5c40,0x5c41,0x5c42,0x5c43, -0x86c5,0x5c50,0x5c51,0x5c52,0x5c53, -#0x86c6,0x5c60,0x5c61,0x5c62,0x5c63, - -0x84c0,0x84c1,0x84c2,0x84c3,0x84c4,0x84c5, -0x5800,0x5801,0x5802,0x5803,0x5804,0x5805,0x5806,0x5807,0x5808, -0x5810,0x5811,0x5812,0x5813,0x5814,0x5815,0x5816,0x5817,0x5818, -0x5820,0x5821,0x5822,0x5823,0x5824,0x5825,0x5826,0x5827,0x5828, -0x5830,0x5831,0x5832,0x5833,0x5834,0x5835,0x5836,0x5837,0x5838, -0x5840,0x5841,0x5842,0x5843,0x5844,0x5845,0x5846,0x5847,0x5848, -0x5850,0x5851,0x5852,0x5853,0x5854,0x5855,0x5856,0x5857,0x5858, - -#0x8700,0x8701,0x8702, -#0x6700,0x6701,0x6702,0x6703, -#0x6710,0x6711,0x6712,0x6713, -#0x6720,0x6721,0x6722,0x6723, - -); - -#RPC -> is ECAL, STS - my @rpc_boards = ( - 0x8a00,0x8a01,0x8a02,0x8a03,0x8a04,0x8a05, -# 0x6000,0x6001,0x6002,0x6003,0x6004,0x6005,0x6006, - 0x6010,0x6011,0x6012,0x6013,0x6014,0x6015,0x6016, - 0x6020,0x6021,0x6022,0x6023,0x6024,0x6025,0x6026, - 0x6030,0x6031,0x6032,0x6033,0x6034,0x6035,0x6036, - 0x6040,0x6041,0x6042,0x6043,0x6044,0x6045,0x6046, - 0x6050,0x6051,0x6052,0x6053,0x6054,0x6055,0x6056, - -#STT1 - 0x8b00, 0x8b01, 0x8b02, 0x8b03, - 0x6400, 0x6401, 0x6402, 0x6403, - 0x6410, 0x6411, 0x6412, 0x6413, - 0x6420, 0x6421, 0x6422, 0x6423, - 0x6430, 0x6431, 0x6432, 0x6433, - -#STT2 - 0x8b10, 0x8b11, 0x8b12, 0x8b13, 0x8b14, 0x8b15, - 0x6440, 0x6441, 0x6442, 0x6443, 0x6444, 0x6445, - 0x6450, 0x6451, 0x6452, 0x6453, 0x6454, 0x6455, - 0x6460, 0x6461, 0x6462, 0x6463, 0x6464, 0x6465, - 0x6470, 0x6471, 0x6472, 0x6473, #0x6474, 0x6475, -#fRPC -# 0x8c00,0x6800,0x6801,0x6802,0x6803, - 0x8c10,0x6810,0x6811,0x6812,0x6813, - ); - - my @other_boards =( - #cts - 0x0002,0x0003, - #central hub - 0x8000,0x8011,0x8012,0x8013,0x8014,0x8800, 0x8810, - #innerTOF -# 0x8d00,0x5d00,0x5d01,0x5d02,0x5d03,0x5d04,0x5d05, - 0x8d00,0x5d01,0x5d04, -# #Pion -# 0x8900,0x3800,0x3801, -# 0x8910,0x3810,0x3811, - #Start TRB3sc - 0x8880,0x5000,0x5001,0x5002,0x5003, - #Hodo TRB3 - 0x8890,0x5010,0x5011,0x5012, - #Trigger - 0x10,0x0100,0x0110,0x0120,0x130 - ); - - ###strip the register value - for (my $k = 0; $k < scalar @result; $k += 2) { - push @all_boards, $result[$k]; - } - - ###mdc - my(%mdc_mask, @mdc_results); - $mdc_results[$_] = [] foreach (0 .. 7); - foreach my $element (@all_boards) { $mdc_mask{$element} |= 1 } - foreach my $element (@mdc_boards) { $mdc_mask{$element} |= 2 } - foreach my $element (@QA::mdc_boards_removed) { $mdc_mask{$element} |= 4 } - foreach my $element (keys %mdc_mask) { - push @{$mdc_results[0]}, sprintf("0x%x",$element); - push @{$mdc_results[$mdc_mask{$element}]}, sprintf("0x%x",$element); - } - - my $num_mdc_missing = (scalar @{$mdc_results[2]}); - my $num_mdc_mistake = (scalar @{$mdc_results[4]}); - my @sorted_mdc_results = sort @{$mdc_results[2]}; - - print $fh "$num_mdc_missing\n"; - $fh->autoflush(1); - seek($fh, 0, 0); - - my $title = "MDC"; - my $value = "OK ".(scalar @mdc_boards - scalar @QA::mdc_boards_removed); - if ($num_mdc_missing > 0) {$value = "$num_mdc_missing / ".(scalar @mdc_boards - scalar @QA::mdc_boards_removed)." miss";} - if ($num_mdc_mistake > 0) {$value = "Check Script";} - my $longtext = (scalar @mdc_boards). " boards. ".(scalar @QA::mdc_boards_removed)." removed"; - if ($num_mdc_missing > 0) {$longtext = "Endp @sorted_mdc_results missing"}; - if ($num_mdc_mistake > 0) {$longtext .= " Endp @{$mdc_results[4]} not known";} - - my $qastate = QA::GetQAState('below',$num_mdc_missing,@QA::MdcEndpMissingLimits); - Hmon::Speak('mdcmissonce',"$num_mdc_missing MDC Frontends missing") if($qastate > 60 && $qastate < QA::ERROR ); - Hmon::Speak('mdcmiss',"$num_mdc_missing MDC Frontends missing") if($qastate >= QA::ERROR ); - 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); - $rich_results[$_] = [] foreach (0 .. 7); - foreach my $element (@all_boards) { $rich_mask{$element} |= 1 } - foreach my $element (@rich_boards) { $rich_mask{$element} |= 2 } - foreach my $element (@QA::rich_boards_removed) { $rich_mask{$element} |= 4 } - foreach my $element (keys %rich_mask) { - push @{$rich_results[0]}, sprintf("0x%x",$element); - push @{$rich_results[$rich_mask{$element}]}, sprintf("0x%x",$element); - } - - my $num_rich_missing = (scalar @{$rich_results[2]}); - my $num_rich_mistake = (scalar @{$rich_results[4]}); - my @sorted_rich_results = sort @{$rich_results[2]}; - - my $rich_title = "RICH"; - my $rich_value = "OK ".(scalar @rich_boards); - if ($num_rich_missing > 0) {$rich_value = "$num_rich_missing / ".(scalar @rich_boards)." miss";} - if ($num_rich_mistake > 0) {$rich_value = "Check Script";} - my $rich_longtext = (scalar @rich_boards). " boards. "; - if ($num_rich_missing > 0) {$rich_longtext = "Endp @sorted_rich_results missing"}; - if ($num_rich_mistake > 0) {$rich_longtext .= " Endp @{$rich_results[4]} not known";} - - - $qastate = QA::GetQAState('below',$num_rich_missing,@QA::RichEndpMissingLimits); - $qastate = QA::NOTE if $num_rich_missing > 900; - if($qastate > 60) { - system("logger -p local1.info -t DAQ Endp \\ $rich_longtext") unless (($timecnt->{rich}++)%$loggerperiod); - } - else {$timecnt->{rich} = 0;} - - - - Hmon::Speak('richmissonce',"$num_rich_missing Rich Frontends missing") if($qastate > 60 && $qastate < QA::ERROR ); - Hmon::Speak('richmiss',"$num_rich_missing Rich Frontends missing") if($qastate >= QA::ERROR ); - - - if($num_rich_missing > 200) {$rich_longtext = $num_rich_missing." boards missing";} - QA::WriteQALog($flog,"endp","rich",$waittime,$qastate, $rich_title,$rich_value,$rich_longtext); - - - ###tof - my(%tof_mask, @tof_results); - $tof_results[$_] = [] foreach (0 .. 7); - foreach my $element (@all_boards) { $tof_mask{$element} |= 1 } - foreach my $element (@tof_boards) { $tof_mask{$element} |= 2 } - foreach my $element (@QA::tof_boards_removed) { $tof_mask{$element} |= 4 } - foreach my $element (keys %tof_mask) { - push @{$tof_results[0]}, sprintf("0x%x",$element); - push @{$tof_results[$tof_mask{$element}]}, sprintf("0x%x",$element); - } - - my $num_tof_missing = (scalar @{$tof_results[2]}); - my $num_tof_mistake = (scalar @{$tof_results[4]}); - my @sorted_tof_results = sort @{$tof_results[2]}; - - my $tof_title = "TOF/RPC/FW"; - my $tof_value = "OK ".(scalar @tof_boards); - if ($num_tof_missing > 0) {$tof_value = "$num_tof_missing / ".(scalar @tof_boards)." miss";} - if ($num_tof_mistake > 0) {$tof_value = "Check Script";} - my $tof_longtext = (scalar @tof_boards). " boards. "; - #if ($num_tof_missing > 0) {$tof_longtext = "Endp @{$tof_results[2]} missing"}; - if ($num_tof_missing > 0) {$tof_longtext = "Endp @sorted_tof_results missing"}; - if ($num_tof_mistake > 0) {$tof_longtext .= " Endp @{$tof_results[4]} not known";} - - $qastate = QA::GetQAState('below',$num_tof_missing,@QA::TofEndpMissingLimits); - Hmon::Speak('tofmiss',"$num_tof_missing Tof, Rpc Frontends missing") if($qastate > 60); - QA::WriteQALog($flog,"endp","tof",$waittime,$qastate, - $tof_title,$tof_value,$tof_longtext); - if($qastate > 60) { - system("logger -p local1.info -t DAQ Endp \\ $tof_longtext") unless (($timecnt->{tof}++)%$loggerperiod); - } - else {$timecnt->{tof} = 0;} - - - ###rpc - my(%rpc_mask, @rpc_results); - $rpc_results[$_] = [] foreach (0 .. 7); - foreach my $element (@all_boards) { $rpc_mask{$element} |= 1 } - foreach my $element (@rpc_boards) { $rpc_mask{$element} |= 2 } - foreach my $element (@QA::rpc_boards_removed) { $rpc_mask{$element} |= 4 } - foreach my $element (keys %rpc_mask) { - push @{$rpc_results[0]}, sprintf("0x%x",$element); - push @{$rpc_results[$rpc_mask{$element}]}, sprintf("0x%x",$element); - } - - my $num_rpc_missing = (scalar @{$rpc_results[2]}); - my $num_rpc_mistake = (scalar @{$rpc_results[4]}); - my @sorted_rpc_results = sort @{$rpc_results[2]}; - - my $rpc_title = "ECal/STT/fRPC"; - my $rpc_value = "OK ".(scalar @rpc_boards); - if ($num_rpc_missing > 0) {$rpc_value = "$num_rpc_missing / ".(scalar @rpc_boards)." miss";} - if ($num_rpc_mistake > 0) {$rpc_value = "Check Script";} - my $rpc_longtext = (scalar @rpc_boards). " boards. "; - if ($num_rpc_missing > 0) {$rpc_longtext = "Endp @sorted_rpc_results missing"}; - if ($num_rpc_mistake > 0) {$rpc_longtext .= " Endp @{$rpc_results[4]} not known";} - - $qastate = QA::GetQAState('below',$num_rpc_missing,@QA::RpcEndpMissingLimits); - Hmon::Speak('rpcmiss',"$num_rpc_missing Forward Frontends missing") if($qastate > 60); - QA::WriteQALog($flog,"endp","rpc",$waittime,$qastate, - $rpc_title,$rpc_value,$rpc_longtext); - if($qastate > 60) { - system("logger -p local1.info -t DAQ Endp \\ $rpc_longtext") unless (($timecnt->{rpc}++)%$loggerperiod); - } - - ###other - my(%other_mask, @other_results); - $other_results[$_] = [] foreach (0 .. 7); - foreach my $element (@all_boards) { $other_mask{$element} |= 1 } - foreach my $element (@other_boards) { $other_mask{$element} |= 2 } - foreach my $element (@QA::other_boards_removed) { $other_mask{$element} |= 4 } - foreach my $element (keys %other_mask) { - push @{$other_results[0]}, sprintf("0x%x",$element); - push @{$other_results[$other_mask{$element}]}, sprintf("0x%x",$element); - } - - my $num_other_missing = (scalar @{$other_results[2]}); - my $num_other_mistake = (scalar @{$other_results[4]}); - my @sorted_other_results = sort @{$other_results[2]}; - - my $other_title = "Hub/St/CTS"; - my $other_value = "OK ".(scalar @other_boards); - if ($num_other_missing > 0) {$other_value = "$num_other_missing / ".(scalar @other_boards)." miss";} - if ($num_other_mistake > 0) {$other_value = "Check Script";} - my $other_longtext = (scalar @other_boards). " boards. "; - if ($num_other_missing > 0) {$other_longtext = "Endp @sorted_other_results missing"}; - if ($num_other_mistake > 0) {$other_longtext .= " Endp @{$other_results[4]} not known";} - - - $qastate = QA::GetQAState('below',$num_other_missing,@QA::OtherEndpMissingLimits); - Hmon::Speak('othermiss',"$num_other_missing Frontends missing") if($qastate > 60); - QA::WriteQALog($flog,"endp","other",$waittime,$qastate, - $other_title,$other_value,$other_longtext); - if($qastate > 60) { - system("logger -p local1.info -t DAQ Endp \\ $other_longtext") unless (($timecnt->{oth}++)%$loggerperiod); - } - else {$timecnt->{oth} = 0;} - - sleep(5); -} diff --git a/hmon/hmon_goofy.pl b/hmon/hmon_goofy.pl deleted file mode 100644 index 42dbc7b..0000000 --- a/hmon/hmon_goofy.pl +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl -use strict; -use IO::Handle; -use Hmon; -use QA; - -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()) - } - - -open my $GP,'|gnuplot -background white'; - -my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; - -my $str = Hmon::MakeTitle(24,20,"Goofy",0); - $str .= qq@@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("goofy1",$str); - - -while(1) -{ -my $tmp_lines = qx{ssh hadesdaq01 tail -n 500 /home/hadaq/Documents/bitscope/EPICS/goofy/goofyApp/gas_quality.txt}; -open(TMP_FILE,">/tmp/last_gas_data.txt"); -print TMP_FILE $tmp_lines; -close(TMP_FILE); - -print {$GP} << '__GNUPLOT__'; -set term png size 1320,700 font "monospace,8" -set out "files/goofyplot1.png" -set multiplot -set size 0.5,0.5 -set origin 0,0.5 -set title "drift velocity" -set grid -set xdata time -set timefmt "%d/%m/%Y:%H:%M:%S" -set format x "%d/%m\n%H:%M" -set xlabel "time (dd/mm)" -set ylabel "drift velocity (cm/us)" -plot "/tmp/last_gas_data.txt" u 1:5 notitle -set size 0.5,0.25 -set origin 0.5,0.5 -set title "drift time top" -set grid -set xdata time -set timefmt "%d/%m/%Y:%H:%M:%S" -set format x "%d/%m\n%H:%M" -set xlabel "time (dd/mm)" -set ylabel "drift time top (us)" -plot "/tmp/last_gas_data.txt" u 1:6 notitle -set origin 0.5,0.75 -set title "drift time bottom" -set grid -set xdata time -set timefmt "%d/%m/%Y:%H:%M:%S" -set format x "%d/%m\n%H:%M" -set xlabel "time (dd/mm)" -set ylabel "drift time bottom (us)" -plot "/tmp/last_gas_data.txt" u 1:7 notitle -set size 0.5,0.5 -set origin 0,0 -set title "pickup bottom on pickup top amplitude ratio" -set grid -set xdata time -set timefmt "%d/%m/%Y:%H:%M:%S" -set format x "%d/%m\n%H:%M" -set xlabel "time (dd/mm)" -set ylabel "pickup bottom on pickup top amplitude ratio" -plot "/tmp/last_gas_data.txt" u 1:8 notitle -set origin 0.5,0 -set title "pickup bottom on pickup top area ratio" -set grid -set xdata time -set timefmt "%d/%m/%Y:%H:%M:%S" -set format x "%d/%m\n%H:%M" -set xlabel "time (dd/mm)" -set ylabel "pickup bottom on pickup top area ratio" -plot "/tmp/last_gas_data.txt" u 1:9 notitle -unset multiplot -reset -__GNUPLOT__ -$GP->autoflush; - -my $qastate = QA::OK; -#Replace 0 by the condition for ERROR on hmon Panel - -my $tmp_line = qx{ssh hadesdaq01 tail -n 1 /home/hadaq/Documents/bitscope/EPICS/goofy/goofyApp/gas_quality.txt}; -my @data = split(/ /,$tmp_line); -my ($dateS,$dateE,$countsT,$countsB,$dv,$dtT,$dtB,$ramp,$rar)=@data; - -$qastate = QA::ERROR if (0); -QA::WriteQALogvaleurs($fqa,"qa","goofy",120,$qastate,"Goofy","Running","Doing whatever needs to be done."); - -sleep(60); -} - -#<>; -close $GP; diff --git a/hmon/hmon_haloforward.pl b/hmon/hmon_haloforward.pl deleted file mode 100644 index 0379f3c..0000000 --- a/hmon/hmon_haloforward.pl +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use Data::Dumper; -use Data::TreeDumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -use Time::HiRes qw(usleep); -use List::Util qw[min max]; - -trb_init_ports() or die trb_strerror(); - -HPlot::PlotInit({ - name => "HaloFast", - file => "files/ForwardQuartz", - title => "ForwardQuartz", - entries => 2, - curves => 4, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - cblabel => "Hitrate [Hz]", -# cbscale => 10, - sizex => 300, - sizey => 240, - nokey => 1, - buffer => 1, - xmin => -0.5, - xmax => 0.5, - ymin => -0.5, - ymax => 3.5, - cbmax => "100<*<1E10", - cbmin => 0, - noinit => 1, -# additional => "set logscale cb;", - showvalues => 0, - }); - -# HPlot::PlotInit({ -# name => "HaloSlow", -# file => "files/ForwardHaloSlow", -# title => "ForwardHalo Slow", -# entries => 3, -# curves => 3, -# type => HPlot::TYPE_HEATMAP, -# output => HPlot::OUT_PNG, -# cblabel => "Hitrate [Hz]", -# # cbscale => 10, -# sizex => 300, -# sizey => 240, -# nokey => 1, -# buffer => 1, -# xmin => -0.5, -# xmax => 2.5, -# ymin => -0.5, -# ymax => 2.5, -# cbmax => "100<*<1E10", -# cbmin => 0, -# noinit => 1, -# # additional => "set logscale cb;", -# showvalues => 0, -# }); - -# HPlot::PlotInit({ -# name => "ForwardHaloPosition", -# file => "files/ForwardHaloPosition", -# entries => 100, -# type => HPlot::TYPE_HISTORY, -# output => HPlot::OUT_PNG, -# titles => ["X position ","Y position","Xrms","Yrms"], -# xlabel => "Seconds", -# ylabel => "Strips", -# sizex => 600, -# sizey => 250, -# ymin => "-1.1", -# ymax => "1.1", -# curves => 2, -# xscale => 1, -# buffer => 1, -# }); - -my $str = Hmon::MakeTitle(4, 6, "Forward Quartz",0); -$str .= qq@\n@; -# $str .= qq@\n@; -# $str .= qq@\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("ForwardQuartz",$str); - -my $old; -my $diff; -my $oldtime; -my $iter = 1; - -while(1) { - - my $o = trb_registertime_read_mem(0x6036,0xc000,0,8); # or die trb_strerror() or sleep 5 and next; - if (defined $old) { - foreach my $b (keys %$o) { - my $tdiff = $o->{$b}{time}->[0] - ($oldtime->{$b}||0); - $tdiff += 2**16 if $tdiff < 0; - $tdiff *= 16; - for my $v (0..7) { - my $vdiff = ($o->{$b}{value}[$v]&0xfffffff) - ($old->{$b}{value}[$v]&0xfffffff); - $vdiff += 2**28 if $vdiff < 0; - $diff->{$b}[$v] = $vdiff/($tdiff||1E6)*1E6; - } - $oldtime->{$b} = $o->{$b}{time}[0]; - } - - - HPlot::PlotFill("HaloFast",$diff->{0x6036}[1],0,0); - HPlot::PlotFill("HaloFast",$diff->{0x6036}[3],0,1); - HPlot::PlotFill("HaloFast",$diff->{0x6036}[5],0,2); - HPlot::PlotFill("HaloFast",$diff->{0x6036}[7],0,3); - -# HPlot::PlotFill("HaloSlow",$diff->{0x6025}[30],1,2); -# HPlot::PlotFill("HaloSlow",$diff->{0x6041}[46],1,0); -# HPlot::PlotFill("HaloSlow",$diff->{0x6025}[32],0,1); -# HPlot::PlotFill("HaloSlow",$diff->{0x6041}[48],2,1); - - HPlot::PlotDraw('HaloFast'); -# HPlot::PlotDraw('HaloSlow'); - -# my $halosum = $diff->{0x6025}[29] + $diff->{0x6041}[45] + $diff->{0x6041}[47] + $diff->{0x6025}[31]; -# my $haloypos = (-$diff->{0x6041}[45] + $diff->{0x6025}[29])/($halosum||1); -# my $haloxpos = (-$diff->{0x6041}[47] + $diff->{0x6025}[31])/($halosum||1); -# $haloxpos = "NaN" if $halosum < 100; -# $haloypos = "NaN" if $halosum < 100; -# HPlot::PlotAdd("ForwardHaloPosition",$haloxpos,0); -# HPlot::PlotAdd("ForwardHaloPosition",$haloypos,1); -# HPlot::PlotDraw('ForwardHaloPosition'); -# - - } - - $old = $o; - usleep(900000); - } - - - -# Oben: 0x6025 TDC-Nr. 29(fast),30(slow) oder ch17 -# Rechts: 0x6025 TDC-Nr. 31(fast),32(slow) oder ch18 -# Unten: 0x6041 TDC-Nr. 45(fast),46(slow) oder ch22 -# Links: 0x6041 TDC-Nr. 47(fast),48(slow) oder ch23 - - - - - - - - - - - - - - - - diff --git a/hmon/hmon_hodo_hist.pl b/hmon/hmon_hodo_hist.pl deleted file mode 100644 index 3161acb..0000000 --- a/hmon/hmon_hodo_hist.pl +++ /dev/null @@ -1,410 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use Data::Dumper; -use Data::TreeDumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -use Time::HiRes qw(usleep time); -use List::Util qw[min max]; - - -my $plot = (); -$plot->{name} = "HodoHist"; -$plot->{file} = "files/HodoHist"; -$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} = 830; -$plot->{sizey} = 415; -$plot->{nokey} = 0; -$plot->{buffer} = 1; -$plot->{xscale} = 5; -$plot->{xlabel} = "Time [s]"; -$plot->{ylabel} = "Hits [1/s]"; -$plot->{storable} = 1; -HPlot::PlotInit($plot); - -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 subtracted)"; -$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"; -$plot3->{storable} = 1; -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 subtracted)"; -$plot4->{xlabel} = "Time [s]"; -$plot4->{sizex} = 650; -$plot4->{sizey} = 360; -$plot4->{ymin} = 0; -$plot4->{buffer} = 1; -$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} = 6; -$plot5->{xscale} = 5; -$plot5->{type} = HPlot::TYPE_HISTORY; -$plot5->{output} = HPlot::OUT_PNG; -$plot5->{ylabel} = "Hit Rate (dark rate subtracted)"; -$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"; -$plot5->{titles}->[5] = "Start"; -$plot5->{storable} = 1; -HPlot::PlotInit($plot5); - -my $plot6 = (); -$plot6->{name} = "SpillSumHist"; -$plot6->{file} = "files/SpillSumHist"; -$plot6->{entries} = 30; -$plot6->{curves} = 5; -$plot6->{type} = HPlot::TYPE_HISTORY; -$plot6->{output} = HPlot::OUT_PNG; -$plot6->{ylabel} = "Hit Rate per spill (dark rate subtracted)"; -$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->{titles}->[4] = "Rec. Events (x50)"; -$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 subtracted)"; -$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 subtracted)"; -$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(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); - -$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; -my $olde; -my $oldtime; -my $time = 0; -my $diff; -my $diff2; -my $diffe; -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; -$spillsum->{0x0002} = 0; - -trb_init_ports() or die trb_strerror(); - - -while (1) { - my $o, my $o2; my $t; - foreach my $b (0xfe48, 0xfe4e) { - $t = trb_registertime_read_mem($b,0xc000,0,33); - foreach my $a (keys %$t) { - $o->{$a} = $t->{$a}; - } - } - $t = trb_registertime_read(0xfe49,0x8132); - if (defined $t) { - foreach my $b (keys %$t) { - $o2->{$b}->{0x8132} = $t->{$b}; - } - } - - $t = trb_registertime_read(0x0002,1); - if (defined $t) { - if (defined $olde) { - #my $tdiff = $t->{0x3000}->{time}->[0] - ($oldtime->{0x3000}||0); - my $vdiff = ($t->{0x0002}->{value}->[0]&0xffff) - ($olde->{0x0002}&0xffff); - if ($vdiff < 0) { $vdiff += 2**16;} - #if ($tdiff < 0) { $tdiff += 2**16;} - #$tdiff *= 16; - $diffe->{0x0002} = $vdiff;#/($tdiff||1E6)*1E6; - } - #$oldtime->{0x3000} = $t->{0x3000}->{time}->[0]; - $olde->{0x0002} = $t->{0x0002}->{value}->[0]; - } - - if (defined $old) { - foreach my $b (keys %$o) { - for my $v (0..32) { - 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..3) { - for my $x (0..1) { - $sum[$bar/2] += ($diff->{0x5013}->[$bar*4+1+$x*16]||0); - $total += ($diff->{0x5013}->[$bar*4+1+$x*16]||0); - $sum[$bar/2+2] += ($diff->{0x5012}->[$bar*4+1+$x*16]||0); - $total += ($diff->{0x5012}->[$bar*4+1+$x*16]||0); - $sum[$bar/2+4] += ($diff->{0x5011}->[$bar*4+1+$x*16]||0); - $total += ($diff->{0x5011}->[$bar*4+1+$x*16]||0); - $sum[$bar/2+6] += ($diff->{0x5010}->[$bar*4+1+$x*16]||0); - $total += ($diff->{0x5010}->[$bar*4+1+$x*16]||0); - } - } - for my $i (0..7) { - HPlot::PlotAdd("HodoHist",$sum[$i]/2,$i); - } -# 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]||0); - } - } -# print $totalstart; - - if($sum[0] > 1000) { - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3800}->{0x8132}||0)-$offset->{0x3800})/(($totalstart-$offset->{0x8880})||1),0); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3801}->{0x8132}||0)-$offset->{0x3801})/(($totalstart-$offset->{0x8880})||1),1); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3810}->{0x8132}||0)-$offset->{0x3810})/(($totalstart-$offset->{0x8880})||1),2); - HPlot::PlotAdd("HitRatioHist",(($diff2->{0x3811}->{0x8132}||0)-$offset->{0x3811})/(($totalstart-$offset->{0x8880})||1),3); - - HPlot::PlotFill("HitRatios",(($diff2->{0x3800}->{0x8132}||0)-$offset->{0x3800})/(($totalstart-$offset->{0x8880})||1),0); - HPlot::PlotFill("HitRatios",(($diff2->{0x3801}->{0x8132}||0)-$offset->{0x3801})/(($totalstart-$offset->{0x8880})||1),1); - HPlot::PlotFill("HitRatios",(($diff2->{0x3810}->{0x8132}||0)-$offset->{0x3810})/(($totalstart-$offset->{0x8880})||1),2); - HPlot::PlotFill("HitRatios",(($diff2->{0x3811}->{0x8132}||0)-$offset->{0x3811})/(($totalstart-$offset->{0x8880})||1),3); - - $spillsum->{0x3800} += (($diff2->{0x3800}->{0x8132}||0)-$offset->{0x3800})/5; - $spillsum->{0x3801} += (($diff2->{0x3801}->{0x8132}||0)-$offset->{0x3801})/5; - $spillsum->{0x3810} += (($diff2->{0x3810}->{0x8132}||0)-$offset->{0x3810})/5; - $spillsum->{0x3811} += (($diff2->{0x3811}->{0x8132}||0)-$offset->{0x3811})/5; - $spillsum->{0x8880} += (($totalstart||0)-$offset->{0x8880})/5; - $spillsum->{0x8890} += (($total||0)-$offset->{0x8890})/5/2; - $spillsum->{0x0002} += $diffe->{0x0002}; - } - 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->{0x8880} += (($totalstart||0) - $offset->{0x8880})/32; - $offset->{0x8890} += (($total||0) - $offset->{0x8890})/32; - $offset->{0x3800} += (($diff2->{0x3800}->{0x8132}) - $offset->{0x3800})/32; - $offset->{0x3801} += (($diff2->{0x3801}->{0x8132}) - $offset->{0x3801})/32; - $offset->{0x3810} += (($diff2->{0x3810}->{0x8132}) - $offset->{0x3810})/32; - $offset->{0x3811} += (($diff2->{0x3811}->{0x8132}) - $offset->{0x3811})/32; - - if($spillsum->{0x8880} >= 10) { - HPlot::PlotAdd('SpillSumHist',$spillsum->{0x3810},0); - HPlot::PlotAdd('SpillSumHist',$spillsum->{0x3811},1); - HPlot::PlotAdd('SpillSumHist',$spillsum->{0x8880},2); - HPlot::PlotAdd('SpillSumHist',$spillsum->{0x8890},3); - HPlot::PlotAdd('SpillSumHist',$spillsum->{0x0002}*50,4); #MT: why? times 20 should be fine.... - HPlot::PlotDraw('SpillSumHist'); - $spillsum->{0x8880} = 0; - $spillsum->{0x8890} = 0; - $spillsum->{0x3810} = 0; - $spillsum->{0x3811} = 0; - $spillsum->{0x0002} = 0; - } - } - - HPlot::PlotAdd('HitSumHist',(($diff2->{0x3800}->{0x8132})||0)-$offset->{0x3800},0); - HPlot::PlotAdd('HitSumHist',(($diff2->{0x3801}->{0x8132})||0)-$offset->{0x3801},1); - HPlot::PlotAdd('HitSumHist',(($diff2->{0x3810}->{0x8132})||0)-$offset->{0x3810},2); - HPlot::PlotAdd('HitSumHist',(($diff2->{0x3811}->{0x8132})||0)-$offset->{0x3811},3); - HPlot::PlotAdd('HitSumHist',(($total||0)-$offset->{0x8890})/2,4); - HPlot::PlotAdd('HitSumHist',($totalstart||0)-$offset->{0x8880},5); - #print (((($total||0)-$offset->{0x8890})/2)."\n"); - - HPlot::PlotAdd('HitSumHistInner',(($diff2->{0x3810}->{0x8132})||0)-$offset->{0x3810},0); - HPlot::PlotAdd('HitSumHistInner',(($diff2->{0x3811}->{0x8132})||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}->{0x8132})||0)-$offset->{0x3810},0); - HPlot::PlotAdd('HitSumHistInnerShort',(($diff2->{0x3811}->{0x8132})||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'); - } - 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'); - } - $timer++; - } - - $old = $o; - $old2 = $o2; - usleep(200000); #Change also scale for SpillSum!! - } diff --git a/hmon/hmon_logfrpc2.pl b/hmon/hmon_logfrpc2.pl deleted file mode 100644 index 3cf80fb..0000000 --- a/hmon/hmon_logfrpc2.pl +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use Data::Dumper; - -use HADES::TrbNet; -use POSIX qw(strftime); -my $fh; - - -trb_init_ports() or die trb_strerror(); -my $inspill; -my $old; -while (1) { - - my $o = trb_register_read(0x10,0x905d); - $inspill = $o->{0x10} >> 31; - - $o = trb_register_read_mem(0xfe47,0xdfc0,0,32); - if(defined $old) { - my @diff; - - foreach my $b (sort keys %$o) { - next if ($b < 0x6800 || $b > 0x6813); - for my $v (0..31) { - my $d = ($o->{$b}[$v]&0xffffff)-($old->{$b}[$v]&0xffffff); - $d += 2**24 if $d < 0; - push(@diff, $d); - } - } - - my $day = strftime("%Y%m%d",localtime()); - my $str = ""; - $str .= strftime("%Y.%m.%d %H:%M:%S",localtime())."\t"; - $str .= time()."\t"; - $str .= $inspill."\t"; - for my $i (0..scalar @diff -1) { - $str .= sprintf("%u\t",$diff[$i]); - } - $str .= "\n"; - open($fh, ">>","/home/hadaq/trbsoft/daq/hmon/archive/frpcscalerloginbeam-$day.csv"); - print $fh $str; - close $fh; - } - - $old = $o; - sleep(1); - } diff --git a/hmon/hmon_mdc_invaliddatamode.pl b/hmon/hmon_mdc_invaliddatamode.pl deleted file mode 100644 index 0846be3..0000000 --- a/hmon/hmon_mdc_invaliddatamode.pl +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/perl -use warnings; -use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use HADES::TrbNet; -use Hmon; -use QA; - - -trb_init_ports() or die trb_strerror(); -my $fqa = QA::OpenQAFile(); - - -my $cnt = 0; - -while (1) { - my $rh_status = trb_register_read(0xfffd, 0x22) or sleep 5 and next; - my $cnt = 0; - my $boardlist = ""; - foreach my $o (sort keys $rh_status) { - if ($rh_status->{$o} & (1 << 30)) { - $boardlist .= sprintf("%04x, ",$o); - $cnt++; - } - } - - my $qastate = QA::OK; - my $status = ""; - my $longmsg = "No OEP is out-of-order and sending the invalid data flag due to low HV"; - - - chop $boardlist; chop $boardlist; - $qastate = QA::WARN_2 if $cnt; - $status = "$cnt" if $cnt; - $longmsg = "Boards sending the out-of-order flag: $boardlist" if $cnt; - - QA::WriteQALog($fqa, "fee", "mdcinvalid", 20, $qastate,"MDC HV", $status,$longmsg); - sleep(5); - } diff --git a/hmon/hmon_micro.pl b/hmon/hmon_micro.pl deleted file mode 100644 index 59afa9a..0000000 --- a/hmon/hmon_micro.pl +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl - -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(0x8800,0xcf82); - my $length = $a->{0x8880}; - $length = 0 if(!defined $length); - 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_onlineqa.pl b/hmon/hmon_onlineqa.pl index 6b2e331..528cadd 100755 --- a/hmon/hmon_onlineqa.pl +++ b/hmon/hmon_onlineqa.pl @@ -17,7 +17,7 @@ while (1) { my $msg = ""; # JAM2020- the pgrep command defaults on lxhadeb06 have changed for debian9. use -fal instead -fl: - my $cmd = "ssh hades66 'pgrep -fal \"hadesonlineserver.exe .* 5678\"' $b} keys %$rh_rate) { - my $ctr = 0xa001; - foreach my $val (@{$rh_rate->{$board}}) { - $store{$ctr} = $val; - $ctr++; - } - } - - my $ena = $store{0xa0c3} + $store{0xa0c4} * 2**32; - my $eno = $store{0xa0c7}; - my $str = ""; - - $str = Hmon::MakeTitle(12, 6, "CTS Rates", 1, ""); - $str .= "\n"; - $str .= "
12345678\n"; - $str .= "
Start in"; - - my $i; - foreach $i (0, 1, 2, 3, 4, 5, 6, 7) { - $str .= sprintf("%d", ($ena & ( 1<< $i)) ? "on" : "off", - $store{0xa008+$i}); - } - $str .= "
Veto in"; - foreach $i (8, 9, 10, 11, 12, 13, 14, 15) { - $str .= sprintf("%d", ($ena & (1 << $i)) ? "on" : "off", - $store{0xa008+$i}); - } - - $str .= "
TOF in"; - foreach $i (16, 17, 18, 19, 20, 21) { - $str .= sprintf("%d", ($ena & (1 << $i)) ? "on" : "off", - $store{0xa008+$i}); - } - $str .= "----"; - $str .= "
RPC in"; - foreach $i (22, 23, 24, 25, 26, 27) { - $str .= sprintf("%d", ($ena & (1 << $i)) ? "on" : "off", - $store{0xa008+$i}); - } - $str .= "----"; - $str .= "
Mult out"; - foreach $i (2, 3, 4, 5, 6, 7) { - $str .= sprintf("%d", ($eno & (1<<($i))) ? "on" : "off", - $store{0xa03f+$i}); - } - $str .= "----"; - - $str .= "
PT in"; - foreach $i (28, 29, 30, 31, 32, 33, 34, 35) { - $str .= sprintf("%d", ($ena & (1 << $i)) ? "on" : "off", - $store{0xa008+$i}); - } - $str .= "
PT dsc"; - foreach $i (11, 12, 13, 14, 15, 16, 17, 18) { - $str .= sprintf("%d","on",$store{0xa02c+$i}); - } - $str .= "
PT coin"; - foreach $i (9,10,11, 12, 13, 14, 15, 16) { - $str .= sprintf("%d","on",$store{0xa052+$i}); - } - $str .= "
PT out"; - foreach $i (11, 12, 13, 14, 15, 16, 17, 18) { - $str .= sprintf("%d", ($eno & (1 << $i)) ? "on" : "off", - $store{0xa03f+$i}); - } - $str .= "
Pulser"; - $str .= sprintf("%d", ($store{0xa0e3}) ? "on" : "off", - ($store{0xa0e3}) ? 1/$store{0xa0e3} * 2E8 : 0); - $str .= "--"; - $str .= sprintf("MDC Calib.", - ($store{0xa0c0} &0x20) ? "on" : "off"); - $str .= sprintf("SHW Calib.", - ($store{0xa0c0} &0x100) ? "on" : "off"); - $str .= sprintf("SHW Ped.", - ($store{0xa0c0} & 0x80) ? "off" : "on"); - $str .= sprintf("Status", - ($store{0xa0c0}& 0x200)?"on":"off"); - $str .= "----"; - $str .= "
Out"; - $str .= sprintf("%d", - ($store{0xa001}) ? "on" : "off", $store{0xa001}); - $str .= "
\n"; - $str .= Hmon::MakeFooter(); - - Hmon::WriteFile("CTSRates", $str); - - - my $shorttext; my $longtext; my $state; - my $oos; - - #Out of spill? - if($store{0xa02c} < 50) { - for my $b (0xa029, 0xa02a, 0xa02b, 0xa024, 0xa009, 0xa03c, 0xa037, 0xa02c, 0xa028, 0xa025, 0xa026) { - $offset->{$b} = ($offset->{$b}||0) + (($store{$b}||0) - ($offset->{$b}||0))/10; - } -# print Dumper $offset; - } - - - $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa026})." / ".getCorrected($store{0xa026},$offset->{0xa026}); - $longtext = sprintf("Trigger Rate from PT3 %i Hz / %i Hz after offset correction",$store{0xa026}, getCorrectedValue($store{0xa026},$offset->{0xa026}) ); - QA::WriteQALog($fqa, "rate", "pt3", 10, - $state, 'PT3 Rate', $shorttext, $longtext); - - $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa025})." / ".getCorrected($store{0xa025},$offset->{0xa025}); - $longtext = sprintf("Trigger Rate from PT2 %i Hz / %i Hz after offset correction",$store{0xa025}, getCorrectedValue($store{0xa025},$offset->{0xa025}) ); - QA::WriteQALog($fqa, "rate", "pt2", 10, - $state, 'PT2 Rate', $shorttext, $longtext); - - $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa02a})." / ".getCorrected($store{0xa02a},$offset->{0xa02a}); - $longtext = sprintf("Trigger Rate from PT7: %i Hz / %i Hz after offset correction",$store{0xa02a}, getCorrectedValue($store{0xa02a},$offset->{0xa02a}) ); - QA::WriteQALog($fqa, "rate", "pt7", 10, - $state, 'PT7 Rate', $shorttext, $longtext); - - $state = QA::OK; - $shorttext = QA::SciNotation($store{0xa02b})." / ".getCorrected($store{0xa02b},$offset->{0xa02b}); - $longtext = sprintf("Trigger Rate from PT8: %i Hz / %i Hz after offset correction",$store{0xa02b}, getCorrectedValue($store{0xa02b},$offset->{0xa02b}) ); - QA::WriteQALog($fqa, "rate", "pt8", 10, - $state, 'PT8 Rate', $shorttext, $longtext); - - $state = QA::OK; - $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); - - sleep 1; -} - - diff --git a/hmon/hmon_richMagnet.pl b/hmon/hmon_richMagnet.pl index f836606..3afb082 100755 --- a/hmon/hmon_richMagnet.pl +++ b/hmon/hmon_richMagnet.pl @@ -20,6 +20,9 @@ use JSON::XS; use HADES::TrbNet; +my $MAKE_MAGNET_LOG = 0; + + my $plot1 = { name => "RichMagnet", file => "files/RichMagnet", @@ -297,11 +300,13 @@ while(1){ print $fh encode_json($data); close $fh; + if($MAKE_MAGNET_LOG==1) { $str_log .= "\n"; my $fh_log; open($fh_log, ">>",Hmon::HMONDIR."/archive/richMagLog.csv"); print $fh_log $str_log; close $fh_log; + } if ($longcnt==6) { #long Range Hist diff --git a/hmon/hmon_startratesimple_VW.pl b/hmon/hmon_startratesimple_VW.pl deleted file mode 100644 index 01fc6dc..0000000 --- a/hmon/hmon_startratesimple_VW.pl +++ /dev/null @@ -1,817 +0,0 @@ -#!/usr/bin/perl -# TODO remove _VW from StartRateNumbers_VW -use warnings; -use strict; - -use Data::Dumper; -use Data::TreeDumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -use Time::HiRes qw(usleep time); -use List::Util qw[min max]; - -use Encode qw(encode from_to); -use JSON::XS; - -my %users = (name => "wiily", lastname => 'Krüger'); - -my $ref_users = \%users; - - -my $plot3 = { - name => "StartPosition", - file => "files/StartPosition", - entries => 200, - type => HPlot::TYPE_HISTORY, - output => HPlot::OUT_PNG, - titles => ["X lower half position","X upper half position","Y left half position","Y right half position"],#,"Xrms_0","Xrms_1","Yrms_0","Yrms_1"], - xlabel => "Seconds", - ylabel => "Strips", - sizex => 970, - sizey => 720, - ymin => "-0.5", - ymax => "49.5", - curves => 4, - xscale => 10, - buffer => 1, - }; - -HPlot::PlotInit($plot3); - -my $plot4 = { - name => "StartPositionRMS", - file => "files/StartPositionRMS", - entries => 200, - type => HPlot::TYPE_HISTORY, - output => HPlot::OUT_PNG, - titles => ["X_rms lower half","X_rms upper half","Y_rms left half","Y_rms right half"], - xlabel => "Seconds", - ylabel => "Strips", - sizex => 970, - sizey => 720, - ymin => "-0.5", - ymax => "49.5", - curves => 4, - xscale => 10, - buffer => 1, - }; - -HPlot::PlotInit($plot4); - - -my $plot5 = { - name => "StartRateX_histbar", - file => "files/StartRateX_histbar", - entries => 2000, - type => HPlot::TYPE_BARGRAPH, - output => HPlot::OUT_PNG, - titles => ["0","1","2","3","4","5","6","7","8","9","10","11"], - xlabel => "Time / 100 ms", - ylabel => "Hitrate [Hz]", - sizex => 950, - sizey => 330, - xmin => 0, - xmax => 2000, - ymin => "0", - ymax => "100<*", - curves => 12, - xscale => 10, # xscale does not work with TYPE_BARGRAPH - buffer => 1, - stacked => 1, - curvewidth => .9, - additional => " - set obj 1 rect from -1, 3.5E6 to 200, 4E6 fc rgb '#ffffbb' behind \n - set obj 2 rect from -1, 4E6 to 200, 10E6 fc rgb '#ffdddd' behind - " - }; - - -HPlot::PlotInit($plot5); - -# my $plot6 = { -# name => "StartRateX_1histbar_VW", -# file => "files/StartRateX_1histbar_VW", -# entries => 2000, -# type => HPlot::TYPE_BARGRAPH, -# output => HPlot::OUT_PNG, -# titles => ["0","1","2","3","4","5","6","7","8","9","10","11"], -# xlabel => "Time / 100 ms", -# ylabel => "Hitrate [Hz]", -# sizex => 950, -# sizey => 330, -# xmin => 0, -# xmax => 2000, -# ymin => "0", -# ymax => "100<*", -# curves => 12, -# xscale => 10, # xscale does not work with TYPE_BARGRAPH -# buffer => 1, -# stacked => 1, -# curvewidth => .9, -# additional => " -# set obj 1 rect from -1, 3.5E6 to 200, 4E6 fc rgb '#ffffbb' behind \n -# set obj 2 rect from -1, 4E6 to 200, 10E6 fc rgb '#ffdddd' behind -# " -# }; -# -# -# HPlot::PlotInit($plot6); - - - -my $plot7 = { - name => "StartRateY_histbar", - file => "files/StartRateY_histbar", - entries => 2000, - type => HPlot::TYPE_BARGRAPH, - output => HPlot::OUT_PNG, - titles => ["0","1","2","3","4","5","6","7","8","9","10","11"], - xlabel => "Time / 100 ms", - ylabel => "Hitrate [Hz]", - sizex => 950, - sizey => 330, - xmin => 0, - xmax => 2000, - ymin => "0", - ymax => "100<*", - curves => 12, - xscale => 10, # xscale does not work with TYPE_BARGRAPH - buffer => 1, - stacked => 1, - curvewidth => .9, - additional => " - set obj 1 rect from -1, 3.5E6 to 200, 4E6 fc rgb '#ffffbb' behind \n - set obj 2 rect from -1, 4E6 to 200, 10E6 fc rgb '#ffdddd' behind - " - }; - - -HPlot::PlotInit($plot7); - -# my $plot8 = { -# name => "StartRateY_1histbar_VW", -# file => "files/StartRateY_1histbar_VW", -# entries => 2000, -# type => HPlot::TYPE_BARGRAPH, -# output => HPlot::OUT_PNG, -# titles => ["0","1","2","3","4","5","6","7","8","9","10","11"], -# xlabel => "Time / 100 ms", -# ylabel => "Hitrate [Hz]", -# sizex => 950, -# sizey => 330, -# xmin => 0, -# xmax => 2000, -# ymin => "0", -# ymax => "100<*", -# curves => 12, -# xscale => 10, # xscale does not work with TYPE_BARGRAPH -# buffer => 1, -# stacked => 1, -# curvewidth => .9, -# additional => " -# set obj 1 rect from -1, 3.5E6 to 200, 4E6 fc rgb '#ffffbb' behind \n -# set obj 2 rect from -1, 4E6 to 200, 10E6 fc rgb '#ffdddd' behind -# " -# }; -# -# -# HPlot::PlotInit($plot8); - - - - - -# -# my $plot1 = { -# name => "StartRateSimple_VW", -# file => "files/StartRateSimple_VW", -# title => "Start Rate", -# entries => 16, -# curves => 16, -# type => HPlot::TYPE_HEATMAP, -# output => HPlot::OUT_PNG, -# zlabel => "Hitrate", -# sizex => 310, -# sizey => 310, -# nokey => 1, -# buffer => 1, -# ymin => 15.5, -# ymax => -0.5, -# xmin => -0.5, -# xmax => 15.5, -# cbmax => "100<*<1E5", -# cbmin => 0, -# noinit => 1, -# additional => "set logscale cb;unset ytics;set format cb \"_{10}{\%L}\"", -# showvalues => 0, }; -# HPlot::PlotInit($plot1); - - -my $plot2 = { - name => "StartRateNumbers", - file => "files/StartRateNumbers", - entries => 4, - curves => 50, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - zlabel => "Hitrate", - sizex => 450, - sizey => 720, - nokey => 1, - buffer => 1, - xmin => -0.5, - xmax => 3.5, - ymin => -0.5, - ymax => 49.5, - cbmax => "100<*<1E5", - cbmin => "1", - showvalues => 0, - # additional => "set logscale cb; set xtics ('Left' 0.5, 'Bottom' 2.5); set x2tics ('Right' 0.5, 'Top' 2.5);" - additional => " set xtics ('Left' 0.5, 'Bottom' 2.5); set x2tics ('Right' 0.5, 'Top' 2.5);" - }; -HPlot::PlotInit($plot2); - - -# my $str = Hmon::MakeTitle(4, 7, "Start Hit Rate",0); -# $str .= qq@
\n@; -# $str .= Hmon::MakeFooter(); -# Hmon::WriteFile("StartRateSimple_VW",$str); - -$str = Hmon::MakeTitle(6, 16, "Start Hit Numbers"); -$str .= qq@
\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartRateNumbers_VW",$str); - -$str = Hmon::MakeTitle(13, 16, "Start Position",0); -$str .= qq@\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartPosition",$str); - - -$str = Hmon::MakeTitle(13, 16, "Start Position RMS",0); -$str .= qq@\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartPositionRMS",$str); - - - -$str = Hmon::MakeTitle(13, 32, "Start Summed Rates X",0); -$str .= qq@

Start X Spill


\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartRateX_histbar",$str); - -$str = Hmon::MakeTitle(13, 32, "Start Summed Rates Y",0); -$str .= qq@

Start X Spill


\n@; - -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartRateY_histbar",$str); - - - - - - - -my $old; -my $oldtime = time(); -my $time = time(); -my $diff; -my $iter = 1; -my $trbnet_endpoint_offset = 0x5000; #20480 - -#Spill analysis variables -my @totalDetectorHitsX_0; -my @totalDetectorHitsX_1; -my @totalDetectorHitsY_0; -my @totalDetectorHitsY_1; -my $spillThreshold = 1000; # threshold of rate in detector signaling the End of the Spill -my $samplesPerSecond =10; - -my @lastspills_x_0; -my @lastspills_x_1; -my @lastspills_y_0; -my @lastspills_y_1; - -my $time_x_0 = 0; -my $time_x_1 = 0; -my $time_y_0 = 0; -my $time_y_1 = 0; - -my $empties_x_0 = 0; -my $empties_x_1 = 0; -my $empties_y_0 = 0; -my $empties_y_1 = 0; -### - -my $channels_x_1 = [ - { pch => 2, tdc => 6, ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 1, tdc => 6, ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 4, tdc => 6, ch => int(5 /2)}, - { pch => 3, tdc => 6, ch => int(7 /2)}, - { pch => 6, tdc => 6, ch => int(9 /2)}, - { pch => 5, tdc => 6, ch => int(11/2)}, - { pch => 8, tdc => 6, ch => int(13/2)}, - { pch => 7, tdc => 6, ch => int(15/2)}, - { pch => 10, tdc => 6, ch => int(17/2)}, - { pch => 9, tdc => 6, ch => int(19/2)}, - { pch => 12, tdc => 6, ch => int(21/2)}, - { pch => 11, tdc => 6, ch => int(23/2)}, - { pch => 14, tdc => 6, ch => int(25/2)}, - { pch => 13, tdc => 6, ch => int(27/2)}, - { pch => 16, tdc => 6, ch => int(29/2)}, - { pch => 15, tdc => 6, ch => int(31/2)}, - { pch => 18, tdc => 6, ch => int(33/2)}, - { pch => 17, tdc => 6, ch => int(35/2)}, - { pch => 20, tdc => 6, ch => int(37/2)}, - { pch => 19, tdc => 6, ch => int(39/2)}, - { pch => 22, tdc => 6, ch => int(41/2)}, - { pch => 21, tdc => 6, ch => int(43/2)}, - { pch => 24, tdc => 6, ch => int(45/2)}, - { pch => 23, tdc => 6, ch => int(47/2)}, - { pch => 34, tdc => 7, ch => int(1 /2)}, - { pch => 33, tdc => 7, ch => int(3 /2)}, - { pch => 36, tdc => 7, ch => int(5 /2)}, - { pch => 35, tdc => 7, ch => int(7 /2)}, - { pch => 38, tdc => 7, ch => int(9 /2)}, - { pch => 37, tdc => 7, ch => int(11/2)}, - { pch => 40, tdc => 7, ch => int(13/2)}, - { pch => 39, tdc => 7, ch => int(15/2)}, - { pch => 42, tdc => 7, ch => int(17/2)}, - { pch => 41, tdc => 7, ch => int(19/2)}, - { pch => 44, tdc => 7, ch => int(21/2)}, - { pch => 43, tdc => 7, ch => int(23/2)}, - { pch => 46, tdc => 7, ch => int(25/2)}, - { pch => 45, tdc => 7, ch => int(27/2)}, - { pch => 48, tdc => 7, ch => int(29/2)}, - { pch => 47, tdc => 7, ch => int(31/2)}, - { pch => 26, tdc => 7, ch => int(33/2)}, - { pch => 25, tdc => 7, ch => int(35/2)}, - { pch => 28, tdc => 7, ch => int(37/2)}, - { pch => 27, tdc => 7, ch => int(39/2)}, - { pch => 30, tdc => 7, ch => int(41/2)}, - { pch => 29, tdc => 7, ch => int(43/2)}, - { pch => 32, tdc => 7, ch => int(45/2)}, - { pch => 31, tdc => 7, ch => int(47/2)} - ]; - -my $channels_x_0 = [ - { pch => 15 , tdc => 4, ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 16 , tdc => 4, ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 13 , tdc => 4, ch => int(5 /2)}, - { pch => 14 , tdc => 4, ch => int(7 /2)}, - { pch => 11 , tdc => 4, ch => int(9 /2)}, - { pch => 12 , tdc => 4, ch => int(11/2)}, - { pch => 9 , tdc => 4, ch => int(13/2)}, - { pch => 10 , tdc => 4, ch => int(15/2)}, - { pch => 7 , tdc => 4, ch => int(17/2)}, - { pch => 8 , tdc => 4, ch => int(19/2)}, - { pch => 5 , tdc => 4, ch => int(21/2)}, - { pch => 6 , tdc => 4, ch => int(23/2)}, - { pch => 3 , tdc => 4, ch => int(25/2)}, - { pch => 4 , tdc => 4, ch => int(27/2)}, - { pch => 1 , tdc => 4, ch => int(29/2)}, - { pch => 2 , tdc => 4, ch => int(31/2)}, - { pch => 31 , tdc => 4, ch => int(33/2)}, - { pch => 32 , tdc => 4, ch => int(35/2)}, - { pch => 29 , tdc => 4, ch => int(37/2)}, - { pch => 30 , tdc => 4, ch => int(39/2)}, - { pch => 27 , tdc => 4, ch => int(41/2)}, - { pch => 28 , tdc => 4, ch => int(43/2)}, - { pch => 25 , tdc => 4, ch => int(45/2)}, - { pch => 26 , tdc => 4, ch => int(47/2)}, - { pch => 47 , tdc => 5, ch => int(1 /2)}, - { pch => 48 , tdc => 5, ch => int(3 /2)}, - { pch => 45 , tdc => 5, ch => int(5 /2)}, - { pch => 46 , tdc => 5, ch => int(7 /2)}, - { pch => 43 , tdc => 5, ch => int(9 /2)}, - { pch => 44 , tdc => 5, ch => int(11/2)}, - { pch => 41 , tdc => 5, ch => int(13/2)}, - { pch => 42 , tdc => 5, ch => int(15/2)}, - { pch => 39 , tdc => 5, ch => int(17/2)}, - { pch => 40 , tdc => 5, ch => int(19/2)}, - { pch => 37 , tdc => 5, ch => int(21/2)}, - { pch => 38 , tdc => 5, ch => int(23/2)}, - { pch => 35 , tdc => 5, ch => int(25/2)}, - { pch => 36 , tdc => 5, ch => int(27/2)}, - { pch => 33 , tdc => 5, ch => int(29/2)}, - { pch => 34 , tdc => 5, ch => int(31/2)}, - { pch => 23 , tdc => 5, ch => int(33/2)}, - { pch => 24 , tdc => 5, ch => int(35/2)}, - { pch => 21 , tdc => 5, ch => int(37/2)}, - { pch => 22 , tdc => 5, ch => int(39/2)}, - { pch => 19 , tdc => 5, ch => int(41/2)}, - { pch => 20 , tdc => 5, ch => int(43/2)}, - { pch => 17 , tdc => 5, ch => int(45/2)}, - { pch => 18 , tdc => 5, ch => int(47/2)} - ]; -my $channels_y_0 = [ - { pch => 2, tdc => 0, ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 1, tdc => 0, ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 4, tdc => 0, ch => int(5 /2)}, - { pch => 3, tdc => 0, ch => int(7 /2)}, - { pch => 6, tdc => 0, ch => int(9 /2)}, - { pch => 5, tdc => 0, ch => int(11/2)}, - { pch => 8, tdc => 0, ch => int(13/2)}, - { pch => 7, tdc => 0, ch => int(15/2)}, - { pch => 10, tdc => 0, ch => int(17/2)}, - { pch => 9, tdc => 0, ch => int(19/2)}, - { pch => 12, tdc => 0, ch => int(21/2)}, - { pch => 11, tdc => 0, ch => int(23/2)}, - { pch => 14, tdc => 0, ch => int(25/2)}, - { pch => 13, tdc => 0, ch => int(27/2)}, - { pch => 16, tdc => 0, ch => int(29/2)}, - { pch => 15, tdc => 0, ch => int(31/2)}, - { pch => 18, tdc => 0, ch => int(33/2)}, - { pch => 17, tdc => 0, ch => int(35/2)}, - { pch => 20, tdc => 0, ch => int(37/2)}, - { pch => 19, tdc => 0, ch => int(39/2)}, - { pch => 22, tdc => 0, ch => int(41/2)}, - { pch => 21, tdc => 0, ch => int(43/2)}, - { pch => 24, tdc => 0, ch => int(45/2)}, - { pch => 23, tdc => 0, ch => int(47/2)}, - { pch => 34, tdc => 1, ch => int(1 /2)}, - { pch => 33, tdc => 1, ch => int(3 /2)}, - { pch => 36, tdc => 1, ch => int(5 /2)}, - { pch => 35, tdc => 1, ch => int(7 /2)}, - { pch => 38, tdc => 1, ch => int(9 /2)}, - { pch => 37, tdc => 1, ch => int(11/2)}, - { pch => 40, tdc => 1, ch => int(13/2)}, - { pch => 39, tdc => 1, ch => int(15/2)}, - { pch => 42, tdc => 1, ch => int(17/2)}, - { pch => 41, tdc => 1, ch => int(19/2)}, - { pch => 44, tdc => 1, ch => int(21/2)}, - { pch => 43, tdc => 1, ch => int(23/2)}, - { pch => 46, tdc => 1, ch => int(25/2)}, - { pch => 45, tdc => 1, ch => int(27/2)}, - { pch => 48, tdc => 1, ch => int(29/2)}, - { pch => 47, tdc => 1, ch => int(31/2)}, - { pch => 26, tdc => 1, ch => int(33/2)}, - { pch => 25, tdc => 1, ch => int(35/2)}, - { pch => 28, tdc => 1, ch => int(37/2)}, - { pch => 27, tdc => 1, ch => int(39/2)}, - { pch => 30, tdc => 1, ch => int(41/2)}, - { pch => 29, tdc => 1, ch => int(43/2)}, - { pch => 32, tdc => 1, ch => int(45/2)}, - { pch => 31, tdc => 1, ch => int(47/2)} - ]; - - -my $channels_y_1 = [ - { pch => 15 , tdc => 2, ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC. - { pch => 16 , tdc => 2, ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels! - { pch => 13 , tdc => 2, ch => int(5 /2)}, - { pch => 14 , tdc => 2, ch => int(7 /2)}, - { pch => 11 , tdc => 2, ch => int(9 /2)}, - { pch => 12 , tdc => 2, ch => int(11/2)}, - { pch => 9 , tdc => 2, ch => int(13/2)}, - { pch => 10 , tdc => 2, ch => int(15/2)}, - { pch => 7 , tdc => 2, ch => int(17/2)}, - { pch => 8 , tdc => 2, ch => int(19/2)}, - { pch => 5 , tdc => 2, ch => int(21/2)}, - { pch => 6 , tdc => 2, ch => int(23/2)}, - { pch => 3 , tdc => 2, ch => int(25/2)}, - { pch => 4 , tdc => 2, ch => int(27/2)}, - { pch => 1 , tdc => 2, ch => int(29/2)}, - { pch => 2 , tdc => 2, ch => int(31/2)}, - { pch => 31 , tdc => 2, ch => int(33/2)}, - { pch => 32 , tdc => 2, ch => int(35/2)}, - { pch => 29 , tdc => 2, ch => int(37/2)}, - { pch => 30 , tdc => 2, ch => int(39/2)}, - { pch => 27 , tdc => 2, ch => int(41/2)}, - { pch => 28 , tdc => 2, ch => int(43/2)}, - { pch => 25 , tdc => 2, ch => int(45/2)}, - { pch => 26 , tdc => 2, ch => int(47/2)}, - { pch => 47 , tdc => 3, ch => int(1 /2)}, - { pch => 48 , tdc => 3, ch => int(3 /2)}, - { pch => 45 , tdc => 3, ch => int(5 /2)}, - { pch => 46 , tdc => 3, ch => int(7 /2)}, - { pch => 43 , tdc => 3, ch => int(9 /2)}, - { pch => 44 , tdc => 3, ch => int(11/2)}, - { pch => 41 , tdc => 3, ch => int(13/2)}, - { pch => 42 , tdc => 3, ch => int(15/2)}, - { pch => 39 , tdc => 3, ch => int(17/2)}, - { pch => 40 , tdc => 3, ch => int(19/2)}, - { pch => 37 , tdc => 3, ch => int(21/2)}, - { pch => 38 , tdc => 3, ch => int(23/2)}, - { pch => 35 , tdc => 3, ch => int(25/2)}, - { pch => 36 , tdc => 3, ch => int(27/2)}, - { pch => 33 , tdc => 3, ch => int(29/2)}, - { pch => 34 , tdc => 3, ch => int(31/2)}, - { pch => 23 , tdc => 3, ch => int(33/2)}, - { pch => 24 , tdc => 3, ch => int(35/2)}, - { pch => 21 , tdc => 3, ch => int(37/2)}, - { pch => 22 , tdc => 3, ch => int(39/2)}, - { pch => 19 , tdc => 3, ch => int(41/2)}, - { pch => 20 , tdc => 3, ch => int(43/2)}, - { pch => 17 , tdc => 3, ch => int(45/2)}, - { pch => 18 , tdc => 3, ch => int(47/2)} - ]; - - - - - - -trb_init_ports() or die trb_strerror(); - -#while (1) { -# #my $data; -# #my $max = 0 ; -# #my $min = 5E9; -# -# my $current = trb_register_read_mem(0xfe74,0xdfc0,0,48) or die trb_strerror() or sleep 5 and next; -# -# print Dumper $o; -# exit; -# if (defined $old) { -# my $tdiff = (time() - $oldtime)|1; -# foreach my $endpoint (sort keys %$current) { -# #foreach my $endpoint (0x5000, 0x5001, 0x5002, 0x5003, 0x5004) { -# #my $ratesum = 0; -# next unless ($endpoint>=0x5000 && $endpoint<=0x5003); -# my $fpga = ($endpoint&0xF); -# -# for my $channel_nr (0..47) { -# my $vdiff = ($current->{$endpoint}->[$channel_nr] & 0xfffffff) - ($old->{$endpoint}->[$channel_nr]&0xfffffff); -# -# if ($vdiff < 0) { -# $vdiff += 2**28; -# } -# $diff->{$endpoint}->[$channel_nr] = $vdiff/$tdiff; -# #$ratesum += $diff->{$endpoint}->[$channel_nr+1]; -# #HPlot::PlotFill('StartRateSimple',$diff->{$endpoint}->[$channel_nr],$channel_nr,); -# HPlot::PlotFill('StartRateSimple_VW',$diff->{$endpoint}->[$channel_nr],$channel_nr%16,$fpga*4+$channel_nr/16); -# -# my $ypos = 0; -# my $side = 0; -# if ($fpga == 0 || $fpga == 3) { -# next if $channel_nr < 0; -# next if $channel_nr > 48; -# -# $ypos= ($channel_nr-10)*2+1; -# } -# -# if ($fpga == 1 || $fpga == 2) { -# $ypos = ((15-($channel_nr%16)) + (int($channel_nr/16)*16) - 8)*2; -# next if $ypos < 0; -# next if $ypos > 59; -# $side=1; -# } -# -# -# HPlot::PlotFill('StartRateNumbers_VW',$diff->{$endpoint}->[$channel_nr],int($fpga/2), $ypos); -# -# } -# #my $s = sprintf("0x%04x",$endpoint); -# #$data->{$s}= int(100*($ratesum / 32) +0.5) /100; -# -# #$min = $data->{$s} if $data->{$s} < $min; -# #$max = $data->{$s} if $data->{$s}> $max; -# } -# -# HPlot::PlotDraw('StartRateSimple_VW'); -# HPlot::PlotDraw('StartRateNumbers_VW'); -# -# # $data->{max} = $max; -# # $data->{min} = $min; -# # $data->{symbol} = " Hits/s"; -# # $data->{title} = "Mean DiRICH TDC Rate"; -# -# # $data->{updatetime} = getTimeString; -# # my $fh; -# # open($fh, ">", Hmon::HMONDIR."/files/richMeanRateDiRICH.json"); -# # print $fh encode_json($data); -# # close $fh; -# } -# -# $old = $current; -# $oldtime = time(); -# sleep 1; -#} - - -while(1) { - - - - my $current_readout = trb_registertime_read_mem(0xfe76,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next; - if (defined $old) { - - - ############ calculate rates and fill Start Rate Numbers_VW - my @hitRatesStartX_0 = calculate_rates($channels_x_0, $old, $current_readout); - my @hitRatesStartX_1 = calculate_rates($channels_x_1, $old, $current_readout); - my @hitRatesStartY_0 = calculate_rates($channels_y_0, $old, $current_readout); - my @hitRatesStartY_1 = calculate_rates($channels_y_1, $old, $current_readout); - - for my $i(1..48 ){ - HPlot::PlotFill('StartRateNumbers_VW',$hitRatesStartX_0[$i],0, $i); - HPlot::PlotFill('StartRateNumbers_VW',$hitRatesStartX_1[$i],1, $i); - HPlot::PlotFill('StartRateNumbers_VW',$hitRatesStartY_0[$i],2, $i); - HPlot::PlotFill('StartRateNumbers_VW',$hitRatesStartY_1[$i],3, $i); - - - } - - - ############ end of calculate rates and fill Start Rate Numbers_VW - my @summedRatesFor4Channels_X0; - my @summedRatesFor4Channels_Y0; - - for my $i(0..11){ - $summedRatesFor4Channels_X0[$i]=0; - $summedRatesFor4Channels_Y0[$i]=0; - } - - for my $i(1..48){ - $summedRatesFor4Channels_X0[int(($i-1) / 4)]+= $hitRatesStartX_0[$i]; # TODO Bugcheck - $summedRatesFor4Channels_X0[int(($i-1) / 4)]+= $hitRatesStartX_1[$i]; - $summedRatesFor4Channels_Y0[int(($i-1) / 4)]+= $hitRatesStartY_0[$i]; - $summedRatesFor4Channels_Y0[int(($i-1) / 4)]+= $hitRatesStartY_1[$i]; - } - - - for my $i (0..11){ - HPlot::PlotAdd("StartRateX_histbar",$summedRatesFor4Channels_X0[$i],$i); - HPlot::PlotAdd("StartRateY_histbar",$summedRatesFor4Channels_Y0[$i],$i); - - } - - - - ##### calculate average position of beam and width - my ($sum_x_0, $wsum_x_0) = calculate_diff_time_and_sum($channels_x_0, $old, $current_readout); - my ($sum_x_1, $wsum_x_1) = calculate_diff_time_and_sum($channels_x_1, $old, $current_readout); - my ($sum_y_0, $wsum_y_0) = calculate_diff_time_and_sum($channels_y_0, $old, $current_readout); - my ($sum_y_1, $wsum_y_1) = calculate_diff_time_and_sum($channels_y_1, $old, $current_readout); - - - my $avg_x_0=0; - my $avg_x_1=0; - my $avg_y_0=0; - my $avg_y_1=0; - my $rms_x_0=0; - my $rms_x_1=0; - my $rms_y_0=0; - my $rms_y_1=0; - - my $minNumberOfEntries = 10; - if($sum_x_0 < $minNumberOfEntries){ - $avg_x_0 = "NaN"; - $rms_x_0 = "NaN"; - } else { - $avg_x_0 = $wsum_x_0 / $sum_x_0 if($sum_x_0 !=0); - my $weighted_sum_difference_from_mean_x_0 = calculate_weighted_sum_difference_from_mean($channels_x_0, $old, $current_readout,$avg_x_0); - $rms_x_0 = sqrt($weighted_sum_difference_from_mean_x_0/($sum_x_0||1E-10)); - } - - if($sum_x_1 < $minNumberOfEntries){ - $avg_x_1 = "NaN"; - $rms_x_1 = "NaN"; - } else { - $avg_x_1 = $wsum_x_1 / $sum_x_1 if($sum_x_1 !=0); - my $weighted_sum_difference_from_mean_x_1 = calculate_weighted_sum_difference_from_mean($channels_x_1, $old, $current_readout,$avg_x_1); - $rms_x_1 = sqrt($weighted_sum_difference_from_mean_x_1/($sum_x_1||1E-10)); - } - - - if($sum_y_0 < $minNumberOfEntries){ - $avg_y_0 = "NaN"; - $rms_y_0 = "NaN"; - } else { - $avg_y_0 = $wsum_y_0 / $sum_y_0 if($sum_y_0 !=0); - my $weighted_sum_difference_from_mean_y_0 = calculate_weighted_sum_difference_from_mean($channels_y_0, $old, $current_readout,$avg_y_0); - $rms_y_0 = sqrt($weighted_sum_difference_from_mean_y_0/($sum_y_0||1E-10)); - } - - if($sum_y_1 < $minNumberOfEntries){ - $avg_y_1 = "NaN"; - $rms_y_1 = "NaN"; - } else { - $avg_y_1 = $wsum_y_1 / $sum_y_1 if($sum_y_1 !=0); - my $weighted_sum_difference_from_mean_y_1 = calculate_weighted_sum_difference_from_mean($channels_y_1, $old, $current_readout,$avg_y_1); - $rms_y_1 = sqrt($weighted_sum_difference_from_mean_y_1/($sum_y_1||1E-10)); - } - - - HPlot::PlotAdd("StartPosition",$avg_x_0,0); - HPlot::PlotAdd("StartPosition",$avg_x_1,1); - HPlot::PlotAdd("StartPosition",$avg_y_0,2); - HPlot::PlotAdd("StartPosition",$avg_y_1,3); - - HPlot::PlotAdd("StartPositionRMS",$rms_x_0,0); - HPlot::PlotAdd("StartPositionRMS",$rms_x_1,1); - HPlot::PlotAdd("StartPositionRMS",$rms_y_0,2); - HPlot::PlotAdd("StartPositionRMS",$rms_y_1,3); - - HPlot::PlotDrawFork('StartPosition') if ($iter == 1); - HPlot::PlotDrawFork('StartRateNumbers_VW') if ($iter == 2); - HPlot::PlotDrawFork('StartPositionRMS') if ($iter == 3); - HPlot::PlotDrawFork('StartRateX_histbar') if ($iter == 4); -# HPlot::PlotDrawFork('StartRateX_1histbar_VW') if ($iter == 5); - HPlot::PlotDrawFork('StartRateY_histbar') if ($iter == 6); -# HPlot::PlotDrawFork('StartRateY_1histbar_VW') if ($iter == 7); - - $iter = 1 if ($iter++ == 10) #dont change - - } - - $old = $current_readout; - usleep(100000); -# sleep 1; -} - - - - - -sub calculate_rates{ - my ($ra_channels, $old,$current_readout) = @_ ; - - my @result; - for my $i (0..48){ - $result[$i] = 0; - } - - foreach my $ch (@$ra_channels) { - my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch}); - $trbnet += $trbnet_endpoint_offset; - my $hits = $current_readout->{$trbnet}->{value}->[$channel]//0; - my $hitdiff = ($hits & 0xfffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); - $hitdiff +=2**28 if $hitdiff < 0; - my $time = $current_readout->{$trbnet}->{time}->[$channel]; - my $tdiff = ($time//0) - ($old->{$trbnet}->{time}->[$channel]//0); - $tdiff += 2**16 if $tdiff <0; - $tdiff *= 16; - my $rate = $hitdiff / ($tdiff || 1E6) * 1E6 ; - - $result[$phy_channel] = $rate; - } - - for my $i(1..48){ - $result[$i] +=2**28 if $result[$i] < 0; - } - - return @result; -} - -sub calculate_diff_time_and_sum { - my ($ra_channels, $old, $current_readout) = @_; - - my ($sum , $wsum) = (0,0); - foreach my $ch (@$ra_channels) { - my ($trbnet, $channel, $phy_channel) = ( $ch->{tdc}, $ch->{ch}, $ch->{pch} ); - $trbnet += $trbnet_endpoint_offset; - my $hits = $current_readout->{$trbnet}->{value}->[$channel] //0; - # print Dumper $current_readout ; - # exit; - my $time = $current_readout->{$trbnet}->{time}->[$channel]//0; - #my $time = 10; - my $tdiff = $time - ($old->{$trbnet}->{time}->[$channel]||0); - #print Dumper $current_readout->{$b}->{time}->[15]; - #exit; - $tdiff += 2**16 if $tdiff < 0; - $tdiff *= 16; - #print Dumper $old; - #exit; - # vdiff is difference in read out values (Read: ValueDifference) - my $vdiff = ($hits & 0xfffffff) - (($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); - $vdiff += 2**28 if $vdiff < 0; - my $diff = $vdiff/($tdiff||1E6)*1E6; - #print "vdiff: $vdiff, diff: $diff, tdiff: $tdiff\n"; - - $sum += $diff; - $wsum += $diff * $phy_channel; - - #$old->{$trbnet}->{value}->[$channel] = $hits; - #$old->{$trbnet}->{time}->[$channel] = $time; - } - - return ($sum, $wsum); -} - -sub calculate_weighted_sum_difference_from_mean{ - my ($ra_channels, $old,$current_readout, $avg) = @_ ; - my $weighted_sum_difference_from_mean = 0; - foreach my $ch (@$ra_channels) { - my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch}); - $trbnet += $trbnet_endpoint_offset; - my $hits = $current_readout->{$trbnet}->{value}->[$channel]//0; - my $hitdiff = ($hits & 0xfffffff)-(($old->{$trbnet}->{value}->[$channel]//0) & 0xfffffff); - printf("%04x %04x\n",$trbnet,$channel) unless defined $hits; - $hitdiff +=2**28 if $hitdiff < 0; - my $time = $current_readout->{$trbnet}->{time}->[$channel]//0; - my $tdiff = $time - ($old->{$trbnet}->{time}->[$channel]//0); - $tdiff += 2**16 if $tdiff <0; - $tdiff *= 16; - my $rate = $hitdiff / ($tdiff || 1E6) * 1E6 ; -# $weighted_sum_difference_from_mean += $hitdiff * ( ($phy_channel-$avg)**2); # this was a bug. One has to weight with the rate, not with the recorded hits, as weighted sum is also a rate - $weighted_sum_difference_from_mean += $rate * ( ($phy_channel-$avg)**2); - } - return $weighted_sum_difference_from_mean; - -} - - diff --git a/hmon/hmon_tdcchanerrors_monitor.pl b/hmon/hmon_tdcchanerrors_monitor.pl deleted file mode 100644 index 1e38dea..0000000 --- a/hmon/hmon_tdcchanerrors_monitor.pl +++ /dev/null @@ -1,378 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use POSIX qw(strftime floor ceil); -use FileHandle; -use lib "./code"; -use lib "../daqtools/tools"; -use HADES::TrbNet; -use Time::HiRes qw(usleep); -use Dmon; -use Hmon; -use HPlot; -use QA; -use getebjson; -use getrootjson; -use JSON::XS; -use Data::Dumper; -use List::Util qw(min max sum); -use LWP::Simple qw(get); -use Try::Tiny; -trb_init_ports() or die trb_strerror(); - -my $data; -my $NUMPLOTS = 9; -my $SERVER = 'calib'; #calib or calibtest - - my $str = Hmon::MakeTitle(200, 110, "TDC Cal Mon",1); - for(my $e = 0; $e < $NUMPLOTS; $e++) { - $str .= qq@
\n@; - } - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("TdcCalMon",$str); - - my $labels = 'set xtics ('; - - my $entry = 0; - my $regs = trb_register_read_mem(0xffff,0xc802,0,2) or die trb_strerror() or sleep 5 and next; - my $boards; - foreach my $b (sort {$a <=> $b} keys %$regs) { - next unless (defined $regs->{$b}[1]); - $boards->{$b}{enable} = $regs->{$b}[0] + ($regs->{$b}[1] << 32); - $labels .= sprintf("'%04x' %i,",$b,$entry++); - } - chomp $labels; - my $numboards = $entry; - $labels .= ') rotate by 90 offset 0,-1.4 font ",6";'; - - my @names = qw(LeadingAverage[ns] LeadingSigma[ps] IgnoredOutliers IgnoredHits ToTAverage[ns] ToTSigna[ps] IgnoredToTOutliers IgnoredToT CorrectedHits); - -HPlot::PlotInit({ - name => "TdcCalMon0", - file => "files/TdcCalMon0", - cblabel => "TdcCalMon ".$names[0], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => -10, - cbmax => 10, - noinit => 1, - palette => 'defined (-10 "red", -9 "yellow", 9 "blue", 10 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon1", - file => "files/TdcCalMon1", - cblabel => "TdcCalMon ".$names[1], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 0, - cbmax => 200, - noinit => 1, - palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "#ffff00", 35 "#ffaaaa", 50 "#ff00ff", 50.1 "#aa0000", 200 "#000000")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon2", - file => "files/TdcCalMon2", - cblabel => "TdcCalMon ".$names[2], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon3", - file => "files/TdcCalMon3", - cblabel => "TdcCalMon ".$names[3], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -################################################################################################### - -HPlot::PlotInit({ - name => "TdcCalMon4", - file => "files/TdcCalMon4", - cblabel => "TdcCalMon ".$names[4], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 19, - cbmax => 31, - noinit => 1, - palette => 'defined (19 "red", 19.8 "red", 20 "green", 20.2 "red", 29.8 "red", 30 "blue", 30.2 "red", 31 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon5", - file => "files/TdcCalMon5", - cblabel => "TdcCalMon ".$names[5], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 0, - cbmax => 400, - noinit => 1, - palette => 'defined (0 "red", 0.1 "#008800", 40 "#00ff00", 50 "#ffff00", 51 "orange", 100 "#ffaaaa", 120 "#ff00ff", 120.1 "#aa0000", 400 "#000000")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon6", - file => "files/TdcCalMon6", - cblabel => "TdcCalMon ".$names[6], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon7", - file => "files/TdcCalMon7", - cblabel => "TdcCalMon ".$names[7], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels."set logscale cb;", - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon8", - file => "files/TdcCalMon8", - cblabel => "TdcCalMon ".$names[8], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, - cbmin => 0, - cbmax => 0.1, - palette => 'defined (0 "#004400", 0.000001 "#00ff00", 0.0009 "#33ff00", 0.001 "yellow", 0.1 "red")', - additional => $labels,#."set logscale cb;", - showvalues => 0, }); - -################################################################################################### - - my $datahistlist = getjsonhash($SERVER,'h.json'); - - #print Dumper $datahistlist->{'_allnames'}; - - $entry = -1; - - foreach my $b (sort {$a <=> $b} keys %$boards) { - $entry++; - my $activechannels = $boards->{$b}{enable}; - - my $p = sprintf("TDC_%04X_Edges",$b); - $p = $datahistlist->{'_allnames'}{$p}; - my $hits = getroothist($SERVER,$p) if($p) ; - next unless $hits; - - $p = sprintf("TDC_%04X_CorrectedHits",$b); - $p = $datahistlist->{'_allnames'}{$p}; - my $corr = getroothist($SERVER,$p) if($p) ; - next unless $corr; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); - - my $avg = ($corr->{bins}[$i]//0) / ($hits->{bins}[$i*2]||1); - HPlot::PlotFill("TdcCalMon8",$avg,$entry,$i); - } - } - - $entry = -1; - foreach my $b (sort {$a <=> $b} keys %$boards) { - $entry++; - my $activechannels = $boards->{$b}{enable}; - - my $p = sprintf("TDC_%04X_RisingChanneslDiff",$b); - $p = $datahistlist->{'_allnames'}{$p}; - if($p) { - my $d = getroothist($SERVER,$p); - next unless $d; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b < 0x5008 && $b >= 0x5000 && !($i&1)); - - my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i]); - - $avg = ($avg/100.-10); - $sigma = ($sigma*10); - #printf("%04x\t%i\n",$b,$sigma); - HPlot::PlotFill("TdcCalMon0",$avg,$entry,$i); - HPlot::PlotFill("TdcCalMon1",$sigma,$entry,$i); - HPlot::PlotFill("TdcCalMon2",$outlier,$entry,$i); - HPlot::PlotFill("TdcCalMon3",$ignored,$entry,$i); - } - } - - $p = sprintf("TDC_%04X_TotVsChannel",$b); - $p = $datahistlist->{'_allnames'}{$p}; - if($p) { - my $d = getroothist($SERVER,$p); - next unless $d; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); - - my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],1460,1540) if ($b < 0x7000); - ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],960,1040) if ($b >= 0x7000); - - $avg = ($avg/50); - $sigma = ($sigma*20); - #printf("%04x\t%i\n",$b,$sigma); - HPlot::PlotFill("TdcCalMon4",$avg,$entry,$i); - HPlot::PlotFill("TdcCalMon5",$sigma,$entry,$i); - HPlot::PlotFill("TdcCalMon6",$outlier,$entry,$i); - HPlot::PlotFill("TdcCalMon7",$ignored,$entry,$i); - } - } - -# last if $entry == 150; - } - - - for(my $e = 0; $e < $NUMPLOTS; $e++) { - HPlot::PlotDraw("TdcCalMon$e"); - } - - - -sub stats { - my @arr = @{$_[0]}; - my $minwindow = $_[1] // 0; - my $maxwindow = $_[2] // (scalar @arr-1); - - my $weightedsum = 0; - my $sigma = 0; - my $outlier = 0; - my $ignored = 0; - my $sum = 0; - my $sigmasum = 0; - - for my $i ($minwindow..$maxwindow){ - $weightedsum += $arr[$i]*$i; - $sum += $arr[$i]; - } - return (0,0,0,0,0) unless $sum; - - my $avg = $weightedsum/$sum; - - for my $i (0..(scalar @arr-1)){ - if ($i > $maxwindow || $i < $minwindow) { - $ignored += $arr[$i]; - } - elsif($arr[$i] > 0 && $arr[$i] <= 2) { - $outlier+= $arr[$i]; - } - else { - $sigma += ($i-$avg)**2 * $arr[$i]; - $sigmasum += $arr[$i]; - } - } - $sigma = sqrt($sigma/($sigmasum||1)); - - return ($sum,$avg,$sigma,$outlier,$ignored); - } - diff --git a/hmon/hmon_tdcchanerrors_testmonitor.pl b/hmon/hmon_tdcchanerrors_testmonitor.pl deleted file mode 100644 index 8f6202c..0000000 --- a/hmon/hmon_tdcchanerrors_testmonitor.pl +++ /dev/null @@ -1,378 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use POSIX qw(strftime floor ceil); -use FileHandle; -use lib "./code"; -use lib "../daqtools/tools"; -use HADES::TrbNet; -use Time::HiRes qw(usleep); -use Dmon; -use Hmon; -use HPlot; -use QA; -use getebjson; -use getrootjson; -use JSON::XS; -use Data::Dumper; -use List::Util qw(min max sum); -use LWP::Simple qw(get); -use Try::Tiny; -trb_init_ports() or die trb_strerror(); - -my $data; -my $NUMPLOTS = 9; -my $SERVER = 'calibtest'; #calib or calibtest - - my $str = Hmon::MakeTitle(200, 110, "TDC Cal Mon",1); - for(my $e = 0; $e < $NUMPLOTS; $e++) { - $str .= qq@
\n@; - } - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("TdcCalMon",$str); - - my $labels = 'set xtics ('; - - my $entry = 0; - my $regs = trb_register_read_mem(0xffff,0xc802,0,2) or die trb_strerror() or sleep 5 and next; - my $boards; - foreach my $b (sort {$a <=> $b} keys %$regs) { - next unless (defined $regs->{$b}[1]); - $boards->{$b}{enable} = $regs->{$b}[0] + ($regs->{$b}[1] << 32); - $labels .= sprintf("'%04x' %i,",$b,$entry++); - } - chomp $labels; - my $numboards = $entry; - $labels .= ') rotate by 90 offset 0,-1.4 font ",6";'; - - my @names = qw(LeadingAverage[ns] LeadingSigma[ps] IgnoredOutliers IgnoredHits ToTAverage[ns] ToTSigna[ps] IgnoredToTOutliers IgnoredToT CorrectedHits); - -HPlot::PlotInit({ - name => "TdcCalMon0", - file => "files/TdcCalMon0", - cblabel => "TdcCalMon ".$names[0], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => -10, - cbmax => 10, - noinit => 1, - palette => 'defined (-10 "red", -9 "yellow", 9 "blue", 10 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon1", - file => "files/TdcCalMon1", - cblabel => "TdcCalMon ".$names[1], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 0, - cbmax => 200, - noinit => 1, - palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "#ffff00", 35 "#ffaaaa", 50 "#ff00ff", 50.1 "#aa0000", 200 "#000000")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon2", - file => "files/TdcCalMon2", - cblabel => "TdcCalMon ".$names[2], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon3", - file => "files/TdcCalMon3", - cblabel => "TdcCalMon ".$names[3], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -################################################################################################### - -HPlot::PlotInit({ - name => "TdcCalMon4", - file => "files/TdcCalMon4", - cblabel => "TdcCalMon ".$names[4], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 19, - cbmax => 31, - noinit => 1, - palette => 'defined (19 "red", 19.8 "red", 20 "green", 20.2 "red", 29.8 "red", 30 "blue", 30.2 "red", 31 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon5", - file => "files/TdcCalMon5", - cblabel => "TdcCalMon ".$names[5], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - cbmin => 0, - cbmax => 400, - noinit => 1, - palette => 'defined (0 "red", 0.1 "#008800", 40 "#00ff00", 50 "#ffff00", 51 "orange", 100 "#ffaaaa", 120 "#ff00ff", 120.1 "#aa0000", 400 "#000000")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon6", - file => "files/TdcCalMon6", - cblabel => "TdcCalMon ".$names[6], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels, - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon7", - file => "files/TdcCalMon7", - cblabel => "TdcCalMon ".$names[7], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, -# palette => 'defined (0 "red", 0.1 "#008800", 10 "#00ff00", 25 "yellow", 60 "violet", 300 "red")', - additional => $labels."set logscale cb;", - showvalues => 0, }); - -HPlot::PlotInit({ - name => "TdcCalMon8", - file => "files/TdcCalMon8", - cblabel => "TdcCalMon ".$names[8], - entries => $numboards, - curves => 49, - type => HPlot::TYPE_HEATMAP, - output => HPlot::OUT_PNG, - sizex => 10000, - sizey => 500, - nokey => 1, - buffer => 0, - xmin => -0.5, - xmax => $numboards-0.5, - ymin => -0.5, - ymax => 48.5, - noinit => 1, - cbmin => 0, - cbmax => 0.1, - palette => 'defined (0 "#004400", 0.000001 "#00ff00", 0.0009 "#33ff00", 0.001 "yellow", 0.1 "red")', - additional => $labels,#."set logscale cb;", - showvalues => 0, }); - -################################################################################################### - - my $datahistlist = getjsonhash($SERVER,'h.json'); - - #print Dumper $datahistlist->{'_allnames'}; - - $entry = -1; - - foreach my $b (sort {$a <=> $b} keys %$boards) { - $entry++; - my $activechannels = $boards->{$b}{enable}; - - my $p = sprintf("TDC_%04X_Edges",$b); - $p = $datahistlist->{'_allnames'}{$p}; - my $hits = getroothist($SERVER,$p) if($p) ; - next unless $hits; - - $p = sprintf("TDC_%04X_CorrectedHits",$b); - $p = $datahistlist->{'_allnames'}{$p}; - my $corr = getroothist($SERVER,$p) if($p) ; - next unless $corr; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); - - my $avg = ($corr->{bins}[$i]//0) / ($hits->{bins}[$i*2]||1); - HPlot::PlotFill("TdcCalMon8",$avg,$entry,$i); - } - } - - $entry = -1; - foreach my $b (sort {$a <=> $b} keys %$boards) { - $entry++; - my $activechannels = $boards->{$b}{enable}; - - my $p = sprintf("TDC_%04X_RisingChanneslDiff",$b); - $p = $datahistlist->{'_allnames'}{$p}; - if($p) { - my $d = getroothist($SERVER,$p); - next unless $d; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b < 0x5008 && $b >= 0x5000 && !($i&1)); - - my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i]); - - $avg = ($avg/100.-10); - $sigma = ($sigma*10); - #printf("%04x\t%i\n",$b,$sigma); - HPlot::PlotFill("TdcCalMon0",$avg,$entry,$i); - HPlot::PlotFill("TdcCalMon1",$sigma,$entry,$i); - HPlot::PlotFill("TdcCalMon2",$outlier,$entry,$i); - HPlot::PlotFill("TdcCalMon3",$ignored,$entry,$i); - } - } - - $p = sprintf("TDC_%04X_TotVsChannel",$b); - $p = $datahistlist->{'_allnames'}{$p}; - if($p) { - my $d = getroothist($SERVER,$p); - next unless $d; - - for(my $i=1;$i<=48;$i++) { - next unless $activechannels & (1<<($i-1)); - next if($b >= 0x5000 && $b < 0x5008 && !($i&1)); - - my ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],1460,1540) if ($b < 0x7000); - ($sum,$avg,$sigma,$outlier,$ignored) = stats($d->{bins}[$i],960,1040) if ($b >= 0x7000); - - $avg = ($avg/50); - $sigma = ($sigma*20); - #printf("%04x\t%i\n",$b,$sigma); - HPlot::PlotFill("TdcCalMon4",$avg,$entry,$i); - HPlot::PlotFill("TdcCalMon5",$sigma,$entry,$i); - HPlot::PlotFill("TdcCalMon6",$outlier,$entry,$i); - HPlot::PlotFill("TdcCalMon7",$ignored,$entry,$i); - } - } - -# last if $entry == 150; - } - - - for(my $e = 0; $e < $NUMPLOTS; $e++) { - HPlot::PlotDraw("TdcCalMon$e"); - } - - - -sub stats { - my @arr = @{$_[0]}; - my $minwindow = $_[1] // 0; - my $maxwindow = $_[2] // (scalar @arr-1); - - my $weightedsum = 0; - my $sigma = 0; - my $outlier = 0; - my $ignored = 0; - my $sum = 0; - my $sigmasum = 0; - - for my $i ($minwindow..$maxwindow){ - $weightedsum += $arr[$i]*$i; - $sum += $arr[$i]; - } - return (0,0,0,0,0) unless $sum; - - my $avg = $weightedsum/$sum; - - for my $i (0..(scalar @arr-1)){ - if ($i > $maxwindow || $i < $minwindow) { - $ignored += $arr[$i]; - } - elsif($arr[$i] > 0 && $arr[$i] <= 2) { - $outlier+= $arr[$i]; - } - else { - $sigma += ($i-$avg)**2 * $arr[$i]; - $sigmasum += $arr[$i]; - } - } - $sigma = sqrt($sigma/($sigmasum||1)); - - return ($sum,$avg,$sigma,$outlier,$ignored); - } - diff --git a/hmon/hmon_vetohist.pl b/hmon/hmon_vetohist.pl deleted file mode 100644 index 38bd77c..0000000 --- a/hmon/hmon_vetohist.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl - -use Hmon; -use QA; -use HADES::TrbNet; - -trb_init_ports() or die("could not connect to trbnetd"); - - -my $str; - -my $plots = fork(); - - -if($plots) { - while(1) { - $str = Hmon::MakeTitle(10,11,"Veto Histogram",0); - my $binning = trb_register_read(3,0xa0c8) or sleep 5 and next; - my $offset = trb_register_read(3,0xa0c6) or sleep 5 and next; - $binning = QA::SciNotation($binning->{3}*100E-9); - $offset = QA::SciNotation($offset->{3}*100E-9); - - - $str .= qq@Offset: @.$offset.qq@s - Binning: @.$binning.qq@s@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("Vetohist",$str); - sleep(5); - } - } - -else { - qx(./hmon_hadplot.sh -d 3000 \\ - -a 0x0003 -r 50216 -m 500 -p 0 -w 32 -t "1" \\ - -a 0x0003 -r 50716 -m 500 -p 0 -w 32 -t "2" \\ - -a 0x0003 -r 51216 -m 500 -p 0 -w 32 -t "3" \\ - -a 0x0003 -r 51716 -m 500 -p 0 -w 32 -t "4" \\ - -a 0x0003 -r 52216 -m 500 -p 0 -w 32 -t "5" \\ - -a 0x0003 -r 52716 -m 500 -p 0 -w 32 -t "6" \\ - -a 0x0003 -r 53216 -m 500 -p 0 -w 32 -t "7" \\ - -a 0x0003 -r 53716 -m 500 -p 0 -w 32 -t "8" \\ - -output "PNG.files/vetohist.760.490" -curvestyle steps -key genreg 2>/dev/null & - - ); - } - diff --git a/hmon/permanent/hmon_archiveveto.pl b/hmon/permanent/hmon_archiveveto.pl deleted file mode 100644 index ef99a56..0000000 --- a/hmon/permanent/hmon_archiveveto.pl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use POSIX qw(strftime); -use Data::Dumper; - - -while(1) { - my $time = strftime("%Y%m%d%H%M%S",localtime()); -# my $time = "201204111356"; - - system("cp /home/hadaq/trbsoft/daq/tools/hmon/files/vetohist.png /home/hadaq/trbsoft/daq/tools/hmon/archive/veto_$time.png"); - - sleep(30); - } - \ No newline at end of file diff --git a/hmon/permanent/hmon_eberrbits.pl b/hmon/permanent/hmon_eberrbits.pl deleted file mode 100644 index 08d5e80..0000000 --- a/hmon/permanent/hmon_eberrbits.pl +++ /dev/null @@ -1,239 +0,0 @@ -#!/usr/bin/perl -# adjusted for BNET with dabc webserver JAM 2-Oct-2018 -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use HADES::TrbNet; -use LWP::Simple; -use JSON qw( decode_json ); - -my $timer = 0; -my $flog = QA::OpenQAFile(); - - -my $opt_debug = 0; -my $opt_verbose =0; - - -my $sources = { -TRB_8800 => "CentralCTS", -TRB_8400 =>"RPC123 ", -TRB_8410 =>"RPC456 ", -TRB_84C0 =>"RPCnew1", -TRB_84C1 =>"RPCnew2", -TRB_84C2 =>"RPCnew3", -TRB_84C3 =>"RPCnew4", -TRB_84C4 =>"RPCnew5", -TRB_84C5 =>"RPCnew6", -TRB_8600 =>"TOF ", -TRB_86C0 =>"TOFnew1", -TRB_86C1 =>"TOFnew2", -TRB_86C2 =>"TOFnew3", -TRB_86C3 =>"TOFnew4", -TRB_86C4 =>"TOFnew5", -TRB_86C5 =>"TOFnew6", -TRB_86C6 =>"TOFnew7", -TRB_8700 =>"FW ", -TRB_8880 => "StartTRB3", -TRB_8890 => "VetoTRB3", -TRB_8900 => "Pion1 ", -TRB_8910 => "Pion2 ", -TRB_1000 => "MDC12sec1", -TRB_1010 => "MDC12sec2", -TRB_1020 => "MDC12sec3", -TRB_1030 => "MDC12sec4", -TRB_1040 => "MDC12sec5", -TRB_1050 => "MDC12sec6", -TRB_1100 => "MDC34sec1", -TRB_1110 => "MDC34sec2", -TRB_1120 => "MDC34sec3", -TRB_1130 => "MDC34sec4", -TRB_1140 => "MDC34sec5", -TRB_1150 => "MDC34sec6", -TRB_8A00 => "ECal0 ", -TRB_8A01 => "ECal1 ", -TRB_8A02 => "ECal2 ", -TRB_8A03 => "ECal3 ", -TRB_8A04 => "ECal4 ", -TRB_8A05 => "ECal5 ", -TRB_83C0 => "RICH0 ", -TRB_83C1 => "RICH1 ", -TRB_83C2 => "RICH2 ", -TRB_83C3 => "RICH3 ", -TRB_83C4 => "RICH4 ", -TRB_83C5 => "RICH5 ", -TRB_83C6 => "RICH6 ", -TRB_83C7 => "RICH7 ", -TRB_83C8 => "RICH8 ", -TRB_83C9 => "RICH9 ", -TRB_83CA => "RICHa ", -TRB_83CB => "RICHb ", -TRB_8B10 => "STS2-0", -TRB_8B11 => "STS2-1", -TRB_8B12 => "STS2-2", -TRB_8B13 => "STS2-3", -TRB_8B14 => "STS2-4", -TRB_8B15 => "STS2-5" -}; - - - - -my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); - - -# JAM 2018 here figure out corresponding json calles -my $masterurl = 'http://lxhadeb12:8099/'; - -my $url_inputs = $masterurl . 'Master/BNET/Inputs/get.json?field="value"'; - -#my $url_cts_histo = $masterurl . '/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_TrigType/get.json?field="bins"'; - -# http://lxhadeb07:8099/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_ErrorBits/get.json?field=%"bins" - - - -while (1) -{ - - my $store = {}; -my $longstring = ""; -my $qastate = QA::OK; -my $value = ""; -my $brokenevents = 0; -my $maxperc = 0; -my $sumperc = 0; -my $errcnt = 0; - - - - my $num_bnetin=0; -my $inputs = get ($url_inputs); -#print Dumper $inputs; -my $inputs_array; -if (defined $inputs) -{ - $inputs_array = decode_json($inputs); - $num_bnetin = scalar @$inputs_array; -} - - - ## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_ins=0; -for my $inpnode (@$inputs_array) { - #print " node is $inpnode \n"; - # todo: remove FirstLevel from inpnode - my $lastslash = rindex($inpnode, "/") + 1; - my $nodepath = substr($inpnode, 0, $lastslash); - #print "nodepath is $nodepath\n"; - my $url_nodehierarchy = $masterurl . $nodepath . '/h.json'; - my $nodehierarchy = get ($url_nodehierarchy); - print "\n--------------\n$url_nodehierarchy \n" if $opt_verbose; - #print Dumper $nodehierarchy; - if (defined $nodehierarchy) - { - my $inpnode_array = decode_json($nodehierarchy); -# print Dumper $inpnode_array; - my $numchilds = scalar $inpnode_array->{'_childs'}; - my $i=0; my $j=0; my $k=0; - for ($i=0; $i < $numchilds; $i = $i + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_name'}); - my $childname= $inpnode_array->{'_childs'}[$i]->{'_name'}; - print "name $i = $childname \n" if $opt_verbose; - if($childname =~ /TRB/) - { - print "found trb node $childname \n" if $opt_verbose; - # scan array of subchildren: - my $numsubchilds = scalar $inpnode_array->{'_childs'}[$i]->{'_childs'}; - for ($j=0; $j < $numsubchilds; $j = $j + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}); - my $subchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}; - if($subchildname =~ /TRB/) - { - my $numsubsubchilds = scalar @{$inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}}; - print "found subnode $subchildname with $numsubsubchilds childs \n" if $opt_verbose; - for ($k=0; $k < $numsubsubchilds; $k = $k + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}); - my $subsubchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}; - print "scanning subsubnode $subsubchildname.. \n" if $opt_verbose; - if($subsubchildname =~ /ErrorBits/) - { - print "found errorbits histogram $subsubchildname \n" if $opt_verbose; - my $errorbits_url = "$masterurl$nodepath/$childname/$subchildname/$subsubchildname/get.json?field=\"bins\""; - print "url is $errorbits_url \n" if $opt_verbose; - my $errorbits = get ($errorbits_url); - #print Dumper $errorbits; - next unless (defined $errorbits); - my $errorbits_array = decode_json($errorbits); - foreach my $bit (0 .. 31) { - if($errorbits_array->[$bit+4]) - { - $store->{$subchildname}->{$bit}+= $errorbits_array->[$bit+4]; - $store->{all}->{$bit}+=$errorbits_array->[$bit+4]; - } - } - } - } - } - } - - } - - last if($i > 1000); - } - - } -} - -print Dumper $store if $opt_verbose; - -# JAM2018 - same as before with epics: -foreach my $k (sort keys %$store) { - if ($k ne "all") { - foreach my $b (sort keys %{$store->{$k}}) { - if(($b != 0)) { - my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; - $maxperc = $perc if $perc > $maxperc; - $sumperc += $perc; - my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", - $sources->{$k}, - # substr ($sources->{$k}, 1, -1), - $store->{$k}->{$b}, - $perc, - $bits[$b]); - $longstring .= $ts; - $brokenevents += $store->{$k}->{$b}; - } - } - } - } - $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); - $longstring = "Total Events in file: ".($store->{TRB_8800}->{0} || "")." - ". - "Events with errors: ".$value." - ". - $longstring; - chop $longstring;chop $longstring;chop $longstring; - print "$longstring \n" if $opt_debug; - $qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); - QA::WriteQALog($flog, "eb", "errbits", 10, - $qastate, "#Evt w/ errors", $value, $longstring) unless $opt_debug; -# JAM2018: do we want system log and speaker again? - # system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); - print 'EB Events with set error-bits written to file: $longstring' if ($opt_debug && $qastate > 60 && !($timer++%60)); - $timer = 0 if $qastate <= 60; - #Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - - -sleep (2); -} - - - - diff --git a/hmon/permanent/hmon_icinga.pl b/hmon/permanent/hmon_icinga.pl deleted file mode 100644 index d6e8df2..0000000 --- a/hmon/permanent/hmon_icinga.pl +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use POSIX qw(strftime); -use FileHandle; -use Hmon; -use QA; -use Getopt::Long; -use Data::Dumper; -use IO::Socket::INET; - -my $flog = QA::OpenQAFile(); - -my $started = 1; -my $last_mod_time = "---"; -my $num_unchanged =0; -my $interval = 5; -my ($socket,$client_socket); - -$socket = new IO::Socket::INET ( - PeerHost => 'lxhadeb06', - PeerPort => '12345', - Proto => 'tcp' - ); - -while (1) { - - my $title = "Icinga"; - my $value = "OK"; - my $longtext = ""; - - my $title_etrax = "TRB"; - my $value_etrax = "OK"; - my $longtext_etrax = ""; - - my $title_power = "Pwrsply"; - my $value_power = "OK"; - my $longtext_power = ""; - - my $num_errors = 0; - my $icinga_running = 0; - #my $icinga_status_file = "/var/lib/icinga/status.dat"; - #my @a = stat($icinga_status_file); - - my $result = undef; - if (defined $socket) { - #print "print to socket\n"; - $result = print $socket "secreticinga\n"; - #print $result . "\n"; - } - if (!$result) { - #print "open socket\n"; - $socket = new IO::Socket::INET ( - PeerHost => 'lxhadeb06', - PeerPort => '12345', - Proto => 'tcp'); - if (!($socket)) { - #print "unable to open socket\n"; - $value = "DOWN"; - $longtext = "Unable to connect to lxhadeb06 (icinga log deamon)"; - $num_errors = 999; - } - } - - my $result_a; - if (defined $socket) { - #print "hallo\n"; - eval { - local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required - alarm 10; - $result_a = <$socket>; - alarm 0; - }; - if ($@) { - if ($@ eq "alarm\n") { - print "Timeout from server\n"; - } - # timed out - } - - #print "blubb\n"; - # JAM: below changed from a[8] to a[9] due to different ls format - if (defined $result_a) { - #print $result_a . "\n"; - my @a = split(/\s+/,$result_a); - #print $a[9]. "\n"; - #print $a[10]. "\n"; - if ($started == 1) { - $started = 0; - $last_mod_time = $a[9]; - $num_unchanged = 0; - } - - if ($last_mod_time ne $a[9]) { - my @a = split(/\s+/,$result_a); - $last_mod_time = $a[9]; - $num_unchanged = 0; - } else { - $num_unchanged++; - } - } - } - - - - if ($num_unchanged > 5) { - #if ($num_unchanged > 0) { - my $downtime = $num_unchanged*$interval; - $value = "DOWN"; - $longtext = "Icinga not updated since $last_mod_time"; - QA::WriteQALog($flog,"server","icinga",10,QA::FATAL,$title,$value,$longtext); - $num_unchanged = 0; - # JAM better reset counter here - } else { - - - - my $icinga_query_hosts = "ssh lxhadeb06 \"REMOTE_USER='icingaadmin' REQUEST_METHOD='GET' QUERY_STRING='csvoutput&style=hostdetail&hoststatustypes=4&hostprops=10' /usr/lib/cgi-bin/icinga/status.cgi\" | grep -v declare"; - my @icinga_result_hosts = qx($icinga_query_hosts); - splice(@icinga_result_hosts, 0, 7); - #printf("@icinga_result_hosts"); - $num_errors += scalar @icinga_result_hosts; - - my $icinga_query_etrax = "ssh lxhadeb06 \"REMOTE_USER='icingaadmin' REQUEST_METHOD='GET' QUERY_STRING='csvoutput&hostgroup=etrax&style=hostdetail&hoststatustypes=4&hostprops=10' /usr/lib/cgi-bin/icinga/status.cgi\" | grep -v declare"; - my @icinga_result_etrax = qx($icinga_query_etrax); - #printf("@icinga_result_etrax"); - splice(@icinga_result_etrax, 0, 7); - my $num_errors_etrax = scalar @icinga_result_etrax; - - my $icinga_query_power = "ssh lxhadeb06 \"REMOTE_USER='icingaadmin' REQUEST_METHOD='GET' QUERY_STRING='csvoutput&hostgroup=power&style=hostdetail&hoststatustypes=4&hostprops=10' /usr/lib/cgi-bin/icinga/status.cgi\" | grep -v declare"; - my @icinga_result_power = qx($icinga_query_power); - #print @icinga_result_power . "\n"; - splice(@icinga_result_power, 0, 7); - my $num_errors_power = scalar @icinga_result_power; - - - my $icinga_query_services = "ssh lxhadeb06 \"REMOTE_USER='icingaadmin' REQUEST_METHOD='GET' QUERY_STRING='csvoutput&style=detail&servicestatustypes=16&hoststatustypes=3&serviceprops=2097162' /usr/lib/cgi-bin/icinga/status.cgi\" | grep -v declare"; - my @icinga_result_services = qx($icinga_query_services); - splice(@icinga_result_services, 0, 7); - #printf("@icinga_result_services"); - $num_errors += scalar @icinga_result_services; - - foreach (@icinga_result_hosts) { - my @error = split(/\;/); - $error[5] =~ s/ - /: /g; - $error[5] =~ s/\n/ - /g; - $error[5] =~ s/'//g; - $longtext .= $error[5]; - } - foreach (@icinga_result_etrax) { - my @error_etrax = split(/\;/); - $error_etrax[5] =~ s/ - /: /g; - $error_etrax[5] =~ s/\n/ - /g; - $error_etrax[5] =~ s/'//g; - if ($error_etrax[5] =~ m/etraxp2/) { - $num_errors_etrax--; - } else { - $longtext_etrax .= $error_etrax[5]; - } - } - foreach (@icinga_result_power) { - my @error_power = split(/\;/); - $error_power[5] =~ s/ - /: /g; - $error_power[5] =~ s/\n/ - /g; - $error_power[5] =~ s/'//g; - $longtext_power .= $error_power[5]; - } - - foreach (@icinga_result_services) { - my @error = split(/\;/); - #printf("$error[6]"); - $error[6] =~ s/ - /: /g; - $error[6] =~ s/\n/ - /g; - $error[6] =~ s/'//g; - $error[0] =~ s/'//g; - $error[1] =~ s/'//g; - $longtext .= "[$error[0]:$error[1]] " . $error[6]; - } - - $longtext =~ s/ - $//; - - - #printf("$longtext\n"); - - - - if ($num_errors>0) { - $value = "Problem"; - QA::WriteQALog($flog,"server","icinga",10,QA::ERROR,$title,$value,$longtext); - } else { - QA::WriteQALog($flog,"server","icinga",10,QA::OK,$title,$value,$longtext); - } - - if ($num_errors_etrax>0) { - $value_etrax = "Problem"; - QA::WriteQALog($flog,"server","etrax",10,QA::ERROR,$title_etrax,$value_etrax,$longtext_etrax); - } else { - QA::WriteQALog($flog,"server","etrax",10,QA::OK,$title_etrax,$value_etrax,$longtext_etrax); - } - - if ($num_errors_power>0) { - $value_power = "Problem"; - QA::WriteQALog($flog,"server","pwrsup",10,QA::ERROR,$title_power,$value_power,$longtext_power); - } else { - QA::WriteQALog($flog,"server","pwrsup",10,QA::OK,$title_power,$value_power,$longtext_power); - } - - - } - sleep($interval); -} diff --git a/hmon/permanent/hmon_interrupt.pl b/hmon/permanent/hmon_interrupt.pl deleted file mode 100644 index 855ddff..0000000 --- a/hmon/permanent/hmon_interrupt.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; - -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Clone qw(clone); -use Hmon; -use QA; -use List::Util qw(sum); - -my $store = {}; -my $laststore = {}; -my $str; - - - -my $fqa = QA::OpenQAFile(); - - -my @srv = qw( lxhadeb08 lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 ); - - - - - -while(1) { - $store = {}; - my $qastate = QA::OK; - my $qastr = ''; - foreach my $s (@srv) { - my @out = Hmon::qxtimeout("ssh $s \"cat /proc/interrupts | grep TxRx-0 | head -n 1 \" {$s} = \@arr; - next unless $laststore->{$s}; - next unless $store->{$s}; - # JAM2021: adjust this for EBs without hyper threading: - my @diff = map {$store->{$s}[$_] - $laststore->{$s}[$_];} (3..33); - my $sum = sum(@diff); - if ($diff[1] < 0.9*$sum) { - $qastate = QA::WARN_2; - $qastr .= "$s "; - } - } - - } - - - QA::WriteQALog($fqa,"misc","irq",40,$qastate,"IRQ","OK","") if $qastr eq ''; - QA::WriteQALog($fqa,"misc","irq",40,$qastate,"IRQ","Error","IRQ affinity wrong on $qastr") unless $qastr eq ''; - $laststore = $store; - sleep 10; - } - diff --git a/hmon/permanent/hmon_logbook.pl b/hmon/permanent/hmon_logbook.pl index 9d86a88..35abd9f 100755 --- a/hmon/permanent/hmon_logbook.pl +++ b/hmon/permanent/hmon_logbook.pl @@ -13,7 +13,7 @@ use JSON; my $firstrun =1; -my $command = "curl 'https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hlogbook2.show' -b /tmp/cookiefile -c /tmp/cookiefile -X POST -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: de,en-US;q=0.7,en;q=0.3' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: https://hades-db.gsi.de' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hlogbook2.form_selection' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: iframe' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1' --data-raw 'p_exp_id=FEB22&p_begin=&p_end=&p_num_days=&p_num_entries=5&p_author=&p_action=Show&p_log_type=All&p_run_type=None&p_current=&p_filename=*&p_search_text=*' -u hades:6\\\$ectors 2>/dev/null | iconv -f ISO-8859-1 -t UTF-8"; +my $command = "curl 'https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hlogbook2.show' -b /tmp/cookiefile -c /tmp/cookiefile -X POST -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: de,en-US;q=0.7,en;q=0.3' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: https://hades-db.gsi.de' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://hades-db.gsi.de/pls/hades_webdbs/hades_oper.hlogbook2.form_selection' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: iframe' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-User: ?1' --data-raw 'p_exp_id=MAY22TEST&p_begin=&p_end=&p_num_days=&p_num_entries=5&p_author=&p_action=Show&p_log_type=All&p_run_type=None&p_current=&p_filename=*&p_search_text=*' -u hades:6\\\$ectors 2>/dev/null | iconv -f ISO-8859-1 -t UTF-8"; my $store; my $hash; diff --git a/hmon/permanent/hmon_mdchv_new.pl b/hmon/permanent/hmon_mdchv_new.pl deleted file mode 100644 index fa429a7..0000000 --- a/hmon/permanent/hmon_mdchv_new.pl +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use POSIX qw(strftime); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; -use HPlot; - -my $timer = 0; -my @colors = ("#000000", "#ff0000","#00ff00","#0000ff","#cccc00","#cc00cc"); -my @names = qw( S1 S2 S3 S4 S5 S6); -my @layerlabel = qw(F C); -my $connect_status = &trb_init_ports(); -if(!$connect_status) { - die("could not connect to trbnetd"); -} - -########### -#Change 3 for-loops to include all four planes again! -############ - -# my $fqa = QA::OpenQAFile(); -my @plot; -foreach my $s (0..1) { - foreach my $p (0..3) { - $plot[$p*2+$s] = (); - $plot[$p*2+$s]->{name} = "P".$p.($s?'F':'C')."I"; - $plot[$p*2+$s]->{file} = "files/MDCHV".$plot[$p*2+$s]->{name}; - $plot[$p*2+$s]->{entries} = 360; - $plot[$p*2+$s]->{xscale} = 12; - $plot[$p*2+$s]->{type} = HPlot::TYPE_HISTORY; - $plot[$p*2+$s]->{output} = HPlot::OUT_PNG; - $plot[$p*2+$s]->{xlabel} = "Minutes"; - $plot[$p*2+$s]->{ylabel} = ($s?'F':'C')." Current"; - $plot[$p*2+$s]->{sizex} = 800; - $plot[$p*2+$s]->{sizey} = 420; - $plot[$p*2+$s]->{curves} = 6; - $plot[$p*2+$s]->{dots} = 1; - $plot[$p*2+$s]->{colors} = \@colors; - foreach my $c (0..5) { - $plot[$p*2+$s]->{titles}->[$c] = ($s?'F ':'C ').$names[$c]; - } - HPlot::PlotInit($plot[$p*2+$s]); - - $plot[$p*2+$s+8]->{name} = "P".$p.($s?'F':'C')."V"; - $plot[$p*2+$s+8]->{file} = "files/MDCHV".$plot[$p*2+$s+8]->{name}; - $plot[$p*2+$s+8]->{entries} = 360; - $plot[$p*2+$s+8]->{xscale} = 12; - $plot[$p*2+$s+8]->{type} = HPlot::TYPE_HISTORY; - $plot[$p*2+$s+8]->{output} = HPlot::OUT_PNG; - $plot[$p*2+$s+8]->{xlabel} = "Minutes"; - $plot[$p*2+$s+8]->{ylabel} = ($s?'F':'C')." Voltage"; - $plot[$p*2+$s+8]->{sizex} = 800; - $plot[$p*2+$s+8]->{sizey} = 420; - $plot[$p*2+$s+8]->{curves} = 6; - $plot[$p*2+$s+8]->{dots} = 1; - $plot[$p*2+$s+8]->{colors} = \@colors; - foreach my $c (0..5) { - $plot[$p*2+$s+8]->{titles}->[$c] = ($s?'F ':'C ').$names[$c]; - } - HPlot::PlotInit($plot[$p*2+$s+8]); - } - } - - -for(my $i = 1; $i<=4; $i++) { - for(my $j = 1; $j<=6; $j++) { - my $s = sprintf("HAD:MDC:HV:P%i:S%i:F:vmon",$i,$j); - Perl2Epics::Connect("$i-$j-0-V",$s); - $s = sprintf("HAD:MDC:HV:P%i:S%i:C:vmon",$i,$j); - Perl2Epics::Connect("$i-$j-1-V",$s); - $s = sprintf("HAD:MDC:HV:P%i:S%i:F:imon",$i,$j); - Perl2Epics::Connect("$i-$j-0-I",$s); - $s = sprintf("HAD:MDC:HV:P%i:S%i:C:imon",$i,$j); - Perl2Epics::Connect("$i-$j-1-I",$s); - } - } -print "Connected.\n"; - -while(1) { - my $data = Perl2Epics::GetAll(); - my $str = Hmon::MakeTitle(13, 6, "MDC HV", 1, ""); - $str .= ""; #
- $str .= "
Sector 1Sector 2Sector 3Sector 4Sector 5Sector 6"; - for(my $i = 1; $i<=4; $i++) { - $str .= "
Plane $i\n"; - for(my $v = 0; $v<=1; $v++) { - $str .= "
".$layerlabel[$v]." "; - for(my $s = 1; $s<=6; $s++) { - my $volt = $data->{"$i-$s-$v-V"}->{val}; - my $curr = $data->{"$i-$s-$v-I"}->{val}; - my $tv = strftime("%H:%M:%S",localtime($data->{"$i-$s-$v-V"}->{tme} || 0)); - my $tc = strftime("%H:%M:%S",localtime($data->{"$i-$s-$v-I"}->{tme} || 0)); - $volt = -1 unless defined $volt; - $curr = -1 unless defined $curr; - HPlot::PlotAdd("P".($i-1).(($v)?'F':'C')."I",$curr,$s-1); - HPlot::PlotAdd("P".($i-1).(($v)?'F':'C')."V",$volt,$s-1); - my $tmp .= sprintf(" %4i V | %2.2f uA",$volt,$curr); - $tmp =~ s/\s/ /gi; - $str .= "".$tmp; - } - } - - #$str .= "
 \n"; - } - $str .= "
";# - $str .= Hmon::MakeFooter(); - - if(!($timer%1)) { - Hmon::WriteFile("MDCHV", $str); - } - if(!($timer%3)) { - foreach my $s (0..1){ - foreach my $p (0..3) { - HPlot::PlotDraw("P".$p.($s?'F':'C')."I"); - HPlot::PlotDraw("P".$p.($s?'F':'C')."V"); - } - } - } - $timer++; - sleep(1); - } diff --git a/hmon/permanent/hmon_open_ssh_master_channels.pl b/hmon/permanent/hmon_open_ssh_master_channels.pl index ab81a25..9b5f169 100755 --- a/hmon/permanent/hmon_open_ssh_master_channels.pl +++ b/hmon/permanent/hmon_open_ssh_master_channels.pl @@ -6,7 +6,7 @@ use v5.10.0; my @cpus = qw | -hades30 hades33 hadesdaq01 hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp28 hadesp30 hadesp31 hadesp33 hadesp57 hadesp63 hadesp66 hadesp70 lxhaddcs05p lxhaddcs06p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhadesdaqp +hades30 hades33 hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp28 hadesp30 hadesp31 hadesp33 hadesp57 hadesp63 hadesp66 hadesp70 lxhaddcs05p lxhaddcs06p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhadesdaqp |; #lxhadeb07 lxhadeb08 lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 lxhadeb13 lxhadeb14 lxhadeb15 lxhadeb16 lxhaddcs05 lxhaddcs06 lxhaddcs11 lxhadesdaq hadesdaq01 hades30 ha#desp31 hades33 lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhaddcs05p lxhaddcs06p lxhaddcs11p lxhad#esdaqp hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp30 hadesp33 hadesp57 hadesp70 diff --git a/hmon/permanent/hmon_pionlv.pl b/hmon/permanent/hmon_pionlv.pl deleted file mode 100644 index 92a0ec8..0000000 --- a/hmon/permanent/hmon_pionlv.pl +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/perl - -use warnings; -#use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use List::Util 'max'; -use QA; -use HPlot; -use Hmon; -use IO::Socket; - -my $flog = Hmon::OpenLogfile(); -my $fqa = QA::OpenQAFile(); - - -my @str; - -my $store = {}; -my $laststore = {}; -my $values = {}; -my $color = {}; -my $raw = {}; -my $val; -my ($max,$min,$avg,$mean); - - - -my $plot = (); -$plot->{name} = "PionLvCurrent"; -$plot->{file} = "files/PionLvCurrent"; -$plot->{entries} = 500; -$plot->{curves} = 2; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = "Pion0"; -$plot->{titles}->[1] = "Pion1"; -$plot->{xlabel} = "Seconds"; -$plot->{ylabel} = "mA"; -$plot->{sizex} = 630; -$plot->{sizey} = 220; -$plot->{storable}= 1; - -HPlot::PlotInit($plot); - - - -$str = Hmon::MakeTitle(9, 10, "Pion Low Voltage"); -$str .= qq@
\n@; -$str .= qq@\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("PionLV",$str); - - -my $cmd_volt = "VOLT?\n++read\n"; -my $cmd_curr = "CURR?\n++read\n"; - -my $sock = open_socket_prologix(); - -while (1) { - - #Hmon::WriteLog($flog, "Pion LV","Test"); - - my $curr0 = 20; - my $curr1 = 20; - - HPlot::PlotAdd("PionLvCurrent",$curr0,0); - HPlot::PlotAdd("PionLvCurrent",$curr1,1); - HPlot::PlotDraw("PionLvCurrent"); - - my $volt = &read_value($sock, $cmd_volt); - my $curr = &read_value($sock, $cmd_curr); - my $time = time(); - #print "$time\t$volt\t$curr\n"; - $curr0 = $curr; - $curr1 = $curr; - - my $qastate = QA::GetQAState('below', max($curr0,$curr1), @QA::PionLvCurrLimits); - my $str = sprintf("%i/%i", $curr0, $curr1); - QA::WriteQALog($fqa,"pion","LV", 10, $qastate, "LV Current", $str, - "Current on LV line for Pion FEE: " . $str); - - sleep(1); -} - -sub open_socket_prologix { - my $sock = new IO::Socket::INET ( PeerAddr => 'eegpibenetp02', - PeerPort => '1234', Proto => 'tcp', ); - die "Could not create socket: $!\n" unless $sock; - - $|=1; - - return $sock; -} - - -sub read_value { - my ($sock, $cmd) = @_; - print $sock $cmd; - my $res = <$sock>; - chomp $res; - return $res; -} diff --git a/hmon/permanent/hmon_pionsupply.pl b/hmon/permanent/hmon_pionsupply.pl deleted file mode 100644 index d808721..0000000 --- a/hmon/permanent/hmon_pionsupply.pl +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/perl -use FileHandle; -use Data::Dumper; -use POSIX qw(strftime); -use Hmon; -use HPlot; -use QA; -my $flog = QA::OpenQAFile(); - -my $plot = (); -$plot->{name} = "HighVoltage"; -$plot->{file} = "files/PionHV"; -$plot->{entries} = 300; -$plot->{curves} = 2; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = "Pion 1"; -$plot->{titles}->[1] = "Pion 2"; -$plot->{xlabel} = "Entries (~0.5h total)"; -$plot->{ylabel} = "Volt"; -$plot->{sizex} = 630; -$plot->{sizey} = 220; -$plot->{ymax} = 200; -$plot->{storable}= 1; -HPlot::PlotInit($plot); - - - -my $plot2 = (); -$plot2->{name} = "HVCurrent"; -$plot2->{file} = "files/PionHVCurrent"; -$plot2->{entries} = 300; -$plot2->{curves} = 2; -$plot2->{type} = HPlot::TYPE_HISTORY; -$plot2->{output} = HPlot::OUT_PNG; -$plot2->{titles}->[0] = "Pion 1"; -$plot2->{titles}->[1] = "Pion 2"; -$plot2->{xlabel} = "Entries (~0.5h total)"; -$plot2->{ylabel} = "Microampere"; -$plot2->{sizex} = 630; -$plot2->{sizey} = 220; -$plot2->{storable}= 1; -HPlot::PlotInit($plot2); - -while(1) { - - - open(PIONLOG, Hmon::HMONDIR."hmon_permanent_tail -F ".Hmon::HMONDIR."pion/scmon.log|"); - - my $readlines = 0; - my $str = ""; - my $oldtime = time(); - my $a; - - while($a = ) { - $str = Hmon::MakeTitle(9,11,"PionSupplies",1); - my @val = split(/\s+/,$a); - - #$str .= strftime("%H:%M:%S",localtime($val[0])); - $str .= "
HV (V)HV (μA)Temp. (°C)"; - $str .= sprintf("
Pion1:%.1fV%.3fuA%.1f°C",$val[3],$val[4],$val[47]); - $str .= sprintf("
Pion2:%.1fV%.3fuA%.1f°C",$val[25],$val[26],$val[53]); - $str .= "
"; - $str .= qq@
\n@; - $str .= qq@\n@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("PionSupplies",$str); - - HPlot::PlotAdd('HighVoltage',$val[3],0); - HPlot::PlotAdd('HighVoltage',$val[25],1); - HPlot::PlotDraw("HighVoltage"); - - HPlot::PlotAdd('HVCurrent',$val[4],0); - HPlot::PlotAdd('HVCurrent',$val[26],1); - HPlot::PlotDraw("HVCurrent"); - - - my $shorttext = sprintf("%.1f/%.3f",$val[3],$val[4]); - my $longtext = sprintf("Pion 1: %.1f V / %.4fuA",$val[3],$val[4]); - my $state = QA::OK; - $state = QA::WARN if($val[3]<140); - $state = QA::WARN if($val[4] > 1.0); - $state = QA::FATAL if($val[4] > 5); - - QA::WriteQALog($flog, "pion", "HV", 30, - $state, 'Pion 0 HV', $shorttext, $longtext); - - $shorttext = sprintf("%.1f/%.3f",$val[25],$val[26]); - $longtext = sprintf("Pion 2: %.2f V / %.3fuA",$val[25],$val[26]); - $state = QA::OK; - $state = QA::WARN if($val[25]<140); - $state = QA::WARN if($val[26] > 1.5); - $state = QA::FATAL if($val[26] > 5); - - QA::WriteQALog($flog, "pion", "HVcurr", 30, - $state, 'Pion 1 HV', $shorttext, $longtext); - - $shorttext = sprintf("%.1f° / %.1f°", $val[47], $val[53]); - $longtext = sprintf("Pion 1: is %.1f°, soll %.1f°
Pion 2: is %.1f°, soll %.1f°", $val[47], $val[49], $val[53], $val[55]); - $state = QA::OK; - $state = QA::WARN if ($val[47] >-15 || $val[53] >- 15); - if ($val[50] != 1 || $val[56] != 1) { - $longtext = $longtext . sprintf("
--------- CHILLER OFFLINE ERROR ---------
Pion1: %s
Pion2: %s", \ - $val[50] != 1 ? "OFF" : "ON", $val[56] != 1 ? "OFF" : "ON"); - $state = QA::ERROR; - } - - QA::WriteQALog($flog, "pion", "cooling", 120, - $state, 'Pion Cool', $shorttext, $longtext); - } -} - - -# hades@lxhadeb06:/data01/tmp/scmon.log -# columns: -# TimeStamp 1 -# V I status -# HV-NE5 4 5 6 -# HV-HAD 26 27 28 -# Temp SetPoint Status -# Chiller-NE5 48 50 51 -# Chiller-HAD 54 56 57 - diff --git a/hmon/permanent/hmon_plot_template.pl b/hmon/permanent/hmon_plot_template.pl deleted file mode 100644 index 1d3d6c8..0000000 --- a/hmon/permanent/hmon_plot_template.pl +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl - -use warnings; -#use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use List::Util 'max'; -use QA; -use HPlot; -use Hmon; -my $flog = Hmon::OpenLogfile(); -my $fqa = QA::OpenQAFile(); - - -my @str; - -my $store = {}; -my $laststore = {}; -my $values = {}; -my $color = {}; -my $raw = {}; -my $val; -my ($max,$min,$avg,$mean); - - - -my $plot = (); -$plot->{name} = "PionLvCurrent"; -$plot->{file} = "files/PionLvCurrent"; -$plot->{entries} = 500; -$plot->{curves} = 2; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = "Pion0"; -$plot->{titles}->[1] = "Pion1"; -$plot->{xlabel} = "Seconds"; -$plot->{ylabel} = "mA"; -$plot->{sizex} = 630; -$plot->{sizey} = 220; -HPlot::PlotInit($plot); - - - - $str = Hmon::MakeTitle(9, 10, "Pion Low Voltage"); - $str .= qq@
\n@; - $str .= qq@\n@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("PionLV",$str); - - -while (1) { - - - - #Hmon::WriteLog($flog, "Pion LV","Test"); - - my $curr0 = 4; - my $curr1 = 5.11; - - HPlot::PlotAdd("PionLvCurrent",$curr0,0); - HPlot::PlotAdd("PionLvCurrent",$curr1,1); - HPlot::PlotDraw("PionLvCurrent"); - - - - - my $qastate = QA::GetQAState('below', max($curr0,$curr1), @QA::PionLvCurrLimits); - my $str = sprintf("%i/%i", $curr0, $curr1); - QA::WriteQALog($fqa,"pion","LV", 10, $qastate, "LV Current", $str, - "Current on LV line for Pion FEE: " . $str); - - sleep(1); -} diff --git a/hmon/permanent/hmon_spill.pl b/hmon/permanent/hmon_spill.pl deleted file mode 100644 index 99ef33e..0000000 --- a/hmon/permanent/hmon_spill.pl +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; -use Data::Dumper; -use Hmon; -use QA; -use HADES::TrbNet; - -my $lastspill = 0; -my $evtrate = 0; -my $events = 0; -my $spilllength = 0; -my $lastres = 0; -my $outofspill = 0; -my @spills; -my $spillavgshort = 0; -my $spillavglong = 0; - -my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; - -trb_init_ports() or die trb_strerror(); - -while (1) { - my $trbneterr = 0; - my $rh_result = trb_register_read(QA::CTSAddress, 0xa002) or $trbneterr = 1; #sleep 5 and next; - $lastspill = $outofspill; - $outofspill = ($rh_result->{QA::CTSAddress} || 0) & 0x10; - $spilllength++ ; #if($outofspill); - $rh_result = trb_register_read(0x3000, 0x01) or $trbneterr = 1; #sleep 5 and next; - # 0x3000 => a reliable guy to ask about rates - - if($trbneterr == 0) { - my $res = $rh_result->{0x3000} & 0xffff; - $evtrate = $res >= $lastres ? $res - $lastres : ($res + 2**16) - $lastres; - $events += $evtrate; - - # When end of spill is detected... - my $qastate; - my $qashort; - my $qalong; - if ($outofspill && !$lastspill) { - push(@spills, $events); - shift(@spills) if scalar @spills > 50; - - $spillavglong = 0; - $spillavglong += $_ for @spills; - $spillavglong /= scalar @spills; - - $spillavgshort = 0; - for ( my $i=-1; $i>=-10; $i--) { - $spillavgshort += $spills[$i] || 0; - } - $spillavgshort /= (scalar @spills < 10)?(scalar @spills):10; - - $qashort = QA::SciNotation($events)." (".$spilllength."s)"; - $qastate = QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill); - $qalong = sprintf("current spill: %s - 10-spill avg. %s - 50-spill avg. %s - Spill length %is", - QA::SciNotation($events), - QA::SciNotation($spillavgshort), - QA::SciNotation($spillavglong), - $spilllength); - QA::WriteQALog($fqa,"trg", "spill", 20, $qastate, "Spill Sum", - $qashort, $qalong); - $events = 0; - $spilllength = 0; - } - - $qashort = sprintf(" %i ", $evtrate); - $qastate = QA::OK; - $qastate = QA::WARN_2 if $evtrate <= 1; - $qalong = sprintf("current: %i", $evtrate); - QA::WriteQALog($fqa, "main", "rate", 5, $qastate, "Current Rate", - $qashort, $qalong); - - $lastres = $res; - sleep(1); - } - else { - QA::WriteQALog($fqa, "main", "rate", 30, QA::ERROR, "Current Rate", "N/A", "N/A"); - QA::WriteQALog($fqa,"trg", "spill", 30, QA::ERROR, "Spill Sum","N/A", "N/A"); - $events = 0; - $spilllength = 0; - sleep(10); - } -} diff --git a/hmon/permanent/hmon_starthv.pl b/hmon/permanent/hmon_starthv.pl deleted file mode 100644 index f762ce0..0000000 --- a/hmon/permanent/hmon_starthv.pl +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use POSIX qw(strftime); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use List::Util qw/min max/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; -use HPlot; - -my $flog = QA::OpenQAFile(); - -my $timer=0; -my $store; - -Perl2Epics::Connect("StartV","HAD:DIAMOND:HV:START:positive:vmon"); -Perl2Epics::Connect("VetoV" ,"HAD:DIAMOND:HV:VETO:negative:vmon" ); -Perl2Epics::Connect("StartI","HAD:DIAMOND:HV:START:positive:imon"); -Perl2Epics::Connect("VetoI" ,"HAD:DIAMOND:HV:VETO:negative:imon" ); -print "Connected.\n"; - - - - - -while(1) { - - my $data = Perl2Epics::GetAll(); -# print Dumper $data; -# print($data->{"StartI"}->{val}." ".$data->{"StartV"}->{val}." ".$data->{"VetoI"}->{val}." ".$data->{"VetoV"}->{val}."\n"); - push(@{$store->{si}},$data->{"StartI"}->{val}); - push(@{$store->{vi}},$data->{"VetoI"}->{val}); - shift(@{$store->{si}}) if scalar @{$store->{si}} > 30; - shift(@{$store->{vi}}) if scalar @{$store->{vi}} > 30; - - my $sv = $data->{"StartV"}->{val}; - my $vv = $data->{"VetoV"}->{val}; - - my $simin = min(@{$store->{si}}); - my $simax = max(@{$store->{si}}); - my $vimin = min(@{$store->{vi}}); - my $vimax = max(@{$store->{vi}}); - - if($timer++ % 10 == 0) { - - - my $str = Hmon::MakeTitle(2, 3, "Start HV", 1, ""); - - $str .= "
Start V".QA::SciNotation($sv)." V"; - $str .= "
Start I".ceil($simin*1000).' - '.ceil($simax*1000)." nA"; - $str .= "
Veto V".QA::SciNotation($vv)." V"; - $str .= "
Veto I".ceil($vimin*1000).' - '.ceil($vimax*1000)." nA"; - - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("StartHV", $str); - } - - my $value = QA::SciNotation($sv)." / ".QA::SciNotation($vv); - my $qastate = QA::OK; - $qastate = QA::WARN_2 if $sv < 160 || $vv < 100; - my $longtext = " Start: ".QA::SciNotation($sv)." V / ".ceil($simin*1000).' - '.ceil($simax*1000)." nA
"; - $longtext .=" Veto: ".QA::SciNotation($vv)." V / ".ceil($vimin*1000).' - '.ceil($vimax*1000)." nA"; - - QA::WriteQALog($flog,"hv2","starthv",30,$qastate,"Start HV",$value,$longtext); - - - - - sleep(1); - } diff --git a/hmon/permanent/hmon_starthv_2022.pl b/hmon/permanent/hmon_starthv_2022.pl deleted file mode 100644 index f762ce0..0000000 --- a/hmon/permanent/hmon_starthv_2022.pl +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use POSIX qw(strftime); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use List::Util qw/min max/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; -use HPlot; - -my $flog = QA::OpenQAFile(); - -my $timer=0; -my $store; - -Perl2Epics::Connect("StartV","HAD:DIAMOND:HV:START:positive:vmon"); -Perl2Epics::Connect("VetoV" ,"HAD:DIAMOND:HV:VETO:negative:vmon" ); -Perl2Epics::Connect("StartI","HAD:DIAMOND:HV:START:positive:imon"); -Perl2Epics::Connect("VetoI" ,"HAD:DIAMOND:HV:VETO:negative:imon" ); -print "Connected.\n"; - - - - - -while(1) { - - my $data = Perl2Epics::GetAll(); -# print Dumper $data; -# print($data->{"StartI"}->{val}." ".$data->{"StartV"}->{val}." ".$data->{"VetoI"}->{val}." ".$data->{"VetoV"}->{val}."\n"); - push(@{$store->{si}},$data->{"StartI"}->{val}); - push(@{$store->{vi}},$data->{"VetoI"}->{val}); - shift(@{$store->{si}}) if scalar @{$store->{si}} > 30; - shift(@{$store->{vi}}) if scalar @{$store->{vi}} > 30; - - my $sv = $data->{"StartV"}->{val}; - my $vv = $data->{"VetoV"}->{val}; - - my $simin = min(@{$store->{si}}); - my $simax = max(@{$store->{si}}); - my $vimin = min(@{$store->{vi}}); - my $vimax = max(@{$store->{vi}}); - - if($timer++ % 10 == 0) { - - - my $str = Hmon::MakeTitle(2, 3, "Start HV", 1, ""); - - $str .= "
Start V".QA::SciNotation($sv)." V"; - $str .= "
Start I".ceil($simin*1000).' - '.ceil($simax*1000)." nA"; - $str .= "
Veto V".QA::SciNotation($vv)." V"; - $str .= "
Veto I".ceil($vimin*1000).' - '.ceil($vimax*1000)." nA"; - - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("StartHV", $str); - } - - my $value = QA::SciNotation($sv)." / ".QA::SciNotation($vv); - my $qastate = QA::OK; - $qastate = QA::WARN_2 if $sv < 160 || $vv < 100; - my $longtext = " Start: ".QA::SciNotation($sv)." V / ".ceil($simin*1000).' - '.ceil($simax*1000)." nA
"; - $longtext .=" Veto: ".QA::SciNotation($vv)." V / ".ceil($vimin*1000).' - '.ceil($vimax*1000)." nA"; - - QA::WriteQALog($flog,"hv2","starthv",30,$qastate,"Start HV",$value,$longtext); - - - - - sleep(1); - } diff --git a/hmon/permanent/hmon_tofhv_wip.pl b/hmon/permanent/hmon_tofhv_wip.pl deleted file mode 100644 index 9650392..0000000 --- a/hmon/permanent/hmon_tofhv_wip.pl +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use POSIX qw(strftime); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use List::Util qw/min max/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; -use HPlot; - -my $flog = QA::OpenQAFile(); -my @colors = ("#333333","#00ff00","#ff0000","#0000ff","#dddd00","#dd00dd"); - - -# -# for my $i (0..5) { -# HPlot::PlotInit( { -# name => "EcalCurr$i", -# file => "files/EcalCurr$i", -# entries => 168, -# type => HPlot::TYPE_BARGRAPH, -# output => HPlot::OUT_PNG, -# titles => [sprintf("Sector %i - current",$i+1)], -# xlabel => "Module number", -# ylabel => "uA", -# sizex => 430, -# sizey => 190, -# xmin => 0, -# xmax => 168, -# ymin => 0, -# ymax => 1600, -# curves => 1, -# countup => 1, -# xscale => 1, -# nokey => 0, -# buffer => 1, -# bargap => 0.4, -# curvewidth => 1,}); -# } -# -# for my $i (0..5) { -# HPlot::PlotInit( { -# name => "EcalVolt$i", -# file => "files/EcalVolt$i", -# entries => 168, -# type => HPlot::TYPE_BARGRAPH, -# output => HPlot::OUT_PNG, -# titles => [sprintf("Sector %i - voltage",$i+1)], -# xlabel => "Module number", -# ylabel => "V", -# sizex => 430, -# sizey => 190, -# xmin => 0, -# xmax => 168, -# ymin => 0, -# ymax => 2500, -# curves => 1, -# countup => 1, -# xscale => 1, -# nokey => 0, -# buffer => 1, -# bargap => 0.4, -# curvewidth => 1,}); -# } -# -# -# for my $i (0..5) { -# HPlot::PlotInit( { -# name => "EcalVMap$i", -# file => "files/EcalVMap$i", -# title => "", -# entries => 17, -# curves => 15, -# type => HPlot::TYPE_HEATMAP, -# output => HPlot::OUT_PNG, -# zlabel => "Voltage [V]", -# titles => ["Voltage [V]"], -# sizex => 255, -# sizey => 200, -# nokey => 0, -# buffer => 1, -# xmin => -0.5, -# xmax => 16.5, -# ymin => -0.5, -# ymax => 14.5, -# cbmax => "1.1<*<2500", -# cbmin => "0.1<*<0.9", -# noinit => 0, -# showvalues => 0, }); -# } -# -# for my $i (0..5) { -# HPlot::PlotInit( { -# name => "EcalCMap$i", -# file => "files/EcalCMap$i", -# title => "", -# entries => 17, -# curves => 15, -# type => HPlot::TYPE_HEATMAP, -# output => HPlot::OUT_PNG, -# zlabel => "Current [uA]", -# titles => ["Current [uA]"], -# sizex => 255, -# sizey => 200, -# nokey => 0, -# buffer => 1, -# xmin => -0.5, -# xmax => 16.5, -# ymin => -0.5, -# ymax => 14.5, -# cbmax => "1.1<*<2000", -# cbmin => "0.1<*<0.9", -# noinit => 0, -# showvalues => 0, }); -# } -# - -my $timer=0; -my $str = ""; -my $s=""; - -#for(my $i = 1; $i <=6; $i++) { -# for(my $j = 1; $j<=2; $j++) { -# my $cnt = (($i-1)*2)+$j-1; -# $s = sprintf("HAD:RPC:HV:S%i:L%i:imon",$i,$j); -# Perl2Epics::Connect("I$cnt",$s); -# $s = sprintf("HAD:RPC:HV:S%i:L%i:vmon",$i,$j); -# Perl2Epics::Connect("U$cnt",$s); -# } -#} - - -print "Connected.\n"; - -#OVERCURRENT variables -my $overcurrent_flag = 0; -my $OVERCURRENT_YELLOW = 200; -my $OVERCURRENT_RED = 300; - -my $OVERCURRENT_period = 3; -my $overcurrent_alarm_flag = 0; -my $current_average = 0; -my $current_sum = 0; - -my $errortimer = 0; - -# my @mod_tab=(0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, 0, 0, 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, 42, 0, 0, 0, 0, 0, 0, 0, 0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 0, 0, 0, 0, 0, 0, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 0, 0, 0, 0, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 0, 0, 0, 0, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 0, 0, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 0, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163); -# -# my @x_tab=(10, 9, 8, 7, 6, 10, 9, 8, 7, 6, 11, 10, 9, 8, 7, 6, 5, 11, 10, 9, 8, 7, 6, 5, 12, 11, 10, 9, 8, 7, 6, 5, 4, 12, 11, 10, 9, 8, 7, 6, 5, 4, 12, 11, 10, 9, 8, 7, 6, 5, 4, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); -# -# my @y_tab=(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14); - - -my @i_integrated=(0,0,0,0,0,0,0,0,0,0,0,0); -my $ChnlsOn = 0; - -while(1) { - my $min_v = -1E5; - my $max_v = 1E5; - my $min_i = -1E5; - my $max_i = 1E5; - # my $data = Perl2Epics::GetAll(); - - - # for(my $i = 0; $i <=5; $i++) { - # for(my $j = 0; $j<=1; $j++) { - # my $cnt = ($i*2)+$j; - # $i_integrated[$cnt]=$i_integrated[$cnt]+$data->{"I$cnt"}->{val}; - # } - # } - - -# $str = Hmon::MakeTitle(11, 18, "ECAL HV - Current", 1, ""); -# $str .= ""; -# -# $str .= "
"; -# -# if ($ChnlsOn == 0) { -# $str .= "

Channels off ("; -# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn < 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn > 652) { -# $str .= "

Channels on ("; -# } else { -# $str .= "

Channels on ("; -# } -# $str .= "$ChnlsOn"; -# $str .= "/652)

"; -# -# $str .= "
\n\n"; -# -# $str .= qq@
\n@; -# $str .= qq@\n@; -# $str .= qq@
\n@; -# $str .= qq@\n@; -# $str .= qq@
\n@; -# $str .= qq@
\n@; -# -# -# $str .= Hmon::MakeFooter(); -# $str .= ""; -# $str .= ""; -# Hmon::WriteFile("EcalHVCurr", $str); -# -# -# -# $str = Hmon::MakeTitle(11, 18, "ECAL HV - Voltage", 1, ""); -# $str .= ""; -# -# $str .= "
"; -# -# if ($ChnlsOn == 0) { -# $str .= "

Channels off ("; -# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn < 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn > 652) { -# $str .= "

Channels on ("; -# } else { -# $str .= "

Channels on ("; -# } -# $str .= "$ChnlsOn"; -# $str .= "/652)

"; -# -# $str .= "
\n\n"; -# -# -# $str .= qq@
\n@; -# $str .= qq@\n@; -# $str .= qq@
\n@; -# $str .= qq@\n@; -# $str .= qq@
\n@; -# $str .= qq@
\n@; -# -# -# $str .= Hmon::MakeFooter(); -# $str .= ""; -# $str .= ""; -# Hmon::WriteFile("EcalHVVolt", $str); -# -# -# -# -# -# $str = Hmon::MakeTitle(10, 13, "ECAL HV - Voltage Map", 1, ""); -# $str .= ""; -# -# $str .= "
"; -# -# if ($ChnlsOn == 0) { -# $str .= "

Channels off ("; -# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn < 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn > 652) { -# $str .= "

Channels on ("; -# } else { -# $str .= "

Channels on ("; -# } -# $str .= "$ChnlsOn"; -# $str .= "/652)

"; -# -# $str .= "
\n\n\n\n\n\n\n"; -# -# -# $str .= qq@\n@; -# $str .= qq@\n@; -# $str .= qq@\n\n@; -# -# $str .= "\n\n\n\n\n"; -# -# $str .= qq@\n@; -# $str .= qq@\n@; -# $str .= qq@\n\n
Sector 1Sector 2Sector 3
Sector 4Sector 5Sector 6
\n@; -# -# -# $str .= Hmon::MakeFooter(); -# $str .= ""; -# $str .= ""; -# Hmon::WriteFile("EcalHVVMap", $str); -# -# -# -# $str = Hmon::MakeTitle(10, 13, "ECAL HV - Current Map", 1, ""); -# $str .= ""; -# -# $str .= "
"; -# -# if ($ChnlsOn == 0) { -# $str .= "

Channels off ("; -# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn < 642) { -# $str .= "

Channels on ("; -# } elsif ($ChnlsOn > 652) { -# $str .= "

Channels on ("; -# } else { -# $str .= "

Channels on ("; -# } -# $str .= "$ChnlsOn"; -# $str .= "/652)

"; -# -# $str .= "
\n\n\n\n\n\n\n"; -# -# -# $str .= qq@\n@; -# $str .= qq@\n@; -# $str .= qq@\n\n@; -# -# $str .= "\n\n\n\n\n"; -# -# $str .= qq@\n@; -# $str .= qq@\n@; -# $str .= qq@\n\n
Sector 1Sector 2Sector 3
Sector 4Sector 5Sector 6
\n@; -# -# -# $str .= Hmon::MakeFooter(); -# $str .= ""; -# $str .= ""; -# Hmon::WriteFile("EcalHVCMap", $str); - - $timer++; - - my $qastate = QA::NOTE; - my $value = sprintf("Work in progress"); - my $longtext = sprintf("Work in progress"); - - #$qastate = QA::GetQAState('above', 12, @QA::RpcHvLimits); - #if ($ChnlsOn == 0){ - #$qastate = QA::NOTE;} - - - $str = ""; - if($timer%8 == 0) { - QA::WriteQALog($flog,"misc","tofhv",30,$qastate,"TOF HV",$value,$longtext); - - - } - - - -# for (my $i = 0; $i <= 5;$i++){ -# if($i==1 or $i==2 or $i==4 or $i==5){ -# for (my $j = 0; $j<=167; $j++) { -# my $cnt = ($i*168)+$j; -# HPlot::PlotAdd("EcalCurr$i",$data->{"I$cnt"}->{val}||-1,); -# HPlot::PlotAdd("EcalVolt$i",$data->{"U$cnt"}->{val}||-1,); -# } -# -# for(my $j=254;$j>=0;$j--){ -# my $cnt =-1; -# if($mod_tab[$j]!=0){ -# $cnt=($i*168)+$mod_tab[$j]-1; -# HPlot::PlotAdd("EcalVMap$i",$data->{"U$cnt"}->{val}||-1,$y_tab[$j],$x_tab[$mod_tab[$j]-1]); -# HPlot::PlotAdd("EcalCMap$i",$data->{"I$cnt"}->{val}||-1,$y_tab[$j],$x_tab[$mod_tab[$j]-1]); -# } -# if($mod_tab[$j]==0){ -# HPlot::PlotAdd("EcalVMap$i",$data->{"U$cnt"}->{val}||'NaN',$y_tab[$j],$x_tab[$mod_tab[$j]-1]); -# HPlot::PlotAdd("EcalCMap$i",$data->{"I$cnt"}->{val}||'NaN',$y_tab[$j],$x_tab[$mod_tab[$j]-1]); -# } -# } -# -# -# } -# } -# -# -# #print Dumper $data; -# if($timer%8 == 0) { -# for (my $i = 0; $i <= 5;$i++){ -# HPlot::PlotDraw("EcalCurr$i"); -# HPlot::PlotDraw("EcalVolt$i"); -# HPlot::PlotDraw("EcalVMap$i"); -# HPlot::PlotDraw("EcalCMap$i"); -# } -# } - usleep(250000); - } diff --git a/hmon/stopall.sh b/hmon/stopall.sh index 7081a38..b73ea5a 100755 --- a/hmon/stopall.sh +++ b/hmon/stopall.sh @@ -6,7 +6,7 @@ cd permanent killall hmon*.pl 2>/dev/null 1>/dev/null cd ../ -pkill -f "sshfs -o allow_other hadaq@hades66:/home/hades-qa/online/5.34.38/pics" +pkill -f "sshfs -o allow_other hadaq@hadesp66:/home/hades-qa/online/5.34.38/pics" pkill -f "sshfs -o allow_other hadaq@hadesp63:/home/hadaq/local/tdcmon/dabc/cal" diff --git a/hmon/test.pl b/hmon/test.pl deleted file mode 100755 index 74beb46..0000000 --- a/hmon/test.pl +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/perl -w - -use warnings; -use strict; -use Data::Dumper; -use Data::TreeDumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -use Time::HiRes qw(usleep); -use List::Util qw[min max]; - - -HPlot::PlotInit({ - name => "StartPositionWK", - file => "files/StartPositionWK", - entries => 200, - type => HPlot::TYPE_HISTORY, - output => HPlot::OUT_PNG, - titles => ["X position","Y position","Xrms","Yrms"], - xlabel => "Seconds", - ylabel => "Strips", - sizex => 970, - sizey => 350, - ymin => "0", - ymax => "10", - curves => 4, - xscale => 10, - buffer => 1, - }); - - -my $str = Hmon::MakeTitle(13, 8, "Start Position",0); -$str .= qq@\n@; -$str .= Hmon::MakeFooter(); -Hmon::WriteFile("StartPositionWK",$str); - - -HPlot::PlotDraw('StartPositionnWK'); - -exit; - - -foreach (1..10) { - foreach (1) { - #HPlot::PlotAdd("StartPositionWK",1.2,0); - #exit; - #HPlot::PlotAdd("StartPositionWK",2.2,1); - #HPlot::PlotAdd("StartPositionWK",3.5,2); - #HPlot::PlotAdd("StartPositionWK",4.6,3); - } - - HPlot::PlotDraw('StartPositionWK'); - print "draw done\n"; - sleep 2; - print "test \n"; - sleep 1; -} - diff --git a/hmon/test/get.json b/hmon/test/get.json deleted file mode 100644 index 8698d0f..0000000 --- a/hmon/test/get.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "_name" : "DataRate", - "_history" : 100, - "_kind" : "rate", - "time" : "2018-09-27T06:18:46.818Z", - "units" : "MB", - "value" : 0.595253 -} \ No newline at end of file diff --git a/hmon/test/hmon_eb_rate_epics.pl b/hmon/test/hmon_eb_rate_epics.pl deleted file mode 100755 index d4f7ff6..0000000 --- a/hmon/test/hmon_eb_rate_epics.pl +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/perl -w - -use warnings; -use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use Data::Dumper; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; - -my $SLEEP_TIME = .5; # in seconds -my $NUM_AVERAGES = 5; -my $offset = 2; -my $last_rate_endp = 0; -my $opt_addr = 3; #CTS -my $error_ctr = 0; -my $error_limit = 3; - -trb_init_ports() or die trb_strerror(); - -my $flog = QA::OpenQAFile(); - -for (my $i = 0; $i <= 15; $i++) { - my $s = sprintf("HAD:eb%02i", $i + 1); - Perl2Epics::Connect("ebrate$i", $s.":evtCRate"); - Perl2Epics::Connect("ebstat$i", $s.":status"); -} -#Perl2Epics::Connect("totalEvts","HAD:eb:totalEvtsComp"); - -while (1) { - - # 0x03 => CTS - # my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) - # or sleep 5 and next; - # my $sentmask = ($rh_result->{QA::CTSAddress} || 0) & 0xFFFF; - - # 0x3000 => ?? - my $actmask = 0; - my $evtrate_eb_tot = 0; - my $evtrate_endp_tot = 0; - my $ctr = 0; - my $starttime = time(); - my $data; - my $last_spill_on = 0; - my $spill_on = 0; - my $use_spill_detect = 0; - - while (($ctr < ($NUM_AVERAGES + $offset)) && (!($last_spill_on == 1 && $spill_on == 0) || $use_spill_detect == 0)) { - my $rh_result = trb_register_read(0x2, 0x1) or sleep 5 and next; - my $rate_endp = ($rh_result->{0x2} & 0xffff); - if ($ctr < $NUM_AVERAGES) { - $evtrate_endp_tot += - $rate_endp >= $last_rate_endp ? $rate_endp - $last_rate_endp - : ($rate_endp + 2**16) - $last_rate_endp; - } - if ($ctr >= $offset) { - $data = Perl2Epics::GetAll(); - my $i = 0; - for ($i = 0; $i <= 15; $i++) { - $evtrate_eb_tot += $data->{"ebrate$i"}->{val} || 0; - if ($data->{"ebstat$i"}->{val}) { - $actmask |= (1 << $i); - } - } - } - $last_rate_endp = $rate_endp; - - ###cancel integration when spill break is detected - my @result = trb_register_read_c($opt_addr, 0xa002 ); - $last_spill_on = $spill_on; - $spill_on = !(($result[1] & 0x10) >> 4); - - usleep($SLEEP_TIME * 1e6); - $ctr++; - } - - my $tottime = (time() - $starttime) * $NUM_AVERAGES/($NUM_AVERAGES+$offset); - my $rate_eb = $evtrate_eb_tot / ($ctr-$offset); - my $rate_eb_str = sprintf "%.1f", $rate_eb; - my $rate_endp = $evtrate_endp_tot / $tottime; - my $rate_endp_str = sprintf "%.1f", $rate_endp; - my $diff = $rate_eb - $rate_endp; - my $diff_str = sprintf "%d", $diff; - my $diff_p = $diff / ($rate_endp || 1) * 100; - my $diff_p_str = sprintf "%d", $diff_p; - if (! $rate_endp) { - $evtrate_endp_tot, $diff_p_str = "---"; - } - - my $limit = $diff / sqrt($rate_endp || 1); - my $status = QA::GetQAState('inside', $limit, @QA::EBDeltaRateLimits); - $status = QA::OK if $rate_endp < 50; - - if (! $actmask) { - $status = QA::WARN_2; - $diff_p_str = "---"; - $rate_eb_str = "EB is stopped"; - } - if (($status >= QA::ERROR) && ($error_ctr < $error_limit)) { - $error_ctr++; - $status = QA::OK; - } else { - $error_ctr = 0; - } - $status = QA::ERROR if ($diff > 2000 || $diff < -2000); - - my $title = "ΔRate EB-CTS"; - my $shorttext = "$diff_str ($diff_p_str%)"; - my $longtext = "CurrentRate CTS: $rate_endp_str - Rate Eventbuilders: $rate_eb_str - ΔRate: $diff_str ($diff_p_str%)"; - $longtext = " $longtext ErrorCtr: $error_ctr" if ($error_ctr > 0); - QA::WriteQALog($flog, "eb", "rate", $SLEEP_TIME * $ctr * 2, - $status, $title, $shorttext, $longtext); - if ($status >= QA::ERROR) { - my $speakermsg = "CTS and Eventbuilder rate differ by "; - my $pmesg = sprintf "%d", abs($diff_p); - Hmon::Speak('dataloss', "Eventbuilder and CTS rate differ by $pmesg per cent") - } -} diff --git a/hmon/test/hmon_eb_rate_json.pl b/hmon/test/hmon_eb_rate_json.pl deleted file mode 100755 index 9a5f742..0000000 --- a/hmon/test/hmon_eb_rate_json.pl +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/perl -w - -# changed from epics to web/json readout of eventbuilder rates 28-sep-2018 JAM - -use warnings; -use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use Data::Dumper; -use Hmon; -use QA; -use LWP::Simple; -use JSON qw( decode_json ); - -use HADES::TrbNet; - -my $SLEEP_TIME = .5; # in seconds -my $NUM_AVERAGES = 5; -my $offset = 2; -my $last_rate_endp = 0; -my $opt_addr = 3; #CTS -my $error_ctr = 0; -my $error_limit = 3; - -my $opt_debug =1; - -trb_init_ports() or die trb_strerror(); - -my $flog = QA::OpenQAFile(); - - -my $masterurl = 'http://lxhadeb07:8099/'; - -my $url_erate = $masterurl . 'Master/BNET/EventsRate/get.json?field="value"'; -my $url_builders = $masterurl . 'Master/BNET/Builders/get.json?field="value"'; - -while (1) { - - # 0x03 => CTS - # my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) - # or sleep 5 and next; - # my $sentmask = ($rh_result->{QA::CTSAddress} || 0) & 0xFFFF; - - # 0x3000 => ?? - my $actmask = 0; - my $evtrate_eb_tot = 0; - my $evtrate_endp_tot = 0; - my $ctr = 0; - my $starttime = time(); - my $data; - my $last_spill_on = 0; - my $spill_on = 0; - my $use_spill_detect = 0; - - while (($ctr < ($NUM_AVERAGES + $offset)) && (!($last_spill_on == 1 && $spill_on == 0) || $use_spill_detect == 0)) { - my $rh_result = trb_register_read(0x2, 0x1) or sleep 5 and next; - my $rate_endp = ($rh_result->{0x2} & 0xffff); - if ($ctr < $NUM_AVERAGES) { - $evtrate_endp_tot += - $rate_endp >= $last_rate_endp ? $rate_endp - $last_rate_endp - : ($rate_endp + 2**16) - $last_rate_endp; - } - if ($ctr >= $offset) { - # JAM2018: direct access to dabc http server instead of epics now: - $evtrate_eb_tot += get ($url_erate); - $evtrate_eb_tot += 0 unless defined $evtrate_eb_tot; - #print Dumper $evtrate_eb_tot; - my $builders = get ($url_builders); - #print Dumper $builders; - if (defined $builders) - { - my $builder_array = decode_json($builders); - $actmask = scalar @$builder_array; - # not exactly the bitmask, but this is not used here anyway JAM - } - - } - $last_rate_endp = $rate_endp; - - ###cancel integration when spill break is detected - my @result = trb_register_read_c($opt_addr, 0xa002 ); - $last_spill_on = $spill_on; - $spill_on = !(($result[1] & 0x10) >> 4); - - usleep($SLEEP_TIME * 1e6); - $ctr++; - } - - my $tottime = (time() - $starttime) * $NUM_AVERAGES/($NUM_AVERAGES+$offset); - my $rate_eb = $evtrate_eb_tot / ($ctr-$offset); - my $rate_eb_str = sprintf "%.1f", $rate_eb; - my $rate_endp = $evtrate_endp_tot / $tottime; - my $rate_endp_str = sprintf "%.1f", $rate_endp; - my $diff = $rate_eb - $rate_endp; - my $diff_str = sprintf "%d", $diff; - my $diff_p = $diff / ($rate_endp || 1) * 100; - my $diff_p_str = sprintf "%d", $diff_p; - if (! $rate_endp) { - $evtrate_endp_tot, $diff_p_str = "---"; - } - - my $limit = $diff / sqrt($rate_endp || 1); - my $status = QA::GetQAState('inside', $limit, @QA::EBDeltaRateLimits); - $status = QA::OK if $rate_endp < 50; - - if (! $actmask) { - $status = QA::WARN_2; - $diff_p_str = "---"; - $rate_eb_str = "EB is stopped"; - } - if (($status >= QA::ERROR) && ($error_ctr < $error_limit)) { - $error_ctr++; - $status = QA::OK; - } else { - $error_ctr = 0; - } - $status = QA::ERROR if ($diff > 2000 || $diff < -2000); - - my $title = "ΔRate EB-CTS"; - my $shorttext = "$diff_str ($diff_p_str%)"; - my $longtext = "CurrentRate CTS: $rate_endp_str - Rate Eventbuilders: $rate_eb_str - ΔRate: $diff_str ($diff_p_str%)"; - $longtext = " $longtext ErrorCtr: $error_ctr" if ($error_ctr > 0); - QA::WriteQALog($flog, "eb", "rate", $SLEEP_TIME * $ctr * 2, - $status, $title, $shorttext, $longtext) unless $opt_debug>0; - print "status:$status title:$title short:$shorttext long: $longtext \n" unless $opt_debug<1; - - if ($status >= QA::ERROR) { - my $speakermsg = "CTS and Eventbuilder rate differ by "; - my $pmesg = sprintf "%d", abs($diff_p); - Hmon::Speak('dataloss', "Eventbuilder and CTS rate differ by $pmesg per cent") unless $opt_debug>0; - print "dataloss: Eventbuilder and CTS rate differ by $pmesg per cent\n" unless $opt_debug<1; - } -} diff --git a/hmon/test/hmon_eb_run_epics.pl b/hmon/test/hmon_eb_run_epics.pl deleted file mode 100755 index d803448..0000000 --- a/hmon/test/hmon_eb_run_epics.pl +++ /dev/null @@ -1,273 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; - -my $store = {}; -my @time; -my @state; -my @rate; -my @disc; -my $mismatchfound_sa = -10; -my $mismatchfound_sr = -10; -my $events = 0; -my @evtrates = (0,0,0); -my @ebrates = (); -my ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = (0,0,0); -my ($cnterrtype9,$cnterrtypeE) = (50,50); -my $lasttotalbytes = 21; -my @ebrecvhist; -my @byteshist; - -my $numebs = 15; - # JAM2018: eb number 16 is deactivated for BNET setup - -sub cntbits32 { - return (unpack('%32b*', pack('i',$_[0]))); - } - -my $connect_status = &trb_init_ports(); -if(!$connect_status) { - die("could not connect to trbnetd"); -} - -my $fqa = QA::OpenQAFile(); - -for(my $i = 0; $i<$numebs; $i++) { - my $s = sprintf("HAD:eb%02i",$i+1); - Perl2Epics::Connect("ebstat$i",$s.":status"); - Perl2Epics::Connect("ebrate$i",$s.":evtCRate"); - Perl2Epics::Connect("ebdisc$i",$s.":evtDRate"); - Perl2Epics::Connect("ebbyte$i",$s.":byteWRate"); - Perl2Epics::Connect("eb$i"."type1", $s.":trigtype:1"); - Perl2Epics::Connect("eb$i"."type9", $s.":trigtype:9"); - Perl2Epics::Connect("eb$i"."typeE", $s.":trigtype:E"); - } -Perl2Epics::Connect("totalEvts","HAD:eb:totalEvtsComp"); -Perl2Epics::Connect("prefix","HAD:eb01:prefix",'DBR_TIME_STRING'); - -my $spilllength = 0; - -while(1) { - my $totalrate = 0; - my $totalbytes = 0; - my $totaldiscarded = 0; - my $ioc = 0; - my $actmask = 0; - my $recvmask = 0; - my $qastate = QA::OK; - my $qamsg = ""; - my $evtrate = 0; - my $qastatedisc = QA::OK; - my $qamsgdisc = ""; - my $evtavgspill; - my $ebavgbytes; - my $ebavgrate = 0; - my $trbneterr = 0; - my $sumtype1 = 0; - my $sumtype9 = 0; - my $sumtypeE = 0; - my ($ratetype1,$ratetype9,$ratetypeE) = (0,0,0); - - # 0x03 => CTS - my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) or $trbneterr = 1; # or sleep 5 and next; - my $sentmask = ($rh_result->{QA::CTSAddress} || 0) & 0xFFFF; - - - # 0x3000 => ?? - #$rh_result = trb_register_read(0x3001, 0x1) or $trbneterr = 1; - # my $res = ($rh_result->{0x3001} || 0) & 0xFFFF; - - # JAM2017: try to check rate with tof if rich is not up: - $rh_result = trb_register_read(0x4c00, 0x1) or $trbneterr = 1; - my $res = ($rh_result->{0x4c00} || 0) & 0xFFFF; - - - $evtrate = $res - ($events || $res); - $evtrate += 2**16 if $evtrate < 0; - $events = $res; - pop(@evtrates) if scalar @evtrates >= $QA::AcceleratorCycle * 2; - unshift(@evtrates,$evtrate); - - $evtavgspill += $_ for @evtrates; - $evtavgspill /= scalar @evtrates; - - my $data = Perl2Epics::GetAll(); - for(my $i = 0; $i<$numebs; $i++) { - - $totalrate += $data->{"ebrate$i"}->{val} || 0; - $totaldiscarded += $data->{"ebdisc$i"}->{val} || 0; - $totalbytes += $data->{"ebbyte$i"}->{val} || 0; - - $sumtype1 += $data->{"eb$i"."type1"}->{val} || 0; - $sumtype9 += $data->{"eb$i"."type9"}->{val} || 0; - $sumtypeE += $data->{"eb$i"."typeE"}->{val} || 0; - - if(($data->{"ebdisc$i"}->{val} || 0) > 5) { - $qamsgdisc .= " - " unless $qamsgdisc eq ""; - $qamsgdisc .= "EB".($i+1)." ".$data->{"ebdisc$i"}->{val}." events"; - } - #print "Perl2Epics::GetAll() delivers ebstat for index $i : $data->{\"ebstat$i\"}->{val} \n"; - if ($data->{"ebstat$i"}->{val}) { - $actmask |= (1<<$i); - if ($data->{"ebrate$i"}->{val} > 0) { - $recvmask |= (1<<$i); - } - } - } - pop(@ebrates) if scalar @ebrates >= $QA::AcceleratorCycle * 2; - unshift(@ebrates,$totalrate); - $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<$numebs;$i++) { - $mismatch_sr |= (1<<$i) if ($sentmask & (1<<$i)) && !($recvmask & (1<<$i)); - $mismatch_sa |= (1<<$i) if ($sentmask & (1<<$i)) && !($actmask & (1<<$i)); - } -# printf ("actmask: %08X, recvmask: %04X, sentmask: %04X, mismatch_sr: %04X, mismatch_sa: %04X\n", -# ,$actmask,$recvmask,$sentmask,$mismatch_sr,$mismatch_sa); - -#Mismatch between selected EB in CTS and EB receiving data - if($mismatch_sr != 0) { - if ($evtrate > $act*32) { - my $str = ""; - for(my $i = 0; $i < $numebs; $i++) { - if ($mismatch_sr & (1<<$i)) { - $str .= ", " if $str ne ""; - $str .= $i+1; - } - } - if ($mismatchfound_sr++ >= 0 && $trbneterr == 0) { - system("logger -p local1.info -t DAQ 'EB Data is sent to EB $str but not received'") unless $mismatchfound_sr % 240; - $qastate = QA::ERROR; - $qamsg .= "Data is sent to EB $str but not received. "; - } - } - } - else { - $mismatchfound_sr = -10; - } - - -#Mismatch between selected EB in CTS and running EB processes - if($mismatch_sa != 0) { - my $str = ""; - for(my $i = 0; $i < $numebs; $i++) { - if ($mismatch_sa & (1<<$i)) { - $str .= ", " if $str ne ""; - $str .= $i+1; - } - } - if ($mismatchfound_sa++ >= 0 && $trbneterr == 0) { - system("logger -p local1.info -t DAQ 'EB Data is sent to not running EB $str'") unless $mismatchfound_sa % 60; - $qastate = QA::ERROR; - $qamsg .= "Data is sent to not running EB $str. "; - } - } - else { - $mismatchfound_sa = -10; - } - if($trbneterr) { - $qamsg .= "TrbNet Error - no information available."; - $qastate = QA::ERROR; - } - if ($qamsg eq "") {$qamsg = "No error found";} - if ($qastate == QA::OK) { - $qamsg .= sprintf(". Total rate: %i, 4-spill average: %i, total per EB: %i", - $totalrate,$ebavgrate,$totalrate/($recv || $totalrate || 1)); - } - - $qamsgdisc = "Discarded events: $totaldiscarded - ".$qamsgdisc; - - - my $qatitle = "#EB running"; - $qatitle = "EB stopped" if ($act == 0) ; - #print "$qatitle with act = $act , actmask = $actmask , sent = $sent , sentmask = $sentmask\n" ; - Hmon::Speak('ebrun',$qamsg) if $qastate > 60; - QA::WriteQALog($fqa, "eb", "run", 10, $qastate, $qatitle, - "act: $recv/$sent (".$data->{"prefix"}->{val}.")", $qamsg); -# if ($totalrate) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded/($totalrate || $totaldiscarded || 1),(0.01,0.05,0.1)); - if($totalrate < 500) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded || 1,(20,50,100)); - } -# } -# else { -# $qastatedisc = QA::NA; -# } - - my $totallost = $evtavgspill - $totalrate; - my $s = sprintf("%5d",$totaldiscarded); - QA::WriteQALog($fqa, "eb", "lostevt", 10, $qastatedisc, - "#Evt Discarded", $s, $qamsgdisc); - - $ratetype1 = $sumtype1 - $oldsumtype1 unless ($oldsumtype1 > $sumtype1); - $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; - if($oldsumtype1 > $sumtype1) { - $cnterrtype9 = 50; - $cnterrtypeE = 50; - } - - - $qastate = QA::OK; -# $qastate = QA::WARN if $ebavgrate <= 0; - 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)"; - } - if($totalbytes < 20 && $lasttotalbytes <20) { - $qastate = QA::WARN_2; - } - - 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"); - } - - ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = ($sumtype1,$sumtype9,$sumtypeE); - $lasttotalbytes = $totalbytes; - usleep(990000); - } diff --git a/hmon/test/hmon_eb_run_firsttryjson.pl b/hmon/test/hmon_eb_run_firsttryjson.pl deleted file mode 100755 index e51585a..0000000 --- a/hmon/test/hmon_eb_run_firsttryjson.pl +++ /dev/null @@ -1,421 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -#use Perl2Epics; -use LWP::Simple; -use JSON qw( decode_json ); - -use HADES::TrbNet; - -my $store = {}; -my @time; -my @state; -my @rate; -my @disc; -my $mismatchfound_sa = -10; -my $mismatchfound_sr = -10; -my $events = 0; -my @evtrates = (0,0,0); -my @ebrates = (); -my ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = (0,0,0); -my ($cnterrtype9,$cnterrtypeE) = (50,50); -my $lasttotalbytes = 21; -my @ebrecvhist; -my @byteshist; - -#my $numebs = 15; - # JAM2018: eb number 16 is deactivated for BNET setup - -sub cntbits32 { - return (unpack('%32b*', pack('i',$_[0]))); - } - -my $connect_status = &trb_init_ports(); -if(!$connect_status) { - die("could not connect to trbnetd"); -} - -my $fqa = QA::OpenQAFile(); - - - -# JAM 2018 here figure out corresponding json calles -my $masterurl = 'http://lxhadeb07:8099/'; - -my $url_drate = $masterurl . 'Master/BNET/DataRate/get.json?field="value"'; -my $url_erate = $masterurl . 'Master/BNET/EventsRate/get.json?field="value"'; -my $url_discrate = $masterurl . 'Master/BNET/LostRate/get.json?field="value"'; -my $url_prefix = $masterurl . 'Master/BNET/RunPrefix/get.json?field="value"'; -my $url_builders = $masterurl . 'Master/BNET/Builders/get.json?field="value"'; -my $url_inputs = $masterurl . 'Master/BNET/Inputs/get.json?field="value"'; - -my $url_cts_histo = $masterurl . '/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_TrigType/get.json?field="bins"'; - -# my $eb_drate = get ($url_drate); -# die "Couldn't get $url_drate" unless defined $eb_drate; -# -# my $eb_evrate = get ($url_erate); -# die "Couldn't get $url_erate" unless defined $eb_evrate; -# -# my $prefix = get ($url_prefix); -# die "Couldn't get $url_prefix" unless defined $prefix; -# -# -# #print Dumper $drate; -# print "Run prefix:$prefix, datarate: $eb_drate MB/s, event rate: $eb_evrate Ev/s \n"; -# -# #my $json_array = decode_json($content); -# -# my $builders = get ($url_builders); -# die "Couldn't get $url_builders" unless defined $builders; -# -# my $builder_array = decode_json($builders); -# -# #print Dumper $builder_array; -# my $numbuilders = scalar @$builder_array; -# -# my $inputs = get ($url_inputs); -# die "Couldn't get $url_inputs" unless defined $inputs; -# -# my $inputs_array = decode_json($inputs); -# -# #print Dumper $inputs_array; -# my $numinputs = scalar @$inputs_array; -# print "input node 1: $inputs_array->[0]\n"; -# print "number of inputs: $numinputs, number of builders: $numbuilders \n" ; -# -# - - -#die "End of test."; - - -my $spilllength = 0; - -while(1) { - my $totalrate = 0; - my $totalbytes = 0; - my $totaldiscarded = 0; - my $ioc = 0; - my $actmask = 0; - my $recvmask = 0; - my $qastate = QA::OK; - my $qamsg = ""; - my $evtrate = 0; - my $qastatedisc = QA::OK; - my $qamsgdisc = ""; - my $evtavgspill; - my $ebavgbytes; - my $ebavgrate = 0; - my $trbneterr = 0; - my $sumtype1 = 0; - my $sumtype9 = 0; - my $sumtypeE = 0; - my ($ratetype1,$ratetype9,$ratetypeE) = (0,0,0); - - # 0x03 => CTS - my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) or $trbneterr = 1; # or sleep 5 and next; - my $sentmask = ($rh_result->{QA::CTSAddress} || 0) & 0xFFFF; - - - # 0x3000 => ?? - #$rh_result = trb_register_read(0x3001, 0x1) or $trbneterr = 1; - # my $res = ($rh_result->{0x3001} || 0) & 0xFFFF; - - # JAM2017: try to check rate with tof if rich is not up: - $rh_result = trb_register_read(0x4c00, 0x1) or $trbneterr = 1; - my $res = ($rh_result->{0x4c00} || 0) & 0xFFFF; - - - $evtrate = $res - ($events || $res); - $evtrate += 2**16 if $evtrate < 0; - $events = $res; - pop(@evtrates) if scalar @evtrates >= $QA::AcceleratorCycle * 2; - unshift(@evtrates,$evtrate); - - $evtavgspill += $_ for @evtrates; - $evtavgspill /= scalar @evtrates; - - -############# JAM2018 - get eventbuilder rates via json here: - -my $cts_trigtype_histo = get ($url_cts_histo); -#print Dumper $cts_trigtype_histo; -my $trigtype_array; -if (defined $cts_trigtype_histo) -{ - $trigtype_array = decode_json($cts_trigtype_histo); -} - -# JAM2018 - note that first 4 histogram bins contain dimension and underflow/overflow bins in jsroot!? -$sumtype1 += $trigtype_array->[5] || 0; -$sumtype9 += $trigtype_array->[13] || 0; -$sumtypeE += $trigtype_array->[18] || 0; - - -$totalrate = get ($url_erate); -$totalrate = -1 unless defined $totalrate; - -$totaldiscarded = get ($url_discrate); -$totaldiscarded = -1 unless defined $totaldiscarded; -#print Dumper $totaldiscarded; - -$totalbytes = get ($url_drate); -$totalbytes = -1 unless defined $totalbytes; -# dabc delivers units MBytes, translate to kB to match previous EPICS kB units: -$totalbytes *=1024; - -#print Dumper $totalbytes; - my $prefix = get ($url_prefix); - #print Dumper $prefix; - - $prefix = "--" unless defined $prefix; - -# print "----------- \nDEBUG: Run prefix:$prefix, datarate: $totalbytes kB/s, event rate: $totalrate Ev/s \n"; - -#################################################################################### -### evaluate the builder node infos: - -my $num_bnetbuild =0; -my $builders = get ($url_builders); -#print Dumper $builders; -my $builder_array; -if (defined $builders) -{ - # $builders = 0 unless defined $builders; - $builder_array = decode_json($builders); - $num_bnetbuild = scalar @$builder_array; -} - -## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_build=0; -my $fileopen=0; -for my $buildnode (@$builder_array) { - #print " node is $buildnode \n"; - my $url_noderate = $masterurl . $buildnode . '/HadaqEvents/get.json?field="value"'; - my $noderate = get ($url_noderate); - #print $url_noderate; - #print Dumper $noderate; - $noderate = 0 unless defined $noderate; - if($noderate > 0) {$num_act_build +=1;} - # check here if file of given prefix is actually written: - my $url_filesize = $masterurl . $buildnode . '/RunFileSize/get.json?field="value"'; - my $filesize = get ($url_filesize); - #print $url_filesize; - #print Dumper $filesize; - $filesize = 0 unless defined $filesize; - if ($filesize>0) {$fileopen =1}; - } - - - - - $prefix = "--" unless $fileopen>0; - $totalbytes =0 unless $fileopen>0; - # emulate previous monitor: only account datarate when writing to file - - - ############################################################################################ - ### evaluate the bnet input node infos: - my $num_bnetin=0; -my $inputs = get ($url_inputs); -#print Dumper $inputs; -my $inputs_array; -if (defined $inputs) -{ - $inputs_array = decode_json($inputs); - $num_bnetin = scalar @$inputs_array; -} - - - ## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_ins=0; -for my $inpnode (@$inputs_array) { - #print " node is $inpnode \n"; - my $url_noderate = $masterurl . $inpnode . '/HadaqEvents/get.json?field="value"'; - my $noderate = get ($url_noderate); - #print $url_noderate; - #print Dumper $noderate; - $noderate = 0 unless defined $noderate; - if($noderate > 0) {$num_act_ins +=1;} - } - - - - - - - - - - pop(@ebrates) if scalar @ebrates >= $QA::AcceleratorCycle * 2; - unshift(@ebrates,$totalrate); - $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; - - ## hier todo: evtl mismatch von vorhandenen und aktiveb bnet nodes? - -# 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<$numebs;$i++) { -# $mismatch_sr |= (1<<$i) if ($sentmask & (1<<$i)) && !($recvmask & (1<<$i)); -# $mismatch_sa |= (1<<$i) if ($sentmask & (1<<$i)) && !($actmask & (1<<$i)); -# } -# printf ("actmask: %08X, recvmask: %04X, sentmask: %04X, mismatch_sr: %04X, mismatch_sa: %04X\n", -# ,$actmask,$recvmask,$sentmask,$mismatch_sr,$mismatch_sa); - -#Mismatch between selected EB in CTS and EB receiving data -# if($mismatch_sr != 0) { -# if ($evtrate > $act*32) { -# my $str = ""; -# for(my $i = 0; $i < $numebs; $i++) { -# if ($mismatch_sr & (1<<$i)) { -# $str .= ", " if $str ne ""; -# $str .= $i+1; -# } -# } -# if ($mismatchfound_sr++ >= 0 && $trbneterr == 0) { -# #system("logger -p local1.info -t DAQ 'EB Data is sent to EB $str but not received'") unless $mismatchfound_sr % 240; -# print "logger -p local1.info -t DAQ 'EB Data is sent to EB $str but not received'")unless $mismatchfound_sr % 240; -# $qastate = QA::ERROR; -# $qamsg .= "Data is sent to EB $str but not received. "; -# } -# } -# } -# else { -# $mismatchfound_sr = -10; -# } -# -# -# #Mismatch between selected EB in CTS and running EB processes -# if($mismatch_sa != 0) { -# my $str = ""; -# for(my $i = 0; $i < $numebs; $i++) { -# if ($mismatch_sa & (1<<$i)) { -# $str .= ", " if $str ne ""; -# $str .= $i+1; -# } -# } -# if ($mismatchfound_sa++ >= 0 && $trbneterr == 0) { -# system("logger -p local1.info -t DAQ 'EB Data is sent to not running EB $str'") unless $mismatchfound_sa % 60; -# $qastate = QA::ERROR; -# $qamsg .= "Data is sent to not running EB $str. "; -# } -# } -# else { -# $mismatchfound_sa = -10; -# } -# - - if($trbneterr) { - $qamsg .= "TrbNet Error - no information available."; - $qastate = QA::ERROR; - } - if ($qamsg eq "") {$qamsg = "No error found";} - if ($qastate == QA::OK) { - $qamsg .= sprintf(". Total rate: %i, 4-spill average: %i, total per EB: %i", - $totalrate,$ebavgrate,$totalrate/($num_act_build || $totalrate || 1)); - } - - $qamsgdisc = "Discarded events: $totaldiscarded - ".$qamsgdisc; - - - my $qatitle = "#EB running"; - $qatitle = "EB stopped" if ($num_bnetbuild == 0) ; - #print "$qatitle with act = $act , actmask = $actmask , sent = $sent , sentmask = $sentmask\n" ; - Hmon::Speak('ebrun',$qamsg) if $qastate > 60; -# QA::WriteQALog($fqa, "eb", "run", 10, $qastate, $qatitle, -# "act: $recv/$sent (".$data->{"prefix"}->{val}.")", $qamsg); - - QA::WriteQALog($fqa, "eb", "run", 10, $qastate, $qatitle, - "i:$num_bnetin/$num_act_ins, b:$num_bnetbuild/$num_act_build ($prefix)", $qamsg); -#print "QAlog: state:$qastate title:$qatitle\n"; -#print "QAlog: i:$num_bnetin/$num_act_ins, b:$num_bnetbuild/$num_act_build ($prefix) msg: $qamsg\n"; - -# if ($totalrate) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded/($totalrate || $totaldiscarded || 1),(0.01,0.05,0.1)); - if($totalrate < 500) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded || 1,(20,50,100)); - } -# } -# else { -# $qastatedisc = QA::NA; -# } - - my $totallost = $evtavgspill - $totalrate; - my $s = sprintf("%5d",$totaldiscarded); - QA::WriteQALog($fqa, "eb", "lostevt", 10, $qastatedisc, - "#Evt Discarded", $s, $qamsgdisc); -#print "QAlog: disc:$qastatedisc #Evt Discarded: $s - $qamsgdisc\n"; - - $ratetype1 = $sumtype1 - $oldsumtype1 unless ($oldsumtype1 > $sumtype1); - $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; - if($oldsumtype1 > $sumtype1) { - $cnterrtype9 = 50; - $cnterrtypeE = 50; - } - - - $qastate = QA::OK; - -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/($num_bnetbuild || $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)"; - } - if($totalbytes < 20 && $lasttotalbytes <20) { - $qastate = QA::WARN_2; - } - - if($trbneterr == 0) { - QA::WriteQALog($fqa,"eb","bytes",5,$qastate,"Data Rate",$evtavgshort,$evtavglong); -#printf "$qastate Data Rate - short:$evtavgshort long:$evtavglong)\n"; -# print $evtavglong."\n"; - } - else { - QA::WriteQALog($fqa,"eb","bytes",30,QA::NA,"Data Rate","N/A","N/A"); - } - - ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = ($sumtype1,$sumtype9,$sumtypeE); - $lasttotalbytes = $totalbytes; - usleep(990000); - } diff --git a/hmon/test/hmon_eb_run_json.pl b/hmon/test/hmon_eb_run_json.pl deleted file mode 100755 index 0a5eaae..0000000 --- a/hmon/test/hmon_eb_run_json.pl +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -#use Perl2Epics; -use LWP::Simple; -use JSON qw( decode_json ); - -use HADES::TrbNet; - -my $store = {}; -my @time; -my @state; -my @rate; -my @disc; -my $mismatchfound_sa = -10; -my $mismatchfound_sr = -10; -my $events = 0; -my @evtrates = (0,0,0); -my @ebrates = (); -my ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = (0,0,0); -my ($cnterrtype9,$cnterrtypeE) = (50,50); -my $lasttotalbytes = 21; -my @ebrecvhist; -my @byteshist; - -# with this switch disable qalog and enable printout only JAM -my $opt_debug = 0; - - -# sub cntbits32 { -# return (unpack('%32b*', pack('i',$_[0]))); -# } - -my $connect_status = &trb_init_ports(); -if(!$connect_status) { - die("could not connect to trbnetd"); -} - -my $fqa = QA::OpenQAFile(); - - - -# JAM 2018 here figure out corresponding json calles -my $masterurl = 'http://lxhadeb07:8099/'; - -my $url_drate = $masterurl . 'Master/BNET/DataRate/get.json?field="value"'; -my $url_erate = $masterurl . 'Master/BNET/EventsRate/get.json?field="value"'; -my $url_discrate = $masterurl . 'Master/BNET/LostRate/get.json?field="value"'; -my $url_prefix = $masterurl . 'Master/BNET/RunPrefix/get.json?field="value"'; -my $url_builders = $masterurl . 'Master/BNET/Builders/get.json?field="value"'; -my $url_inputs = $masterurl . 'Master/BNET/Inputs/get.json?field="value"'; - -my $url_cts_histo = $masterurl . '/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_TrigType/get.json?field="bins"'; - -# my $eb_drate = get ($url_drate); -# die "Couldn't get $url_drate" unless defined $eb_drate; -# -# my $eb_evrate = get ($url_erate); -# die "Couldn't get $url_erate" unless defined $eb_evrate; -# -# my $prefix = get ($url_prefix); -# die "Couldn't get $url_prefix" unless defined $prefix; -# -# -# #print Dumper $drate; -# print "Run prefix:$prefix, datarate: $eb_drate MB/s, event rate: $eb_evrate Ev/s \n"; -# -# #my $json_array = decode_json($content); -# -# my $builders = get ($url_builders); -# die "Couldn't get $url_builders" unless defined $builders; -# -# my $builder_array = decode_json($builders); -# -# #print Dumper $builder_array; -# my $numbuilders = scalar @$builder_array; -# -# my $inputs = get ($url_inputs); -# die "Couldn't get $url_inputs" unless defined $inputs; -# -# my $inputs_array = decode_json($inputs); -# -# #print Dumper $inputs_array; -# my $numinputs = scalar @$inputs_array; -# print "input node 1: $inputs_array->[0]\n"; -# print "number of inputs: $numinputs, number of builders: $numbuilders \n" ; -# -# -#die "End of test."; - - -my $spilllength = 0; - -while(1) { - my $totalrate = 0; - my $totalbytes = 0; - my $totaldiscarded = 0; - my $ioc = 0; - my $actmask = 0; - my $recvmask = 0; - my $qastate = QA::OK; - my $qamsg = ""; - my $evtrate = 0; - my $qastatedisc = QA::OK; - my $qamsgdisc = ""; - my $evtavgspill; - my $ebavgbytes; - my $ebavgrate = 0; - my $trbneterr = 0; - my $sumtype1 = 0; - my $sumtype9 = 0; - my $sumtypeE = 0; - my ($ratetype1,$ratetype9,$ratetypeE) = (0,0,0); - - # 0x03 => CTS - my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) or $trbneterr = 1; # or sleep 5 and next; - my $sentmask = ($rh_result->{QA::CTSAddress} || 0) & 0xFFFF; - - - # 0x3000 => ?? - #$rh_result = trb_register_read(0x3001, 0x1) or $trbneterr = 1; - # my $res = ($rh_result->{0x3001} || 0) & 0xFFFF; - - # JAM2017: try to check rate with tof if rich is not up: - $rh_result = trb_register_read(0x4c00, 0x1) or $trbneterr = 1; - my $res = ($rh_result->{0x4c00} || 0) & 0xFFFF; - - - $evtrate = $res - ($events || $res); - $evtrate += 2**16 if $evtrate < 0; - $events = $res; - pop(@evtrates) if scalar @evtrates >= $QA::AcceleratorCycle * 2; - unshift(@evtrates,$evtrate); - - $evtavgspill += $_ for @evtrates; - $evtavgspill /= scalar @evtrates; - - -############# JAM2018 - get eventbuilder rates via json here: - -my $cts_trigtype_histo = get ($url_cts_histo); -#print Dumper $cts_trigtype_histo; -my $trigtype_array; -if (defined $cts_trigtype_histo) -{ - $trigtype_array = decode_json($cts_trigtype_histo); -} - -# JAM2018 - note that first 4 histogram bins contain dimension and underflow/overflow bins in jsroot!? -$sumtype1 += $trigtype_array->[5] || 0; -$sumtype9 += $trigtype_array->[13] || 0; -$sumtypeE += $trigtype_array->[18] || 0; - - -$totalrate = get ($url_erate); -$totalrate = -1 unless defined $totalrate; - -$totaldiscarded = get ($url_discrate); -$totaldiscarded = -1 unless defined $totaldiscarded; -#print Dumper $totaldiscarded; - -$totalbytes = get ($url_drate); -$totalbytes = -1 unless defined $totalbytes; -# dabc delivers units MBytes, translate to kB to match previous EPICS kB units: -$totalbytes *=1024; - -#print Dumper $totalbytes; - my $prefix = get ($url_prefix); - #print Dumper $prefix; - - $prefix = "--" unless defined $prefix; - -# print "----------- \nDEBUG: Run prefix:$prefix, datarate: $totalbytes kB/s, event rate: $totalrate Ev/s \n"; - -#################################################################################### -### evaluate the builder node infos: - -my $num_bnetbuild =0; -my $builders = get ($url_builders); -#print Dumper $builders; -my $builder_array; -if (defined $builders) -{ - # $builders = 0 unless defined $builders; - $builder_array = decode_json($builders); - $num_bnetbuild = scalar @$builder_array; -} - -## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_build=0; -my $fileopen=0; -for my $buildnode (@$builder_array) { - #print " node is $buildnode \n"; - my $url_noderate = $masterurl . $buildnode . '/HadaqEvents/get.json?field="value"'; - my $noderate = get ($url_noderate); - #print $url_noderate; - #print Dumper $noderate; - $noderate = 0 unless defined $noderate; - if($noderate > 0) {$num_act_build +=1;} - # check here if file of given prefix is actually written: - my $url_filesize = $masterurl . $buildnode . '/RunFileSize/get.json?field="value"'; - my $filesize = get ($url_filesize); - #print $url_filesize; - #print Dumper $filesize; - $filesize = 0 unless defined $filesize; - if ($filesize>0) {$fileopen =1}; - } - - - - - $prefix = "--" unless $fileopen>0; - $totalbytes =0 unless $fileopen>0; - # emulate previous monitor: only account datarate when writing to file - - - ############################################################################################ - ### evaluate the bnet input node infos: - my $num_bnetin=0; -my $inputs = get ($url_inputs); -#print Dumper $inputs; -my $inputs_array; -if (defined $inputs) -{ - $inputs_array = decode_json($inputs); - $num_bnetin = scalar @$inputs_array; -} - - - ## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_ins=0; -for my $inpnode (@$inputs_array) { - #print " node is $inpnode \n"; - my $url_noderate = $masterurl . $inpnode . '/HadaqEvents/get.json?field="value"'; - my $noderate = get ($url_noderate); - #print $url_noderate; - #print Dumper $noderate; - $noderate = 0 unless defined $noderate; - if($noderate > 0) {$num_act_ins +=1;} - } - - - - - pop(@ebrates) if scalar @ebrates >= $QA::AcceleratorCycle * 2; - unshift(@ebrates,$totalrate); - $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; - - - -# here check mismatch between running bnet nodes and active ones: - -if($num_bnetin>$num_act_ins) -{ - $qastate = QA::ERROR; - $qamsg .= "Only $num_act_ins nodes of $num_bnetin BNET inputs receive data! "; -} - -if($num_bnetbuild>$num_act_build) -{ - $qastate = QA::ERROR; - $qamsg .= "Only $num_act_build nodes of $num_bnetbuild BNET builders are building events! "; -} - - - - - if($trbneterr) { - $qamsg .= "TrbNet Error - no information available."; - $qastate = QA::ERROR; - } - if ($qamsg eq "") {$qamsg = "No error found";} - if ($qastate == QA::OK) { - $qamsg .= sprintf(". Total rate: %i, 4-spill average: %i, total per EB: %i", - $totalrate,$ebavgrate,$totalrate/($num_act_build || $totalrate || 1)); - } - - $qamsgdisc = "Discarded events: $totaldiscarded - ".$qamsgdisc; - - - my $qatitle = "#EB running"; - $qatitle = "EB stopped" if ($num_bnetbuild == 0) ; - -if($opt_debug<1) -{ - - Hmon::Speak('ebrun',$qamsg) if $qastate > 60; - QA::WriteQALog($fqa, "eb", "run", 10, $qastate, $qatitle, - "i:$num_act_ins/$num_bnetin, b:$num_act_build/$num_bnetbuild ($prefix)", $qamsg); -} -else -{ - print "QAlog: state:$qastate title:$qatitle\n"; - print "QAlog: i::$num_act_ins/$num_bnetin, b:$num_act_build/$num_bnetbuild ($prefix) msg: $qamsg\n"; - } - -# if ($totalrate) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded/($totalrate || $totaldiscarded || 1),(0.01,0.05,0.1)); - if($totalrate < 500) { - $qastatedisc = QA::GetQAState('below',$totaldiscarded || 1,(20,50,100)); - } -# } -# else { -# $qastatedisc = QA::NA; -# } - - my $totallost = $evtavgspill - $totalrate; - my $s = sprintf("%5d",$totaldiscarded); - if($opt_debug<1) - { - QA::WriteQALog($fqa, "eb", "lostevt", 10, $qastatedisc, - "#Evt Discarded", $s, $qamsgdisc); - } - else - { - print "QAlog: disc:$qastatedisc #Evt Discarded: $s - $qamsgdisc\n"; - } - - $ratetype1 = $sumtype1 - $oldsumtype1 unless ($oldsumtype1 > $sumtype1); - $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; - if($oldsumtype1 > $sumtype1) { - $cnterrtype9 = 50; - $cnterrtypeE = 50; - } - - - $qastate = QA::OK; - -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/($num_bnetbuild || $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)"; - } - if($totalbytes < 20 && $lasttotalbytes <20) { - $qastate = QA::WARN_2; - } - - if($trbneterr == 0) { - - QA::WriteQALog($fqa,"eb","bytes",5,$qastate,"Data Rate",$evtavgshort,$evtavglong) unless $opt_debug>0; - if($opt_debug>0) - { - printf "$qastate Data Rate - short:$evtavgshort long:$evtavglong)\n"; - print $evtavglong."\n"; - } - } - else { - QA::WriteQALog($fqa,"eb","bytes",30,QA::NA,"Data Rate","N/A","N/A") unless $opt_debug>0; - } - - ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = ($sumtype1,$sumtype9,$sumtypeE); - $lasttotalbytes = $totalbytes; - usleep(990000); - } diff --git a/hmon/test/hmon_eberrbits_epics.pl b/hmon/test/hmon_eberrbits_epics.pl deleted file mode 100755 index 2d72350..0000000 --- a/hmon/test/hmon_eberrbits_epics.pl +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; - -my $timer = 0; -my $flog = QA::OpenQAFile(); - -# my $connect_status = &trb_init_ports(); -# if(!$connect_status) { -# die("could not connect to trbnetd"); -# } - - -### JAM2018: we have to write this completely new for BNET. - - - -my $sources = {50000 => "CTS/Start", - 50003 => "RICH 1/2", - 50004 => "RICH 3/4", - 50005 => "RICH 5/6", - 50006 => "RPC 1/2/3", - 50007 => "RPC 4/5/6", - 50008 => "Shower", - 50009 => "TOF", - 50010 => "FWall", - 50011 => "CTS/Start", - 50016 => "MDC 1/2 1000", - 50017 => "MDC 1/2 1010", - 50018 => "MDC 1/2 1020", - 50019 => "MDC 1/2 1030", - 50020 => "MDC 1/2 1040", - 50021 => "MDC 1/2 1050", - 50022 => "MDC 3/4 sec.1", - 50023 => "MDC 3/4 sec.2", - 50024 => "MDC 3/4 sec.3", - 50025 => "MDC 3/4 sec.4", - 50026 => "MDC 3/4 sec.5", - 50027 => "MDC 3/4 sec.6", - 50028 => "MDC Test", - 50032 => "Shower sec.1", - 50033 => "Shower sec.2", - 50034 => "Shower sec.3", - 50035 => "Shower sec.4", - 50036 => "Shower sec.5", - 50037 => "Shower sec.6", - }; - -my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 - EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); - - -Perl2Epics::Connect("streams","HAD:eb01:nrOfMsgs"); -foreach my $i (0 .. 20) { - Perl2Epics::Connect("stream".($i),"HAD:eb01:portnr1:".($i)); - Perl2Epics::Connect("stream".($i+21),"HAD:eb01:portnr2:".($i+21)); - } -foreach my $i (1 .. 16) { - my $t = sprintf("%02i",$i); - foreach my $s (0 .. 4) { - Perl2Epics::Connect("eb".$i."stat$s","HAD:eb$t:stat:errBitStat$s"); - Perl2Epics::Connect("eb".$i."pat$s","HAD:eb$t:stat:errBitPtrn$s"); - } - } - - - -sleep(2); - -while(1) { - my $data = Perl2Epics::GetAll(); - - my $store = {}; - #$store->{all}->{$bit} - #$store->{$stream}->{$bit} - - my $streams = $data->{"streams"}->{val} || 0; - - foreach my $eb (1 .. 16) { - foreach my $stream (0 .. $streams-1) { - my $currentstream = ($data->{"stream".($stream)}->{val} || 0); -# print $currentstream." ".$stream."\n"; - foreach my $pat (0 .. 4) { - my $currentpattern = $data->{"eb".$eb."pat".$pat}->{val} || 0; - foreach my $bit (0 .. 31) { - if($currentpattern & (1<<$bit)) { - my $currentvalue = $data->{"eb".$eb."stat".$pat}->{val}[$stream] || 0; - if($currentvalue) { - $store->{$currentstream}->{$bit}+= $currentvalue; - } - $store->{all}->{$bit} += $currentvalue; - } - } - } - } - } -# print Dumper $store; - -# my $str = Hmon::MakeTitle(10, 23, "MDC HV", 1, ""); -my $longstring = ""; -my $qastate = QA::OK; -my $value = ""; -my $brokenevents = 0; -my $maxperc = 0; -my $sumperc = 0; -my $errcnt = 0; - - foreach my $k (sort keys %$store) { - if ($k ne "all") { - foreach my $b (sort keys %{$store->{$k}}) { - if(($b != 0)) { - my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; - $maxperc = $perc if $perc > $maxperc; - $sumperc += $perc; - my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", - $sources->{$k}, - $store->{$k}->{$b}, - $perc, - @bits[$b]); - $longstring .= $ts; - - $brokenevents += $store->{$k}->{$b}; - } - } - } - } - $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); - - ## JAM2018: following should be $store->{"all"}->{0} ?????? - $longstring = "Total Events in file: ".($store->{50010}->{0} || "")." - ". - "Events with errors: ".$value." - ". - $longstring; - chop $longstring;chop $longstring;chop $longstring; - - $qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); - - QA::WriteQALog($flog, "eb", "errbits", 10, - $qastate, "#Evt w/ errors", $value, $longstring); - - system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); - $timer = 0 if $qastate <= 60; - Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - sleep(1); - } - diff --git a/hmon/test/hmon_eberrbits_json.pl b/hmon/test/hmon_eberrbits_json.pl deleted file mode 100755 index 0d7f65e..0000000 --- a/hmon/test/hmon_eberrbits_json.pl +++ /dev/null @@ -1,216 +0,0 @@ -#!/usr/bin/perl -w -# adjusted for BNET with dabc webserver JAM 2-Oct-2018 -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use HADES::TrbNet; -use LWP::Simple; -use JSON qw( decode_json ); - -my $timer = 0; -my $flog = QA::OpenQAFile(); - - -my $opt_debug = 0; -my $opt_verbose =0; - - -my $sources = { -TRB_0x8800 => "CentralCTS", -TRB_0x8400 =>"RPC123 ", -TRB_0x8410 =>"RPC456 ", -TRB_0x8600 =>"TOF ", -TRB_0x8700 =>"FW ", -TRB_0x8880 => "StartTRB3", -TRB_0x8890 => "VetoTRB3", -TRB_0x8900 => "Pion1 ", -TRB_0x8910 => "Pion2 ", -TRB_0x1000 => "MDC12sec1", -TRB_0x1010 => "MDC12sec2", -TRB_0x1020 => "MDC12sec3", -TRB_0x1030 => "MDC12sec4", -TRB_0x1040 => "MDC12sec5", -TRB_0x1050 => "MDC12sec6", -TRB_0x1100 => "MDC34sec1", -TRB_0x1110 => "MDC34sec2", -TRB_0x1120 => "MDC34sec3", -TRB_0x1130 => "MDC34sec4", -TRB_0x1140 => "MDC34sec5", -TRB_0x1150 => "MDC34sec6", -TRB_0x8a00 => "ECal0 ", -TRB_0x8a01 => "ECal1 ", -TRB_0x8a02 => "ECal2 ", -TRB_0x8a03 => "ECal3 ", -TRB_0x8a04 => "ECal4 ", -TRB_0x8a05 => "ECal5 ", -TRB_0x83c0 => "RICH0 ", -TRB_0x83c1 => "RICH1 ", -TRB_0x83c2 => "RICH2 ", -TRB_0x83c3 => "RICH3 ", -TRB_0x83c4 => "RICH4 ", -TRB_0x83c5 => "RICH5 ", -TRB_0x83c6 => "RICH6 ", -TRB_0x83c7 => "RICH7 ", -TRB_0x83c8 => "RICH8 ", -TRB_0x83c9 => "RICH9 ", -TRB_0x83ca => "RICHa ", -TRB_0x83cb => "RICHb " -}; - -my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); - - -# JAM 2018 here figure out corresponding json calles -my $masterurl = 'http://lxhadeb07:8099/'; - -my $url_inputs = $masterurl . 'Master/BNET/Inputs/get.json?field="value"'; - -#my $url_cts_histo = $masterurl . '/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_TrigType/get.json?field="bins"'; - -# http://lxhadeb07:8099/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_ErrorBits/get.json?field=%"bins" - - - -while (1) -{ - - my $store = {}; -my $longstring = ""; -my $qastate = QA::OK; -my $value = ""; -my $brokenevents = 0; -my $maxperc = 0; -my $sumperc = 0; -my $errcnt = 0; - - - - my $num_bnetin=0; -my $inputs = get ($url_inputs); -#print Dumper $inputs; -my $inputs_array; -if (defined $inputs) -{ - $inputs_array = decode_json($inputs); - $num_bnetin = scalar @$inputs_array; -} - - - ## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_ins=0; -for my $inpnode (@$inputs_array) { - #print " node is $inpnode \n"; - # todo: remove FirstLevel from inpnode - my $lastslash = rindex($inpnode, "/") + 1; - my $nodepath = substr($inpnode, 0, $lastslash); - #print "nodepath is $nodepath\n"; - my $url_nodehierarchy = $masterurl . $nodepath . '/h.json'; - my $nodehierarchy = get ($url_nodehierarchy); - print "\n--------------\n$url_nodehierarchy \n" if $opt_verbose; - #print Dumper $nodehierarchy; - if (defined $nodehierarchy) - { - my $inpnode_array = decode_json($nodehierarchy); -# print Dumper $inpnode_array; - my $numchilds = scalar $inpnode_array->{'_childs'}; - my $i=0; my $j=0; my $k=0; - for ($i=0; $i < $numchilds; $i = $i + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_name'}); - my $childname= $inpnode_array->{'_childs'}[$i]->{'_name'}; - print "name $i = $childname \n" if $opt_verbose; - if($childname =~ /TRB/) - { - print "found trb node $childname \n" if $opt_verbose; - # scan array of subchildren: - my $numsubchilds = scalar $inpnode_array->{'_childs'}[$i]->{'_childs'}; - for ($j=0; $j < $numsubchilds; $j = $j + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}); - my $subchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}; - if($subchildname =~ /TRB/) - { - my $numsubsubchilds = scalar @{$inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}}; - print "found subnode $subchildname with $numsubsubchilds childs \n" if $opt_verbose; - for ($k=0; $k < $numsubsubchilds; $k = $k + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}); - my $subsubchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}; - print "scanning subsubnode $subsubchildname.. \n" if $opt_verbose; - if($subsubchildname =~ /ErrorBits/) - { - print "found errorbits histogram $subsubchildname \n" if $opt_verbose; - my $errorbits_url = "$masterurl$nodepath/$childname/$subchildname/$subsubchildname/get.json?field=\"bins\""; - print "url is $errorbits_url \n" if $opt_verbose; - my $errorbits = get ($errorbits_url); - #print Dumper $errorbits; - next unless (defined $errorbits); - my $errorbits_array = decode_json($errorbits); - foreach my $bit (0 .. 31) { - if($errorbits_array->[$bit+4]) - { - $store->{$subchildname}->{$bit}+= $errorbits_array->[$bit+4]; - $store->{all}->{$bit}+=$errorbits_array->[$bit+4]; - } - } - } - } - } - } - - } - - last if($i > 1000); - } - - } -} - -print Dumper $store if $opt_verbose; - -# JAM2018 - same as before with epics: -foreach my $k (sort keys %$store) { - if ($k ne "all") { - foreach my $b (sort keys %{$store->{$k}}) { - if(($b != 0)) { - my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; - $maxperc = $perc if $perc > $maxperc; - $sumperc += $perc; - my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", - $sources->{$k}, - $store->{$k}->{$b}, - $perc, - $bits[$b]); - $longstring .= $ts; - $brokenevents += $store->{$k}->{$b}; - } - } - } - } - $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); - $longstring = "Total Events in file: ".($store->{TRB_8800}->{0} || "")." - ". - "Events with errors: ".$value." - ". - $longstring; - chop $longstring;chop $longstring;chop $longstring; - print "$longstring \n" if $opt_debug; - $qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); - QA::WriteQALog($flog, "eb", "errbits", 10, - $qastate, "#Evt w/ errors", $value, $longstring) unless $opt_debug; -# JAM2018: do we want system log and speaker again? - # system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); - print 'EB Events with set error-bits written to file: $longstring' if ($opt_debug && $qastate > 60 && !($timer++%60)); - $timer = 0 if $qastate <= 60; - #Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - - -sleep (2); -} - - - - \ No newline at end of file diff --git a/hmon/test/hmon_eberrbits_json_v0.pl b/hmon/test/hmon_eberrbits_json_v0.pl deleted file mode 100755 index b88d8d4..0000000 --- a/hmon/test/hmon_eberrbits_json_v0.pl +++ /dev/null @@ -1,377 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -#use Perl2Epics; -use HADES::TrbNet; -use LWP::Simple; -use JSON qw( decode_json ); - -my $timer = 0; -my $flog = QA::OpenQAFile(); - -# my $connect_status = &trb_init_ports(); -# if(!$connect_status) { -# die("could not connect to trbnetd"); -# } - -my $opt_debug = 1; -my $opt_verbose =0; - - -my $sources = { -TRB_0x8800 => "CentralCTS", -TRB_0x8400 =>"RPC123 ", -TRB_0x8410 =>"RPC456 ", -TRB_0x8600 =>"TOF ", -TRB_0x8700 =>"FW ", -TRB_0x8880 => "StartTRB3", -TRB_0x8890 => "VetoTRB3", -TRB_0x8900 => "Pion1 ", -TRB_0x8910 => "Pion2 ", -TRB_0x1000 => "MDC12sec1", -TRB_0x1010 => "MDC12sec2", -TRB_0x1020 => "MDC12sec3", -TRB_0x1030 => "MDC12sec4", -TRB_0x1040 => "MDC12sec5", -TRB_0x1050 => "MDC12sec6", -TRB_0x1100 => "MDC34sec1", -TRB_0x1110 => "MDC34sec2", -TRB_0x1120 => "MDC34sec3", -TRB_0x1130 => "MDC34sec4", -TRB_0x1140 => "MDC34sec5", -TRB_0x1150 => "MDC34sec6", -TRB_0x8a00 => "ECal0 ", -TRB_0x8a01 => "ECal1 ", -TRB_0x8a02 => "ECal2 ", -TRB_0x8a03 => "ECal3 ", -TRB_0x8a04 => "ECal4 ", -TRB_0x8a05 => "ECal5 ", -TRB_0x83c0 => "RICH0 ", -TRB_0x83c1 => "RICH1 ", -TRB_0x83c2 => "RICH2 ", -TRB_0x83c3 => "RICH3 ", -TRB_0x83c4 => "RICH4 ", -TRB_0x83c5 => "RICH5 ", -TRB_0x83c6 => "RICH6 ", -TRB_0x83c7 => "RICH7 ", -TRB_0x83c8 => "RICH8 ", -TRB_0x83c9 => "RICH9 ", -TRB_0x83ca => "RICHa ", -TRB_0x83cb => "RICHb " -}; - -my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); - - -# JAM 2018 here figure out corresponding json calles -my $masterurl = 'http://lxhadeb07:8099/'; - -my $url_inputs = $masterurl . 'Master/BNET/Inputs/get.json?field="value"'; - -#my $url_cts_histo = $masterurl . '/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_TrigType/get.json?field="bins"'; - -# http://lxhadeb07:8099/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_ErrorBits/get.json?field=%"bins" - - - -while (1) -{ - - my $store = {}; -my $longstring = ""; -my $qastate = QA::OK; -my $value = ""; -my $brokenevents = 0; -my $maxperc = 0; -my $sumperc = 0; -my $errcnt = 0; - - - - my $num_bnetin=0; -my $inputs = get ($url_inputs); -#print Dumper $inputs; -my $inputs_array; -if (defined $inputs) -{ - $inputs_array = decode_json($inputs); - $num_bnetin = scalar @$inputs_array; -} - - - ## find out how many of the active eventbuilders are actually receiving stuff: -my $num_act_ins=0; -for my $inpnode (@$inputs_array) { - #print " node is $inpnode \n"; - # todo: remove FirstLevel from inpnode - my $lastslash = rindex($inpnode, "/") + 1; - my $nodepath = substr($inpnode, 0, $lastslash); - #print "nodepath is $nodepath\n"; - my $url_nodehierarchy = $masterurl . $nodepath . '/h.json'; - my $nodehierarchy = get ($url_nodehierarchy); - print "\n--------------\n$url_nodehierarchy \n" if $opt_verbose; - #print Dumper $nodehierarchy; - if (defined $nodehierarchy) - { - my $inpnode_array = decode_json($nodehierarchy); -# print Dumper $inpnode_array; -# die breaking test; -# for my $child (@$inpnode_array->{'_childs'}) { -# print $child->{'_name'}; -# print "\n"; -# } -# my $numchilds = scalar @(%keys $inpnode_array); - my $numchilds = scalar $inpnode_array->{'_childs'}; -# my $numchilds = 5; - my $i=0; my $j=0; my $k=0; - for ($i=0; $i < $numchilds; $i = $i + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_name'}); - my $childname= $inpnode_array->{'_childs'}[$i]->{'_name'}; - print "name $i = $childname \n" if $opt_verbose; - if($childname =~ /TRB/) - { - print "found trb node $childname \n" if $opt_verbose; - # scan array of subchildren: - my $numsubchilds = scalar $inpnode_array->{'_childs'}[$i]->{'_childs'}; - for ($j=0; $j < $numsubchilds; $j = $j + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}); - my $subchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_name'}; - if($subchildname =~ /TRB/) - { - - my $numsubsubchilds = scalar @{$inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}}; - print "found subnode $subchildname with $numsubsubchilds childs \n" if $opt_verbose; - for ($k=0; $k < $numsubsubchilds; $k = $k + 1) - { - last unless (defined $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}); - my $subsubchildname = $inpnode_array->{'_childs'}[$i]->{'_childs'}[$j]->{'_childs'}[$k]->{'_name'}; - print "scanning subsubnode $subsubchildname.. \n" if $opt_verbose; - if($subsubchildname =~ /ErrorBits/) - { - print "found errorbits histogram $subsubchildname \n" if $opt_verbose; - my $errorbits_url = "$masterurl$nodepath/$childname/$subchildname/$subsubchildname/get.json?field=\"bins\""; - print "url is $errorbits_url \n" if $opt_verbose; - my $errorbits = get ($errorbits_url); - #print Dumper $errorbits; - next unless (defined $errorbits); - - my $errorbits_array = decode_json($errorbits); - foreach my $bit (0 .. 31) { - if($errorbits_array->[$bit+4]) - { - $store->{$subchildname}->{$bit}+= $errorbits_array->[$bit+4]; - $store->{all}->{$bit}+=$errorbits_array->[$bit+4]; - } - } - - - } - } - } - } - - } - - last if($i > 100); - } - - } -} - -print Dumper $store if $opt_verbose; - -# JAM2018 - same as before with epics -# my $str = Hmon::MakeTitle(10, 23, "MDC HV", 1, ""); - -foreach my $k (sort keys %$store) { - if ($k ne "all") { - foreach my $b (sort keys %{$store->{$k}}) { - if(($b != 0)) { - my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; - $maxperc = $perc if $perc > $maxperc; - $sumperc += $perc; - my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", - $sources->{$k}, - $store->{$k}->{$b}, - $perc, - $bits[$b]); - $longstring .= $ts; - - $brokenevents += $store->{$k}->{$b}; - } - } - } - } - $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); - - ## JAM2018: following should be $store->{"all"}->{0} ?????? - $longstring = "Total Events in file: ".($store->{TRB_8800}->{0} || "")." - ". - "Events with errors: ".$value." - ". - $longstring; - - #print $longstring; - - - chop $longstring;chop $longstring;chop $longstring; - print "$longstring \n" if $opt_debug; -# -$qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); -# - QA::WriteQALog($flog, "eb", "errbits", 10, - $qastate, "#Evt w/ errors", $value, $longstring) unless $opt_debug; -# JAM2018: do we want system log and speaker again? - # system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); - print 'EB Events with set error-bits written to file: $longstring' if ($opt_debug && $qastate > 60 && !($timer++%60)); - $timer = 0 if $qastate <= 60; - #Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - - -sleep (2); -} - -#die "End of test."; - - -### JAM2018: we have to write this completely new for BNET. - - - -# my $sources = {50000 => "CTS/Start", -# 50003 => "RICH 1/2", -# 50004 => "RICH 3/4", -# 50005 => "RICH 5/6", -# 50006 => "RPC 1/2/3", -# 50007 => "RPC 4/5/6", -# 50008 => "Shower", -# 50009 => "TOF", -# 50010 => "FWall", -# 50011 => "CTS/Start", -# 50016 => "MDC 1/2 1000", -# 50017 => "MDC 1/2 1010", -# 50018 => "MDC 1/2 1020", -# 50019 => "MDC 1/2 1030", -# 50020 => "MDC 1/2 1040", -# 50021 => "MDC 1/2 1050", -# 50022 => "MDC 3/4 sec.1", -# 50023 => "MDC 3/4 sec.2", -# 50024 => "MDC 3/4 sec.3", -# 50025 => "MDC 3/4 sec.4", -# 50026 => "MDC 3/4 sec.5", -# 50027 => "MDC 3/4 sec.6", -# 50028 => "MDC Test", -# 50032 => "Shower sec.1", -# 50033 => "Shower sec.2", -# 50034 => "Shower sec.3", -# 50035 => "Shower sec.4", -# 50036 => "Shower sec.5", -# 50037 => "Shower sec.6", -# }; - -# my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 -# EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); -# - -# Perl2Epics::Connect("streams","HAD:eb01:nrOfMsgs"); -# foreach my $i (0 .. 20) { -# Perl2Epics::Connect("stream".($i),"HAD:eb01:portnr1:".($i)); -# Perl2Epics::Connect("stream".($i+21),"HAD:eb01:portnr2:".($i+21)); -# } -# foreach my $i (1 .. 16) { -# my $t = sprintf("%02i",$i); -# foreach my $s (0 .. 4) { -# Perl2Epics::Connect("eb".$i."stat$s","HAD:eb$t:stat:errBitStat$s"); -# Perl2Epics::Connect("eb".$i."pat$s","HAD:eb$t:stat:errBitPtrn$s"); -# } -# } -# - - -# sleep(2); -# -# while(1) { - #my $data = Perl2Epics::GetAll(); - -# my $store = {}; -# #$store->{all}->{$bit} -# #$store->{$stream}->{$bit} -# -# my $streams = $data->{"streams"}->{val} || 0; -# -# foreach my $eb (1 .. 16) { -# foreach my $stream (0 .. $streams-1) { -# my $currentstream = ($data->{"stream".($stream)}->{val} || 0); -# # print $currentstream." ".$stream."\n"; -# foreach my $pat (0 .. 4) { -# my $currentpattern = $data->{"eb".$eb."pat".$pat}->{val} || 0; -# foreach my $bit (0 .. 31) { -# if($currentpattern & (1<<$bit)) { -# my $currentvalue = $data->{"eb".$eb."stat".$pat}->{val}[$stream] || 0; -# if($currentvalue) { -# $store->{$currentstream}->{$bit}+= $currentvalue; -# } -# $store->{all}->{$bit} += $currentvalue; -# } -# } -# } -# } -# } -# # print Dumper $store; - -# my $str = Hmon::MakeTitle(10, 23, "MDC HV", 1, ""); -# my $longstring = ""; -# my $qastate = QA::OK; -# my $value = ""; -# my $brokenevents = 0; -# my $maxperc = 0; -# my $sumperc = 0; -# my $errcnt = 0; -# -# foreach my $k (sort keys %$store) { -# if ($k ne "all") { -# foreach my $b (sort keys %{$store->{$k}}) { -# if(($b != 0)) { -# my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; -# $maxperc = $perc if $perc > $maxperc; -# $sumperc += $perc; -# my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", -# $sources->{$k}, -# $store->{$k}->{$b}, -# $perc, -# @bits[$b]); -# $longstring .= $ts; -# -# $brokenevents += $store->{$k}->{$b}; -# } -# } -# } -# } -# $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); -# -# ## JAM2018: following should be $store->{"all"}->{0} ?????? -# $longstring = "Total Events in file: ".($store->{50010}->{0} || "")." - ". -# "Events with errors: ".$value." - ". -# $longstring; -# chop $longstring;chop $longstring;chop $longstring; -# -# $qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); -# -# QA::WriteQALog($flog, "eb", "errbits", 10, -# $qastate, "#Evt w/ errors", $value, $longstring); -# -# # system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); -# $timer = 0 if $qastate <= 60; -# #Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - - - -# sleep(1); -# } - diff --git a/hmon/test/hmon_eberrbits_old.pl b/hmon/test/hmon_eberrbits_old.pl deleted file mode 100755 index 2d72350..0000000 --- a/hmon/test/hmon_eberrbits_old.pl +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; -use Time::HiRes qw( gettimeofday usleep time ); -use FileHandle; -use Data::Dumper; -use POSIX qw/floor ceil/; -use Hmon; -use QA; -use Perl2Epics; -use HADES::TrbNet; - -my $timer = 0; -my $flog = QA::OpenQAFile(); - -# my $connect_status = &trb_init_ports(); -# if(!$connect_status) { -# die("could not connect to trbnetd"); -# } - - -### JAM2018: we have to write this completely new for BNET. - - - -my $sources = {50000 => "CTS/Start", - 50003 => "RICH 1/2", - 50004 => "RICH 3/4", - 50005 => "RICH 5/6", - 50006 => "RPC 1/2/3", - 50007 => "RPC 4/5/6", - 50008 => "Shower", - 50009 => "TOF", - 50010 => "FWall", - 50011 => "CTS/Start", - 50016 => "MDC 1/2 1000", - 50017 => "MDC 1/2 1010", - 50018 => "MDC 1/2 1020", - 50019 => "MDC 1/2 1030", - 50020 => "MDC 1/2 1040", - 50021 => "MDC 1/2 1050", - 50022 => "MDC 3/4 sec.1", - 50023 => "MDC 3/4 sec.2", - 50024 => "MDC 3/4 sec.3", - 50025 => "MDC 3/4 sec.4", - 50026 => "MDC 3/4 sec.5", - 50027 => "MDC 3/4 sec.6", - 50028 => "MDC Test", - 50032 => "Shower sec.1", - 50033 => "Shower sec.2", - 50034 => "Shower sec.3", - 50035 => "Shower sec.4", - 50036 => "Shower sec.5", - 50037 => "Shower sec.6", - }; - -my @bits = qw(OK Collision WordMissing ChecksumMismatch DontUnderstand BufferMismatch AnswerMissing 7 8 9 10 11 12 13 14 15 - EventNumberMismatch TriggerCodeMismatch WrongLength AnswerMissing NotFound PartiallyMissing SevereProblem BrokenEvent EthernetLinkError SubEventBufferFull EthernetError TimingTriggerError 28 29 30 31); - - -Perl2Epics::Connect("streams","HAD:eb01:nrOfMsgs"); -foreach my $i (0 .. 20) { - Perl2Epics::Connect("stream".($i),"HAD:eb01:portnr1:".($i)); - Perl2Epics::Connect("stream".($i+21),"HAD:eb01:portnr2:".($i+21)); - } -foreach my $i (1 .. 16) { - my $t = sprintf("%02i",$i); - foreach my $s (0 .. 4) { - Perl2Epics::Connect("eb".$i."stat$s","HAD:eb$t:stat:errBitStat$s"); - Perl2Epics::Connect("eb".$i."pat$s","HAD:eb$t:stat:errBitPtrn$s"); - } - } - - - -sleep(2); - -while(1) { - my $data = Perl2Epics::GetAll(); - - my $store = {}; - #$store->{all}->{$bit} - #$store->{$stream}->{$bit} - - my $streams = $data->{"streams"}->{val} || 0; - - foreach my $eb (1 .. 16) { - foreach my $stream (0 .. $streams-1) { - my $currentstream = ($data->{"stream".($stream)}->{val} || 0); -# print $currentstream." ".$stream."\n"; - foreach my $pat (0 .. 4) { - my $currentpattern = $data->{"eb".$eb."pat".$pat}->{val} || 0; - foreach my $bit (0 .. 31) { - if($currentpattern & (1<<$bit)) { - my $currentvalue = $data->{"eb".$eb."stat".$pat}->{val}[$stream] || 0; - if($currentvalue) { - $store->{$currentstream}->{$bit}+= $currentvalue; - } - $store->{all}->{$bit} += $currentvalue; - } - } - } - } - } -# print Dumper $store; - -# my $str = Hmon::MakeTitle(10, 23, "MDC HV", 1, ""); -my $longstring = ""; -my $qastate = QA::OK; -my $value = ""; -my $brokenevents = 0; -my $maxperc = 0; -my $sumperc = 0; -my $errcnt = 0; - - foreach my $k (sort keys %$store) { - if ($k ne "all") { - foreach my $b (sort keys %{$store->{$k}}) { - if(($b != 0)) { - my $perc = $store->{$k}->{$b}/($store->{$k}->{0} || $store->{$k}->{$b} || 1)*100; - $maxperc = $perc if $perc > $maxperc; - $sumperc += $perc; - my $ts = sprintf("%s has %i events (%.2f%%) with %s - ", - $sources->{$k}, - $store->{$k}->{$b}, - $perc, - @bits[$b]); - $longstring .= $ts; - - $brokenevents += $store->{$k}->{$b}; - } - } - } - } - $value = sprintf("%s (%.1f%%)",QA::SciNotation($brokenevents), $sumperc); - - ## JAM2018: following should be $store->{"all"}->{0} ?????? - $longstring = "Total Events in file: ".($store->{50010}->{0} || "")." - ". - "Events with errors: ".$value." - ". - $longstring; - chop $longstring;chop $longstring;chop $longstring; - - $qastate = QA::GetQAState('below', $sumperc, @QA::Eventsbroken); - - QA::WriteQALog($flog, "eb", "errbits", 10, - $qastate, "#Evt w/ errors", $value, $longstring); - - system("logger -p local1.info -t DAQ 'EB Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60)); - $timer = 0 if $qastate <= 60; - Hmon::Speak("Eventbuilder receive events with set error bits") if $brokenevents > 1000 && $qastate >= 60; - sleep(1); - } - diff --git a/hmon/test/hmon_micha_test.pl b/hmon/test/hmon_micha_test.pl deleted file mode 100644 index 11d999d..0000000 --- a/hmon/test/hmon_micha_test.pl +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/perl -w - -use warnings; -use strict; -use Time::HiRes qw( gettimeofday usleep time ); -use Data::Dumper; -use Hmon; -use QA; -use LWP::Simple; -use JSON qw( decode_json ); -use POSIX qw/floor ceil strftime/; -use lib '.'; -use getebjson; -use Storable qw(lock_store lock_retrieve); -use HADES::TrbNet; -use List::Util qw[min max]; - - -my $fqa = QA::OpenQAFile(); -trb_init_ports() or die trb_strerror(); - - - - my $data = getjsonhash('eb', 'Master/BNET/get.json'); - unless($data->{Inputs}{value}) {sleep 5; next;} - - - - my $store; - my $newstore; - my $storefile = '/dev/shm/hmon_calibrationinformation.store'; - if (-e $storefile) { - $store = lock_retrieve($storefile); - } -# print Dumper $store; - my ($min,$max) = (0,0); -# print "Read\n"; - - my $temp = trb_register_read(0xffff,0); - foreach my $b (keys %{$temp}) { - if(($b&0xF000) == 0x7000 || ($b&0xFF00) == 0x6000 || ($b&0xFF00) == 0x5000 ) { - my $t = (($temp->{$b}>>20)&0xFFF)/16.; - $newstore->{boards}{$b} = $t; - if($store->{boards}) { - next unless $store->{boards}{$b}; - if ($t - $store->{boards}{$b} > $max) { - $max = $t - $store->{boards}{$b}; - } - if ($t - $store->{boards}{$b} < $min) { - $min = $t - $store->{boards}{$b}; - } - } - } - } - - - if(!$store->{boards} || $data->{LastCalibr}{'time'} != $store->{LastCalibr}) { - $newstore->{LastCalibr} = $data->{LastCalibr}{'time'}; - lock_store($newstore,$storefile); - print "Writing\n"; - } - - my $timesincecalib = time() - ($data->{LastCalibr}{'time'}); - my $txt = strftime("%d.%m. %H:%M",localtime($data->{LastCalibr}{'time'})); - my $longtext = "Last Calibration was done at ".$txt; - $longtext .= sprintf(". Temperature changed in the interval of %.1f to %.1f degrees.",$min,$max); - my $status = max(QA::GetQAState('below',$timesincecalib,@QA::TdcCalibrationInterval), - QA::GetQAState('below',max(-$min,$max),@QA::TdcCalibrationTemperature) - ); - - #print qx("ls /home/hadaq/oper/*/*.cal -lah --time-style=long-iso") - my $ls_out = `ls /home/hadaq/oper/*/*.cal -lah --time-style=long-iso`; - my @ls_out_list = split("\n",$ls_out); - #print $ls_out; - -################ comparing timestamps ############ - -my $calib_file_epochs; - - for my $i (@ls_out_list) { - $i =~ m/^\S+\s+\S\s+\S+\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)/; - - my $date = $1; - my $time = $2; - my $fname = $3; - $fname =~ m%/local(\S+).cal$%; - my $addr = eval("0x".$1); - - $date =~/(\d\d\d\d)-(\d\d)-(\d\d)/; - my $year = $1; - my $month = $2; - my $day = $3; - - $time =~/(\d\d):(\d\d)/; - my $hours = $1; - my $minutes = $2; - - my $dt = DateTime->new( - year => $year, - month => $month, - day => $day, - hour => $hours, - minute => $minutes, - ); - $dt->set_time_zone( 'Europe/Berlin' ); - - my $epoch = $dt->epoch; - #my $epoch = timelocal(0,$minutes,$hours,$day,$month,$year); - #print $i."\n"; - #printf("%s %s %s\n", $date, $time, $addr); - #printf("%s-%s-%s %s:%s\n", $year, $month, $day, $hours, $minutes); - #print $epoch."\n"; - - $calib_file_epochs->{$addr} = $epoch; - - } - - my $max_calib_epoch_diff = 120; #seconds - - - my $all_calib_files_fresh = 1; - - foreach my $b (keys %{$temp}) { - if(($b&0xF000) == 0x7000 || ($b&0xFF00) == 0x6000 || ($b&0xFF00) == 0x5000 ) { - #print "temp: $b"; - - if ( $calib_file_epochs->{$b}){ - # print " calib exists "; - #print " epoch diff "; - #print $calib_file_epochs->{$b}; - #print " - "; - #print $data->{LastCalibr}{'time'}; - #print " = "; - #print $calib_file_epochs->{$b} - $data->{LastCalibr}{'time'}; - if (abs($calib_file_epochs->{$b} - $data->{LastCalibr}{'time'}) <$max_calib_epoch_diff){ - #printf("calib file exists for 0x%x and is fresh\n",$b); - } else { - printf("calib file exists for 0x%x but is not fresh\n",$b); - $all_calib_files_fresh = 0; - } - - - } else { - printf("calib file not found for 0x%x \n",$b); - $all_calib_files_fresh = 0; - - } - - } - } - - - if($all_calib_files_fresh == 1){ - print "\n\n calibration okay\n"; - } else { - print "\n\n calibration NOT okay\n"; - } - - #QA::WriteQALog($fqa,"misc","calib",240,$status,'Last TDC Calib',$txt,$longtext); - - - - #sleep 10; diff --git a/hmon/test/hmon_spill_epics.pl b/hmon/test/hmon_spill_epics.pl deleted file mode 100755 index 677a7a9..0000000 --- a/hmon/test/hmon_spill_epics.pl +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/perl -w - -use warnings; -use Time::HiRes qw(usleep); -use List::Util qw(min max); -use strict; -use Data::Dumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -use Perl2Epics; - -my $lastspill = 1; -my $evtrate = 0; -my $events = 0; -my $spilllength = 0; -my $lastres = 0; -my $midlastres = 0; -my $outofspill = 0; -my @spills; -my $spillavgshort = 0; -my $spillavglong = 0; -my $errtime = 0; -my $lastspillcount = 0; -my $countnochange = 0; - -my $plot = (); -$plot->{name} = "EvtsPerSpill"; -$plot->{file} = "files/EvtsPerSpill"; -$plot->{entries} = 40; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = ""; -$plot->{xlabel} = "Spill Number"; -$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@@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("EvtsPerSpill",$str); - -my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; -my $lastqa = 0; - -trb_init_ports() or die trb_strerror(); - -Perl2Epics::Connect("prefix", "HAD:eb01:prefix",'DBR_TIME_STRING'); - -while (1) { - my $trbneterr = 0; - my $rh_result = trb_register_read(QA::CTSAddress, 0xa002) or $trbneterr = 1; #sleep 5 and next; - my $stopped = trb_register_read(0x3,0xa0c0) or sleep 5 and next; - $stopped = ($stopped->{3} || 0) & 0x400; - -# my $sc = trb_register_read(0x3830,0xc00d); -# if(!defined $sc) { -# sleep 10; -# next; -# } -# my $spillcount = $sc->{0x3830} & 0x00ffffff; -# my $inspill = ($sc->{0x3830} & 0x80000000) >> 31; - my $spillcount = 0; - my $inspill = 0; - - $lastspill = $outofspill; - $outofspill = ($rh_result->{QA::CTSAddress} || 0) & 0x10; - $spilllength++ ; #if($outofspill); - $rh_result = trb_register_read(0x0002, 0x01) or $trbneterr = 1; #sleep 5 and next; - - if($trbneterr == 0) { - my $res = $rh_result->{0x0002} & 0xffff; - $evtrate = $res >= $lastres ? $res - $lastres : ($res + 2**16) - $lastres; - $events += $evtrate; - $midlastres = $res; - usleep(500000); - - $rh_result = trb_register_read(0x0002, 0x01) or $trbneterr = 1; #sleep 5 and next; - $res = $rh_result->{0x0002} & 0xffff; - my $evtrate2 = $res >= $midlastres ? $res - $midlastres : ($res + 2**16) - $midlastres; - $events += $evtrate2; - $evtrate += $evtrate2; - # When end of spill is detected... - my $qastate; - my $qashort; - my $qalong; - - - - if ($outofspill && !$lastspill) { - push(@spills, $events); - shift(@spills) if scalar @spills > 50; - - $spillavglong = 0; - $spillavglong += $_ for @spills; - $spillavglong /= scalar @spills; - - $spillavgshort = 0; - for ( my $i=-1; $i>=-10; $i--) { - $spillavgshort += $spills[$i] || 0; - } - $spillavgshort /= (scalar @spills < 10)?(scalar @spills):10; - - $qashort = QA::SciNotation($events)." (".$spilllength."s)"; - $qastate = min($lastqa,QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill)); - $lastqa = QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill); - $qalong = sprintf("current spill: %s - 10-spill avg. %s - 50-spill avg. %s - Spill length %is", - QA::SciNotation($events), - QA::SciNotation($spillavgshort), - QA::SciNotation($spillavglong), - $spilllength); - QA::WriteQALog($fqa,"trg", "spill", 30, $qastate, "Spill Sum", - $qashort, $qalong); - HPlot::PlotAdd("EvtsPerSpill",$events/1E3); - HPlot::PlotDraw("EvtsPerSpill"); - $events = 0; - $spilllength = 0; - } elsif ($spilllength > 20) { - QA::WriteQALog($fqa, "trg", "spill", 30, QA::NOTE, "Spill Sum", - "No Spills", "No Spills detected at the moment"); - #print $spilllength."\n" unless $spilllength%10; - if($spilllength >= 25 && ($spilllength%25 == 0)) { - my $data = Perl2Epics::GetAll(); - print STDERR $data->{'prefix'}->{val}."\n"; - if(($data->{'prefix'}->{val} eq '-1') || ($data->{'prefix'}->{val} eq 'be')) { - Hmon::Speak('nobeam', "No beam"); - } - } - } - - $qashort = sprintf(" %i ", $evtrate); - $qastate = QA::OK; - - ################Remove after comics or adjust! - if (($evtrate <= 200 || $evtrate >= 80000) && $errtime<20){ - $errtime++; - } - elsif ($errtime > 1) { - $errtime-=4; - } - $qastate = QA::WARN if $errtime > 10; - ##################### - - $qastate = QA::ERROR if $evtrate <= 1 && $stopped == 0; - $qastate = QA::WARN_2 if $stopped; - - $qalong = sprintf("current: %i Events/second", $evtrate); - QA::WriteQALog($fqa, "main", "rate", 5, $qastate, "Current Rate", - $qashort, $qalong); - - my $spillcountstate = QA::OK; - if ($countnochange > 15) {$spillcountstate = QA::WARN;} - QA::WriteQALog($fqa, "daq", "spillcount", 5, $spillcountstate, "Spill Count", - $spillcount,"Number of spills: $spillcount" ); - if($lastspillcount == $spillcount) { - $countnochange++; - } - else { - $countnochange = 0; - } - $lastspillcount = $spillcount; - $lastres = $res; - usleep(500000); - } else { - QA::WriteQALog($fqa, "main", "rate", 30, QA::ERROR, "Current Rate", "N/A", "N/A"); - QA::WriteQALog($fqa,"trg", "spill", 30, QA::ERROR, "Spill Sum","N/A", "N/A"); - $events = 0; - $spilllength = 0; - sleep(10); - } -} diff --git a/hmon/test/hmon_spill_json.pl b/hmon/test/hmon_spill_json.pl deleted file mode 100755 index 5399ebe..0000000 --- a/hmon/test/hmon_spill_json.pl +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/perl -w - -use warnings; -use Time::HiRes qw(usleep); -use List::Util qw(min max); -use strict; -use Data::Dumper; -use Hmon; -use QA; -use HADES::TrbNet; -use HPlot; -#use Perl2Epics; -use LWP::Simple; - -my $opt_debug = 0; - -my $lastspill = 1; -my $evtrate = 0; -my $events = 0; -my $spilllength = 0; -my $lastres = 0; -my $midlastres = 0; -my $outofspill = 0; -my @spills; -my $spillavgshort = 0; -my $spillavglong = 0; -my $errtime = 0; -my $lastspillcount = 0; -my $countnochange = 0; - -my $plot = (); -$plot->{name} = "EvtsPerSpill"; -$plot->{file} = "files/EvtsPerSpill"; -$plot->{entries} = 40; -$plot->{type} = HPlot::TYPE_HISTORY; -$plot->{output} = HPlot::OUT_PNG; -$plot->{titles}->[0] = ""; -$plot->{xlabel} = "Spill Number"; -$plot->{ylabel} = "Recorded Events / Spill (1000)"; -$plot->{sizex} = 630; -$plot->{sizey} = 220; -$plot->{nokey} = 1; -$plot->{storable} = 1; -HPlot::PlotInit($plot) unless $opt_debug; -my $str = Hmon::MakeTitle(8,5,"Recorded Events per Spill (1000)",0); - $str .= qq@@; - $str .= Hmon::MakeFooter(); - Hmon::WriteFile("EvtsPerSpill",$str); - -my $fqa = QA::OpenQAFile() or die "No connection to QA Logfile"; -my $lastqa = 0; - -trb_init_ports() or die trb_strerror(); - -#Perl2Epics::Connect("prefix", "HAD:eb01:prefix",'DBR_TIME_STRING'); -# JAM28-9-2018 replace epics by dabc url access -my $masterurl = 'http://lxhadeb07:8099/'; -my $url_prefix = $masterurl . 'Master/BNET/RunPrefix/get.json?field="value"'; - - - -while (1) { - my $trbneterr = 0; - my $rh_result = trb_register_read(QA::CTSAddress, 0xa002) or $trbneterr = 1; #sleep 5 and next; - my $stopped = trb_register_read(0x3,0xa0c0) or sleep 5 and next; - $stopped = ($stopped->{3} || 0) & 0x400; - -# my $sc = trb_register_read(0x3830,0xc00d); -# if(!defined $sc) { -# sleep 10; -# next; -# } -# my $spillcount = $sc->{0x3830} & 0x00ffffff; -# my $inspill = ($sc->{0x3830} & 0x80000000) >> 31; - my $spillcount = 0; - my $inspill = 0; - - $lastspill = $outofspill; - $outofspill = ($rh_result->{QA::CTSAddress} || 0) & 0x10; - $spilllength++ ; #if($outofspill); - $rh_result = trb_register_read(0x0002, 0x01) or $trbneterr = 1; #sleep 5 and next; - - if($trbneterr == 0) { - my $res = $rh_result->{0x0002} & 0xffff; - $evtrate = $res >= $lastres ? $res - $lastres : ($res + 2**16) - $lastres; - $events += $evtrate; - $midlastres = $res; - usleep(500000); - - $rh_result = trb_register_read(0x0002, 0x01) or $trbneterr = 1; #sleep 5 and next; - $res = $rh_result->{0x0002} & 0xffff; - my $evtrate2 = $res >= $midlastres ? $res - $midlastres : ($res + 2**16) - $midlastres; - $events += $evtrate2; - $evtrate += $evtrate2; - # When end of spill is detected... - my $qastate; - my $qashort; - my $qalong; - - - - if ($outofspill && !$lastspill) { - push(@spills, $events); - shift(@spills) if scalar @spills > 50; - - $spillavglong = 0; - $spillavglong += $_ for @spills; - $spillavglong /= scalar @spills; - - $spillavgshort = 0; - for ( my $i=-1; $i>=-10; $i--) { - $spillavgshort += $spills[$i] || 0; - } - $spillavgshort /= (scalar @spills < 10)?(scalar @spills):10; - - $qashort = QA::SciNotation($events)." (".$spilllength."s)"; - $qastate = min($lastqa,QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill)); - $lastqa = QA::GetQAState('above', "$events", @QA::LimitTriggerPerSpill); - $qalong = sprintf("current spill: %s - 10-spill avg. %s - 50-spill avg. %s - Spill length %is", - QA::SciNotation($events), - QA::SciNotation($spillavgshort), - QA::SciNotation($spillavglong), - $spilllength); - QA::WriteQALog($fqa,"trg", "spill", 30, $qastate, "Spill Sum", - $qashort, $qalong) unless $opt_debug>0; - HPlot::PlotAdd("EvtsPerSpill",$events/1E3) unless $opt_debug>0; - HPlot::PlotDraw("EvtsPerSpill") unless $opt_debug>0; - $events = 0; - $spilllength = 0; - } elsif ($spilllength > 20) { - QA::WriteQALog($fqa, "trg", "spill", 30, QA::NOTE, "Spill Sum", - "No Spills", "No Spills detected at the moment") unless $opt_debug>0;; - #print $spilllength."\n" unless $spilllength%10; - if($spilllength >= 25 && ($spilllength%25 == 0)) { - # my $data = Perl2Epics::GetAll(); - # print STDERR $data->{'prefix'}->{val}."\n"; -# if(($data->{'prefix'}->{val} eq '-1') || ($data->{'prefix'}->{val} eq 'be')) { -# Hmon::Speak('nobeam', "No beam"); -# } - my $prefix = get ($url_prefix); - print Dumper $prefix; - $prefix = "--" unless defined $prefix; - if(($prefix eq '-1') || ($prefix eq 'be')) { - Hmon::Speak('nobeam', "No beam") unless $opt_debug>0; - } - - } - } - - $qashort = sprintf(" %i ", $evtrate); - $qastate = QA::OK; - - ################Remove after comics or adjust! - if (($evtrate <= 200 || $evtrate >= 80000) && $errtime<20){ - $errtime++; - } - elsif ($errtime > 1) { - $errtime-=4; - } - $qastate = QA::WARN if $errtime > 10; - ##################### - - $qastate = QA::ERROR if $evtrate <= 1 && $stopped == 0; - $qastate = QA::WARN_2 if $stopped; - - $qalong = sprintf("current: %i Events/second", $evtrate); - QA::WriteQALog($fqa, "main", "rate", 5, $qastate, "Current Rate", - $qashort, $qalong) unless $opt_debug>0; - - my $spillcountstate = QA::OK; - if ($countnochange > 15) {$spillcountstate = QA::WARN;} - QA::WriteQALog($fqa, "daq", "spillcount", 5, $spillcountstate, "Spill Count", - $spillcount,"Number of spills: $spillcount" ) unless $opt_debug>0; - if($lastspillcount == $spillcount) { - $countnochange++; - } - else { - $countnochange = 0; - } - $lastspillcount = $spillcount; - $lastres = $res; - print "debug: short:$qashort long:$qalong, spillcount:$spillcount\n" unless $opt_debug==0; - usleep(500000); - - } else { - QA::WriteQALog($fqa, "main", "rate", 30, QA::ERROR, "Current Rate", "N/A", "N/A") unless $opt_debug>0; - QA::WriteQALog($fqa,"trg", "spill", 30, QA::ERROR, "Spill Sum","N/A", "N/A") unless $opt_debug>0; - $events = 0; - $spilllength = 0; - print "debug: spill and rate N/At\n" unless $opt_debug==0; - sleep(10); - } -} diff --git a/hodo/set_threshold_hodo.sh b/hodo/set_threshold_hodo.sh index b119654..87e6d6f 100755 --- a/hodo/set_threshold_hodo.sh +++ b/hodo/set_threshold_hodo.sh @@ -1,6 +1,6 @@ export PERL5LIB="$HOME/trbsoft/daqtools/perllibs" cd ~/trbsoft/daq/hodo/thresholds -~/trbsoft/daqtools/thresholds/write_thresholds.pl thresholds_HODO.txt --offset=-100 +~/trbsoft/daqtools/thresholds/write_thresholds.pl thresholds_HODO.txt --offset=100 ~/trbsoft/daqtools/padiwa.pl 0x5010 0 invert 0xffff ~/trbsoft/daqtools/padiwa.pl 0x5010 1 invert 0xffff ~/trbsoft/daqtools/padiwa.pl 0x5011 0 invert 0xffff diff --git a/hub/register_configgbe_ip_2021-test-mdconlytwoebs.db b/hub/register_configgbe_ip_2021-test-mdconlytwoebs.db index 31c1cc8..2a76c66 100644 --- a/hub/register_configgbe_ip_2021-test-mdconlytwoebs.db +++ b/hub/register_configgbe_ip_2021-test-mdconlytwoebs.db @@ -161,16 +161,16 @@ 0x1130 0 0xc670 0xdead1130 0xc0a86499 0xc670 0xc0a86409 0 # mdc - lxhadeb09 0x1140 0 0xc66B 0xdead1140 0xc0a8649A 0xc66B 0xc0a86409 0 # mdc - lxhadeb09 - moved 0x1150 0 0xc669 0xdead1150 0xc0a8649B 0xc669 0xc0a86409 0 # mdc - lxhadeb09 - JAM21 swapped for test - 0x8a00 0 0xc676 0xdead8a00 0xc0a864A6 0xc676 0xc0a8640a 1 # ecal lxhadeb10 - 0x8a01 0 0xc677 0xdead8a01 0xc0a864A7 0xc677 0xc0a8640a 1 # ecal lxhadeb10 - 0x8a02 0 0xc678 0xdead8a02 0xc0a864A8 0xc678 0xc0a8640a 1 # ecal lxhadeb10 - 0x8a03 0 0xc679 0xdead8a03 0xc0a864A9 0xc679 0xc0a8640a 1 # ecal lxhadeb10 + 0x8a00 0 0xc676 0xdead8a00 0xc0a864A6 0xc676 0xc0a8640a 2 # ecal lxhadeb10 + 0x8a01 0 0xc677 0xdead8a01 0xc0a864A7 0xc677 0xc0a8640a 2 # ecal lxhadeb10 + 0x8a02 0 0xc678 0xdead8a02 0xc0a864A8 0xc678 0xc0a8640a 2 # ecal lxhadeb10 + 0x8a03 0 0xc679 0xdead8a03 0xc0a864A9 0xc679 0xc0a8640a 2 # ecal lxhadeb10 # 0x8a00 0 0xc676 0xdead8a00 0xc0a864A6 0xc676 0xc0a86409 1 # ecal- lxhadeb09 # 0x8a01 0 0xc677 0xdead8a01 0xc0a864A7 0xc677 0xc0a86409 1 # ecal- lxhadeb09 # 0x8a02 0 0xc678 0xdead8a02 0xc0a864A8 0xc678 0xc0a86409 1 # ecal- lxhadeb09 # 0x8a03 0 0xc679 0xdead8a03 0xc0a864A9 0xc679 0xc0a86409 1 # ecal- lxhadeb09 - 0x8a04 0 0xc67a 0xdead8a04 0xc0a864AA 0xc67A 0xc0a86972 1 # ecal- lxhadeb14 - 0x8a05 0 0xc67b 0xdead8a05 0xc0a864AB 0xc67B 0xc0a86972 1 # ecal- lxhadeb14 + 0x8a04 0 0xc67a 0xdead8a04 0xc0a864AA 0xc67A 0xc0a86972 2 # ecal- lxhadeb14 + 0x8a05 0 0xc67b 0xdead8a05 0xc0a864AB 0xc67B 0xc0a86972 2 # ecal- lxhadeb14 0x83c0 0 0xc67c 0xdead83c0 0xc0a864AC 0xc67C 0xc0a86972 11 # rich lxhadeb14 0x83c1 0 0xc67d 0xdead83c1 0xc0a864AD 0xc67D 0xc0a86972 11 # rich lxhadeb14 0x83c2 0 0xc67e 0xdead83c2 0xc0a864AE 0xc67E 0xc0a86972 11 # rich lxhadeb14 @@ -196,8 +196,8 @@ 0x86c2 0 0xc692 0xdead86c2 0xc0a864C2 0xc692 0xc0a8640A 2 # tof hub 2 lxhadeb10 0x86c3 0 0xc693 0xdead86c3 0xc0a864C3 0xc693 0xc0a8690B 2 # tof hub 3 lxhadeb11 0x86c4 0 0xc694 0xdead86c4 0xc0a864C4 0xc694 0xc0a8690B 2 # tof hub 4 lxhadeb11 - 0x86c5 0 0xc695 0xdead86c5 0xc0a864C5 0xc695 0xc0a8690E 2 # tof hub 5 lxhadeb14 - 0x86c6 0 0xc696 0xdead86c6 0xc0a864C6 0xc696 0xc0a8690E 2 # tof hub 6 lxhadeb14 + 0x86c5 0 0xc695 0xdead86c5 0xc0a864C5 0xc695 0xc0a86972 2 # tof hub 5 lxhadeb14 + 0x86c6 0 0xc696 0xdead86c6 0xc0a864C6 0xc696 0xc0a86972 2 # tof hub 6 lxhadeb14 0x8b00 0 0xc6B0 0xdead8b00 0xc0a864D0 0xc6B0 0xc0a86973 2 # STS1 0 lxhadeb15 0x8b01 0 0xc6B1 0xdead8b01 0xc0a864D1 0xc6B1 0xc0a86973 2 # STS1 1 lxhadeb15 0x8b02 0 0xc6B2 0xdead8b02 0xc0a864D2 0xc6B2 0xc0a86973 2 # STS1 2 lxhadeb15 diff --git a/main/data_sources.db b/main/data_sources.db index b315cc0..58e89be 100644 --- a/main/data_sources.db +++ b/main/data_sources.db @@ -5,12 +5,12 @@ 0x8800 1 CentralCTS low 0x8880 1 StartTRB3 low 0x8890 1 Veto mid -0x84c0 1 RPCnew1 mid -0x84c1 1 RPCnew2 mid -0x84c2 1 RPCnew3 mid -0x84c3 1 RPCnew4 mid -0x84c4 1 RPCnew5 mid -0x84c5 1 RPCnew6 mid +0x84c0 0 RPCnew1 mid +0x84c1 0 RPCnew2 mid +0x84c2 0 RPCnew3 mid +0x84c3 0 RPCnew4 mid +0x84c4 0 RPCnew5 mid +0x84c5 0 RPCnew6 mid 0x86c0 1 TOFnew1 mid 0x86c1 1 TOFnew2 mid 0x86c2 1 TOFnew3 mid @@ -44,7 +44,7 @@ 0x83c3 1 RICH3 mid 0x83c4 1 RICH4 mid 0x83c5 1 RICH5 mid -0x83c6 1 RICH6 mid +0x83c6 0 RICH6 mid 0x83c7 1 RICH7 mid 0x83c8 1 RICH8 mid 0x83c9 1 RICH9 mid @@ -62,4 +62,4 @@ 0x8b15 1 STS2-5 mid 0x8c00 1 FRPC-0 mid 0x8c10 1 FRPC-1 mid -0x8d00 1 ITOF mid +0x8d00 0 ITOF mid diff --git a/main/startup_briccolage.sh b/main/startup_briccolage.sh index 158ecbc..2c34007 100755 --- a/main/startup_briccolage.sh +++ b/main/startup_briccolage.sh @@ -60,8 +60,8 @@ trbcmd w 0x1031 0xc3 0xfbf #Disable failing boards ###switchport.pl 0x1104 2 off #2309 , didn't like spike rejection 0x10 (means off), mt 2021.02.14 switchport.pl 0x1101 4 off #2203, 02.02.22 -switchport.pl 0x1024 7 off #2027, 04.02.22 -switchport.pl 0x1023 8 off #2057, 04.02.22 +switchport.pl 0x1024 7 off #2057, 04.02.22 +switchport.pl 0x1023 8 off #2027, 04.02.22 diff --git a/nettools/Perl2Epics.pm b/nettools/Perl2Epics.pm index 043bb52..90ce2f2 100644 --- a/nettools/Perl2Epics.pm +++ b/nettools/Perl2Epics.pm @@ -16,7 +16,7 @@ use CA; $ENV{EPICS_CA_AUTO_ADDR_LIST} = 'NO'; #JoF2022: updated during beamtime -$ENV{EPICS_CA_ADDR_LIST} = "lxhadeb07p frpcpid1 lxhaddcs05p lxhaddcs06p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p gas.hades.gsi.de richhvcrate"; +$ENV{EPICS_CA_ADDR_LIST} = "cryo1.hades.gsi.de lxhadeb07p frpcpid1 lxhaddcs05p lxhaddcs06p lxhaddcs10p lxhaddcs11p lxhaddcs12p lxhaddcs13p gas.hades.gsi.de richhvcrate"; # $ENV{EPICS_CA_ADDR_LIST} = "192.168.111.255"; #$ENV{EPICS_CA_ADDR_LIST} = "192.168.103.182 192.168.100.235 192.168.100.236 192.168.97.10 192.168.97.11 192.168.97.14 192.168.97.15 192.168.100.17 192.168.97.4 192.168.100.216"; @@ -26,9 +26,9 @@ $ENV{EPICS_CA_ADDR_LIST} = "lxhadeb07p frpcpid1 lxhaddcs05p lxhaddcs06p lxhaddcs #$ENV{EPICS_CA_ADDR_LIST} = "192.168.103.83:10000 192.168.103.83:10008 192.168.103.83:10003 192.168.103.83:10002 192.168.111.255:10001"; #$ENV{EPICS_CA_ADDR_LIST} = "192.168.103.83 192.168.103.83:10012 192.168.103.83:10008 192.168.103.83:10003 192.168.103.83:10002 192.168.103.83:10001 192.168.103.83:10014 192.168.103.83:10007 192.168.103.83:10004 192.168.103.83:10010 192.168.103.83:10013 192.168.103.83:10015 192.168.103.83:10016 192.168.103.83:10009 192.168.103.83:10005 192.168.103.83:10011 192.168.103.83:10006 localhost"; -#hotfix PZ 2022-02-08 -# $ENV{EPICS_CA_ADDR_LIST} = "192.168.111.255"; -# $ENV{EPICS_CA_AUTO_ADDR_LIST} = 'NO'; +#hotfix PZ 2022-02-14 +#$ENV{EPICS_CA_ADDR_LIST} = "192.168.111.255"; +#$ENV{EPICS_CA_AUTO_ADDR_LIST} = 'NO'; # # JAM added fixed port numbers of EB epics diff --git a/nettools/revivedirich.pl b/nettools/revivedirich.pl index 69983f6..d16e74b 100755 --- a/nettools/revivedirich.pl +++ b/nettools/revivedirich.pl @@ -183,11 +183,13 @@ foreach my $h (@boardstoloadthresh) { #start trigger -print("Done. Starting trigger again\n"); +print("Starting trigger again\n"); trb_register_write(0xfe52,0xc0,0xffff); - system("trbcmd clearbit 0x0003 0xa0c0 0x400"); +print("Done.\n"); + + chop $msg; chop $msg; system("logger -p local1.info -t DAQ 'RICH Re-Included DiRich to DAQ: $msg'"); diff --git a/oracle/boards.txt b/oracle/boards.txt index 73318ef..8b3efd0 100644 --- a/oracle/boards.txt +++ b/oracle/boards.txt @@ -12,6 +12,7 @@ TRB3sc 1611 d100000940938628 8000 TRB3sc 1051 8400000941031228 6015 TRB3sc 1061 b300000941031328 6016 + TRB3sc 1071 b000000940ce5228 6013 TRB3sc 1081 cd00000940ce5e28 6022 TRB3sc 1091 3500000940ce5528 6021 TRB3sc 1101 fc00000940ce6a28 6025 @@ -24,20 +25,18 @@ TRB3sc 1181 49000009409d6828 6020 TRB3sc 1191 7100000940c28d28 6053 TRB3sc 1201 c100000940c29828 6042 - TRB3sc 1211 4600000940c28c28 6013 TRB3sc 1221 0c00000940c28128 6050 TRB3sc 1231 3b00000940c28028 6012 - TRB3sc 1241 7d00000940880b28 6046 TRB3sc 1251 b1000009409d6328 6043 TRB3sc 1261 0200000940881428 6056 TRB3sc 1321 6f00000940a61528 6055 - TRB3sc 1331 ea00000940a61228 6045 TRB3sc 1401 6d00000940a60628 6026 TRB3sc 1511 4400000940954f28 6054 TRB3sc 1541 1a0000094093aa28 6023 TRB3sc 1591 7200000940939d28 6014 TRB3sc 1651 ce0000094117f228 6011 TRB3sc 3051 b600000a63054c28 6051 + TRB3sc 3091 0a00000a63061828 6045 TRB3sc 3111 5100000a63052328 6030 TRB3sc 3121 2a00000a63051a28 6031 TRB3sc 3131 9900000a627d9d28 6032 @@ -45,6 +44,7 @@ TRB3sc 3221 a000000a624b3128 6035 TRB3sc 3231 8900000a63050128 6034 TRB3sc 3241 2200000a625a1628 6033 + TRB3sc 4631 d7000003480c4728 6046 TRB3sc 91 f1000006e919a128 8a01 TRB3sc 1281 0d00000940876f28 8a03 TRB3sc 1291 9a00000940a5da28 8a05 @@ -443,7 +443,7 @@ TRB3sc 2061 a700000a628ec628 5837 TRB3sc 2071 a800000a62955028 5833 TRB3sc 2091 1800000a631ed228 5854 - TRB3sc 2101 bd00000a627d9228 5826 + TRB3sc 2101 4800000a628ee528 5826 TRB3sc 2111 e000000a62e97628 5822 TRB3sc 2121 e900000a62442d28 5810 TRB3sc 2131 9400000a63057628 5843 @@ -635,6 +635,7 @@ DiRich 1199 e700000a49f34c28 7067 DiRich 1200 e600000a49bc5828 7160 DiRich 1202 b800000bb6d00828 7904 + DiRich 1203 c900000bb6cf6028 7392 DiRich 1209 b400000bb6cf6c28 7814 DiRich 1211 d900000bb732ad28 7805 DiRich 1214 6900000bb754f328 7905 @@ -820,10 +821,14 @@ DiRichConcentrator 109 6800000a5236b428 8266 TRB3 1545 9e0000070ee47628 8b15 TRB3 1555 360000070f366e28 8b11 TRB3 1575 b90000070f3dd528 8b14 - TRB3sc 4051 0c00000348060928 5002 - TRB3sc 4071 eb000003480c9c28 5003 - TRB3sc 4091 5a00000347f16228 5001 - TRB3sc 4391 d5000003480c5428 5000 + TRB3sc 3341 b4000005b75b9428 5007 + TRB3sc 3401 83000005b75b9528 5001 + TRB3sc 3421 f2000005b7bd9428 5002 + TRB3sc 3441 55000005b7bda928 5003 + TRB3sc 4241 8e000003480c4428 5004 + TRB3sc 4331 8a00000347f33e28 5005 + TRB3sc 4341 e600000347fe9a28 5006 + TRB3sc 4411 5900000347efe328 5000 TRB3sc 4121 3e000003480c5128 8880 TRB3 60 b5000003482d3d28 5c20 TRB3 61 d5000003481eef28 5c21 @@ -841,10 +846,10 @@ DiRichConcentrator 109 6800000a5236b428 8266 TRB3 2421 6500000812740e28 5c31 TRB3 2422 d2000008135a6628 5c32 TRB3 2423 4b00000813706228 5c33 - TRB3 2640 5900000943ba5c28 5c10 - TRB3 2641 e700000943aab928 5c11 - TRB3 2642 fe00000943ba6128 5c12 - TRB3 2643 1f00000943aab228 5c13 + TRB3 2620 5b00000941731428 5c10 + TRB3 2621 ec0000094176cc28 5c11 + TRB3 2622 3400000941728a28 5c12 + TRB3 2623 070000094176c928 5c13 TRB3 2650 e900000943803128 5c40 TRB3 2651 a700000943801a28 5c41 TRB3 2652 3700000943802628 5c42 @@ -853,7 +858,7 @@ DiRichConcentrator 109 6800000a5236b428 8266 TRB3 885 650000031321c728 86c0 TRB3 945 81000004fa286228 86c5 TRB3 2425 22000008135a2128 86c3 - TRB3 2645 6200000943aabe28 86c1 + TRB3 2625 3c000009416b9e28 86c1 TRB3 2655 6e00000943802528 86c4 TRB3 1275 9c000005ed716028 8890 TRB3 740 6800000313245528 6710 @@ -871,20 +876,20 @@ DiRichConcentrator 109 6800000a5236b428 8266 TRB3 745 010000031323a828 8701 TRB3 2665 cf000009438ad728 8702 TRB3 2675 de00000942671628 8700 - TRB3 2370 1800000813703e28 6800 - TRB3 2371 a200000813a78828 6801 - TRB3 2372 40000008123d4328 6802 - TRB3 2373 94000008123e2028 6803 - TRB3 2440 7000000943e2eb28 6810 - TRB3 2441 6100000943e2f628 6811 - TRB3 2442 7600000943e2de28 6812 - TRB3 2443 4700000943e2ea28 6813 - TRB3 2375 fc000008123d3c28 8c00 - TRB3 2445 3900000943b1c428 8c10 + TRB3 2380 6000000942823628 6810 + TRB3 2381 2a00000942823b28 6811 + TRB3 2382 1e0000094285e328 6812 + TRB3 2383 ad00000942822f28 6813 + TRB3 2610 fd0000094176d128 6800 + TRB3 2611 6500000941758a28 6801 + TRB3 2612 210000094176d528 6802 + TRB3 2613 800000094175f628 6803 + TRB3 2385 470000094285e028 8c10 + TRB3 2615 4300000941759628 8c00 TRB3sc 3371 72000005b6f3e028 5d02 TRB3sc 3381 060000070f046f28 5d00 TRB3sc 3391 fb000005b7443428 5d04 TRB3sc 3411 56000005b7be1428 5d01 - TRB3sc 4081 c200000348068628 5d05 + TRB3sc 3461 64000005b7bd9d28 5d05 TRB3sc 4101 810000034809c528 5d03 TRB3sc 3071 1c00000a62956328 8d00 diff --git a/oracle/collab/collab_fromora_daily.pl b/oracle/collab/collab_fromora_daily.pl new file mode 100755 index 0000000..e93a4bf --- /dev/null +++ b/oracle/collab/collab_fromora_daily.pl @@ -0,0 +1,323 @@ +#!/usr/bin/perl -w +################### +# JAM2022 - cronjob script frequently export hades collaborationfrom oracle +# 13.10-2022 - first version adopted from beamtime statistic scripts + +use English; +use strict; +use Getopt::Long; +use Data::Dumper; +#use Scalar::Util qw(reftype); +use IO::Socket; +use IO::Select; +use FileHandle; +use Time::Local; +use DateTime; +use threads; +use threads::shared; + +use DBI; +use DBD::ODBC; + +my $opt_help = 0; +my $opt_verb = 0; +#my $opt_oracle = 0; + +# JAM optionally change account here: +#my $orauser = 'DAQ_PUB'; +my $orauser = 'HADES_COLLAB'; +my $orapass = 'hades';# real pw is put in invoking script only! +#my $oradatabase = 'db-hades-test'; +my $oradatabase = 'db-hades'; + + + +# JAM real passwords are delivered by command line options now. + + +GetOptions ('h|help' => \$opt_help, + 'v|verb' => \$opt_verb, +# 'o|oracle' => \$opt_oracle, + 'opass=s' => \$orapass, + ); + +if( $opt_help ) { + &help(); + exit(0); +} + + + + + +# JAM here definition of table names +my $oraruns = 'daq.daq_runs'; + +my $ExitCode : shared = -1; +my $status : shared = "OK"; + +#- POSIX signal handlers: see signal(7) or kill(1) for available signals +foreach my $signal ( qw(HUP INT QUIT ILL ABRT FPE SEGV TERM USR1 USR2) ){ + $SIG{$signal} = sub { &finishAndExit( $signal ); }; +} + + +#my $app_logfile = "/home/hadaq/log/collabfromora_daily.log"; + + +#-------- need to explicitely set oracle environment if this was started by icinga restarthandler (not-login ssh!) +$ENV{ORACLE_HOME}='/usr/lib/oracle/12.1/client64'; +$ENV{LD_LIBRARY_PATH}='/usr/lib/oracle/12.1/client64/lib'; + +#-------- Connect the database +#$status = "Try to connect to the Oracle Data Base ..."; +print "Try to connect to the Oracle Data Base ...\n" if($opt_verb); + +#- Disable autocommit and enable error handling +#print "database=$oradatabase, user=$orauser,pass=$orapass \n"; +my $oradbh = DBI->connect( "dbi:Oracle:$oradatabase", $orauser, $orapass, {AutoCommit=>0, RaiseError=>1, 'PrintError'=>1}) + or die "Couldn't connect to oracle database: " . DBI->errstr; +#my $dbh = DBI->connect( "dbi:Oracle:$database", $user,$pass, {AutoCommit=>0}); +print "Oracle Connected!\n" if($opt_verb); +#print Dumper $oradbh; + + + + + + +my $institutes_active_file = "/home/hadaq/oper/collab/institutes-active.csv"; +my $institutes_full_file = "/home/hadaq/oper/collab/institutes_full.csv"; +my $persons_institutes_file = "/home/hadaq/oper/collab/persons_institutes.csv"; +my $persons_roles_file = "/home/hadaq/oper/collab/persons-roles.csv"; + +#exit(0); +# test only connection up to here +#my $beamtime = 'FEB22'; +#my $runtype = 'BEAM'; + + + + + +open( OUTFILE_INST, '>', $institutes_active_file ) or die "Could not open $institutes_active_file for writing ! \n"; +&putInstitutesActiveHeader() or die "Failed to write institutes header\n"; +&readInstitutesActive() or die "Failed to access institute tables\n"; + +open( OUTFILE_PERS, '>', $persons_institutes_file ) or die "Could not open $persons_institutes_file for writing ! \n"; +&putPersonsInstitutesHeader() or die "Failed to write persons header\n"; +&readPersonsInstitutes() or die "Failed to access person tables\n"; + +open( OUTFILE_ROLES, '>', $persons_roles_file ) or die "Could not open $persons_roles_file for writing ! \n"; +&putPersonsRolesHeader() or die "Failed to write roles header\n"; +&readPersonsRoles() or die "Failed to access roles tables\n"; + + +open( OUTFILE_FULL, '>', $institutes_full_file ) or die "Could not open $institutes_full_file for writing ! \n"; +&putInstitutesFullHeader() or die "Failed to write institutes full header\n"; +&readInstitutesFull() or die "Failed to access institute full tables\n"; + +#-------- Finish and disconnect +&finishAndDisconnect(); + +close(OUTFILE_INST) || die "Couldn't close file $institutes_active_file properly"; +close(OUTFILE_PERS) || die "Couldn't close file $persons_institutes_file properly"; +close(OUTFILE_ROLES) || die "Couldn't close file $persons_roles_file properly"; +print "Export of HADES collaboration members finished successfully.\n"; +#if ($opt_verb); +exit(0); + + + + + +sub help() +{ + print "\n"; + print << 'EOF'; +collabfromora.pl + + This script exports hades collaboration members from oracle +Usage: + + Command line: collab_fromora_daily.pl + [-h|--help] : Print this help. + [-opass orapass] : Specify password for Oracle database + [-v|--verb] : More verbose. + +Examples: + + Gets run statistics from oracle between previous update and now, and be verbose: + collab_fromora_daily.pl -v -opass + +EOF +} + +sub finishAndDisconnect() +{ + if(defined $oradbh){ + $oradbh->disconnect || die "Failed to disconnect from Oracle\n"; + } +} + +sub finishAndExit() +{ + # don't allow nested signal handling + return if ($ExitCode ne "-1"); + + # this will stop the treads, too + $ExitCode = shift; + + print "collab_fromora_daily.pl exited (signal/exit code: $ExitCode).\n"; + + &finishAndDisconnect(); + + + close(STDOUT); + close(STDERR); + + exit(1); +} + + + + + +#################################################### + + +sub putInstitutesActiveHeader() +{ +# csv does not have comments? JAM +# first provide output file with standard header: +my ($sec, $min, $hr, $day, $mon, $year) = localtime; +my $timestamp= sprintf("%02d.%02d.%04d at %02d:%02d:%02d",$day, $mon + 1, 1900 + $year, $hr, $min, $sec); +# +# +# print OUTFILE_INST "###############################################################################\n"; +# print OUTFILE_INST "# This file was generated from collab_fromora_daily.pl\n"; +# print OUTFILE_INST "# Updated: $timestamp\n"; +# print OUTFILE_INST "# \n"; +print OUTFILE_INST "\"INSTITUTE_ID\", \"INSTITUTE_NAME\", \"ADDRESS\", \"ZIP_CODE\", \"TOWN\" \"COUNTRY\"\n"; +print "Updated institutes active files at $timestamp\n"; +return 1; +} + + +sub readInstitutesActive() +{ +my $orasth_institutes_active = $oradbh->prepare("SELECT DISTINCT a.INSTITUTE_ID, a.INSTITUTE_NAME, b.ADDRESS, b.ZIP_CODE, a.TOWN, a.COUNTRY from ALL_CURRENT_HADES_PEOPLE a left join INSTITUTES b on (a.INSTITUTE_ID=b.ID) order by a.INSTITUTE_ID") or die "Couldn't prepare statement: " . $oradbh->errstr; +$orasth_institutes_active->execute() or die "Couldn't execute statement: " . $orasth_institutes_active; +my $success = 1; +my @data; +while (@data = $orasth_institutes_active->fetchrow_array()) { + print OUTFILE_INST "$data[0], \t\"$data[1]\", \t\"$data[2]\", \t\"$data[3]\", \t\"$data[4]\", \t\"$data[5]\"\n" or die "Could not append output file"; + } + $orasth_institutes_active->finish(); +return $success; +} + + +sub putPersonsInstitutesHeader() +{ +# csv does not have comments? JAM +# first provide output file with standard header: +my ($sec, $min, $hr, $day, $mon, $year) = localtime; +my $timestamp= sprintf("%02d.%02d.%04d at %02d:%02d:%02d",$day, $mon + 1, 1900 + $year, $hr, $min, $sec); +# +# +# print OUTFILE_PERS "###############################################################################\n"; +# print OUTFILE_PERS "# This file was generated from collab_fromora_daily.pl\n"; +# print OUTFILE_PERS "# Updated: $timestamp\n"; +# print OUTFILE_PERS "# \n"; +print OUTFILE_PERS "\"PEOPLE_ID\",\"FAMILY_NAME\",\"FIRST_NAME\",\"INSTITUTE_ID\",\"NAME\",\"SHORT_NAME\",\"COUNTRY\"\n"; +print "Updated people institutes file at $timestamp\n"; +return 1; +} + + +sub readPersonsInstitutes() +{ +#my $orasth_persons_institutes = $oradbh->prepare("SELECT a.PEOPLE_ID, a.INSTITUTE_ID from ALL_CURRENT_HADES_PEOPLE a left join INSTITUTES b on (a.INSTITUTE_ID=b.ID) order by a.PEOPLE_ID") or die "Couldn't prepare statement: " . $oradbh->errstr; + +my $orasth_persons_institutes = $oradbh->prepare("select distinct a.PEOPLE_ID, a.FAMILY_NAME, A.FIRST_NAME, b.INSTITUTE_ID, b.NAME, b.SHORT_NAME, b.COUNTRY from ALL_CURRENT_HADES_PEOPLE a left join LAST_HADES_INSTITUTE b on (a.PEOPLE_ID=b.PEOPLE_ID AND b.NUM_INSTITUTE=1) order by family_name") or die "Couldn't prepare statement: " . $oradbh->errstr; + + + +$orasth_persons_institutes->execute() or die "Couldn't execute statement: " . $orasth_persons_institutes; +my $success = 1; +my @data; +while (@data = $orasth_persons_institutes->fetchrow_array()) { + print OUTFILE_PERS "$data[0], \t$data[1], $data[2], \t$data[3], $data[4], \t$data[5], $data[6]\n" or die "Could not append output file"; + } + $orasth_persons_institutes->finish(); +return $success; +} + + + + +sub putPersonsRolesHeader() +{ +# csv does not have comments? JAM +# first provide output file with standard header: +my ($sec, $min, $hr, $day, $mon, $year) = localtime; +my $timestamp= sprintf("%02d.%02d.%04d at %02d:%02d:%02d",$day, $mon + 1, 1900 + $year, $hr, $min, $sec); +# +# +# print OUTFILE_ROLES "###############################################################################\n"; +# print OUTFILE_ROLES "# This file was generated from collab_fromora_daily.pl\n"; +# print OUTFILE_ROLES "# Updated: $timestamp\n"; +# print OUTFILE_ROLES "# \n"; +print OUTFILE_ROLES "\"PEOPLE_ID\",\"FAMILY_NAME\",\"FIRST_NAME\",\"PEOPLE_ROLE_ID\",\"PEOPLE_ROLE_NAME\",\"CONTACT\" \n"; +print "Updated people roles file at $timestamp\n"; +return 1; +} + + +sub readPersonsRoles() +{ +my $orasth_persons_roles = $oradbh->prepare(" +SELECT DISTINCT a.PEOPLE_ID, a.FAMILY_NAME, a.FIRST_NAME, c.PEOPLE_ROLE_ID, c.PEOPLE_ROLE_NAME, b.CONTACT from ALL_CURRENT_HADES_PEOPLE a left join people_contact b on (a.PEOPLE_ID=b.PEOPLE_ID AND b.CONTACT_TYPE='E') left join PEOPLE_INVOLVEMENT_VIEW c on (a.PEOPLE_ID=c.PEOPLE_ID) order by a.FAMILY_NAME") or die "Couldn't prepare statement: " . $oradbh->errstr; + +$orasth_persons_roles->execute() or die "Couldn't execute statement: " . $orasth_persons_roles; +my $success = 1; +my @data; +while (@data = $orasth_persons_roles->fetchrow_array()) { + + print OUTFILE_ROLES "$data[0], \t\"$data[1]\", \t\"$data[2]\", \t$data[3], \t\"$data[4]\", \t\"$data[5]\"\n" or die "Could not append output file"; + + + } + $orasth_persons_roles->finish(); +return $success; +} + + +sub putInstitutesFullHeader() +{ +# csv does not have comments? JAM +# first provide output file with standard header: +my ($sec, $min, $hr, $day, $mon, $year) = localtime; +my $timestamp= sprintf("%02d.%02d.%04d at %02d:%02d:%02d",$day, $mon + 1, 1900 + $year, $hr, $min, $sec); +print OUTFILE_FULL "\"ID\", \"NAME\",\"NAME_US\",\"SHORT_NAME\",\"COUNTRY\",\"TOWN\",\"TOWN_US\",\"CHARACTER_SET_ID\",\"ZIP_CODE\",\"ADDRESS\",\"PHONE_PREFIX\",\"EMAIL_EXTENSION\",\"HOMEPAGE\",\"LAST_CHANGE\",\"LOCAL_REPRESENTATIVE\",\"ADDRESS_TOWN\" \n" or die "Could not append output file"; + +print "Updated institutes full files at $timestamp\n"; +return 1; +} + + +sub readInstitutesFull() +{ +my $orasth_institutes_full = $oradbh->prepare("SELECT * from INSTITUTES order by ID") or die "Couldn't prepare statement: " . $oradbh->errstr; +$orasth_institutes_full->execute() or die "Couldn't execute statement: " . $orasth_institutes_full; +my $success = 1; +my @data; +while (@data = $orasth_institutes_full->fetchrow_array()) { + print OUTFILE_FULL "$data[0], \"$data[1]\", \"$data[2]\", \"$data[3]\", \"$data[4]\", \"$data[5]\", \"$data[6]\", $data[7], \"$data[8]\", \"$data[9]\", \"$data[10]\" , $data[11]\", \"$data[12]\", $data[13], $data[14] , \"$data[15]\" \n" or die "Could not append output file"; + } + $orasth_institutes_full->finish(); +return $success; +} + + diff --git a/oracle/runstatsfromora_testplot.sh b/oracle/runstatsfromora_testplot.sh index 03f3f80..5006745 100755 --- a/oracle/runstatsfromora_testplot.sh +++ b/oracle/runstatsfromora_testplot.sh @@ -13,9 +13,9 @@ end=1646802000 cat < /tmp/beam_trend.txt # timestamp real propaganda $(date -d @$(($start)) "+%Y-%m-%d %H:%M:%S") 0 0 -$(date -d @$(($breakstart)) "+%Y-%m-%d %H:%M:%S") $((($breakstart-$start)*1960/86400)) $((($breakstart-$start)*1600/86400)) -$(date -d @$(($breakend)) "+%Y-%m-%d %H:%M:%S") $((($breakstart-$start)*1960/86400)) $((($breakstart-$start)*1600/86400)) -$(date -d @$(($end)) "+%Y-%m-%d %H:%M:%S") $((($end-$start+$breakstart-$breakend)*1960/86400)) $((($end-$start+$breakstart-$breakend)*1600/86400)) +$(date -d @$(($breakstart)) "+%Y-%m-%d %H:%M:%S") $((($breakstart-$start)*1650/86400)) $((($breakstart-$start)*1450/86400)) +$(date -d @$(($breakend)) "+%Y-%m-%d %H:%M:%S") $((($breakstart-$start)*1650/86400)) $((($breakstart-$start)*1450/86400)) +$(date -d @$(($end+25000)) "+%Y-%m-%d %H:%M:%S") $((($end-$start+$breakstart-$breakend)*1650/86400)) $((($end-$start+$breakstart-$breakend)*1450/86400)) EOF #1.6 million per day nominal + 10% due to PT2 @@ -30,14 +30,14 @@ $(date -d @$(($breakstart-1)) "+%Y-%m-%d %H:%M:%S") 0 0 $(date -d @$(($breakstart)) "+%Y-%m-%d %H:%M:%S") 50000 0 $(date -d @$(($breakend)) "+%Y-%m-%d %H:%M:%S") 50000 0 $(date -d @$(($breakend+1)) "+%Y-%m-%d %H:%M:%S") 0 0 -$(date -d @$(($end-1)) "+%Y-%m-%d %H:%M:%S") 0 0 -$(date -d @$(($end)) "+%Y-%m-%d %H:%M:%S") 50000 0 +$(date -d @$(($end+25000)) "+%Y-%m-%d %H:%M:%S") 0 0 +$(date -d @$(($end+25001)) "+%Y-%m-%d %H:%M:%S") 50000 0 $(date -d @$(($end+1000000)) "+%Y-%m-%d %H:%M:%S") 50000 0 EOF gnuplot -p <{"ECALLV_Power"}->{val}."\n"; print "turned off. Wait 8 seconds\n"; sleep 8; Perl2Epics::Put("ECALLV_Power",0); #On +Perl2Epics::Update(0.2); print "turned on. You can continue!\n"; sleep 1; diff --git a/utils/HUB_Powercycle.pl b/utils/HUB_Powercycle.pl index a69f1ab..007581a 100755 --- a/utils/HUB_Powercycle.pl +++ b/utils/HUB_Powercycle.pl @@ -8,11 +8,20 @@ use Data::Dumper; print "Connect..\n"; my $s = "HAD:LV:PS:16:SETONOFF"; -Perl2Epics::Connect("RICHLV_PowerOnOff",$s); +my $ret = Perl2Epics::Connect("RICHLV_PowerOnOff",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} +print "Connected\n"; Perl2Epics::Put("RICHLV_PowerOnOff",1); -Perl2Epics::GetAll(); - +Perl2Epics::Update(0.2); +print "turned off. Wait 8 seconds\n"; sleep 8; Perl2Epics::Put("RICHLV_PowerOnOff",0); +Perl2Epics::Update(0.2); +print "turned on. You can continue!\n"; +sleep 1; diff --git a/utils/MDC_Powercycle_2PSx.pl b/utils/MDC_Powercycle_2PSx.pl index 92a2aaf..91f4978 100755 --- a/utils/MDC_Powercycle_2PSx.pl +++ b/utils/MDC_Powercycle_2PSx.pl @@ -22,6 +22,8 @@ if( $opt_help ) { &help(); exit(0); } +print $ENV{'EPICS_CA_ADDR_LIST'}."\n"; +print $ENV{'EPICS_CA_AUTO_ADDR_LIST'}."\n"; my $P=$opt_plane; my $S=$opt_sector; @@ -42,14 +44,22 @@ if ($opt_dryrun) { exit(0); } -Perl2Epics::Connect("MDC_LV_Switch",$s); +my $ret = Perl2Epics::Connect("MDC_LV_Switch",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} +print "Connected\n"; +print "Switching off.\n"; Perl2Epics::Put("MDC_LV_Switch",$off); Perl2Epics::GetAll(); - -sleep 8; +sleep 4; +print "Switching on.\n"; Perl2Epics::Put("MDC_LV_Switch",$on); - +Perl2Epics::Update(0.2); +sleep 2; exit(0); #----------- diff --git a/utils/MdcTofCentral_Powercycle.pl b/utils/MdcTofCentral_Powercycle.pl index 20f1eeb..6f7617a 100755 --- a/utils/MdcTofCentral_Powercycle.pl +++ b/utils/MdcTofCentral_Powercycle.pl @@ -8,10 +8,17 @@ use Data::Dumper; print "Connect..\n"; my $s = "HAD:LV:PS:03:SETONOFF"; -Perl2Epics::Connect("MDCTOFCENTRLV_Power",$s); +my $ret = Perl2Epics::Connect("MDCTOFCENTRLV_Power",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} +print "Connected\n"; Perl2Epics::Put("MDCTOFCENTRLV_Power",1); my $data = Perl2Epics::GetAll(); print $data->{"MDCTOFCENTRLV_Power"}->{val}."\n"; sleep 8; Perl2Epics::Put("MDCTOFCENTRLV_Power",0); +Perl2Epics::Update(0.2); diff --git a/utils/Powercycle_STS_fRPC.pl b/utils/Powercycle_STS_fRPC.pl index 3d1f6ea..011f7f8 100755 --- a/utils/Powercycle_STS_fRPC.pl +++ b/utils/Powercycle_STS_fRPC.pl @@ -8,9 +8,20 @@ use Data::Dumper; print "Connect..\n"; my $s = "HAD:LV:PS:33:SETONOFF"; -Perl2Epics::Connect("STS_PowerOnOff",$s); +my $ret = Perl2Epics::Connect("STS_PowerOnOff",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} $s = "HAD:LV:PS:34:SETONOFF"; -Perl2Epics::Connect("fRPC_PowerOnOff",$s); +$ret = Perl2Epics::Connect("fRPC_PowerOnOff",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} +print "Connected\n"; Perl2Epics::Put("STS_PowerOnOff",1); Perl2Epics::Put("fRPC_PowerOnOff",1); @@ -19,3 +30,4 @@ Perl2Epics::GetAll(); sleep 8; Perl2Epics::Put("STS_PowerOnOff",0); Perl2Epics::Put("fRPC_PowerOnOff",0); +Perl2Epics::Update(0.2); diff --git a/utils/RICH_Powercycle.pl b/utils/RICH_Powercycle.pl index 7973c48..6e05777 100755 --- a/utils/RICH_Powercycle.pl +++ b/utils/RICH_Powercycle.pl @@ -8,13 +8,25 @@ use Data::Dumper; print "Connect..\n"; my $s = "HAD:RICH:PS:poweron"; -Perl2Epics::Connect("RICHLV_PowerOn",$s); +my $ret = Perl2Epics::Connect("RICHLV_PowerOn",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} $s = "HAD:RICH:PS:poweroff"; -Perl2Epics::Connect("RICHLV_PowerOff",$s); +$ret = Perl2Epics::Connect("RICHLV_PowerOff",$s); +if(!$ret) { + print "Could not connect to ".$s."\nEXITING\n"; + sleep 5; + exit; +} +print "Connected\n"; Perl2Epics::Put("RICHLV_PowerOff",1); Perl2Epics::GetAll(); -sleep 8; +sleep 10; Perl2Epics::Put("RICHLV_PowerOn",1); +Perl2Epics::Update(0.2); diff --git a/utils/allmonoff b/utils/allmonoff index f4de886..d89e378 100755 --- a/utils/allmonoff +++ b/utils/allmonoff @@ -1,7 +1,7 @@ #!/bin/bash #ssh hades33 xset -display :0 dpms force off ssh hades70 xset -display :0 dpms force off -ssh hades57 xset -display :0 dpms force off +ssh hadesp57 xset -display :0 dpms force off #ssh hades17 xset -display :0 dpms force off #ssh hades25 xset -display :0 dpms force off #ssh hades27 xset -display :0 dpms force off