From 28ca80ef9e4afe7b398b6a9e9f7134cddf3739bd Mon Sep 17 00:00:00 2001 From: Hades DAQ Date: Wed, 18 Oct 2017 13:50:01 +0200 Subject: [PATCH] current status hades39, mt --- tools/determine_noiseband_dirich.pl | 94 ++++++++++++++++++-------- tools/dirich_scan_backplane.pl | 5 ++ tools/switch_power_dirich.pl | 3 +- users/gsi_dirc/README | 2 +- users/gsi_ee_trb84/TdcEventBuilder.xml | 4 +- users/gsi_ee_trb84/first.C | 3 +- 6 files changed, 78 insertions(+), 33 deletions(-) diff --git a/tools/determine_noiseband_dirich.pl b/tools/determine_noiseband_dirich.pl index 0e355e3..4d360c8 100755 --- a/tools/determine_noiseband_dirich.pl +++ b/tools/determine_noiseband_dirich.pl @@ -5,11 +5,26 @@ use HADES::TrbNet; use Time::HiRes qw(usleep); use Data::Dumper; -my $dirich = 0x1208; +use lib "/home/hadaq/trbsoft/daqtools/dmon/code"; +use Dmon; + +my $dirich = 0x1229; + +$dirich = $ARGV[0]; + +unless ($ARGV[0]) { + print "usage: $0 \n"; + exit; +} + +$dirich = hex($dirich); + my $throffset = 0xa000; -my $monitor = 0xdfc0; +#my $monitor = 0xdfc0; +my $monitor = 0xc001; -my $last_channel = 8; +my $first_channel = 0; +my $last_channel = 31; my $default_threshold = 0x3000; @@ -20,6 +35,7 @@ my @res; my $res; my $rh_res; trb_init_ports() or die trb_strerror(); +# enable monitor counters $res = trb_register_write($dirich, 0xdf80 , 0xffffffff); if(!defined $res) { $res = trb_strerror(); @@ -27,42 +43,60 @@ if(!defined $res) { } +my $fixed_bits = 0x00800000; +my $shift_bits = 0; +my $channel_shift = 24; +my $command; +my $chain=0; + + + for my $channel (0 .. 31) { - trb_register_write($dirich, $throffset + $channel , $default_threshold); - #$rh_res = trb_register_read($dirich, $throffset + $channel); + $chain = ($channel <16) ? 0 : 1; + $command = $fixed_bits | ($channel << $channel_shift) | ($default_threshold << $shift_bits); + Dmon::PadiwaSendCmd($command,$dirich, $chain); + #trb_register_write($dirich, $throffset + $channel , $default_threshold); + #$rh_res = trb_register_read($dirich, $throffset + $channel); } usleep (1E5); my $boundaries = {}; -#for my $channel (0 .. $last_channel) { -for my $channel (28 .. 31) { +for my $channel ($first_channel .. $last_channel) { +#for my $channel (30 .. 31) { my $hit_zero_diff_flag = 0; - my $lower_threshold = 0x6e00; + my $lower_threshold = 0x6a80; my $upper_threshold = 0xd000; my $reasonable_upper_threshold = 0x8000; - my $thresh_increment = 0x04; - + my $thresh_increment = 0x8; + THRESH_LOOP: for (my $thresh = $lower_threshold ; $thresh <= $upper_threshold; $thresh += $thresh_increment) { - trb_register_write($dirich, $throffset + $channel , $thresh); + $chain = ($channel <16) ? 0 : 1; + $command = $fixed_bits | ($channel << $channel_shift) | ($thresh << $shift_bits); + Dmon::PadiwaSendCmd($command,$dirich, $chain); + ##trb_register_write($dirich, $throffset + $channel , $thresh); undef $rh_res; my @hits = (); foreach (1..2) { - usleep(50E3); $rh_res = trb_register_read($dirich, $monitor + $channel); #$res = trb_strerror(); #print "error output: $res\n"; #print Dumper $rh_res; push @hits ,$rh_res->{$dirich}; - } - + #if ($_==1) { + usleep(40E3); + #} + } + my $diff = $hits[1] - $hits[0]; + #printf "cur thresh: %.4x diff: $diff\n",$thresh ; + #sleep 0.2; $hit_zero_diff_flag = 1 if($diff == 0); - - if($diff > 1 && !$hit_zero_diff_flag ) { + + if($diff != 0 && !$hit_zero_diff_flag ) { print "channel: $channel, backup threshold a bit (by 0x800)..., thresh: "; printf "0x%x\n",$thresh; if($thresh <= $absolute_min_threshold) { print "reached abs min threshold\n"; @@ -78,33 +112,38 @@ for my $channel (28 .. 31) { } $thresh_increment *= 4 if($thresh_increment <= 0x100 && $thresh >= $reasonable_upper_threshold ); - + #my $thrstr = sprintf("0x%x", $thresh); #print "channel: $channel: thresh: $thrstr : diff: $diff, a=$hits[0] b=$hits[1]\n"; my $thrstr = sprintf("0x%x", $thresh); - if($diff > 1) { + if($diff >= 50) { if( ! exists $boundaries->{$channel}->{'lower'} ) { print "channel: $channel, lower thresh: $thrstr\n"; $boundaries->{$channel}->{'lower'} = $thresh; } } - elsif ($diff == 0 && exists $boundaries->{$channel}->{'lower'}) { + elsif ($diff == 0 && exists $boundaries->{$channel}->{'lower'} && ($thresh - $boundaries->{$channel}->{'lower'} ) > 0x40 ) { print "channel: $channel, upper thresh: $thrstr\n"; $boundaries->{$channel}->{'upper'} = $thresh; last THRESH_LOOP; } - - } + + } + if ( ! exists $boundaries->{$channel}->{'upper'}) { - $boundaries->{$channel}->{'upper'} = $upper_threshold; + $boundaries->{$channel}->{'upper'} = $upper_threshold; + print "strange setting of upper thresh.\n"; } - - trb_register_write($dirich, $throffset + $channel , $default_threshold); + + $chain = ($channel <16) ? 0 : 1; + $command = $fixed_bits | ($channel << $channel_shift) | ($default_threshold << $shift_bits); + Dmon::PadiwaSendCmd($command,$dirich, $chain); + #trb_register_write($dirich, $throffset + $channel , $default_threshold); } -print "\nresult:\n"; +printf "\nresult for 0x%.4x:\n",$dirich; #print Dumper $boundaries; print "channel | noiseband [mV]\n"; print "------------------------\n"; @@ -114,12 +153,11 @@ foreach my $cur_channel (sort {$a <=> $b} keys %$boundaries) { printf "%2d | %02.0f\n", $cur_channel , $width; } -print "\nsummary:\n"; +printf "\nsummary for 0x%.4x:\n", $dirich; foreach my $cur_channel (sort {$a <=> $b} keys %$boundaries) { my $diff = $boundaries->{$cur_channel}->{upper} - $boundaries->{$cur_channel}->{lower}; my $width = $diff * 38E-6 * 1000; - printf "%2d ", $width; + printf "%02.0f ", $width; } print "\n"; - diff --git a/tools/dirich_scan_backplane.pl b/tools/dirich_scan_backplane.pl index aef8c03..d5519bc 100755 --- a/tools/dirich_scan_backplane.pl +++ b/tools/dirich_scan_backplane.pl @@ -5,6 +5,11 @@ use Data::Dumper; my $dirich_concentrator_address = $ARGV[0]; +unless ($ARGV[0]) { + print "usage: dirich_scan_backplane.pl \n"; + exit; +} + my $c; #($dirich_concentrator_address) = $dirich_concentrator_address =~ /0x([\w\d]+)/; diff --git a/tools/switch_power_dirich.pl b/tools/switch_power_dirich.pl index 1b650e3..9bc893e 100755 --- a/tools/switch_power_dirich.pl +++ b/tools/switch_power_dirich.pl @@ -10,7 +10,8 @@ my $dirich_power_module_offset = 0xd580; my @res; my $res; my $rh_res; -my @dirich_powerbit_mapping = (1, 23, 17, 24, 18, 26, 20, 25, 19, 28, 22, 27,21); +#my @dirich_powerbit_mapping = (1, 23, 17, 24, 18, 26, 20, 25, 19, 28, 22, 27,21); +my @dirich_powerbit_mapping = (1, 17 .. 28); my $dirich_concentrator_address = $ARGV[0]; my $position = $ARGV[1]; diff --git a/users/gsi_dirc/README b/users/gsi_dirc/README index aa2ed72..36d567b 100644 --- a/users/gsi_dirc/README +++ b/users/gsi_dirc/README @@ -1,5 +1,5 @@ #to start deamon -TRB3_SERVER=trb056 ~/trbsoft/trbnettools/binlocal/trbnetd -i 56 +TRB3_SERVER=trb056 ~/trbsoft/trbnettools/bin/trbnetd -i 56 #set environment export DAQOPSERVER=localhost:56 diff --git a/users/gsi_ee_trb84/TdcEventBuilder.xml b/users/gsi_ee_trb84/TdcEventBuilder.xml index 9bb7a8a..004e19d 100644 --- a/users/gsi_ee_trb84/TdcEventBuilder.xml +++ b/users/gsi_ee_trb84/TdcEventBuilder.xml @@ -69,8 +69,8 @@ When starting analysis from the go4 gui, one should specify stream server with p - - + + diff --git a/users/gsi_ee_trb84/first.C b/users/gsi_ee_trb84/first.C index 66418bf..eb6e22a 100644 --- a/users/gsi_ee_trb84/first.C +++ b/users/gsi_ee_trb84/first.C @@ -103,10 +103,11 @@ extern "C" void after_create(hadaq::HldProcessor* hld) // tdc->SetRefChannel(nch, nch-1, 0xffff, 10000, -90., 90.); //} - for (unsigned j=0; j<33; j++) { + for (unsigned j=10; j<33; j++) { tdc->SetRefChannel(j, 1, 0xffff, 10000, -40., 40.); } + tdc->SetRefChannel(6, 0, 0xffff, 10000, -100.,100.); //tdc->SetRefChannel(0, 0, 0x1202, 10000, -20., 20.); //tdc->SetRefChannel(4, 2, 0xffff, 10000, -20., 20.); //tdc->SetRefChannel(1, tdc->NumChannels() -1 , 0xffff, 20000, -10., 10.); -- 2.43.0