* FIELD.KUMAC - based on USER$1:[FISYAK.MAGNET] * from 25 March 1998 * Comments added by R.Breedon ************************************************* * Procedure to * 1) prepare and (optionally) plot * an RZ file of the CMS magnetic field. * 2) prepare a TZ file for insertion in CMSIM * 3) verify and plot the field with CMSIM *------------------------------------------------ * 1. Obtain field map from Wisconsin (via Dick Loveless); * versions as of April 1998 are FIELD80, FIELD90 and FIELD100 * 2. Edit FIELD***.MAP to remove non-essential words * and numbers from the beginning and end of the file; * Save as FIELD***.DAT * 3. Read FIELD***.DAT into PAW as an ntuple (field#read) * 4. Book 2-D histograms and output .rz file (field#book) * 5. If you want to make plots, use field#magnet, for instance: * zone 1 2 * exec field#magnet * hi/pl 111 colz * exec field#vers90 (Outline of steel: no vers100 yet) * hi/pl 112 colz ************************************************** * READ the magnet field data file into PAW * (be sure to check that the data file format matches * the format statement) * The .dat file is identified by the parameter "map" * macro read map=100 hi/del * vec/del * nt/cre 100 'mag field' 6 ! ! id r z br bz aphi *nt/read 100 field[map].dat (f8.0,1x,5g12.5) nt/read 100 field[map].dat (f7.0,1x,5g12.5) return ************************************************** * BOOK histograms * The file (version) is identified by the paramter "vrs" * Other paramters (the number of Z points (nz) and the * number of R points (nr)) I hope are standardized * by the program at Wisconsin. * macro book nz=240 nr=180 vrs=100 2 400 'entries' [nr] 00.0 9.0 [nz] 0.0 12.0 2 401 'Br' [nr] 00.0 9.0 [nz] 0.0 12.0 2 402 'Bz' [nr] 00.0 9.0 [nz] 0.0 12.0 *2 403 'A[f]' [nr] 00.0 9.0 [nz] 0.0 12.0 nt/proj 400 100.z%r nt/proj 401 100.z%r 100.+10.*br nt/proj 402 100.z%r 100.+10.*bz *nt/proj 403 100.z%r 100.+aphi hi/op/sub 401 400 301 1 100. hi/op/sub 402 400 302 1 100. *hi/op/sub 403 400 303 1 100. hi/op/div 301 400 101 hi/op/div 302 400 102 *hi/op/div 303 400 103 vec/cre en([nr],[nz]) vec/cre br([nr],[nz]) vec/cre bz([nr],[nz]) hi/get/cont 400 en hi/get/cont 101 br hi/get/cont 102 bz APPLIcation COMIS QUIT * PARAMETER (NZ=120, NR=90, NN=1) PARAMETER (NZ=240, NR=180, NN=1) REAL EN2(NR,NZ) VECTOR EN(NR,NZ) VECTOR BR(NR,NZ) VECTOR BZ(NR,NZ) * do ip = 1, 2 CALL VZERO (EN2, NZ*NR) DO J = 1, NZ DO I = 1, NR IF (EN(I,J) .EQ. 0.) THEN SUM = 0.0 BRSUM = 0.0 BZSUM = 0.0 * TYPE 'empty', I, J DO I1 = MAX(1,I-nn), MIN(I+nn,NR) DO J1 = J, J IF (EN(I1,J1) .GT. 0.0) THEN SUM = SUM + 1 BRSUM = BRSUM + BR(I1,J1) BZSUM = BZSUM + BZ(I1,J1) * type i1, j1, BR(I1,J1), BZ(I1,J1) END IF END DO END DO IF (SUM .GT. 0.0) THEN BR(I,J) = BRSUM/SUM BZ(I,J) = BZSUM/SUM EN2(I,J) = SUM * type br(i,j), bz(i,j), sum ELSE * TYPE 'BinZ', I, J, ' No entries' END IF ELSE EN2(I,J) = EN(I,J) END IF END DO END DO CALL UCOPY (EN2, EN, NR*NZ) DO I = 1, NR DO J = 1, NZ IF (EN(I,J) .EQ. 0.) THEN * TYPE 'empty', I, J SUM = 0.0 BRSUM = 0.0 BZSUM = 0.0 DO I1 = I, I DO J1 = MAX(1,J-nn), MIN(J+nn,NZ) IF (EN(I1,J1) .GT. 0.0) THEN SUM = SUM + 1 BRSUM = BRSUM + BR(I1,J1) BZSUM = BZSUM + BZ(I1,J1) * type i1, j1, BR(I1,J1), BZ(I1,J1) END IF END DO END DO IF (SUM .GT. 0.0) THEN BR(I,J) = BRSUM/SUM BZ(I,J) = BZSUM/SUM EN2(I,J) = SUM * type br(i,j), bz(i,j), sum ELSE * TYPE 'BinR', I, J, ' No entries' END IF ELSE EN2(I,J) = EN(I,J) END IF END DO END DO end do END QUIT hi/cop 101 111 hi/cop 102 112 hi/put/cont 111 br hi/put/cont 112 bz hi/file 1 field_map[vrs].rz ! n hrout * close 1 return ************************************************** macro booko nz=120 nr=90 2 400 'entries' [nr] 00.0 9.0 [nz] 0.0 12.0 2 401 'Br' [nr] 00.0 9.0 [nz] 0.0 12.0 2 402 'Bz' [nr] 00.0 9.0 [nz] 0.0 12.0 *2 403 'A[f]' [nr] 00.0 9.0 [nz] 0.0 12.0 nt/proj 400 100.z%r nt/proj 401 100.z%r 100.+10.*br nt/proj 402 100.z%r 100.+10.*bz *nt/proj 403 100.z%r 100.+aphi hi/op/sub 401 400 301 1 100. hi/op/sub 402 400 302 1 100. *hi/op/sub 403 400 303 1 100. hi/op/div 301 400 101 hi/op/div 302 400 102 *hi/op/div 303 400 103 vec/cre en([nr],[nz]) vec/cre br([nr],[nz]) vec/cre bz([nr],[nz]) hi/get/cont 400 en hi/get/cont 101 br hi/get/cont 102 bz APPLIcation COMIS QUIT PARAMETER (NZ=120, NR=90, NN=1) REAL EN2(NR,NZ) VECTOR EN(NR,NZ) VECTOR BR(NR,NZ) VECTOR BZ(NR,NZ) * do ip = 1, 2 CALL VZERO (EN2, NZ*NR) DO J = 1, NZ DO I = 1, NR IF (EN(I,J) .EQ. 0.) THEN SUM = 0.0 BRSUM = 0.0 BZSUM = 0.0 * TYPE 'empty', I, J DO I1 = MAX(1,I-nn), MIN(I+nn,NR) DO J1 = J, J IF (EN(I1,J1) .GT. 0.0) THEN SUM = SUM + 1 BRSUM = BRSUM + BR(I1,J1) BZSUM = BZSUM + BZ(I1,J1) * type i1, j1, BR(I1,J1), BZ(I1,J1) END IF END DO END DO IF (SUM .GT. 0.0) THEN BR(I,J) = BRSUM/SUM BZ(I,J) = BZSUM/SUM EN2(I,J) = SUM * type br(i,j), bz(i,j), sum ELSE * TYPE 'BinZ', I, J, ' No entries' END IF ELSE EN2(I,J) = EN(I,J) END IF END DO END DO CALL UCOPY (EN2, EN, NR*NZ) DO I = 1, NR DO J = 1, NZ IF (EN(I,J) .EQ. 0.) THEN * TYPE 'empty', I, J SUM = 0.0 BRSUM = 0.0 BZSUM = 0.0 DO I1 = I, I DO J1 = MAX(1,J-nn), MIN(J+nn,NZ) IF (EN(I1,J1) .GT. 0.0) THEN SUM = SUM + 1 BRSUM = BRSUM + BR(I1,J1) BZSUM = BZSUM + BZ(I1,J1) * type i1, j1, BR(I1,J1), BZ(I1,J1) END IF END DO END DO IF (SUM .GT. 0.0) THEN BR(I,J) = BRSUM/SUM BZ(I,J) = BZSUM/SUM EN2(I,J) = SUM * type br(i,j), bz(i,j), sum ELSE * TYPE 'BinR', I, J, ' No entries' END IF ELSE EN2(I,J) = EN(I,J) END IF END DO END DO end do END QUIT hi/cop 101 111 hi/cop 102 112 hi/put/cont 111 br hi/put/cont 112 bz hi/file 1 field_map[vrs].rz ! n hrout * close 1 return ************************************************** MACRO MAGNET VRS=100 nr=180 nz=240 hi/del * vec/del * nrz = [nr]*[nz] vec/cre vec([nrz]) r hi/file 1 field_map[vrs].rz ! u OPT NSTA ZONE 1 2 VEC/CRE BR([nr],[nz]) R VEC/CRE BZ([nr],[nz]) R hi/get/cont 111 br hi/get/cont 112 bz *if vrs=3t then * sc = $format(30.0/bz(1,1),f15.5) *else sc = $format(40.0/bz(1,1),f15.5) *endif scale = [sc] sigma bz=[scale]*bz sigma br=[scale]*br for/file 41 br000[VRS].dat vec/cop br vec call vecwr.for([nrz]) close 41 for/file 41 bz000[VRS].dat vec/cop bz vec call vecwr.for([nrz]) close 41 vec/write br br00n[VRS].dat '(8f10.5)' vec/write bZ bZ00n[VRS].dat '(8f10.5)' hi/put/cont 111 br hi/put/cont 112 bz *hrout 111 *hrout 112 CLOSE 1 RETURN ************************************************** macro vers70 | iron as boxes vs R (x) and Z (y) * r1 r2 z1 z2 box 2.950 3.650 0.000 6.500 | solenoid box 3.075 3.280 0.170 3.030 | coil box 3.075 3.280 3.330 6.190 | coil * r position and z position of barrel iron: box 4.440 4.735 0.000 1.268 | RY1 1st layer box 5.195 5.885 0.000 1.268 | RY2 box 6.280 6.970 0.000 1.268 | RY3 * box 4.440 4.735 1.468 4.004 | RY1 2nd layer box 5.195 5.885 1.468 4.004 | RY2 box 6.280 6.970 1.468 4.004 | RY3 * box 4.440 4.735 4.124 6.660 | RY1 3rd layer box 5.195 5.885 4.124 6.660 | RY2 box 6.280 6.970 4.124 6.660 | RY3 vec/crea rrf1(5) r .725 .785 6.970 6.970 .725 | r position of endcap iron: RF1 vec/crea rrf2(5) r .848 .907 6.970 6.970 .848 | r position of endcap iron: RF2 vec/crea rrf3(5) r .970 1.000 6.970 6.970 .970 | r position of endcap iron: RF3 vec/crea rnos(5) r .625 .723 2.8 2.8 .625 | r position of endcap iron: nose vec/crea zrf1(5) r 7.26 7.86 7.86 7.26 7.26 | z position of endcap iron: RF1 vec/crea zrf2(5) r 8.49 9.09 9.09 8.49 8.49 | z position of endcap iron: RF2 vec/crea zrf3(5) r 9.72 10.02 10.02 9.72 9.72 | z position of endcap iron: RF3 vec/crea znos(5) r 6.26 7.24 7.24 6.26 6.26 | z position of endcap iron: nose pline 5 rrf1 zrf1 pline 5 rrf2 zrf2 pline 5 rrf3 zrf3 pline 5 rnos znos return ************************************************** macro vers76 | iron as boxes vs R (x) and Z (y) * r1 r2 z1 z2 box 2.950 3.650 0.000 6.500 | solenoid box 3.075 3.280 0.170 3.030 | coil box 3.075 3.280 3.330 6.190 | coil * r position and z position of barrel iron: box 4.440 4.940 0.000 1.268 | RY1 1st layer box 5.400 5.900 0.000 1.268 | RY2 box 6.295 6.795 0.000 1.268 | RY3 * box 4.440 4.940 1.468 4.004 | RY1 2nd layer box 5.400 5.900 1.468 4.004 | RY2 box 6.295 6.795 1.468 4.004 | RY3 * box 4.440 4.940 4.124 6.660 | RY1 3rd layer box 5.400 5.900 4.124 6.660 | RY2 box 6.295 6.795 4.124 6.660 | RY3 vec/crea rrf1(5) r .725 .785 6.970 6.970 .725 | r position of endcap iron: RF1 vec/crea rrf2(5) r .848 .907 6.970 6.970 .848 | r position of endcap iron: RF2 vec/crea rrf3(5) r .970 1.000 6.970 6.970 .970 | r position of endcap iron: RF3 vec/crea rnos(5) r .625 .723 2.8 2.8 .625 | r position of endcap iron: nose vec/crea zrf1(5) r 7.26 7.86 7.86 7.26 7.26 | z position of endcap iron: RF1 vec/crea zrf2(5) r 8.49 9.09 9.09 8.49 8.49 | z position of endcap iron: RF2 vec/crea zrf3(5) r 9.72 10.02 10.02 9.72 9.72 | z position of endcap iron: RF3 vec/crea znos(5) r 6.26 7.24 7.24 6.26 6.26 | z position of endcap iron: nose pline 5 rrf1 zrf1 pline 5 rrf2 zrf2 pline 5 rrf3 zrf3 pline 5 rnos znos return ************************************************** macro vers80 | iron as boxes vs R (x) and Z (y) * r1 r2 z1 z2 box 2.950 3.650 0.000 6.500 | solenoid box 3.075 3.280 0.170 3.030 | coil box 3.075 3.280 3.330 6.190 | coil * r position and z position of barrel iron: box 4.590 4.885 0.000 1.268 | RY1 1st layer box 5.345 5.975 0.000 1.268 | RY2 box 6.370 7.000 0.000 1.268 | RY3 * box 4.590 4.885 1.468 4.004 | RY1 2nd layer box 5.345 5.975 1.468 4.004 | RY2 box 6.370 7.000 1.468 4.004 | RY3 * box 4.590 4.885 4.124 6.660 | RY1 3rd layer box 5.345 5.975 4.124 6.660 | RY2 box 6.370 7.000 4.124 6.660 | RY3 vec/crea rrf1(5) r .725 .785 6.970 6.970 .725 | r position of endcap iron: RF1 vec/crea rrf2(5) r .848 .907 6.970 6.970 .848 | r position of endcap iron: RF2 vec/crea rrf3(5) r .970 1.000 6.970 6.970 .970 | r position of endcap iron: RF3 vec/crea rnos(5) r .625 .723 2.8 2.8 .625 | r position of endcap iron: nose vec/crea zrf1(5) r 7.26 7.86 7.86 7.26 7.26 | z position of endcap iron: RF1 vec/crea zrf2(5) r 8.49 9.09 9.09 8.49 8.49 | z position of endcap iron: RF2 vec/crea zrf3(5) r 9.72 10.02 10.02 9.72 9.72 | z position of endcap iron: RF3 vec/crea znos(5) r 6.26 7.24 7.24 6.26 6.26 | z position of endcap iron: nose pline 5 rrf1 zrf1 pline 5 rrf2 zrf2 pline 5 rrf3 zrf3 pline 5 rnos znos return ************************************************** macro vers90 | iron as boxes vs R (x) and Z (y) * r1 r2 z1 z2 box 2.950 3.650 0.000 6.500 | solenoid box 3.180 3.480 0.000 6.190 | coil * r position and z position of barrel iron: box 4.590 4.885 0.000 1.268 | YB1 1st layer box 5.345 5.975 0.000 1.268 | YB2 box 6.370 7.000 0.000 1.268 | YB3 * box 4.590 4.885 1.468 4.004 | YB1 2nd layer box 5.345 5.975 1.468 4.004 | YB2 box 6.370 7.000 1.468 4.004 | YB3 * box 4.590 4.885 4.124 6.660 | YB1 3rd layer box 5.345 5.975 4.124 6.660 | YB2 box 6.370 7.000 4.124 6.660 | YB3 vec/crea rrf1(5) r .726 .785 6.970 6.970 .726 | r position of endcap iron: YE1 vec/crea rrf2(5) r .848 .907 6.970 6.970 .848 | r position of endcap iron: YE2 vec/crea rrf3(5) r .970 1.000 6.970 6.970 .970 | r position of endcap iron: YE3 vec/crea zrf1(5) r 7.26 7.86 7.86 7.26 7.26 | z position of endcap iron: YE1 vec/crea zrf2(5) r 8.49 9.09 9.09 8.49 8.49 | z position of endcap iron: YE2 vec/crea zrf3(5) r 9.72 10.02 10.02 9.72 9.72 | z position of endcap iron: YE3 vec/crea rnos(5) r .634 .726 2.633 2.63 .634 | r position of endcap iron: nose vec/crea znos(5) r 6.340 7.26 7.26 6.34 6.34 | z position of endcap iron: nose pline 5 rrf1 zrf1 pline 5 rrf2 zrf2 pline 5 rrf3 zrf3 pline 5 rnos znos return