-
Notifications
You must be signed in to change notification settings - Fork 1
/
adjust.c
203 lines (179 loc) · 5.18 KB
/
adjust.c
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <stdio.h>
#include <math.h>
#define N 50 /* number of runs */
#define TRA 0 /* transverse */
#define DIS 1 /* dispersive */
#define UNCOR 0 /* uncorrected */
#define COR 1 /* corrected */
/* this program adjusts the output of the position finding run of RAYTR
to take in account of the tilt of the mirror in x position of the
focal point for the dispersive direction. */
float fpx[60][2][2],
fpy[60][2][2],
ep[60][2][2],
size[60][2][2],
radius[60];
main()
{
FILE *in,*out;
int i;
float theta,newfpx,newfpx2;
/* if( !(in=fopen("eff1.dat","r")) )
{
printf("unable to open 'eff1.dat'.\n");
exit(1);
}
for(i=0;i<N;i++)
{
fscanf(in,"%f %f %f %f ",&(fpx[i][TRA][UNCOR]),
&(fpy[i][TRA][UNCOR]),
&(ep[i][TRA][UNCOR]),
&(size[i][TRA][UNCOR]) );
fscanf(in,"%f %f %f %f ",&(fpx[i][TRA][COR]),
&(fpy[i][TRA][COR]),
&(ep[i][TRA][COR]),
&(size[i][TRA][COR]) );
fscanf(in,"\n");
}
for(i=0;i<N;i++)
{
fscanf(in,"%f %f %f %f ",&(fpx[i][DIS][UNCOR]),
&(fpy[i][DIS][UNCOR]),
&(ep[i][DIS][UNCOR]),
&(size[i][DIS][UNCOR]) );
fscanf(in,"%f %f %f %f ",&(fpx[i][DIS][COR]),
&(fpy[i][DIS][COR]),
&(ep[i][DIS][COR]),
&(size[i][DIS][COR]) );
fscanf(in,"\n");
}
fclose(in);
*/
if( !(in=fopen("radius.lst","r")) )
{
printf("unable to open 'radius.lst'.\n");
exit(1);
}
for(i=0;i<N;i++)
{
fscanf(in,"%f\n",radius+i);
}
fclose( in );
out = fopen("out.top","w");
fprintf(out,"set font duplex\n");
fprintf(out,"title top 'efficiency vs PMT placement'\n");
fprintf(out,"title bottom 'PMT placement (cm)'\n");
fprintf(out,"title left 'efficiency and spot size (%% of PMT size)'\n");
fprintf(out,"title 'solid: transverse, dashed: dispersive'\n");
fprintf(out,"title 'solid: corrected, dotted: uncorrected'\n");
fprintf(out,"set limits x 0 to 120 y 60 to 105\n");
/* uncorrected transverse efficiency */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][UNCOR],ep[i][TRA][UNCOR]);
}
fprintf(out,"join 1 dots\n");
/* corrected transverse efficiency */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][COR],ep[i][TRA][COR]);
}
fprintf(out,"join 1\n");
/* uncorrected transverse spot size */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][UNCOR],size[i][TRA][UNCOR]);
}
fprintf(out,"join 1 dots\n");
/* corrected transverse spot size */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][COR],size[i][TRA][COR]);
}
fprintf(out,"join 1\n");
/* uncorrected dispersive efficiency */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][UNCOR]/radius[i]);
newfpx = fpx[i][DIS][UNCOR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,ep[i][DIS][UNCOR]);
}
fprintf(out,"join 1 dotdash\n");
/* corrected dispersive efficiency */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][COR]/radius[i]);
newfpx = fpx[i][DIS][COR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,ep[i][DIS][COR]);
}
fprintf(out,"join 1 dashes\n");
/* uncorrected dispersive spot size */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][UNCOR]/radius[i]);
newfpx = fpx[i][DIS][UNCOR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,size[i][DIS][UNCOR]);
}
fprintf(out,"join 1 dotdash\n");
/* corrected dispersive spot size */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][COR]/radius[i]);
newfpx = fpx[i][DIS][COR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,size[i][DIS][COR]);
}
fprintf(out,"join 1 dashes\n");
fprintf(out,"new frame\n");
fprintf(out,"title top 'x vs y position'\n");
fprintf(out,"title bottom 'x position (cm)'\n");
fprintf(out,"title left 'y position (cm)'\n");
fprintf(out,"title 'solid: transverse, dashed: dispersive'\n");
fprintf(out,"set limits x 0 to 120 y 26 to 52\n");
fprintf(out,"title 'solid: corrected, dotted: uncorrected'\n");
/* uncorrected transverse x vs y */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][UNCOR],fpy[i][TRA][UNCOR]);
}
fprintf(out,"join 1 dots\n");
/* corrected transverse x vs y */
for(i=0;i<N;i++)
{
fprintf(out,"%f %f\n",fpx[i][TRA][COR],fpy[i][TRA][COR]);
}
fprintf(out,"join 1\n");
/* uncorrected dispersive x vs y */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][UNCOR]/radius[i]);
newfpx = fpx[i][DIS][UNCOR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,fpy[i][DIS][UNCOR]);
}
fprintf(out,"join 1 dotdash\n");
/* corrected dispersive spot x vs y */
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][COR]/radius[i]);
newfpx = fpx[i][DIS][COR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%f %f\n",newfpx,fpy[i][DIS][COR]);
}
fprintf(out,"join 1 dashes\n");
fclose(out);
out = fopen("eff1_adjusted.dat","w");
for(i=0;i<N;i++)
{
theta = asin( fpy[i][TRA][UNCOR]/radius[i]);
newfpx = fpx[i][DIS][UNCOR] + radius[i]*(1.0-cos(theta) );
theta = asin( fpy[i][TRA][COR]/radius[i]);
newfpx2 = fpx[i][DIS][COR] + radius[i]*(1.0-cos(theta) );
fprintf(out,"%6.2f %6.2f %6.2f %6.2f ",newfpx,
fpy[i][DIS][UNCOR],
ep[i][DIS][UNCOR],
size[i][DIS][UNCOR]) ;
fprintf(out,"%6.2f %6.2f %6.2f %6.2f ",newfpx2,
fpy[i][DIS][COR],
ep[i][DIS][COR],
size[i][DIS][COR]) ;
fprintf(out,"\n");
}
}