-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmear_all.pl
executable file
·55 lines (51 loc) · 1.13 KB
/
smear_all.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
54
#!/usr/bin/perl
use Cwd;
@dirs = glob("*");
$cwd = Cwd::getcwd();
foreach $dir (@dirs) {
if (-d $dir) {
print("$dir\n");
chdir($dir);
chdir("Q_val_dist");
&smear (0.2);
# chdir("../..");
chdir($cwd);
}
}
sub smear {
my ($a) = @_;
my (@files,@name,$j,@e,@P);
my ($x,$n,$f,$log,$pi);
$pi = 3.141592653589793;
@name = @files;
@files = glob("Q*.dat");
foreach (@files) {
/(.*)\.dat/;
open(in,"$1.dat");
$j = 0;
while (<in>) {
/[\s\d]\S+/;
@e[$j] = $&;
@P[$j] = $';
++$j;
}
close(in);
$n = @e;
open(out,">smear_$1.dat");
$j = 0;
$x = -2.0;
$dx = 0.01;
while ($x <= @e[$n-1]) {
$f = 0.0 ;
for($j=0; $j<=$n-1; ++$j) {
# $f += $a*@P[$j] / (($x-@e[$j])**2 + $a*$a)/$pi;
$f += @P[$j] / (sqrt(2.0*$pi) * $a)
* exp(-($x-@e[$j])**2/(2.0*$a*$a));
}
print out "$x $f\n";
$x += $dx;
++$j;
}
close(out);
}
}