--- /dev/null
+#!/bin/bash
+#JAM 5-mar-2019 7:56 added missing perrlib environment. cannot test this during data taking, still to do
+export myvar=$(doyoureallywant.pl "to powercycle the STS and fRPC?")
+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...\"
+ cd /home/hadaq/hadesdaq/utils;
+ PERLLIB=/home/hadaq/EPICS/EPICS-3.15.6/base/lib/perl Powercycle_STS_fRPC.pl;
+ sleep 5
+"
+'
--- /dev/null
+#!/usr/bin/perl -w
+
+use English;
+use strict;
+use Getopt::Long;
+use Data::Dumper;
+use Config::Std;
+use FileHandle;
+use List::MoreUtils qw(any apply first_index);
+use File::Basename;
+use Cwd;
+
+#- Copy all the arguments because
+# later on the @ARGV becomes empty
+my @arg_list = @ARGV;
+
+#- the command line option flags
+my $opt_help = 0;
+my $opt_ebconf = "/home/hadaq/trbsoft/hadesdaq/evtbuild/eb.conf";
+my $opt_test = 0;
+my $opt_verb = 0;
+my $opt_eb = "";
+my @opt_ebrange = ();
+#my $opt_rfio = 'undef';
+my $opt_disk = 'undef';
+#my $opt_online = 'undef';
+my $opt_bnet = 3;
+my $opt_prefix;
+
+GetOptions ('h|help' => \$opt_help,
+ 'c|conf=s' => \$opt_ebconf,
+ 'e|eb=s' => \$opt_eb,
+ 'n|nr=s' => \@opt_ebrange,
+ 'd|disk=s' => \$opt_disk,
+ 'p|prefix=s' => \$opt_prefix,
+ 'b|bnet=s' => \$opt_bnet,
+ 'v|verb' => \$opt_verb);
+
+if ( $opt_help ) {
+ &help();
+ exit(0);
+}
+
+#- List of EBs provided via command line options
+my $active_EBs_aref = &setArgs();
+
+#- Hash with status of CPU cores of EBs (used for 'taskset')
+my %EB_CPU_status;
+my $EB_CPU_status_href = \%EB_CPU_status;
+&init_CPU_status($EB_CPU_status_href);
+
+#my $expect_ioc_script = "/tmp/ioc_exit.exp";
+my $log_path = "/home/hadaq/tmp/log";
+my %temp_args;
+my $temp_args_href = \%temp_args;
+read_config $opt_ebconf => %$temp_args_href;
+#print Dumper $temp_args_href;
+#exit;
+
+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");
+
+
+
+my %IP_GSI_lookup = (
+ '192.168.100.8' => 'lxhadeb08',
+ '192.168.100.9' => 'lxhadeb09',
+ '192.168.100.10' => 'lxhadeb10',
+ '192.168.105.11' => 'lxhadeb11',
+ '192.168.105.12' => 'lxhadeb12',
+ '192.168.105.13' => 'lxhadeb13',
+ '192.168.105.114' => 'lxhadeb14',
+ '192.168.105.115' => 'lxhadeb15',
+ '192.168.105.116' => 'lxhadeb16'
+ );
+
+
+my $IP_GSI_href = \%IP_GSI_lookup;
+
+
+my $numOfEBProcs = 0;
+my %EB_Args;
+my $EB_Args_href = \%EB_Args;
+
+#my @EB_IP_list;
+
+
+
+&getEBArgs( $EB_Args_href );
+
+
+if ($opt_eb eq "start") {
+ &writeArgs2file();
+ &startEvtBuilders();
+} elsif ($opt_eb eq "stop") {
+ &stopEvtBuilders();
+} elsif ($opt_eb eq "restart") {
+ &stopEvtBuilders();
+ sleep 10;
+ &writeArgs2file();
+ &startEvtBuilders();
+}
+
+exit(0);
+
+################### END OF MAIN ####################
+
+sub help() {
+ print "\n";
+ print << 'EOF';
+start_eb_gbe.pl
+
+ This script starts parallel Event Building processes.
+ The script also starts IOC processes for the run control.
+
+Usage:
+
+ Command line: start_eb_gbe.pl
+ [-h|--help] : Show this help.
+ [-c|--conf <path/name>] : Path to the config file (default: ../evtbuild/eb.conf).
+ [-e|--eb <start|stop|restart>] : Start or stop Event Builders (default: start).
+ [-p|--prefix <prefix>] : Prefix of hld file.
+ [-b|--bnet <on|off>] : Specify number of bnet builder nodes(default: 5).
+ [-t|--test] : Test without execution.
+ [-v|--verb] : More verbouse.
+
+Examples:
+
+ Start 6 EBs with the numbers 1,2,3,5,7 and prefix 'md':
+ start_eb_gbe.pl -e start -n 1-3 -n 5 -n 7 -p md
+
+
+EOF
+}
+
+sub init_CPU_status() {
+
+ # JAM 17-oct-2018 - for BNET this cpu reservation is deprecated TODO: remove it
+ my ($EB_CPU_status_href) = @_;
+
+
+ # MT 2020-12: reserve lower 16 (8?) cpus for network interrupts
+ $EB_CPU_status_href->{'192.168.100.8'}->{'input'} = "10-25";
+ $EB_CPU_status_href->{'192.168.100.8'}->{'build'} = "26-31";
+ $EB_CPU_status_href->{'192.168.100.9'}->{'input'} = "10-25";
+ $EB_CPU_status_href->{'192.168.100.9'}->{'build'} = "26-31";
+ $EB_CPU_status_href->{'192.168.100.10'}->{'input'} = "10-25";
+ $EB_CPU_status_href->{'192.168.100.10'}->{'build'} = "26-31";
+ $EB_CPU_status_href->{'192.168.105.11'}->{'input'} = "10-25";
+ $EB_CPU_status_href->{'192.168.105.11'}->{'build'} = "26-31";
+ $EB_CPU_status_href->{'192.168.105.12'}->{'input'} = "10-25";
+ $EB_CPU_status_href->{'192.168.105.12'}->{'build'} = "26-31";
+
+ # JAM 7-2021: new servers have 64 cores, reserve lower 32 cpus for network interrupts - TODO with new set_eth_affinity.pl
+ $EB_CPU_status_href->{'192.168.105.114'}->{'input'} = "32-47";
+ $EB_CPU_status_href->{'192.168.105.114'}->{'build'} = "48-63";
+
+# $EB_CPU_status_href->{'192.168.105.114'}->{'input'} = "10-25";
+# $EB_CPU_status_href->{'192.168.105.114'}->{'build'} = "26-31";
+
+
+
+ $EB_CPU_status_href->{'192.168.105.115'}->{'input'} = "32-47";
+
+ $EB_CPU_status_href->{'192.168.105.115'}->{'build'} = "48-63";
+ $EB_CPU_status_href->{'192.168.105.116'}->{'input'} = "32-47";
+ $EB_CPU_status_href->{'192.168.105.116'}->{'build'} = "48-63";
+
+ # MT, separate scheme, doesn't do so well
+ #$EB_CPU_status_href->{'192.168.105.12'}->{'input'} = "16-23";
+ #$EB_CPU_status_href->{'192.168.105.12'}->{'build'} = "24-31";
+
+
+}
+
+
+sub getCoreNr() {
+ #my ($ip) = @_;
+ my ($ip, $role) = @_;
+ my $core_nr;
+ if (defined $role) {
+ $core_nr = $EB_CPU_status_href->{$ip}->{$role}
+ }
+
+ unless( defined $core_nr ){
+ print "No free cores left on CPU $ip. Exit.\n";
+ exit(0);
+ }
+
+ print "found core numbers $core_nr for node $ip, role $role\n";
+ return $core_nr;
+}
+
+
+
+
+sub setArgs() {
+ my @active_EBs;
+
+ if (@opt_ebrange) {
+ foreach my $range (@opt_ebrange) {
+ if ($range =~ /(\d+)-(\d+)/) {
+ my $max = $1;
+ my $min = $2;
+
+ foreach my $eb ($max..$min) {
+ #- 1 must be subtracted to match
+ # EB numbering in the register_configgbe_ip.db
+ # which starts from zero
+ &checkEB_nr($eb);
+ push(@active_EBs, $eb-1);
+ }
+ } elsif ($range =~ /(\d+)/) {
+ &checkEB_nr($1);
+ push(@active_EBs, $1-1);
+ }
+ }
+ }
+
+ return \@active_EBs;
+}
+
+sub checkEB_nr() {
+ my ($eb_nr) = @_;
+
+ if ( $eb_nr < 1 || $eb_nr > 16 ) {
+ print "ERROR: EB number should be in the range 1-16. Exit.";
+ exit(0);
+ }
+}
+
+sub getEBArgs() {
+ my ($href) = @_;
+
+
+ #- Number of EB process
+ my $ebproc = 0;
+
+ # BNET setup:
+ my $listOfBnetInputs = $temp_args_href->{'Parallel'}->{'BNETINP'};
+ my @bnet_in_list = split(/\s+/, $listOfBnetInputs);
+
+ my $listOfBnetBuilders = $temp_args_href->{'Parallel'}->{'BNETBLD'};
+ my @bnet_bld_list = split(/\s+/, $listOfBnetBuilders);
+ #print Dumper @bnet_bld_list;
+
+
+ #- LTSM settings
+ my $listOfLTSM = $temp_args_href->{'Parallel'}->{'LTSM'};
+ my @ltsm_list = split(/\s+/, $listOfLTSM);
+
+ my $ltsm_path = $temp_args_href->{'Parallel'}->{'LTSM_PATH'};
+ my $ltsm_server = $temp_args_href->{'Parallel'}->{'LTSM_Server'};
+ my $ltsm_node = $temp_args_href->{'Parallel'}->{'LTSM_Node'};
+ my $ltsm_passwd = $temp_args_href->{'Parallel'}->{'LTSM_Passwd'};
+ my $ltsm_filesys = $temp_args_href->{'Parallel'}->{'LTSM_Filesystem'};
+
+ my $ltsm_usefsd = $temp_args_href->{'Parallel'}->{'LTSM_USEFSD'};
+ my $ltsm_fsd_servers = $temp_args_href->{'Parallel'}->{'LTSM_FSD_SERVERS'};
+ my @ltsm_fsd_server_list = split(/\s+/, $ltsm_fsd_servers);
+ my $ltsm_fsd_ports = $temp_args_href->{'Parallel'}->{'LTSM_FSD_PORT'};
+ my @ltsm_fsd_port_list = split(/\s+/, $ltsm_fsd_ports);
+
+ my $ltsm_usefsqdest = $temp_args_href->{'Parallel'}->{'LTSM_USEFSQDEST'};
+ my $ltsm_fsqdest = $temp_args_href->{'Parallel'}->{'LTSM_FSQDEST'};
+
+ #--- Read GbE configuration
+ my %eb_ids_gbe_hash;
+ my $eb_ids_gbe_href = \%eb_ids_gbe_hash;
+
+ &getGbEconfig($eb_ids_gbe_href);
+
+ #--- Loop over all EB processes
+ #print Dumper $eb_ids_gbe_href;
+ #exit;
+ #foreach my $ebproc ( sort keys %{$eb_ids_gbe_href} ){
+ foreach my $ebproc ( 0 .. $#bnetservers) {
+
+
+
+ $href->{$ebproc}->{'IP'} = $bnetservers[$ebproc];
+ $href->{$ebproc}->{'EBNUM'} = $ebproc+1;
+
+ $href->{$ebproc}->{'PORT_LIST'} = $eb_ids_gbe_href->{$ebproc}->{'port_list'};
+
+ # JAM2016: bnet requieres udp destination nodes in a list like the ports:
+ $href->{$ebproc}->{'IP_LIST'} = $eb_ids_gbe_href->{$ebproc}->{'ip_list'};
+
+ # JAM2018: bnet requieres calibration modes in a list like the ports:
+ $href->{$ebproc}->{'CALIB_LIST'} = $eb_ids_gbe_href->{$ebproc}->{'calib_list'};
+
+ # JAM2018: bnet requires hub addresses/subevents in a list like the ports:
+ $href->{$ebproc}->{'HUB_LIST'} = $eb_ids_gbe_href->{$ebproc}->{'addr_list'};
+
+
+
+ $href->{$ebproc}->{'LTSM'} = $ltsm_list[$ebproc]; # 0|1
+ $href->{$ebproc}->{'LTSM_PATH'} = $ltsm_path;
+ $href->{$ebproc}->{'LTSM_Server'} = $ltsm_server;
+ $href->{$ebproc}->{'LTSM_Node'} = $ltsm_node;
+ $href->{$ebproc}->{'LTSM_Passwd'} = $ltsm_passwd;
+ $href->{$ebproc}->{'LTSM_Filesystem'} = $ltsm_filesys;
+
+ $href->{$ebproc}->{'LTSM_USEFSD'} = $ltsm_usefsd;
+ $href->{$ebproc}->{'LTSM_FSD_PORT'} = $ltsm_fsd_port_list[$ebproc];
+ $href->{$ebproc}->{'LTSM_FSD_SERVER'} = $ltsm_fsd_server_list[$ebproc];
+
+
+ $href->{$ebproc}->{'LTSM_USEFSQDEST'} = $ltsm_usefsqdest;
+ $href->{$ebproc}->{'LTSM_FSQDEST'} = $ltsm_fsqdest;
+
+
+
+ # if ($ebproc<7) {
+ # note that for bnet setup, index does not mean eb number, but machine number!
+ # we misuse this here to save complexity of setup
+ $href->{$ebproc}->{'BNET_INP'} = $bnet_in_list[$ebproc]; # 0|1|2...
+ $href->{$ebproc}->{'BNET_BLD'} = $bnet_bld_list[$ebproc]; # 0|1|2|3
+ #print "dump bnet_bld\n";
+ #print Dumper \$bnet_bld_list[$ebproc];
+# }
+
+ } #foreach
+
+ $numOfEBProcs = $ebproc;
+ #print "result\n";
+ #print Dumper $ebproc;
+ # exit;
+}
+
+
+
+
+sub startBnet() {
+ # here we launch the dabc bnet.
+ # parameters in eb.conf can specify how many input and builder processes run on each node.
+ # we misuse daq gbe setup for EB 15 to specify ports and destination nodes.
+ my (@process_list);
+ # setup for first EB
+ my $ebproc =0; # setup for first EB will define the BNET
+ my $username = "hadaq";
+ my $cdworkdir = "cd /home/hadaq/oper;";
+
+ # here the default installation. always the most recent...
+ my $dabclogin = ". /home/hadaq/soft/dabc/bin/dabclogin.head; ";
+ my $cmd_dabc = "/home/hadaq/soft/dabc/bin/dabc_exe.head ";
+ # my $cmd_dabc = "/usr/bin/gdb -x /home/hadaq/soft/dabc/head/base/run/gdbcmd.txt --args /home/hadaq/soft/dabc/bin/dabc_exe.head ";
+ my $conf_bnet_inp = " BnetInputHades.head.xml";
+ #my $conf_bnet_bld = " BnetBuilderHades.head.xml";
+ 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";
+
+
+ # variable master node now:
+ my $bnetmaster = "lxhadeb12";
+ # "lxhadeb07";
+ #lxhadeb12";
+
+ # before we start inidividual bnet processes, need to evaluate list of ports and nodes:
+ # BNETSENDERS=[localhost:12501,localhost:12502]
+ # BNETRECEIVERS= [localhost:12101,localhost:12102]
+ # HADAQPORTS =[50000,50001,50002]
+
+ my $bnetsenders = "[";
+ my $bnetrcvs = "[";
+ my @bnet_port_list = ();
+ my @bnet_calib_list = ();
+ my @bnet_subevt_list = ();
+ my $firstsnd = 1;
+ my $firstrcv = 1;
+
+ my $maxbuildservers = 5; #exclude lxhadeb10, lxhadeb11 from data writing JAM2021
+ my $maxbuilders=1;
+ if ($opt_bnet>0 && $opt_bnet <16) {
+ $maxbuilders=$opt_bnet;
+ }
+
+ print "Using $maxbuilders event builder nodes from option -b $opt_bnet\n";
+ my $totalbuilders=0;
+ my @localbuilders = (0,0,0,0,0,0,0); # JAM21 entries also for servers that were deactivated as builders
+ while ($totalbuilders < $maxbuilders) {
+ my $lasttotalbuilders=$totalbuilders;
+ for ( my $ebserver=0; $ebserver<$maxbuildservers; $ebserver=$ebserver+1) {
+ my $bnet_numbuilders = $EB_Args_href->{$ebserver}->{'BNET_BLD'};
+ print "numbuilders for $ebserver is $bnet_numbuilders \n";
+ if ($totalbuilders < $maxbuilders) {
+ if ($localbuilders[$ebserver] < $bnet_numbuilders) {
+ $localbuilders[$ebserver]++;
+ $totalbuilders++;
+ print "Added 1 builder on EB server: $ebserver\n";
+ }
+ }
+ }
+ if ($totalbuilders==$lasttotalbuilders) {
+ last;
+ } # more ebs demanded than configured
+ }
+
+ for ( my $ebserver=0; $ebserver<$maxbuildservers; $ebserver=$ebserver+1) {
+ print "Found $localbuilders[$ebserver] builders on EB server: $ebserver\n";
+ }
+
+ my $rcvport = 12100;
+ for ( my $ebserver=0; $ebserver<$#bnetservers+1; $ebserver=$ebserver+1) {
+ print "Gathering processes at EB server: $ebserver\n";
+ my $sendport = 12501;
+ my $ip = $bnetservers[$ebserver];
+
+ # JAM2018 - need to transform HADES VLAN IPs into GSI VLAN for BNET!
+ my $gsi_ip = getIP_hades2gsi($ip);
+ # array of BNET values is already indexed with server id:
+ my $bnet_numsenders = $EB_Args_href->{$ebserver}->{'BNET_INP'};
+ for (my $six=0; $six<$bnet_numsenders; $six=$six+1) {
+ $bnetsenders=$bnetsenders . "," unless ($firstsnd>0);
+ $bnetsenders=$bnetsenders . $gsi_ip.":". $sendport;
+ $sendport=$sendport+1;
+ $firstsnd=0 if($firstsnd>0);
+ }
+ for (my $rix=0; $rix<$localbuilders[$ebserver]; $rix=$rix+1) {
+ $bnetrcvs=$bnetrcvs . "," unless ($firstrcv>0);
+ $bnetrcvs=$bnetrcvs . $gsi_ip.":". $rcvport;
+ $rcvport=$rcvport+1;
+ $firstrcv=0 if($firstrcv>0);
+ }
+ my $hadaqports = "[";
+ my $calibflags = "[";
+ my $subevents = "[";
+ my $firstport = 1;
+
+ #- add ports: note that we only use eb 1 from hub setup and do check which ports belong to our eb server:
+ my $ix =0;
+ foreach my $port (@{$EB_Args_href->{$ebproc}->{'PORT_LIST'}}) {
+ # here we only gather such ports that are assigned to our node:
+ # todo: how to distribute the ports to more than one bnet input process per server?
+ my $cflag = $EB_Args_href->{$ebproc}->{'CALIB_LIST'}[$ix];
+ my $hub = $EB_Args_href->{$ebproc}->{'HUB_LIST'}[$ix];
+ #print "ip" . $ip . " with port:" . $port ." index:" . $ix . " ip: ". $EB_Args_href->{$ebproc}->{'IP_LIST'}[$ix] . " calib: ". $cflag ." hub: ". $hub ."\n" ;
+ if ($ip eq $EB_Args_href->{$ebproc}->{'IP_LIST'}[$ix]) {
+ $hadaqports=$hadaqports . "," unless ($firstport>0);
+ $hadaqports = $hadaqports . $port;
+ $calibflags=$calibflags . "," unless ($firstport>0);
+ $calibflags = $calibflags . $cflag;
+ $subevents=$subevents . "," unless ($firstport>0);
+ $subevents = $subevents . $hub;
+ $firstport=0 if($firstport>0);
+ }
+ $ix++;
+ }
+ $hadaqports=$hadaqports . "]";
+ push(@bnet_port_list, $hadaqports); # ports are per server
+ $calibflags=$calibflags . "]";
+ push(@bnet_calib_list, $calibflags); # flags per server
+ $subevents=$subevents . "]";
+ push(@bnet_subevt_list, $subevents); # flags per server
+ # print "node ". $gsi_ip . " uses ports ".$hadaqports . ", calibflags " .$calibflags . " hubs: ". $subevents ."\n";
+ }
+ $bnetsenders = $bnetsenders . "]";
+ $bnetrcvs = $bnetrcvs . "]";
+
+ print "bnetsenders: ". $bnetsenders ."\n";
+ print "bnetreceivers: ". $bnetrcvs ."\n";
+
+ my $portid=0; #
+ my $sendid=0;
+
+ my $bnebport=12100;
+ for ( my $ebserver=0; $ebserver<$#bnetservers+1; $ebserver=$ebserver+1) {
+ print "Starting input processes on EB server: $ebserver\n";
+ my $ebid=$ebserver + 1; # still need unique eventbuilder ids on cluster because of epics!
+ my $cpu = $bnetservers[$ebserver];
+
+ my $gsi_cpu = getIP_hades2gsi($cpu);
+ # in the following, the port and ip setup of the bnet is taken from ebproc 0 only!
+ my $bnet_numsenders = $EB_Args_href->{$ebserver}->{'BNET_INP'};
+ #my $bnet_numbuilders = $EB_Args_href->{$ebserver}->{'BNET_BLD'};
+ print "found $bnet_numsenders senders on node $cpu \n";
+
+ my $bninpport=12501;
+ # loop over senders on this node and start them:
+ for (my $sender=0; $sender<$bnet_numsenders; $sender=$sender+1) {
+ #my $sendnum= $sender + 1;
+ my $exports = " export MYHOST=" . $gsi_cpu . ";" .
+ " export BNETMASTER=" . $bnetmaster . ";" .
+ #" export BNINPNUM=" . $sendnum . ";" . # need to use different sender numbers on differentnodes
+ " export BNINPNUM=" . $ebid . ";" . # todo: extend if more than one sender per node
+ " export BNINPID=" . $sendid . "; " .
+ " export BNINPPORT=" . $bninpport . "; " .
+ " export BNETSENDERS=" . $bnetsenders . ";" .
+ " export BNETRECEIVERS=" . $bnetrcvs . ";" .
+ " export HADAQPORTS=" . $bnet_port_list[$ebserver] .";" .
+ " export SUBEVENTS=" . $bnet_subevt_list[$ebserver] .";" .
+ " export CALIBFLAGS=" . $bnet_calib_list[$ebserver] .";";
+ # todo: how to configure situation with more than one bnet input per node? hadaqports must be distributed on them...
+ #
+ #my $core_nr = &getCoreNr($cpu) . "," . &getCoreNr($cpu);
+ 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 1</dev/null & (sleep 2; ~/bin/optimize_taskset.sh) &\"";
+ # JAM21 - try without optimize taskset
+ my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_inp 1</dev/null &\"";
+ #strace -s 200 -ff -o strace_out.txt
+ #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 &\"" ;
+ # 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 &\"";
+
+
+ my $log = $log_path . "/log_" . $ebserver . "_" . "startBnetInp_". $sender. ".txt";
+ #my $log = "/dev/null 2>&1";
+
+ print "Forking:" . $exe_dabc ."\n";
+ forkMe($exe_dabc, $log, \@process_list) unless($opt_test);
+
+ $sendid = $sendid +1;
+ $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";
+ my $ebid=$ebserver + 1; # still need unique eventbuilder ids on cluster because of epics! (and dabc?)
+ my $cpu = $bnetservers[$ebserver];
+ my $gsi_cpu = getIP_hades2gsi($cpu);
+ # in the following, the port and ip setup of the bnet is taken from ebproc 15 or 0 only!
+ #my $bnet_numbuilders = $EB_Args_href->{$ebserver}->{'BNET_BLD'};
+ print "start $localbuilders[$ebserver] builders on node $cpu \n";
+
+ for (my $builder=0; $builder<$localbuilders[$ebserver]; $builder=$builder+1) {
+ my $exports = " export MYHOST=" . $gsi_cpu . ";" .
+ " export BNETMASTER=" . $bnetmaster . ";" .
+ " export BNEBNUM=" . $ebid . ";" .
+ " export BNEBID=" . $portid . "; " .
+ " export BNEBPORT=" . $bnebport . "; " .
+ # ignore prefix at startup. always start without files and show it:
+ #" export PREFIX=" . $EB_Args_href->{$ebproc}->{'PREFIX'}. "; " .
+ " export PREFIX=--;" .
+ " export BNETSENDERS=" . $bnetsenders . ";" .
+ " export BNETRECEIVERS=" . $bnetrcvs . ";" .
+ " export HADAQPORTS=" . $bnet_port_list[$ebserver]. "; " ;
+
+ # 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
+ $exports = $exports . " export FILEOUTPUTS=3;";
+ # additional exports for LTSM
+
+ $exports = $exports . " export LTSMPATH=". $EB_Args_href->{$ebproc}->{'LTSM_PATH'} . ";";
+ $exports = $exports . " export LTSMSERVER=". $EB_Args_href->{$ebproc}->{'LTSM_Server'} . ";";
+ $exports = $exports . " export LTSMNODE=". $EB_Args_href->{$ebproc}->{'LTSM_Node'} . ";";
+ $exports = $exports . " export LTSMPASSWD=". $EB_Args_href->{$ebproc}->{'LTSM_Passwd'} . ";";
+ $exports = $exports . " export LTSMFSNAME=". $EB_Args_href->{$ebproc}->{'LTSM_Filesystem'} . ";";
+ $exports = $exports . " export DSM_LOG=/home/hadaq/oper/ltsm". $ebid .".log;";
+
+ # new for file system daemon JAM2020:
+ if ($EB_Args_href->{$ebproc}->{'LTSM_USEFSD'}) {
+ $exports = $exports . " export USEFSD=true;";
+ $exports = $exports . " export LTSMSESSIONFILES=999999;";
+ # increase number of session files if fsd is used:
+ } else {
+ $exports = $exports . " export USEFSD=false;";
+ $exports = $exports . " export LTSMSESSIONFILES=10;"
+ }
+ # JAM2021: for FSQ api with data destination flag:
+ if ($EB_Args_href->{$ebproc}->{'LTSM_USEFSQDEST'}) {
+ $exports = $exports . " export FSQDEST=". $EB_Args_href->{$ebproc}->{'LTSM_FSQDEST'}. ";";
+ }
+ else
+ {
+ # 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
+ # in this case, server 4 will use first fsd
+ $exports = $exports . " export FSDPORT=". $EB_Args_href->{$fsdix}->{'LTSM_FSD_PORT'} . ";";
+ $exports = $exports . " export FSDSERVER=". $EB_Args_href->{$fsdix}->{'LTSM_FSD_SERVER'} . ";";
+ } else {
+ # no ltsm, just local file
+ $exports = $exports . " export FILEOUTPUTS=2;";
+ }
+
+
+ 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 1</dev/null & (sleep 4; ~/bin/optimize_taskset.sh) &\"";
+ #JAM21 - disable further taskset optimization for the moment.
+ #strace -o strace_out.txt
+ my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports taskset -c $core_nr $cmd_dabc $conf_bnet_bld 1</dev/null &\"";
+
+ #my $exe_dabc = "ssh -n $cpu -l $username \"$dabclogin $cdworkdir $exports $cmd_dabc $conf_bnet_bld >builderlog_$cpu.log 2>&1 &\"";
+
+
+ my $log = $log_path . "/log_" . $ebserver . "_" . "startBnetBld_". $builder . ".txt";
+ #my $log = "/dev/null 2>&1";
+ print "Forking:" . $exe_dabc ."\n";
+ forkMe($exe_dabc, $log, \@process_list) unless($opt_test);
+
+ $ebid = $ebid + $maxbuildservers; #5 ; # increment ebnum by 5 (JAM2020) per ebserver to re-use EPICS iocs (deprecated, but keep numbering logic JAM2021)
+ $portid = $portid + 1;
+ $bnebport = $bnebport +1;
+ #
+ } # builder processes
+ } # servers
+
+ # finally, we need to set eb lut on cts for setup of EB1 => bnet distribution
+ #trbcmd w 0x0003 0xa0f0 0x8000`;
+ #`trbcmd w 0x0003 0xa0f0 0x1`;
+ `trbcmd setbit 0x0003 0xa0f0 0x1`;
+ # use EB1 as pseude for BNET now
+ # all calibration triggers also assigned to pseudo EB1=> bnet distribution for the moment
+ #trbcmd w 0x0003 0xa0f3 0xfff`;
+ # `trbcmd w 0x0003 0xa0f3 0xff0`;
+ `trbcmd setbit 0x0003 0xa0f3 0xff0`;
+ # use EB1 as pseudo receiver for calib triggers
+
+ 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
+
+}
+
+
+
+sub startEvtBuilders() {
+ # JAM21 - always use bnet now, disable support of old scheme
+ # if ( $EB_Args_href->{0}->{'BNET_INP'} ) {
+ print "Starting Builder network...\n";
+ startBnet();
+ return;
+ # }
+ }
+
+
+sub stopEvtBuilders() {
+ my $username = "hadaq";
+
+ my @process_list = ();
+
+ #--- 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\"";
+ if ($opt_verb) {
+ print "Killing running EBs...\n";
+ print "Exec: $exe\n";
+ }
+
+ my $log = $log_path . "/log_" . $ip . "_" . "stopEB.txt";
+
+ forkMe($exe, $log, \@process_list) unless($opt_test);
+ }
+
+ #- Wait for children
+ foreach my $cur_child_pid (@process_list) {
+ print "wait for $cur_child_pid\n";
+ waitpid($cur_child_pid,0);
+ }
+}
+
+
+sub forkMe() {
+ my ($cmd, $log, $proc_list) = @_;
+
+ my $child = fork();
+
+ if ( $child ) { # parent
+ push( @$proc_list, $child );
+ } elsif ( $child == 0 ) { # child
+ system("$cmd >$log 2>&1 ");
+ exit(0);
+ } else {
+ print "Could not fork: $!\n";
+ exit(1);
+ }
+}
+
+
+sub getGbEconfig() {
+ #
+ # Read DB configurations of GbE and CTS,
+ # look for active data sources as well as
+ # for EB IPs and ports.
+ #
+
+ my ($eb_ids_href) = @_;
+
+ my $data_sources = $temp_args_href->{'Parallel'}->{'DATA_SOURCES'};
+ my $gbe_conf = $temp_args_href->{'Parallel'}->{'GBE_CONF'};
+
+ my %activeSources_hash;
+ my $activeSources_href = \%activeSources_hash;
+
+ &readActiveSources($data_sources, $activeSources_href);
+
+ my @id_list;
+ my $id_list_aref = \@id_list;
+
+ #- Overwrite array with EB numbers
+ @id_list = (0 .. 15);
+ #print Dumper $id_list_aref;
+
+ &readEBports($gbe_conf, $activeSources_href, $id_list_aref, $eb_ids_href);
+}
+
+sub readEBids() {
+ #
+ # Read EB Ids
+ #
+
+ my ($file, $id_list_aref) = @_;
+
+ my $nnn_table = 0;
+ my $val_table = 0;
+
+ my $SPACE = "";
+
+ my $fh = new FileHandle("$file", "r");
+
+ while (<$fh>) {
+
+ #- Remove all comments
+ $_ =~ s{ # Substitue...
+ \# # ...a literal octothorpe
+ [^\n]* # ...followed by any number of non-newlines
+ }
+ {
+$SPACE}gxms; # Raplace it with a single space
+
+ #- Skip line if it contains only whitespaces
+ next unless(/\S/);
+
+ if (/^(\s+)?!Value\stable/) {
+ $val_table = 1;
+ $nnn_table = 0;
+ next;
+ } elsif (/^(\s+)?!\w+/) {
+ $val_table = 0;
+ $nnn_table = 1;
+ }
+
+ if ($val_table) {
+ my (@vals) = split(" ", $_);
+ my @id_list1 = split("", $vals[12]);
+ my @id_list2 = split("", $vals[13]);
+ foreach my $id (@id_list1) {
+ push(@$id_list_aref, hex($id));
+ }
+ foreach my $id (@id_list2) {
+ push(@$id_list_aref, hex($id));
+ }
+ } elsif ($nnn_table) {
+ }
+ }
+
+ $fh->close;
+}
+
+sub readEBports() {
+ #
+ # Read EB IPs and ports accoring to EB Id (type)
+ # and TRB-Net addresses of active data sources.
+ #
+
+ my ($file, $activeSources_href, $id_list_aref, $ports_href) = @_;
+
+ my $nnn_table = 0;
+ my $val_table = 0;
+
+ my $fh = new FileHandle("$file", "r");
+
+ &isFileDefined($fh, $file);
+
+ my %tmp;
+ my $tmp_href = \%tmp;
+
+ my $SPACE = "";
+
+ while (<$fh>) {
+
+ #print $_;
+ #- Remove all comments
+ $_ =~ s{ # Substitue...
+ \# # ...a literal octothorpe
+ [^\n]* # ...followed by any number of non-newlines
+ }
+ {
+$SPACE}gxms; # Raplace it with a single space
+
+ #- Skip line if it contains only whitespaces
+ next unless(/\S/);
+
+ #print $_;
+ if (/^(\s+)?!Value\stable/) {
+ $val_table = 1;
+ $nnn_table = 0;
+ next;
+ } elsif (/^(\s+)?!\w+/) {
+ $nnn_table = 1;
+ $val_table = 0;
+ }
+
+ if ($val_table) {
+ my (@vals) = split(" ", $_);
+ my $id = $vals[1];
+
+
+ #- Accept only EB Ids from CTS config file
+ #print "value: $_";
+ next unless( any {$_ eq $id} @$id_list_aref );
+
+ #print Dumper \@vals;
+ #print "active sources: "; print Dumper $activeSources_href->{'addr_list'};
+ #exit;
+
+ my $ip = &getIP_hex2dec($vals[6]);
+ my $port = &getPort_hex2dec($vals[2]);
+ my $addr = $vals[0];
+ my $calib = $vals[7]; # jam2018 - add list of trb3 tdc calibration modes
+
+ # print "got: ip: $ip, port: $port, addr: $addr\n";
+ #- Accept only sources from active source list
+ if ( any {hex($_) == hex($addr)} @{$activeSources_href->{'addr_list'}} ) {
+ $tmp_href->{$id}->{'IP'} = $ip;
+ push( @{$tmp_href->{$id}->{'port_list'}}, $port );
+ push( @{$tmp_href->{$id}->{'addr_list'}}, $addr );
+ push( @{$tmp_href->{$id}->{'calib_list'}}, $calib );
+
+ # JAM2016: for bnet we need the receiver nodes per port as list also:
+ push( @{$tmp_href->{$id}->{'ip_list'}}, $ip );
+
+ }
+ }
+ }
+
+ $fh->close;
+
+ # print Dumper $tmp_href;
+
+ #- Sort hash according to active data source list
+ my $numids= scalar keys %tmp;
+ #print "number of ids: $numids \n";
+ foreach my $id (keys %tmp) {
+ $ports_href->{$id}->{'IP'} = $tmp_href->{$id}->{'IP'};
+
+ foreach my $addr (@{$activeSources_href->{'addr_list'}}) {
+
+ my $ind1 = first_index {$_ eq $addr} @{$tmp_href->{$id}->{'addr_list'}};
+ my $ind2 = first_index {$_ eq $addr} @{$activeSources_href->{'addr_list'}};
+
+ next if($ind1 == -1);
+
+
+ if ($id == 0 && $numids==1) {
+ # fill all ids of active inputs with setup for id 0 of bnet
+ foreach my $bid (0 .. $#bnetservers) {
+ push( @{$ports_href->{$bid}->{'port_list'}}, $tmp_href->{$id}->{'port_list'}->[$ind1]);
+ push( @{$ports_href->{$bid}->{'ip_list'}}, $tmp_href->{$id}->{'ip_list'}->[$ind1]);
+ push( @{$ports_href->{$bid}->{'calib_list'}}, $tmp_href->{$id}->{'calib_list'}->[$ind1]);
+ push( @{$ports_href->{$bid}->{'addr_list'}}, $addr);
+ #push( @{$ports_href->{$bid}->{'bufsize_list'}}, $activeSources_href->{'bufsize_list'}->[$ind2]);
+ }
+ } else {
+# #old EB mode/no bnet: config file defines all. DO WE NEED THIS STILL?
+# push( @{$ports_href->{$id}->{'port_list'}}, $tmp_href->{$id}->{'port_list'}->[$ind1]);
+# # added for bnet JAM:
+# #push( @{$ports_href->{$id}->{'ip_list'}}, $tmp_href->{$id}->{'ip_list'}->[$ind1]);
+# #push( @{$ports_href->{$id}->{'calib_list'}}, $tmp_href->{$id}->{'calib_list'}->[$ind1]);
+# push( @{$ports_href->{$id}->{'addr_list'}}, $addr);
+# push( @{$ports_href->{$id}->{'bufsize_list'}}, $activeSources_href->{'bufsize_list'}->[$ind2]);
+ }
+ }
+ }
+
+ #print Dumper $ports_href;
+}
+
+sub readActiveSources() {
+ #
+ # Read TRB-Net addresses of active data sources
+ #
+
+ my ($file, $activeSources_href) = @_;
+
+ my $fh = new FileHandle("$file", "r");
+
+ &isFileDefined($fh, $file);
+
+ my $SPACE = "";
+
+ # this one contains list of deactivated data sources
+ my $log="/home/hadaq/trbsoft/hadesdaq/evtbuild/tmp/EB_NotActiveSources.txt";
+ system("truncate -s 0 $log ;");
+ while (<$fh>) {
+ #- Remove all comments
+ $_ =~ s{ # Substitue...
+ \# # ...a literal octothorpe
+ [^\n]* # ...followed by any number of non-newlines
+ }
+ {
+$SPACE}gxms; # Raplace it with a single space
+
+ #- Skip line if it contains only whitespaces
+ next unless(/\S/);
+
+ my ($addr, $astat, $sys, $size) = split(" ", $_);
+
+ if ($astat == 0) {
+ system("echo $addr >> $log 2>&1;");
+ next;
+ }
+ push( @{$activeSources_href->{'addr_list'}}, $addr);
+ #push( @{$activeSources_href->{'bufsize_list'}}, &getBufSize($size));
+ }
+
+ $fh->close;
+}
+
+
+sub getIP_hex2dec() {
+ my ($ip_hex) = @_;
+
+ my $ip_dec;
+
+ if ( $ip_hex =~ /0x(\w{2})(\w{2})(\w{2})(\w{2})/ ) {
+ $ip_dec = hex($1) . "." . hex($2) . "." . hex($3) . "." . hex($4);
+ } else {
+ print "getIP_hex2dec(): cannot extract ip address because of diferent format! Exit.";
+ exit(0);
+ }
+
+ return $ip_dec;
+}
+
+sub getPort_hex2dec() {
+ my ($port_hex) = @_;
+
+ my $port_dec;
+
+ if ( $port_hex =~ /0x(\w+)/ ) {
+ $port_dec = hex($1);
+ } else {
+ print "getPort_hex2dec(): cannot extract port number because of diferent format! Exit.";
+ exit(0);
+ }
+
+ return $port_dec;
+}
+
+sub getIP_hades2gsi() {
+ my ($ip_hades) = @_;
+ my $ip_gsi = "";
+ if (exists $IP_GSI_href->{$ip_hades}) {
+ $ip_gsi = $IP_GSI_href->{$ip_hades};
+ } else {
+ print "getIP_hades2gsi(): WARNING - unknown hades ip $ip_hades";
+ }
+ return $ip_gsi;
+}
+
+
+
+
+sub isFileDefined() {
+ my ($fh, $name) = @_;
+
+ if (!$fh) {
+ my $txt = "\nError! Could not open file \'$name\'. Exit.\n";
+ print STDERR $txt;
+ print $txt;
+ exit(128);
+ }
+
+ return 0;
+}
+
+sub writeArgs2file() {
+ my $fileName = $0;
+
+ #- Replace .pl with .sh
+ $fileName =~ s/\.pl/\.sh/;
+
+ my $fh = new FileHandle(">./$fileName");
+ if (!$fh) {
+ my $txt = "\nError! Could not open file \"$fileName\" for output. Exit.\n";
+ print STDERR $txt;
+ print $txt;
+ exit(128);
+ }
+
+ my $current_dir = cwd();
+ my $ptogName = $0;
+
+
+ #- Write to the file the script name itself
+ print $fh $0;
+
+ #- Write to the file the arguments
+ foreach my $arg (@arg_list) {
+ print $fh " $arg";
+ }
+ print $fh ";\n";
+ ## do not start te files by default. user should actively restart the file JAM 29-06-2018
+ # here put command to start the correct file prefix in bnet builders:
+ #my $prefix=$EB_Args_href->{0}->{'PREFIX'};
+ #print $fh "/usr/bin/wget -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt \"http://lxhadeb03:8090/Master/BNET/StartRun/execute?prefix=$prefix&oninit=10\"\n";
+ $fh->close();
+
+ system("chmod 755 ./$fileName");
+}
+
#!/bin/bash
echo stop TDC calibration
+ trbcmd setbit 0x0003 0xa0c0 0x400
+ # stop DAQ triggers here to avoid that EBs carry on writing and opening a new file... JAM 25-11-2021
/usr/bin/wget -a /tmp/EB_runid.log -O /tmp/last_calib_runid.txt "http://lxhadeb12:8099/Master/BNET/RunIdStr/value/get.json"
runid="$(/bin/cat /tmp/last_calib_runid.txt)"
echo " Last calibration run id is $runid";
-
echo Setting file prefix no file
/usr/bin/wget -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt "http://lxhadeb12:8099/Master/BNET/StopRun/execute?tmout=10"
echo set prefix nofile on BNET master controller
trbcmd w 0x003 0xa0c7 $enab
trbcmd clearbit 0x003 0xa0c0 0x10
trbcmd w 0x003 0xa0e3 0x0
+ # JAM 25-11-2021: also enable triggers again
+ trbcmd clearbit 0x0003 0xa0c0 0x400
# JAM 24-08-21 - now start tdc monitor
-ssh hadesp63 "/home/hadaq/local/bin/startTDCcalibmon.sh $runid &"</dev/null &>/dev/null &
-echo "started tdc calibmonitor on http://hades63:8092"
+
+echo "copying calibration files to tdc calib monitor node..."
+# JAM24-11-21: may wait until calibration files are ready written by dabc...
+sleep 5
+ssh hadesp63 "/home/hadaq/local/bin/copyTDCcalibrations.sh $runid &"</dev/null &>/dev/null &
+# again for second monitoring host JAM 17-01-22
+ssh hadesp66 "/home/hadaq/local/bin/copyTDCcalibrations.sh $runid &"</dev/null &>/dev/null &
--- /dev/null
+#!/bin/bash
+
+echo setting CTS to calibration mode;
+export DAQOPSERVER=hadesp31;
+ trbcmd r 0x003 0xa0c7 > /home/hadaq/tmp/precalibctsregs.txt 2> /home/hadaq/tmp/precalibctserr.txt ;
+ echo disabled output mask: `cat /home/hadaq/tmp/precalibctsregs.txt`;
+ trbcmd w 0x003 0xa0c7 0;
+ trbcmd clearbit 0x003 0xa0c0 0x1F;
+ trbcmd setbit 0x003 0xa0c0 0x1D;
+# trbcmd w 0x003 0xa0e3 0x1E8480;
+ trbcmd w 0x003 0xa0e3 0x61A80;
+
+echo Setting file prefix ct;
+ /usr/bin/wget -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt "http://lxhadeb12:8099/Master/BNET/StartRun/execute?prefix=ct&oninit=10";
+ echo set prefix ct on BNET master controller;
+
+
--- /dev/null
+#!/bin/bash
+ echo stop TDC calibration test
+ trbcmd setbit 0x0003 0xa0c0 0x400
+ # stop DAQ triggers here to avoid that EBs carry on writing and opening a new file... JAM 25-11-2021
+ /usr/bin/wget -a /tmp/EB_runid.log -O /tmp/last_calib_runid.txt "http://lxhadeb12:8099/Master/BNET/RunIdStr/value/get.json"
+ runid="$(/bin/cat /tmp/last_calib_runid.txt)"
+ echo " Last calibration test run id is $runid";
+ echo Setting file prefix no file
+ /usr/bin/wget -a /tmp/EB_filestart.log -O /tmp/EB_fileres.txt "http://lxhadeb12:8099/Master/BNET/StopRun/execute?tmout=10"
+ echo set prefix nofile on BNET master controller
+ sleep 2
+ echo setting CTS back to regular mode
+ export DAQOPSERVER=hadesp31
+ echo ${DAQOPSERVER}
+ enab="$(/bin/cat /home/hadaq/tmp/precalibctsregs.txt | /usr/bin/cut -d' ' -f3)"
+ echo "enabling outputs $enab"
+ trbcmd w 0x003 0xa0c7 $enab
+ trbcmd clearbit 0x003 0xa0c0 0x10
+ trbcmd w 0x003 0xa0e3 0x0
+ # JAM 25-11-2021: also enable triggers again
+ trbcmd clearbit 0x0003 0xa0c0 0x400
+# JAM 24-08-21 - now start tdc monitor
+
+ssh hadesp66 "/home/hadaq/local/bin/startTDCcalibmon.sh $runid &"</dev/null &>/dev/null &
+echo "started tdc calib test monitor on http://hades66:8092"
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use POSIX qw(strftime);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[2],5); #Tof
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[4],6); #STS
HPlot::PlotAdd('BusyTimes',$diff->{0x8000}->[0],7); #Cts
- HPlot::PlotAdd('BusyTimes',$diff->{0x8014}->[8],8); #Start TRB3
+ HPlot::PlotAdd('BusyTimes',$diff->{0x8013}->[8],8); #Start TRB3
# HPlot::PlotAdd('BusyTimes',max($diff->{0x8003}->[1],$diff->{0x8003}->[2]),9); #Pion
#Default plots
HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[2],5); #Tof
HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[4],6); #STS
HPlot::PlotFill('BusyTimeBars',$diff->{0x8000}->[0],7); #Cts
- HPlot::PlotFill('BusyTimeBars',$diff->{0x8014}->[8],8); #Start TRB3
+ HPlot::PlotFill('BusyTimeBars',$diff->{0x8013}->[8],8); #Start TRB3
# HPlot::PlotAdd('BusyTimes',max($diff->{0x8003}->[1],$diff->{0x8003}->[2]),9); #Pion
# #Extended view
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
my $temp = trb_register_read(0xffff,0);
foreach my $b (keys %{$temp}) {
- if(($b&0xF000) == 0x7000 || ($b&0xFF00) == 0x6000 || ($b&0xFF00) == 0x5000 ) {
+ if(($b&0xF000) == 0x7000 || ($b&0xF000) == 0x6000 || ($b&0xF000) == 0x5000 ) {
my $t = (($temp->{$b}>>20)&0xFFF)/16.;
$newstore->{boards}{$b} = $t;
if($store->{boards}) {
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
# changed from epics to web/json readout of eventbuilder rates 28-sep-2018 JAM
my $last_rate_endp = 0;
my $opt_addr = 3; #CTS
my $error_ctr = 0;
-my $error_limit = 6;
+my $error_limit = 1;
my $opt_debug =1;
$evtrate_eb_tot = get ($url_erate);
$evtrate_eb_tot = 0 unless defined $evtrate_eb_tot;
+ #$evtrate_eb_tot = 0;
+ #$evtrate_eb_tot = 400 if($loop_counter >=15);
unshift (@{$rh_data->{rates_eb}}, $evtrate_eb_tot);
- #print Dumper $evtrate_eb_tot;
+ ##print Dumper $evtrate_eb_tot;
+
my $builders = get ($url_builders);
#print Dumper $builders;
if (defined $builders) {
print "averages: daq: $avg_daq, eb: $avg_eb\n";
+ #my $status = QA::GetQAState('inside', 0.1, @QA::EBDeltaRateLimits);
my $status = QA::GetQAState('inside', ($avg_daq - $avg_eb)/($avg_daq?$avg_daq:1), @QA::EBDeltaRateLimits);
- $status = QA::OK if $loop_counter < 60;
+ #printf "ratio: %f \n", abs($avg_daq - $avg_eb)/($avg_daq?$avg_daq:1);
+ $status = QA::OK if $loop_counter < 4;
$status = QA::OK if($avg_eb > $avg_daq);
#$diff_p_str = "---";
#$rate_eb_str = "EB is stopped";
}
-
+ #print "before: status: $status\n";
+ #print "error counter: $error_ctr\n";
if (($status >= QA::ERROR) && ($error_ctr < $error_limit)) {
$error_ctr++;
$status = QA::OK;
} else {
- if ($status != QA::ERROR) {
+ if ($status <= QA::ERROR) {
$error_ctr = 0;
}
}
+ #print "error counter: $error_ctr\n";
#$status = QA::ERROR if ($diff > 2000 || $diff < -2000);
my $title = "ΔRate CTS/EB";
$longtext = " $longtext ErrorCtr: $error_ctr" if ($error_ctr > 0);
QA::WriteQALog($flog, "eb", "rate", 2,
$status, $title, $shorttext, $longtext); # unless $opt_debug>0;
- print "status: $status title:$title short:$shorttext long: $longtext \n" unless $opt_debug<1;
+ #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);
}
- if($loop_counter%100 == 0) {
- print Dumper $rh_data;
- }
+ #if($loop_counter%10 == 0) {
+ # print Dumper $rh_data;
+ #}
}
--- /dev/null
+#!/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_84C0 =>"RPC1",
+TRB_84C1 =>"RPC2",
+TRB_84C2 =>"RPC3",
+TRB_84C3 =>"RPC4",
+TRB_84C4 =>"RPC5",
+TRB_84C5 =>"RPC6",
+TRB_86C0 =>"TOF1",
+TRB_86C1 =>"TOF2",
+TRB_86C2 =>"TOF3",
+TRB_86C3 =>"TOF4",
+TRB_86C4 =>"TOF5",
+TRB_86C5 =>"TOF6",
+TRB_86C6 =>"TOF7",
+TRB_8700 =>"FW ",
+TRB_8880 => "Start",
+TRB_8890 => "Veto",
+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_8B00 => "STS1-0",
+TRB_8B01 => "STS1-1",
+TRB_8B02 => "STS1-2",
+TRB_8B03 => "STS1-3",
+TRB_8B10 => "STS2-0",
+TRB_8B11 => "STS2-1",
+TRB_8B12 => "STS2-2",
+TRB_8B13 => "STS2-3",
+TRB_8B14 => "STS2-4",
+TRB_8B15 => "STS2-5",
+TRB_8C00 => 'fRPC1',
+TRB_8C10 => 'fRPC2',
+TRB_8D00 => 'iTOF',
+
+};
+
+
+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://lxhadeb12:8099/BNET-IN-4/TRB8800_TdcCal/TRB_8800/TRB_8800_ErrorBits/get.json?field=%"bins"
+
+
+my $firstcall = 1;
+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;
+
+
+ if($firstcall>0)
+ {
+ my $errorbits_reset_url="$masterurl$nodepath/$childname/$subchildname/$subsubchildname/cmd.json?command=ClearHistos";
+ print "url for reset is $errorbits_reset_url \n" if $opt_verbose;
+ my $result= get ($errorbits_reset_url);
+ print "reset result is $result \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 <E> Events with set error-bits written to file: $longstring'") if ($qastate > 60 && !($timer++%60));
+ print 'EB <E> 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;
+
+$firstcall = 0;
+sleep (2);
+}
+
+
+
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use POSIX qw(strftime);
# $b = sprintf('0x')hex($b);
my $v = $chain*16+$channel;
- if (($v % 2) == 0 && ($b ne "6036")) {
+ if (($v % 2) == 0 && ($b ne "6006")) {
$data->{fast}{"0x".$b}{$v/2} = sprintf('%.2f',$val);
if ($val > $fastmax ) {$fastmax = $val;}
if ($val < $fastmin ) {$fastmin = $val;}
}
- if (($v % 2) == 1 && ($b ne "6036")) {
+ if (($v % 2) == 1 && ($b ne "6006")) {
$data->{slow}{"0x".$b}{int($v/2)} = sprintf('%.2f',$val);
if ($val > $slowmax ) {$slowmax = $val;}
if ($val < $slowmin ) {$slowmin = $val;}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use QA;
use Getopt::Long;
use Data::Dumper;
-
+use List::MoreUtils qw(uniq);
use HADES::TrbNet;
trb_init_ports() or die trb_strerror();
my $flog = QA::OpenQAFile();
my $waittime = 15;
+my $mdcmissingtime = 0;
my $loggerperiod = 12; #times 5 seconds sleep
my $timecnt;
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,
+ 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,
+ 0x1110,0x1111,0x1112,0x1113,0x1114,
+ 0x1120,0x1121,0x1122,0x1123,0x1124,
+ 0x1130,0x1131,0x1132,0x1133,0x1134,
+ 0x1140,0x1141,0x1142,0x1143,0x1144,
+ 0x1150,0x1151,0x1152,0x1153,0x1154,
###
);
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,
+ 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,
#Start TRB3sc
0x8880,0x5000,0x5001,0x5002,0x5003,0x5004,0x5005,0x5006,0x5007,
#Hodo TRB3
- 0x8890,0x5010,0x5011,0x5012,
+ 0x8890,0x5010,0x5011, #0x5012,
#Trigger
0x10,0x0100,0x0110,0x0120,0x130
);
push @all_boards, $result[$k];
}
- ###mdc
+###MDC
+########################
my(%mdc_mask, @mdc_results);
$mdc_results[$_] = [] foreach (0 .. 7);
foreach my $element (@all_boards) { $mdc_mask{$element} |= 1 }
my $num_mdc_mistake = (scalar @{$mdc_results[4]});
my @sorted_mdc_results = sort @{$mdc_results[2]};
+ $mdcmissingtime = 0 if $num_mdc_missing == 0;
+ $mdcmissingtime += $num_mdc_missing;
+
+ #Are two boards from the same chamber missing?
+ my @mdcboards = @sorted_mdc_results;
+ chop(@mdcboards);
+ my @uniqchambers = uniq @mdcboards;
+ my $samechamberboards = 0;
+ if(scalar @mdcboards != scalar @uniqchambers) {$samechamberboards = 1;}
+
print $fh "$num_mdc_missing\n";
$fh->autoflush(1);
seek($fh, 0, 0);
if ($num_mdc_mistake > 0) {$longtext .= " Endp @{$mdc_results[4]} not known";}
my $qastate = QA::GetQAState('below',$num_mdc_missing,@QA::MdcEndpMissingLimits);
+ $qastate = QA::ERROR if $samechamberboards;
+ $qastate = QA::ERROR if $mdcmissingtime > 250;
+ $longtext .= "<br>Few boards missing, but for a long time. Better do a restart." if $mdcmissingtime > 1800;
+
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);
}
else {$timecnt->{mdc} = 0;}
- ###rich
+###RICH
+########################
my(%rich_mask, @rich_results);
$rich_results[$_] = [] foreach (0 .. 7);
foreach my $element (@all_boards) { $rich_mask{$element} |= 1 }
--- /dev/null
+#!/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 \\<E\\> $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 \\<E\\> $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 \\<E\\> $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 \\<E\\> $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 \\<E\\> $other_longtext") unless (($timecnt->{oth}++)%$loggerperiod);
+ }
+ else {$timecnt->{oth} = 0;}
+
+ sleep(5);
+}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use JSON::XS;
-my $plot1 = {
-name => "FrpcRate",
-file => "files/FrpcRate",
-title => "fRPC Rate",
-entries => 16,
-curves => 20,
-type => HPlot::TYPE_HEATMAP,
-output => HPlot::OUT_PNG,
-zlabel => "Hitrate",
-sizex => 310,
-sizey => 310,
-nokey => 1,
-buffer => 1,
-ymin => 19.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);
-
+HPlot::PlotInit({
+ name => "FrpcRate",
+ file => "files/FrpcRate",
+ title => "fRPC Rate",
+ entries => 16,
+ curves => 20,
+ type => HPlot::TYPE_HEATMAP,
+ output => HPlot::OUT_PNG,
+ zlabel => "Hitrate",
+ sizex => 310,
+ sizey => 310,
+ nokey => 1,
+ buffer => 1,
+ ymin => 19.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({
+ name => "FrpcRateHist",
+ file => "files/FrpcRateHist",
+ entries => 400,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ titles => ["S1 F","S1 B","S2 F","S2 B","S3 F","S3 B","S4 F","S4 B"],
+ xlabel => "Time [s]",
+ ylabel => "Hitrate [Hz]",
+ sizex => 950,
+ sizey => 330,
+ ymin => "0",
+ ymax => "100<*",
+ curves => 8,
+ buffer => 1,
+ storable => 1,
+ });
my $str = Hmon::MakeTitle(4, 7, "fRPC Hit Rate",0);
$str .= qq@<img src="%ADDPNG files/FrpcRate.png%" type="image/png"><br>\n@;
Hmon::WriteFile("FrpcRate",$str);
+$str = Hmon::MakeTitle(13, 8, "fRPC Hit Rate",0);
+$str .= qq@<img src="%ADDPNG files/FrpcRateHist.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("FrpcRateHist",$str);
+
my $old;
my $oldtime = time();
my $time = time();
while(1) {
- #my $data;
- #my $max = 0 ;
- #my $min = 5E9;
+
- my $o = trb_register_read_mem(0xfe47,0xdfc0,0,32) or die trb_strerror() or sleep 5 and next;
+ my $o = trb_register_read_mem(0xfe47,0xdfc0,0,36) or die trb_strerror() or sleep 5 and next;
if (defined $old) {
my $tdiff = (time() - $oldtime)|1;
#$ratesum += $diff->{$b}->[$v+1];
HPlot::PlotFill('FrpcRate',$diff->{$b}->[$v],$v%16,$xpos+$v/16);
}
- #my $s = sprintf("0x%04x",$b);
- #$data->{$s}= int(100*($ratesum / 32) +0.5) /100;
-
- #$min = $data->{$s} if $data->{$s} < $min;
- #$max = $data->{$s} if $data->{$s}> $max;
+
+ my $v = 34;
+ my $vdiff = ($o->{$b}->[$v]&0xffffff) - ($old->{$b}->[$v]&0xffffff);
+ if ($vdiff < 0) { $vdiff += 2**24;}
+ $diff->{$b}->[$v] = $vdiff/$tdiff;
+ $xpos = ($b&0xF) + ($b>>4 & 0xF)*4;
+ HPlot::PlotAdd('FrpcRateHist',$diff->{$b}->[$v],$xpos);
}
- HPlot::PlotDraw('FrpcRate');
+ HPlot::PlotDrawFork('FrpcRate');
+ HPlot::PlotDrawFork('FrpcRateHist');
-
- # $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 = $o;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use Hmon;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
--- /dev/null
+#!/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 gettimeofday);
+use List::Util qw[min max sum];
+no warnings 'uninitialized';
+
+
+trb_init_ports() or die trb_strerror();
+
+
+HPlot::PlotInit({
+ name => "HodoPosition",
+ file => "files/HodoPosition",
+ entries => 200,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ titles => [" X_0 position"," Y_0 position"," X_0 3*rms"," Y_0 3*rms"],
+ xlabel => "Seconds",
+ ylabel => "Strips",
+ sizex => 970,
+ sizey => 350,
+ ymin => "-0.5",
+ ymax => "15.5",
+ curves => 4,
+ xscale => 10,
+ buffer => 1,
+ });
+
+HPlot::PlotInit({
+ name => "HodoRateXhistbar_0",
+ file => "files/HodoRateXhistbar_0",
+ entries => 200,
+ type => HPlot::TYPE_BARGRAPH,
+ output => HPlot::OUT_PNG,
+ titles => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
+ xlabel => "Time / 100 ms",
+ ylabel => "Hitrate [Hz]",
+ sizex => 950,
+ sizey => 330,
+ xmin => 0,
+ xmax => 200,
+ ymin => "0",
+ ymax => "100<*",
+ curves => 16,
+ 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({
+ name => "HodoRateYhistbar_0",
+ file => "files/HodoRateYhistbar_0",
+ entries => 200,
+ type => HPlot::TYPE_BARGRAPH,
+ output => HPlot::OUT_PNG,
+ titles => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
+ xlabel => "Time / 100 ms",
+ ylabel => "Hitrate [Hz]",
+ sizex => 950,
+ sizey => 330,
+ xmin => 0,
+ xmax => 200,
+ ymin => "0",
+ ymax => "100<*",
+ curves => 16,
+ 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({
+ name => "HodoDutyFactorX_0",
+ file => "files/HodoDutyFactorX_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Duty Factor",
+ sizex => 600,
+ sizey => 200,
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "HodoDutyFactorY_0",
+ file => "files/HodoDutyFactorY_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Duty Factor",
+ sizex => 600,
+ sizey => 200,
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "HodoSpillSumX_0",
+ file => "files/HodoSpillSumX_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Total Sum",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+HPlot::PlotInit({
+ name => "HodoSpillSumY_0",
+ file => "files/HodoSpillSumY_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Total Sum",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "HodoSpillPeakX_0",
+ file => "files/HodoSpillPeakX_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Peak Intensity [Hz]",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "HodoSpillPeakY_0",
+ file => "files/HodoSpillPeakY_0",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Peak Intensity [Hz]",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+
+my $str = Hmon::MakeTitle(13, 8, "Hodo Position",0);
+$str .= qq@<img src="%ADDPNG files/HodoPosition.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("HodoPosition",$str);
+
+$str = Hmon::MakeTitle(13, 32, "Hodo Rates X_0",0);
+$str .= qq@<h3>Hodo X Spill</h3><img src="%ADDPNG files/HodoRateXhistbar_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo X Duty</h3><img src="%ADDPNG files/HodoDutyFactorX_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo X Peak</h3><img src="%ADDPNG files/HodoSpillPeakX_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo X Sum</h3><img src="%ADDPNG files/HodoSpillSumX_0.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("HodoRateX_0",$str);
+
+
+$str = Hmon::MakeTitle(13, 32, "Hodo Rates Y_0",0);
+$str .= qq@<h3>Hodo Y Spill</h3><img src="%ADDPNG files/HodoRateYhistbar_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo Y Duty</h3><img src="%ADDPNG files/HodoDutyFactorY_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo Y Peak</h3><img src="%ADDPNG files/HodoSpillPeakY_0.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo Y Sum</h3><img src="%ADDPNG files/HodoSpillSumY_0.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("HodoRateY_0",$str);
+
+
+$str = Hmon::MakeTitle(16, 32, "Spill Info Hodo",0);
+$str .= qq@<h3>Hodo Duty</h3><img src="%ADDPNG files/HodoDutyFactorX_0.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo Peak</h3><img src="%ADDPNG files/HodoSpillPeakX_0.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Hodo Sum</h3><img src="%ADDPNG files/HodoSpillSumX_0.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("SpillInfoHodoX_0",$str);
+
+
+
+my $iter = 1;
+
+my $trbnet_endpoint_offset = 0x5000; #20480
+
+
+##
+##
+##
+ # pch is physical channel in the detector, tdc is the connected TDC and ch is the channel of the TDC
+my $channels_x_0 = [
+ { pch => 0, tdc => 17, ch => 1 },
+ { pch => 1, tdc => 17, ch => 2 },
+ { pch => 2, tdc => 17, ch => 3 },
+ { pch => 3, tdc => 17, ch => 4 },
+ { pch => 4, tdc => 17, ch => 5 },
+ { pch => 5, tdc => 17, ch => 6 },
+ { pch => 6, tdc => 17, ch => 7 },
+ { pch => 7, tdc => 17, ch => 8 },
+ { pch => 8, tdc => 17, ch => 9 },
+ { pch => 9, tdc => 17, ch => 10 },
+ { pch => 10, tdc => 17, ch => 11 },
+ { pch => 11, tdc => 17, ch => 12 },
+ { pch => 12, tdc => 17, ch => 13 },
+ { pch => 13, tdc => 17, ch => 14 },
+ { pch => 14, tdc => 17, ch => 15 },
+ { pch => 15, tdc => 17, ch => 16 }
+ ];
+
+my $channels_y_0 = [
+ { pch => 0, tdc => 16, ch => 1 },
+ { pch => 1, tdc => 16, ch => 2 },
+ { pch => 2, tdc => 16, ch => 3 },
+ { pch => 3, tdc => 16, ch => 4 },
+ { pch => 4, tdc => 16, ch => 5 },
+ { pch => 5, tdc => 16, ch => 6 },
+ { pch => 6, tdc => 16, ch => 7 },
+ { pch => 7, tdc => 16, ch => 8 },
+ { pch => 8, tdc => 16, ch => 9 },
+ { pch => 9, tdc => 16, ch => 10 },
+ { pch => 10, tdc => 16, ch => 11 },
+ { pch => 11, tdc => 16, ch => 12 },
+ { pch => 12, tdc => 16, ch => 13 },
+ { pch => 13, tdc => 16, ch => 14 },
+ { pch => 14, tdc => 16, ch => 15 },
+ { pch => 15, tdc => 16, ch => 16 }
+ ];
+
+
+
+my @chanx = qw(0 0 2 4 6 8 10 12 14 16 13 11 9 7 5 3 1); #move noisy ch. 15 to 16 to disable it 2019-03-26
+#my @chanx = qw(0 15 13 11 9 7 5 3 1 0 2 4 6 8 10 12 14);
+
+my @chany = qw(0 0 2 4 6 8 10 12 14 15 13 11 9 7 5 3 1);
+my @chanveto = qw(0 2 7 3 4 0 5 1 6);
+my $cts_set;
+
+my $old;
+
+#Spill
+my @totalDetectorHitsX_0;
+my @totalDetectorHitsY_0;
+my $spillThreshold = 1000; # threshold of rate in detector signaling the End of the Spill
+my $samplesPerSecond =10;
+
+my @lastspills_x_0;
+my @lastspills_y_0;
+
+my $time_x_0 = 0;
+my $time_y_0 = 0;
+
+my $empties_x_0 = 0;
+my $empties_y_0 = 0;
+my($max_x_0, $duty_x_0, $total_x_0, $spillmin_x_0, $spillmax_x_0, $spillavg_x_0, $flucqual_x_0, $offtime_x_0, $length_x_0, $spillEnds_x_0) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my($max_y_0, $duty_y_0, $total_y_0, $spillmin_y_0, $spillmax_y_0, $spillavg_y_0, $flucqual_y_0, $offtime_y_0, $length_y_0, $spillEnds_y_0) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my ($lastinspill,$inspill,$spillends) = (0,0,0);
+
+
+HPlot::PlotDrawFork('HodoSpillSumX_0');
+HPlot::PlotDrawFork('HodoSpillPeakX_0');
+HPlot::PlotDrawFork('HodoDutyFactorX_0');
+
+HPlot::PlotDrawFork('HodoSpillSumY_0');
+HPlot::PlotDrawFork('HodoSpillPeakY_0');
+HPlot::PlotDrawFork('HodoDutyFactorY_0');
+
+
+
+
+while(1) {
+
+ if($iter == 1) {
+ $cts_set = trb_register_read(0x3,0xa0da);
+ }
+ my $current_readout;
+ foreach my $b (0x5010,0x5011) {
+ my $t = trb_registertime_read_mem($b,0xc000,0,33); # check if TDC channels are counted from 1 or from 0
+ $current_readout->{$b} = $t->{$b};
+ }
+
+ # my $current_readout = trb_registertime_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
+ #my $o = trb_register_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
+ #print Dumper $o;
+ #exit;
+ if (defined $old) {
+# print Dumper $current_readout;
+# exit;
+
+ # Calculation of total Detector hits ($sum_) and weighted with position in detector (wsum_)
+ my ($sum_x_0, $wsum_x_0) = calculate_diff_time_and_sum($channels_x_0, $old, $current_readout);
+ my ($sum_y_0, $wsum_y_0) = calculate_diff_time_and_sum($channels_y_0, $old, $current_readout);
+
+ # Create an array containing the sums per readout
+
+
+
+ # calculate beam position and width, by using a weighted average of physical channels and the RMS.
+ my $avg_x_0=0;
+ my $avg_y_0=0;
+ my $rms_x_0=0;
+ my $rms_y_0=0;
+
+ if($sum_x_0 < 5000){
+ $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_y_0 < 5000){
+ $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));
+ }
+
+ # Calculate Number of hits in detector by subgroups consisting of 5 channels
+ my @hitRatesHodoX_0 = calculate_rates($channels_x_0, $old, $current_readout);
+ my @hitRatesHodoY_0 = calculate_rates($channels_y_0, $old, $current_readout);
+
+ push(@totalDetectorHitsX_0, $sum_x_0);
+ shift(@totalDetectorHitsX_0) if scalar @totalDetectorHitsX_0 > 2000; # makes sure that the array does not get huge. after 200 seconds of no beam, the last entries start to fall off
+ $empties_x_0++ if ($sum_x_0 < 1000);
+ push(@totalDetectorHitsY_0, $sum_y_0);
+ shift(@totalDetectorHitsY_0) if scalar @totalDetectorHitsY_0 > 2000;
+ $empties_y_0++ if ($sum_y_0 < 1000);
+
+ my $sp = trb_register_read(0x10,0x905d);
+ $inspill = ($sp->{0x10} >> 31) & 1;
+ $spillends = $inspill == 0 && $lastinspill == 1;
+ if($spillends){
+ ($max_x_0, $duty_x_0, $total_x_0, $spillmin_x_0, $spillmax_x_0, $spillavg_x_0, $flucqual_x_0, $offtime_x_0, $length_x_0, $time_x_0, $empties_x_0, $spillEnds_x_0) = spillAnalysisACCSIG(\@totalDetectorHitsX_0, \@lastspills_x_0, $time_x_0, $empties_x_0);
+
+ @totalDetectorHitsX_0 = ();
+
+ ($max_y_0, $duty_y_0, $total_y_0, $spillmin_y_0, $spillmax_y_0, $spillavg_y_0, $flucqual_y_0, $offtime_y_0, $length_y_0,$time_y_0, $empties_y_0, $spillEnds_y_0) = spillAnalysisACCSIG(\@totalDetectorHitsY_0, \@lastspills_y_0, $time_y_0, $empties_y_0);
+
+ @totalDetectorHitsY_0 = ();
+ }
+
+
+ if($spillends){
+ HPlot::PlotAdd("HodoDutyFactorX_0", $duty_x_0,0);
+ HPlot::PlotAdd("HodoSpillPeakX_0", $max_x_0,0);
+ HPlot::PlotAdd("HodoSpillSumX_0", $total_x_0,0);
+
+ $str = Hmon::MakeTitle(8, 19, "HodoSpillShapeAnalysisX_0",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/HodoRateXhistbar_0.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoDutyFactorX_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoSpillSumX_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoSpillPeakX_0.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_x_0);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_x_0);
+ $str .= "<tr><td>Last Duration<td>".$length_x_0;
+ $str .= "<td>Last Break<td>".$offtime_x_0." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_x_0)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_x_0)." - ".QA::SciNotation($spillmax_x_0)."<br>∅ ".QA::SciNotation($spillavg_x_0)." (".QA::SciNotation($flucqual_x_0).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("HodoSpillShapeAnalysisX_0",$str);
+
+ HPlot::PlotDrawFork('HodoSpillSumX_0');
+ HPlot::PlotDrawFork('HodoSpillPeakX_0');
+ HPlot::PlotDrawFork('HodoDutyFactorX_0');
+# }
+#
+#
+# if($spillends){#$spillEnds_y == 1
+ HPlot::PlotAdd("HodoDutyFactorY_0", $duty_y_0,0);
+ HPlot::PlotAdd("HodoSpillPeakY_0", $max_y_0,0);
+ HPlot::PlotAdd("HodoSpillSumY_0", $total_y_0,0);
+
+ $str = Hmon::MakeTitle(8, 19, "HodoSpillShapeAnalysisY_0",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/HodoRateYhistbar_0.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoDutyFactorY_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoSpillSumY_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/HodoSpillPeakY_0.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_y_0);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_y_0);
+ $str .= "<tr><td>Last Duration<td>".$length_y_0;
+ $str .= "<td>Last Break<td>".$offtime_y_0." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_y_0)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_y_0)." - ".QA::SciNotation($spillmax_y_0)."<br>∅ ".QA::SciNotation($spillavg_y_0)." (".QA::SciNotation($flucqual_y_0).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("HodoSpillShapeAnalysisY_0",$str);
+
+ HPlot::PlotDrawFork('HodoSpillSumY_0');
+ HPlot::PlotDrawFork('HodoSpillPeakY_0');
+ HPlot::PlotDrawFork('HodoDutyFactorY_0');
+ }
+
+ HPlot::PlotAdd("HodoPosition",$avg_x_0,0);
+ HPlot::PlotAdd("HodoPosition",$avg_y_0,1);
+ HPlot::PlotAdd("HodoPosition",3*$rms_x_0,2);
+ HPlot::PlotAdd("HodoPosition",3*$rms_y_0,3);
+
+ for my $i(0..15){
+# HPlot::PlotAdd("HodoRateXhistbar_0",@hitRatesHodoX_0[$i],$i);
+# HPlot::PlotAdd("HodoRateYhistbar_0",@hitRatesHodoY_0[$i],$i);
+ HPlot::PlotAdd("HodoRateXhistbar_0",$hitRatesHodoX_0[$i],$i);
+ HPlot::PlotAdd("HodoRateYhistbar_0",$hitRatesHodoY_0[$i],$i);
+ }
+
+ HPlot::PlotDrawFork('HodoPosition') if ($iter == 1);
+ HPlot::PlotDrawFork('HodoRateXhistbar_0') if ($iter == 2);
+ HPlot::PlotDrawFork('HodoRateYhistbar_0') if ($iter == 3);
+# HPlot::PlotDrawFork('SpillSumX') if ($iter == 4);
+# HPlot::PlotDrawFork('SpillPeakX') if ($iter == 5);
+# HPlot::PlotDrawFork('SpillSumY') if ($iter == 6);
+# HPlot::PlotDrawFork('SpillPeakY') if ($iter == 7);
+# HPlot::PlotDrawFork('DutyFactorX') if ($iter == 8);
+# HPlot::PlotDrawFork('DutyFactorY') if ($iter == 9);
+
+ $iter = 1 if ($iter++ == 10) #dont change
+
+ }
+
+ $lastinspill = $inspill;
+ $old = $current_readout;
+ usleep(100000);
+}
+
+
+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}-1, $ch->{pch} );
+ 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}-1,$ch->{pch});
+ my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch});
+ $trbnet += $trbnet_endpoint_offset;
+ my $hits = $current_readout->{$trbnet}->{value}->[$channel];
+ my $hitdiff = ($hits & 0xfffffff)-($old->{$trbnet}->{value}->[$channel] & 0xfffffff);
+ printf("%04x %04x\n",$trbnet,$channel) unless defined $hits;
+ $hitdiff +=2**28 if $hitdiff < 0;
+ my $time = $current_readout->{$trbnet}->{time}->[$channel];
+ my $tdiff = $time - ($old->{$trbnet}->{time}->[$channel]);
+ $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;
+
+}
+sub calculate_rates{
+ my ($ra_channels, $old,$current_readout) = @_ ;
+
+ my @result;
+ for my $i (0..15){
+ $result[$i] = 0;
+ }
+
+ foreach my $ch (@$ra_channels) {
+ # my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch}-1,$ch->{pch});
+ my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch},$ch->{pch});
+ $trbnet += $trbnet_endpoint_offset;
+ my $hits = $current_readout->{$trbnet}->{value}->[$channel];
+
+ my $hitdiff = ($hits & 0xfffffff)-($old->{$trbnet}->{value}->[$channel] & 0xfffffff);
+ $hitdiff +=2**28 if $hitdiff < 0;
+ my $time = $current_readout->{$trbnet}->{time}->[$channel];
+ my $tdiff = $time - ($old->{$trbnet}->{time}->[$channel]);
+ $tdiff += 2**16 if $tdiff <0;
+ $tdiff *= 16;
+ my $rate = $hitdiff / ($tdiff || 1E6) * 1E6 ;
+
+ # $result[int($phy_channel/5)] += $rate;
+ $result[$phy_channel] = $rate;
+ }
+
+# for my $i(0..11){
+# $result[$i] +=2**28 if $result[$i] < 0;
+# }
+
+ return @result;
+}
+
+sub spillAnalysis{
+ my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
+
+ my $lastsum = 0; # sum of entries in last 15 readouts
+ my @totalDetectorHits = @{$totalDetectorHitsReference};
+ my @lastSpills = @{$lastSpillReference};
+ my ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, $spillEnds) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+
+ for my $i (1..15) { $lastsum += $totalDetectorHits[-$i]//0;}
+
+ #end of spill signaled by last 15 readouts having an average below spillThreshold entries and the one before having more
+ if($lastsum < 15 * $spillThreshold && ($totalDetectorHits[-16]//0) > $spillThreshold){
+ $max = max(@totalDetectorHits);
+ my $samples = scalar @totalDetectorHits;
+ my $avg = sum(@totalDetectorHits)/$samples;
+ $duty = $avg/$max;
+ $total = sum(@totalDetectorHits)/$samplesPerSecond;# sum and mulitply by bin width -> Integral. Gives total hits in a spill
+
+ push(@lastSpills,$total);
+ shift(@lastSpills) if scalar @lastSpills > 50;
+
+ $spillmin = min(@lastSpills);
+ $spillmax = max(@lastSpills);
+ $spillavg = sum(@lastSpills)/(scalar @lastSpills);
+ $flucqual = ($spillmax-$spillmin)/$spillavg;
+ $offtime = $empties/10;
+ $length = sprintf("%0.1f s (%i samples)", time()-$time, $samples);
+
+ $empties = 0;
+ $time = time();
+ @totalDetectorHits = ();
+
+ return ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, 1);
+ }
+
+ return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+sub spillAnalysisACCSIG{
+ my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
+
+ my @totalDetectorHits = @{$totalDetectorHitsReference};
+ my @lastSpills = @{$lastSpillReference};
+ my ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, $spillEnds) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+
+
+ #end of spill signaled by last 15 readouts having an average below spillThreshold entries and the one before having more
+# if($inspill == 0 && $lastinspill == 1){
+ $max = max(@totalDetectorHits);
+ my $samples = scalar @totalDetectorHits;
+ my $avg = sum(@totalDetectorHits)/$samples;
+ $duty = $avg/($max||1);
+ $total = sum(@totalDetectorHits)/$samplesPerSecond;# sum and mulitply by bin width -> Integral. Gives total hits in a spill
+
+ push(@lastSpills,$total);
+ shift(@lastSpills) if scalar @lastSpills > 50;
+
+ $spillmin = min(@lastSpills);
+ $spillmax = max(@lastSpills);
+ $spillavg = sum(@lastSpills)/(scalar @lastSpills);
+ $flucqual = ($spillmax-$spillmin)/($spillavg||1);
+ $offtime = $empties/10;
+ $length = sprintf("%0.1f s (%i samples)", gettimeofday()-$time, $samples);
+ $empties = 0;
+ $time = gettimeofday();
+
+
+ # @totalDetectorHits = ();
+
+# $lastinspill = $inspill;
+ return ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length,$time, $empties, 1);
+# }
+# $lastinspill = $inspill;
+# return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
if ($vdiff < 0) { $vdiff += 2**28;}
$diff->{$board}->[$v] = $vdiff/$tdiff;
#$ratesum += $diff->{$b}->[$v+1];
+ next if ($v%16 == 15);
HPlot::PlotFill('ItofRate',$diff->{$board}->[$v],$v%16,$xpos+$v/16);
}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw(usleep);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
my $lasttime = 0;
my $store = {};
- my @out = qx(ssh lxhadesdaq cat /home/hadeslog/messages | grep 'Endp 0x\\w\\w\\w\\w .* missing');
+ my @out = qx(ssh lxhadesdaqp cat /home/hadeslog/messages | grep 'Endp 0x\\w\\w\\w\\w .* missing');
foreach my $s ( @out) {
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Time::HiRes qw( gettimeofday usleep time );
my $values = {};
my $sum = 0;
my $totalsum = 0;
+ my $boardstring = "";
my $r_store = \%store;
$values = Hmon::MakeDifferences($r_store, \%laststore, 2**31*2);
($min,$max,$avg) = Hmon::MakeMinMax3($r_store, 4, 6, 16, 0);
$raw->{$b} = sprintf("%i", $r_store->{$l}->{$s}->{$b});
$totalsum += $r_store->{$l}->{$s}->{$b};
$sum += $values->{$l}->{$s}->{$b};
+ if($values->{$l}->{$s}->{$b}) {
+ $boardstring .= sprintf(" 2%x%x%x",$l,$s,$b);
+ }
}
$str[1][$l] .= Hmon::DrawMDC($l, $s, $color, $raw);
}
# QA::WriteQALog($fqa, "mdc", "oeps", 20, $qastate,
# "OEP present", "$numboards / " . $QA::MdcOepLimits[0], "");
- QA::WriteQALog($flog,"mdc","token",20,$qastate,"MBO Reinit",($sum || 0)."","Missing Tokens / MBO Reinitializations during last second: $sum - Total number of reinits: $totalsum");
+ QA::WriteQALog($flog,"mdc","token",20,$qastate,"MBO Reinit",($sum || 0)."","Missing Tokens / MBO Reinitializations during last second: $sum <br> Total number of reinits: $totalsum <br> Boards $boardstring");
%laststore = %store;
sleep 1;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
my @names = qw(5.8V 5V 3.8V 3.3V 1.8V 1.2V 3V -3V);
my @minimum = (5.5, 4.75, 3.5, 3.15, 1.4, 1.15, 2.90, -3.05);
-my @maximum = (6.2, 5.1, 4.0, 3.4, 2.0, 1.25, 3.10, -2.95);
+my @maximum = (6.3, 5.1, 4.0, 3.4, 2.1, 1.25, 3.10, -2.95);
my $fqa = QA::OpenQAFile();
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw(usleep);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use Hmon;
use QA;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my $msg = "";
# JAM2020- the pgrep command defaults on lxhadeb06 have changed for debian9. use -fal instead -fl:
- my $cmd = "ssh hades63 'pgrep -fal \"hadesonlineserver.exe .* 5678\"' </dev/null";
+ my $cmd = "ssh hades66 'pgrep -fal \"hadesonlineserver.exe .* 5678\"' </dev/null";
my @out = qx($cmd);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
trb_init_ports() or die trb_strerror();
my $flog = Hmon::OpenLogfile();
my $fqa = QA::OpenQAFile();
+my $errorcnt = 0;
+
while(1) {
my @r;
}
my $worstQaState = ( $qastateTemp != QA::OK ? $qastateTemp : $qastateNof);
+
+ if ($worstQaState == QA::OK) {
+ $errorcnt = 0;
+ }
+ else {
+ $errorcnt++;
+ }
+
+ if ($worstQaState != QA::OK && $errorcnt <= 2) {
+ $worstQaState = QA::OK;
+ }
+
QA::WriteQALog($fqa,"padiwa","ecal", 45, $worstQaState, "ECAL", $nofStr . " | " . $tempStr,
$tempStr2. "Temperature in ECAL " . $tempStr . "°C.<br>" . $nofStr2 . $nofStr . " PADIWAs<br>" . " Missing are: " . $missing_str);
--- /dev/null
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Data::Dumper;
+# use Data::TreeDumper;
+use Hmon;
+use QA;
+use HADES::TrbNet;
+use HPlot;
+use Dmon;
+use Time::HiRes qw(usleep);
+use List::Util qw[min max];
+
+trb_init_ports() or die trb_strerror();
+my $flog = Hmon::OpenLogfile();
+my $fqa = QA::OpenQAFile();
+my $errorcnt = 0;
+
+
+while(1) {
+ my @r;
+ $r[0] = Dmon::PadiwaSendCmd(0x1004 << 16,0x5010,0) or sleep 1 and next;
+ $r[1] = Dmon::PadiwaSendCmd(0x1004 << 16,0x5011,0) or sleep 1 and next;
+
+ my $min = 1000;
+ my $max = 0;
+ my $count = 0;
+ my @missing = ();
+ my $c = -1;
+ if (!defined $r[0] || $r[0] == -1 || scalar %{$r[0]} < 1) {sleep 10; next;}
+ foreach my $r (@r) {
+ $c++;
+ foreach my $b (keys %{$r}) {
+ last if $r->{$b} =~ /SPI/;
+# next if ($b < 0x5010 || $b > 0x5011);
+ my $t = ($r->{$b} & 0xfff)/16;
+ if ($t < 84 && $t > 10) {
+ $count++;
+ }
+ else {
+ push @missing, sprintf("%04x-%i ",$b,$c);
+ }
+ # $missing .= sprintf("%04x-%i ",$b,$c) if $t > 90;
+ next if $t < 10 || $t > 84;
+ $min = $t if $t < $min;
+ $max = $t if $t > $max;
+ }
+ }
+ if ($count > $QA::PadiwaHodoNumber) {
+ sleep 5;
+ next;
+ }
+ @missing = sort @missing;
+ my $missing_str = "";
+ my $ctr = 1;
+ foreach (@missing) {
+ $missing_str .= "<br>" if $ctr % 5 == 0;
+ $missing_str .= $_;
+ $ctr++;
+ }
+
+ my $qastateTemp = QA::GetQAState('below', $max, @QA::StartTempLimits);
+ my $qastateNof = QA::GetQAState('below', $QA::PadiwaHodoNumber-$count, @QA::PadiwaHodoLimits);
+ my $tempStr = sprintf("%i-%i", $min, $max);
+ my $tempStr2;
+ if ($qastateTemp == QA::OK) {
+ $tempStr2 = sprintf("<b>Temperature OK</b><br>");
+ }
+ else {
+ $tempStr2 = sprintf("<b>Temperature Bad</b><br>");
+ }
+
+ my $nofStr = sprintf("%i/%i",$count,$QA::PadiwaHodoNumber);
+ my $nofStr2;
+ if ($count == $QA::PadiwaHodoNumber) {
+ $nofStr2 = sprintf("<b>Number of PADIWA OK</b><br>All ") ;
+ }
+ else {
+ $nofStr2 = sprintf("<b>Number of PADIWA");
+ $nofStr2 .= $qastateNof == QA::OK ? sprintf(" Suboptimal</b><br>Only ") : sprintf(" Bad</b><br>Only ");
+ }
+
+ my $worstQaState = ( $qastateTemp != QA::OK ? $qastateTemp : $qastateNof);
+
+ if ($worstQaState == QA::OK) {
+ $errorcnt = 0;
+ }
+ else {
+ $errorcnt++;
+ }
+
+ if ($worstQaState != QA::OK && $errorcnt <= 2) {
+ $worstQaState = QA::OK;
+ }
+
+ QA::WriteQALog($fqa,"padiwa","hodo", 45, $worstQaState, "Hodo", $nofStr . " | " . $tempStr,
+ $tempStr2. "Temperature in Hodo " . $tempStr . "°C.<br>" . $nofStr2 . $nofStr . " PADIWAs<br>" . " Missing are: " . $missing_str);
+
+ sleep(10);
+}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
trb_init_ports() or die trb_strerror();
my $flog = Hmon::OpenLogfile();
my $fqa = QA::OpenQAFile();
+my $errorcnt = 0;
+
while(1) {
my @r;
}
my $worstQaState = ( $qastateTemp != QA::OK ? $qastateTemp : $qastateNof);
+
+ if ($worstQaState == QA::OK) {
+ $errorcnt = 0;
+ }
+ else {
+ $errorcnt++;
+ }
+
+ if ($worstQaState != QA::OK && $errorcnt <= 2) {
+ $worstQaState = QA::OK;
+ }
+
QA::WriteQALog($fqa,"padiwa","itof", 45, $worstQaState, "iTOF", $nofStr . " | " . $tempStr,
$tempStr2. "Temperature in iTOF " . $tempStr . "°C.<br>" . $nofStr2 . $nofStr . " PADIWAs<br>" . " Missing are: " . $missing_str);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
my $flog = Hmon::OpenLogfile();
my $fqa = QA::OpenQAFile();
+my $errorcnt = 0;
+
while(1) {
my @r;
- $r[0] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe74,0) or sleep 1 and next;
- $r[1] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe74,1) or sleep 1 and next;
- $r[2] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe74,2) or sleep 1 and next;
+ $r[0] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe76,0) or sleep 1 and next;
+ $r[1] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe76,1) or sleep 1 and next;
+ $r[2] = Dmon::PadiwaSendCmd(0x1004 << 16,0xfe76,2) or sleep 1 and next;
my $min = 1000;
my $max = 0;
$c++;
foreach my $b (keys %{$r}) {
last if $r->{$b} =~ /SPI/;
- next if ($b < 0x5000 || $b > 0x5003);
+ next if ($b < 0x5000 || $b > 0x5007);
my $t = ($r->{$b} & 0xfff)/16;
- $count++ unless $t > 90;
- push @missing, sprintf("%04x-%i ",$b,$c) if $t > 90;
+ if ($t < 84 && $t > 10) {
+ $count++;
+ }
+ else {
+ push @missing, sprintf("%04x-%i ",$b,$c);
+ }
# $missing .= sprintf("%04x-%i ",$b,$c) if $t > 90;
- next if $t < 10 || $t > 90;
+ next if $t < 10 || $t > 84;
$min = $t if $t < $min;
$max = $t if $t > $max;
}
}
-
+ if ($count > $QA::PadiwaStartNumber) {
+ sleep 5;
+ next;
+ }
@missing = sort @missing;
my $missing_str = "";
my $ctr = 1;
}
my $worstQaState = ( $qastateTemp != QA::OK ? $qastateTemp : $qastateNof);
+
+ if ($worstQaState == QA::OK) {
+ $errorcnt = 0;
+ }
+ else {
+ $errorcnt++;
+ }
+
+ if ($worstQaState != QA::OK && $errorcnt <= 2) {
+ $worstQaState = QA::OK;
+ }
+
QA::WriteQALog($fqa,"padiwa","start", 45, $worstQaState, "Start", $nofStr . " | " . $tempStr,
$tempStr2. "Temperature in Start " . $tempStr . "°C.<br>" . $nofStr2 . $nofStr . " PADIWAs<br>" . " Missing are: " . $missing_str);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
$str = Hmon::MakeTitle(12, 6, "CTS Rates", 1, "");
$str .= "<table class=\"rates\">\n";
$str .= "<tr><th style=\"width:80px\"><th>1<th>2<th>3<th>4<th>5<th>6<th>7<th>8\n";
- $str .= "<tr><th>Start in";
+ $str .= "<tr><th>Start X in";
my $i;
foreach $i (0, 1, 2, 3, 4, 5, 6, 7) {
$str .= sprintf("<td class=\"%s\">%d", ($ena & ( 1<< $i)) ? "on" : "off",
$store{0xa008+$i});
}
+ $str .= "<tr class=\"linebelow\"><th>Start Y in";
+ foreach $i (95,96,97,98,99,100,101,102) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i-59)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
$str .= "<tr class=\"linebelow\"><th>Veto in";
foreach $i (8, 9, 10, 11, 12, 13, 14, 15) {
$str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i)) ? "on" : "off",
--- /dev/null
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Hmon;
+use Data::Dumper;
+use HADES::TrbNet;
+use List::Util qw[min max];
+use QA;
+
+trb_init_ports() or die trb_strerror();
+
+my $flog = Hmon::OpenLogfile();
+my $fqa = QA::OpenQAFile();
+
+my $offset;
+my $starterrorcnt = 0;
+
+sub getRate {
+ my ($newval, $oldval, $timediff) = @_;
+ $new = 0 unless $new;
+ $old = 0 unless $old;
+ $timediff = 1 unless $timediff;
+ my $vdiff = ($newval&0xfffffff) - ($oldval&0xfffffff);
+ $vdiff += 2**28 if $vdiff < 0;
+ return $vdiff/$timediff;
+}
+
+sub getCorrectedRate {
+ my ($new, $old, $timediff, $corr) = @_;
+ $cor = 0 unless $cor;
+ my $rate = getRate($new, $old, $timediff);
+ my $value = max($val-$cor,0);
+ return $value;
+}
+
+sub isOn {
+ my ($val) = @_;
+ return $val & 2**32;
+}
+
+my $beam_ch = 0x905d;
+my $start_ch0 = 0x9038; #0x9038 -- 0x903f
+my $start_ch9 = 0x9048; #0x9048 -- 0x904f
+my @tof_chn = (0x9020+0, 0x9020+1, 0x9020+2, 0x9020+3, 0x9020+4, 0x9020+5);
+my @rpc_chn = (0x9028+0, 0x9028+1, 0x9028+2, 0x9028+3, 0x9028+5, 0x9028+6);
+
+my $old;
+
+while (1) {
+ my $r;
+ $r = trb_registertime_read_mem(0x0010, 0x9000, 0, 0xff) or sleep 5 and next;
+ if(! $old) {
+ $old = $r and next;
+ }
+
+ my %rate;
+ foreach my $board (sort {$a <=> $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 .= "<table class=\"rates\">\n";
+ $str .= "<tr><th style=\"width:80px\"><th>1<th>2<th>3<th>4<th>5<th>6<th>7<th>8\n";
+ $str .= "<tr><th>Start in";
+
+ my $i;
+ foreach $i (0, 1, 2, 3, 4, 5, 6, 7) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & ( 1<< $i)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
+ $str .= "<tr class=\"linebelow\"><th>Veto in";
+ foreach $i (8, 9, 10, 11, 12, 13, 14, 15) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
+
+ $str .= "<tr><th>TOF in";
+ foreach $i (16, 17, 18, 19, 20, 21) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
+ $str .= "<td>--<td>--";
+ $str .= "<tr><th>RPC in";
+ foreach $i (22, 23, 24, 25, 26, 27) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
+ $str .= "<td>--<td>--";
+ $str .= "<tr class=\"linebelow\"><th>Mult out";
+ foreach $i (2, 3, 4, 5, 6, 7) {
+ $str .= sprintf("<td class=\"%s\">%d", ($eno & (1<<($i))) ? "on" : "off",
+ $store{0xa03f+$i});
+ }
+ $str .= "<td>--<td>--";
+
+ $str .= "<tr><th>PT in";
+ foreach $i (28, 29, 30, 31, 32, 33, 34, 35) {
+ $str .= sprintf("<td class=\"%s\">%d", ($ena & (1 << $i)) ? "on" : "off",
+ $store{0xa008+$i});
+ }
+ $str .= "<tr><th>PT dsc";
+ foreach $i (11, 12, 13, 14, 15, 16, 17, 18) {
+ $str .= sprintf("<td class=\"%s\">%d","on",$store{0xa02c+$i});
+ }
+ $str .= "<tr><th>PT coin";
+ foreach $i (9,10,11, 12, 13, 14, 15, 16) {
+ $str .= sprintf("<td class=\"%s\">%d","on",$store{0xa052+$i});
+ }
+ $str .= "<tr class=\"linebelow\"><th>PT out";
+ foreach $i (11, 12, 13, 14, 15, 16, 17, 18) {
+ $str .= sprintf("<td class=\"%s\">%d", ($eno & (1 << $i)) ? "on" : "off",
+ $store{0xa03f+$i});
+ }
+ $str .= "<tr><th>Pulser";
+ $str .= sprintf("<td class=\"%s\">%d", ($store{0xa0e3}) ? "on" : "off",
+ ($store{0xa0e3}) ? 1/$store{0xa0e3} * 2E8 : 0);
+ $str .= "<td>--";
+ $str .= sprintf("<td class=\"%s\">MDC Calib.",
+ ($store{0xa0c0} &0x20) ? "on" : "off");
+ $str .= sprintf("<td class=\"%s\">SHW Calib.",
+ ($store{0xa0c0} &0x100) ? "on" : "off");
+ $str .= sprintf("<td class=\"%s\">SHW Ped.",
+ ($store{0xa0c0} & 0x80) ? "off" : "on");
+ $str .= sprintf("<td class=\"%s\">Status",
+ ($store{0xa0c0}& 0x200)?"on":"off");
+ $str .= "<td>--<td>--";
+ $str .= "<tr><th>Out<td><td><td><td><td><td><td>";
+ $str .= sprintf("<td class=\"%s\"><b>%d</b>",
+ ($store{0xa001}) ? "on" : "off", $store{0xa001});
+ $str .= "</table>\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;
+}
+
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Time::HiRes qw( gettimeofday usleep time );
--- /dev/null
+#!/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 @prev_rich_miss;
+my $fh_missRich;
+open ($fh_missRich, ">>", "/tmp/rich_missing_boards_fast");
+if (!$fh_missRich) {
+ print STDERR "error opening temp file: /tmp/rich_missing_boards_fast\n";
+ exit;
+}
+print $fh_missRich "Start of script ... ". QA::getTimeString()."\n";
+
+close $fh_missRich;
+
+
+while(1) {
+ my @result = trb_register_read_c(0xffff, 0x0) or sleep 5 and next;
+
+ ####config
+ my @all_boards =();
+
+ 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,
+ );
+
+
+ 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];
+ }
+
+ ###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]};
+
+
+ ### Check for lost boards
+ if ($num_rich_missing < 900 ) { ## do not check if RICH is off
+ open ($fh_missRich, ">>", "/tmp/rich_missing_boards_fast");
+ if (!$fh_missRich) {
+ print STDERR "error opening temp file: /tmp/rich_missing_boards_fast\n";
+ exit;
+ }
+
+ foreach my $rich_element (@sorted_rich_results) {
+ ## check if board was already missing
+ my $foundBoard = 0;
+ foreach my $prev_rich_element (@prev_rich_miss) {
+ if ( $rich_element eq $prev_rich_element ) {
+ $foundBoard = 1;
+ last;
+ }
+ }
+ if ($foundBoard == 1 ) {
+ #print "already missing $rich_element \n";
+ } else {
+ print $fh_missRich "new missing board $rich_element. ". QA::getTimeString()."\n";
+ }
+ }
+ ### check for reconnected boards
+ foreach my $prev_rich_element(@prev_rich_miss) {
+ ## check if board was already missing
+ my $foundBoard = 0;
+ foreach my $rich_elements (@sorted_rich_results) {
+ if ( $rich_elements eq $prev_rich_element ) {
+ $foundBoard = 1;
+ last;
+ }
+ }
+ if ($foundBoard == 0 ) {
+ print $fh_missRich "board $prev_rich_element reconnected. ". QA::getTimeString()."\n";
+ }
+ }
+ close $fh_missRich;
+ }
+ ### Store misisng boards for next check
+ @prev_rich_miss = @sorted_rich_results;
+ sleep(10);
+}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
entries => 1200,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
- titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+# titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ titles => ["M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
#titles => ['min','max','mean'],
xlabel => "Minutes",
ylabel => "Temperature [°C]",
sizey => 300,
#ymin => "*<15",
#ymax => "40<*",
- curves => 24,
+# curves => 24,
+ curves => 20,
xscale => 6,
storable=> 1,
buffer => 1,
- colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+# colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ colors => ["#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
additional => "set offsets 0,0,1.5,1.5"
# colors => ["#333333","#00ff00","#ff0000"]
};
entries => 1200,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
- titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+# titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ titles => ["M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
#titles => ['min','max','mean'],
xlabel => "Hours",
ylabel => "Temperature [°C]",
sizey => 300,
#ymin => "*<15",
#ymax => "40<*",
- curves => 24,
+# curves => 24,
+ curves => 20,
xscale => 60,
storable=> 1,
buffer => 1,
- colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+# colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ colors => ["#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
additional => "set offsets 0,0,1.5,1.5"
# colors => ["#333333","#00ff00","#ff0000"]
};
HPlot::PlotInit($plot3);
+my $plot4 = {
+ name => "RichMagnetHistLong",
+ file => "files/RichMagnetHistLong",
+ entries => 1200,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+# titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ titles => ["M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ #titles => ['min','max','mean'],
+ xlabel => "Hours",
+ ylabel => "B [uT]",
+ sizex => 950,
+ sizey => 300,
+ #ymin => "*<15",
+ #ymax => "40<*",
+# curves => 24,
+ curves => 20,
+ xscale => 60,
+ storable=> 1,
+ buffer => 1,
+# colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ colors => ["#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ additional => "set offsets 0,0,1.5,1.5"
+# colors => ["#333333","#00ff00","#ff0000"]
+ };
+HPlot::PlotInit($plot4);
+
-my $str = Hmon::MakeTitle(7, 9, "RICH Magnet",0);
+my $plot5 = {
+ name => "RichMagnetHist",
+ file => "files/RichMagnetHist",
+ entries => 1200,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+# titles => ["M_0_0","M_0_1","M_0_2","M_0_3","M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ titles => ["M_1_0","M_1_1","M_1_2","M_1_3","M_2_0","M_2_1","M_2_2","M_2_3","M_3_0","M_3_1","M_3_2","M_3_3","M_4_0","M_4_1","M_4_2","M_4_3","M_5_0","M_5_1","M_5_2","M_5_3"],
+ #titles => ['min','max','mean'],
+ xlabel => "Minutes",
+ ylabel => "B [uT]",
+ sizex => 950,
+ sizey => 300,
+ #ymin => "*<15",
+ #ymax => "40<*",
+# curves => 24,
+ curves => 20,
+ xscale => 6,
+ storable=> 1,
+ buffer => 1,
+# colors => ["#333333","#00ff00","#ff0000","#0022ff","#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ colors => ["#9a176d","#b844b8","#555555","#22ff22","#ffaaaa","#2222ff","#2d9c94","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df","#777777","#55ff77","#ff7755","#7575ff","#aadd47","#aa0033","#316022","#09b9df"],
+ additional => "set offsets 0,0,1.5,1.5"
+# colors => ["#333333","#00ff00","#ff0000"]
+ };
+HPlot::PlotInit($plot5);
+
+
+my $str = Hmon::MakeTitle(12, 21, "RICH Magnet",0);
$str .= qq@<img src="%ADDPNG files/RichMagnet.png%" type="image/png"><br>\n@;
+$str .= qq@<img src="%ADDPNG files/RichMagnetHist.png%" type="image/png"><br>\n@;
+$str .= qq@<img src="%ADDPNG files/RichMagnetHistLong.png%" type="image/png"><br>\n@;
$str .= Hmon::MakeFooter();
Hmon::WriteFile("RichMagnet",$str);
trb_init_ports() or die trb_strerror();
-my $calib = [[[70.000,1.083,235.889],[-73.417,-29.833,-36.539],[-13.833,-34.333,-115.930],[5.667,-21.333,39.494]],[[101.333,-75.167,204.321],[-39.700,-77.800,-149.271],[109.700,-63.300,-2.418],[-36.400,-25.300,-139.438]],[[75.100,-144.200,154.107],[-34.500,-149.000,-166.520],[1.400,-91.500,-25.631],[49.100,-65.000,-106.553]],[[63.400,-155.100,-26.114],[-93.000,-72.600,164.908],[167.600,-68.200,-152.495],[-14.200,-39.600,-87.854]],[[-26.800,-8.100,35.625],[93.600,-14.800,208.109],[86.000,-6.500,197.309],[12.200,1.500,-215.041]],[[-116.500,-41.200,161.361],[-15.100,-11.000,-55.936],[-4.300,-17.400,26.598],[37.900,14.100,151.850]]];
+#my $calib = [[[70.000,1.083,235.889],[-73.417,-29.833,-36.539],[-13.833,-34.333,-115.930],[5.667,-21.333,39.494]],[[101.333,-75.167,204.321],[-39.700,-77.800,-149.271],[109.700,-63.300,-2.418],[-36.400,-25.300,-139.438]],[[75.100,-144.200,154.107],[-34.500,-149.000,-166.520],[1.400,-91.500,-25.631],[49.100,-65.000,-106.553]],[[63.400,-155.100,-26.114],[-93.000,-72.600,164.908],[167.600,-68.200,-152.495],[-14.200,-39.600,-87.854]],[[-26.800,-8.100,35.625],[93.600,-14.800,208.109],[86.000,-6.500,197.309],[12.200,1.500,-215.041]],[[-116.500,-41.200,161.361],[-15.100,-11.000,-55.936],[-4.300,-17.400,26.598],[37.900,14.100,151.850]]];
+my $calib = [[[0,0,0],[0,0,0],[0,0,0],[0,0,0]],[[98.185,-163.24,201.231],[-39.24,-110.981,-151.08],[108,-72.055,-4.895],[-31.018,-26.925,-142.602]],[[75.425,-254.277,157.767],[-34.388,-190.092,-158.632],[2.666,-107.351,-21.941],[48.148,-78.888,-101.854]],[[62.777,-273.407,-24.239],[-90.962,-117.314,167.08],[165.351,-89.092,-150.93],[-8.962,-53.666,-89.137]],[[-19.703,-105.685,38.867],[98.462,-53.592,210.754],[90.333,-23.481,199.32],[15,-6.481,-207.112]],[[-113.481,-165.777,156.155],[-10.962,-57.962,-56.121],[0.592,-36.574,31.702],[34.685,2.925,156.632]]];
my $cnt=0;
my $longcnt=0;
my @TempLong = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
my @TempLongCnt = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+my @MagnetLong = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+my @MagnetLongCnt = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+
while(1){
my $count = 0;
my $data;
$maxtemp = $t if $t > $maxtemp;
my $reg = 4*$boardT+$sensT;
if ($cnt > 7) {$cnt =0;} else {$cnt++;}
- if ($t != 0) {HPlot::PlotAdd('RichInnerTempHist',$t,$reg);}
+ if ($reg > 3) {
+ if ($t != 0) {HPlot::PlotAdd('RichInnerTempHist',$t,$reg-4);}
+ }
+# HPlot::PlotAdd('RichInnerTempHist',$t,$reg);
$TempLong[$reg]+=$t;
$TempLongCnt[$reg]++;
$str_log .= sprintf("%3.2f\t",$t);
if (($magActive->{0x0110}[$board] >> 8) == 0 ) {
#HPlot::PlotFill('RichMagnet',sqrt($val),$board,$sens);
Val2Hist('RichMagnet',sqrt($val),$board,$sens);
+ my $sensorID2Array = $board*4+$sens;
+ $MagnetLong[$sensorID2Array]+=sqrt($val);
+ $MagnetLongCnt[$sensorID2Array]++;
+ if ($sensorID2Array > 3){
+ if ($val != 0) {HPlot::PlotAdd('RichMagnetHist',sqrt($val),$sensorID2Array-4);}
+ }
}
}
HPlot::PlotDraw('RichMagnet');
HPlot::PlotDraw('RichInnerTemp');
HPlot::PlotDraw('RichInnerTempHist');
+ HPlot::PlotDraw('RichMagnetHist');
$data->{max} = $maxtemp;
#long Range Hist
for (my $i=0;$i<24;$i++){
$TempLong[$i] /= $TempLongCnt[$i]||1;
- if ($TempLong[$i] != 0) {HPlot::PlotAdd('RichInnerTempHistLong',$TempLong[$i],$i);}
+ if ($i > 3) {
+ if ($TempLong[$i] != 0) {HPlot::PlotAdd('RichInnerTempHistLong',$TempLong[$i],$i-4);}
+ }
#print $TempLong[$i]."\n";
$TempLong[$i] = 0;
$TempLongCnt[$i] = 0;
+
+ $MagnetLong[$i] /= $MagnetLongCnt[$i]||1;
+ if ($i > 3) {
+ if ($MagnetLong[$i] != 0) {HPlot::PlotAdd('RichMagnetHistLong',$MagnetLong[$i],$i-4);}
+ }
+ #print $MagnetLong[$i]."\n";
+ $MagnetLong[$i] = 0;
+ $MagnetLongCnt[$i] = 0;
}
HPlot::PlotDraw('RichInnerTempHistLong');
+ HPlot::PlotDraw('RichMagnetHistLong');
$longcnt = 0;
}
$longcnt++;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use POSIX qw(strftime);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use HADES::TrbNet;
use HPlot;
use Time::HiRes qw(usleep time);
-use List::Util qw[min max];
+use List::Util qw[min max sum];
use Encode qw(encode from_to);
use JSON::XS;
+my $fqa = QA::OpenQAFile();
+
my $plot1 = {
name => "RpcRate",
my $diff;
my $iter = 0;
+my $lowratelimit = 200;
+my $highratelimit = 50000;
+my $lowratecount = 300;
+my $highratecount = 10;
+
trb_init_ports() or die trb_strerror();
+my $qastate = QA::OK;
+my $text = "OK";
+my $shorttext = "OK";
while(1) {
#my $data;
#my $max = 0 ;
#my $min = 5E9;
-
+ my @lowrate = (0,0,0,0,0,0); my @highrate = (0,0,0,0,0,0);
my $o = trb_register_read_mem(0xfe73,0xdfc0,0,48) or die trb_strerror() or sleep 5 and next;
if (defined $old) {
if ($vdiff < 0) { $vdiff += 2**24;}
$diff->{$b}->[$v] = $vdiff/$tdiff;
- #$ratesum += $diff->{$b}->[$v+1];
HPlot::PlotFill('RpcRate',$diff->{$b}->[$v],$v,$xpos);
+
+
+ $highrate[($b>>4)&0xF]++ if ($diff->{$b}->[$v] > $highratelimit);
+ $lowrate[($b>>4)&0xF]++ if ($diff->{$b}->[$v] < $lowratelimit);
}
- #my $s = sprintf("0x%04x",$b);
- #$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('RpcRate');
-
+ HPlot::PlotDrawFork('RpcRate');
- # $data->{max} = $max;
- # $data->{min} = $min;
- # $data->{symbol} = " Hits/s";
- # $data->{title} = "Mean DiRICH TDC Rate";
+
+ }
-
- # $data->{updatetime} = getTimeString;
+ if(sum(@lowrate) > $lowratecount * 6) {
+
+ $qastate = QA::OK;
+ $text = "OK";
+ $shorttext = "OK";
- # my $fh;
- # open($fh, ">", Hmon::HMONDIR."/files/richMeanRateDiRICH.json");
- # print $fh encode_json($data);
- # close $fh;
- }
+ for my $i (0..5) {
+ if ($highrate[$i] > $highratecount) {
+ $qastate = QA::ERROR;
+ $shorttext = "Problem";
+ $text = "Sector $i has $highrate[$i] high rates.";
+ }
+ }
+
+ QA::WriteQALog($fqa,"feeerr","rpc", 60, $qastate, "RPC Thresh", $shorttext, $text);
+ }
$old = $o;
$oldtime = time();
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw(usleep);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw(usleep);
my $rpcsum = 0;
my $tofsum = 0;
- my $o = trb_register_read(0xfe60,0xdfe6);
+ my $o = trb_register_read(0xfe61,0xdfe6);
foreach my $b (keys %{$o}) {
next unless defined $oldrpc->{$b};
my $diff = $o->{$b} - $oldrpc->{$b};
}
$oldrpc = $o;
- $o = trb_register_read(0xfe60,0xdfe6);
+ $o = trb_register_read(0xfe40,0xdfd3);
foreach my $b (keys %{$o}) {
next unless defined $oldtof->{$b};
my $diff = $o->{$b} - $oldtof->{$b};
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw(usleep);
-#!/usr/bin/perl -w
+#!/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 gettimeofday);
+use Time::HiRes qw(usleep time gettimeofday);
use List::Util qw[min max sum];
+use Encode qw(encode from_to);
+use JSON::XS;
-trb_init_ports() or die trb_strerror();
+my %users = (name => "wiily", lastname => 'Krüger');
+my $ref_users = \%users;
-HPlot::PlotInit({
+
+my $plot3 = {
name => "StartPosition",
file => "files/StartPosition",
entries => 200,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
- titles => ["X position","Y position","Xrms","Yrms"],
+ 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 => 350,
+ sizey => 720,
ymin => "-0.5",
- ymax => "59.5",
+ ymax => "49.5",
curves => 4,
xscale => 10,
buffer => 1,
- });
-
-HPlot::PlotInit({
- name => "StartRateXhistbar",
- file => "files/StartRateXhistbar",
+ };
+
+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"],
sizex => 950,
sizey => 330,
xmin => 0,
- xmax => 200,
+ xmax => 2000,
ymin => "0",
ymax => "100<*",
curves => 12,
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({
- name => "StartRateYhistbar",
- file => "files/StartRateYhistbar",
- entries => 200,
+ };
+
+
+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"],
sizex => 950,
sizey => 330,
xmin => 0,
- xmax => 200,
+ xmax => 2000,
ymin => "0",
ymax => "100<*",
curves => 12,
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<*<1E7",
+ 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);
+
+# START spill plots
HPlot::PlotInit({
- name => "DutyFactorX",
- file => "files/DutyFactorX",
+ name => "StartDutyFactorX_0",
+ file => "files/StartDutyFactorX_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
buffer => 0,
nokey => 1,
storable => 1,
- });
-
+});
+
HPlot::PlotInit({
- name => "DutyFactorY",
- file => "files/DutyFactorY",
+ name => "StartSpillPeakX_0",
+ file => "files/StartSpillPeakX_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
xlabel => "Spills",
- ylabel => "Duty Factor",
+ ylabel => "Peak Intensity [Hz]",
sizex => 600,
sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
curves => 1,
buffer => 0,
nokey => 1,
storable => 1,
- });
+});
HPlot::PlotInit({
- name => "SpillSumX",
- file => "files/SpillSumX",
+ name => "StartSpillSumX_0",
+ file => "files/StartSpillSumX_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
buffer => 0,
nokey => 1,
storable => 1,
- });
+ });
+
HPlot::PlotInit({
- name => "SpillSumY",
- file => "files/SpillSumY",
+ name => "StartDutyFactorY_0",
+ file => "files/StartDutyFactorY_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
xlabel => "Spills",
- ylabel => "Total Sum",
+ ylabel => "Duty Factor",
sizex => 600,
sizey => 200,
- ymin => 0,
- ymax => "*<9E9",
curves => 1,
buffer => 0,
nokey => 1,
storable => 1,
- });
+});
HPlot::PlotInit({
- name => "SpillPeakX",
- file => "files/SpillPeakX",
+ name => "StartSpillPeakY_0",
+ file => "files/StartSpillPeakY_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
buffer => 0,
nokey => 1,
storable => 1,
- });
-
+});
+
HPlot::PlotInit({
- name => "SpillPeakY",
- file => "files/SpillPeakY",
+ name => "StartSpillSumY_0",
+ file => "files/StartSpillSumY_0",
entries => 100,
type => HPlot::TYPE_HISTORY,
output => HPlot::OUT_PNG,
xlabel => "Spills",
- ylabel => "Peak Intensity [Hz]",
+ ylabel => "Total Sum",
sizex => 600,
sizey => 200,
ymin => 0,
buffer => 0,
nokey => 1,
storable => 1,
- });
+ });
+# my $str = Hmon::MakeTitle(4, 7, "Start Hit Rate",0);
+# $str .= qq@<img src="%ADDPNG files/StartRateSimple_VW.png%" type="image/png"><br>\n@;
+# $str .= Hmon::MakeFooter();
+# Hmon::WriteFile("StartRateSimple_VW",$str);
-my $str = Hmon::MakeTitle(13, 8, "Start Position",0);
+my $str = Hmon::MakeTitle(6, 16, "Start Hit Numbers");
+$str .= qq@<img src="%ADDPNG files/StartRateNumbers.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateNumbers",$str);
+
+$str = Hmon::MakeTitle(13, 16, "Start Position",0);
$str .= qq@<img src="%ADDPNG files/StartPosition.png%" type="image/png">\n@;
$str .= Hmon::MakeFooter();
Hmon::WriteFile("StartPosition",$str);
-$str = Hmon::MakeTitle(13, 32, "Start Rates X",0);
-$str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateXhistbar.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start X Duty</h3><img src="%ADDPNG files/DutyFactorX.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start X Peak</h3><img src="%ADDPNG files/SpillPeakX.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start X Sum</h3><img src="%ADDPNG files/SpillSumX.png%" type="image/png"><br>\n@;
+
+$str = Hmon::MakeTitle(13, 16, "Start Position RMS",0);
+$str .= qq@<img src="%ADDPNG files/StartPositionRMS.png%" type="image/png">\n@;
$str .= Hmon::MakeFooter();
-Hmon::WriteFile("StartRateX",$str);
+Hmon::WriteFile("StartPositionRMS",$str);
+
+$str = Hmon::MakeTitle(8, 5, "DutyFactor",0);
+$str .= qq@<img src="%ADDPNG files/StartDutyFactorX_0.png%" type="image/png"><br\>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("DutyFactor",$str);
-$str = Hmon::MakeTitle(13, 32, "Start Rates Y",0);
-$str .= qq@<h3>Start Y Spill</h3><img src="%ADDPNG files/StartRateYhistbar.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start Y Duty</h3><img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start Y Peak</h3><img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start Y Sum</h3><img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br>\n@;
+$str = Hmon::MakeTitle(13, 32, "Start Summed Rates X",0);
+$str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateX_histbar.png%" type="image/png"><br>\n@;
$str .= Hmon::MakeFooter();
-Hmon::WriteFile("StartRateY",$str);
+Hmon::WriteFile("StartRateX_histbar",$str);
+$str = Hmon::MakeTitle(13, 32, "Start Summed Rates Y",0);
+$str .= qq@<h3>Start Y Spill</h3><img src="%ADDPNG files/StartRateY_histbar.png%" type="image/png"><br>\n@;
-$str = Hmon::MakeTitle(16, 32, "Spill Info Start",0);
-$str .= qq@<h3>Start Duty</h3><img src="%ADDPNG files/DutyFactorX.png%" type="image/png">\n@;
-$str .= qq@<img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start Peak</h3><img src="%ADDPNG files/SpillPeakX.png%" type="image/png">\n@;
-$str .= qq@<img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br>\n@;
-$str .= qq@<h3>Start Sum</h3><img src="%ADDPNG files/SpillSumX.png%" type="image/png">\n@;
-$str .= qq@<img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br>\n@;
$str .= Hmon::MakeFooter();
-Hmon::WriteFile("SpillInfoStart",$str);
+Hmon::WriteFile("StartRateY_histbar",$str);
+# Spill for START
+# $str = Hmon::MakeTitle(13, 32, "Start X Spill Summary",0);
+# $str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateX_histbar.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start X Duty Factor</h3><img src="%ADDPNG files/StartDutyFactorX_0.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start X Peak</h3><img src="%ADDPNG files/StartSpillPeakX_0.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start X Sum</h3><img src="%ADDPNG files/StartSpillSumX_0.png%" type="image/png"><br>\n@;
+# $str .= Hmon::MakeFooter();
+# Hmon::WriteFile("StarX_spill",$str);
+# $str = Hmon::MakeTitle(13, 32, "Start Y Spill Summary",0);
+# $str .= qq@<h3>Start Y Spill</h3><img src="%ADDPNG files/StartRateY_histbar.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start Y Duty Factor</h3><img src="%ADDPNG files/StartDutyFactorY_0.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start Y Peak</h3><img src="%ADDPNG files/StartSpillPeakY_0.png%" type="image/png"><br>\n@;
+# $str .= qq@<h3>Start Y Sum</h3><img src="%ADDPNG files/StartSpillSumY_0.png%" type="image/png"><br>\n@;
+# $str .= Hmon::MakeFooter();
+# Hmon::WriteFile("StarY_spill",$str);
+my $old;
+my $oldtime = time();
+my $time = time();
+my $diff;
my $iter = 1;
-
my $trbnet_endpoint_offset = 0x5000; #20480
+# Spill variables
+my @totalDetectorHitsX_0;
+my @totalDetectorHitsY_0;
+my $spillThreshold = 1000; # threshold of rate in detector signaling the End of the Spill
+my $samplesPerSecond =10;
-##
-##
-##
- # pch is physical channel in the detector, tdc is the connected TDC and ch is the channel of the TDC
-my $channels_x = [
- { pch => 0, tdc => 2, ch => 8 },
- { pch => 1, tdc => 3, ch => 11 },
- { pch => 2, tdc => 2, ch => 7 },
- { pch => 3, tdc => 3, ch => 12 },
- { pch => 4, tdc => 2, ch => 6 },
- { pch => 5, tdc => 3, ch => 13 },
- { pch => 6, tdc => 2, ch => 5 },
- { pch => 7, tdc => 3, ch => 14 },
- { pch => 8, tdc => 2, ch => 4 },
- { pch => 9, tdc => 3, ch => 15 },
- { pch => 10, tdc => 2, ch => 3 },
- { pch => 11, tdc => 3, ch => 16 },
- { pch => 12, tdc => 2, ch => 2 },
- { pch => 13, tdc => 3, ch => 17 },
- { pch => 14, tdc => 2, ch => 1 },
- { pch => 15, tdc => 3, ch => 18 },
- { pch => 16, tdc => 2, ch => 32 },
- { pch => 17, tdc => 3, ch => 19 },
- { pch => 18, tdc => 2, ch => 31 },
- { pch => 19, tdc => 3, ch => 20 },
- { pch => 20, tdc => 2, ch => 30 },
- { pch => 21, tdc => 3, ch => 21 },
- { pch => 22, tdc => 2, ch => 29 },
- { pch => 23, tdc => 3, ch => 22 },
- { pch => 24, tdc => 2, ch => 28 },
- { pch => 25, tdc => 3, ch => 23 },
- { pch => 26, tdc => 2, ch => 27 },
- { pch => 27, tdc => 3, ch => 24 },
- { pch => 28, tdc => 2, ch => 26 },
- { pch => 29, tdc => 3, ch => 25 },
- { pch => 30, tdc => 2, ch => 25 },
- { pch => 31, tdc => 3, ch => 26 },
- { pch => 32, tdc => 2, ch => 24 },
- { pch => 33, tdc => 3, ch => 27 },
- { pch => 34, tdc => 2, ch => 23 },
- { pch => 35, tdc => 3, ch => 28 },
- { pch => 36, tdc => 2, ch => 22 },
- { pch => 37, tdc => 3, ch => 29 },
- { pch => 38, tdc => 2, ch => 21 },
- { pch => 39, tdc => 3, ch => 30 },
- { pch => 40, tdc => 2, ch => 20 },
- { pch => 41, tdc => 3, ch => 31 },
- { pch => 42, tdc => 2, ch => 19 },
- { pch => 43, tdc => 3, ch => 32 },
- { pch => 44, tdc => 2, ch => 18 },
- { pch => 45, tdc => 3, ch => 33 },
- { pch => 46, tdc => 2, ch => 17 },
- { pch => 47, tdc => 3, ch => 34 },
- { pch => 48, tdc => 2, ch => 48 },
- { pch => 49, tdc => 3, ch => 35 },
- { pch => 50, tdc => 2, ch => 47 },
- { pch => 51, tdc => 3, ch => 36 },
- { pch => 52, tdc => 2, ch => 46 },
- { pch => 53, tdc => 3, ch => 37 },
- { pch => 54, tdc => 2, ch => 45 },
- { pch => 55, tdc => 3, ch => 38 },
- { pch => 56, tdc => 2, ch => 44 },
- { pch => 57, tdc => 3, ch => 39 },
- { pch => 58, tdc => 2, ch => 43 },
- { pch => 59, tdc => 3, ch => 40 },
-
- ];
-
-my $channels_y = [
- { pch => 0, tdc => 1, ch => 8 },
- { pch => 1, tdc => 0, ch => 11 },
- { pch => 2, tdc => 1, ch => 7 },
- { pch => 3, tdc => 0, ch => 12 },
- { pch => 4, tdc => 1, ch => 6 },
- { pch => 5, tdc => 0, ch => 13 },
- { pch => 6, tdc => 1, ch => 5 },
- { pch => 7, tdc => 0, ch => 14 },
- { pch => 8, tdc => 1, ch => 4 },
- { pch => 9, tdc => 0, ch => 15 },
- { pch => 10, tdc => 1, ch => 3 },
- { pch => 11, tdc => 0, ch => 16 },
- { pch => 12, tdc => 1, ch => 2 },
- { pch => 13, tdc => 0, ch => 17 },
- { pch => 14, tdc => 1, ch => 1 },
- { pch => 15, tdc => 0, ch => 18 },
- { pch => 16, tdc => 1, ch => 32 },
- { pch => 17, tdc => 0, ch => 19 },
- { pch => 18, tdc => 1, ch => 31 },
- { pch => 19, tdc => 0, ch => 20 },
- { pch => 20, tdc => 1, ch => 30 },
- { pch => 21, tdc => 0, ch => 21 },
- { pch => 22, tdc => 1, ch => 29 },
- { pch => 23, tdc => 0, ch => 22 },
- { pch => 24, tdc => 1, ch => 28 },
- { pch => 25, tdc => 0, ch => 23 },
- { pch => 26, tdc => 1, ch => 27 },
- { pch => 27, tdc => 0, ch => 24 },
- { pch => 28, tdc => 1, ch => 26 },
- { pch => 29, tdc => 0, ch => 25 },
- { pch => 30, tdc => 1, ch => 25 },
- { pch => 31, tdc => 0, ch => 26 },
- { pch => 32, tdc => 1, ch => 24 },
- { pch => 33, tdc => 0, ch => 27 },
- { pch => 34, tdc => 1, ch => 23 },
- { pch => 35, tdc => 0, ch => 28 },
- { pch => 36, tdc => 1, ch => 22 },
- { pch => 37, tdc => 0, ch => 29 },
- { pch => 38, tdc => 1, ch => 21 },
- { pch => 39, tdc => 0, ch => 30 },
- { pch => 40, tdc => 1, ch => 20 },
- { pch => 41, tdc => 0, ch => 31 },
- { pch => 42, tdc => 1, ch => 19 },
- { pch => 43, tdc => 0, ch => 32 },
- { pch => 44, tdc => 1, ch => 18 },
- { pch => 45, tdc => 0, ch => 33 },
- { pch => 46, tdc => 1, ch => 17 },
- { pch => 47, tdc => 0, ch => 34 },
- { pch => 48, tdc => 1, ch => 48 },
- { pch => 49, tdc => 0, ch => 35 },
- { pch => 50, tdc => 1, ch => 47 },
- { pch => 51, tdc => 0, ch => 36 },
- { pch => 52, tdc => 1, ch => 46 },
- { pch => 53, tdc => 0, ch => 37 },
- { pch => 54, tdc => 1, ch => 45 },
- { pch => 55, tdc => 0, ch => 38 },
- { pch => 56, tdc => 1, ch => 44 },
- { pch => 57, tdc => 0, ch => 39 },
- { pch => 58, tdc => 1, ch => 43 },
- { pch => 59, tdc => 0, ch => 40 },
-
- ];
+my @lastspills_x_0;
+my @lastspills_y_0;
+my $time_x_0 = 0;
+my $time_y_0 = 0;
-
-my @chanx = qw(0 0 2 4 6 8 10 12 14 16 13 11 9 7 5 3 1); #move noisy ch. 15 to 16 to disable it 2019-03-26
-#my @chanx = qw(0 15 13 11 9 7 5 3 1 0 2 4 6 8 10 12 14);
+my $empties_x_0 = 0;
+my $empties_y_0 = 0;
+my($max_x_0, $duty_x_0, $total_x_0, $spillmin_x_0, $spillmax_x_0, $spillavg_x_0, $flucqual_x_0, $offtime_x_0, $length_x_0, $spillEnds_x_0) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my($max_y_0, $duty_y_0, $total_y_0, $spillmin_y_0, $spillmax_y_0, $spillavg_y_0, $flucqual_y_0, $offtime_y_0, $length_y_0, $spillEnds_y_0) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my ($lastinspill,$inspill,$spillends) = (0,0,0);
-my @chany = qw(0 0 2 4 6 8 10 12 14 15 13 11 9 7 5 3 1);
-my @chanveto = qw(0 2 7 3 4 0 5 1 6);
-my $cts_set;
+HPlot::PlotDrawFork('StartSpillSumX_0');
+HPlot::PlotDrawFork('StartSpillPeakX_0');
+HPlot::PlotDrawFork('StartDutyFactorX_0');
+HPlot::PlotDrawFork('StartSpillSumY_0');
+HPlot::PlotDrawFork('StartSpillPeakY_0');
+HPlot::PlotDrawFork('StartDutyFactorY_0');
-my $old;
-#Spill
-my @totalDetectorHitsX;
-my @totalDetectorHitsY;
-my $spillThreshold = 1000; # threshold of rate in detector signaling the End of the Spill
-my $samplesPerSecond =10;
+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_1 = [
+ { pch => 2, tdc => 2, ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+ { pch => 1, tdc => 2, ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+ { pch => 4, tdc => 2, ch => int(5 /2)},
+ { pch => 3, tdc => 2, ch => int(7 /2)},
+ { pch => 6, tdc => 2, ch => int(9 /2)},
+ { pch => 5, tdc => 2, ch => int(11/2)},
+ { pch => 8, tdc => 2, ch => int(13/2)},
+ { pch => 7, tdc => 2, ch => int(15/2)},
+ { pch => 10, tdc => 2, ch => int(17/2)},
+ { pch => 9, tdc => 2, ch => int(19/2)},
+ { pch => 12, tdc => 2, ch => int(21/2)},
+ { pch => 11, tdc => 2, ch => int(23/2)},
+ { pch => 14, tdc => 2, ch => int(25/2)},
+ { pch => 13, tdc => 2, ch => int(27/2)},
+ { pch => 16, tdc => 2, ch => int(29/2)},
+ { pch => 15, tdc => 2, ch => int(31/2)},
+ { pch => 18, tdc => 2, ch => int(33/2)},
+ { pch => 17, tdc => 2, ch => int(35/2)},
+ { pch => 20, tdc => 2, ch => int(37/2)},
+ { pch => 19, tdc => 2, ch => int(39/2)},
+ { pch => 22, tdc => 2, ch => int(41/2)},
+ { pch => 21, tdc => 2, ch => int(43/2)},
+ { pch => 24, tdc => 2, ch => int(45/2)},
+ { pch => 23, tdc => 2, ch => int(47/2)},
+ { pch => 34, tdc => 3, ch => int(1 /2)},
+ { pch => 33, tdc => 3, ch => int(3 /2)},
+ { pch => 36, tdc => 3, ch => int(5 /2)},
+ { pch => 35, tdc => 3, ch => int(7 /2)},
+ { pch => 38, tdc => 3, ch => int(9 /2)},
+ { pch => 37, tdc => 3, ch => int(11/2)},
+ { pch => 40, tdc => 3, ch => int(13/2)},
+ { pch => 39, tdc => 3, ch => int(15/2)},
+ { pch => 42, tdc => 3, ch => int(17/2)},
+ { pch => 41, tdc => 3, ch => int(19/2)},
+ { pch => 44, tdc => 3, ch => int(21/2)},
+ { pch => 43, tdc => 3, ch => int(23/2)},
+ { pch => 46, tdc => 3, ch => int(25/2)},
+ { pch => 45, tdc => 3, ch => int(27/2)},
+ { pch => 48, tdc => 3, ch => int(29/2)},
+ { pch => 47, tdc => 3, ch => int(31/2)},
+ { pch => 26, tdc => 3, ch => int(33/2)},
+ { pch => 25, tdc => 3, ch => int(35/2)},
+ { pch => 28, tdc => 3, ch => int(37/2)},
+ { pch => 27, tdc => 3, ch => int(39/2)},
+ { pch => 30, tdc => 3, ch => int(41/2)},
+ { pch => 29, tdc => 3, ch => int(43/2)},
+ { pch => 32, tdc => 3, ch => int(45/2)},
+ { pch => 31, tdc => 3, ch => int(47/2)}
+ ];
+
+
+my $channels_y_0 = [
+ { pch => 15 , tdc => 0 , ch => int(1 /2)}, # Int(ch/2) because we read from monitoring register, which counts 0-23 for each TDC.
+ { pch => 16 , tdc => 0 , ch => int(3 /2)}, # Take care that the functions copy pasted DO NOT have a "-1" for the channels!
+ { pch => 13 , tdc => 0 , ch => int(5 /2)},
+ { pch => 14 , tdc => 0 , ch => int(7 /2)},
+ { pch => 11 , tdc => 0 , ch => int(9 /2)},
+ { pch => 12 , tdc => 0 , ch => int(11/2)},
+ { pch => 9 , tdc => 0 , ch => int(13/2)},
+ { pch => 10 , tdc => 0 , ch => int(15/2)},
+ { pch => 7 , tdc => 0 , ch => int(17/2)},
+ { pch => 8 , tdc => 0 , ch => int(19/2)},
+ { pch => 5 , tdc => 0 , ch => int(21/2)},
+ { pch => 6 , tdc => 0 , ch => int(23/2)},
+ { pch => 3 , tdc => 0 , ch => int(25/2)},
+ { pch => 4 , tdc => 0 , ch => int(27/2)},
+ { pch => 1 , tdc => 0 , ch => int(29/2)},
+ { pch => 2 , tdc => 0 , ch => int(31/2)},
+ { pch => 31 , tdc => 0 , ch => int(33/2)},
+ { pch => 32 , tdc => 0 , ch => int(35/2)},
+ { pch => 29 , tdc => 0 , ch => int(37/2)},
+ { pch => 30 , tdc => 0 , ch => int(39/2)},
+ { pch => 27 , tdc => 0 , ch => int(41/2)},
+ { pch => 28 , tdc => 0 , ch => int(43/2)},
+ { pch => 25 , tdc => 0 , ch => int(45/2)},
+ { pch => 26 , tdc => 0 , ch => int(47/2)},
+ { pch => 47 , tdc => 1 , ch => int(1 /2)},
+ { pch => 48 , tdc => 1 , ch => int(3 /2)},
+ { pch => 45 , tdc => 1 , ch => int(5 /2)},
+ { pch => 46 , tdc => 1 , ch => int(7 /2)},
+ { pch => 43 , tdc => 1 , ch => int(9 /2)},
+ { pch => 44 , tdc => 1 , ch => int(11/2)},
+ { pch => 41 , tdc => 1 , ch => int(13/2)},
+ { pch => 42 , tdc => 1 , ch => int(15/2)},
+ { pch => 39 , tdc => 1 , ch => int(17/2)},
+ { pch => 40 , tdc => 1 , ch => int(19/2)},
+ { pch => 37 , tdc => 1 , ch => int(21/2)},
+ { pch => 38 , tdc => 1 , ch => int(23/2)},
+ { pch => 35 , tdc => 1 , ch => int(25/2)},
+ { pch => 36 , tdc => 1 , ch => int(27/2)},
+ { pch => 33 , tdc => 1 , ch => int(29/2)},
+ { pch => 34 , tdc => 1 , ch => int(31/2)},
+ { pch => 23 , tdc => 1 , ch => int(33/2)},
+ { pch => 24 , tdc => 1 , ch => int(35/2)},
+ { pch => 21 , tdc => 1 , ch => int(37/2)},
+ { pch => 22 , tdc => 1 , ch => int(39/2)},
+ { pch => 19 , tdc => 1 , ch => int(41/2)},
+ { pch => 20 , tdc => 1 , ch => int(43/2)},
+ { pch => 17 , tdc => 1 , ch => int(45/2)},
+ { pch => 18 , tdc => 1 , ch => int(47/2)}
+ ];
-my @lastspills_x;
-my @lastspills_y;
-my $time_x = 0;
-my $time_y = 0;
-my $empties_x = 0;
-my $empties_y = 0;
-my($max_x, $duty_x, $total_x, $spillmin_x, $spillmax_x, $spillavg_x, $flucqual_x, $offtime_x, $length_x, $spillEnds_x) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
-my($max_y, $duty_y, $total_y, $spillmin_y, $spillmax_y, $spillavg_y, $flucqual_y, $offtime_y, $length_y, $spillEnds_y) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
-my ($lastinspill,$inspill,$spillends) = (0,0,0);
-HPlot::PlotDrawFork('SpillSumY');
-HPlot::PlotDrawFork('SpillPeakY');
-HPlot::PlotDrawFork('DutyFactorY');
+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) {
- if($iter == 1) {
- $cts_set = trb_register_read(0x3,0xa0da);
- }
- my $current_readout = trb_registertime_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
- #my $o = trb_register_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
- #print Dumper $o;
- #exit;
- if (defined $old) {
-# print Dumper $current_readout;
-# exit;
-
- # Calculation of total Detector hits ($sum_) and weighted with position in detector (wsum_)
- my ($sum_x, $wsum_x) = calculate_diff_time_and_sum($channels_x, $old, $current_readout);
- my ($sum_y, $wsum_y) = calculate_diff_time_and_sum($channels_y, $old, $current_readout);
-
- # Create an array containing the sums per readout
+ 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',$hitRatesStartX_0[$i],0, $i);
+ HPlot::PlotFill('StartRateNumbers',$hitRatesStartX_1[$i],1, $i);
+ HPlot::PlotFill('StartRateNumbers',$hitRatesStartY_0[$i],2, $i);
+ HPlot::PlotFill('StartRateNumbers',$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));
+ }
+
+ push(@totalDetectorHitsX_0, $sum_x_0);
+ shift(@totalDetectorHitsX_0) if scalar @totalDetectorHitsX_0 > 2000; # makes sure that the array does not get huge. after 200 seconds of no beam, the last entries start to fall off
+ $empties_x_0++ if ($sum_x_0 < 1000);
+ push(@totalDetectorHitsY_0, $sum_y_0);
+ shift(@totalDetectorHitsY_0) if scalar @totalDetectorHitsY_0 > 2000;
+ $empties_y_0++ if ($sum_y_0 < 1000);
+
+ my $sp = trb_register_read(0x10,0x905d); # check it
+ $inspill = ($sp->{0x10} >> 31) & 1;
+ $spillends = $inspill == 0 && $lastinspill == 1;
+
+ if($spillends){
+ ($max_x_0, $duty_x_0, $total_x_0, $spillmin_x_0, $spillmax_x_0, $spillavg_x_0, $flucqual_x_0, $offtime_x_0, $length_x_0, $time_x_0, $empties_x_0, $spillEnds_x_0) = spillAnalysisACCSIG(\@totalDetectorHitsX_0, \@lastspills_x_0, $time_x_0, $empties_x_0);
+
+ @totalDetectorHitsX_0 = ();
+
+ ($max_y_0, $duty_y_0, $total_y_0, $spillmin_y_0, $spillmax_y_0, $spillavg_y_0, $flucqual_y_0, $offtime_y_0, $length_y_0,$time_y_0, $empties_y_0, $spillEnds_y_0) = spillAnalysisACCSIG(\@totalDetectorHitsY_0, \@lastspills_y_0, $time_y_0, $empties_y_0);
+
+ @totalDetectorHitsY_0 = ();
+ }
+
+ if($spillends){
+ # Start X
+ HPlot::PlotAdd("StartDutyFactorX_0", $duty_x_0,0);
+ HPlot::PlotAdd("StartSpillPeakX_0", $max_x_0,0);
+ HPlot::PlotAdd("StartSpillSumX_0", $total_x_0,0);
+
+ $str = Hmon::MakeTitle(8, 19, "StartSpillShapeAnalysisX_0",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/StartRateX_histbar.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartDutyFactorX_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartSpillSumX_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartSpillPeakX_0.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_x_0);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_x_0);
+ $str .= "<tr><td>Last Duration<td>".$length_x_0;
+ $str .= "<td>Last Break<td>".$offtime_x_0." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_x_0)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_x_0)." - ".QA::SciNotation($spillmax_x_0)."<br>∅ ".QA::SciNotation($spillavg_x_0)." (".QA::SciNotation($flucqual_x_0).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("StartSpillShapeAnalysisX_0",$str);
+
+ HPlot::PlotDrawFork('StartSpillSumX_0');
+ HPlot::PlotDrawFork('StartSpillPeakX_0');
+ HPlot::PlotDrawFork('StartDutyFactorX_0');
+
+ # Start Y
+ HPlot::PlotAdd("StartDutyFactorY_0", $duty_y_0,0);
+ HPlot::PlotAdd("StartSpillPeakY_0", $max_y_0,0);
+ HPlot::PlotAdd("StartSpillSumY_0", $total_y_0,0);
+
+ $str = Hmon::MakeTitle(8, 19, "StartSpillShapeAnalysisY_0",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/StartRateY_histbar.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartDutyFactorY_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartSpillSumY_0.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/StartSpillPeakY_0.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_x_0);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_y_0);
+ $str .= "<tr><td>Last Duration<td>".$length_y_0;
+ $str .= "<td>Last Break<td>".$offtime_y_0." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_y_0)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_y_0)." - ".QA::SciNotation($spillmax_y_0)."<br>∅ ".QA::SciNotation($spillavg_y_0)." (".QA::SciNotation($flucqual_y_0).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("StartSpillShapeAnalysisY_0",$str);
+
+ HPlot::PlotDrawFork('StartSpillSumY_0');
+ HPlot::PlotDrawFork('StartSpillPeakY_0');
+ HPlot::PlotDrawFork('StartDutyFactorY_0');
+ }
+
+ 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);
- # calculate beam position and width, by using a weighted average of physical channels and the RMS.
- my $avg_x=0;
- my $avg_y=0;
- my $rms_x=0;
- my $rms_y=0;
+ HPlot::PlotDrawFork('StartPosition') if ($iter == 1);
+ HPlot::PlotDrawFork('StartRateNumbers') 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
- if($sum_x < 1000){
- $avg_x = "NaN";
- $rms_x = "NaN";
- } else {
- $avg_x = $wsum_x / $sum_x if($sum_x !=0);
- my $weighted_sum_difference_from_mean_x = calculate_weighted_sum_difference_from_mean($channels_x, $old, $current_readout,$avg_x);
- $rms_x = sqrt($weighted_sum_difference_from_mean_x/($sum_x||1E-10));
- }
- if($sum_y < 1000){
- $avg_y = "NaN";
- $rms_y = "NaN";
- } else {
- $avg_y = $wsum_y / $sum_y if($sum_y !=0);
- my $weighted_sum_difference_from_mean_y = calculate_weighted_sum_difference_from_mean($channels_y, $old, $current_readout,$avg_y);
- $rms_y = sqrt($weighted_sum_difference_from_mean_y/($sum_y||1E-10));
- }
+ }
- # Calculate Number of hits in detector by subgroups consisting of 5 channels
- my @hitRatesStartX = calculate_rates($channels_x, $old, $current_readout);
- my @hitRatesStartY = calculate_rates($channels_y, $old, $current_readout);
-
- push(@totalDetectorHitsX, $sum_x);
- shift(@totalDetectorHitsX) if scalar @totalDetectorHitsX > 2000; # makes sure that the array does not get huge big. after 200 seconds of no beam, the last entries start to fall off
- $empties_x++ if ($sum_x < 1000);
- push(@totalDetectorHitsY, $sum_y);
- shift(@totalDetectorHitsY) if scalar @totalDetectorHitsY > 2000;
- $empties_y++ if ($sum_y < 1000);
-
- my $sp = trb_register_read(0x10,0x905d);
- $inspill = ($sp->{0x10} >> 31) & 1;
- $spillends = $inspill == 0 && $lastinspill == 1;
- if($spillends){
- ($max_x, $duty_x, $total_x, $spillmin_x, $spillmax_x, $spillavg_x, $flucqual_x, $offtime_x, $length_x, $time_x, $empties_x, $spillEnds_x) = spillAnalysisACCSIG(\@totalDetectorHitsX, \@lastspills_x, $time_x, $empties_x);
-
- @totalDetectorHitsX = ();
-
- ($max_y, $duty_y, $total_y, $spillmin_y, $spillmax_y, $spillavg_y, $flucqual_y, $offtime_y, $length_y,$time_y, $empties_y, $spillEnds_y) = spillAnalysisACCSIG(\@totalDetectorHitsY, \@lastspills_y, $time_y, $empties_y);
-
- @totalDetectorHitsY = ();
- }
+ $lastinspill = $inspill;
+ $old = $current_readout;
+ usleep(100000);
+# sleep 1;
+}
+
+
+
+# VK: Jan said register is 24 bit, not 28 => change all 2**28 to 2**24
+sub calculate_rates{
+ my ($ra_channels, $old,$current_readout) = @_ ;
- if($spillends){
- HPlot::PlotAdd("DutyFactorX", $duty_x,0);
- HPlot::PlotAdd("SpillPeakX", $max_x,0);
- HPlot::PlotAdd("SpillSumX", $total_x,0);
-
- $str = Hmon::MakeTitle(8, 19, "SpillShapeAnalysisX",1);
- $str .= qq@<img width="600" src="%ADDPNG files/StartRateXhistbar.png%" type="image/png"><br>\n@;
- $str .= qq@<img src="%ADDPNG files/DutyFactorX.png%" type="image/png"><br\>\n@;
- $str .= qq@<img src="%ADDPNG files/SpillSumX.png%" type="image/png"><br\>\n@;
- $str .= qq@<img src="%ADDPNG files/SpillPeakX.png%" type="image/png"><br\>\n@;
- $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_x);
- $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_x);
- $str .= "<tr><td>Last Duration<td>".$length_x;
- $str .= "<td>Last Break<td>".$offtime_x." s";
- $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_x)." Hz (100ms)";
- $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_x)." - ".QA::SciNotation($spillmax_x)."<br>∅ ".QA::SciNotation($spillavg_x)." (".QA::SciNotation($flucqual_x).")";
- $str .= "</table>";
- $str .= Hmon::MakeFooter();
- Hmon::WriteFile("SpillShapeAnalysisX",$str);
-
- HPlot::PlotDrawFork('SpillSumX');
- HPlot::PlotDrawFork('SpillPeakX');
- HPlot::PlotDrawFork('DutyFactorX');
-# }
-#
-#
-# if($spillends){#$spillEnds_y == 1
- HPlot::PlotAdd("DutyFactorY", $duty_y,0);
- HPlot::PlotAdd("SpillPeakY", $max_y,0);
- HPlot::PlotAdd("SpillSumY", $total_y,0);
-
- $str = Hmon::MakeTitle(8, 19, "SpillShapeAnalysisY",1);
- $str .= qq@<img width="600" src="%ADDPNG files/StartRateYhistbar.png%" type="image/png"><br>\n@;
- $str .= qq@<img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br\>\n@;
- $str .= qq@<img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br\>\n@;
- $str .= qq@<img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br\>\n@;
- $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_y);
- $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_y);
- $str .= "<tr><td>Last Duration<td>".$length_y;
- $str .= "<td>Last Break<td>".$offtime_y." s";
- $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_y)." Hz (100ms)";
- $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_y)." - ".QA::SciNotation($spillmax_y)."<br>∅ ".QA::SciNotation($spillavg_y)." (".QA::SciNotation($flucqual_y).")";
- $str .= "</table>";
- $str .= Hmon::MakeFooter();
- Hmon::WriteFile("SpillShapeAnalysisY",$str);
-
- HPlot::PlotDrawFork('SpillSumY');
- HPlot::PlotDrawFork('SpillPeakY');
- HPlot::PlotDrawFork('DutyFactorY');
+ my @result;
+ for my $i (0..48){
+ $result[$i] = 0;
}
- HPlot::PlotAdd("StartPosition",$avg_x,0);
- HPlot::PlotAdd("StartPosition",$avg_y,1);
- HPlot::PlotAdd("StartPosition",$rms_x,2);
- HPlot::PlotAdd("StartPosition",$rms_y,3);
-
- for my $i(0..11){
- HPlot::PlotAdd("StartRateXhistbar",$hitRatesStartX[$i],$i);
- HPlot::PlotAdd("StartRateYhistbar",$hitRatesStartY[$i],$i);
+ 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**24 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;
}
-
- HPlot::PlotDrawFork('StartPosition') if ($iter == 1);
- HPlot::PlotDrawFork('StartRateXhistbar') if ($iter == 2);
- HPlot::PlotDrawFork('StartRateYhistbar') if ($iter == 3);
-# HPlot::PlotDrawFork('SpillSumX') if ($iter == 4);
-# HPlot::PlotDrawFork('SpillPeakX') if ($iter == 5);
-# HPlot::PlotDrawFork('SpillSumY') if ($iter == 6);
-# HPlot::PlotDrawFork('SpillPeakY') if ($iter == 7);
-# HPlot::PlotDrawFork('DutyFactorX') if ($iter == 8);
-# HPlot::PlotDrawFork('DutyFactorY') if ($iter == 9);
-
- $iter = 1 if ($iter++ == 10) #dont change
-
- }
-
- $lastinspill = $inspill;
- $old = $current_readout;
- usleep(100000);
+
+ for my $i(1..48){
+ $result[$i] +=2**24 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}-1, $ch->{pch} );
+ 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;
# 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;
+ $vdiff += 2**24 if $vdiff < 0;
my $diff = $vdiff/($tdiff||1E6)*1E6;
#print "vdiff: $vdiff, diff: $diff, tdiff: $tdiff\n";
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}-1,$ch->{pch});
+ 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;
+ $hitdiff +=2**24 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;
return $weighted_sum_difference_from_mean;
}
-sub calculate_rates{
- my ($ra_channels, $old,$current_readout) = @_ ;
-
- my @result;
- for my $i (0..11){
- $result[$i] = 0;
- }
-
- foreach my $ch (@$ra_channels) {
- my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch}-1,$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[int($phy_channel/5)] += $rate;
- }
-
-# for my $i(0..11){
-# $result[$i] +=2**28 if $result[$i] < 0;
-# }
-
- return @result;
-}
-
-sub spillAnalysis{
- my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
-
- my $lastsum = 0; # sum of entries in last 15 readouts
- my @totalDetectorHits = @{$totalDetectorHitsReference};
- my @lastSpills = @{$lastSpillReference};
- my ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, $spillEnds) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
-
- for my $i (1..15) { $lastsum += $totalDetectorHits[-$i]//0;}
-
- #end of spill signaled by last 15 readouts having an average below spillThreshold entries and the one before having more
- if($lastsum < 15 * $spillThreshold && ($totalDetectorHits[-16]//0) > $spillThreshold){
- $max = max(@totalDetectorHits);
- my $samples = scalar @totalDetectorHits;
- my $avg = sum(@totalDetectorHits)/$samples;
- $duty = $avg/$max;
- $total = sum(@totalDetectorHits)/$samplesPerSecond;# sum and mulitply by bin width -> Integral. Gives total hits in a spill
-
- push(@lastSpills,$total);
- shift(@lastSpills) if scalar @lastSpills > 50;
-
- $spillmin = min(@lastSpills);
- $spillmax = max(@lastSpills);
- $spillavg = sum(@lastSpills)/(scalar @lastSpills);
- $flucqual = ($spillmax-$spillmin)/$spillavg;
- $offtime = $empties/10;
- $length = sprintf("%0.1f s (%i samples)", time()-$time, $samples);
-
- $empties = 0;
- $time = time();
- @totalDetectorHits = ();
-
- return ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, 1);
- }
-
- return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-}
sub spillAnalysisACCSIG{
my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
# $lastinspill = $inspill;
# return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
-
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
HPlot::PlotInit($plot1);
-my $plot2 = {
- name => "StartRateNumbers",
- file => "files/StartRateNumbers",
- entries => 2,
- curves => 60,
- type => HPlot::TYPE_HEATMAP,
- output => HPlot::OUT_PNG,
- zlabel => "Hitrate",
- sizex => 450,
- sizey => 720,
- nokey => 1,
- buffer => 1,
- xmin => -0.5,
- xmax => 1.5,
- ymin => -0.5,
- ymax => 59.5,
- cbmax => "100<*<1E5",
- cbmin => "0",
- showvalues => 0,
- additional => "set xtics ('Bottom' 0, 'Left' 1); set x2tics ('Top' 0, 'Right' 1);"
- };
-HPlot::PlotInit($plot2);
+# my $plot2 = {
+# name => "StartRateNumbers",
+# file => "files/StartRateNumbers",
+# entries => 2,
+# curves => 60,
+# type => HPlot::TYPE_HEATMAP,
+# output => HPlot::OUT_PNG,
+# zlabel => "Hitrate",
+# sizex => 450,
+# sizey => 720,
+# nokey => 1,
+# buffer => 1,
+# xmin => -0.5,
+# xmax => 1.5,
+# ymin => -0.5,
+# ymax => 59.5,
+# cbmax => "100<*<1E5",
+# cbmin => "0",
+# showvalues => 0,
+# additional => "set xtics ('Bottom' 0, 'Left' 1); set x2tics ('Top' 0, 'Right' 1);"
+# };
+# HPlot::PlotInit($plot2);
my $str = Hmon::MakeTitle(4, 7, "Start Hit Rate",0);
$str .= Hmon::MakeFooter();
Hmon::WriteFile("StartRateSimple",$str);
-$str = Hmon::MakeTitle(6, 16, "Start Hit Numbers");
-$str .= qq@<img src="%ADDPNG files/StartRateNumbers.png%" type="image/png"><br>\n@;
-$str .= Hmon::MakeFooter();
-Hmon::WriteFile("StartRateNumbers",$str);
+# $str = Hmon::MakeTitle(6, 16, "Start Hit Numbers");
+# $str .= qq@<img src="%ADDPNG files/StartRateNumbers.png%" type="image/png"><br>\n@;
+# $str .= Hmon::MakeFooter();
+# Hmon::WriteFile("StartRateNumbers",$str);
my $old;
my $oldtime = time();
#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;
+ my $current = trb_register_read_mem(0xfe76,0xdfc0,0,48) or die trb_strerror() or sleep 5 and next;
#print Dumper $o;
if (defined $old) {
next unless ($endpoint>=0x5000 && $endpoint<=0x5007);
my $fpga = ($endpoint&0xF);
- for my $channel_nr (0..47) {
+ for my $channel_nr (0..23) {
my $vdiff = ($current->{$endpoint}->[$channel_nr] & 0xfffffff) - ($old->{$endpoint}->[$channel_nr]&0xfffffff);
if ($vdiff < 0) {
#HPlot::PlotFill('StartRateSimple',$diff->{$endpoint}->[$channel_nr],$channel_nr,);
HPlot::PlotFill('StartRateSimple',$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 < 10;
- next if $channel_nr > 39;
- $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',$diff->{$endpoint}->[$channel_nr],int($fpga/2), $ypos);
+# my $ypos = 0;
+# my $side = 0;
+# if ($fpga == 0 || $fpga == 3) {
+# next if $channel_nr < 10;
+# next if $channel_nr > 39;
+# $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',$diff->{$endpoint}->[$channel_nr],int($fpga/2), $ypos);
}
#my $s = sprintf("0x%04x",$endpoint);
}
HPlot::PlotDraw('StartRateSimple');
- HPlot::PlotDraw('StartRateNumbers');
+# HPlot::PlotDraw('StartRateNumbers');
# $data->{max} = $max;
# $data->{min} = $min;
--- /dev/null
+#!/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@<img src="%ADDPNG files/StartRateSimple_VW.png%" type="image/png"><br>\n@;
+# $str .= Hmon::MakeFooter();
+# Hmon::WriteFile("StartRateSimple_VW",$str);
+
+$str = Hmon::MakeTitle(6, 16, "Start Hit Numbers");
+$str .= qq@<img src="%ADDPNG files/StartRateNumbers_VW.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateNumbers_VW",$str);
+
+$str = Hmon::MakeTitle(13, 16, "Start Position",0);
+$str .= qq@<img src="%ADDPNG files/StartPosition.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartPosition",$str);
+
+
+$str = Hmon::MakeTitle(13, 16, "Start Position RMS",0);
+$str .= qq@<img src="%ADDPNG files/StartPositionRMS.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartPositionRMS",$str);
+
+
+
+$str = Hmon::MakeTitle(13, 32, "Start Summed Rates X",0);
+$str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateX_histbar.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateX_histbar",$str);
+
+$str = Hmon::MakeTitle(13, 32, "Start Summed Rates Y",0);
+$str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateY_histbar.png%" type="image/png"><br>\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;
+
+}
+
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use POSIX qw(strftime floor ceil);
use Hmon;
use HPlot;
use QA;
+use getebjson;
use JSON::XS;
use Data::Dumper;
use List::Util qw(min max);
use Try::Tiny;
trb_init_ports() or die trb_strerror();
+my $data;
+
# my $regs = trb_register_read(0xffff,0xc802) or die trb_strerror() or sleep 5 and next;
# my $numboards;# = scalar keys %$regs;
$str .= Hmon::MakeFooter();
Hmon::WriteFile("TdcCal",$str);
-
###################################################################################################
}
catch {sleep(60);next;};
- my $str = Hmon::MakeTitle(20, 11, "TDC Errors",1);
+ $str = Hmon::MakeTitle(20, 11, "TDC Errors",1);
$str .= qq@<img src="%ADDPNG files/TDCErrors.png%" type="image/png"><br>\n@;
$str .= Hmon::MakeFooter();
Hmon::WriteFile("TDCErrors",$str);
-
-
-
-
-
-
-
-
-
-
-
-
+###################################################################################################
+
--- /dev/null
+#!/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@<img src="%ADDPNG files/TdcCalMon@.$e.qq@.png%" type="image/png"><br>\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);
+ }
+
--- /dev/null
+#!/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@<img src="%ADDPNG files/TdcCalMon@.$e.qq@.png%" type="image/png"><br>\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);
+ }
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
if ($rh_hubs->{$board} & (1<<$i)) {
$msg .= sprintf("0x%04x ",Hmon::TraceDBGet($board,$i));
$boardlist1 .= sprintf("%04X, ",Hmon::TraceDBGet($board,$i));
+ $cnt++;
}
}
$msg .= ")";
- $cnt++;
}
if ((($rh_hubs->{$board}>>16) & 0xffff) != 0x0000 && (($board > 0x1000 && $board < 0x1200 && $board%16) || (($board&0xff00) == 0x8a00) || (($board&0xff00) == 0x8200))) {
$msg2 .= ", " if $msg2 ne "";
#something else...
$MDCRICH_fail++;
}
+ $cnt2++;
$boardlist2 .= sprintf("%04X, ",Hmon::TraceDBGet($board,$i));
}
}
$msg2 .= " )";
- $cnt2++;
}
}
$msg =~ s/\s+\)/\)/g; $msg =~ s/\(\s+/\(/g;
$msg2 =~ s/\s+\)/\)/g; $msg2 =~ s/\(\s+/\(/g;
- my $status = "on ".($cnt+$cnt2)." boards";
+ my $status = "on ".($cnt+$cnt2)." ports";
my $qastate = QA::GetQAState('below', $cnt+$cnt2, @QA::TimeoutLimits);
#$qastate = QA::ERROR if (($MDCRICH_fail == 0) && ($qastate == QA::FATAL));
if ($MDCRICH_fail == 0) {
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
#my $max = 0 ;
#my $min = 5E9;
- my $o = trb_register_read_mem(0xfe47,0xc000,0,33) or die trb_strerror() or sleep 5 and next;
+ my $o = trb_register_read_mem(0xfe47,0xdfc0,0,32) or die trb_strerror() or sleep 5 and next;
if (defined $old) {
my $tdiff = (time() - $oldtime)|1;
my $xpos = (($b>>4)&0xF)*5 + ($b&0xF);
for my $v (0..31) {
- my $vdiff = ($o->{$b}->[$v+1]&0xfffffff) - ($old->{$b}->[$v+1]&0xfffffff);
+ my $vdiff = ($o->{$b}->[$v]&0xfffffff) - ($old->{$b}->[$v]&0xfffffff);
if ($vdiff < 0) { $vdiff += 2**28;}
- $diff->{$b}->[$v+1] = $vdiff/$tdiff;
+ $diff->{$b}->[$v] = $vdiff/$tdiff;
#$ratesum += $diff->{$b}->[$v+1];
- HPlot::PlotFill('TofRate',$diff->{$b}->[$v+1],$v,$xpos);
+ HPlot::PlotFill('TofRate',$diff->{$b}->[$v],$v,$xpos);
}
#my $s = sprintf("0x%04x",$b);
#$data->{$s}= int(100*($ratesum / 32) +0.5) /100;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
SectorwiseMult4 SectorwiseMult5 SectorwiseMult6 SectorwiseMult2NoNeighbour
SectorwiseMult3NoNeighbour SectorwiseMult2Opposite);
-my @ptnames= qw(PT1 PT2 PT3 PT4 PT5 Ri FW EC);
-my @ptlnames= qw(PT1 PT2 PT3 PT4 PT5 PT6/Ri PT7/FW PT8/EC);
+my @ptnames= qw(PT1 PT2 PT3 PT4 PT5 PT6 PT7 PT8);
+my @ptlnames= qw(PT1/M2 PT2/MB PT3/Main PT4 PT5/iTOF PT6/ECal PT7/Rich PT8/Fwd);
my $lastlongmsg = "";
my $spillsum = 0;
my $longmsgcheck = $longmsg;
#Input polarity wrong?
- if($QA::TrgCheckPolarity && (($polarity->{3}->[1] & 0x7fff0000))) { # || $polarity->{3}->[0] & 0x1e0)
+ if($QA::TrgCheckPolarity && (($polarity->{3}->[1] & 0xffff0000))) { # || $polarity->{3}->[0] & 0x1e0)
$qastate = QA::WARN;
$longmsg .= " - Signal polarity wrong on inputs ";
- foreach my $i(0..30) {
+ foreach my $i(16..31) {
if($polarity->{3}->[1] & (1<<$i)) {
- $longmsg .= "Start ".($i+1) if $i<8;
- $longmsg .= "Veto ".($i-7) if $i<16 && $i>=8;
+# $longmsg .= "Start ".($i+1) if $i<8;
+# $longmsg .= "Veto ".($i-7) if $i<16 && $i>=8;
$longmsg .= "TOF ".($i-15) if $i<22 && $i>=16;
$longmsg .= "RPC ".($i-21) if $i<28 && $i>=22;
$longmsg .= "PT ".($i-27) if $i<32 && $i>=28;
}
$startmsg = sprintf("%s / %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum));
$startlongmsg = sprintf("counts per second %s/s - counts per spill %s",QA::SciNotation($startsum),QA::SciNotation($lastspillsum));
-# QA::WriteQALog($fqa, "trg", "start", 10, $qastatstart, "Start Count", $startmsg, $startlongmsg);
+ QA::WriteQALog($fqa, "trg", "start", 10, $qastatstart, "Start Count", $startmsg, $startlongmsg);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use Hmon;
use QA;
--- /dev/null
+#!/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 gettimeofday);
+use List::Util qw[min max sum];
+
+
+trb_init_ports() or die trb_strerror();
+
+
+HPlot::PlotInit({
+ name => "StartPosition",
+ file => "files/StartPosition",
+ 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.5",
+ ymax => "59.5",
+ curves => 4,
+ xscale => 10,
+ buffer => 1,
+ });
+
+HPlot::PlotInit({
+ name => "StartRateXhistbar",
+ file => "files/StartRateXhistbar",
+ entries => 200,
+ 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 => 200,
+ 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({
+ name => "StartRateYhistbar",
+ file => "files/StartRateYhistbar",
+ entries => 200,
+ 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 => 200,
+ 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({
+ name => "DutyFactorX",
+ file => "files/DutyFactorX",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Duty Factor",
+ sizex => 600,
+ sizey => 200,
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "DutyFactorY",
+ file => "files/DutyFactorY",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Duty Factor",
+ sizex => 600,
+ sizey => 200,
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "SpillSumX",
+ file => "files/SpillSumX",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Total Sum",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+HPlot::PlotInit({
+ name => "SpillSumY",
+ file => "files/SpillSumY",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Total Sum",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "SpillPeakX",
+ file => "files/SpillPeakX",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Peak Intensity [Hz]",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+HPlot::PlotInit({
+ name => "SpillPeakY",
+ file => "files/SpillPeakY",
+ entries => 100,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ xlabel => "Spills",
+ ylabel => "Peak Intensity [Hz]",
+ sizex => 600,
+ sizey => 200,
+ ymin => 0,
+ ymax => "*<9E9",
+ curves => 1,
+ buffer => 0,
+ nokey => 1,
+ storable => 1,
+ });
+
+
+my $str = Hmon::MakeTitle(13, 8, "Start Position",0);
+$str .= qq@<img src="%ADDPNG files/StartPosition.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartPosition",$str);
+
+$str = Hmon::MakeTitle(13, 32, "Start Rates X",0);
+$str .= qq@<h3>Start X Spill</h3><img src="%ADDPNG files/StartRateXhistbar.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start X Duty</h3><img src="%ADDPNG files/DutyFactorX.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start X Peak</h3><img src="%ADDPNG files/SpillPeakX.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start X Sum</h3><img src="%ADDPNG files/SpillSumX.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateX",$str);
+
+
+$str = Hmon::MakeTitle(13, 32, "Start Rates Y",0);
+$str .= qq@<h3>Start Y Spill</h3><img src="%ADDPNG files/StartRateYhistbar.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start Y Duty</h3><img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start Y Peak</h3><img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start Y Sum</h3><img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("StartRateY",$str);
+
+
+$str = Hmon::MakeTitle(16, 32, "Spill Info Start",0);
+$str .= qq@<h3>Start Duty</h3><img src="%ADDPNG files/DutyFactorX.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start Peak</h3><img src="%ADDPNG files/SpillPeakX.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br>\n@;
+$str .= qq@<h3>Start Sum</h3><img src="%ADDPNG files/SpillSumX.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("SpillInfoStart",$str);
+
+
+
+my $iter = 1;
+
+my $trbnet_endpoint_offset = 0x5000; #20480
+
+
+##
+##
+##
+ # pch is physical channel in the detector, tdc is the connected TDC and ch is the channel of the TDC
+my $channels_x = [
+ { pch => 0, tdc => 2, ch => 8 },
+ { pch => 1, tdc => 3, ch => 11 },
+ { pch => 2, tdc => 2, ch => 7 },
+ { pch => 3, tdc => 3, ch => 12 },
+ { pch => 4, tdc => 2, ch => 6 },
+ { pch => 5, tdc => 3, ch => 13 },
+ { pch => 6, tdc => 2, ch => 5 },
+ { pch => 7, tdc => 3, ch => 14 },
+ { pch => 8, tdc => 2, ch => 4 },
+ { pch => 9, tdc => 3, ch => 15 },
+ { pch => 10, tdc => 2, ch => 3 },
+ { pch => 11, tdc => 3, ch => 16 },
+ { pch => 12, tdc => 2, ch => 2 },
+ { pch => 13, tdc => 3, ch => 17 },
+ { pch => 14, tdc => 2, ch => 1 },
+ { pch => 15, tdc => 3, ch => 18 },
+ { pch => 16, tdc => 2, ch => 32 },
+ { pch => 17, tdc => 3, ch => 19 },
+ { pch => 18, tdc => 2, ch => 31 },
+ { pch => 19, tdc => 3, ch => 20 },
+ { pch => 20, tdc => 2, ch => 30 },
+ { pch => 21, tdc => 3, ch => 21 },
+ { pch => 22, tdc => 2, ch => 29 },
+ { pch => 23, tdc => 3, ch => 22 },
+ { pch => 24, tdc => 2, ch => 28 },
+ { pch => 25, tdc => 3, ch => 23 },
+ { pch => 26, tdc => 2, ch => 27 },
+ { pch => 27, tdc => 3, ch => 24 },
+ { pch => 28, tdc => 2, ch => 26 },
+ { pch => 29, tdc => 3, ch => 25 },
+ { pch => 30, tdc => 2, ch => 25 },
+ { pch => 31, tdc => 3, ch => 26 },
+ { pch => 32, tdc => 2, ch => 24 },
+ { pch => 33, tdc => 3, ch => 27 },
+ { pch => 34, tdc => 2, ch => 23 },
+ { pch => 35, tdc => 3, ch => 28 },
+ { pch => 36, tdc => 2, ch => 22 },
+ { pch => 37, tdc => 3, ch => 29 },
+ { pch => 38, tdc => 2, ch => 21 },
+ { pch => 39, tdc => 3, ch => 30 },
+ { pch => 40, tdc => 2, ch => 20 },
+ { pch => 41, tdc => 3, ch => 31 },
+ { pch => 42, tdc => 2, ch => 19 },
+ { pch => 43, tdc => 3, ch => 32 },
+ { pch => 44, tdc => 2, ch => 18 },
+ { pch => 45, tdc => 3, ch => 33 },
+ { pch => 46, tdc => 2, ch => 17 },
+ { pch => 47, tdc => 3, ch => 34 },
+ { pch => 48, tdc => 2, ch => 48 },
+ { pch => 49, tdc => 3, ch => 35 },
+ { pch => 50, tdc => 2, ch => 47 },
+ { pch => 51, tdc => 3, ch => 36 },
+ { pch => 52, tdc => 2, ch => 46 },
+ { pch => 53, tdc => 3, ch => 37 },
+ { pch => 54, tdc => 2, ch => 45 },
+ { pch => 55, tdc => 3, ch => 38 },
+ { pch => 56, tdc => 2, ch => 44 },
+ { pch => 57, tdc => 3, ch => 39 },
+ { pch => 58, tdc => 2, ch => 43 },
+ { pch => 59, tdc => 3, ch => 40 },
+
+ ];
+
+my $channels_y = [
+ { pch => 0, tdc => 1, ch => 8 },
+ { pch => 1, tdc => 0, ch => 11 },
+ { pch => 2, tdc => 1, ch => 7 },
+ { pch => 3, tdc => 0, ch => 12 },
+ { pch => 4, tdc => 1, ch => 6 },
+ { pch => 5, tdc => 0, ch => 13 },
+ { pch => 6, tdc => 1, ch => 5 },
+ { pch => 7, tdc => 0, ch => 14 },
+ { pch => 8, tdc => 1, ch => 4 },
+ { pch => 9, tdc => 0, ch => 15 },
+ { pch => 10, tdc => 1, ch => 3 },
+ { pch => 11, tdc => 0, ch => 16 },
+ { pch => 12, tdc => 1, ch => 2 },
+ { pch => 13, tdc => 0, ch => 17 },
+ { pch => 14, tdc => 1, ch => 1 },
+ { pch => 15, tdc => 0, ch => 18 },
+ { pch => 16, tdc => 1, ch => 32 },
+ { pch => 17, tdc => 0, ch => 19 },
+ { pch => 18, tdc => 1, ch => 31 },
+ { pch => 19, tdc => 0, ch => 20 },
+ { pch => 20, tdc => 1, ch => 30 },
+ { pch => 21, tdc => 0, ch => 21 },
+ { pch => 22, tdc => 1, ch => 29 },
+ { pch => 23, tdc => 0, ch => 22 },
+ { pch => 24, tdc => 1, ch => 28 },
+ { pch => 25, tdc => 0, ch => 23 },
+ { pch => 26, tdc => 1, ch => 27 },
+ { pch => 27, tdc => 0, ch => 24 },
+ { pch => 28, tdc => 1, ch => 26 },
+ { pch => 29, tdc => 0, ch => 25 },
+ { pch => 30, tdc => 1, ch => 25 },
+ { pch => 31, tdc => 0, ch => 26 },
+ { pch => 32, tdc => 1, ch => 24 },
+ { pch => 33, tdc => 0, ch => 27 },
+ { pch => 34, tdc => 1, ch => 23 },
+ { pch => 35, tdc => 0, ch => 28 },
+ { pch => 36, tdc => 1, ch => 22 },
+ { pch => 37, tdc => 0, ch => 29 },
+ { pch => 38, tdc => 1, ch => 21 },
+ { pch => 39, tdc => 0, ch => 30 },
+ { pch => 40, tdc => 1, ch => 20 },
+ { pch => 41, tdc => 0, ch => 31 },
+ { pch => 42, tdc => 1, ch => 19 },
+ { pch => 43, tdc => 0, ch => 32 },
+ { pch => 44, tdc => 1, ch => 18 },
+ { pch => 45, tdc => 0, ch => 33 },
+ { pch => 46, tdc => 1, ch => 17 },
+ { pch => 47, tdc => 0, ch => 34 },
+ { pch => 48, tdc => 1, ch => 48 },
+ { pch => 49, tdc => 0, ch => 35 },
+ { pch => 50, tdc => 1, ch => 47 },
+ { pch => 51, tdc => 0, ch => 36 },
+ { pch => 52, tdc => 1, ch => 46 },
+ { pch => 53, tdc => 0, ch => 37 },
+ { pch => 54, tdc => 1, ch => 45 },
+ { pch => 55, tdc => 0, ch => 38 },
+ { pch => 56, tdc => 1, ch => 44 },
+ { pch => 57, tdc => 0, ch => 39 },
+ { pch => 58, tdc => 1, ch => 43 },
+ { pch => 59, tdc => 0, ch => 40 },
+
+ ];
+
+
+
+my @chanx = qw(0 0 2 4 6 8 10 12 14 16 13 11 9 7 5 3 1); #move noisy ch. 15 to 16 to disable it 2019-03-26
+#my @chanx = qw(0 15 13 11 9 7 5 3 1 0 2 4 6 8 10 12 14);
+
+my @chany = qw(0 0 2 4 6 8 10 12 14 15 13 11 9 7 5 3 1);
+my @chanveto = qw(0 2 7 3 4 0 5 1 6);
+my $cts_set;
+
+my $old;
+
+#Spill
+my @totalDetectorHitsX;
+my @totalDetectorHitsY;
+my $spillThreshold = 1000; # threshold of rate in detector signaling the End of the Spill
+my $samplesPerSecond =10;
+
+my @lastspills_x;
+my @lastspills_y;
+
+my $time_x = 0;
+my $time_y = 0;
+
+my $empties_x = 0;
+my $empties_y = 0;
+my($max_x, $duty_x, $total_x, $spillmin_x, $spillmax_x, $spillavg_x, $flucqual_x, $offtime_x, $length_x, $spillEnds_x) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my($max_y, $duty_y, $total_y, $spillmin_y, $spillmax_y, $spillavg_y, $flucqual_y, $offtime_y, $length_y, $spillEnds_y) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+my ($lastinspill,$inspill,$spillends) = (0,0,0);
+
+
+HPlot::PlotDrawFork('SpillSumY');
+HPlot::PlotDrawFork('SpillPeakY');
+HPlot::PlotDrawFork('DutyFactorY');
+
+
+
+
+while(1) {
+
+ if($iter == 1) {
+ $cts_set = trb_register_read(0x3,0xa0da);
+ }
+
+
+ my $current_readout = trb_registertime_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
+ #my $o = trb_register_read_mem(0xfe74,0xdfc0,0,48); # or die trb_strerror() or sleep 5 and next;
+ #print Dumper $o;
+ #exit;
+ if (defined $old) {
+# print Dumper $current_readout;
+# exit;
+
+ # Calculation of total Detector hits ($sum_) and weighted with position in detector (wsum_)
+ my ($sum_x, $wsum_x) = calculate_diff_time_and_sum($channels_x, $old, $current_readout);
+ my ($sum_y, $wsum_y) = calculate_diff_time_and_sum($channels_y, $old, $current_readout);
+
+ # Create an array containing the sums per readout
+
+
+
+ # calculate beam position and width, by using a weighted average of physical channels and the RMS.
+ my $avg_x=0;
+ my $avg_y=0;
+ my $rms_x=0;
+ my $rms_y=0;
+
+ if($sum_x < 1000){
+ $avg_x = "NaN";
+ $rms_x = "NaN";
+ } else {
+ $avg_x = $wsum_x / $sum_x if($sum_x !=0);
+ my $weighted_sum_difference_from_mean_x = calculate_weighted_sum_difference_from_mean($channels_x, $old, $current_readout,$avg_x);
+ $rms_x = sqrt($weighted_sum_difference_from_mean_x/($sum_x||1E-10));
+ }
+ if($sum_y < 1000){
+ $avg_y = "NaN";
+ $rms_y = "NaN";
+ } else {
+ $avg_y = $wsum_y / $sum_y if($sum_y !=0);
+ my $weighted_sum_difference_from_mean_y = calculate_weighted_sum_difference_from_mean($channels_y, $old, $current_readout,$avg_y);
+ $rms_y = sqrt($weighted_sum_difference_from_mean_y/($sum_y||1E-10));
+ }
+
+ # Calculate Number of hits in detector by subgroups consisting of 5 channels
+ my @hitRatesStartX = calculate_rates($channels_x, $old, $current_readout);
+ my @hitRatesStartY = calculate_rates($channels_y, $old, $current_readout);
+
+ push(@totalDetectorHitsX, $sum_x);
+ shift(@totalDetectorHitsX) if scalar @totalDetectorHitsX > 2000; # makes sure that the array does not get huge big. after 200 seconds of no beam, the last entries start to fall off
+ $empties_x++ if ($sum_x < 1000);
+ push(@totalDetectorHitsY, $sum_y);
+ shift(@totalDetectorHitsY) if scalar @totalDetectorHitsY > 2000;
+ $empties_y++ if ($sum_y < 1000);
+
+ my $sp = trb_register_read(0x10,0x905d);
+ $inspill = ($sp->{0x10} >> 31) & 1;
+ $spillends = $inspill == 0 && $lastinspill == 1;
+ if($spillends){
+ ($max_x, $duty_x, $total_x, $spillmin_x, $spillmax_x, $spillavg_x, $flucqual_x, $offtime_x, $length_x, $time_x, $empties_x, $spillEnds_x) = spillAnalysisACCSIG(\@totalDetectorHitsX, \@lastspills_x, $time_x, $empties_x);
+
+ @totalDetectorHitsX = ();
+
+ ($max_y, $duty_y, $total_y, $spillmin_y, $spillmax_y, $spillavg_y, $flucqual_y, $offtime_y, $length_y,$time_y, $empties_y, $spillEnds_y) = spillAnalysisACCSIG(\@totalDetectorHitsY, \@lastspills_y, $time_y, $empties_y);
+
+ @totalDetectorHitsY = ();
+ }
+
+
+ if($spillends){
+ HPlot::PlotAdd("DutyFactorX", $duty_x,0);
+ HPlot::PlotAdd("SpillPeakX", $max_x,0);
+ HPlot::PlotAdd("SpillSumX", $total_x,0);
+
+ $str = Hmon::MakeTitle(8, 19, "SpillShapeAnalysisX",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/StartRateXhistbar.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/DutyFactorX.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/SpillSumX.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/SpillPeakX.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_x);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_x);
+ $str .= "<tr><td>Last Duration<td>".$length_x;
+ $str .= "<td>Last Break<td>".$offtime_x." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_x)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_x)." - ".QA::SciNotation($spillmax_x)."<br>∅ ".QA::SciNotation($spillavg_x)." (".QA::SciNotation($flucqual_x).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("SpillShapeAnalysisX",$str);
+
+ HPlot::PlotDrawFork('SpillSumX');
+ HPlot::PlotDrawFork('SpillPeakX');
+ HPlot::PlotDrawFork('DutyFactorX');
+# }
+#
+#
+# if($spillends){#$spillEnds_y == 1
+ HPlot::PlotAdd("DutyFactorY", $duty_y,0);
+ HPlot::PlotAdd("SpillPeakY", $max_y,0);
+ HPlot::PlotAdd("SpillSumY", $total_y,0);
+
+ $str = Hmon::MakeTitle(8, 19, "SpillShapeAnalysisY",1);
+ $str .= qq@<img width="600" src="%ADDPNG files/StartRateYhistbar.png%" type="image/png"><br>\n@;
+ $str .= qq@<img src="%ADDPNG files/DutyFactorY.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/SpillSumY.png%" type="image/png"><br\>\n@;
+ $str .= qq@<img src="%ADDPNG files/SpillPeakY.png%" type="image/png"><br\>\n@;
+ $str .= "<table style=\"margin:auto;\"><tr><td>Last Sum<td>".QA::SciNotation($total_y);
+ $str .= "<td>Last Duty<td>".sprintf("%0.3f",$duty_y);
+ $str .= "<tr><td>Last Duration<td>".$length_y;
+ $str .= "<td>Last Break<td>".$offtime_y." s";
+ $str .= "<tr><td>Last Max<td>".QA::SciNotation($max_y)." Hz (100ms)";
+ $str .= "<td>Spill Fluctuation<td>".QA::SciNotation($spillmin_y)." - ".QA::SciNotation($spillmax_y)."<br>∅ ".QA::SciNotation($spillavg_y)." (".QA::SciNotation($flucqual_y).")";
+ $str .= "</table>";
+ $str .= Hmon::MakeFooter();
+ Hmon::WriteFile("SpillShapeAnalysisY",$str);
+
+ HPlot::PlotDrawFork('SpillSumY');
+ HPlot::PlotDrawFork('SpillPeakY');
+ HPlot::PlotDrawFork('DutyFactorY');
+ }
+
+ HPlot::PlotAdd("StartPosition",$avg_x,0);
+ HPlot::PlotAdd("StartPosition",$avg_y,1);
+ HPlot::PlotAdd("StartPosition",$rms_x,2);
+ HPlot::PlotAdd("StartPosition",$rms_y,3);
+
+ for my $i(0..11){
+ HPlot::PlotAdd("StartRateXhistbar",$hitRatesStartX[$i],$i);
+ HPlot::PlotAdd("StartRateYhistbar",$hitRatesStartY[$i],$i);
+
+ }
+
+ HPlot::PlotDrawFork('StartPosition') if ($iter == 1);
+ HPlot::PlotDrawFork('StartRateXhistbar') if ($iter == 2);
+ HPlot::PlotDrawFork('StartRateYhistbar') if ($iter == 3);
+# HPlot::PlotDrawFork('SpillSumX') if ($iter == 4);
+# HPlot::PlotDrawFork('SpillPeakX') if ($iter == 5);
+# HPlot::PlotDrawFork('SpillSumY') if ($iter == 6);
+# HPlot::PlotDrawFork('SpillPeakY') if ($iter == 7);
+# HPlot::PlotDrawFork('DutyFactorX') if ($iter == 8);
+# HPlot::PlotDrawFork('DutyFactorY') if ($iter == 9);
+
+ $iter = 1 if ($iter++ == 10) #dont change
+
+ }
+
+ $lastinspill = $inspill;
+ $old = $current_readout;
+ usleep(100000);
+}
+
+
+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}-1, $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}-1,$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;
+
+}
+sub calculate_rates{
+ my ($ra_channels, $old,$current_readout) = @_ ;
+
+ my @result;
+ for my $i (0..11){
+ $result[$i] = 0;
+ }
+
+ foreach my $ch (@$ra_channels) {
+ my ($trbnet, $channel, $phy_channel) = ($ch->{tdc}, $ch->{ch}-1,$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[int($phy_channel/5)] += $rate;
+ }
+
+# for my $i(0..11){
+# $result[$i] +=2**28 if $result[$i] < 0;
+# }
+
+ return @result;
+}
+
+sub spillAnalysis{
+ my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
+
+ my $lastsum = 0; # sum of entries in last 15 readouts
+ my @totalDetectorHits = @{$totalDetectorHitsReference};
+ my @lastSpills = @{$lastSpillReference};
+ my ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, $spillEnds) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+
+ for my $i (1..15) { $lastsum += $totalDetectorHits[-$i]//0;}
+
+ #end of spill signaled by last 15 readouts having an average below spillThreshold entries and the one before having more
+ if($lastsum < 15 * $spillThreshold && ($totalDetectorHits[-16]//0) > $spillThreshold){
+ $max = max(@totalDetectorHits);
+ my $samples = scalar @totalDetectorHits;
+ my $avg = sum(@totalDetectorHits)/$samples;
+ $duty = $avg/$max;
+ $total = sum(@totalDetectorHits)/$samplesPerSecond;# sum and mulitply by bin width -> Integral. Gives total hits in a spill
+
+ push(@lastSpills,$total);
+ shift(@lastSpills) if scalar @lastSpills > 50;
+
+ $spillmin = min(@lastSpills);
+ $spillmax = max(@lastSpills);
+ $spillavg = sum(@lastSpills)/(scalar @lastSpills);
+ $flucqual = ($spillmax-$spillmin)/$spillavg;
+ $offtime = $empties/10;
+ $length = sprintf("%0.1f s (%i samples)", time()-$time, $samples);
+
+ $empties = 0;
+ $time = time();
+ @totalDetectorHits = ();
+
+ return ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, 1);
+ }
+
+ return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
+sub spillAnalysisACCSIG{
+ my ($totalDetectorHitsReference, $lastSpillReference, $time, $empties) = @_;
+
+ my @totalDetectorHits = @{$totalDetectorHitsReference};
+ my @lastSpills = @{$lastSpillReference};
+ my ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length, $spillEnds) = (0, 0, 0, 0, 0, 0, 0, 0, "", 0);
+
+
+ #end of spill signaled by last 15 readouts having an average below spillThreshold entries and the one before having more
+# if($inspill == 0 && $lastinspill == 1){
+ $max = max(@totalDetectorHits);
+ my $samples = scalar @totalDetectorHits;
+ my $avg = sum(@totalDetectorHits)/$samples;
+ $duty = $avg/($max||1);
+ $total = sum(@totalDetectorHits)/$samplesPerSecond;# sum and mulitply by bin width -> Integral. Gives total hits in a spill
+
+ push(@lastSpills,$total);
+ shift(@lastSpills) if scalar @lastSpills > 50;
+
+ $spillmin = min(@lastSpills);
+ $spillmax = max(@lastSpills);
+ $spillavg = sum(@lastSpills)/(scalar @lastSpills);
+ $flucqual = ($spillmax-$spillmin)/($spillavg||1);
+ $offtime = $empties/10;
+ $length = sprintf("%0.1f s (%i samples)", gettimeofday()-$time, $samples);
+ $empties = 0;
+ $time = gettimeofday();
+
+
+ # @totalDetectorHits = ();
+
+# $lastinspill = $inspill;
+ return ($max, $duty, $total, $spillmin, $spillmax, $spillavg, $flucqual, $offtime, $length,$time, $empties, 1);
+# }
+# $lastinspill = $inspill;
+# return (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+}
+
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
# my $time = "201204111356";
system("mkdir /home/hadaq/trbsoft/daq/hmon/archive/$time");
- system("cp /home/hadaq/trbsoft/daq/hmon/files/*.htt /home/hadaq/trbsoft/daq/hmon/files/*.png /home/hadaq/trbsoft/daq/hmon/archive/$time");
system("mkdir /home/hadaq/trbsoft/daq/hmon/archive/$time/files");
- system("mv /home/hadaq/trbsoft/daq/hmon/archive/$time/*.png /home/hadaq/trbsoft/daq/hmon/archive/$time/files/");
+ system("cp /home/hadaq/trbsoft/daq/hmon/files/*.htt /home/hadaq/trbsoft/daq/hmon/archive/$time");
+ system("cp /home/hadaq/trbsoft/daq/hmon/files/*.json /home/hadaq/trbsoft/daq/hmon/archive/$time");
+ system("cp /home/hadaq/trbsoft/daq/hmon/files/*.png /home/hadaq/trbsoft/daq/hmon/archive/$time/files/");
+# system("mv /home/hadaq/trbsoft/daq/hmon/archive/$time/*.png /home/hadaq/trbsoft/daq/hmon/archive/$time/files/");
my @files = qx(ls /home/hadaq/trbsoft/daq/hmon/archive/$time/*.htt);
foreach my $f (@files) {
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
$longtext .= "inactive" if (substr($res[0],7,2) eq "10");
$longtext .= "ABORT" if (substr($res[0],8,1) eq "1");
+ $longtext .= "<br>";
+ $longtext .= "Beam Abort Latch: ";
+ $longtext .= "none" if (substr($res[3],3,1) ne "1");
+ $longtext .= "ABORTED" if (substr($res[3],3,1) eq "1");
+
$value = "inactive" if $longtext =~ /inactive/;
$value = "ABORT" if $longtext =~ /ABORT/;
+ $value = "ABORTED" if $longtext =~ /ABORTED/;
$qastate = QA::WARN if $longtext =~ /inactive/;
$qastate = QA::FATAL if $longtext =~ /ABORT/;
+ $qastate = QA::ERROR if $longtext =~ /ABORTED/;
}
QA::WriteQALog($fqa,"main","beamabort",30,$qastate,'Beam Abort',$value,$longtext);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
# adjusted for BNET with dabc webserver JAM 2-Oct-2018
use strict;
use warnings;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
my $flog = QA::OpenQAFile();
my @colors = ("#333333","#00ff00","#ff0000","#0000ff","#dddd00","#dd00dd");
-my $TOTALCHANS = 652;
+my $TOTALCHANS = 815;
for my $i (0..5) {
HPlot::PlotInit( {
my $s="";
for(my $i = 1; $i <=6; $i++) {
- if ($i==2 or $i==3 or $i==5 or $i==6){
+ if ($i>=2){
for(my $j = 1; $j<=168; $j++) {
my $cnt = (($i-1)*168)+$j-1;
if($j<10) {$s = sprintf("HAD:ECAL:HV:S%i:M00%i:imon",$i,$j);}
for(my $i = 0; $i <=5; $i++) {
for(my $j = 0; $j<=167; $j++) {
my $cnt = ($i*168)+$j;
- if ($i==1 or $i==2 or $i==4 or $i==5){
+ if ($i>=1){
if (abs($data->{"U$cnt"}->{val}//0)>1000 and ($data->{"I$cnt"}->{val}//0)>50) {$ChnlsOn++;}
}
}
if ($ChnlsOn == 0) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
- } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= $TOTALCHANS-10) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
- } elsif ($ChnlsOn < 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS-10) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
} elsif ($ChnlsOn > $TOTALCHANS) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
if ($ChnlsOn == 0) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
- } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= $TOTALCHANS-10) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
- } elsif ($ChnlsOn < 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS-10) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
} elsif ($ChnlsOn > $TOTALCHANS) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
if ($ChnlsOn == 0) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
- } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= $TOTALCHANS-10) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
- } elsif ($ChnlsOn < 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS-10) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
} elsif ($ChnlsOn > $TOTALCHANS) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
if ($ChnlsOn == 0) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
- } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS and $ChnlsOn >= $TOTALCHANS-10) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
- } elsif ($ChnlsOn < 642) {
+ } elsif ($ChnlsOn < $TOTALCHANS-10) {
$str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
} elsif ($ChnlsOn > $TOTALCHANS) {
$str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
if($timer%8 == 0) {
if ($ChnlsOn>0 and $ChnlsOn<$TOTALCHANS and ($TOTALCHANS - $ChnlsOn) < 16) { #only report if a small number of channels is off
for(my $i = 1; $i <=6; $i++) {
- if ($i==2 or $i==3 or $i==5 or $i==6){
+ if ($i>=2){
for(my $j = 1; $j<=168; $j++) {
my $cnt = (($i-1)*168)+$j-1;
if($data->{"U$cnt"}->{val}<1000 and $data->{"I$cnt"}->{val}>=10){ $str .= sprintf("Low voltage on module %i, sector %i.<br>",$j,$i);}
$longtext = sprintf("HV channels On: %i/$TOTALCHANS<br>Check the current and voltage monitoring plots!<br>%s",$ChnlsOn,$str);
}
elsif($ChnlsOn==0) {
- $value = sprintf("HV is OFF");
+ $value = sprintf("OFF");
$longtext = sprintf("HV is OFF");
}
QA::WriteQALog($flog,"hv","ecalhv",30,$qastate,"ECAL HV",$value,$longtext);
for (my $i = 0; $i <= 5;$i++){
- if($i==1 or $i==2 or $i==4 or $i==5){
+ if($i>=1){
for (my $j = 0; $j<=167; $j++) {
my $cnt = ($i*168)+$j;
HPlot::PlotAdd("EcalCurr$i",$data->{"I$cnt"}->{val}||-1,);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
Perl2Epics::Connect("fRPC3_I" ,$EPICS_HEAD."S3:imon");
Perl2Epics::Connect("fRPC4_I" ,$EPICS_HEAD."S4:imon");
+Perl2Epics::Connect("fRPC_Temp" ,"HAD:fRPC:heater:T");
+
+
print "Connected.\n";
while(1) {
my $data = Perl2Epics::GetAll();
my @V = (
- $data->{"fRPC1_V"}->{val}/1000 || 0
- , $data->{"fRPC2_V"}->{val}/1000 || 0
- , $data->{"fRPC3_V"}->{val}/1000 || 0
- , $data->{"fRPC4_V"}->{val}/1000 || 0
+ $data->{"fRPC1_V"}->{val}/1000. || 0
+ , $data->{"fRPC2_V"}->{val}/1000. || 0
+ , $data->{"fRPC3_V"}->{val}/1000. || 0
+ , $data->{"fRPC4_V"}->{val}/1000. || 0
);
-
+
+ my @I = (
+ $data->{"fRPC1_I"}->{val}/1e6 || 0
+ , $data->{"fRPC2_I"}->{val}/1e6 || 0
+ , $data->{"fRPC3_I"}->{val}/1e6 || 0
+ , $data->{"fRPC4_I"}->{val}/1e6 || 0
+ );
+
+ my $temperature = $data->{"fRPC_Temp"}->{val} || 0;
+ my $temperature_s = sprintf("%.1f",$temperature);
+
my $max_V = max(@V);
my $min_V = min(@V);
-
-# my $value = QA::SciNotation($min_V)." - ".QA::SciNotation($max_V);
+ my $max_I = max(@I);
+ my $min_I = min(@I);
+
+ my $value = QA::SciNotation($min_V)."k/".QA::SciNotation($max_I)."/".$temperature_s."°";
- my $value = QA::SciNotation($data->{"fRPC1_V"}->{val}/1000)."/";
- $value .= QA::SciNotation($data->{"fRPC2_V"}->{val}/1000)."/";
- $value .= QA::SciNotation($data->{"fRPC3_V"}->{val}/1000)."/";
- $value .= QA::SciNotation($data->{"fRPC4_V"}->{val}/1000)."/";
+# my $value = QA::SciNotation($data->{"fRPC1_V"}->{val}/1000.)."/";
+# $value .= QA::SciNotation($data->{"fRPC2_V"}->{val}/1000.)."/";
+# $value .= QA::SciNotation($data->{"fRPC3_V"}->{val}/1000.)."/";
+# $value .= QA::SciNotation($data->{"fRPC4_V"}->{val}/1000.);
my $qastate = QA::GetQAState('above', $min_V, @QA::FrpcHvLimits);
$qastate = QA::NOTE if $QA::FrpcHvOff == 1;
$value = "HV is OFF" if $min_V < $QA::FrpcHvLimits[2] || $QA::FrpcHvOff == 1;
$value = "HV is ON, but should be off" if $min_V > $QA::FrpcHvLimits[2] && $QA::FrpcHvOff == 1;
- my $longtext = " fRPC-S1: ".QA::SciNotation($data->{"fRPC1_V"}->{val}/1000)."kV / ";
- $longtext .= QA::SciNotation($data->{"fRPC1_I"}->{val})."A <br>";
- $longtext .= " fRPC-S2: ".QA::SciNotation($data->{"fRPC2_V"}->{val}/1000)."kV / ";
- $longtext .= QA::SciNotation($data->{"fRPC2_I"}->{val})."A <br>";
- $longtext .= " fRPC-S3: ".QA::SciNotation($data->{"fRPC3_V"}->{val}/1000)."kV / ";
- $longtext .= QA::SciNotation($data->{"fRPC3_I"}->{val})."A <br>";
- $longtext .= " fRPC-S4: ".QA::SciNotation($data->{"fRPC4_V"}->{val}/1000)."kV / ";
- $longtext .= QA::SciNotation($data->{"fRPC4_I"}->{val})."A <br>";
+ my $longtext = " fRPC-S1: ".QA::SciNotation($V[0])."kV / ";
+ $longtext .= QA::SciNotation($I[0])."A <br>";
+ $longtext .= " fRPC-S2: ".QA::SciNotation($V[1])."kV / ";
+ $longtext .= QA::SciNotation($I[1])."A <br>";
+ $longtext .= " fRPC-S3: ".QA::SciNotation($V[2])."kV / ";
+ $longtext .= QA::SciNotation($I[2])."A <br>";
+ $longtext .= " fRPC-S4: ".QA::SciNotation($V[3])."kV / ";
+ $longtext .= QA::SciNotation($I[3])."A <br>";
+ $longtext .= " Temperature: ".$temperature_s."°C";
- QA::WriteQALog($flog,"hv2","frpchv",30,$qastate,"fRPC HV",$value,$longtext);
+ QA::WriteQALog($flog,"hv2","frpchv",30,$qastate,"fRPC",$value,$longtext);
sleep(10);
}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
my $longtext = sprintf("HV channels On: %i/%i<br>%s",$ChnlsOn, scalar @channels,$str);
$qastate = QA::GetQAState('above', $ChnlsOn, @QA::FwHvLimits);
- if ($ChnlsOn == 0){ $qastate = QA::WARN_2; $value = "HV is OFF";}
- if ($QA::FwHvOff == 1) { $qastate = QA::NOTE;}
+ if ($ChnlsOn == 0){ $qastate = QA::WARN_2; $value = "OFF";}
+ if ($QA::FwHvOff == 1) { $qastate = QA::OK;}
QA::WriteQALog($flog,"hv","fwhv",30,$qastate,"FW HV",$value,$longtext);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
#-d:DProf
use Hmon;
use QA;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
my $flog = QA::OpenQAFile();
-my $EPICS_HEAD = "HAD:iTOF:HV:";
-
-Perl2Epics::Connect("iTOF1_V" ,$EPICS_HEAD."S1:vmon");
-Perl2Epics::Connect("iTOF2_V" ,$EPICS_HEAD."S2:vmon");
-Perl2Epics::Connect("iTOF3_V" ,$EPICS_HEAD."S3:vmon");
-Perl2Epics::Connect("iTOF4_V" ,$EPICS_HEAD."S4:vmon");
-
-Perl2Epics::Connect("iTOF1_I" ,$EPICS_HEAD."S1:imon");
-Perl2Epics::Connect("iTOF2_I" ,$EPICS_HEAD."S2:imon");
-Perl2Epics::Connect("iTOF3_I" ,$EPICS_HEAD."S3:imon");
-Perl2Epics::Connect("iTOF4_I" ,$EPICS_HEAD."S4:imon");
-
-print "Connected.\n";
while(1) {
- my $data = Perl2Epics::GetAll();
- my @V = (
- $data->{"iTOF1_V"}->{val} || 0
- , $data->{"iTOF2_V"}->{val} || 0
- , $data->{"iTOF3_V"}->{val} || 0
- , $data->{"iTOF4_V"}->{val} || 0
- );
-
- my $max_V = max(@V);
- my $min_V = min(@V);
-
-# my $value = QA::SciNotation($min_V)." - ".QA::SciNotation($max_V);
+ my @ret = qx(/home/hadaq/trbsoft/daq/utils/HMP_Powersupply.pl 'IP192.168.103.187&HMP&5025&INST OUT4&MEAS:VOLT?&MEAS:CURR?');
- my $value = QA::SciNotation($data->{"iTOF1_V"}->{val})."/";
- $value .= QA::SciNotation($data->{"iTOF2_V"}->{val})."/";
- $value .= QA::SciNotation($data->{"iTOF3_V"}->{val})."/";
- $value .= QA::SciNotation($data->{"iTOF4_V"}->{val})."/";
-
- my $qastate = QA::GetQAState('above', $min_V, @QA::ItofHvLimits);
- $qastate = QA::NOTE if $QA::ItofHvOff == 1;
- $value = "HV is OFF" if $min_V < $QA::ItofHvLimits[2] || $QA::ItofHvOff == 1;
- $value = "HV is ON, but should be off" if $min_V > $QA::ItofHvLimits[2] && $QA::ItofHvOff == 1;
-
- my $longtext = " iTOF-1: ".QA::SciNotation($data->{"iTOF1_V"}->{val})."V / ";
- $longtext .= QA::SciNotation($data->{"iTOF1_I"}->{val})."A <br>";
- $longtext .= " iTOF-2: ".QA::SciNotation($data->{"iTOF2_V"}->{val})."V / ";
- $longtext .= QA::SciNotation($data->{"iTOF2_I"}->{val})."A <br>";
- $longtext .= " iTOF-3: ".QA::SciNotation($data->{"iTOF3_V"}->{val})."V / ";
- $longtext .= QA::SciNotation($data->{"iTOF3_I"}->{val})."A <br>";
- $longtext .= " iTOF-4: ".QA::SciNotation($data->{"iTOF4_V"}->{val})."V / ";
- $longtext .= QA::SciNotation($data->{"iTOF4_I"}->{val})."A <br>";
-
- QA::WriteQALog($flog,"hv2","itofhv",30,$qastate,"iTOF HV",$value,$longtext);
+ my @vals = split('&',$ret[0]);
+ my $value = QA::SciNotation( $vals[1])."V / ".QA::SciNotation( $vals[2])."A";
+ $value = "HV is OFF" if $vals[1] < 20 || $QA::ItofHvOff == 1;
+
+ my $qastate = QA::OK;
+ $qastate = QA::ERROR if $vals[1] < 20;
+ $qastate = QA::NOTE if $QA::ItofHvOff == 1;
+
+ QA::WriteQALog($flog,"hv2","itofhv",30,$qastate,"iTOF HV",$value,"");
+
sleep(10);
}
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
use warnings;
use v5.10.0;
-my @cpus = qw |lxhadeb07 lxhadeb08 lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 lxhadeb13 lxhadeb14 lxhadeb15 lxhadeb16 lxhaddcs05 lxhaddcs06 lxhadesdaq hadesdaq01 hades30 hadesp31 hades33 lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhaddcs05p lxhaddcs06p lxhadesdaqp hadesdaqp01 hadesdaqp02 hadesp30 hadesp33 hadesp57 |;
+my @cpus = qw |lxhadeb07 lxhadeb08 lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 lxhadeb13 lxhadeb14 lxhadeb15 lxhadeb16 lxhaddcs05 lxhaddcs06 lxhaddcs11 lxhadesdaq hadesdaq01 hades30 hadesp31 hades33 lxhadeb07p lxhadeb08p lxhadeb09p lxhadeb10p lxhadeb11p lxhadeb12p lxhadeb13p lxhadeb14p lxhadeb15p lxhadeb16p lxhaddcs05p lxhaddcs06p lxhaddcs11p lxhadesdaqp hadesdaqp02 hadesdaqp03 hadesdaqp04 hadesp30 hadesp33 hadesp57 hadesp70|;
for my $cpu (@cpus) {
my $c = "~/trbsoft/hadesdaq/hmon/hmon_ssh hadaq\@$cpu -N -f </dev/null >/dev/null&";
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
#use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use FileHandle;
use Data::Dumper;
use POSIX qw(strftime);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
#use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use FileHandle;
use Data::Dumper;
use POSIX qw(strftime);
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
<ul>
<li><a href="qaplot_Main.htm">Main</a><br>
<li><a href="qaplot_Start.htm">Start</a><br>
- <li><a href="qaplot_Hodo.htm">Hodo</a><br>
+ <li><a href="qaplot_Hodo.htm">Hodo</a><br>
<li><a href="qaplot_InnerTOF.htm">InnerTOF</a><br>
- <li><a href="qaplot_ForwardDet.htm">ForwardDet</a><br>
+ <li><a href="qaplot_ForwardDet.htm">ForwardDet</a><br>
<li><a href="qaplot_RICH.htm">RICH</a><br>
<li><a href="qaplot_MDCMon.htm">MDC</a><br>
<li><a href="qaplot_MDCExpert.htm">MDC Expert</a><br>
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use QA;
use List::Util qw(min max);
use Perl2Epics;
-
+use lib ".";
my @names;
my $errorcounter;
HAD:MDC:HV:P4:S5:TRIP:status:alive:roc:average
HAD:MDC:HV:P4:S6:TRIP:status:alive:roc:average
HAD:MDC:TEMP:TempLV:status:alive:roc:average
+HAD:MDC:HV:Ind1:TRIP:status:alive:roc:average
+HAD:MDC:HV:Ind2:TRIP:status:alive:roc:average
+HAD:MDC:HV:Ind3:TRIP:status:alive:roc:average
+HAD:MDC:HV:Ind4:TRIP:status:alive:roc:average
);
-# HAD:SHWR:HV:G26:status:alive:roc:average
-# HAD:SHWR:HV:G27:status:alive:roc:average
-# HAD:SHWR:HV:G28:status:alive:roc:average
-# HAD:SHWR:HV:G29:status:alive:roc:average
-# HAD:SHWR:HV:G30:status:alive:roc:average
-# HAD:SHWR:HV:G31:status:alive:roc:average
-# HAD:RICH:HV:G25:status:alive:roc:average
-# HAD:MDC:HV:Ind1:TRIP:status:alive:roc:average
-# HAD:MDC:HV:Ind2:TRIP:status:alive:roc:average
-# HAD:MDC:HV:Ind3:TRIP:status:alive:roc:average
-# HAD:MDC:HV:Ind4:TRIP:status:alive:roc:average
-
-# HAD:RPC:HV:G9:status:alive:roc:average
-
# HAD:MDC:HV:G41:status:alive:roc:average
# HAD:MDC:HV:G42:status:alive:roc:average
# HAD:MDC:HV:G43:status:alive:roc:average
# HAD:MDC:HV:G4045:status:alive:roc:average
# HAD:MDC:HV:G4046:status:alive:roc:average
+# HAD:SHWR:HV:G26:status:alive:roc:average
+# HAD:SHWR:HV:G27:status:alive:roc:average
+# HAD:SHWR:HV:G28:status:alive:roc:average
+# HAD:SHWR:HV:G29:status:alive:roc:average
+# HAD:SHWR:HV:G30:status:alive:roc:average
+# HAD:SHWR:HV:G31:status:alive:roc:average
+# HAD:RICH:HV:G25:status:alive:roc:average
+# HAD:MDC:HV:Ind1:TRIP:status:alive:roc:average
+# HAD:MDC:HV:Ind2:TRIP:status:alive:roc:average
+# HAD:MDC:HV:Ind3:TRIP:status:alive:roc:average
+# HAD:MDC:HV:Ind4:TRIP:status:alive:roc:average
+
+# HAD:RPC:HV:G9:status:alive:roc:average
+
+
+
my $flog = QA::OpenQAFile();
for my $v (@variables) {
for my $v (@names) {
next if $data->{$v}->{val} < 0;
if($data->{$v}->{val} < 0.5) {
- $qastate = max($qastate,QA::WARN2);
+ $qastate = max($qastate,QA::WARN_2);
$longtxt .= "$v stopped, ";
$count++;
}
$longtxt = "All sequencers running" if $longtxt eq "";
my $value = ((scalar @names)-$count)."/".(scalar @names);
- QA::WriteQALog($flog,"misc","sequencer",20,$qastate,"HV Sequencer",$value,$longtxt);
+ QA::WriteQALog($flog,"misc","sequencer",50,$qastate,"HV Sequencer",$value,$longtxt);
if($qastate == QA::FATAL) {
if(!($errorcounter%15)){
Hmon::Speak('nobeam', "High Voltage Control is not working");
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
--- /dev/null
+#!/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];
+
+use Encode qw(encode from_to);
+use JSON::XS;
+
+my $MINRATE = 1000; #minimum counts in 42ms
+my $BINWIDTH = 20; # µs bin width
+my $BINPERMEAN = 2100; #bins per read number set
+
+#TODO: Start / Stop trbnet here
+
+$ENV{'TRB3_SERVER'} = "192.168.104.2";
+$ENV{'DAQOPSERVER'} = "localhost:2";
+
+HPlot::PlotInit({
+ name => "QFactor",
+ file => "files/QFactor",
+ entries => 600,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ titles => [],
+ xlabel => "Time [s] (".($BINWIDTH*$BINPERMEAN/1000)." ms binning)",
+ ylabel => "QFactor",
+ sizex => 970,
+ sizey => 320,
+ ymin => "0.95",
+ ymax => "20.05",
+# ymax => "1.05<*",
+ curves => 2,
+ xscale => 23.81,
+ nokey => 1,
+ buffer => 1,
+ dots => 1,
+ });
+
+HPlot::PlotInit({
+ name => "MicroRate",
+ file => "files/MicroRate",
+ entries => 6000,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ titles => [],
+ xlabel => "Time [ms] (".($BINWIDTH)." µs binning)",
+ ylabel => "MicroRate",
+ sizex => 970,
+ sizey => 330,
+ ymin => "0",
+ curves => 1,
+ xscale => 50,
+ nokey => 1,
+# buffer => 1,
+# dots => 1,
+ });
+
+
+HPlot::PlotInit({
+ name => "MicroRate10ms",
+ file => "files/MicroRate10ms",
+ entries => 500,
+ type => HPlot::TYPE_HISTORY,
+ output => HPlot::OUT_PNG,
+ titles => [],
+ xlabel => "Time [ms] (".($BINWIDTH)." µs binning)",
+ ylabel => "MicroRate",
+ sizex => 970,
+ sizey => 330,
+ ymin => "0",
+ curves => 1,
+ xscale => 50,
+ nokey => 1,
+# buffer => 1,
+# dots => 1,
+ });
+
+
+
+
+my $str = Hmon::MakeTitle(13, 7, "Beam QFactor",0);
+$str .= qq@<img src="%ADDPNG files/QFactor.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("QFactor",$str);
+
+$str = Hmon::MakeTitle(13, 14, "Spill micro-structure",0);
+$str .= qq@<img src="%ADDPNG files/MicroRate.png%" type="image/png"><br>\n@;
+$str .= qq@<img src="%ADDPNG files/MicroRate10ms.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("MicroSpillStructure",$str);
+
+
+trb_init_ports() or die trb_strerror();
+
+my $round = 0;
+while(1) {
+
+
+ my $o = trb_register_read_mem(0xf3c0,0xb810,1,500) or print trb_strerror() or sleep 5 and next;
+
+ foreach my $b (keys %$o) {
+ my $time = 0;
+ my $maxbin = 0;
+ my $mean = 0;
+ my $total = 0;
+
+ foreach my $val (@{$o->{$b}}) {
+ if(($val & 0xf0000000) == 0x80000000) {
+ $time = $val & 0x0fffffff;
+ }
+ if(($val & 0xf0000000) == 0x90000000) {
+ $maxbin = $val & 0x0fffffff;
+ }
+ if(($val & 0xf0000000) == 0xa0000000) {
+ $total = $val & 0x0fffffff;
+# print $total."\n";
+ $mean = $total / $BINPERMEAN;
+ my $qfactor = $maxbin / ($mean||1);
+ HPlot::PlotAdd('QFactor',$qfactor,0) if($total >= $MINRATE && $qfactor < 20);
+ HPlot::PlotAdd('QFactor',"NaN",0) if($total < $MINRATE);
+ HPlot::PlotAdd('QFactor',"NaN",0) if($qfactor >= 20);
+
+ HPlot::PlotAdd('QFactor',"NaN",1) if($total >= $MINRATE && $qfactor < 20);
+ HPlot::PlotAdd('QFactor',1,1) if($total < $MINRATE);
+ HPlot::PlotAdd('QFactor',20,1) if($qfactor >= 20);
+
+ }
+ }
+ }
+ HPlot::PlotDraw('QFactor');
+
+
+# if($round == 8) {
+# trb_register_write(0xf3c0,0xb801,0x80000000);
+# }
+ $o = trb_register_read(0xf3c0,0xb806);
+ if($o->{0xf3c0} == 3) {
+ $o = trb_register_read_mem(0xf3c0,0xb811,1,6000) or print trb_strerror() or sleep 5 and next;
+
+
+ foreach my $b (keys %$o) {
+ foreach my $val (@{$o->{$b}}) {
+ HPlot::PlotAdd('MicroRate',$val & 0xffff,0);
+ HPlot::PlotAdd('MicroRate10ms',$val & 0xffff,0);
+ }
+ }
+ HPlot::PlotDraw('MicroRate');
+ HPlot::PlotDraw('MicroRate10ms');
+ }
+
+ $round++;
+ sleep 1;
+ }
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
--- /dev/null
+#!/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 .= "<table><col style=\"width:50px\"><col style=\"width:80px\"><tr><th>Start V<td>".QA::SciNotation($sv)." V";
+ $str .= "<tr><th>Start I<td>".ceil($simin*1000).' - '.ceil($simax*1000)." nA";
+ $str .= "<tr><th>Veto V<td>".QA::SciNotation($vv)." V";
+ $str .= "<tr><th>Veto I<td>".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<br>";
+ $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);
+ }
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
my $timer=0;
my $store;
-Perl2Epics::Connect("STS1_1" ,"HAD:STS:HV:STS1:P1:vmon");
-Perl2Epics::Connect("STS1_2" ,"HAD:STS:HV:STS1:P2:vmon" );
+Perl2Epics::Connect("STS1_3" ,"HAD:STS:HV:STS1:P3:vmon");
+Perl2Epics::Connect("STS1_4" ,"HAD:STS:HV:STS1:P4:vmon" );
Perl2Epics::Connect("STS2_1" ,"HAD:STS:HV:STS2:P1:vmon");
Perl2Epics::Connect("STS2_2" ,"HAD:STS:HV:STS2:P2:vmon" );
Perl2Epics::Connect("STS2_3" ,"HAD:STS:HV:STS2:P3:vmon");
my $data = Perl2Epics::GetAll();
my @v;
- $v[0] = $data->{"STS1_1"}->{val};
- $v[1] = $data->{"STS1_2"}->{val};
+ $v[0] = $data->{"STS1_3"}->{val};
+ $v[1] = $data->{"STS1_4"}->{val};
$v[2] = $data->{"STS2_1"}->{val};
$v[3] = $data->{"STS2_2"}->{val};
$v[4] = $data->{"STS2_3"}->{val};
my $max = max(@v);
my $min = min(@v);
-#
-# my $str = Hmon::MakeTitle(2, 3, "Start HV", 1, "");
-#
-# $str .= "<table><col style=\"width:50px\"><col style=\"width:80px\"><tr><th>Start V<td>".QA::SciNotation($sv)." V";
-# $str .= "<tr><th>Start I<td>".ceil($simin*1000).' - '.ceil($simax*1000)." nA";
-# $str .= "<tr><th>Veto V<td>".QA::SciNotation($vv)." V";
-# $str .= "<tr><th>Veto I<td>".ceil($vimin*1000).' - '.ceil($vimax*1000)." nA";
-#
-# $str .= Hmon::MakeFooter();
-# Hmon::WriteFile("StartHV", $str);
my $value = QA::SciNotation($min)." - ".QA::SciNotation($max);
my $qastate = QA::OK;
- $qastate = QA::WARN if $min < 1600;
+ $qastate = QA::WARN if $min < 1698;
$qastate = QA::ERROR if $min <= 100;
if ($QA::StsHvOff == 1) { $qastate = QA::NOTE;}
- if ($max < 10 || $QA::StsHvOff == 1) { $value="HV is OFF";}
+ if ($max < 10 || $QA::StsHvOff == 1) { $value="OFF";}
my $longtext = " STS-1: ".QA::SciNotation($v[0])."V / ".QA::SciNotation($v[1])."V <br>";
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use warnings;
use strict;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw( gettimeofday usleep time );
--- /dev/null
+#!/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 .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"files/styles.css\">";
+#
+# $str .= "<div style=\"text-align:left; margin-top: 10px; width: 200px\">";
+#
+# if ($ChnlsOn == 0) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
+# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn < 642) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn > 652) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } else {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# }
+# $str .= "$ChnlsOn";
+# $str .= "/652)</p></div>";
+#
+# $str .= "</div>\n\n";
+#
+# $str .= qq@<img src="%ADDPNG files/EcalCurr0.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalCurr5.png%" type="image/png">\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalCurr1.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalCurr4.png%" type="image/png">\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalCurr2.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalCurr3.png%" type="image/png"><br>\n@;
+#
+#
+# $str .= Hmon::MakeFooter();
+# $str .= "</body>";
+# $str .= "</html>";
+# Hmon::WriteFile("EcalHVCurr", $str);
+#
+#
+#
+# $str = Hmon::MakeTitle(11, 18, "ECAL HV - Voltage", 1, "");
+# $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"files/styles.css\">";
+#
+# $str .= "<div style=\"text-align:left; margin-top: 10px; width: 200px\">";
+#
+# if ($ChnlsOn == 0) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
+# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn < 642) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn > 652) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } else {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# }
+# $str .= "$ChnlsOn";
+# $str .= "/652)</p></div>";
+#
+# $str .= "</div>\n\n";
+#
+#
+# $str .= qq@<img src="%ADDPNG files/EcalVolt0.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalVolt5.png%" type="image/png">\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalVolt1.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalVolt4.png%" type="image/png">\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalVolt2.png%" type="image/png"><br>\n@;
+# $str .= qq@<img src="%ADDPNG files/EcalVolt3.png%" type="image/png"><br>\n@;
+#
+#
+# $str .= Hmon::MakeFooter();
+# $str .= "</body>";
+# $str .= "</html>";
+# Hmon::WriteFile("EcalHVVolt", $str);
+#
+#
+#
+#
+#
+# $str = Hmon::MakeTitle(10, 13, "ECAL HV - Voltage Map", 1, "");
+# $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"files/styles.css\">";
+#
+# $str .= "<div style=\"text-align:left; margin-top: 10px; width: 200px\">";
+#
+# if ($ChnlsOn == 0) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
+# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn < 642) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn > 652) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } else {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# }
+# $str .= "$ChnlsOn";
+# $str .= "/652)</p></div>";
+#
+# $str .= "</div>\n\n<table>\n<tr><td>Sector 1</td>\n<td>Sector 2</td>\n<td>Sector 3</td>\n</tr>\n<tr>";
+#
+#
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap0.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap1.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap2.png%" type="image/png"></td>\n</tr>\n@;
+#
+# $str .= "<tr><td>Sector 4</td>\n<td>Sector 5</td>\n<td>Sector 6</td>\n</tr>\n<tr>\n";
+#
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap3.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap4.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalVMap5.png%" type="image/png"></td>\n</tr>\n</table>\n@;
+#
+#
+# $str .= Hmon::MakeFooter();
+# $str .= "</body>";
+# $str .= "</html>";
+# Hmon::WriteFile("EcalHVVMap", $str);
+#
+#
+#
+# $str = Hmon::MakeTitle(10, 13, "ECAL HV - Current Map", 1, "");
+# $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"files/styles.css\">";
+#
+# $str .= "<div style=\"text-align:left; margin-top: 10px; width: 200px\">";
+#
+# if ($ChnlsOn == 0) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\" title=\"channels off\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels off (";
+# } elsif ($ChnlsOn < 652 and $ChnlsOn >= 642) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: orange;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn < 642) {
+# $str .= "<div><div class=\"redbutton\" style=\"float:left;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } elsif ($ChnlsOn > 652) {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left; background-color: #ffcc00;\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# } else {
+# $str .= "<div><div class=\"greenbutton\" style=\"float:left\"></div><p style=\"text-align:left;position: relative; left: 10px;top: 6px;\"> Channels on (";
+# }
+# $str .= "$ChnlsOn";
+# $str .= "/652)</p></div>";
+#
+# $str .= "</div>\n\n<table>\n<tr><td>Sector 1</td>\n<td>Sector 2</td>\n<td>Sector 3</td>\n</tr>\n<tr>";
+#
+#
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap0.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap1.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap2.png%" type="image/png"></td>\n</tr>\n@;
+#
+# $str .= "<tr><td>Sector 4</td>\n<td>Sector 5</td>\n<td>Sector 6</td>\n</tr>\n<tr>\n";
+#
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap3.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap4.png%" type="image/png"></td>\n@;
+# $str .= qq@<td><img src="%ADDPNG files/EcalCMap5.png%" type="image/png"></td>\n</tr>\n</table>\n@;
+#
+#
+# $str .= Hmon::MakeFooter();
+# $str .= "</body>";
+# $str .= "</html>";
+# 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);
+ }
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use Time::HiRes qw( gettimeofday usleep time );
use FileHandle;
use Data::Dumper;
-#!/usr/bin/perl -w
+#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
--- /dev/null
+###########################################################################################
+# JAM 17-10-2018 - introduce even more new server lxhadeb11, lxhadeb12, skip lxhadeb05
+# JAM2018 - setup for usage of NEW SERVERS lxhadeb08. lxhadeb09, lxhadeb10 - BNET only
+# JAM DEC-2019 - prepare for new trb3 datasources of rpc and tof
+# 0x84c0 - 0x84c5 : 6 new subevents for new RPC electronics.
+# 0x86c0 to 0x86c6 are the new hubs for TOF (1 TRB3 each, 128 channels each, 7 TRB3 total)
+#######
+# JAM july 2021: add new eventbuilders lxhadeb14,15,16; new setup with 7 inputs and 5 builders
+# JAM 14-jan-2022: optimization for beamtime feb22
+
+# Eventbuilders:
+# EB 0 is now used to define BNET destinations:
+
+# we define 7 input nodes in the setup for EB0-
+# BNET_IN 1: lxhadeb08 enp97s0f1 192.168.100.8 0xc0a86408 ports 50768 - 50805
+# BNET_IN 2: lxhadeb09 enp97s0f1 192.168.100.9 0xc0a86409 ports
+# BNET_IN 3: lxhadeb10 enp97s0f1 192.168.100.10 0xc0a8640a ports
+# BNET_IN 4: lxhadeb11 eno2 192.168.105.11 0xc0a8690b
+## BNET_IN 5: lxhadeb12 eno2 192.168.105.12 0xc0a8690c
+# lxhadeb14 enp67s0f0 192.168.105.14 0xc0a8690e
+# lxhadeb15 enp67s0f0 192.168.105.15 0xc0a8690f
+# lxhadeb16 enp67s0f0 192.168.105.16 0xc0a86910
+
+# the 5 builder nodes lxhadeb08 -lxhadeb11 are assigned in start_eb_gbe.pl
+#####################
+
+
+
+# EB 1: lxhadeb09 enp97s0f1 192.168.100.9 0xc0a86409 ports 50000 - 50099
+# EB 2: lxhadeb10 enp97s0f1 192.168.100.10 0xc0a8640a ports 50000 - 50099
+# EB 3: lxhadeb11 eth4 192.168.100.15 0xc0a8690b ports 50000 - 50099
+# EB 4: lxhadeb08 enp97s0f1 192.168.100.8 0xc0a86408 ports 50256 - 50293
+# EB 5: lxhadeb09 enp97s0f1 192.168.100.9 0xc0a86409 ports 50256 - 50293
+# EB 6: lxhadeb10 enp97s0f1 192.168.100.10 0xc0a8640a ports 50256 - 50293
+# EB 7: lxhadeb11 eno2 192.168.105.11 0xc0a8690b ports 50256 - 50293
+# EB 8: lxhadeb08 enp97s0f1 192.168.100.8 0xc0a86408 ports 50512 - 50549
+# EB 9: lxhadeb09 enp97s0f1 192.168.100.9 0xc0a86409 ports 50512 - 50549
+# EB 10: lxhadeb10 enp97s0f1 192.168.100.10 0xc0a8640a ports 50512 - 50549
+# EB 11: lxhadeb11 eno2 192.168.105.11 0xc0a8690b ports 50512 - 50549
+# EB 12: lxhadeb08 enp97s0f1 192.168.100.8 0xc0a86408 ports 50768 - 50805
+# EB 13: lxhadeb09 enp97s0f1 192.168.100.9 0xc0a86409 ports 50768 - 50805
+# EB 14: lxhadeb10 enp97s0f1 192.168.100.10 0xc0a8640a ports 50768 - 50805
+# EB 15: lxhadeb11 eno2 192.168.105.11 0xc0a8690b ports 50768 - 50805
+
+###########################################################################################
+
+
+#Broadcast to all GbE-Entities: 0xff7f
+
+!Register table
+# Type # C0 # C1 # C2 # C3 # C4 # C5 # C6 # C7 # C8 #
+###########################################################################################
+# #old register set
+# 17 0xc100 0xc101 0xc102 0xc103 0xc104 0xc105 0xc106 0xc107 0xc108
+# #new memory locations
+# 0 0x8100 0x8101 0x8102 0x8103 0x8104 0x8105 0x8106 0x8107 0x8108
+# 1 0x8110 0x8111 0x8112 0x8113 0x8114 0x8115 0x8116 0x8117 0x8118
+# 2 0x8120 0x8121 0x8122 0x8123 0x8124 0x8125 0x8126 0x8127 0x8128
+# 3 0x8130 0x8131 0x8132 0x8133 0x8134 0x8135 0x8136 0x8137 0x8138
+# 4 0x8140 0x8141 0x8142 0x8143 0x8144 0x8145 0x8146 0x8147 0x8148
+# 5 0x8150 0x8151 0x8152 0x8153 0x8154 0x8155 0x8156 0x8157 0x8158
+# 6 0x8160 0x8161 0x8162 0x8163 0x8164 0x8165 0x8166 0x8167 0x8168
+# 7 0x8170 0x8171 0x8172 0x8173 0x8174 0x8175 0x8176 0x8177 0x8178
+# 8 0x8180 0x8181 0x8182 0x8183 0x8184 0x8185 0x8186 0x8187 0x8188
+# 9 0x8190 0x8191 0x8192 0x8193 0x8194 0x8195 0x8196 0x8197 0x8198
+# 10 0x81A0 0x81A1 0x81A2 0x81A3 0x81A4 0x81A5 0x81A6 0x81A7 0x81A8
+# 11 0x81B0 0x81B1 0x81B2 0x81B3 0x81B4 0x81B5 0x81B6 0x81B7 0x81B8
+# 12 0x81C0 0x81C1 0x81C2 0x81C3 0x81C4 0x81C5 0x81C6 0x81C7 0x81C8
+# 13 0x81D0 0x81D1 0x81D2 0x81D3 0x81D4 0x81D5 0x81D6 0x81D7 0x81D8
+# 14 0x81E0 0x81E1 0x81E2 0x81E3 0x81E4 0x81E5 0x81E6 0x81E7 0x81E8
+# 15 0x81F0 0x81F1 0x81F2 0x81F3 0x81F4 0x81F5 0x81F6 0x81F7 0x81F8
+
+
+#Sliced tables for broadcast settings follow:
+# Type # C0 # C1 # C2 # C5 # C8 #
+#######################################################
+ 100 0x8100 0x8101 0x8102 0x8105 0x8108
+ 101 0x8110 0x8111 0x8112 0x8115 0x8118
+ 102 0x8120 0x8121 0x8122 0x8125 0x8128
+ 103 0x8130 0x8131 0x8132 0x8135 0x8138
+ 104 0x8140 0x8141 0x8142 0x8145 0x8148
+ 105 0x8150 0x8151 0x8152 0x8155 0x8158
+ 106 0x8160 0x8161 0x8162 0x8165 0x8168
+ 107 0x8170 0x8171 0x8172 0x8175 0x8178
+ 108 0x8180 0x8181 0x8182 0x8185 0x8188
+ 109 0x8190 0x8191 0x8192 0x8195 0x8198
+ 110 0x81A0 0x81A1 0x81A2 0x81A5 0x81A8
+ 111 0x81B0 0x81B1 0x81B2 0x81B5 0x81B8
+ 112 0x81C0 0x81C1 0x81C2 0x81C5 0x81C8
+ 113 0x81D0 0x81D1 0x81D2 0x81D5 0x81D8
+ 114 0x81E0 0x81E1 0x81E2 0x81E5 0x81E8
+ 115 0x81F0 0x81F1 0x81F2 0x81F5 0x81F8
+
+#Table for individual settings
+# Type # C3 # C4 # C6 # C7 #
+##############################################
+ 0 0x8103 0x8104 0x8106 0x8107
+ 1 0x8113 0x8114 0x8116 0x8117
+ 2 0x8123 0x8124 0x8126 0x8127
+ 3 0x8133 0x8134 0x8136 0x8137
+ 4 0x8143 0x8144 0x8146 0x8147
+ 5 0x8153 0x8154 0x8156 0x8157
+ 6 0x8163 0x8164 0x8166 0x8167
+ 7 0x8173 0x8174 0x8176 0x8177
+ 8 0x8183 0x8184 0x8186 0x8187
+ 9 0x8193 0x8194 0x8196 0x8197
+ 10 0x81A3 0x81A4 0x81A6 0x81A7
+ 11 0x81B3 0x81B4 0x81B6 0x81B7
+ 12 0x81C3 0x81C4 0x81C6 0x81C7
+ 13 0x81D3 0x81D4 0x81D6 0x81D7
+ 14 0x81E3 0x81E4 0x81E6 0x81E7
+ 15 0x81F3 0x81F4 0x81F6 0x81F7
+
+
+
+
+
+!Value table
+
+
+
+
+# Dest Port Src MAC Src IP Src Port # # TDC Calib flag
+# Hub # Type # C3 # C4 # C6 # C7 # EB IP # 1:NO 1:linear 2:complex 11:linear with ToT 15ns
+##########################################################################################################
+# JAM 25-may-2018: this first EB will be also used as pseudo node to setup the dabc bnet
+# JAM 17-oct-2018: adjusted for new server hardware only
+# last column will distribute to bnet input nodes
+# EB_LUT must be 0x1 in CTS for bnet mode
+# 0xc0a86408 lxhadeb08 mac 90:e2:ba:f7:9b:b5 192.168.100.8
+# 0xc0a86409 lxhadeb09, mac 90:e2:ba:f7:cf:a1 192.168.100.9
+# 0xc0a8640a lxhadeb10, mac 90:e2:ba:e2:c9:95 192.168.100.10
+# 0xc0a8690b lxhadeb11 mac ac:1f:6b:66:2a:29 192.168.105.11
+## 0xc0a8690c lxhadeb12 mac ac:1f:6b:64:73:17 192.168.105.12
+# note: lxhadeb12 will be only master node (and spare) JAM 26-07-2021
+# 0xc0a8690e lxhadeb14 mac 40:a6:b7:3c:b2:0c 192.168.105.14 - new 192.168.105.114
+# 0xc0a8690f lxhadeb15 mac 40:a6:b7:3c:5e:0c 192.168.105.15 - new 192.168.105.115
+# 0xc0a86910 lxhadeb16 mac 40:a6:b7:3c:6d:98 192.168.105.16 - new 192.168.105.116
+
+
+# note that we also need to set same destination ips in the hub table at the end of this file!
+#
+#lxhadebXX, EB1 XX
+# 0x8000 0 0xc65B 0xdead8000 0xc0a86480 0xc65B 0xc0a86408 0 # OLD cts -lxhadeb08
+ 0x8800 0 0xc650 0xdead8800 0xc0a8648B 0xc650 0xc0a8690b 0 # central-cts lxhadeb11
+ 0x8700 0 0xc65A 0xdead8700 0xc0a8648C 0xc65A 0xc0a86974 1 # fw new 1 lxhadeb16
+ 0x8701 0 0xc65B 0xdead8701 0xc0a8648C 0xc65B 0xc0a86974 1 # fw new 2 lxhadeb16
+ 0x8702 0 0xc65C 0xdead8702 0xc0a8648C 0xc65C 0xc0a86974 1 # fw new 3 lxhadeb16
+ 0x8880 0 0xc65D 0xdead8A00 0xc0a8648D 0xc65D 0xc0a86409 2 # start - lxhadeb09
+ 0x8890 0 0xc65F 0xdead8890 0xc0a8648F 0xc65F 0xc0a86409 2 # veto lxhadeb09
+# 0x8900 0 0xc65C 0xdead8900 0xc0a8648C 0xc65C 0xc0a86409 0 # pion1 lxhadeb09
+# 0x8910 0 0xc65E 0xdead8910 0xc0a8648E 0xc65E 0xc0a86409 0 # pion2 lxhadeb09
+ 0x1000 0 0xc660 0xdead1000 0xc0a86490 0xc660 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1010 0 0xc661 0xdead1010 0xc0a86491 0xc661 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1020 0 0xc662 0xdead1020 0xc0a86492 0xc662 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1030 0 0xc663 0xdead1030 0xc0a86493 0xc663 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1040 0 0xc664 0xdead1040 0xc0a86494 0xc664 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1050 0 0xc665 0xdead1050 0xc0a86495 0xc665 0xc0a86408 0 # mdc - lxhadeb08
+ 0x1100 0 0xc666 0xdead1100 0xc0a86496 0xc666 0xc0a86409 0 # mdc - lxhadeb09
+ 0x1110 0 0xc66A 0xdead1110 0xc0a86497 0xc66A 0xc0a86409 0 # mdc - lxhadeb09
+ 0x1120 0 0xc668 0xdead1120 0xc0a86498 0xc668 0xc0a86409 0 # mdc - lxhadeb09 - min for 09
+ 0x1130 0 0xc670 0xdead1130 0xc0a86499 0xc670 0xc0a86409 0 # mdc - lxhadeb09
+ 0x1140 0 0xc66B 0xdead1140 0xc0a8649A 0xc66B 0xc0a86409 0 # mdc - lxhadeb09
+ 0x1150 0 0xc669 0xdead1150 0xc0a8649B 0xc669 0xc0a86409 0 # mdc - lxhadeb09
+ 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
+ 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
+ 0x83c3 0 0xc67f 0xdead83c3 0xc0a864AF 0xc67F 0xc0a8640a 11 # rich lxhadeb10
+ 0x83c4 0 0xc680 0xdead83c4 0xc0a864B0 0xc680 0xc0a8640a 11 # rich lxhadeb10
+ 0x83c5 0 0xc681 0xdead83c5 0xc0a864B1 0xc681 0xc0a86974 11 # rich lxhadeb16 CHANGED
+ 0x83c6 0 0xc682 0xdead83c6 0xc0a864B2 0xc682 0xc0a86973 11 # rich lxhadeb15 CHANGED
+ 0x83c7 0 0xc683 0xdead83c7 0xc0a864B3 0xc683 0xc0a86973 11 # rich lxhadeb15 CHANGED
+ 0x83c8 0 0xc684 0xdead83c8 0xc0a864B4 0xc684 0xc0a86974 11 # rich lxhadeb16 CHANGED
+ 0x83c9 0 0xc685 0xdead83c9 0xc0a864B5 0xc685 0xc0a86974 11 # rich lxhadeb16 CHANGED
+ 0x83ca 0 0xc686 0xdead83ca 0xc0a864B6 0xc686 0xc0a8690b 11 # rich lxhadeb11
+ 0x83cb 0 0xc687 0xdead83cb 0xc0a864B7 0xc687 0xc0a86973 11 # rich lxhadeb15 CHANGED
+ 0x8810 0 0xc653 0xdead8810 0xc0a864B8 0xc653 0xc0a8690b 0 # central-aux lxhadeb11
+ 0x84c0 0 0xc654 0xdead84c0 0xc0a864B9 0xc654 0xc0a8640a 2 # rpc sector 1 lxhadeb10
+ 0x84c1 0 0xc655 0xdead84c1 0xc0a864BA 0xc655 0xc0a8640a 2 # rpc sector 2 lxhadeb10
+ 0x84c2 0 0xc656 0xdead84c2 0xc0a864BB 0xc656 0xc0a8640a 2 # rpc sector 3 lxhadeb10
+ 0x84c3 0 0xc657 0xdead84c3 0xc0a864BC 0xc657 0xc0a8690b 2 # rpc sector 4 lxhadeb11
+ 0x84c4 0 0xc658 0xdead84c4 0xc0a864BD 0xc658 0xc0a8690b 2 # rpc sector 4 lxhadeb11
+ 0x84c5 0 0xc651 0xdead84c4 0xc0a864BE 0xc651 0xc0a8690b 2 # rpc sector 4 lxhadeb11
+ 0x86c0 0 0xc690 0xdead86c0 0xc0a864C0 0xc690 0xc0a86408 2 # tof hub 0 lxhadeb08
+ 0x86c1 0 0xc691 0xdead86c2 0xc0a864C2 0xc691 0xc0a8640A 2 # tof hub 1 lxhadeb10
+ 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 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
+ 0x8b03 0 0xc6B3 0xdead8b03 0xc0a864D3 0xc6B3 0xc0a86973 2 # STS1 3 lxhadeb15
+ 0x8b10 0 0xc6B4 0xdead8b10 0xc0a864D9 0xc6B4 0xc0a86974 2 # STS2 0 lxhadeb16
+ 0x8b11 0 0xc6B5 0xdead8b11 0xc0a864DA 0xc6B5 0xc0a86974 2 # STS2 1 lxhadeb16
+ 0x8b12 0 0xc6B6 0xdead8b12 0xc0a864DB 0xc6B6 0xc0a86974 2 # STS2 2 lxhadeb16
+ 0x8b13 0 0xc6B7 0xdead8b13 0xc0a864DC 0xc6B7 0xc0a86974 2 # STS2 3 lxhadeb16
+ 0x8b14 0 0xc6B8 0xdead8b14 0xc0a864DD 0xc6B8 0xc0a86974 2 # STS2 4 lxhadeb16
+ 0x8b15 0 0xc6B9 0xdead8b15 0xc0a864DE 0xc6B9 0xc0a86974 2 # STS2 5 lxhadeb16
+ 0x8c00 0 0xc6BA 0xdead8c00 0xc0a864C0 0xc6BA 0xc0a86973 2 # fw-RPC 0 lxhadeb15
+ 0x8c10 0 0xc6BB 0xdead8c01 0xc0a864C0 0xc6BB 0xc0a86973 2 # fw-RPC 1 lxhadeb15
+ 0x8d00 0 0xc6BC 0xdead86c2 0xc0a864C2 0xc6BC 0xc0a8640A 2 # innertof moved to lxhadeb10
+ # 0x8d00 0 0xc6BC 0xdead86c1 0xc0a864C1 0xc6BC 0xc0a86409 2 # inner-tof lxhadeb09
+
+ #######################################################################################################################
+#######################################################################################################################
+
+
+
+# hub setup - destination macs and ips
+
+#############################################################################
+#
+# lxhadeb08 enp97s0f1 90:e2:ba:f7:9b:b5 192.168.100.8 0xc0a86408
+# lxhadeb09 enp97s0f1 90:e2:ba:f7:cf:a1 192.168.100.9 0xc0a86409
+# lxhadeb10 enp97s0f1 90:e2:ba:e2:c9:95 192.168.100.10 0xc0a8640a
+# lxhadeb11 eno2 ac:1f:6b:66:2a:29 192.168.105.11 0xc0a8690b
+# lxhadeb12 eno2 ac:1f:6b:64:73:17 192.168.105.12 0xc0a8690c
+
+# second gbe
+# lxhadeb11 enp19s0f1 ac:1f:6b:8b:62:f1 192.168.105.11 0xc0a8690b
+# lxhadeb12 enp19s0f1 ac:1f:6b:8b:60:1f 192.168.105.12 0xc0a8690c
+
+# lxhadeb14 enp67s0f0 40:a6:b7:3c:b2:0c 192.168.105.14 0xc0a8690e
+# new 192.168.105.114 0xc0a86972
+# lxhadeb15 enp67s0f0 40:a6:b7:3c:5e:0c 192.168.105.15 0xc0a8690f
+# new 192.168.105.115 0xc0a86973
+# lxhadeb16 enp67s0f0 40:a6:b7:3c:6d:98 192.168.105.16 0xc0a86910
+# new 192.168.105.116 0xc0a86974
+
+# EB 3: lxhadeb05 eth4 192.168.100.15 0xc0a8640f
+
+
+# Dest MAC Dest MAC Dest IP Src MAC Packet Size
+# Hub # Type # C0 # C1 # C2 # C5 # C8 #
+#####################################################################################
+ # 0xff7f 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 #lxhadeb08 EB0 90:e2:ba:f7:9b:b5 192.168.100.8
+ # JAM 27-apr-2018: for DABC-BNET (Type 100) the destination ips have to be set here for individual hubs
+# the ip entries in above table for eb1 needs to match this to configure EBs!
+ # 0xff7f 100 0x2157b095 0x001B 0xc0a8640f 0x0230 0x0578 #dummies to lxhadeb05, EB3 00:1b:21:57:b0:95 192.168.100.15
+#
+ 0x8700 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # fw new 1 lxhadeb16
+ 0x8701 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # fw new 2 lxhadeb16
+ 0x8702 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # fw new 3 lxhadeb16
+ 0x8800 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # central-cts lxhadeb11 ######
+ 0x8880 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # start - lxhadeb09
+ 0x8890 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # veto lxhadeb09
+# 0x8900 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # pion1 lxhadeb09
+# 0x8910 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # pion2 lxhadeb09
+ 0x1000 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1010 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1020 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1030 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1040 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1050 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # mdc - lxhadeb08
+ 0x1100 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x1110 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x1120 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x1130 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x1140 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x1150 100 0xbaf7cfa1 0x90e2 0xc0a86409 0x0230 0x0578 # mdc- lxhadeb09
+ 0x8a00 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # ecal - lxhadeb10
+ 0x8a01 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # ecal - lxhadeb10
+ 0x8a02 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # ecal - lxhadeb10
+ 0x8a03 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # ecal - lxhadeb10
+ 0x8a04 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # ecal- lxhadeb14
+ 0x8a05 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # ecal- lxhadeb14
+ 0x83c0 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # rich -lxhadeb14
+ 0x83c1 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # rich -lxhadeb14
+ 0x83c2 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # rich -lxhadeb14
+ 0x83c3 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # rich - lxhadeb10
+ 0x83c4 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # rich - lxhadeb10
+ 0x83c5 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # rich - lxhadeb16 CHANGED
+ 0x83c6 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # rich - lxhadeb15 CHANGED
+ 0x83c7 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # rich - lxhadeb15 CHANGED
+ 0x83c8 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # rich - lxhadeb16 CHANGED
+ 0x83c9 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # rich - lxhadeb16 CHANGED
+ 0x83ca 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # rich - lxhadeb11
+ 0x83cb 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # rich - lxhadeb15 CHANGED
+ 0x8810 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # central aux - lxhadeb11
+ 0x84c0 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # rpc sector 1 lxhadeb10
+ 0x84c1 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # rpc sector 2 lxhadeb10
+ 0x84c2 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # rpc sector 3 lxhadeb10
+ 0x84c3 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # rpc sector 4 lxhadeb11
+ 0x84c4 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # rpc sector 5 lxhadeb11
+ 0x84c5 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # rpc sector 6 lxhadeb11
+ 0x86c0 100 0xbaf79bb5 0x90e2 0xc0a86408 0x0230 0x0578 # tof hub 0 lxhadeb08
+ 0x86c1 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # tof hub 1 lxhadeb10
+ 0x86c2 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # tof hub 2 lxhadeb10
+ 0x86c3 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # tof hub 3 lxhadeb11
+ 0x86c4 100 0x6b8b62f1 0xac1f 0xc0a8690b 0x0230 0x0578 # tof hub 4 lxhadeb11
+ 0x86c5 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # tof hub 5 lxhadeb14
+ 0x86c6 100 0xb73cb20c 0x40a6 0xc0a86972 0x0230 0x0578 # tof hub 6 lxhadeb14
+ 0x8b00 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # STS1 0 lxhadeb15
+ 0x8b01 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # STS1 1 lxhadeb15
+ 0x8b02 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # STS1 2 lxhadeb15
+ 0x8b03 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # STS1 3 lxhadeb15
+ 0x8b10 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 0 lxhadeb16
+ 0x8b11 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 1 lxhadeb16
+ 0x8b12 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 2 lxhadeb16
+ 0x8b13 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 3 lxhadeb16
+ 0x8b14 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 4 lxhadeb16
+ 0x8b15 100 0xb73c6d98 0x40a6 0xc0a86974 0x0230 0x0578 # STS2 5 lxhadeb16
+ 0x8c00 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # fwRPC-0 - lxhadeb15
+ 0x8c10 100 0xb73c5e0c 0x40a6 0xc0a86973 0x0230 0x0578 # fwRPC-1 - lxhadeb15
+ 0x8d00 100 0xbae2c995 0x90e2 0xc0a8640a 0x0230 0x0578 # innertof lxhadeb10
+
+
+
+
+
+
+++ /dev/null
-../hmon/Perl2Epics.pm
\ No newline at end of file
--- /dev/null
+package Perl2Epics;
+use warnings;
+use strict;
+use Data::Dumper;
+# use Hmon;
+
+use lib '/home/scs/EPICS/EPICS-3.14.12.4/base/' . '/lib/perl';
+use lib '/home/hadaq/EPICS/EPICS-3.15.6/base' . '/lib/perl';
+use lib '/home/hadaq/soft/EPICS/EPICS-3.16.1/base/' . '/lib/perl';
+use lib '/home/epics/EPICS/EPICS-3.16.1/base/' . '/lib/perl';
+use lib '/home/hadaq/soft/EPICS/EPICS-7.0.1.1/base/' . '/lib/perl';
+use CA;
+
+#JAM 2020: back to default after EBs are done with epics
+$ENV{EPICS_CA_AUTO_ADDR_LIST} = 'YES';
+#$ENV{EPICS_CA_AUTO_ADDR_LIST} = 'NO';
+
+#JAM2018: updated after network mask redefinition:
+#$ENV{EPICS_CA_ADDR_LIST} = "192.168.111.255 192.168.111.255:10012 192.168.111.255:10008 192.168.111.255:10003 192.168.111.255:10002 192.168.111.255:10001 192.168.111.255:10014 192.168.111.255:10007 192.168.111.255:10004 192.168.111.255:10010 192.168.111.255:10013 192.168.111.255:10015 192.168.111.255:10016 192.168.111.255:10009 192.168.111.255:10005 192.168.103.83:10011 192.168.111.255:10006 localhost";
+#$ENV{EPICS_CA_ADDR_LIST} = "192.168.111.255:10006 192.168.111.255:10010 192.168.111.255:10011 192.168.111.255:10012 192.168.111.255:10013 192.168.111.255:10014 192.168.111.255:10015 192.168.111.255:10016 192.168.111.255:10017 192.168.111.255:10018 192.168.111.255:10019";
+#$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";
+
+
+#
+# JAM added fixed port numbers of EB epics
+#$ENV{EPICS_CA_ADDR_LIST} = "192.168.103.255 192.168.103.255:10012 192.168.103.255:10008 192.168.103.255:10003 192.168.103.255:10002 192.168.103.255:10001 192.168.103.255:10014 192.168.103.255:10007 192.168.103.255:10004 192.168.103.255:10010 192.168.103.255:10013 192.168.103.255:10015 192.168.103.255:10016 192.168.103.255:10009 192.168.103.255:10005 192.168.103.255:10011 192.168.103.255:10006 localhost";
+#$ENV{EPICS_CA_ADDR_LIST} = "192.168.100.11 192.168.100.12 192.168.100.13 192.168.100.14 192.168.100.15 localhost";
+
+my $EpicsValues = {};
+my $EpicsStore = {};
+my @EpicsChans = ();
+my $EpicsNames = {};
+my $errcnt = {};
+
+sub callback {
+ my ($chan, $status, $data) = @_;
+# print Dumper $data;
+ if ($status) {
+ printf "%-30s %s\n", $chan->name, $status;
+ }
+ else {
+# print $chan->name . ": $data->{value}\n";
+# print scalar @{$EpicsStore->{$chan->name}->{tme}}."\n";
+ if(scalar @{$EpicsStore->{$chan->name}->{tme}} > 10) {
+ shift @{$EpicsStore->{$chan->name}->{tme}};
+ shift @{$EpicsStore->{$chan->name}->{val}};
+ }
+ push(@{$EpicsStore->{$chan->name}->{tme}}, $data->{stamp});
+ push(@{$EpicsStore->{$chan->name}->{val}}, $data->{value});
+ $EpicsValues->{$chan->name}->{tme} = $data->{stamp};
+ $EpicsValues->{$chan->name}->{val} = $data->{value};
+ }
+}
+
+
+sub Connect {
+ my ($title, $varname, $type, $wait) = @_;
+ # push(@EpicsChans,CA->new($name));
+ # $EpicsChans[-1]->create_subscription('v', \&callback, 'DBR_TIME_DOUBLE');
+ ## print $varname."\n";
+ $type = 'DBR_TIME_DOUBLE' unless defined $type;
+ $EpicsStore->{$varname}->{tme} = [];
+ $EpicsStore->{$varname}->{val} = [];
+ $EpicsNames->{$title} = $varname;
+ $errcnt->{$varname} = 0;
+ my $success;
+ eval {
+ my $c = CA->new($varname);
+ CA->pend_io($wait || 0.05);
+ $c->create_subscription('v', \&callback, $type);
+# $c->get_callback(\&callback, $type, 1);
+ $EpicsStore->{$varname}->{ca} = $c;
+ $success = $c->is_connected();
+ };
+ #print Dumper $EpicsValues;
+ return ($success);
+}
+
+sub Update {
+ CA->pend_event($_[0]);
+}
+
+
+sub GetAll {
+ my $store = {};
+ my $time;
+ my $val;
+
+ #Update(0.001);
+ Update(0.2);
+
+ foreach my $el (keys %{$EpicsNames}) {
+ my $varname = $EpicsNames->{$el};
+ my $ca = $EpicsStore->{$varname}->{ca};
+ my $r = $ca->is_connected() if(defined $ca);
+ my $success = 1;
+ if(!$r && (!defined $errcnt->{$el} || $errcnt->{$el} < 2000)) {
+ $success = Connect($el, $varname);
+ $errcnt->{$el}++;
+ }
+
+ if(!$success) {
+ $time = -1;
+ $val = 0;
+ } elsif (scalar @{$EpicsStore->{$varname}->{tme}} > 0) {
+ $time = (@{$EpicsStore->{$varname}->{tme}})[-1];
+ $val = (@{$EpicsStore->{$varname}->{val}})[-1];
+ } else {
+ $time = $EpicsStore->{$varname}->{lasttime};
+ $val = $EpicsStore->{$varname}->{lastval};
+ }
+ $store->{$el}->{tme} = $time;
+ $store->{$el}->{val} = $val;
+ $EpicsStore->{$varname}->{lasttime} = $time;
+ $EpicsStore->{$varname}->{lastval} = $val;
+ }
+
+ return $store;
+}
+
+sub Get {
+ my ($title,$latest) = @_;
+ my $varname = $EpicsNames->{$title};
+ my $time;
+ my $val;
+# print $varname;
+
+ my $c = $EpicsStore->{$varname}->{ca};
+ my $r = $c->is_connected() if(defined $c);
+
+ my $success = 1;
+ if(!$r) {
+ $success = Connect($title, $varname);
+ }
+
+ if(!$success) {
+ return (-1, 0);
+ }
+
+ #Update(0.00001);
+ Update(0.2);
+
+ if (scalar @{$EpicsStore->{$varname}->{tme}} > 0) {
+ if(defined $latest && $latest == 1) {
+ $time = (@{$EpicsStore->{$varname}->{tme}})[-1];
+ $val = (@{$EpicsStore->{$varname}->{val}})[-1];
+ }
+ else { #if (scalar @{$EpicsStore->{$varname}->{tme}} > 1)
+ $time = shift (@{$EpicsStore->{$varname}->{tme}});
+ $val = shift (@{$EpicsStore->{$varname}->{val}});
+ }
+ }
+ else {
+ $time = $EpicsStore->{$varname}->{lasttime};
+ $val = $EpicsStore->{$varname}->{lastval};
+ }
+ $EpicsStore->{$varname}->{lasttime} = $time;
+ $EpicsStore->{$varname}->{lastval} = $val;
+ $time = $time || -1;
+ $val = $val || 0;
+ return ($time,$val);
+}
+
+sub Put {
+ my ($title, $value) = @_;
+ my $varname = $EpicsNames->{$title};
+ if (!defined $varname) {
+ return -1;
+ }
+
+ my $c = $EpicsStore->{$varname}->{ca};
+ my $r = $c->is_connected() if(defined $c);
+
+ my $success = 1;
+ if(!$r) {
+ $success = Connect($title, $varname);
+ }
+
+ if(!$success) {
+ return -2;
+ }
+
+ if (!$c || ($c->element_count()) != 1) {
+ print "5\n";
+ return -3;
+ }
+
+ my $type = $c->field_type;
+ my @values;
+ if ($type !~ m/ ^DBR_STRING$ | ^DBR_ENUM$ /x) {
+ # Make @ARGV strings numeric
+ push (@values, (map { +$_; } $value));
+ } else {
+ # Use strings
+ push (@values, $value);
+ }
+ $c->put(@values);
+
+ return 0;
+}
+
+1;
+__END__
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use lib "../nettools/";
+use Perl2Epics;
+use Data::Dumper;
+
+print "Connect..\n";
+my $s = "HAD:LV:PS:33:SETONOFF";
+Perl2Epics::Connect("STS_PowerOnOff",$s);
+$s = "HAD:LV:PS:34:SETONOFF";
+Perl2Epics::Connect("fRPC_PowerOnOff",$s);
+
+Perl2Epics::Put("RICHLV_PowerOnOff",1);
+Perl2Epics::Put("fRPC_PowerOnOff",1);
+Perl2Epics::GetAll();
+
+sleep 8;
+Perl2Epics::Put("RICHLV_PowerOnOff",0);
+Perl2Epics::Put("fRPC_PowerOnOff",0);