subroutine event_display_apply_align(length, . xraw_local, yraw_local, zraw_local, iplane, iview, . xaligned, yaligned, zaligned) c c this routine takes raw coordinates (eg, x = strip number * pitch) and c transforms them into the telescope coordinate system. c zraw_local is zero on the detector. More generally, zraw_local is c the distance from the point in question to the detector plane, taken c perpendicular to the detector surface. c c c George Gollin, g-gollin@uiuc.edu, 1999. c c #include "event_display.inc" c c dimension xraw_local(*), yraw_local(*), zraw_local(*) dimension xaligned(*), yaligned(*), zaligned(*) c c c centers of planes, in local-to-plane coordinates: dimension xcenter_plane_raw(max_planes) dimension ycenter_plane_raw(max_planes) dimension zcenter_plane_raw(max_planes) c c logical first_time logical debug c c data first_time /.true./ data iamcalled /0/ data maxdump /10/ data debug /.false./ c c c ************************************************************************* c if(first_time) then first_time=.false. c c calculate where the center of the detector is, in a coordinate system c local to the detector: c c strip planes: do ipl=1,4 call event_display_rowcol_to_raw( . number_strips/2, number_strips/2, ipl, . xcenter_plane_raw(ipl), ycenter_plane_raw(ipl)) zcenter_plane_raw(ipl)=0. c c if there are an even number of strips/pixels, need to move the point c by half the pitch: if(mod(number_strips,2).eq.0) then xcenter_plane_raw(ipl)=xcenter_plane_raw(ipl) - . strip_pitch/2. ycenter_plane_raw(ipl)=ycenter_plane_raw(ipl) - . strip_pitch/2. end if c end do c c c pixel detector 1: ipl=ipldem1 call event_display_rowcol_to_raw( . number_rows_dem1/2, number_cols_dem1/2, ipl, . xcenter_plane_raw(ipl), ycenter_plane_raw(ipl)) zcenter_plane_raw(ipl)=0. if(mod(number_rows_dem1,2).eq.0) . xcenter_plane_raw(ipl)=xcenter_plane_raw(ipl) - . dem1_pitch_fine/2. if(mod(number_cols_dem1,2).eq.0) . ycenter_plane_raw(ipl)=ycenter_plane_raw(ipl) - . dem1_pitch_coarse/2. c c c pixel detector 2: ipl=ipldem2 call event_display_rowcol_to_raw( . number_rows_dem2/2, number_cols_dem2/2, ipl, . xcenter_plane_raw(ipl), ycenter_plane_raw(ipl)) zcenter_plane_raw(ipl)=0. if(mod(number_rows_dem2,2).eq.0) . xcenter_plane_raw(ipl)=xcenter_plane_raw(ipl) - . dem2_pitch_fine/2. if(mod(number_cols_dem2,2).eq.0) . ycenter_plane_raw(ipl)=ycenter_plane_raw(ipl) - . dem2_pitch_coarse/2. c c c pixel marebo detector: ipl=ipldemm call event_display_rowcol_to_raw( . number_rows_demm/2, number_cols_demm/2, ipl, . xcenter_plane_raw(ipl), ycenter_plane_raw(ipl)) zcenter_plane_raw(ipl)=0. if(mod(number_rows_demm,2).eq.0) . xcenter_plane_raw(ipl)=xcenter_plane_raw(ipl) - . demm_pitch_fine/2. if(mod(number_cols_demm,2).eq.0) . ycenter_plane_raw(ipl)=ycenter_plane_raw(ipl) - . demm_pitch_coarse/2. c c c pixel module of detectors: ipl=ipldemd call event_display_rowcol_to_raw( . number_rows_demd/2, number_cols_demd/2, ipl, . xcenter_plane_raw(ipl), ycenter_plane_raw(ipl)) zcenter_plane_raw(ipl)=0. if(mod(number_rows_demd,2).eq.0) . xcenter_plane_raw(ipl)=xcenter_plane_raw(ipl) - . demd_pitch_fine/2. c note the use of ...coarse2 here, not ...coarse since the edge column is c a fat column, with 600 micron pitch. if(mod(number_cols_demd,2).eq.0) . ycenter_plane_raw(ipl)=ycenter_plane_raw(ipl) - . demd_pitch_coarse2/2. c c end if c c c ************************************************************************* c c iamcalled=iamcalled+1 debug=debug .and. iamcalled.lt.maxdump c c if(debug) then print *,' ' print *,' apply_align_GG: plane is ',iplane print *,' xraw_local, yraw_local are ', . xraw_local(1), yraw_local(1) print *,' zraw_local is ', . zraw_local(1) end if c c if(length .le.0) then print *,' zero length! ouch!' return end if c c c loop over the array of input coordinates: do ipoint=1,length c c now calculate where the raw hit is in a coordinate system with axes c parallel to the detector raw coordinate axes, but with origin at the c detector center. c c space point: xa=xraw_local(ipoint) - xcenter_plane_raw(iplane) ya=yraw_local(ipoint) - ycenter_plane_raw(iplane) za=zraw_local(ipoint) - zcenter_plane_raw(iplane) c c c c now call a rotation routine: call event_display_rotate(xa, ya, za, iplane, . xd, yd, zd) c c c The (xd, yd, zd) system has its axes parallel to the lab system, but has c its origin at the beam centroid in the detector plane. c if(debug) then print *,' before, after rotations: ' print *,' xa, ya, za', xa, ya, za print *,' xd, yd, zd', xd, yd, zd end if c c c At this point, a hit in any plane at the position of the detector center c will have (xd,yd) = (0,0). I need to translate this point so that the c a hit at the center of the first strip plane would be at (x,y,z) = c (strip_pitch*(number_strips/2.0), strip_pitch*(number_strips/2.0), 0.). c (This would put one corner of a perfectly aligned first plane at (0,0,0).) c c if(debug) then print *,' ipoint, iplane are ', ipoint, iplane end if c c c for z, need to put detector center at nominal z... calculate offsets c that we'll include: if(iview .eq. 1) then xnom=xplane_x0(iplane) ynom=0. znom=xplane_z0(iplane) else xnom=0. ynom=yplane_y0(iplane) znom=yplane_z0(iplane) end if c c c notice use of plane 1 as the index, not iplane, since xd is in a frame c with origin at detector center, but lab frame has origin at plane 1's corner. xaligned(ipoint)=xd + xcenter_plane_raw(1) + xnom c yaligned(ipoint)=yd + ycenter_plane_raw(1) + ynom c c in the z value returned, include a certain amount of exaggeration c relative to the true value in order to make pixel planes more visible c when rotated. if(iplane .eq. ipldem1 .or. iplane .eq. ipldem2 .or. . iplane .eq. ipldemm .or. iplane .eq. ipldemd) then zaligned(ipoint)=znom + zd * factor_dem_z_exaggerate else zaligned(ipoint)=znom + zd end if c c if(debug) then print *,' after translations: ' print *,' xaligned, yaligned, zaligned' print *, xaligned(ipoint), yaligned(ipoint), . zaligned(ipoint) print *,' ' end if c c end of loop over points in the arrays: end do c return end