From: Adrian Weber Date: Thu, 27 Dec 2018 14:38:01 +0000 (+0100) Subject: mRICH config file and mrichrate script. X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=bd0b4e54d5d682ab4bcefed0397d74c916fd39c5;p=daqtools.git mRICH config file and mrichrate script. --- diff --git a/dmon/mRICH_config.pl b/dmon/mRICH_config.pl new file mode 100644 index 0000000..2e92124 --- /dev/null +++ b/dmon/mRICH_config.pl @@ -0,0 +1,27 @@ +#This a an example configuration file. Copy this file to your user directory and give +#start.pl a link to this file as first argument. + +#Scripts to start & order of icons in the Overview +activeScripts => [['time','trgrate','HMP4040','trigNr','daqop'], + ['trbnet','timeouts','reftime','datarate','deadtime'], + ['temperature_mrich','adcvolt','adccurr','bck','cts_temp'], + ['numfee','-','-','extClk','pulser'],], + +#Names to be shown in left column of Overview (max 4 letters!) +qaNames => ['main','DAQ','rich','rich'], + +#Expected number of FPGAs in system +NumberOfFpga => 79, + +#The address of the CTS +CtsAddress => 0xc000, + +#Addresses of all TDCs. Either single or broadcast addresses +TdcAddress => [0xfe51,0xfe52], + +AdcDiRichAddress => [0xfe51], +AdcCombinerAddress => [0xfe52], +AdcTrb3sc => [0xc000], + +# Write in jsonToObj [LV,] +Json => [1], diff --git a/dmon/scripts/dmon_richrate.pl b/dmon/scripts/dmon_richrate.pl new file mode 100755 index 0000000..dbf6cc1 --- /dev/null +++ b/dmon/scripts/dmon_richrate.pl @@ -0,0 +1,111 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Data::Dumper; +use Data::TreeDumper; +use Dmon; +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 $plot0 = { +name => "RichRate", +file => "files/RichRate", +title => "mRICH Rate", +entries => 72, +curves => 32, +type => HPlot::TYPE_HEATMAP, +output => HPlot::OUT_PNG, +zlabel => "Hitrate", +sizex => 800, +sizey => 700, +nokey => 1, +buffer => 1, +xmin => -0.5, +xmax => 71.5, +ymin => -0.5, +ymax => 31.5, +cbmax => "100<*<1E6", +cbmin => 0.0, +noinit => 1, +additional => "set logscale cb;", #set xrange [192.5:-1.5] reverse +showvalues => 0, }; +HPlot::PlotInit($plot0); + + +my $str = Dmon::MakeTitle(11, 16, "RICH Hit Rate",0); +$str .= qq@
\n@; +$str .= Dmon::MakeFooter(); +Dmon::WriteFile("RichRate",$str); + + +my $old; +my $oldtime = time(); +my $time = time(); +my $diff; +my $iter = 0; + + + +trb_init_ports() or die trb_strerror(); + + my $filename = 'files/mRICH_Mapping_20181227.geo'; + + open(my $fh, '<:encoding(UTF-8)', $filename) + or die "Could not open file '$filename' $!"; + + my @pos; + + while (my $row = <$fh>) { + chomp $row; + if (substr($row,0,1) eq '#') {next;} + my @words = split / /, $row; + if ($words[0] eq "Di-Rich") {next;} + if (defined $words[0]) { + + my $dirich= ((hex $words[0])&0xfff); + my $ch=int $words[1]; + $pos[$dirich][$ch][0]=int $words[4]; + $pos[$dirich][$ch][1]=int $words[5]; + + } + } + + +while(1) { + + my $o = trb_register_read_mem(0xfe51,0xc000,0,33) or die trb_strerror() or sleep 5 and next; + + if (defined $old) { + my $tdiff = time() - $oldtime; + foreach my $b (keys %$o) { + #my $ratesum = 0; + #my $sec = ($b>>1) & 0x3; + #my $xpos = (($b>>8)&0xF)*24 + (($b>>4)&0xF)*2 + ($b&1); + + for my $v (0..31) { + my $vdiff = ($o->{$b}->[$v+1]&0xfffffff) - ($old->{$b}->[$v+1]&0xfffffff); + + if ($vdiff < 0) { $vdiff += 2**28;} + $diff->{$b}->[$v+1] = $vdiff/($tdiff|1); + #$ratesum += $diff->{$b}->[$v+1]; + if (defined $pos[$b&0xfff][$v+1][0] && defined $pos[$b&0xfff][$v+1][1]) { + HPlot::PlotFill('RichRate',$diff->{$b}->[$v+1],$pos[$b&0xfff][$v+1][0],$pos[$b&0xfff][$v+1][1]); + } + } + } + + HPlot::PlotDraw('RichRate'); + + } + + $old = $o; + $oldtime = time(); + sleep 2; + }