/[PAMELA software]/eventviewer/ground/src/read_B_outer.for
ViewVC logotype

Annotation of /eventviewer/ground/src/read_B_outer.for

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Dec 6 10:12:57 2005 UTC (19 years ago) by mocchiut
Branch point for: MAIN, EventViewer
Initial revision

1 mocchiut 1.1 *************************************************************************
2     *
3     * Subroutine read_B_outer.f
4     *
5     * it reads from rz files the two magnetic field maps taken inside the
6     * spectrometer cavity and fills the variables in common_B_inner.f
7     *
8     * needs:
9     * - ../common/common_B_outer.f common file for the outer magnetic field map
10     * - .rz map files in ./ containing coordinates of measured points, Bx, By
11     * and Bz components + errors
12     *
13     * output variables: (see common_B_outer.f)
14     * - pxo(nx,3)
15     * - pyo(ny,3)
16     * - pzo(nz,3)
17     * - bo(nx,ny,nz,3)
18     *
19     *************************************************************************
20    
21     subroutine read_B_outer(idata_dir)
22     include './common_B_outer.for'
23     c implicit double precision (a-h,o-z)
24     CHARACTER*250 idata_dir
25     integer lastnb
26     c integer lung
27    
28    
29    
30     c------------------------------------------------------------------------
31     c
32     c local variables
33     c
34     c------------------------------------------------------------------------
35    
36     character*264 Bmap_file !magnetic field file name
37     parameter (lun_Bmap_file=66) !magnetic field map file id number
38     parameter (ntpl_Bmap=20) !ntuple identifier
39    
40     REAL PFX(3),FX,DFX !Bx field component coordinates in m, value and error in T
41     REAL PFY(3),FY,DFY
42     REAL PFZ(3),FZ,DFZ
43     INTEGER INDEX(3) !point index
44     COMMON /ntplvars/ INDEX,PFX,FX,DFX,PFY,FY,DFY,PFZ,FZ,DFZ
45     c save/ntplvars/
46     c
47     parameter(NWPAWC=200000)
48     common/pawc/hmem(NWPAWC)
49     c save/pawc/
50     common/quest/iquest(100)
51     c save/quest/
52     c
53     c call hlimit(nwpawc)
54    
55     c------------------------------------------------------------------------
56     c
57     c *** FIRST MAP ***
58     c
59     c------------------------------------------------------------------------
60    
61     c------------------------------------------------------------------------
62     c
63     c initialization and map file opening
64     c
65     c------------------------------------------------------------------------
66    
67     c print*,' '
68     c print*,' '
69     c idata_dir='/wizard3/pamela/sw/calib/External_top_map_n4_150402.rz'
70     c lastnb = length(idata_dir)
71     c lung = lastnb+2
72     lastnb = length(idata_dir)-1
73     c idata_dir(lastnb:lastnb+29)='/External_top_map_n4_150402.rz'
74     c lung = lastnb+29
75     Bmap_file = idata_dir(1:lastnb)//'/External_top_map_n4_150402.rz'
76     c goto 9000
77     c Bmap_file='measure_n3_290302.rz'
78    
79     c$$$ cmd1='cp $TRK_GRND/source/magnet/'
80     c$$$ $ //Bmap_file(1:LNBLNK(Bmap_file))//' .'
81     c$$$ call system(cmd1)
82    
83     c opens magnetic field map first file
84     c print *,'Opening file: -',idata_dir(1:lung),'- '
85     print *,'Opening file: ',Bmap_file(1:lastnb+30)
86    
87     c Bmap_file='External_top_map_n4_150402.rz'
88    
89     c opens magnetic field map first file
90     c print *,'Opening file: ',Bmap_file
91     c
92     call HROPEN
93     $ (lun_Bmap_file,'Bmap',Bmap_file,'P',1024,istat)
94     c $ (lun_Bmap_file,'Bmap',idata_dir(1:lung),'P',1024,istat)
95     c $ (lun_Bmap_file,'Bmap',idata_dir(1:lung),' ',1024,istat)
96     c $ (lun_Bmap_file,'Bmap','./bin-aux/'//Bmap_file,'P',1024,istat)
97     if(istat.ne.0) goto 21
98    
99    
100     call HRIN(ntpl_Bmap,9999,0) !puts B map ntuple in memory
101    
102     c call HPRNTU(ntpl_Bmap)
103     call HBNAME(ntpl_Bmap,' ',0,'$CLEAR')
104     call HBNAME(ntpl_Bmap,'INDEX',index,'$SET')
105     call HBNAME(ntpl_Bmap,'BX',pfx,'$SET')
106     call HBNAME(ntpl_Bmap,'BY',pfy,'$SET')
107     call HBNAME(ntpl_Bmap,'BZ',pfz,'$SET')
108    
109    
110     c------------------------------------------------------------------------
111     c
112     c reads events and fills variables
113     c
114     c------------------------------------------------------------------------
115    
116     call HNOENT(ntpl_Bmap,iemax) !number of events
117    
118     c initializes measurement grid edges
119     do ic=1,3
120     poxmax(ic)=0.
121     poxmin(ic)=0.
122     poymax(ic)=0.
123     poymin(ic)=0.
124     pozmax(ic)=0.
125     pozmin(ic)=0.
126     enddo
127    
128    
129     do iev=1,iemax !event loop
130    
131     call HGNT(ntpl_Bmap,iev,ierr) !reads event
132     if(ierr.ne.0) goto 22
133    
134     c the output consists of matrices for coordinates, B components values
135     c and errors:
136     c e.g. px1(4,2) = X coordinate of the point with index = 4 along X,
137     c in which By (=2) component has been measured
138     c e.g. b1(3,23,4,1) = Bx (=1) component value, measured in the point with
139     c indexes = 3,23,4 along X, Y and Z
140    
141     c Bx component
142     pox(index(1),1) = dble(pfx(1))
143     if(pox(index(1),1).lt.poxmin(1)) poxmin(1)=pox(index(1),1)
144     if(pox(index(1),1).gt.poxmax(1)) poxmax(1)=pox(index(1),1)
145     poy(index(2),1) = dble(pfx(2))
146     if(poy(index(2),1).lt.poymin(1)) poymin(1)=poy(index(2),1)
147     if(poy(index(2),1).gt.poymax(1)) poymax(1)=poy(index(2),1)
148     poz(index(3),1) = dble(pfx(3))
149     if(poz(index(3),1).lt.pozmin(1)) pozmin(1)=poz(index(3),1)
150     if(poz(index(3),1).gt.pozmax(1)) pozmax(1)=poz(index(3),1)
151    
152     bo(index(1),index(2),index(3),1) = dble(fx)
153    
154    
155     c By component
156     pox(index(1),2) = dble(pfy(1))
157     if(pox(index(1),2).lt.poxmin(2)) poxmin(2)=pox(index(1),2)
158     if(pox(index(1),2).gt.poxmax(2)) poxmax(2)=pox(index(1),2)
159     poy(index(2),2) = dble(pfy(2))
160     if(poy(index(2),2).lt.poymin(2)) poymin(2)=poy(index(2),2)
161     if(poy(index(2),2).gt.poymax(2)) poymax(2)=poy(index(2),2)
162     poz(index(3),2) = dble(pfy(3))
163     if(poz(index(3),2).lt.pozmin(2)) pozmin(2)=poz(index(3),2)
164     if(poz(index(3),2).gt.pozmax(2)) pozmax(2)=poz(index(3),2)
165    
166     bo(index(1),index(2),index(3),2) = dble(fy)
167    
168    
169     c Bz component
170     pox(index(1),3) = dble(pfz(1))
171     if(pox(index(1),3).lt.poxmin(3)) poxmin(3)=pox(index(1),3)
172     if(pox(index(1),3).gt.poxmax(3)) poxmax(3)=pox(index(1),3)
173     poy(index(2),3) = dble(pfz(2))
174     if(poy(index(2),3).lt.poymin(3)) poymin(3)=poy(index(2),3)
175     if(poy(index(2),3).gt.poymax(3)) poymax(3)=poy(index(2),3)
176     poz(index(3),3) = dble(pfz(3))
177     if(poz(index(3),3).lt.pozmin(3)) pozmin(3)=poz(index(3),3)
178     if(poz(index(3),3).gt.pozmax(3)) pozmax(3)=poz(index(3),3)
179    
180     bo(index(1),index(2),index(3),3) = dble(fz)
181    
182     enddo
183    
184    
185     c------------------------------------------------------------------------
186     c
187     c closes files
188     c
189     c------------------------------------------------------------------------
190     call HCDIR('//Bmap',' ')
191     call HREND('Bmap')
192     close(lun_Bmap_file)
193    
194    
195     c------------------------------------------------------------------------
196     c
197     c no error exit
198     c
199     c------------------------------------------------------------------------
200    
201     c print*,' '
202     c print*,'MAGNETIC FIELD SUCCESSFULLY READ'
203     c print*,' '
204     c print*,' '
205    
206     goto 9000 !happy ending
207    
208     c------------------------------------------------------------------------
209     c
210     c magnetic field map file opening error
211     c
212     c------------------------------------------------------------------------
213    
214     21 continue
215    
216     print*,' '
217     print*,'read_B_inner: ERROR OPENING MAGNETIC FIELD MAP FILE: '
218     c $ ,idata_dir(1:lung)
219     $ ,Bmap_file
220     print*,' '
221     print*,' '
222    
223     goto 9000 !the end
224    
225    
226     c------------------------------------------------------------------------
227     c
228     c ntuple event reading error
229     c
230     c------------------------------------------------------------------------
231    
232     22 continue
233    
234     print*,' '
235     print*,'read_B_inner: ERROR WHILE READING NTUPLE, AT EVENT
236     $ : ',iev
237     print*,' '
238     print*,' '
239    
240     goto 9000 !the end
241    
242    
243     c------------------------------------------------------------------------
244     c
245     c exit
246     c
247     c------------------------------------------------------------------------
248    
249     9000 continue
250    
251     return
252     end

  ViewVC Help
Powered by ViewVC 1.1.23