Child pages
  • Sector 34 Detector Geometry file
Skip to end of metadata
Go to start of metadata

Sector 34 currently uses a detector geometry file.  An example of this file for 34-ID and 33- BM is given here.

A description of the file from Jon Tischler follows:Everything that counts is between <geoN xmlns="http://sector34.xor.aps.anl.gov/34ide/geoN"> ... </geoN>

The first four tags are global to this file:
dateWritten date that the file was written (optional)
timeWritten time of day that the file was written (optional)
EPOCH seconds from midnight Jan 1, 1904 corresponding to the dateWritten & timeWritten (optional)
fileNote a note of possible interest about this file (optional)

The <Detectors> group. This is a list of all the detectors defined in this file. The Ndetectors="3" in the above example
indicates that there are 3 detectors defined here.
Each detector is defined in its own <Detector> ... </Detector> group.

The <Detector> group describes a detector, the tag: <Detector N="0"> describes detector #0 in the above
example. Probably the first detector. The numbers need not be sequential, but that is convienent.
In the <Detector N="0"> group, the tags are:
<Npixels> contains two numbers, the number of pixels along the x and y directions in the detetor
This is the full un-binned number of pixels, not an ROI. (required)

<size> FULL outside dimensions of the detector from the left edge of pixel 0 to the right edge of pixel Nx-1
It contains two numbers one for the x direction on the detector, one for the right (required)

<timeMeasured> date and time when this detetector parameters were measured (optional)

<note> a note of possible interest (optional)

<ID> a unique detector ID, a string that is different for each detector. This same ID should be stored in the HDF
file so that a connection can be made between an image and one of the <Detecto> groups in this file (required)

<P> The translation vector applied to all pixels on the detector, usually mm (required)

<R> The rotation vector applied to all pixels on the detector. The direction of R is the rotation
axis, and the magnitude of R is the amount of rotation (usually radians) (required)

The <Sample> group is only of interest to the 34ID-E experiment. It describes the orientation and offset
of the sample positioner

The <Wire> group is only of interest to the 34ID-E experiment. It describes the wire, and orientation and offset
of the wire positioner.

Note on the detector orientation.

When P=0 and R=0, the detector is assumed to be positioned with its center at the origin, and it is
oriented in the following way:
X pixels increasing along the X direction
Y pixels increasing along the Y direction
the beam is assumed to travel along the Z direction and, of course, hits the center of the detector.

To convert a pixel position to XYZ in the beamline coordinate system do the following:

first convert a binned ROI to full chip un-binned pixels:
px = startx + px*groupx + (groupx-1)/2 // pixel is zero based here & startx is zero based
py = starty + py*groupy + (groupy-1)/2 // groupx=1 is un-binned

where startx is the first pixel in the ROI (startx is in un-binned pixels)
groupx is the binning and is assumed to be an integer
ditto for starty and groupy

second convert un-binned pixels (px,py) to xy on the detector (xd, yd) in real units:
xd = (px - 0.5*(Nx-1)) * sizeX/Nx
yd = (py - 0.5*(Ny-1)) * sizeY/Ny
here, Nx,Ny, ans sizeX,sizeY come from the <Npixels> and <size> for this detector
we now have (xd,yd) of the pixel, z of the pixel is still z=0, since the base detector position is at the origin
and perpendicular to the z-direction.

third translate (xd,yd) by the vector P to get (xd,yd,zd):
x = xd + P0
y = yd + P1
z = 0 + P2// remember zd=0

and fourth and last, rotate about R:
This is the full equation, (XYZ) = rho x (xd,yd,zd) + P, where XYZ in beamline coordinates
X = rho00*x + rho01*y + rho02*z // rhoij is the rotation matrix computed from R below
Y = rho10*x + rho11*y + rho12*z
Z = rho20*x + rho21*y + rho22*z

the matrix rhoij is the rotation matrix computed from R as follows:
using R = (Rx,Ry,Rz)

theta = sqrt(Rx*Rx+Ry*Ry+Rz*Rz) // total rotation angle (radians)
if (theta==0) // no rotation, set to identity matrix
rho00 = 1; rho01 = 0; rho02 = 0
rho10 = 0; rho11 = 1; rho12 = 0
rho20 = 0; rho21 = 0; rho22 = 1
return

c = cos(theta) // remember, theta is in radians
s = sin(theta)
c1 = 1-c
Rx /= theta; Ry /= theta; Rz /= theta // normalize (Rx,Ry,Rz)

rho00 = c + Rx*Rx*c1; rho01 = Rx*Ry*c1 - Rz*s; rho02 = Ry*s + Rx*Rz*c1 // this is the Rodrigues formula from:
rho10 = Rz*s + Rx*Ry*c1; rho11 = c + Ry*Ry*c1; rho12 = -Rx*s + Ry*Rz*c1 // http://mathworld.wolfram.com/RodriguesRotationFormula.html
rho20 = -Ry*s + Rx*Rz*c1; rho21 = Rx*s + Ry*Rz*c1; rho22 = c + Rz*Rz*c1
return

Note, to convert from XYZ to pixel on the detector, invert the procedure. This is
easy since rhoij is a rotation matrix and so its inverse is its transpose.

  • No labels