my $hitregister = 0xc001;
-my $interval_step = 0x0400;
-my $start_value = 0x7000;
my $sleep_time = 2.0;
my $accepted_dark_rate = 150;
-my $number_of_iterations = 40;
+my $number_of_iterations = 50;
my $endpoint = 0x0303;
my $mode = "padiwa";
}
$endpoint = hex($endpoint);
-
+my $interval_step = 0x0400;
+my $start_value = 0x7000;
+if ($polarity == -1) {$start_value = 0xb000;}
# go to the right position
$hit_diff[$i] = $hit_diff;
if($number_of_steps > $number_of_iterations - 20 || $opt_finetune) {
- # select best threshold, closest from bottom
+ # select best threshold
if( $hit_diff[$i] <= $accepted_dark_rate
- && $best_thresh[$i] <= $current_thresh[$i]
+ && ( ($best_thresh[$i] <= $current_thresh[$i] && $polarity == 1)
+ || ($best_thresh[$i] >= $current_thresh[$i] && $polarity == -1))
&& $static_value == (($polarity==1)?0:1)) {
$best_thresh[$i] = $current_thresh[$i];
}
#delete bogus entries
- if($hit_diff[$i] >= $accepted_dark_rate && $current_thresh[$i] < $best_thresh[$i]) {
+ if($hit_diff[$i] >= $accepted_dark_rate
+ && ( ($current_thresh[$i] < $best_thresh[$i] && $polarity == 1)
+ || ($current_thresh[$i] > $best_thresh[$i] && $polarity == -1))) {
$best_thresh[$i] = $current_thresh[$i];
}
}
}
elsif ($hit_diff > $accepted_dark_rate
&& $hit_diff < 10000 ) {
- $current_thresh[$i] -= max($interval_step * $polarity , $opt_finetune?0x2:0x10);
+ $current_thresh[$i] -= max($interval_step , $opt_finetune?0x2:0x10) * $polarity;
$interval_step = max(int($interval_step/2),4);
}
elsif ($hit_diff > $accepted_dark_rate ) {
- $current_thresh[$i] -= max($interval_step * 2 * $polarity , $opt_finetune?0x4:0x50);
+ $current_thresh[$i] -= max($interval_step * 2 , $opt_finetune?0x4:0x50)* $polarity;
$interval_step = max(int($interval_step/2),0x10);
if ($hit_diff > 20000) {
$make_it_quiet[$i] = 1;
$shift_bits = 4;
}
my $thresh = $ra_thresh->[$current_channel];
- if($make_it_quiet[$current_channel]) {$thresh = 0x0000;}
+ if($make_it_quiet[$current_channel]) {if($polarity == 1) {$thresh = 0x0000;} else {$thresh = 0xffff;}}
push(@commands,$fixed_bits | ($current_channel << 16) | ($thresh << $shift_bits));
}
Dmon::PadiwaSendCmdMultiple(\@commands,$endpoint,$chain,5E3);
use Data::Dumper;
use ChannelMapping;
+my $fn1 = $ARGV[0] or die("usage: thresholds_compare.pl file1 [file2]. omit file2 to get abs value, include for file1-file2");
+my $fn2 = $ARGV[1];
+
+
my $plot2 = ();
$plot2->{name} = "HeatmapRich";
$plot2->{file} = "thresh_heatmap";
$plot2->{xmax} = $ChannelMapping::chanmap->{xsize}+0.5;
$plot2->{ymin} = 0.5;
$plot2->{ymax} = $ChannelMapping::chanmap->{ysize}+0.5;
-$plot2->{cbmin} = "-400<*";
-$plot2->{cbmax} = "*<400";
+$plot2->{cbmin} = "-400<*" if $fn2;
+$plot2->{cbmax} = "*<" . ($fn2 ? '400' : '45000');
$plot2->{showvalues} = 0;
$plot2->{xlabel} = "column";
$plot2->{ylabel} = "row";
-$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.85\nset bmargin at screen 0.07\nset tmargin at screen 0.95";
-$plot2->{palette} = "defined ( 0 0 0 1, 0.5 1 1 1, 1 1 0 0 )";
+$plot2->{addCmd} = "set lmargin at screen 0.07\nset rmargin at screen 0.85\nset bmargin at screen 0.07\nset tmargin at screen 0.95";# . ($fn2 ? "": "\n set logscale cb");
+$plot2->{palette} = "defined ( 0 0 0 1, 0.5 1 1 1, 1 1 0 0 )" if $fn2;
HPlot::PlotInit($plot2);
}
# load files
- my $fn1 = $ARGV[0] or die("usage: thresholds_compare.pl file1 [file2]. omit file2 to get abs value, include for file1-file2");
- my $fn2 = $ARGV[1];
my $totalsize = ($ChannelMapping::chanmap->{xsize}*$ChannelMapping::chanmap->{ysize});
my %threshs1 = readSettings($fn1);
if ($fn2) {
%threshs2 = readSettings($fn2);
print "WARNING: Expected ".$totalsize." settings in $fn2. Got " . scalar(keys %threshs2) unless scalar(keys %threshs2) == $totalsize;
+ } else {
+ for my $key (keys %threshs1) {
+ $threshs2{$key} = 0;
+ }
+ $fn2 = 'n/a';
}
# plot heatmap
set xrange [$min:$max]
-binwidth=20
+binwidth=50
bin(x,width)=width*floor(x/width)
set style line 1 lt 1 lc rgb "green"
SpillThreshold => 30,
#Name detectors
-BeamDetectorsTrb => [0x0110, 0x0110, 0x0111,0x0110,0x0111,0x0110,0x0113,0x0110],
-BeamDetectorsChan => [0xc001, 0xc003, 0xc001,0xc009,0xc005,0xc00b,0xc009,0xc005],
-BeamDetectorsName => ['Fngr_d', 'Lead_d', 'C1', 'C1_d', 'C2', 'C2_d', 'Lead', 'Hodo'],
+BeamDetectorsTrb => [0x0110, 0x0110, 0x0111,0x0110,0x0111,0x0110,0x0113,0x0111,0x0110],
+BeamDetectorsChan => [0xc001, 0xc003, 0xc001,0xc009,0xc005,0xc00b,0xc009,0xc009,0xc005],
+BeamDetectorsName => ['Fngr_d', 'Lead_d', 'C1', 'C1_d', 'C2', 'C2_d', 'Lead1', 'Lead2', 'Hodo'],
#User directory
UserDirectory => '/home/hadaq/trbsoft/daqtools/users/cern_cbmrich/',
trbcmd w 0x0112 0xb01e 0 # include billboard info with e-trigger
#cbmnet
-trbcmd w 0x7005 0xa800 0x400003 # Listen to DLM 6, Enable CBMNet AND GbE
+trbcmd w 0x7005 0xa800 0x3 # Listen to DLM 6, Enable CBMNet AND GbE
+trbcmd w 0x7005 0xa900 0x400000 # Listen to DLM 6, Enable CBMNet AND GbE
trbcmd w 0x7005 0xa901 62500 # enable sync pulser with 2 khz ... prob. dont need it, but better safe thEn sorry
# pulser enable
# trbcmd setbit 0x7005 0xa00c 0x80000000
+echo "Disable leds of PMTS"
+for i in $( padiwa.pl 0xfe4c 0 time | grep "2014-11-21" | cut -d$'\t' -f1 - ); do
+ ./padiwa.pl $i 0 led 0 &
+done
+
+wait
+
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
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
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 03 threshold: 0xDB10, uid: 0
-2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 04 threshold: 0x0616, uid: 0
+2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 04 threshold: 0x075d, uid: 0
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 05 threshold: 0xd170, uid: 0
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 06 threshold: 0x0600, uid: 0
-2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 07 threshold: 0xdf80, uid: 0
-2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 08 threshold: 0xffff, uid: 0
+2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 07 threshold: 0xd377, uid: 0
+2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 08 threshold: 0x0560, uid: 0
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 09 threshold: 0x0000, uid: 0
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 10 threshold: 0xffff, uid: 0
2014/10/20 00:00:00 endpoint: 0x0111, chain: 00, channel: 11 threshold: 0x0000, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 01 threshold: 0x0000, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 02 threshold: 0xffff, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 03 threshold: 0x0000, uid: 0
-2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 04 threshold: 0x050E, uid: 0
-2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 05 threshold: 0xDC50, uid: 0
+2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 04 threshold: 0x075D, uid: 0
+2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 05 threshold: 0xD168, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 06 threshold: 0xffff, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 07 threshold: 0x0000, uid: 0
2014/10/20 00:00:00 endpoint: 0x0113, chain: 00, channel: 08 threshold: 0xffff, uid: 0