aboutsummaryrefslogtreecommitdiff
path: root/scripts/i0-analysis
blob: b29892a936ed20511e81b0665553a04ee06880cb (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/perl -w

use strict;
use File::Basename;
use POSIX;

open(FH, $ARGV[0]);

my $line;
my $filename;
my $full_filename;

my $hsteps = 128;
my @hist;

open(GP, "| gnuplot");
print(GP "set term postscript enhanced font \"Helvetica,20\"\n");
print(GP "set output \"i0.ps\"\n");
print(GP "unset key\n");
print(GP "set xtics nomirror out rotate by 0\n");
print(GP "unset xdata\n");
print(GP "set format x \"% g\"\n");
print(GP "unset key\n");


# First graph: distribution of scaling factors
my $hmin = -0.1;
my $hmax = 1.5;
my $hstep = ($hmax - $hmin)/$hsteps;
for ( my $i=0; $i<$hsteps; $i++ ) {
	$hist[$i] = 0;
}
while ( $line = <FH> ) {
	if ( $line =~ /^([\d\.]+)\ ([\d\.]+)$/ ) {
		my $scale = $1;
		my $i0 = $2;
		my $bin = floor(($scale-$hmin)/$hstep);
		$hist[$bin]++;
	}
}
close(FH);
open(OFH, "> i0-scale-hist.dat");
for ( my $i=0; $i<$hsteps; $i++ ) {
	printf(OFH "%f %f\n", $hmin+$hstep*$i+($hstep/2), $hist[$i]);
}
close(OFH);
print(GP "set title \"Distribution of Scaling Factors\"\n");
print(GP "plot [] [] \"i0-scale-hist.dat\" u 1:2 w histeps\n");


# Second graph: distribution of gas detector values
$hmin = -0.5;
$hmax = 3.0;
$hstep = ($hmax - $hmin)/$hsteps;
open(FH, $ARGV[0]);
for ( my $i=0; $i<$hsteps; $i++ ) {
	$hist[$i] = 0;
}
while ( $line = <FH> ) {
	if ( $line =~ /^([\d\.]+)\ ([\d\.]+)$/ ) {
		my $scale = $1;
		my $i0 = $2;
		my $bin = floor(($i0-$hmin)/$hstep);
		$hist[$bin]++;
	}
}
close(FH);
open(OFH, "> i0-hist.dat");
for ( my $i=0; $i<$hsteps; $i++ ) {
	printf(OFH "%f %f\n", $hmin+$hstep*$i+($hstep/2), $hist[$i]);
}
close(OFH);
print(GP "set title \"Distribution of Gas Detector Values\"\n");
print(GP "plot [] [] \"i0-hist.dat\" u 1:2 w histeps\n");


# Third graph: distribution of scale factors after scaling i0=1
$hmin = -0.1;
$hmax = 1.5;
$hstep = ($hmax - $hmin)/$hsteps;
open(FH, $ARGV[0]);
for ( my $i=0; $i<$hsteps; $i++ ) {
	$hist[$i] = 0;
}
while ( $line = <FH> ) {
	if ( $line =~ /^([\d\.]+)\ ([\d\.]+)$/ ) {
		my $scale = $1;
		my $i0 = $2;
		my $bin = floor((($scale/$i0)-$hmin)/$hstep);
		$hist[$bin]++;
	}
}
close(FH);
open(OFH, "> i0-prior-hist.dat");
for ( my $i=0; $i<$hsteps; $i++ ) {
	printf(OFH "%f %f\n", $hmin+$hstep*$i+($hstep/2), $hist[$i]);
}
close(OFH);
print(GP "set title \"Distribution of Scaling Factors with I0=1\"\n");
print(GP "plot [] [] \"i0-prior-hist.dat\" u 1:2 w histeps\n");


close(GP);

system("ps2pdf i0.ps");
unlink("i0.dat");
unlink("i0.ps");
unlink("i0-hist.dat");
unlink("i0-prior-hist.dat");
unlink("i0-scale-hist.dat");