]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Update off scripts for CBM RICH
authorCbm Rich <richdaq@wuppertal>
Mon, 17 Nov 2014 09:18:35 +0000 (10:18 +0100)
committerCbm Rich <richdaq@wuppertal>
Mon, 17 Nov 2014 09:18:35 +0000 (10:18 +0100)
dmon/scripts/dmon_billboard.pl
thresholds/thresholds_automatic_jan.pl
thresholds/write_thresholds.pl
users/cern_cbmrich/prepare_padiwas_invert_leds.pl
users/cern_cbmrich/startup.sh
users/cern_cbmrich/thresh/thresholds_padiwa_amps.thr
users/cern_cbmrich/thresholds_compare.pl

index 68345fad9339c9b624fd96ebf1fc093df4a69ee4..a1e1ba585904be7b6e210d2b687f35b99a67b51a 100755 (executable)
@@ -15,7 +15,7 @@ my %config = Dmon::StartUp();
 my $t0;
 
 for(my $i = 0; $i< 16 ; $i++) {
-  Perl2Epics::Connect("PC".$i, sprintf('CBM:PWRSWITCH:GetCurrent%02x',$i));
+  Perl2Epics::Connect("PC".$i, sprintf('CBM:PWRSWITCH:GetCurrent%02X',$i));
 
   Perl2Epics::Connect("HV_U".$i, sprintf('OUTPUT_TERMINAL_VOLTAGE_U%d',$i));
   Perl2Epics::Connect("HV_I".$i, sprintf('MEASUREMENT_CURRENT_U%d',$i));
@@ -42,12 +42,14 @@ while(1) {
     my $milAmp = $epicsData->{"PC".$i}->{"val"} * 1000;
     $reg = 0 unless $i & 1;
     $reg |= ($milAmp & 0xffff) << (16 * ($i&1));
-    push @billboardValues, $reg if $i & 1;
+    
+    push(@billboardValues, $reg) if ($i & 1);
   }
+  
 
   # threshold timestamp
-  my $threshTime = do($config{UserDirectory} . '/thresh/billboard_info') || 0;
-  push @billboardValues, $threshTime & 0xffffffff;
+  my $threshTime = do($config{UserDirectory} . '/thresh/billboard_info');
+  push @billboardValues, ($threshTime & 0xffffffff);
   
   # hv values
   for(my $i=0; $i < 16; $i++) {
index 2987bc473852ffb9ad0d622ee8ce01d26a9c1fcd..4c87e64f2745fa48d668abdb1b4aa5c040b53cc0 100755 (executable)
@@ -4,9 +4,7 @@ use strict;
 use warnings;
 use Data::Dumper;
 
-use lib "/home/hadaq/trbsoft/daqtools/dmon/code";
 use Dmon;
-
 use Getopt::Long;
 use Time::HiRes qw(time usleep);
 use Log::Log4perl qw(get_logger);
@@ -14,19 +12,6 @@ use List::Util qw(min max);
 use POSIX qw(strftime);
 use HADES::TrbNet;
 
-# use IPC::ShareLite qw( :lock );
-
-use constant false => 0;
-use constant true => 1;
-
-# my $share = IPC::ShareLite->new(
-#     -key     => 3214,
-#     -create  => 'yes',
-#     -destroy => 'yes'
-#     ) or die $!;
-# 
-# $share->store("dummy text");
-#print "store res: $r\n";
 
 my $hitregister = 0xc001;
 
@@ -35,7 +20,7 @@ my $start_value =  0x7000;
 
 my $sleep_time = 1.0;
 my $accepted_dark_rate = 150;
-my $number_of_iterations = 50; # at least 15 are recommended
+my $number_of_iterations = 50;
 
 my $endpoint = 0x0303;
 my $mode = "padiwa";
@@ -44,7 +29,7 @@ my $offset = 0;
 my $polarity = 1;
 my @channels  = ();
 my $channel32 = undef;
-my $opt_finetune = false;
+my $opt_finetune = 0;
 
 our $chain = 0;
 
@@ -117,20 +102,19 @@ my @current_thresh = ($start_value) x 16;
 my @best_thresh = (0) x 16;
 my @hit_diff = (0) x 16;
 my @crossed_thresh = (0) x 16;
-my @interval_step = ($interval_step) x 16;
+
 my @make_it_quiet;
 my $rh_res;
 my $old_rh_res;
 
-if ($opt_finetune == true) {
-    my $ra_thresh = read_thresholds("padiwa", $chain);
-    @current_thresh = @$ra_thresh;
-    print Dumper \@current_thresh;
-
-    $interval_step = 4;
-
-}
+if ($opt_finetune) {
+  my $ra_thresh = read_thresholds("padiwa", $chain);
+  @current_thresh = @$ra_thresh;
+#   print Dumper \@current_thresh;
+  $interval_step = 2;
+  }
 
+my @interval_step = ($interval_step) x 16;
 
 #     foreach my $i (0..15) {
 
@@ -170,7 +154,7 @@ while ($number_of_steps < $number_of_iterations) {
       $hit_diff += 2**24 if $hit_diff < 0;
       $hit_diff[$i] = $hit_diff;
 
-      if($number_of_steps  > $number_of_iterations - 10) {
+      if($number_of_steps  > $number_of_iterations - 10 || $opt_finetune) {
         # select best  threshold, closest from bottom
         if(   $hit_diff[$i] <= $accepted_dark_rate
           && $best_thresh[$i] <= $current_thresh[$i]
@@ -191,11 +175,11 @@ while ($number_of_steps < $number_of_iterations) {
         } 
       elsif ($hit_diff > $accepted_dark_rate 
              && $hit_diff < 10000 ) {
-        $current_thresh[$i] -= max($interval_step * $polarity , 0x10);
+        $current_thresh[$i] -= max($interval_step * $polarity , $opt_finetune?0x2:0x10);
         $interval_step = max(int($interval_step/2),4);
         }
       elsif ($hit_diff > $accepted_dark_rate ) {
-        $current_thresh[$i] -= max($interval_step * 2 * $polarity , 0x50);
+        $current_thresh[$i] -= max($interval_step * 2 * $polarity , $opt_finetune?0x4:0x50);
         $interval_step = max(int($interval_step/2),0x10);
         if ($hit_diff > 20000) {
           $make_it_quiet[$i] = 1;
@@ -240,7 +224,7 @@ foreach my $i (reverse (0..3)) {
 
 my $str;
 
-$logger_data->info(time);
+$logger_data->info("\t".time);
 foreach my $i (0..15) {
   $logger_data->info(sprintf "endpoint: 0x%04x, chain: %02d, channel: %2d threshold: 0x%04x, uid: %s", $endpoint, $chain, $i, $best_thresh[$i], $uid );
 }
@@ -271,8 +255,8 @@ sub read_thresholds {
     }
 
     $command = $fixed_bits | ($current_channel << 16) ;
-    my $rh_res = Dmon::PadiwaSendCmd($endpoint, $chain, $command);
-    push (@thresh , $rh_res->{$endpoint});
+    my $rh_res = Dmon::PadiwaSendCmd($command, $endpoint, $chain, );
+    push (@thresh , $rh_res->{$endpoint} & 0xFFFF);
   }
 
 
index 486d894ea3c113a5f7bf0f680aad5bcf2e96e7cd..cc18e8da915a4b22b534bfde12e614956cc75b6a 100755 (executable)
@@ -49,11 +49,12 @@ my @f = <$fh>;
 
 #Put Information to logfile and timestamp to billboard information
 chomp $f[0];
-system("echo ".time.'     '.strftime("%Y-%m-%d %H:%M:%S",localtime()).'     '." $f[0]>>threshold_log.txt");
+system("echo \"".strftime("%Y-%m-%d %H:%M:%S",localtime()).'\t'.time.'\t'.
+              $offset.'\t'.$f[0]."\">>threshold_log.txt");
 my ($t) = $f[0] =~ /(\d{10})/;
-system("echo $t>billboard_info");
+system("echo $t>thresh/billboard_info");
+
 
-exit;
 my $count=0;
 foreach my $cl (@f) {
     (my $ep, my $chain, my $channel, my $thresh, my $uid) = 
index 0ab3d369e55afe704a9c3c7f2a82802651cf8270..4a373cb8a77466518c4d2226e3eed46fb55636ad 100755 (executable)
@@ -41,6 +41,17 @@ foreach (@padiwas) {
     $pm->finish; # Terminates the child process 
 };
 
+# print "padiwas: set temperature compensation: ";
+# 
+# foreach (@padiwas) { 
+#     my $pid = $pm->start and next;
+#     print "$_ ";
+#     my $c="/home/hadaq/trbsoft/daqtools/padiwa.pl $_ 0 comp 0x02c0 >/dev/null";
+#     qx($c); die "could not execute command $c" if $?;
+#     $pm->finish; # Terminates the child process 
+# };
+
+
 $pm->wait_all_children;
 
 print "\n";
index 832cdc96b0e273f9d0a5b0cac3f93daef16cacc9..0a14b2101b06786d7f4df5ca332398a7d23ecced 100755 (executable)
@@ -191,8 +191,12 @@ echo "Disable noisy pixel in Padiwa"
 #trbcmd clearbit 0x8103 0xc1 0xf6
 #trbcmd clearbit 0x8103 0xc3 0xf6
 
+# trbcmd setbit 0x7005 0xa00c 0x80000000
+
 echo "Wait a sec (http://goo.gl/bdWW1g)"
 sleep 1
 trbcmd w 0x7005 0xa101 0xffff6004  # trg_channel_mask: edge=1111 1111 1111 1111, mask=0110 0000 0000 0100
 
 echo "Trigger activated. I'm done"
+
+
index 7581a1617d4a8631273005ed28f511ca2472a37b..a58402c48dbaea43676ae54719f10aba3c5da025 100644 (file)
@@ -1,3 +1,4 @@
+2000/00/00 00:00:00   0000000000.00000  Padiwa Amps Thresholds
 2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 00 threshold: 0x0697, uid: 0
 2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 01 threshold: 0xDA00, uid: 0
 2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 02 threshold: 0x0744, uid: 0
index 5efffc4745574af9ead3b183e4e6ee563533d98b..ebc2c1ba952e9b661d9edee04477038281405f76 100755 (executable)
@@ -43,11 +43,11 @@ sub readSettings {
   close $fh;
 
   my %thresholds = ();
-
   my $count=0;
   foreach my $cl (@f) {
     (my $ep, my $chain, my $channel, my $thresh, my $uid) = 
       $cl =~ /endpoint:\s+(\w+), chain:\s+(\d+), channel:\s+(\d+) threshold:\s+(\w+), uid: (\w+)/;
+    next unless defined $ep;
     $thresholds{hex($ep) .":". int($channel)} = hex $thresh;
   }