]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
pack and unpack to save the signedness
authormaps <maps@jspc10.x-matter.uni-frankfurt.de>
Fri, 31 Oct 2014 17:47:16 +0000 (18:47 +0100)
committermaps <maps@jspc10.x-matter.uni-frankfurt.de>
Fri, 31 Oct 2014 17:47:16 +0000 (18:47 +0100)
user_interface/plot.png
user_interface/plotalldat.sh
user_interface/pmt_ro.pl
user_interface/regio.pm

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8f57cbafbb591653ec4885d3642e9a4bf3525ddf 100644 (file)
Binary files a/user_interface/plot.png and b/user_interface/plot.png differ
index dceb24771d13e9084f39bc1bb20c5bea0e653a30..d490adfa5fc005e70194fa3d58ae4305b4a68d83 100755 (executable)
@@ -6,9 +6,24 @@ datfile=$i
 datfilebase=$(echo $datfile| sed 's/.dat//')
 
 cat <<EOF | gnuplot
-#set terminal png
-set terminal postscript enhanced solid color
-set output "$datfilebase.ps"
+set terminal png
+#set terminal postscript enhanced solid color
+
+set style line 1 lc rgb '#8b1a0e' pt 1 ps 1 lt 1 lw 2 # --- red
+set style line 2 lc rgb '#5e9c36' pt 6 ps 1 lt 1 lw 2 # --- green
+
+set style line 11 lc rgb '#808080' lt 1
+set border 3 back ls 11
+set tics nomirror
+
+set style line 12 lc rgb '#808080' lt 0 lw 1
+set grid back ls 12
+
+set xlabel "bins"
+set ylabel "counts"
+
+
+set output "$datfilebase.png"
 plot "$datfile" using 1:2
 EOF
 
index 5233a116827e2ba145c80aec68f0931ea566d1e6..2e88722f5c8f2af81afb8a3fe9112119eb0f61f0 100755 (executable)
@@ -8,7 +8,20 @@ pmt_ro - configure and read out the photomultiplier hardware
 
 =head1 SYNOPSIS
 
-./pmt_ro action=signal_range channel=(signal|veto)
+automatic scan of signal range, can configure "integration time" of each step.
+
+/pmt_ro action=signal_range channel=(signal|veto) [delay=<delay in sec>]
+
+count on a specific channel for a specific time (default 1 sec)
+./pmt_ro.pl action=count channel=signal [delay=2.5]
+
+read from a register, either by name or by address
+./pmt_ro.pl action=read_register regName=signal_thresh
+
+./pmt_ro.pl action=read_register addr=21
+
+
+
 
 =head1 DESCRIPTION
 
@@ -105,7 +118,8 @@ sub main {
     read_register => 1,
     write_register => 1,
     find_baseline => 1,
-    signal_range => 1
+    signal_range => 1,
+    count => 1
   };
   
   # if method exists, execute it, if not complain and show help message
@@ -116,7 +130,7 @@ sub main {
     my $return = $self->$action(%$args);
     # does it return anything?
     if(defined($return)){ # we get a return value
-      if(ref($return) eq "SCALAR"){ # just print it if it is a scalar
+      if(ref(\$return) eq "SCALAR"){ # just print it if it is a scalar
         print "$return\n";
       } else { # use Data::Dumper to display a hash
         print "method returns a hash:\n";
@@ -129,6 +143,42 @@ sub main {
   }
 }
 
+sub count { # count for a given time on a given channel
+  # return number of counts
+  my $self = shift;
+  my %options = @_;
+  
+  my $channel = $options{channel}; # can be "signal" or "veto" or "net"
+  my $delay   = $options{delay} || 1;
+  
+  my $counter_addr;
+  my $threshold_addr;
+  
+  if( $channel eq "signal" ){
+    $counter_addr = $self->{regaddr_lookup}->{signal_counter};
+    $threshold_addr = $self->{regaddr_lookup}->{signal_thresh};
+  } elsif ( $channel eq "veto" ){
+    $counter_addr = $self->{regaddr_lookup}->{veto_counter};
+    $threshold_addr = $self->{regaddr_lookup}->{veto_thresh};
+  } elsif ( $channel eq "net" ){
+    $counter_addr = $self->{regaddr_lookup}->{net_counter};
+    $threshold_addr = $self->{regaddr_lookup}->{net_thresh};
+  } else {
+    die "$channel is not a valid channel!\n possible channels are \"signal\",\"veto\" and \"net\"\n!";
+  }
+  
+  $self->{regio}->write($self->{regaddr_lookup}->{acquisition},0); # stop acquisition
+  $self->{regio}->read($self->{regaddr_lookup}->{reset_counter}); # reset counter
+  $self->{regio}->write($self->{regaddr_lookup}->{acquisition},1); # start acquisition
+  Time::HiRes::sleep($delay); # let the counter count
+  $self->{regio}->write($self->{regaddr_lookup}->{acquisition},0); # stop acquisition
+  my $counts = $self->{regio}->read($counter_addr); # read counter value
+  $self->{regio}->write($self->{regaddr_lookup}->{acquisition},1); # start acquisition
+  
+  die "Padiwa does not answer!\n" unless defined($counts);
+  return $counts;
+}
+
 sub signal_range { # determine the range and the position the signal/noise in terms of
   # DAC setting
   my $self = shift;
index bebf65e4c5912b011dc50d92563db9cdca2dfeba..abb23f59ff0b658fc4bda7cc440efaf6025bd9f3 100644 (file)
@@ -128,11 +128,12 @@ sub communicate {
   }
   
   if($ack){
-    my $byte3 = ord(substr($rstring,0,1));
-    my $byte2 = ord(substr($rstring,1,1));
-    my $byte1 = ord(substr($rstring,2,1));
-    my $byte0 = ord(substr($rstring,3,1));
-    my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0);
+#     my $byte3 = ord(substr($rstring,0,1));
+#     my $byte2 = ord(substr($rstring,1,1));
+#     my $byte1 = ord(substr($rstring,2,1));
+#     my $byte0 = ord(substr($rstring,3,1));
+#     my $val = (($byte3<<24)|($byte2<<16)|($byte1<<8)|$byte0);
+    my $val = unpack('l',reverse pack('a4',substr($rstring,0,4)));
     return $val;
   } else {
     print "no answer\n" if $self->{verbose};