You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

CsPad Geometry

The geometry of the CSPad (Cornell SLAC Pixel Array Detector) is described elsewhere, but briefly, the exact alignment of each 2x1 (section) in each quad differs from detector to detector (there are 3 currently) and (potentially) from experiment to experiment. Optical measurements of the detector metrology has been made for each detector configuration (link needed), and cspad data array alignment have been worked out on the basis of these (link needed), sufficient for conveniently displaying the full detector image.

This document describes a different approach: The data pixels are typically stored in terms of quad-number (0-4), section-number (0-8), row and column numbers (185 x 2*194). We can compute the x,y,z coordinates of each of these pixels individually, based on the optical meterology measurements.

XtcExplorer

This is in the XtcExplorer, in it's cspad utility class CsPad. The function that computes the coordinates is called once, at class creation time, but could equally well be loaded from a numpy array (perhaps we'll do this in the future). For now this serves as an example of how to compute this pixel coordinate maps.

The coordinates

The coordinates of the optical measurements are defined by X, Y, Z, where (0,0,0) is at the nominal beam spot, and X points along the long side of section 1, Y points towards section 3 and Z points downstream. The unit of the measurements are micrometers, but the computed pixel coordinates here have been converted to pixel units (based on the average effective pixel size).

The method (python code)

import numpy as np
import scipy.ndimage.interpolation as interpol

x_coordinates = np.zeros((4,8,185,388), dtype="float")
y_coordinates = np.zeros((4,8,185,388), dtype="float")
z_coordinates = np.zeros((4,8,185,388), dtype="float")

def get_asics(bigsection):
    """Utility function
    @param bigsection   a 185 x 391 section for plotting (has a 3-pixel gap between asics)
    @return asics       the 185 x 388 section array which has the 3-pixel gap removed
    """
    asic0 = bigsection[:,0:194]
    asic1 = bigsection[:,(391-194):]
    asics = np.concatenate( (asic0,asic1), axis=1 )
    return asics

# section pixel array / grid
rr,cc = np.mgrid[0:185:185j, 0:391:391j]

# now compute the "fractional pixels"
rrfrac = rr / 185.0
ccfrac = cc / 391.0

# remove the 3-pixel gap
rrfrac = get_asics(rrfrac)
ccfrac = get_asics(ccfrac)

sec_coords = np.array([rrfrac,ccfrac])

# load data from metrology file (ignore first column)
metrology = np.loadtxt("XtcExplorer/calib/CSPad/cspad_2011-08-10-Metrology.txt")[:,1:]
metrology = metrology.reshape(4,8,4,3)

# also, we need to resort the 2x1 sections, they are
# listed in the file in the order 1,0,3,2,4,5,7,6
metrology = metrology[:,(1,0,3,2,4,5,7,6),:,:]

# I want the points in a different order: 
# (firstrow,firstcol), (firstrow,lastcol), (lastrow,firstcol), (lastrow,lastcol)
sec_coord_order = [(1,2,0,3),(1,2,0,3),(2,3,1,0),(2,3,1,0),(3,0,2,1),(3,0,2,1),(2,3,1,0),(2,3,1,0)]

# collect all pixel widths for averaging
dLong = np.zeros((4,8,2), dtype="float64")   # pixel size from long side of section
dShort = np.zeros((4,8,2), dtype="float64")  # pixel size from short side of section

# Start looping over quads and sections:

for quad in range(4):

    for sec in range(8):

        # corner values
        input_x = metrology[quad,sec,sec_coord_order[sec],0].reshape(2,2)
        input_y = metrology[quad,sec,sec_coord_order[sec],1].reshape(2,2)
        input_z = metrology[quad,sec,sec_coord_order[sec],2].reshape(2,2)

        # interpolate coordinates over to the pixel map
        x_coordinates[quad,sec] = interpol.map_coordinates(input_x, sec_coords)
        y_coordinates[quad,sec] = interpol.map_coordinates(input_y, sec_coords)
        z_coordinates[quad,sec] = interpol.map_coordinates(input_z, sec_coords)

        # ! in micrometers! Need to convert to pixel units
        dL = np.array([ abs(input_x[0,1]-input_x[0,0])/391,
                        abs(input_x[1,1]-input_x[1,0])/391,
                        abs(input_y[0,0]-input_y[0,1])/391,
                        abs(input_y[1,0]-input_y[1,1])/391 ])
        dLong[quad,sec] = dL[dL>100] # filter out the nonsense ones

        dS = np.array([ abs(input_y[0,0]-input_y[1,0])/185,
                        abs(input_y[0,1]-input_y[1,1])/185,
                        abs(input_x[0,0]-input_x[1,0])/185,
                        abs(input_x[0,1]-input_x[1,1])/185 ])
        dShort[quad,sec] = dS[dS>100] # filter out the nonsense ones

dTotal = np.concatenate( (dLong.ravel(), dShort.ravel() ))
print "Pixel-size:"
print "     long side average:    %.2f +- %.2f "%( dLong.mean(), dLong.std())
print "     short side average:   %.2f +- %.2f "%( dShort.mean(), dShort.std())
print "     all sides average:    %.2f +- %.2f "%( dTotal.mean(), dTotal.std())

# use the total to convert it all to pixel units
x_coordinates = x_coordinates / dTotal.mean()
y_coordinates = y_coordinates / dTotal.mean()
z_coordinates = z_coordinates / dTotal.mean()

print "Done making coordinate map of the CSPAD detector."

The result (coordinate maps for x,y,z and plots)

  • No labels