/[PAMELA software]/DarthVader/TrackerLevel2/src/F77/readallparam.f
ViewVC logotype

Annotation of /DarthVader/TrackerLevel2/src/F77/readallparam.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Fri Aug 17 16:47:16 2007 UTC (17 years, 3 months ago) by pam-fi
Branch: MAIN
Changes since 1.4: +2 -2 lines
*** empty log message ***

1 mocchiut 1.1
2     ************************************************************
3    
4     subroutine readvkmask
5    
6     include 'commontracker.f'
7     include 'calib.f'
8     include 'common_c2f.f' !<<<< C2F
9    
10     c2f_error = 0
11    
12 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print *
13     if(verbose)print *
14 mocchiut 1.1 $ ,c2f_path(1:c2f_pathlen)//'trk-maskvk.dat'
15     open(10,
16     $ FILE=c2f_path(1:c2f_pathlen)//'trk-maskvk.dat' !<<<< C2F
17     $ ,STATUS='OLD'
18     $ ,IOSTAT=iostat
19     $ )
20     if(iostat.ne.0)then
21 pam-fi 1.2 c if(C2F_DEBUG.eq.1)
22     if(debug)
23 mocchiut 1.1 $ print*,'READVKMASK: *** Error opening file ***'
24     c2f_error = 1
25     return
26     endif
27     do iv=1,nviews
28     read(10,*
29     $ ,IOSTAT=iostat
30     $ )
31     $ (mask_vk(iv,i),i=1,24)
32     if(iostat.ne.0)then
33 pam-fi 1.2 c if(C2F_DEBUG.eq.1)
34     if(debug)
35 mocchiut 1.1 $ print*,'READVKMASK: *** Error reading file ***'
36     c2f_error = 1
37     goto 1000
38     endif
39     enddo
40     1000 close(10)
41     1001 continue
42     return
43     end
44    
45    
46     ************************************************************
47    
48     subroutine readmipparam
49    
50     include 'commontracker.f'
51     include 'calib.f'
52     include 'common_c2f.f' !<<<< C2F
53    
54     character*60 fname_param
55     c2f_error = 0
56     201 format('trk-LADDER',i1,'-mip.dat')
57     do ilad=1,nladders_view
58     write(fname_param,201)ilad
59 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print *
60     if(VERBOSE)print *
61 mocchiut 1.1 $ ,c2f_path(1:c2f_pathlen)!<<<< C2F
62     $ //fname_param(1:LNBLNK(fname_param))
63     open(10,
64     $ FILE=c2f_path(1:c2f_pathlen)!<<<< C2F
65     $ //fname_param(1:LNBLNK(fname_param))
66     $ ,STATUS='OLD'
67     $ ,IOSTAT=iostat
68     $ )
69     if(iostat.ne.0)then
70 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print*
71     if(DEBUG)print*
72 mocchiut 1.1 $ ,'READMIPPARAM: *** Error opening file *** '
73     c2f_error = 1
74     return
75     endif
76     do iv=1,nviews
77     read(10,*
78     $ ,IOSTAT=iostat
79     $ )pip,
80     $ mip(int(pip),ilad)
81     if(iostat.ne.0)then
82     c2f_error = 1
83     goto 1000
84     endif
85     enddo
86     1000 close(10)
87     enddo
88    
89     return
90     end
91     *** * * * *** * * * *** * * * *** * * * *** * * * *** * * * ***
92     subroutine readchargeparam
93    
94    
95     include 'commontracker.f'
96     include 'calib.f'
97     include 'common_c2f.f' !<<<< C2F
98     character*60 fname_param
99     c2f_error = 0
100     201 format('charge-l',i1,'.dat')
101     do ilad=1,nladders_view
102     write(fname_param,201)ilad
103 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print *
104     if(VERBOSE)print *
105 mocchiut 1.1 $ ,c2f_path(1:c2f_pathlen)!<<<< C2F
106     $ //fname_param(1:LNBLNK(fname_param))
107     open(10,
108     $ FILE=c2f_path(1:c2f_pathlen)!<<<< C2F
109     $ //fname_param(1:LNBLNK(fname_param))
110     $ ,STATUS='OLD'
111     $ ,IOSTAT=iostat
112     $ )
113     if(iostat.ne.0)then
114     c2f_error = 1
115     return
116     endif
117     do ip=1,nplanes
118     read(10,*
119     $ ,IOSTAT=iostat
120     $ )pip,
121     $ kch(ip,ilad),cch(ip,ilad),sch(ip,ilad)
122     if(iostat.ne.0)then
123     c2f_error = 1
124     goto 1000
125     endif
126     enddo
127     1000 close(10)
128     enddo
129    
130     return
131     end
132     *** * * * *** * * * *** * * * *** * * * *** * * * *** * * * ***
133     subroutine readetaparam
134     * -----------------------------------------
135     * read eta2,3,4 calibration parameters
136     * and fill variables:
137     *
138     * eta2(netabin,nladders_view,nviews)
139     * eta3(2*netabin,nladders_view,nviews)
140     * eta4(2*netabin,nladders_view,nviews)
141     *
142     include 'commontracker.f'
143     include 'calib.f'
144     include 'common_c2f.f' !<<<< C2F
145    
146     character*40 fname_binning
147     character*40 fname_param
148    
149    
150     c2f_error = 0
151    
152 pam-fi 1.3 * ======================================================
153     * read ANGULAR BINNING info
154     * ======================================================
155 mocchiut 1.1 fname_binning='binning.dat'
156 pam-fi 1.2 c if(C2F_DEBUG.eq.1)
157     if(VERBOSE)
158 mocchiut 1.1 $ print *
159     $ ,c2f_path(1:c2f_pathlen) !<<<< C2F
160     $ //fname_binning(1:LNBLNK(fname_binning))
161     open(10,
162     $ FILE=c2f_path(1:c2f_pathlen) !<<<< C2F
163     $ //fname_binning(1:LNBLNK(fname_binning))
164     $ ,STATUS='OLD'
165     $ ,IOSTAT=iostat
166     $ )
167     if(iostat.ne.0)then
168 pam-fi 1.2 c if(C2F_DEBUG.eq.1)
169     if(DEBUG)
170 mocchiut 1.1 $ print*,'READETAPARAM: *** Error in opening file *** '
171     c2f_error = 1
172     return
173     endif
174     c print*,'---- ANGULAR BINNING ----'
175     c print*,'Bin - angL - angR'
176     101 format(i2,' ',f6.2,' ',f6.2)
177     xnn=0
178     do ibin=1,nangmax
179     read(10,*
180     $ ,IOSTAT=iostat
181     $ )xnn,angL(ibin),angR(ibin)
182     if(iostat.ne.0)goto 1000
183     c write(*,101)int(xnn),angL(ibin),angR(ibin)
184     enddo
185     1000 nangbin=int(xnn)
186     close(10)
187     if(nangbin.eq.0)c2f_error = 1
188     c print*,'-------------------------'
189     c print*,nangbin
190    
191    
192    
193 pam-fi 1.3 * ======================================================
194     * read eta2-eta3-eta4 parameters
195     * ======================================================
196 mocchiut 1.1 do ieta=2,4 !loop on eta 2,3,4
197     200 format(' Opening eta',i1,' files...')
198 pam-fi 1.2 c if(C2F_DEBUG.eq.1)write(*,200)ieta
199     if(VERBOSE)write(*,200)ieta
200 mocchiut 1.1
201     201 format('eta',i1,'-bin',i1,'-l',i1,'.dat')
202     202 format('eta',i1,'-bin',i2,'-l',i1,'.dat')
203     do iang=1,nangbin
204     do ilad=1,nladders_view
205     if(iang.lt.10)write(fname_param,201)ieta,iang,ilad
206     if(iang.ge.10)write(fname_param,202)ieta,iang,ilad
207     open(10,
208     c $ FILE=eta_parampath(1:eta_pathlen) !<<<< C2F
209     $ FILE=c2f_path(1:c2f_pathlen) !<<<< C2F
210     $ //fname_param(1:LNBLNK(fname_param))
211     $ ,STATUS='OLD'
212     $ ,IOSTAT=iostat
213     $ )
214     if(iostat.ne.0)then
215 pam-fi 1.2 c if(C2F_DEBUG.eq.1)
216     if(DEBUG)
217 mocchiut 1.1 $ print*,'READETAPARAM: ** Error opening file ** '
218     $ ,c2f_path(1:c2f_pathlen)
219     $ //fname_param(1:LNBLNK(fname_param))
220     c2f_error = 1
221 pam-fi 1.3 c return
222     goto 2001
223 mocchiut 1.1 endif
224     netaval=0
225     do ival=1,netavalmax
226     if(ieta.eq.2)read(10,*
227     $ ,IOSTAT=iostat
228     $ )
229     $ eta2(ival,iang),
230     $ (feta2(ival,iv,ilad,iang),iv=1,nviews)
231     if(ieta.eq.3)read(10,*
232     $ ,IOSTAT=iostat
233     $ )
234     $ eta3(ival,iang),
235     $ (feta3(ival,iv,ilad,iang),iv=1,nviews)
236     if(ieta.eq.4)read(10,*
237     $ ,IOSTAT=iostat
238     $ )
239     $ eta4(ival,iang),
240     $ (feta4(ival,iv,ilad,iang),iv=1,nviews)
241     if(iostat.ne.0)then
242     if(netaval.eq.0)then
243 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print*,'READETAPARAM: '
244     if(DEBUG)print*,'READETAPARAM: '
245 mocchiut 1.1 $ //'*** Error reading file *** '
246     $ ,c2f_path(1:c2f_pathlen)
247     $ //fname_param(1:LNBLNK(fname_param))
248     $ ,' (netaval=',netaval,')'
249     c2f_error = 1
250     endif
251     goto 2000
252     endif
253     netaval=netaval+1
254     enddo
255     2000 close(10)
256 pam-fi 1.3 2001 continue
257 mocchiut 1.1 * print*,'... done'
258     enddo
259     enddo
260    
261     enddo !end loop on eta 2,3,4
262    
263 pam-fi 1.3 * ======================================================
264     * read landi correction
265     * ======================================================
266     if(VERBOSE)print*,' Opening landi-correction files...'
267    
268     301 format('lcorr-l',i1,'.dat')
269     do ilad=1,nladders_view
270    
271     write(fname_param,301)ilad
272     open(10,
273     $ FILE=c2f_path(1:c2f_pathlen)
274     $ //fname_param(1:LNBLNK(fname_param))
275     $ ,STATUS='OLD'
276     $ ,IOSTAT=iostat
277     $ )
278     if(iostat.ne.0)then
279     if(.true.)
280     $ print*,'READETAPARAM: ** Error opening file ** '
281     $ ,c2f_path(1:c2f_pathlen)
282     $ //fname_param(1:LNBLNK(fname_param))
283 pam-fi 1.5 c c2f_error = 1 !tolto solo temporaneamente
284 pam-fi 1.3 c return
285     goto 3001
286     endif
287    
288     do iang=1,nangbin
289    
290     read(10,*,IOSTAT=iostat)
291     $ ii,aal,aar,(fcorr(iv,ilad,iang),iv=1,nviews)
292    
293     write(*,*)
294     $ ii,aal,aar,(fcorr(iv,ilad,iang),iv=1,nviews)
295    
296     if(ii.ne.iang)print*,'parametri eta incasinati'
297     if(aal.ne.angl(iang))print*,'parametri eta incasinati'
298     if(aar.ne.angr(iang))print*,'parametri eta incasinati'
299    
300     if(iostat.ne.0)then
301     if(.true.)
302     $ print*,'READETAPARAM: '
303     $ //'*** Error reading file *** '
304     $ ,c2f_path(1:c2f_pathlen)
305     $ //fname_param(1:LNBLNK(fname_param))
306 pam-fi 1.5 c2f_error = 1
307 pam-fi 1.3 goto 3000
308     endif
309    
310     enddo !end loop on angular bins
311     3000 close(10)
312     3001 continue
313    
314     enddo ! end loop on ladders
315 mocchiut 1.1
316     return
317     end
318    
319     *************************************************************************
320     subroutine readalignparam
321    
322     include 'commontracker.f'
323     include 'common_mech.f'
324     include 'common_align.f'
325     include 'common_c2f.f'
326    
327     character*50 fname_param
328     integer sensor
329     c character*120 cmd1
330     c character*120 cmd2
331    
332     c2f_error = 0
333     call mech_sensor
334     do ip=1,nplanes
335     fitz(ip)=z_mech_sensor(ip,1,1)*0.1 !cm
336     * gets planes mechanical z positions
337     * (in mm) and sets them in micrometers
338     enddo
339    
340    
341     100 format('parameters_l',i1,'s',i1,'.dat')
342    
343     do ilad=1,nladders_view
344     do is=1,2
345    
346     write(fname_param,100)ilad,is
347 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print *
348     if(VERBOSE)print *
349 mocchiut 1.1 $ ,c2f_path(1:c2f_pathlen)
350     $ //fname_param
351    
352     open(10,
353     $ FILE=
354     $ c2f_path(1:c2f_pathlen)
355     $ //fname_param(1:LNBLNK(fname_param))
356     $ ,STATUS='OLD',IOSTAT=iostat
357     $ )
358     if(iostat.ne.0)then
359     c2f_error = 1
360     return
361     endif
362    
363     do ip=1,nplanes
364     *
365     * NB! NB! NB! NB! NB!
366     * The file labelled for example "l1s1" include the alignment
367     * parameters of the column of sensors:
368     *
369     * PLANE LADDER SENSOR
370     * -------------------
371     * 1 1 2
372     * 2 1 1
373     * 3 1 1
374     * 4 1 1
375     * 5 1 1
376     * 6 1 1
377     *
378     * This is becouse the plane 1 (bottom plane) is up-side-down
379     *
380     sensor=is
381     if(ip.eq.1)sensor=mod(is,2)+1
382     read(10,*)omega(ip,ilad,sensor)
383     read(10,*)beta(ip,ilad,sensor)
384     read(10,*)gamma(ip,ilad,sensor)
385    
386     c N.B. I convert angles from microradiants to radiant
387     omega(ip,ilad,sensor)=omega(ip,ilad,sensor)/1.d6
388     beta(ip,ilad,sensor)=beta(ip,ilad,sensor)/1.d6
389     gamma(ip,ilad,sensor)=gamma(ip,ilad,sensor)/1.d6
390    
391     read(10,*)dx(ip,ilad,sensor)
392     read(10,*)dy(ip,ilad,sensor)
393     read(10,*)dz(ip,ilad,sensor)
394     enddo
395    
396     close(10)
397     enddo
398     enddo
399    
400     return
401     end
402    
403     c------------------------------------------------------------------------
404    
405     c NB: le coordinate in mech_pos.dat sono calcolate a partire da alcuni dati
406     c contenuti in commontracker.f. forse si puo' evitare mech_pos.dat e mettere
407     c tutto in commontracker.f
408    
409    
410     subroutine mech_sensor
411     c !it reads sensors coordinates (in PAMELA reference
412     c ! frame) from a text file and it uses them to fill
413     c ! x/y/z_mech_sensor variables, taking into account
414     c ! last plane inversion
415    
416     include 'commontracker.f'
417     include 'common_tracks.f'
418     include 'common_c2f.f'
419    
420     real xvec(nladders_view),yvec(2),zvec(nplanes)
421    
422     c2f_error = 0
423    
424 pam-fi 1.2 c if(C2F_DEBUG.eq.1)print *
425     if(VERBOSE)print *
426 mocchiut 1.1 $ ,c2f_path(1:c2f_pathlen)//'mech_pos.dat'
427     open(10
428     $ ,FILE=
429     $ c2f_path(1:c2f_pathlen)//'mech_pos.dat'
430     $ ,IOSTAT=iostat)
431     c !sensors centres coordinates in mm in
432     c ! PAMELA reference frame:
433     c ! the first plane is the one with lowest Z (the one
434     c ! nearest the calorimeter)
435     c ! the first ladder is the one with lowest X (the
436     c ! one on which the first X strip is)
437     c ! the first sensor is the one with lowest Y (the
438     c ! one on which the first Y strip is) for planes
439     c ! 2..6. for plane 1 the first sensor has higher Y
440    
441     if(iostat.ne.0)then
442     c2f_error = 1
443     return
444     endif
445    
446     read(10,*) xvec
447     read(10,*) yvec
448     read(10,*) zvec
449    
450     do i=1,nplanes
451     do j=1,nladders_view
452     do k=1,2
453     x_mech_sensor(i,j,k)=xvec(j)
454     y_mech_sensor(i,j,k)=yvec(k)
455     z_mech_sensor(i,j,k)=zvec(i)
456     if(i.eq.1) then !y coordinates of first plane (11th view) are
457     y_mech_sensor(i,j,k)=-yvec(k) ! exchanged due to last plane inversion
458     endif
459     enddo
460     enddo
461     enddo
462    
463     close(10)
464    
465     ! *** INIZIO DEBUG ***
466     c$$$ do i=1,6
467     c$$$ do j=1,3
468     c$$$ do k=1,2
469     c$$$c j=1
470     c$$$ print*,x_mech_sensor(i,j,k)
471     c$$$ print*,y_mech_sensor(i,j,k)
472     c$$$ print*,z_mech_sensor(i,j,k)
473     c$$$ enddo
474     c$$$ enddo
475     c$$$ print*,' '
476     c$$$ enddo
477     ! *** FINE DEBUG ***
478    
479    
480     return
481     end
482     c------------------------------------------------------------------------
483    

  ViewVC Help
Powered by ViewVC 1.1.23