]> jspc29.x-matter.uni-frankfurt.de Git - hadesdaq.git/commitdiff
update Hmon scripts
authorhadaq <jan@lxhadeb07>
Tue, 27 Nov 2018 09:08:03 +0000 (10:08 +0100)
committerhadaq <jan@lxhadeb07>
Tue, 27 Nov 2018 09:08:03 +0000 (10:08 +0100)
hmon/ecal_drawing.htm
hmon/getrootjson.cgi [new file with mode: 0755]
hmon/hmon_richthreshold.pl [new file with mode: 0755]
hmon/hmon_startrate.pl
hmon/hmon_tdcchanerrors.pl [new file with mode: 0755]
hmon/index.cgi
hmon/permanent/hmon_eb_run.pl
hmon/permanent/hmon_ecalhv.pl [new file with mode: 0755]
hmon/permanent/hmon_interrupt.pl [new file with mode: 0755]
hmon/permanent/hmon_richhv.pl

index 4d4726f47124e2386194a77c1804e62c2f4ad4e9..3f2f08d2f767bdb1c3c06872172a6956583d6ad3 100644 (file)
@@ -1831,7 +1831,7 @@ function updatedata(d) {
                   ["0x6055",52,0,0], ["0x6055",53,1,1], ["0x6055",54,2,2], ["0x6055",55,14,14], ["0x6055",56,15,15], ["0x6052",57,5,5], ["0x6052",58,6,6], ["0x6052",59,7,7], ["0x6052",60,8,8], ["0x6052",61,9,9], ["0x6052",62,10,10],
                   ["0x6055",63,3,3], ["0x6055",64,4,4], ["0x6055",65,5,5], ["0x6055",66,6,6], ["0x6055",67,7,7], ["0x6052",68,16,16], ["0x6052",69,11,11], ["0x6052",70,12,12], ["0x6052",71,13,13], ["0x6052",72,14,14], ["0x6052",73,15,15],
                   ["0x6054",74,17,17], ["0x6054",75,18,18], ["0x6054",76,19,19], ["0x6054",77,20,20], ["0x6054",78,21,21], ["0x6054",79,22,22], ["0x6054",80,23,23], ["0x6051",81,16,16], ["0x6051",82,17,17], ["0x6051",83,18,18], ["0x6051",84,19,19], ["0x6051",85,20,20], ["0x6051",86,21,21],
-                  ["0x6054",87,8,8], ["0x6054",88,9,9], ["0x6054",89,10,10], ["0x6054",90,11,11], ["0x6054",91,12,12], ["0x6054",92,13,13], ["0x6051",93,8,8], ["0x6051",94,9,9], ["0x6051",95,10,10], ["0x6051",96,11,11], ["0x6051",97,12,12], ["0x6051",98,13,13], ["0x6051",99,14,14],
+                  ["0x6054",87,8,8], ["0x6054",88,9,9], ["0x6054",89,10,10], ["0x6054",90,11,11], ["0x6054",91,12,12], ["0x6054",92,13,13], ["0x6051",93,9,9], ["0x6051",94,9,9], ["0x6051",95,10,10], ["0x6051",96,11,11], ["0x6051",97,12,12], ["0x6051",98,13,13], ["0x6051",99,14,14],
                   ["0x6054",100,0,0], ["0x6054",101,1,1], ["0x6054",102,2,2], ["0x6054",103,3,3], ["0x6054",104,4,4], ["0x6054",105,5,5], ["0x6054",106,6,6], ["0x6051",107,0,0], ["0x6051",108,1,1], ["0x6051",109,2,2], ["0x6051",110,3,3], ["0x6051",111,4,4], ["0x6051",112,5,5], ["0x6051",113,6,6], ["0x6051",114,7,7],
                   ["0x6054",115,7,7], ["0x6053",116,16,16], ["0x6053",117,17,17], ["0x6053",118,18,18], ["0x6053",119,19,19], ["0x6053",120,20,20], ["0x6053",121,21,21], ["0x6053",122,22,22], ["0x6050",123,16,16], ["0x6050",124,17,17], ["0x6050",125,18,18], ["0x6050",126,19,19], ["0x6050",127,20,20], ["0x6050",128,21,21], ["0x6050",129,22,22],
                   ["0x6053",130,8,8], ["0x6053",131,9,9], ["0x6053",132,10,10], ["0x6053",133,11,11], ["0x6053",134,12,12], ["0x6053",135,13,13], ["0x6053",136,14,14], ["0x6053",137,15,15], ["0x6053",138,23,23], ["0x6050",139,23,23], ["0x6050",140,8,8], ["0x6050",141,9,9], ["0x6050",142,10,10], ["0x6050",143,11,11], ["0x6050",144,12,12], ["0x6050",145,13,13], ["0x6050",146,14,14],
diff --git a/hmon/getrootjson.cgi b/hmon/getrootjson.cgi
new file mode 100755 (executable)
index 0000000..fe82a07
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use LWP::Simple qw(get);
+use JSON qw( decode_json encode_json ); 
+use Data::Dumper;
+use CGI qw(:standard);
+
+
+my $q = CGI->new;
+
+
+return unless $q->param('histo') =~ /^[a-zA-Z0-9_\-\/]+$/;
+return unless $q->param('src')   =~ /^[a-zA-Z0-9]+$/;
+
+my $baseurl;
+if($q->param('src') eq 'rawmon') {$baseurl = 'http://lxhadeb13:8090/';}
+if($q->param('src') eq 'ebmon')  {$baseurl = 'http://lxhadeb13:8090/';}
+if($q->param('src') eq 'eb')     {$baseurl = 'http://lxhadeb07:8099/';}
+
+
+
+my $rawdata = get ($baseurl.$q->param('histo')."/get.json");
+
+my $data;
+if (defined $rawdata) {
+  $data = decode_json($rawdata);
+  } 
+
+foreach my $s ('xlabels', 'ylabels', 'zlabels') {  
+  if ($data->{$s}) {
+    my @labels = split(',',$data->{$s});
+    $data->{$s} = \@labels;
+    }
+  }
+
+  
+if($data->{'_kind'} eq 'ROOT.TH1D')   {
+  $data->{"underflow"} = $data->{bins}[3];
+  $data->{"overflow"}  = $data->{bins}[-1];
+  @{$data->{"bins"}} = splice(@{$data->{"bins"}},4,-1);
+  }
+
+if($data->{'_kind'} eq 'ROOT.TH2D')   {
+  my $d;
+  foreach my $x (1..$data->{nbins1}) {
+    foreach my $y (1..$data->{nbins2}) {
+      $d->[$x-1][$y-1] = $data->{bins}[6+$x+$y*($data->{nbins1}+2)];
+      }
+    }
+#   foreach my $x (1..$data->{nbins1}) {    
+#     $data->{underflow}{x}[$x] = $data->{bins}[7+$x];
+#     $data->{overflow}{x}[$x]  = $data->{bins}[-($data->{nbins1}+$x-2)];
+#     }
+    
+  $data->{bins} = $d;
+  }
+
+  
+  
+print "Cache-Control: no-cache, must-revalidate, max-age=1\r\n";
+print "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n";
+print "Content-type: application/json\r\n\r\n";
+
+print encode_json($data);
+
diff --git a/hmon/hmon_richthreshold.pl b/hmon/hmon_richthreshold.pl
new file mode 100755 (executable)
index 0000000..67f4791
--- /dev/null
@@ -0,0 +1,93 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use POSIX qw(strftime);
+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 JSON::XS;
+use Data::Dumper;
+use List::Util qw(min max);
+
+
+my $plot0 = {
+name    => "RichThresh",
+file    => "files/RichThresh",
+title   => "RICH Thresholds",
+entries => 193,
+curves  => 193,
+type    => HPlot::TYPE_HEATMAP,
+output  => HPlot::OUT_PNG,
+cblabel  => "mV",
+sizex   => 800,
+sizey   => 700,
+nokey   => 1,
+buffer  => 0,
+xmin    => -1.5,
+xmax    => 192.5,
+ymin    => -1.5,
+ymax    => 192.5,
+cbmax   => "*<1600",
+cbmin   => "1300<*",
+noinit  => 1,
+additional => "set xrange [192.5:-1.5] reverse",
+showvalues => 0,  };
+HPlot::PlotInit($plot0);
+
+my $str  = Hmon::MakeTitle(11, 16, "RICH Threshold",0);
+$str .= qq@<img src="%ADDPNG files/RichThresh.png%" type="image/png"><br>\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("RichThresh",$str);
+
+ my $filename = 'rich_pmt_parameters_xy.geo';
+
+ open(my $fh, '<:encoding(UTF-8)', $filename)
+   or die "Could not open file '$filename' $!";
+   
+ my @pos;
+ while (my $row = <$fh>) {
+   chomp $row;
+   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 @t;
+my $store;
+for my $i (0..15) {
+  my $cmd = "/home/hadaq/trbsoft/daqtools/tools/spi_slave.pl -e=0xfe51 -c=0 -x pwm --channel=".$i;
+  push(@t,qx($cmd));
+     $cmd = "/home/hadaq/trbsoft/daqtools/tools/spi_slave.pl -e=0xfe51 -c=1 -x pwm --channel=".$i;
+  push(@t,qx($cmd));
+  }
+foreach my $s (@t) {
+  my ($b,$chain,$channel,$val) = $s =~ /endpoint: 0x(\w\w\w\w)  chain: (\d)  channel: (\d+)  .+  voltage: (\d+\.\d+) mV/;
+#   $store->{hex($b)}{$chain*16+$channel} = $val;
+  $b = hex($b);
+  my $v = $chain*16+$channel;
+  HPlot::PlotFill('RichThresh',$val,$pos[$b&0xfff][$v+1][0],$pos[$b&0xfff][$v+1][1]);
+  }
+HPlot::PlotDraw('RichThresh');   
+  
+sleep 120;
+}
+  
+  
+  
+  
+#   print Dumper $store;
index 6f87849c8aba2a2f8f96b597107b6598b231bdeb..0bbfc2dc1c919e16ff0de85c1cdcd9900099de40 100755 (executable)
@@ -16,7 +16,7 @@ trb_init_ports() or die trb_strerror();
 HPlot::PlotInit({
     name    => "StartRateXhistbar",
     file    => "files/StartRateXhistbar",
-    entries => 500,
+    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"],
@@ -25,11 +25,11 @@ HPlot::PlotInit({
     sizex   => 950,
     sizey   => 330,
     xmin    => 0,
-    xmax    => 500,
+    xmax    => 200,
     ymin    => "0",
     ymax    => "100<*",
     curves  => 16,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     stacked => 1,
     curvewidth  => .9,
@@ -38,7 +38,7 @@ HPlot::PlotInit({
 HPlot::PlotInit({
     name    => "StartRateYhistbar",
     file    => "files/StartRateYhistbar",
-    entries => 500,
+    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"],
@@ -47,11 +47,11 @@ HPlot::PlotInit({
     sizex   => 950,
     sizey   => 330,
     xmin    => 0,
-    xmax    => 500,
+    xmax    => 200,
     ymin    => "0",
     ymax    => "100<*",
     curves  => 16,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     stacked => 1,
     curvewidth  => .9,
@@ -60,7 +60,7 @@ HPlot::PlotInit({
 HPlot::PlotInit({
     name    => "VetoRatehistbar",
     file    => "files/VetoRatehistbar",
-    entries => 500,
+    entries => 200,
     type    => HPlot::TYPE_BARGRAPH,
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7"],
@@ -69,11 +69,11 @@ HPlot::PlotInit({
     sizex   => 950,
     sizey   => 330,
     xmin    => 0,
-    xmax    => 500,
+    xmax    => 200,
     ymin    => "0",
     ymax    => "100<*",
     curves  => 8,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     stacked => 1,
     curvewidth  => .9,
@@ -83,7 +83,7 @@ HPlot::PlotInit({
 HPlot::PlotInit({
     name    => "StartRateXhist",
     file    => "files/StartRateXhist",
-    entries => 500,
+    entries => 200,
     type    => HPlot::TYPE_HISTORY,
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
@@ -94,14 +94,14 @@ HPlot::PlotInit({
     ymin    => "0",
     ymax    => "100<*",
     curves  => 16,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     });
 
 HPlot::PlotInit({
     name    => "StartRateYhist",
     file    => "files/StartRateYhist",
-    entries => 500,
+    entries => 200,
     type    => HPlot::TYPE_HISTORY,
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
@@ -112,14 +112,14 @@ HPlot::PlotInit({
     ymin    => "0",
     ymax    => "100<*",
     curves  => 16,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     });
 
 HPlot::PlotInit({
     name    => "VetoRatehist",
     file    => "files/VetoRatehist",
-    entries => 500,
+    entries => 200,
     type    => HPlot::TYPE_HISTORY,
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7"],
@@ -130,7 +130,7 @@ HPlot::PlotInit({
     ymin    => "0",
     ymax    => "100<*",
     curves  => 8,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     });    
 
@@ -142,6 +142,7 @@ HPlot::PlotInit({
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
     ylabel  => "Hits",
+    yscale  => 10,
     nokey   => 1,
     sizex   => 340,
     sizey   => 330,
@@ -162,6 +163,7 @@ HPlot::PlotInit({
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
     ylabel  => "Hits",
+    yscale  => 10,
     nokey   => 1,
     sizex   => 340,
     sizey   => 330,
@@ -182,6 +184,7 @@ HPlot::PlotInit({
     output  => HPlot::OUT_PNG,
     titles  => ["0","1","2","3","4","5","6","7"],
     ylabel  => "Hits",
+    yscale  => 10,
     nokey   => 1,
     sizex   => 340,
     sizey   => 330,
@@ -197,7 +200,7 @@ HPlot::PlotInit({
 HPlot::PlotInit({
     name    => "StartPosition",
     file    => "files/StartPosition",
-    entries => 500,
+    entries => 200,
     type    => HPlot::TYPE_HISTORY,
     output  => HPlot::OUT_PNG,
     titles  => ["X position","Y position","Xrms","Yrms"],
@@ -208,10 +211,61 @@ HPlot::PlotInit({
     ymin    => "-0.5",
     ymax    => "15.5",
     curves  => 4,
-    xscale  => 5,
+    xscale  => 10,
     buffer  => 1,
     });     
     
+HPlot::PlotInit({
+    name    => "HALO",
+    file    => "files/HALO",
+    title   => "HALO",
+    entries => 3,
+    curves  => 3,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    cblabel  => "Hitrate",
+    cbscale  => 10,
+    sizex   => 300,
+    sizey   => 240,
+    nokey   => 1,
+    buffer  => 1,
+    xmin    => -0.5,
+    xmax    => 2.5,
+    ymin    => -0.5,
+    ymax    => 2.5,
+#     cbmax   => "100<*<1E5",
+    cbmin   => 0,
+    noinit  => 1,
+#     additional => "set logscale cb;",
+    showvalues => 0,  
+    });
+    
+HPlot::PlotInit({
+    name    => "Veto",
+    file    => "files/Veto",
+    title   => "Veto",
+    entries => 3,
+    curves  => 3,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    cblabel  => "Hitrate",
+    cbscale  => 10,
+    sizex   => 300,
+    sizey   => 240,
+    nokey   => 1,
+    buffer  => 1,
+    xmin    => -0.5,
+    xmax    => 2.5,
+    ymin    => -0.5,
+    ymax    => 2.5,
+#     cbmax   => "100<*<1E5",
+    cbmin   => 0,
+    noinit  => 1,
+#     additional => "set logscale cb;",
+    showvalues => 0,  
+    });
+    
+    
 my $str  = Hmon::MakeTitle(13, 22, "Start / Veto Rate",0);
 $str .= qq@<h3>Start X</h3><img src="%ADDPNG files/StartRateXhist.png%" type="image/png"><br>\n@;
 $str .= qq@<h3>Start Y</h3><img src="%ADDPNG files/StartRateYhist.png%" type="image/png"><br>\n@;
@@ -226,13 +280,19 @@ $str .= qq@<h3>Veto</h3><img src="%ADDPNG files/VetoRatehistbar.png%" type="imag
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("StartRateBars",$str);
     
-$str  = Hmon::MakeTitle(14, 8, "Start-X / Start-Y / Veto Rate",0);
+$str  = Hmon::MakeTitle(14, 8, "Start-X / Start-Y / Veto Rate / HALO",0);
 $str .= qq@<img src="%ADDPNG files/StartXbar.png%" type="image/png">\n@;
 $str .= qq@<img src="%ADDPNG files/StartYbar.png%" type="image/png">\n@;
-$str .= qq@<img src="%ADDPNG files/Vetobar.png%" type="image/png"><br>\n@;
+$str .= qq@<img src="%ADDPNG files/Vetobar.png%" type="image/png">\n@;
 $str .= Hmon::MakeFooter();
 Hmon::WriteFile("StartBars",$str);
 
+$str  = Hmon::MakeTitle(8, 6, "Veto / HALO",0);
+$str .= qq@<img src="%ADDPNG files/Veto.png%" type="image/png">\n@;
+$str .= qq@<img src="%ADDPNG files/HALO.png%" type="image/png">\n@;
+$str .= Hmon::MakeFooter();
+Hmon::WriteFile("VetoHalo",$str);
+
     
 $str  = Hmon::MakeTitle(13, 8, "Start Position",0);
 $str .= qq@<img src="%ADDPNG files/StartPosition.png%" type="image/png">\n@;
@@ -241,8 +301,9 @@ Hmon::WriteFile("StartPosition",$str);
 my $old;
 my $diff;
 my $oldtime;
-my $iter = 0;
-my @chan = qw(0 0 2 4 6 8 10 12 14 15 13 11 9 7 5 3 1);
+my $iter = 1;
+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);
 
 
@@ -266,29 +327,29 @@ while(1) {
     my ($sumx,$sumy,$avgx,$avgy,$rmsx,$rmsy) = (0,0,0,0,0,0);
 
     for my $c (1..16) {
-      HPlot::PlotAdd("StartRateXhist",$diff->{0x5000}[$c],$chan[$c]);
-      HPlot::PlotAdd("StartRateYhist",$diff->{0x5001}[$c],$chan[$c]);
-      HPlot::PlotAdd("StartRateXhistbar",$diff->{0x5000}[$c],$chan[$c]);
-      HPlot::PlotAdd("StartRateYhistbar",$diff->{0x5001}[$c],$chan[$c]);
-      HPlot::PlotFill("StartXbar",$diff->{0x5000}[$c],$chan[$c]);
-      HPlot::PlotFill("StartYbar",$diff->{0x5001}[$c],$chan[$c]);
+      HPlot::PlotAdd("StartRateXhist",$diff->{0x5000}[$c],$chanx[$c]);
+      HPlot::PlotAdd("StartRateYhist",$diff->{0x5001}[$c],$chany[$c]);
+      HPlot::PlotAdd("StartRateXhistbar",$diff->{0x5000}[$c],$chanx[$c]);
+      HPlot::PlotAdd("StartRateYhistbar",$diff->{0x5001}[$c],$chany[$c]);
+      HPlot::PlotFill("StartXbar",$diff->{0x5000}[$c],$chanx[$c],0,$iter-7);
+      HPlot::PlotFill("StartYbar",$diff->{0x5001}[$c],$chany[$c],0,$iter-8);
 
       $sumx += $diff->{0x5000}[$c];
       $sumy += $diff->{0x5001}[$c];
 
-      $avgx += $diff->{0x5000}[$c]*$chan[$c];
-      $avgy += $diff->{0x5001}[$c]*$chan[$c];
+      $avgx += $diff->{0x5000}[$c]*$chanx[$c];
+      $avgy += $diff->{0x5001}[$c]*$chany[$c];
 
       }
     $avgx /= $sumx if($sumx !=0);
     $avgy /= $sumy if($sumy !=0);
 
     for my $c (1..16) {
-      $rmsx += $diff->{0x5000}[$c]*($chan[$c]/$avgx)**2 ;
-      $rmsy += $diff->{0x5001}[$c]*($chan[$c]/$avgy)**2 ;
+      $rmsx += $diff->{0x5000}[$c]*($chanx[$c]/($avgx||1E-10))**2 ;
+      $rmsy += $diff->{0x5001}[$c]*($chany[$c]/($avgy||1E-10))**2 ;
       }
-    $rmsx = sqrt($rmsx/$sumx);
-    $rmsy = sqrt($rmsy/$sumy);
+    $rmsx = sqrt($rmsx/($sumx||1E-10));
+    $rmsy = sqrt($rmsy/($sumy||1E-10));
     
     
     $avgx = "NaN" if $sumx < 50;
@@ -304,24 +365,41 @@ while(1) {
     for my $c (1..8) {
       HPlot::PlotAdd("VetoRatehist",$diff->{0x5002}[$c],$chanveto[$c]);
       HPlot::PlotAdd("VetoRatehistbar",$diff->{0x5002}[$c],$chanveto[$c]);
-      HPlot::PlotFill("Vetobar",$diff->{0x5002}[$c],$chanveto[$c]);
+      HPlot::PlotFill("Vetobar",$diff->{0x5002}[$c],$chanveto[$c],0,$iter-9);
       }
 
-    HPlot::PlotDraw('StartRateXhist') if ($iter == 0);
-    HPlot::PlotDraw('StartRateYhist') if ($iter == 1);
-    HPlot::PlotDraw('VetoRatehist')   if ($iter == 2);
-    HPlot::PlotDraw('StartRateXhistbar') if ($iter == 3);
+    HPlot::PlotFill("HALO",$diff->{0x5002}[9], 1,2,$iter-1);  
+    HPlot::PlotFill("HALO",$diff->{0x5002}[10],1,0,$iter-1);  
+    HPlot::PlotFill("HALO",$diff->{0x5002}[11],0,1,$iter-1);  
+    HPlot::PlotFill("HALO",$diff->{0x5002}[12],2,1,$iter-1);  
+
+    HPlot::PlotFill("Veto",$diff->{0x5002}[8], 0,0,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[3], 1,0,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[7], 2,0,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[4], 0,1,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[2], 2,1,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[5], 0,2,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[1], 1,2,$iter-1);  
+    HPlot::PlotFill("Veto",$diff->{0x5002}[6], 2,2,$iter-1);  
+      
+      
+    HPlot::PlotDraw('StartRateXhist') if ($iter == 1);
+    HPlot::PlotDraw('StartRateYhist') if ($iter == 2);
+    HPlot::PlotDraw('VetoRatehist')   if ($iter == 3);
+    HPlot::PlotDraw('StartRateXhistbar') if ($iter == 4);
     HPlot::PlotDraw('StartRateYhistbar') if ($iter == 4);
     HPlot::PlotDraw('VetoRatehistbar')   if ($iter == 5);
-    HPlot::PlotDraw('StartXbar')   if ($iter == 6);
-    HPlot::PlotDraw('StartYbar')   if ($iter == 7);
-    HPlot::PlotDraw('Vetobar')     if ($iter == 8);
+    HPlot::PlotDraw('StartXbar')   if ($iter == 6); #dont change
+    HPlot::PlotDraw('StartYbar')   if ($iter == 7); #dont change
+    HPlot::PlotDraw('Vetobar')     if ($iter == 8); #dont change
     HPlot::PlotDraw('StartPosition')     if ($iter == 9);
-    $iter = 0                         if ($iter++ == 9)
+    HPlot::PlotDraw('HALO')           if ($iter == 10); #dont change
+    HPlot::PlotDraw('Veto')           if ($iter == 10); #dont change
+    $iter = 1                         if ($iter++ == 10) #dont change
 
     }
 
 
   $old = $o;
-  usleep(200000);
+  usleep(100000);
   }
diff --git a/hmon/hmon_tdcchanerrors.pl b/hmon/hmon_tdcchanerrors.pl
new file mode 100755 (executable)
index 0000000..87fb061
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/perl -w
+
+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 JSON::XS;
+use Data::Dumper;
+use List::Util qw(min max);
+use LWP::Simple qw(get);
+use Try::Tiny;
+
+
+while(1) {
+
+  my $dataerr = get ('http://localhost/mon/getrootjson.cgi?src=rawmon&histo=HADES/Run/HLD/HLD_ErrPerChannel');
+  my $datahit = get ('http://localhost/mon/getrootjson.cgi?src=rawmon&histo=HADES/Run/HLD/HLD_HitsPerChannel');
+
+  unless (defined $dataerr && defined $datahit) {
+    sleep(60);
+    next;
+    }
+    
+  my $data;
+  try{ 
+    $data->{hit} = decode_json($datahit);
+    $data->{err} = decode_json($dataerr);
+    }
+  catch {sleep(60);next;};
+  
+  my $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);  
+  
+  my $boards   = scalar @{$data->{hit}{bins}};
+  my $channels = scalar @{$data->{hit}{bins}[0]};
+
+
+  HPlot::PlotInit({
+    name    => "TDCErrors",
+    file    => "files/TDCErrors",
+    title   => "TDC Hit Error Ratio [1/1000]",
+    entries => $boards,
+    curves  => $channels,
+    type    => HPlot::TYPE_HEATMAP,
+    output  => HPlot::OUT_PNG,
+    cblabel  => "Error ratio (x1000)",
+    sizex   => 3000,
+    sizey   => 500,
+    nokey   => 1,
+    buffer  => 1,
+    xmin    => -0.5,
+    xmax    => $boards-0.5,
+    ymin    => -0.5,
+    ymax    => $channels-0.5,
+    cbmax   => "1<*<40",
+    cbmin   => 0.1,
+    noinit  => 1,
+    palette => 'rgb 7,5,15',
+    additional => "set logscale cb;",
+    showvalues => 0,  });
+
+  my @stats;
+  foreach my $board (0..$boards-1) {
+    foreach my $chan (0..$channels-1) {
+      $data->{div}[$board][$chan] = 'NaN';
+      if ($data->{hit}{bins}[$board][$chan]) {
+        $data->{div}[$board][$chan] = $data->{err}{bins}[$board][$chan] / $data->{hit}{bins}[$board][$chan];
+#         $stats[min(100,ceil($data->{div}[$board][$chan]*10000))]++;
+        }
+      HPlot::PlotFill('TDCErrors',$data->{div}[$board][$chan]*1000,$board,$chan);
+      
+      }
+    }
+#   print Dumper @stats;
+  HPlot::PlotDraw('TDCErrors');  
+  sleep(300);
+}
+
+
+
+
index 4b152847e1033d177911047d20536c531f134684..6521224239eb558944b76a0e0b257ddad0dd0db4 100755 (executable)
@@ -31,16 +31,16 @@ function openwin(url) {
 <li style="width:600px;"><a href="monitor.cgi?1-window-QA" style="color:#d33">Tactical Overview (the central screen)</a></li>
 <li style="width:600px;"><a href="monitor.cgi?3-window-logfile">Logfile (most important messages)</a></li>
 <li style="width:600px;"><a href="monitor.cgi?10-window-chat">Chat Log</a></li>
-<li style="width:600px;"><a href="http://cerberus.x-matter.uni-frankfurt.de:3060/daqtools/index.pl" target="_blank">Web Tools</a></li>
-<li style="width:600px;"><a href="http://cerberus.x-matter.uni-frankfurt.de:3060/eb/?browser=fix" target="_blank">Eventbuilder Monitor</a></li>
+<li style="width:600px;"><a href="../daqtools/index.pl" target="_blank">Web Tools</a></li>
+<li style="width:600px;"><a href="../eb/?browser=fix" target="_blank">Eventbuilder Monitor</a></li>
 </ul></div>
 
 <div class="linkbox" style="width:730px;"><h4>Other Ressources</h4><ul>
 <li style="width:600px;"><a href="files/qa.htm">QA Plots (updated every 5 minutes)</a></li>
 <li style="width:500px;"><a href="files/vertex.htm">Vertex Plots (updated after each file)</a></li>
-<li style="width:500px;"><a href="http://cerberus.x-matter.uni-frankfurt.de:3060/logbook">Beamtime Logbook</a></li>
+<li style="width:500px;"><a href="../logbook">Beamtime Logbook</a></li>
 <li style="width:500px;"><a href="http://lxhadeb06/icinga">Icinga Server Monitoring</a>
-<li style="width:500px;"><a href="http://cerberus.x-matter.uni-frankfurt.de:3060/munin">Munin Server Monitoring</a></li>
+<li style="width:500px;"><a href="../munin">Munin Server Monitoring</a></li>
 <li style="width:500px;"><a href="archive">Archive of Hmon Windows (updated every 10 minutes)</a></li>
 </ul></div>
 
@@ -84,7 +84,8 @@ function openwin(url) {
 <div class="linkbox" style="float:left"><h4>Start</h4><ul>
 <li><a href="monitor.cgi?1-window-StartRate">Rates for all Start / Veto (histo)</a></li>
 <li><a href="monitor.cgi?1-window-StartRateBars">Rates for all Start / Veto (histo,bargraph)</a></li>
-<li><a href="monitor.cgi?1-window-StartBars">Rates for all Start / Veto (bargraph)</a></li>
+<li><a href="monitor.cgi?1-window-StartBars">Rates for all Start / Veto (bargraph) </a></li>
+<li><a href="monitor.cgi?1-window-VetoHalo">Rates for Veto &amp; HALO</a></li>
 <li><a href="monitor.cgi?1-window-StartPosition">Beam Position</a></li>
 <li><a href="monitor.cgi?1-window-SpillStructure">Spill Structure from Start</a></li>
 </ul></div>
@@ -92,6 +93,8 @@ function openwin(url) {
 <div class="linkbox" style="float:left"><h4>ECal</h4><ul>
 <li><a href="monitor.cgi?1-window-ECalRate">Rate Summary for ECal</a></li>
 <li><a href="ecal_drawing.htm#ecalrate_slow">Rate for ECal</a></li>
+<li><a href="monitor.cgi?2-EcalHVVMap">ECAL HV Voltage Map</a></li>
+<li><a href="monitor.cgi?2-EcalHVCMap">ECAL HV Current Map</a></li>
 </ul></div>
 
 
index 0a5eaaeb3b5eb93150c75adc6041ee015cf23453..9e629cb99d4059eadeb57ded77b09025308adaa4 100755 (executable)
@@ -23,8 +23,8 @@ my $mismatchfound_sr = -10;
 my $events = 0;
 my @evtrates = (0,0,0);
 my @ebrates = ();
-my ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = (0,0,0);
-my ($cnterrtype9,$cnterrtypeE) = (50,50);
+my ($oldsumtype1,$oldsumtype9,$oldsumtypeE,$oldsumtypeD) = (0,0,0,0);
+my ($cnterrtype9,$cnterrtypeE,$cnterrtypeD) = (50,50,50);
 my $lasttotalbytes = 21;
 my @ebrecvhist;
 my @byteshist;
@@ -44,6 +44,8 @@ if(!$connect_status) {
 
 my $fqa = QA::OpenQAFile();
 
+my $notactivesourcefile = "/home/hadaq/trbsoft/hadesdaq/evtbuild/tmp/EB_NotActiveSources.txt";
+my $cmdchecksources = "cat $notactivesourcefile 2>/dev/null;";
 
 
 # JAM 2018 here figure out corresponding json calles
@@ -115,8 +117,9 @@ while(1) {
   my $trbneterr = 0;
   my $sumtype1 = 0;
   my $sumtype9 = 0;
-  my $sumtypeE = 0;
-  my ($ratetype1,$ratetype9,$ratetypeE) = (0,0,0);
+  my $sumtypeE = 0;  
+  my $sumtypeD = 0;
+  my ($ratetype1,$ratetype9,$ratetypeE,$ratetypeD) = (0,0,0,0);
   
   # 0x03 => CTS
   my $rh_result = trb_register_read(QA::CTSAddress, 0xa0f0) or $trbneterr = 1; # or sleep 5 and next;
@@ -156,6 +159,7 @@ if (defined $cts_trigtype_histo)
 $sumtype1 += $trigtype_array->[5] || 0;
 $sumtype9 += $trigtype_array->[13] || 0;
 $sumtypeE += $trigtype_array->[18] || 0;
+$sumtypeD += $trigtype_array->[17] || 0;
 
 
 $totalrate = get ($url_erate);
@@ -263,6 +267,8 @@ for my $inpnode (@$inputs_array) {
  
  
 
 # here check mismatch between running bnet nodes and active ones:
 
 if($num_bnetin>$num_act_ins)
@@ -277,7 +283,22 @@ if($num_bnetbuild>$num_act_build)
     $qamsg   .= "Only $num_act_build nodes of $num_bnetbuild BNET builders are building events! ";
 }
 
+# here check if some hub sources are not active:
+my @notactivehubs = `$cmdchecksources`;    
+chomp @notactivehubs;
+if(scalar @notactivehubs>0)
+{
+  $qamsg   .= "EB setup has non active datasources: ";
+  $qastate = QA::WARN_2  unless  $qastate == QA::ERROR;
+  
+}
+foreach my $line (@notactivehubs)
+{
+     $qamsg   .=  " $line ";
+}
 
+#########################
 
     
   if($trbneterr) {
@@ -285,8 +306,8 @@ if($num_bnetbuild>$num_act_build)
     $qastate = QA::ERROR;
     }
   if ($qamsg eq "") {$qamsg = "No error found";}
-  if ($qastate == QA::OK) {
-    $qamsg .= sprintf(". Total rate: %i, 4-spill average: %i, total per EB: %i", 
+  if ($qastate == QA::OK || $qastate == QA::WARN_2) {
+    $qamsg .= sprintf(".  <br> Total rate: %i, 4-spill average: %i, total per EB: %i", 
                         $totalrate,$ebavgrate,$totalrate/($num_act_build || $totalrate || 1));
     }
 
@@ -334,10 +355,12 @@ else
   $ratetype1 = $sumtype1 - $oldsumtype1 unless ($oldsumtype1 > $sumtype1);
   $ratetype9 = $sumtype9 - $oldsumtype9 unless ($oldsumtype9 > $sumtype9);
   $ratetypeE = $sumtypeE - $oldsumtypeE unless ($oldsumtypeE > $sumtypeE);
+  $ratetypeD = $sumtypeD - $oldsumtypeD unless ($oldsumtypeD > $sumtypeD);
 
   $cnterrtype9 += -0.8+$ratetype9 ;#if $evtrate > $act*32;
   $cnterrtypeE += -0.8+$ratetypeE ;#if $evtrate > $act*32;
-  if($oldsumtype1 > $sumtype1) {
+#  $cnterrtypeD += -0.8+$ratetypeD;
+  if(($oldsumtype1 > $sumtype1) || ($ratetypeD == 0)) {
     $cnterrtype9 = 50;
     $cnterrtypeE = 50;
     }
@@ -353,10 +376,14 @@ my $evtavgshort = sprintf("%i MB - %i kB",$ebavgbytes/1024,$ebavgbytes/($ebavgra
                                   $ebavgbytes/($ebavgrate || $ebavgbytes || 1),
                                   $totalrate/($num_bnetbuild || $totalrate || 1));                               
                                   
-     $evtavglong .= sprintf(" <br> MDC Calib Evt: %i (%i/s) - Status Evt: %i (%i/s)",
-                                $sumtype9,$ratetype9,$sumtypeE,$ratetypeE);
+     $evtavglong .= sprintf(" <br> MDC Calib Evt: %i (%i/s) - Status Evt: %i (%i/s) - Trb3Cal Evt: %i (%i/s)",
+                                $sumtype9,$ratetype9,$sumtypeE,$ratetypeE,$sumtypeD,$ratetypeD);
 
-  if($cnterrtypeE < 30 || $cnterrtype9 < 30) {
+   if($ratetypeD > 0) {                             
+      $evtavglong .= " <br> TRB3 Calibration mode is running! (total $sumtypeD events)";                                 
+    }
+    
+  if(($cnterrtypeE < 30 || $cnterrtype9 < 30) && ($ratetypeD == 0)) {
     $qastate = QA::WARN_2;
     $evtavglong .= " <br> Number of special triggers is not correct (debug $cnterrtype9 $cnterrtypeE)";
     }
@@ -377,7 +404,7 @@ my $evtavgshort = sprintf("%i MB - %i kB",$ebavgbytes/1024,$ebavgbytes/($ebavgra
     QA::WriteQALog($fqa,"eb","bytes",30,QA::NA,"Data Rate","N/A","N/A") unless $opt_debug>0;
     }
 
-  ($oldsumtype1,$oldsumtype9,$oldsumtypeE) = ($sumtype1,$sumtype9,$sumtypeE);
+  ($oldsumtype1,$oldsumtype9,$oldsumtypeE,$oldsumtypeD) = ($sumtype1,$sumtype9,$sumtypeE,$sumtypeD);
   $lasttotalbytes = $totalbytes;
   usleep(990000);
  }
diff --git a/hmon/permanent/hmon_ecalhv.pl b/hmon/permanent/hmon_ecalhv.pl
new file mode 100755 (executable)
index 0000000..46fa378
--- /dev/null
@@ -0,0 +1,417 @@
+#!/usr/bin/perl -w
+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++) {
+  if ($i==2 or $i==3 or $i==5 or $i==6){
+  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);}
+    if($j>=10 and $j<100) {$s = sprintf("HAD:ECAL:HV:S%i:M0%i:imon",$i,$j);}
+    if($j>=100) {$s = sprintf("HAD:ECAL:HV:S%i:M%i:imon",$i,$j);}
+    Perl2Epics::Connect("I$cnt",$s);
+    if($j<10) {$s = sprintf("HAD:ECAL:HV:S%i:M00%i:vmon",$i,$j);}
+    if($j>=10 and $j<100) {$s = sprintf("HAD:ECAL:HV:S%i:M0%i:vmon",$i,$j);}
+    if($j>=100) {$s = sprintf("HAD:ECAL:HV:S%i:M%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);
+
+
+
+
+while(1) {
+  my $min_v = -1E5;
+  my $max_v =  1E5;
+  my $min_i = -1E5;
+  my $max_i =  1E5;
+  my $ChnlsOn = 0;
+  my $data = Perl2Epics::GetAll();
+
+  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 (abs($data->{"U$cnt"}->{val})>1000 and $data->{"I$cnt"}->{val}>50) {$ChnlsOn++;}
+            }
+        }
+    }
+  
+  
+  $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::OK;
+   my $value = sprintf("%i/652",$ChnlsOn);
+   my $longtext = sprintf("HV channels On: %i/652",$ChnlsOn);
+
+ if ($ChnlsOn < 652 and $ChnlsOn >= 642){
+    $qastate = QA::WARN_2;}
+ if ($ChnlsOn < 642){
+    $qastate = QA::ERROR_2;}
+ if ($ChnlsOn == 0){
+    $qastate = QA::NOTE;}
+    
+    
+ $str = "";
+   if($timer%8 == 0) {
+     if ($ChnlsOn>0 and $ChnlsOn<652) {
+     for(my $i = 1; $i <=6; $i++) {
+        if ($i==2 or $i==3 or $i==5 or $i==6){
+            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);}
+                if($data->{"I$cnt"}->{val}<10 and $data->{"U$cnt"}->{val}>=1000){ $str .= sprintf("Low current on module %i, sector %i.<br>",$j,$i);}
+                if($data->{"U$cnt"}->{val}<10 and $data->{"I$cnt"}->{val}<10){ $str .= sprintf("Module %i, sector %i is switched off. Check!<br>",$j,$i);}
+                
+            }
+        }
+    }
+#        $value    = sprintf("%i/652",$ChnlsOn);
+       $longtext = sprintf("HV channels On: %i/652<br>Check the current and voltage monitoring plots!<br>%s",$ChnlsOn,$str);
+     } 
+     elsif($ChnlsOn==0) {
+       $value    = sprintf("HV is 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){
+        for (my $j = 0; $j<=167; $j++) {
+        my $cnt = ($i*168)+$j;
+        HPlot::PlotAdd("EcalCurr$i",$data->{"I$cnt"}->{val}||-1,);
+        HPlot::PlotAdd("EcalVolt$i",$data->{"U$cnt"}->{val}||-1,);
+      }
+
+        for(my $j=254;$j>=0;$j--){
+        my $cnt =-1;
+        if($mod_tab[$j]!=0){
+            $cnt=($i*168)+$mod_tab[$j]-1;
+            HPlot::PlotAdd("EcalVMap$i",$data->{"U$cnt"}->{val}||-1,$y_tab[$j],$x_tab[$mod_tab[$j]-1]);
+            HPlot::PlotAdd("EcalCMap$i",$data->{"I$cnt"}->{val}||-1,$y_tab[$j],$x_tab[$mod_tab[$j]-1]);
+            }
+        if($mod_tab[$j]==0){
+            HPlot::PlotAdd("EcalVMap$i",$data->{"U$cnt"}->{val}||'NaN',$y_tab[$j],$x_tab[$mod_tab[$j]-1]);
+            HPlot::PlotAdd("EcalCMap$i",$data->{"I$cnt"}->{val}||'NaN',$y_tab[$j],$x_tab[$mod_tab[$j]-1]);
+            }
+        }
+        
+        
+        }
+    }
+    
+    
+    #print Dumper $data;
+    if($timer%8 == 0) {
+        for (my $i = 0; $i <= 5;$i++){
+            HPlot::PlotDraw("EcalCurr$i");
+            HPlot::PlotDraw("EcalVolt$i");
+            HPlot::PlotDraw("EcalVMap$i");
+            HPlot::PlotDraw("EcalCMap$i");
+            }
+    }
+
+  usleep(250000);
+  }
diff --git a/hmon/permanent/hmon_interrupt.pl b/hmon/permanent/hmon_interrupt.pl
new file mode 100755 (executable)
index 0000000..efdb88e
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Time::HiRes qw( gettimeofday usleep time );
+use FileHandle;
+use Data::Dumper;
+use POSIX qw/floor ceil/;
+use Clone qw(clone);
+use Hmon;
+use QA;
+use List::Util qw(sum);
+
+my $store = {};
+my $laststore = {};
+my $str;
+
+
+
+my $fqa = QA::OpenQAFile();
+
+
+my @srv = qw( lxhadeb08  lxhadeb09 lxhadeb10 lxhadeb11 lxhadeb12 );
+
+
+
+
+
+while(1) {
+  $store = {};
+  my $qastate = QA::OK;
+  my $qastr = '';
+  foreach my $s (@srv) {
+    my @out = Hmon::qxtimeout("ssh $s \"cat /proc/interrupts | grep TxRx-0 | head -n 1 \" </dev/null",10);
+
+    if ($out[0] =~ /TxRx-0/) {
+      my @arr = split(/\s+/,$out[0]);
+      $store->{$s} = \@arr;
+      next unless $laststore->{$s};
+      my @diff = map {$store->{$s}[$_] - $laststore->{$s}[$_];} (2..65);
+      my $sum = sum(@diff);
+      if ($diff[0] < 0.9*$sum) {
+        $qastate = QA::WARN_2;
+        $qastr .= "$s ";
+        }
+      }
+    
+    }
+
+
+  QA::WriteQALog($fqa,"misc","irq",40,$qastate,"IRQ","OK","") if $qastr eq '';
+  QA::WriteQALog($fqa,"misc","irq",40,$qastate,"IRQ","Error","IRQ affinity wrong on $qastr") unless $qastr eq '';
+  $laststore = $store;
+  sleep 10;    
+  }
+
index bba2115a551341c23dc47aa7b36e6dc2111c24a9..33011ec99e5032a921e240be41aaff44b0601e07 100755 (executable)
@@ -170,15 +170,15 @@ while(1) {
     }
     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 < 66) {
+    } elsif ($ChnlsOn < 74) {
         $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 > 66) {
+    } elsif ($ChnlsOn > 74) {
         $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 .= "/66)</p></div>";
+        $str .= "/74)</p></div>";
     
     my $ModulesOk = 0;
     
@@ -234,14 +234,14 @@ while(1) {
       }
     }
     
-$qastate = QA::WARN_2 if ($ChnlsOn < 66);
+$qastate = QA::WARN_2 if ($ChnlsOn < 74);
 $qastate = QA::ERROR_2 if ($ChnlsOn == 0);
 $qastate = QA::NOTE if ($QA::RichHvOff == 1);
 
   if( $timer % (4*$OVERCURRENT_period) == 0) {
     if ($data->{"HVPowerOn"}->{val} != 0) {
       $value    = sprintf("%.2f / %.2f kV",$min_v/1000,$max_v/1000);
-      $longtext = sprintf("Min: %.2f kV | Max: %.2f kV <br> Min: %.4f mA | Max: %.4f mA <br> HV channel On: %i/66",$min_v/1000,$max_v/1000,$min_i,$max_i,$ChnlsOn);
+      $longtext = sprintf("Min: %.2f kV | Max: %.2f kV <br> Min: %.4f mA | Max: %.4f mA <br> HV channel On: %i/74",$min_v/1000,$max_v/1000,$min_i,$max_i,$ChnlsOn);
     } else {
       $value    = sprintf("HV-Crate is OFF");
       $longtext = sprintf("HV-Crate is OFF");