From a9630812369f6df57f1361d7d523d9526f7d7f2c Mon Sep 17 00:00:00 2001 From: Hadaq Hades Date: Sat, 22 Jan 2022 18:39:34 +0100 Subject: [PATCH] changes for the beamtime 2022, all backwards compatible, mt --- thresholds/thresholds_automatic.pl | 43 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/thresholds/thresholds_automatic.pl b/thresholds/thresholds_automatic.pl index d1d9725..fb02e55 100755 --- a/thresholds/thresholds_automatic.pl +++ b/thresholds/thresholds_automatic.pl @@ -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 -- 2.43.0