-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeVDC.pl
executable file
·133 lines (109 loc) · 2.7 KB
/
makeVDC.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/perl
#
# VDC Dimensions
# short side in dispersive plane
#$width = 10.06;
#$length = 91.4;
#$end_length = 19.1;
#$wire_in = $width/3.; # guess
#$VDC2_offset_z = 39.4;
#$VDC2_offset_x = 39.4;
# long side in dispersive plane
$width = 10.06;
$length = 243.84;
$end_length = 19.7;
$wire_in = $width/3.; # guess
$VDC2_offset_z = 39.4;
$VDC2_offset_x = 0.;
$shift_up = 60.;
#$rotate_angle = 17.66; # deg
#$rotate_angle = 90. -28.25; # deg
$rotate_angle = 0.; # deg
$PI180 = 0.017453293;
# Edge points in its own frame of reference
# centered on first wire active area
# z perpendicular to chamber
$z[0] = -$wire_in;
$x[0] = -$length/2;
$z[1] = $z[0] + $width;
$x[1] = $x[0];
$z[2] = $z[1];
$x[2] = -$x[1];
$z[3] = $z[2] - $width;
$x[3] = $x[2];
$z[4] = $z[0];
$x[4] = $x[0];
$z[5] = $z[4];
$x[5] = $x[4] + $end_length;
$z[6] = $z[5] + $width;
$x[6] = $x[5];
$z[7] = $z[6];
$x[7] = -$x[6];
$z[8] = $z[7] - $width;
$x[8] = $x[7];
$z[9] = 0.;
$x[9] = $x[8];
$z[10] = 0.;
$x[10] = -$x[9];
$z[11] = -$wire_in + $width - $wire_in;
$x[11] = $x[10];
$z[12] = $z[11];
$x[12] = -$x[11];
$offset_z = 0.;
$offset_x = 0;
# read the parameters
open(DAXIS, "daxis_params.dat") || die "Cannot open daxis_params.dat\n";
while(<DAXIS>)
{
@word = split /\s+/;
if($word[0] =~ /x_convert=/) {$x_convert = $word[1];}
if($word[0] =~ /z_convert=/) {$z_convert = $word[1];}
if($word[0] =~ /theta_convert=/) {$theta_convert = $word[1];}
if($word[0] =~ /sin_theta=/) {$sin_theta = $word[1];}
if($word[0] =~ /cos_theta=/) {$cos_theta = $word[1];}
}
#print "$x_convert $z_convert\n";
#print "$theta_convert $sin_theta $cos_theta\n";
close(DAXIS);
open(OUT, ">VDC.dat") || die "Cannot open file for output\n";
setcoord(0., 0., $rotate_angle);
for($i = 0; $i < 13; $i++)
{
$X = $x[$i] + $shift_up;
$Z = $z[$i];
printoutput($X, $Z);
}
close(OUT);
open(OUT, ">VDC2.dat") || die "Cannot open file for output\n";
for($i = 0; $i < 13; $i++)
{
$X = $x[$i] + $shift_up + $VDC2_offset_x;
$Z = $z[$i] + $VDC2_offset_z;
printoutput($X, $Z);
}
close(OUT);
sub transinit {
my($x_in, $z_in) = @_;
my(@ret);
$ret[0] = $x_in*$cos_theta - $z_in*$sin_theta + $x_convert;
$ret[1] = $x_in*$sin_theta + $z_in*$cos_theta + $z_convert;
return(@ret);
}
sub setcoord {
my($x_in, $z_in, $th_in) = @_;
($x_convert, $z_convert) = transinit($x_in, $z_in);
$theta_convert += $th_in;
while($theta_convert > 180.) { $theta_convert -= 360.; }
while($theta_convert < -180.) { $theta_convert += 360.; }
$theta_rad = $theta_convert * $PI180;
$sin_theta = sin($theta_rad);
$cos_theta = cos($theta_rad);
}
sub printoutput {
my($x, $z) = @_;
my($x_out, $z_out) = transinit($x,$z);
my($xx,$yy);
$xx = -$x_out;
$yy = $z_out;
printf OUT "%.4f %.4f\n",$xx, $yy;
}