From: Michael Traxler Date: Mon, 12 Aug 2024 03:42:14 +0000 (+0200) Subject: added automatic threshold for farich, mt X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=d8c89f18aaeadb4f5d0286beb688dbd7599883f2;p=daqtools.git added automatic threshold for farich, mt --- diff --git a/base/serials_dirich5d.db b/base/serials_dirich5d.db index 62d85ba..367e402 100644 --- a/base/serials_dirich5d.db +++ b/base/serials_dirich5d.db @@ -25,3 +25,8 @@ 0181 0x5600000e5cf40a28 0191 0xfd00000e5c6e0228 0201 0xae00000e5bf1ed28 + + +# DiRICH5d2 + +0301 0xb8f34840dfc03c4f diff --git a/base/serials_farich.db b/base/serials_farich.db index 6e9ea28..295a4e7 100644 --- a/base/serials_farich.db +++ b/base/serials_farich.db @@ -34,3 +34,6 @@ 0271 0x0000667700562941 0281 0x0000e35900562941 + +0291 0x0000008b00572941 +0301 0x0000023a00572941 diff --git a/thresholds/logger_threshold.conf b/thresholds/logger_threshold.conf index 0bdd71e..425c946 100644 --- a/thresholds/logger_threshold.conf +++ b/thresholds/logger_threshold.conf @@ -1,6 +1,6 @@ log4perl.logger.padiwa_threshold=ERROR, A1 log4perl.appender.A1=Log::Dispatch::File -log4perl.appender.A1.filename=padiwa_threshold.log +log4perl.appender.A1.filename=padiwathreshold.log log4perl.appender.A1.mode=append log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout #log4perl.appender.A1.layout.ConversionPattern=%d %p> %F{1}:%L %M %P - %m%n @@ -9,7 +9,7 @@ log4perl.appender.A1.layout.ConversionPattern=%d %p> %M %P - %m%n # results of threshold scan log4perl.logger.padiwa_threshold_data=DEBUG, D1 log4perl.appender.D1=Log::Dispatch::File -log4perl.appender.D1.filename=padiwa_threshold_results.log +log4perl.appender.D1.filename=padiwathreshold_results.log log4perl.appender.D1.mode=append log4perl.appender.D1.layout=Log::Log4perl::Layout::PatternLayout log4perl.appender.D1.layout.ConversionPattern=%d %m%n diff --git a/thresholds/tdcv4_treshold_logger.conf b/thresholds/tdcv4_treshold_logger.conf new file mode 100644 index 0000000..57f414c --- /dev/null +++ b/thresholds/tdcv4_treshold_logger.conf @@ -0,0 +1,26 @@ +log4perl.logger.tdcv4_threshold=ERROR, A1 +log4perl.appender.A1=Log::Dispatch::File +log4perl.appender.A1.filename=tdcv4_threshold.log +log4perl.appender.A1.mode=append +log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout +#log4perl.appender.A1.layout.ConversionPattern=%d %p> %F{1}:%L %M %P - %m%n +log4perl.appender.A1.layout.ConversionPattern=%d %p> %M %P - %m%n + +# results of threshold scan +log4perl.logger.tdcv4_threshold_data=DEBUG, D1 +log4perl.appender.D1=Log::Dispatch::File +log4perl.appender.D1.filename=tdcv4_threshold_results.log +log4perl.appender.D1.mode=append +log4perl.appender.D1.layout=Log::Log4perl::Layout::PatternLayout +log4perl.appender.D1.layout.ConversionPattern=%d %m%n + + +# results of threshold scan +log4perl.logger.tdcv4_threshold_dump=DEBUG, D2 +log4perl.appender.D2=Log::Dispatch::File +log4perl.appender.D2.filename=tdcv4_threshold_dump.log +log4perl.appender.D2.mode=append +log4perl.appender.D2.layout=Log::Log4perl::Layout::PatternLayout +log4perl.appender.D2.layout.ConversionPattern=%d %m%n + + diff --git a/thresholds/thresholds_automatic_tdcv4.pl b/thresholds/thresholds_automatic_tdcv4.pl new file mode 100755 index 0000000..15c09b0 --- /dev/null +++ b/thresholds/thresholds_automatic_tdcv4.pl @@ -0,0 +1,563 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Data::Dumper; + +use lib "/home/hadaq/trbsoft/daqtools/dmon/code"; +use Dmon; + +use Getopt::Long; +use Log::Log4perl qw(get_logger); + +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 @threshold_to_channel_mapping_odd = qw(4 27 29 3 5 9 6 24 7 8 10 21 23 25 26 28 14 13 12 0 2 20 15 31 30 22 19 16 17 18 11 1); + +my @threshold_to_channel_mapping_even = qw(5 29 24 3 4 9 6 19 7 8 10 21 23 25 27 26 14 13 12 15 2 30 0 20 28 17 22 18 16 31 11 1); + +#my @threshold_to_channel_mapping = (0..31); +my @channel_to_threshold_mapping_odd = (); +my @channel_to_threshold_mapping_even = (); + +my $threshold_number = 0; +foreach my $cur_channel (@threshold_to_channel_mapping_odd) { + $channel_to_threshold_mapping_odd[$cur_channel] = $threshold_number++; +} + +$threshold_number = 0; +foreach my $cur_channel (@threshold_to_channel_mapping_even) { + $channel_to_threshold_mapping_even[$cur_channel] = $threshold_number++; +} + +#print Dumper \@threshold_to_channel_mapping, \@channel_to_threshold_mapping; + +my $USE_LOCK = 0; + +my $hitregister = 0xcc00; + +my @valid_interval = (0x4000, 0xc000); +my $interval_step = ($valid_interval[1] - $valid_interval[0])/2; +my $start_value = int ( ($valid_interval[1] + $valid_interval[0])/2 ); + +#$start_value = 0xffff; + +my $sleep_time = 0.3; +my $accepted_dark_rate = 10; +my $number_of_iterations = 40; # at least 15 are recommended + +my $endpoint = 0x0303; +my $help = ""; +my $offset = 0; +my $opt_skip = 99; +my $polarity = 1; +my $default_direction = 1; +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; + +my $result = GetOptions ( + "h|help" => \$help, + "c|chain=i" => \$chain, + "channel_to_set=i" => \$channel_to_set, + "channel_by_channel" => \$channel_by_channel, + "e|endpoint=s" => \$endpoint, + "p|polarity=i" => \$polarity, + "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=i" => \$accepted_dark_rate, + ); + +if ($help) { + usage(); + exit; +} + + +if ($offset) { + if ($offset =~ /^0x/) { + $offset = hex($offset); + } else { + die "wrong number format for offset parameter: \"$offset\"" unless $offset =~ /^\d+$/; + $offset = int($offset); + } + + #print "called with offset: $offset\n"; +} + +if ($default_direction != 1 && $default_direction != -1) { + die "direction can only be 1 or -1"; +} + +die "wrong number format for chain parameter: \"$chain\"" unless $chain =~ /^\d+$/; + +if ($endpoint !~ /^0x/) { + print "wrong format for enpoint number $endpoint, should be 0x0 - 0xffff, use hex notation with 0x\n"; + usage(); + exit; +} +$endpoint = hex($endpoint); + + +# go to the right position + +my $hitchannel_multiplicator = 1; + +if ($channel32 || $channel16) { + $hitregister += 32*$chain; + $hitchannel_multiplicator = 2; +} else { + $hitregister += 16*$chain; +} + + + +Log::Log4perl->init("tdcv4_treshold_logger.conf"); + +my $logger = get_logger("tdcv4_threshold.log"); +my $logger_data = get_logger("tdcv4_threshold_data"); + + +my $startup_str = sprintf "startup with: endpoint: $endpoint, chain: $chain, offset: $offset, polarity: $polarity"; +$logger->info($startup_str); + +trb_init_ports() or die trb_strerror(); + +my @current_thresh = ($start_value) x 32; +my @best_thresh = (0) x 32; +my @hit_diff = (0) x 32; +my @crossed_thresh = (0) x 32; +my @interval_step = ($interval_step) x 32; + +if (defined $opt_skip && $opt_skip < 32) { + $best_thresh[$opt_skip] = 0x6800; +} + +if ($opt_finetune == true) { + my $ra_thresh = read_thresholds($chain); + @current_thresh = @$ra_thresh; + print Dumper \@current_thresh; + + $interval_step = 4; +} + + +my $hit_diff = 0; + +my $number_of_steps = 0; + +my $rh_res; +my $rh_res2; +my $old_rh_res; +my $old_rh_res2; +my $rh_static; + +my $outermost_channel_loop_counter = 0; + +#set default values +my @zero_array = (0x0) x 32; + +write_thresholds($chain, \@zero_array); + +#$outermost_channel_loop_counter = 32; +if ($channel_by_channel == true) { + $outermost_channel_loop_counter = 31; +} + +my @outermost_channel_loop = (0); + +if ($channel_by_channel) { + @outermost_channel_loop = (0 .. $outermost_channel_loop_counter); +} + +#print "channellist:\n"; +#print Dumper \@outermost_channel_loop; + +foreach my $current_channel_outer_loop (@outermost_channel_loop) { + + if ($channel_by_channel) { + $channel_to_set = $current_channel_outer_loop; + write_thresholds($chain, \@zero_array); + } + + $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 + ) { + $number_of_steps++; + last if($number_of_steps > 40); + + write_thresholds($chain, \@current_thresh, $channel_to_set); + + # wait settling time, experimentally determined to 0.04 seconds + select(undef, undef, undef, 0.1); + + ($old_rh_res) = read_hitcounters($endpoint); + select(undef, undef, undef, $sleep_time); + ($rh_res, $rh_static) = read_hitcounters($endpoint); + + #print Dumper $rh_res; + #print Dumper $old_rh_res; + + my @iterate_loop = (0 .. 31); + + if ($channel_by_channel) { + @iterate_loop = ($current_channel_outer_loop); + } + + foreach my $i (@iterate_loop) { + $interval_step = $interval_step[$i]; + + my $cur_hitreg = $rh_res ->{$endpoint}->[$i*$hitchannel_multiplicator]; + my $old_hitreg = $old_rh_res->{$endpoint}->[$i*$hitchannel_multiplicator]; + my $hits = $cur_hitreg; + my $static_value = $rh_static ->{$endpoint}->[$i*$hitchannel_multiplicator]; + + $hit_diff = abs($hits - $old_hitreg); + #printf "channel: %3d: diff: %8d, static_value: $static_value, cur_thresh: 0x%06x\n", $i, $hit_diff, $current_thresh[$i]; + $hit_diff[$i] = $hit_diff; + + #if ( ($static_value == ($polarity ? 0 : 1)) + # && $hit_diff < 100 + # && $crossed_thresh[$i] == 0) { + # $crossed_thresh[$i] = 1; + # print "crossed threshold\n"; + #} + + # $crossed_thresh[$i] = 1; + + # select best threshold, closest from bottom + if ( + $hit_diff[$i] <= $accepted_dark_rate + && $best_thresh[$i] <= $current_thresh[$i] + && $static_value == $polarity + ) { + $best_thresh[$i] = $current_thresh[$i]; + } + + #delete bogus entries + if ($hit_diff[$i] >= $accepted_dark_rate && $current_thresh[$i] < $best_thresh[$i]) { + $best_thresh[$i] = $current_thresh[$i]; + } + + my $direction = $default_direction; + if ($static_value == ($polarity ? 0 : 1)) { + $interval_step = int($interval_step/1.2); + $direction = -1 * $direction; + } elsif ($hit_diff > $accepted_dark_rate ) { + $interval_step = int($interval_step/1.2); + $direction = -1 * $direction; + } else { + $interval_step = int($interval_step/1.2); + } + + $interval_step = 2 if($interval_step < 2); + $interval_step = 3 if($interval_step == 1 && $direction ==- 1); + + $interval_step[$i] = $interval_step; + + $current_thresh[$i] += $interval_step * $direction; + + if ($current_thresh[$i] < 0) { + $current_thresh[$i] = 0; + } + if ($current_thresh[$i] > 0xffff) { + $current_thresh[$i] = 0xffff; + } + + my $str = + sprintf ("iter: %4d, endpoint: 0x%04x, chain: %2d, channel: %2d, hits: %8d ", + $number_of_steps, $endpoint, $chain, $i, $hits); + $str.= "static: $static_value, diff: " . + sprintf("%8d, dir: %2d", $hit_diff, $direction) . " , " . + "new thresh: " . sprintf("0x%x", $current_thresh[$i]) . + ", step_size: " . sprintf ("0x%04x best: 0x%04x", $interval_step[$i], $best_thresh[$i]); + + #print "$str\n"; + $logger->info($str); + + } # end of loop over 15 channel + + } #end of loop over steps + + + + map { $_-= ($offset * $default_direction) } @best_thresh; + write_thresholds($chain, \@best_thresh, $channel_to_set); + + my $uid = 0; + foreach my $i (reverse (0 .. 3)) { + #print "send command: $endpoint , i: $i\n"; + # read uids + #$rh_res = Dmon::PadiwaSendCmd(0x10000000 | $i * 0x10000, $endpoint, $chain); + #$uid .= sprintf("%04x", $rh_res->{$endpoint} &0xffff); + #print $uid; + } + + my $str; + #$logger_data->info("thresholds have been set to the following values:"); + #$logger_data->info(sprintf "endpoint: %04x, chain: %02d, uid: $uid", $endpoint, $chain); + #$logger_data->info("\t".time); + + my @range = (0 .. 31); + + if ($channel_by_channel) { + @range = ($current_channel_outer_loop .. $current_channel_outer_loop); + } + + #print "range2: "; + #print Dumper @range; + + foreach my $i (@range) { + my $str = sprintf "endpoint: 0x%04x, chain: %02d, channel: %2d threshold: 0x%04x, uid: %s", $endpoint, $chain, $i, $best_thresh[$i], $uid; + #print "$str\n"; + $logger_data->info($str); + } + +} # end of channel_by_channel loop + +# set all channels to 0 after threshold determination in single channel mode +if ($channel_by_channel == true) { + write_thresholds($chain, \@zero_array); +} + + +exit; + +sub read_hitcounters { + (my $address) = @_; + + my $counter; + my $old_counter; + my $channel = 0; + my $rh_counters; + my $base_offset = 0xcc00; + + my $rh_static; + my $rh_static_expanded; + + $channel = 0; + foreach my $current_register (0xce01,0xce11) { + $rh_static = trb_register_read_mem($address, $current_register, 0 , 1); + foreach (@{$rh_static->{$address}}) { + #print "static value of whole register: $_\n"; + my $current_static_vector = $rh_static->{$address}->[0]; + foreach (0..15) { + $rh_static_expanded->{$address}->[$channel++] = ($current_static_vector >> $_ ) & 0x1; + } + } + } + + $channel = 0; + foreach (0x0,0x10,0x20,0x30) { + my $current_offset = $base_offset + $_; + $rh_counters = trb_register_read_mem($address, $current_offset, 0 , 8); + foreach (@{$rh_counters->{$address}}) { + $counter->{$address}->[$channel++] = $_; + } + } + + + #print Dumper $counter, $rh_static_expanded; + return $counter, $rh_static_expanded; +} + + +sub read_thresholds { + (my $chain) = @_; + + my @thresh = (); + + $share->store($chain); + + my $res; + + if ($USE_LOCK) { + $res = $share->lock(LOCK_EX); + if (!defined $res || $res != 1) { + die "could not lock shared element"; + } + } + + my $rh_res; + # $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain); + + my @range = (0 .. 31); + foreach my $current_channel (@range) { + + my $command; + my $fixed_bits; + my $shift_bits; + + $fixed_bits = 0x00300000; + $shift_bits = 4; + + $command = $fixed_bits | ($current_channel << 16) ; + my $rh_res = Dmon::PadiwaSendCmd($command,$endpoint, $chain); + push (@thresh , 0xffff & $rh_res->{$endpoint}); + } + + #sleep 10 if($current_channel == 15 && $chain==1); + #sleep 1; + if ($USE_LOCK) { + $share->unlock(); + } + + + return \@thresh; + +} + + +sub write_thresholds { + (my $chain, my $ra_thresh, my $channel_to_set) = @_; + + #print "mode: $mode, chain: $chain, channel_to_set: $channel_to_set: ra_thresh:\n"; + #print Dumper $ra_thresh; + $share->store($chain); + + my $res; + + if ($USE_LOCK) { + $res = $share->lock(LOCK_EX); + if (!defined $res || $res != 1) { + die "could not lock shared element"; + } + } + ### old and wrong way #my $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain); + + my @range = (0 .. 31); + + if (defined $channel_to_set && $channel_to_set <32 ) { + @range = ($channel_to_set .. $channel_to_set); + #print "range: \n"; + } + + #print Dumper \@range; + foreach my $current_channel (@range) { + + my $command; + my $fixed_bits; + my $shift_bits; + my $channel_shift; + + $fixed_bits = 0x8 << 20; # write command + $shift_bits = 0; + $channel_shift = 24; + + my $mapped_channel; + if ($endpoint % 2 == 0) { + $mapped_channel = $channel_to_threshold_mapping_even[$current_channel]; + } + else { + $mapped_channel = $channel_to_threshold_mapping_odd[$current_channel]; + } + + #print "mapped channel: $mapped_channel\n"; + $command = $fixed_bits | ( ($mapped_channel&0xf) << $channel_shift) | ( ( $ra_thresh->[$current_channel]&0xffff) << $shift_bits); + #printf "command: %x\n", $command; + if ($mapped_channel<16) { + Dmon::PadiwaSendCmd($command,$endpoint, 0); + } else { + #print "second chain\n"; + Dmon::PadiwaSendCmd($command,$endpoint, 1); + } + + #sleep 10 if($current_channel == 15 && $chain==1); + #sleep 1; + if ($USE_LOCK) { + $share->unlock(); + } + } +} + +sub send_command { + (my $endpoint, my $chain, my $command) = @_; + + my $ra_atomic = [$command,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001]; + my $rh_res = trb_register_write_mem($endpoint, 0xd400, 0, $ra_atomic, scalar @{$ra_atomic}); + send_command_error($endpoint) if (!defined $rh_res); + + $rh_res = trb_register_read($endpoint,0xd412); + #print Dumper $rh_res; + send_command_error($endpoint) if (!defined $rh_res); + return $rh_res; + +} + + + +sub send_command_error { + my $res = trb_strerror(); + my $s= sprintf "error output for access to endpoint 0x%04x: $res\n", $endpoint; + print $s; + $s=~s/\n/, /g; + $logger->error($s); + $logger_data->error($s); + exit(); +} + +sub usage { + + print < --chain= [--offset=] + [--help] [--32channel] + +example: + +thresholds_automatic_tdcv4.pl --endpoint=0x303 --chain=0 --offset=0x10 --32channel +or in short +thresholds_automatic_tdcv4.pl -e 0x303 -o 0x10 -c 0 + +example to find correct threshold for a dirich2 system from high values to lower ones (above pedestal) +./run_thresh_on_system.pl --endpoint=0x1200-0x120b --offset=0 --polarity=1 --direction=-1 --32channel + +example to find correct threshold for a dirich2 system from low values to higher ones (below pedestal) +./run_thresh_on_system.pl --endpoint=0x1200-0x120b --offset=0 --polarity=0 --direction=1 --32channel + +polarity: tells what the status of bit 32 is in the TDC, when the thresholds are set to 0 + this is needed just for the convention, that an inactive channel shows up in the TDC registers + as green fields and therefore the padiwas need an invert of the outputs for negative signals +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 + +} diff --git a/users/gsi_ee_trb84/first.C b/users/gsi_ee_trb84/first.C index e90606c..192a046 100644 --- a/users/gsi_ee_trb84/first.C +++ b/users/gsi_ee_trb84/first.C @@ -24,15 +24,17 @@ void first() // 4 - use common statistic for both rising and falling edge hadaq::TrbProcessor::SetDefaults(33, 2); - hadaq::TdcProcessor::SetTriggerDWindow(-5, 90); + //hadaq::TdcProcessor::SetTriggerDWindow(-5, 90); + hadaq::TdcProcessor::SetTriggerDWindow(-5, 1E15); // hadaq::TdcProcessor::SetToTRange(30, 50, 80); // [min..max] range for TDC ids - hadaq::TrbProcessor::SetTDCRange(0x1000, 0x1FFF); + //hadaq::TrbProcessor::SetTDCRange(0x1000, 0x1FFF); + hadaq::TrbProcessor::SetTDCRange(0x1300, 0x13ff); // [min..max] range for HUB ids - hadaq::TrbProcessor::SetHUBRange(0x8000, 0x8FFF); + hadaq::TrbProcessor::SetHUBRange(0x8000, 0x8fff); //hadaq::TrbProcessor::SetHUBRange(0xc000, 0xcfff); // Histogramming for ToT: first: nr. of bins, 2nd: TOT range @@ -123,7 +125,7 @@ extern "C" void after_create(hadaq::HldProcessor* hld) //tdc->SetCustomMhz(350); //tdc->SetCustomMhz(200); - tdc->SetUseLastHit(false); + tdc->SetUseLastHit(true); // needed if tdc-ToT values are larger 60ns // arguments: delay, range (min, max) @@ -133,7 +135,8 @@ extern "C" void after_create(hadaq::HldProcessor* hld) // This gives a factor of 1.5625, so the calibration pulse has a length of // 31.25ns //tdc->SetToTRange(31.25, 40, 70); - tdc->SetToTRange(31.25, 30, 70); + //tdc->SetToTRange(31.25, 30, 70); + tdc->SetToTRange(20, 15, 70); // in new dirich5s design the correct PLL is included, so no correction necessary! @@ -141,14 +144,19 @@ extern "C" void after_create(hadaq::HldProcessor* hld) //tdc->SetStoreEnabled(); for (unsigned nch=1; nchNumChannels(); nch++) { //if(nch!=48) { - //tdc->SetRefChannel(nch, nch-1, 0xffff, 100000, -50., 50.); - //} - } - - tdc->SetRefChannel(3, 7, 0x1417, 100000, -20.1, 20.); - tdc->SetRefChannel(4, 6, 0x1410, 100000, -20.1, 20.); - tdc->SetRefChannel(5, 7, 0x1417, 100000, -20.1, 20.); - tdc->SetRefChannel(6, 8, 0x1417, 100000, -20.1, 20.); + tdc->SetRefChannel(nch, nch-1, 0xffff, 100000, -50., 50.); + } + //} + + //tdc->SetRefChannel(4, 2, 0x1306, 10000, -20.1, 20.); + //tdc->SetRefChannel(3, 1, 0x1306, 10000, -20.1, 20.); + + //tdc->SetRefChannel(4, 2, 0x1306, 10000, -20.1, 20.); + //tdc->SetRefChannel(5, 1, 0x1306, 10000, -20.1, 20.); + // tdc->SetRefChannel(6, 2, 0x1306, 10000, -20.1, 20.); + // tdc->SetRefChannel(3, 1, 0x1306, 10000, -20.1, 20.); + + //tdc->SetRefChannel(4, 6, 0xffff, 10000, -20.1, 20.); //tdc->SetRefChannel(0, 0, 0x1410, 100000, -500000.1, 500000.); //tdc->SetRefChannel(48, 39, 0xffff, 18000, -50., 50.); diff --git a/users/gsi_ee_trb84/startup_461.sh b/users/gsi_ee_trb84/startup_461.sh index 0018507..a5a80c2 100755 --- a/users/gsi_ee_trb84/startup_461.sh +++ b/users/gsi_ee_trb84/startup_461.sh @@ -132,7 +132,7 @@ echo "pulser frequency" #trbcmd w 0xc001 0xa155 0x3e7 # Pulser 2: 100kHz ./tdcv4_setup.sh 0xfe55 -./tdcv4_setup.sh 0xfe53 +#./tdcv4_setup.sh 0xfe53 # # Enable #./tdcv4_enable_channels.sh 0xfe55 0xf 0xf #enable channels diff --git a/users/gsi_ee_trb84/tdcv4_setup.sh b/users/gsi_ee_trb84/tdcv4_setup.sh index d0c9a9f..e802843 100755 --- a/users/gsi_ee_trb84/tdcv4_setup.sh +++ b/users/gsi_ee_trb84/tdcv4_setup.sh @@ -24,7 +24,9 @@ trbcmd clearbit $ADDR 0xcd00 0x02000000 # Un-Block Input Buffer of t trbcmd setbit $ADDR 0xcd01 0x04000000 # Enable calibration clock trbcmd loadbit $ADDR 0xcd01 0xff 0x7c # 8 / OscFreq = 25.6ns, all channels, 1 Pulse per trigger - # 312MHz => 0x7c; 200MHz => 0x4c, internal Osc (155MHz) => 0x3c. + # 312.5MHz => 0x7c; 200MHz => 0x4c, internal Osc (155MHz) => 0x3c. + +#trbcmd loadbit $ADDR 0xcd01 0xff 0x3c trbcmd clearbit $ADDR 0xcd00 0x1 # release Programmable TDC Reset diff --git a/users/gsi_ee_trb84/tdcv4_show_hit_rates.pl b/users/gsi_ee_trb84/tdcv4_show_hit_rates.pl index 23932bb..8e6aaa3 100755 --- a/users/gsi_ee_trb84/tdcv4_show_hit_rates.pl +++ b/users/gsi_ee_trb84/tdcv4_show_hit_rates.pl @@ -22,7 +22,7 @@ my $channel = 0; while (1) { # capture hit counters - trb_register_write($address, 0xcd30, 0x100); + #trb_register_write($address, 0xcd30, 0x100); my $rh_counters; my $base_offset = 0xcc00; foreach (0x0,0x10,0x20,0x30) { @@ -43,7 +43,7 @@ while (1) { $old_counter->[$channel++] = $_; } - # print Dumper $counter; + print Dumper $counter; sleep 1; $channel=0;