-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcheckOfflineMaskSize.pl
executable file
·54 lines (46 loc) · 1.63 KB
/
checkOfflineMaskSize.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w
# Like checkOnlineMaskSize.pl, but operates on the "offline" masks
# (with FED channel number and no ranges in the fields).
use strict;
my $infile = shift;
open INFILE, $infile or die "Couldn't open $infile: $!\n";
# list keyed by: channel number, roc number, and then
# 0: x left edge, 1: x right edge, 2: y bottom edge, 3: y top edge
my @activeArea;
while (my $line = <INFILE>) {
next if ($line =~ /^\#/); # skip comments
next if ($line =~ /^\s*$/); # skip blank lines
# next if ($line !~ /-/); # if line doesn't contain a range, it's just
# a single masked pixel, so ignore it
my @fields = split(" ", $line);
my $channel = $fields[0];
my $roc = $fields[1];
#print "Processing line $channel $roc $fields[4] $fields[5]\n";
if ($fields[4] == 0 && $fields[5] == 79) {
if ($fields[2] == 0) {
$activeArea[$channel][$roc][0] = $fields[3] + 1;
}
elsif ($fields[3] == 51) {
$activeArea[$channel][$roc][1] = $fields[2] - 1;
} else {
warn "Arg!\n";
}
}
if ($fields[2] == 0 && $fields[3] == 51) {
if ($fields[4] == 0) {
$activeArea[$channel][$roc][2] = $fields[5] + 1;
}
elsif ($fields[5] == 79) {
$activeArea[$channel][$roc][3] = $fields[4] - 1;
}
}
}
for (my $i=1; $i<24; ++$i) {
next if (!$activeArea[$i]);
for (my $r=0; $r<3; ++$r) {
#print "Ch $i ROC $r: x: ".$activeArea[$i][$r][0]."-".$activeArea[$i][$r][1]." y: ".$activeArea[$i][$r][2]."-".$activeArea[$i][$r][3];
my $xsize = $activeArea[$i][$r][1] - $activeArea[$i][$r][0] + 1;
my $ysize = $activeArea[$i][$r][3] - $activeArea[$i][$r][2] + 1;
print "Ch $i ROC $r: $xsize by $ysize\n";
}
}