aboutsummaryrefslogtreecommitdiff
path: root/scripts/peak-intensity
blob: 13bed6999720f58bfbbedaa93febbad91dc51be1 (plain)
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
#!/usr/bin/perl -w

use strict;

open(FH, $ARGV[0]);

my $line;
my $total_i;
my $n = 0;
my $n_patt = 0;
my $num_peaks_tot = 0;
my $num_sat_peaks_tot = 0;
my $num_pats_with_sat = 0;

while ( $line = <FH> ) {

	if ( $line =~ /^-----\ Begin chunk\ -----$/ ) {
		$n_patt++;
	}

	if ( $line =~ /^\s*([\d\.]+)\s+([\d\.]+)\s+([\d\.]+)\s+([\d\.]+)$/ ) {

		my $fs = $1;
		my $ss = $2;
		my $one_over_d = $3;
		my $i = $4;

		$total_i += $i;
		$n++;

	}

	if ( $line =~ /^num_saturated_peaks\s=\s(\d+)$/ ) {
		$num_sat_peaks_tot += $1;
		if ( $1 > 0 ) {
			$num_pats_with_sat++;
		}
	}

}

printf("%i patterns, %i peaks, %.2f total ADU\n", $n_patt, $n, $total_i);
printf("Mean %i peaks per hit\n", $n / $n_patt);
printf("Mean %.2f ADU per peak\n", $total_i / $n);
printf("Mean %.2f ADU per hit\n", $total_i / $n_patt);
printf("%i out of %i patterns contained any saturation\n", $num_pats_with_sat, $n_patt);
if ( $num_pats_with_sat > 0 ) {
	printf(" of those, there was an average of %.2f saturated peaks per pattern\n",
	       $num_sat_peaks_tot/$num_pats_with_sat);
}