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
=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
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
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";
}
}
+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;
}
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};