]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
changes for the beamtime 2022, all backwards compatible, mt
authorHadaq Hades <hadaq@lxhadesdaq>
Sat, 22 Jan 2022 17:39:34 +0000 (18:39 +0100)
committerHadaq Hades <hadaq@lxhadesdaq>
Sat, 22 Jan 2022 17:39:34 +0000 (18:39 +0100)
thresholds/thresholds_automatic.pl

index d1d9725ebb36366f0268e302fd8d1908ee6c6b12..fb02e55f9ec5be63ee994bbb76a267cd0eece8ec 100755 (executable)
@@ -49,6 +49,7 @@ my @channels  = ();
 my $channel_to_set = undef;
 my $channel_by_channel = false;
 my $channel32 = undef;
+my $channel16 = undef;
 my $opt_finetune = false;
 
 our $chain = 0;
@@ -64,8 +65,10 @@ my $result = GetOptions (
     "d|direction=i" => \$default_direction,
     "o|offset=s" => \$offset,
     "32|32channel" => \$channel32,
+    "16|16channel" => \$channel16,
     "s|skip=i" => \$opt_skip,
     "f|finetune" => \$opt_finetune,
+    "a|accepted_dark_rate" => \$accepted_dark_rate,
     );
 
 if($help) {
@@ -104,7 +107,7 @@ $endpoint = hex($endpoint);
 
 my $hitchannel_multiplicator = 1;
 
-if($channel32) {
+if($channel32 || $channel16) {
     $hitregister += 32*$chain;
     $hitchannel_multiplicator = 2;
 }
@@ -112,6 +115,8 @@ else {
     $hitregister += 16*$chain;
 }
 
+
+
 Log::Log4perl->init("logger_threshold.conf");
 
 my $logger = get_logger("padiwa_threshold.log");
@@ -147,7 +152,9 @@ my $hit_diff = 0;
 my $number_of_steps = 0;
 
 my $rh_res;
+my $rh_res2;
 my $old_rh_res;
+my $old_rh_res2;
 
 my $outermost_channel_loop_counter = 0;
 
@@ -178,6 +185,11 @@ if($channel_by_channel) {
 }
 
 $number_of_steps = 0;
+my $number_of_channels = 32;
+
+if ($channel16) {
+  $number_of_channels = 16;
+}
 
 while ($number_of_steps < $number_of_iterations ||
        grep({$_ == 0} @best_thresh) > 0
@@ -192,15 +204,35 @@ while ($number_of_steps < $number_of_iterations ||
     # wait settling time, experimentally determined to 0.04 seconds
     select(undef, undef, undef, 0.05);
 
-    $old_rh_res = trb_register_read_mem($endpoint, $hitregister, 0, 32);
+    $old_rh_res  = trb_register_read_mem($endpoint,   $hitregister, 0, $number_of_channels);
+
+    if ($channel16) {
+      $old_rh_res2 = trb_register_read_mem($endpoint+1, $hitregister, 0, $number_of_channels);
+      foreach my $ep (keys %$old_rh_res2) {
+        foreach my $cur_value (@{$old_rh_res2->{$ep}}) {
+          push (@{$old_rh_res->{$ep-1}}, $cur_value);
+        }
+      }
+    }
 
     select(undef, undef, undef, $sleep_time);
 
-    $rh_res = trb_register_read_mem($endpoint, $hitregister, 0, 32);
+    $rh_res = trb_register_read_mem($endpoint, $hitregister, 0, $number_of_channels);
+
+    if ($channel16) {
+      $rh_res2 = trb_register_read_mem($endpoint+1, $hitregister, 0, $number_of_channels);
+      foreach my $ep (keys %$rh_res2) {
+        foreach my $cur_value (@{$rh_res2->{$ep}}) {
+          push (@{$rh_res->{$ep-1}}, $cur_value);
+        }
+      }
+    }
+
     #print Dumper $rh_res;
     #print Dumper $old_rh_res;
 
     my @iterate_loop = ($mode eq "dirich2") ? (0 .. 31) : (0 .. 15);
+
     if($channel_by_channel) {
        @iterate_loop = ($current_channel_outer_loop);
     }
@@ -514,7 +546,12 @@ direction: what do you want to detect:
             negative pulses: direction = 1 (default)
             positive pulses: direction = -1
 32channel: when set the tool assums a TDC with 32 channels, leading and trailing channels use two channels
+16channel: a special mode, where only a TDC with one edge per channel used and additionally the upper 8 
+           channels of each Padiwa go to the TDC with the endpoint n+1. One mode for the HADES-start in
+           2022
+
 finetune: tries to optimize the thresholds beginning with the current ones
+accepted_dark_date: sets the value, which dark rate is accepted to indicate that the threshold is high enough (default=10)
 
 EOF