/[PAMELA software]/tracker/ground/source/magnet/read_B_outer.f
ViewVC logotype

Contents of /tracker/ground/source/magnet/read_B_outer.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed Mar 8 15:00:37 2006 UTC (18 years, 11 months ago) by pam-fi
Branch: MAIN, trk-ground
CVS Tags: R3v02, HEAD
Changes since 1.1: +0 -0 lines
First CVS release of tracker ground software (R3v02) 

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
22
23 implicit double precision (a-h,o-z)
24 include '../common/common_B_outer.f'
25
26
27 c------------------------------------------------------------------------
28 c
29 c local variables
30 c
31 c------------------------------------------------------------------------
32
33 character*64 Bmap_file !magnetic field file name
34 parameter (lun_Bmap_file=66) !magnetic field map file id number
35
36 parameter (ntpl_Bmap=20) !ntuple identifier
37
38 REAL PFX(3),FX,DFX, !Bx field component coordinates in m, value and error in T
39 $ PFY(3),FY,DFY
40 $ ,PFZ(3),FZ,DFZ
41 INTEGER INDEX(3) !point index
42
43 COMMON /PAWCR4/ INDEX,PFX,FX,DFX,PFY,FY,DFY,PFZ,FZ,DFZ
44
45
46 c------------------------------------------------------------------------
47 c
48 c *** FIRST MAP ***
49 c
50 c------------------------------------------------------------------------
51
52 c------------------------------------------------------------------------
53 c
54 c initialization and map file opening
55 c
56 c------------------------------------------------------------------------
57
58 c print*,' '
59 c print*,' '
60
61 Bmap_file='External_top_map_n4_150402.rz'
62
63 c opens magnetic field map first file
64 print *,'Opening file: ',Bmap_file
65 call HROPEN
66 $ (lun_Bmap_file,'Bmap','./bin-aux/'//Bmap_file,'P',1024,istat)
67 if(istat.ne.0) goto 21
68
69
70 call HRIN(ntpl_Bmap,9999,0) !puts B map ntuple in memory
71
72 c call HPRNTU(ntpl_Bmap)
73 call HBNAME(ntpl_Bmap,' ',0,'$CLEAR')
74 call HBNAME(ntpl_Bmap,'INDEX',index,'$SET')
75 call HBNAME(ntpl_Bmap,'BX',pfx,'$SET')
76 call HBNAME(ntpl_Bmap,'BY',pfy,'$SET')
77 call HBNAME(ntpl_Bmap,'BZ',pfz,'$SET')
78
79
80 c------------------------------------------------------------------------
81 c
82 c reads events and fills variables
83 c
84 c------------------------------------------------------------------------
85
86 call HNOENT(ntpl_Bmap,iemax) !number of events
87
88 c initializes measurement grid edges
89 do ic=1,3
90 poxmax(ic)=0.
91 poxmin(ic)=0.
92 poymax(ic)=0.
93 poymin(ic)=0.
94 pozmax(ic)=0.
95 pozmin(ic)=0.
96 enddo
97
98
99 do iev=1,iemax !event loop
100
101 call HGNT(ntpl_Bmap,iev,ierr) !reads event
102 if(ierr.ne.0) goto 22
103
104 c the output consists of matrices for coordinates, B components values
105 c and errors:
106 c e.g. px1(4,2) = X coordinate of the point with index = 4 along X,
107 c in which By (=2) component has been measured
108 c e.g. b1(3,23,4,1) = Bx (=1) component value, measured in the point with
109 c indexes = 3,23,4 along X, Y and Z
110
111 c Bx component
112 pox(index(1),1) = pfx(1)
113 if(pox(index(1),1).lt.poxmin(1)) poxmin(1)=pox(index(1),1)
114 if(pox(index(1),1).gt.poxmax(1)) poxmax(1)=pox(index(1),1)
115 poy(index(2),1) = pfx(2)
116 if(poy(index(2),1).lt.poymin(1)) poymin(1)=poy(index(2),1)
117 if(poy(index(2),1).gt.poymax(1)) poymax(1)=poy(index(2),1)
118 poz(index(3),1) = pfx(3)
119 if(poz(index(3),1).lt.pozmin(1)) pozmin(1)=poz(index(3),1)
120 if(poz(index(3),1).gt.pozmax(1)) pozmax(1)=poz(index(3),1)
121
122 bo(index(1),index(2),index(3),1) = fx
123
124
125 c By component
126 pox(index(1),2) = pfy(1)
127 if(pox(index(1),2).lt.poxmin(2)) poxmin(2)=pox(index(1),2)
128 if(pox(index(1),2).gt.poxmax(2)) poxmax(2)=pox(index(1),2)
129 poy(index(2),2) = pfy(2)
130 if(poy(index(2),2).lt.poymin(2)) poymin(2)=poy(index(2),2)
131 if(poy(index(2),2).gt.poymax(2)) poymax(2)=poy(index(2),2)
132 poz(index(3),2) = pfy(3)
133 if(poz(index(3),2).lt.pozmin(2)) pozmin(2)=poz(index(3),2)
134 if(poz(index(3),2).gt.pozmax(2)) pozmax(2)=poz(index(3),2)
135
136 bo(index(1),index(2),index(3),2) = fy
137
138
139 c Bz component
140 pox(index(1),3) = pfz(1)
141 if(pox(index(1),3).lt.poxmin(3)) poxmin(3)=pox(index(1),3)
142 if(pox(index(1),3).gt.poxmax(3)) poxmax(3)=pox(index(1),3)
143 poy(index(2),3) = pfz(2)
144 if(poy(index(2),3).lt.poymin(3)) poymin(3)=poy(index(2),3)
145 if(poy(index(2),3).gt.poymax(3)) poymax(3)=poy(index(2),3)
146 poz(index(3),3) = pfz(3)
147 if(poz(index(3),3).lt.pozmin(3)) pozmin(3)=poz(index(3),3)
148 if(poz(index(3),3).gt.pozmax(3)) pozmax(3)=poz(index(3),3)
149
150 bo(index(1),index(2),index(3),3) = fz
151
152 enddo
153
154
155 c------------------------------------------------------------------------
156 c
157 c closes files
158 c
159 c------------------------------------------------------------------------
160
161 call HREND('Bmap')
162 close(lun_Bmap_file)
163
164
165 c------------------------------------------------------------------------
166 c
167 c no error exit
168 c
169 c------------------------------------------------------------------------
170
171 c$$$ print*,' '
172 c$$$ print*,'MAGNETIC FIELD SUCCESSFULLY READ'
173 c$$$ print*,' '
174 c$$$ print*,' '
175
176 goto 9000 !happy ending
177
178 c------------------------------------------------------------------------
179 c
180 c magnetic field map file opening error
181 c
182 c------------------------------------------------------------------------
183
184 21 continue
185
186 print*,' '
187 print*,'read_B_inner: ERROR OPENING MAGNETIC FIELD MAP FILE: '
188 $ ,Bmap_file
189 print*,' '
190 print*,' '
191
192 goto 9000 !the end
193
194
195 c------------------------------------------------------------------------
196 c
197 c ntuple event reading error
198 c
199 c------------------------------------------------------------------------
200
201 22 continue
202
203 print*,' '
204 print*,'read_B_inner: ERROR WHILE READING NTUPLE, AT EVENT
205 $ : ',iev
206 print*,' '
207 print*,' '
208
209 goto 9000 !the end
210
211
212 c------------------------------------------------------------------------
213 c
214 c exit
215 c
216 c------------------------------------------------------------------------
217
218 9000 continue
219
220 return
221 end

  ViewVC Help
Powered by ViewVC 1.1.23