1 |
pam-fi |
1.1 |
************************************************************ |
2 |
|
|
|
3 |
|
|
subroutine readmipparam |
4 |
|
|
|
5 |
|
|
include '../common/commontracker.f' |
6 |
|
|
include '../common/calib.f' |
7 |
|
|
|
8 |
|
|
character*60 fname_param |
9 |
|
|
201 format('trk-LADDER',i1,'-mip.dat') |
10 |
|
|
do ilad=1,nladders_view |
11 |
|
|
write(fname_param,201)ilad |
12 |
|
|
print *,'Opening file: ',fname_param |
13 |
|
|
open(10, |
14 |
|
|
$ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) |
15 |
|
|
$ ,STATUS='UNKNOWN' |
16 |
|
|
$ ,IOSTAT=iostat |
17 |
|
|
$ ) |
18 |
|
|
if(iostat.ne.0)then |
19 |
|
|
print*,'READMIPPARAM: *** Error in opening file ***' |
20 |
|
|
return |
21 |
|
|
endif |
22 |
|
|
do iv=1,nviews |
23 |
|
|
read(10,* |
24 |
|
|
$ ,IOSTAT=iostat |
25 |
|
|
$ )pip, |
26 |
|
|
$ mip(int(pip),ilad) |
27 |
|
|
c print*,ilad,iv,pip,mip(int(pip),ilad) |
28 |
|
|
enddo |
29 |
|
|
close(10) |
30 |
|
|
enddo |
31 |
|
|
|
32 |
|
|
return |
33 |
|
|
end |
34 |
|
|
*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** |
35 |
|
|
subroutine readchargeparam |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
include '../common/commontracker.f' |
39 |
|
|
include '../common/calib.f' |
40 |
|
|
|
41 |
|
|
character*60 fname_param |
42 |
|
|
201 format('charge-l',i1,'.dat') |
43 |
|
|
do ilad=1,nladders_view |
44 |
|
|
write(fname_param,201)ilad |
45 |
|
|
print *,'Opening file: ',fname_param |
46 |
|
|
open(10, |
47 |
|
|
$ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) |
48 |
|
|
$ ,STATUS='UNKNOWN' |
49 |
|
|
$ ,IOSTAT=iostat |
50 |
|
|
$ ) |
51 |
|
|
if(iostat.ne.0)then |
52 |
|
|
print*,'READCHARGEPARAM: *** Error in opening file ***' |
53 |
|
|
return |
54 |
|
|
endif |
55 |
|
|
do ip=1,nplanes |
56 |
|
|
read(10,* |
57 |
|
|
$ ,IOSTAT=iostat |
58 |
|
|
$ )pip, |
59 |
|
|
$ kch(ip,ilad),cch(ip,ilad),sch(ip,ilad) |
60 |
|
|
c print*,ilad,ip,pip,kch(ip,ilad), |
61 |
|
|
c $ cch(ip,ilad),sch(ip,ilad) |
62 |
|
|
enddo |
63 |
|
|
close(10) |
64 |
|
|
enddo |
65 |
|
|
|
66 |
|
|
return |
67 |
|
|
end |
68 |
|
|
*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** |
69 |
|
|
subroutine readetaparam |
70 |
|
|
* ----------------------------------------- |
71 |
|
|
* read eta2,3,4 calibration parameters |
72 |
|
|
* and fill variables: |
73 |
|
|
* |
74 |
|
|
* eta2(netabin,nladders_view,nviews) |
75 |
|
|
* eta3(2*netabin,nladders_view,nviews) |
76 |
|
|
* eta4(2*netabin,nladders_view,nviews) |
77 |
|
|
* |
78 |
|
|
include '../common/commontracker.f' |
79 |
|
|
include '../common/calib.f' |
80 |
|
|
|
81 |
|
|
character*40 fname_binning |
82 |
|
|
character*40 fname_param |
83 |
|
|
c character*120 cmd1 |
84 |
|
|
c character*120 cmd2 |
85 |
|
|
|
86 |
|
|
|
87 |
|
|
******retrieve ANGULAR BINNING info |
88 |
|
|
fname_binning='binning.dat' |
89 |
|
|
print *,'Opening file: ',fname_binning |
90 |
|
|
open(10, |
91 |
|
|
$ FILE='./bin-aux/'//fname_binning(1:LNBLNK(fname_binning)) |
92 |
|
|
$ ,STATUS='UNKNOWN' |
93 |
|
|
$ ,IOSTAT=iostat |
94 |
|
|
$ ) |
95 |
|
|
if(iostat.ne.0)then |
96 |
|
|
print*,'READETAPARAM: *** Error in opening file ***' |
97 |
|
|
return |
98 |
|
|
endif |
99 |
|
|
print*,'---- ANGULAR BINNING ----' |
100 |
|
|
print*,'Bin - angL - angR' |
101 |
|
|
101 format(i2,' ',f6.2,' ',f6.2) |
102 |
|
|
do ibin=1,nangmax |
103 |
|
|
read(10,* |
104 |
|
|
$ ,IOSTAT=iostat |
105 |
|
|
$ )xnn,angL(ibin),angR(ibin) |
106 |
|
|
if(iostat.ne.0)goto 1000 |
107 |
|
|
write(*,101)int(xnn),angL(ibin),angR(ibin) |
108 |
|
|
enddo |
109 |
|
|
1000 nangbin=int(xnn) |
110 |
|
|
close(10) |
111 |
|
|
print*,'-------------------------' |
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
do ieta=2,4 !loop on eta 2,3,4 |
116 |
|
|
******retrieve correction parameters |
117 |
|
|
200 format(' Opening eta',i1,' files...') |
118 |
|
|
write(*,200)ieta |
119 |
|
|
|
120 |
|
|
201 format('eta',i1,'-bin',i1,'-l',i1,'.dat') |
121 |
|
|
202 format('eta',i1,'-bin',i2,'-l',i1,'.dat') |
122 |
|
|
do iang=1,nangbin |
123 |
|
|
do ilad=1,nladders_view |
124 |
|
|
if(iang.lt.10)write(fname_param,201)ieta,iang,ilad |
125 |
|
|
if(iang.ge.10)write(fname_param,202)ieta,iang,ilad |
126 |
|
|
c print *,'Opening file: ',fname_param |
127 |
|
|
open(10, |
128 |
|
|
$ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) |
129 |
|
|
$ ,STATUS='UNKNOWN' |
130 |
|
|
$ ,IOSTAT=iostat |
131 |
|
|
$ ) |
132 |
|
|
if(iostat.ne.0)then |
133 |
|
|
print*,'READETAPARAM: *** Error in opening file ***' |
134 |
|
|
return |
135 |
|
|
endif |
136 |
|
|
do ival=1,netavalmax |
137 |
|
|
if(ieta.eq.2)read(10,* |
138 |
|
|
$ ,IOSTAT=iostat |
139 |
|
|
$ ) |
140 |
|
|
$ eta2(ival,iang), |
141 |
|
|
$ (feta2(ival,iv,ilad,iang),iv=1,nviews) |
142 |
|
|
if(ieta.eq.3)read(10,* |
143 |
|
|
$ ,IOSTAT=iostat |
144 |
|
|
$ ) |
145 |
|
|
$ eta3(ival,iang), |
146 |
|
|
$ (feta3(ival,iv,ilad,iang),iv=1,nviews) |
147 |
|
|
if(ieta.eq.4)read(10,* |
148 |
|
|
$ ,IOSTAT=iostat |
149 |
|
|
$ ) |
150 |
|
|
$ eta4(ival,iang), |
151 |
|
|
$ (feta4(ival,iv,ilad,iang),iv=1,nviews) |
152 |
|
|
if(iostat.ne.0)then |
153 |
|
|
netaval=ival-1 |
154 |
|
|
c$$$ if(eta2(1,iang).ne.-eta2(netaval,iang)) |
155 |
|
|
c$$$ $ print*,'**** ERROR on parameters !!! ****' |
156 |
|
|
goto 2000 |
157 |
|
|
endif |
158 |
|
|
enddo |
159 |
|
|
2000 close(10) |
160 |
|
|
* print*,'... done' |
161 |
|
|
enddo |
162 |
|
|
enddo |
163 |
|
|
|
164 |
|
|
enddo !end loop on eta 2,3,4 |
165 |
|
|
|
166 |
|
|
|
167 |
|
|
return |
168 |
|
|
end |
169 |
|
|
|
170 |
|
|
*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** |
171 |
|
|
subroutine readalignparam |
172 |
|
|
|
173 |
|
|
include '../common/commontracker.f' |
174 |
|
|
include '../common/common_align.f' |
175 |
|
|
|
176 |
|
|
character*50 fname_param |
177 |
|
|
integer sensor |
178 |
|
|
c character*120 cmd1 |
179 |
|
|
c character*120 cmd2 |
180 |
|
|
|
181 |
|
|
c 100 format('../common/align_param/parameters_l',i1,'s',i1,'.dat') |
182 |
|
|
100 format('parameters_l',i1,'s',i1,'.dat') |
183 |
|
|
|
184 |
|
|
do ilad=1,nladders_view |
185 |
|
|
do is=1,2 |
186 |
|
|
|
187 |
|
|
write(fname_param,100)ilad,is |
188 |
|
|
c$$$ cmd1='cp $TRK_GRND/source/common/align_param/' |
189 |
|
|
c$$$ $ //fname_param(1:LNBLNK(fname_param))//' .' |
190 |
|
|
c$$$ call system(cmd1) |
191 |
|
|
print *,'Opening file: ',fname_param |
192 |
|
|
|
193 |
|
|
open(10, |
194 |
|
|
$ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) |
195 |
|
|
$ ,STATUS='UNKNOWN' |
196 |
|
|
$ ) |
197 |
|
|
|
198 |
|
|
do ip=1,nplanes |
199 |
|
|
* |
200 |
|
|
* NB! NB! NB! NB! NB! |
201 |
|
|
* The file labelled for example "l1s1" include the alignment |
202 |
|
|
* parameters of the column of sensors: |
203 |
|
|
* |
204 |
|
|
* PLANE LADDER SENSOR |
205 |
|
|
* ------------------- |
206 |
|
|
* 1 1 2 |
207 |
|
|
* 2 1 1 |
208 |
|
|
* 3 1 1 |
209 |
|
|
* 4 1 1 |
210 |
|
|
* 5 1 1 |
211 |
|
|
* 6 1 1 |
212 |
|
|
* |
213 |
|
|
* This is becouse the plane 1 (bottom plane) is up-side-down |
214 |
|
|
* |
215 |
|
|
sensor=is |
216 |
|
|
if(ip.eq.1)sensor=mod(is,2)+1 |
217 |
|
|
read(10,*)omega(ip,ilad,sensor) |
218 |
|
|
read(10,*)beta(ip,ilad,sensor) |
219 |
|
|
read(10,*)gamma(ip,ilad,sensor) |
220 |
|
|
|
221 |
|
|
c N.B. I convert angles from microradiants to radiant |
222 |
|
|
omega(ip,ilad,sensor)=omega(ip,ilad,sensor)/1.d6 |
223 |
|
|
beta(ip,ilad,sensor)=beta(ip,ilad,sensor)/1.d6 |
224 |
|
|
gamma(ip,ilad,sensor)=gamma(ip,ilad,sensor)/1.d6 |
225 |
|
|
|
226 |
|
|
read(10,*)dx(ip,ilad,sensor) |
227 |
|
|
read(10,*)dy(ip,ilad,sensor) |
228 |
|
|
read(10,*)dz(ip,ilad,sensor) |
229 |
|
|
enddo |
230 |
|
|
|
231 |
|
|
close(10) |
232 |
|
|
c$$$ cmd2='rm -f ' |
233 |
|
|
c$$$ $ //fname_param(1:LNBLNK(fname_param)) |
234 |
|
|
c$$$ call system(cmd2) |
235 |
|
|
enddo |
236 |
|
|
enddo |
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
end |
241 |
|
|
c------------------------------------------------------------------------ |
242 |
|
|
|
243 |
|
|
c NB: le coordinate in mech_pos.dat sono calcolate a partire da alcuni dati |
244 |
|
|
c contenuti in commontracker.f. forse si puo' evitare mech_pos.dat e mettere |
245 |
|
|
c tutto in commontracker.f |
246 |
|
|
|
247 |
|
|
|
248 |
|
|
subroutine mech_sensor |
249 |
|
|
c !it reads sensors coordinates (in PAMELA reference |
250 |
|
|
c ! frame) from a text file and it uses them to fill |
251 |
|
|
c ! x/y/z_mech_sensor variables, taking into account |
252 |
|
|
c ! last plane inversion |
253 |
|
|
|
254 |
|
|
include './commontracker.f' |
255 |
|
|
include './common_tracks.f' |
256 |
|
|
|
257 |
|
|
real xvec(nladders_view),yvec(2),zvec(nplanes) |
258 |
|
|
|
259 |
|
|
integer id !file identifier |
260 |
|
|
logical od !.true. if the specified unit is connected to a file |
261 |
|
|
|
262 |
|
|
do id=20,100,1 !opens the file using a free file id |
263 |
|
|
inquire (id, opened=od) |
264 |
|
|
if(.not.od) goto 666 |
265 |
|
|
enddo |
266 |
|
|
666 continue |
267 |
|
|
|
268 |
|
|
c open(id,FILE='../common/mech_pos.dat') !sensors centres coordinates in mm in |
269 |
|
|
c open(id,FILE='source/common/mech_pos.dat') |
270 |
|
|
c call system('cp $TRK_GRND/source/common/mech_pos.dat .') |
271 |
|
|
print *,'Opening file: mech_pos.dat' |
272 |
|
|
open(id,FILE='./bin-aux/mech_pos.dat',IOSTAT=iostat) |
273 |
|
|
c !sensors centres coordinates in mm in |
274 |
|
|
c ! PAMELA reference frame: |
275 |
|
|
c ! the first plane is the one with lowest Z (the one |
276 |
|
|
c ! nearest the calorimeter) |
277 |
|
|
c ! the first ladder is the one with lowest X (the |
278 |
|
|
c ! one on which the first X strip is) |
279 |
|
|
c ! the first sensor is the one with lowest Y (the |
280 |
|
|
c ! one on which the first Y strip is) for planes |
281 |
|
|
c ! 2..6. for plane 1 the first sensor has higher Y |
282 |
|
|
|
283 |
|
|
if(iostat.ne.0)then |
284 |
|
|
print*,'MECH_SENSOR: *** Error in opening file ***' |
285 |
|
|
return |
286 |
|
|
endif |
287 |
|
|
|
288 |
|
|
read(id,*) xvec |
289 |
|
|
read(id,*) yvec |
290 |
|
|
read(id,*) zvec |
291 |
|
|
|
292 |
|
|
do i=1,nplanes |
293 |
|
|
do j=1,nladders_view |
294 |
|
|
do k=1,2 |
295 |
|
|
x_mech_sensor(i,j,k)=xvec(j) |
296 |
|
|
y_mech_sensor(i,j,k)=yvec(k) |
297 |
|
|
z_mech_sensor(i,j,k)=zvec(i) |
298 |
|
|
if(i.eq.1) then !y coordinates of first plane (11th view) are |
299 |
|
|
y_mech_sensor(i,j,k)=-yvec(k) ! exchanged due to last plane inversion |
300 |
|
|
endif |
301 |
|
|
enddo |
302 |
|
|
enddo |
303 |
|
|
enddo |
304 |
|
|
|
305 |
|
|
close(id) |
306 |
|
|
c call system('rm -f mech_pos.dat') |
307 |
|
|
|
308 |
|
|
c$$$ ! *** INIZIO DEBUG *** |
309 |
|
|
c$$$ do i=1,6 |
310 |
|
|
c$$$c do j=1,3 |
311 |
|
|
c$$$ do k=1,2 |
312 |
|
|
c$$$ j=1 |
313 |
|
|
c$$$c print*,x_mech_sensor(1,j,k) |
314 |
|
|
c$$$ print*,y_mech_sensor(i,j,k) |
315 |
|
|
c$$$c print*,z_mech_sensor(i,j,k) |
316 |
|
|
c$$$ enddo |
317 |
|
|
c$$$c enddo |
318 |
|
|
c$$$ print*,' ' |
319 |
|
|
c$$$ enddo |
320 |
|
|
c$$$ ! *** FINE DEBUG *** |
321 |
|
|
|
322 |
|
|
|
323 |
|
|
return |
324 |
|
|
end |
325 |
|
|
|