reader: place a detector swung out on a 2theta arm where the file says it stands
Chemical crystallography reaches high angle by swinging the detector out on a 2theta arm. Both readers had the number and neither used it: the miniCBF header's Detector_2theta was parsed into a struct member nothing ever read, and on the NXmx side the rotation was in the depends_on chain, which was not followed at all. A sweep taken at 30 degrees was therefore processed with its detector plane 30 degrees from where it stood, and nothing indexed. The geometry could already express it, and needed no change: the arm turns the detector about the sample, so the distance is still measured along the detector normal and the beam centre is still the point of normal incidence - which is exactly the PONI convention, and a swung detector is one PONI rotation. What moves is the direct beam, by distance*tan(2theta), off the beam centre and often off the detector. NXmx is the harder half, because the swing has no field of its own: it is one rotation in the chain the detector's position depends on, and "two_theta" is only one beamline's name for that dataset. So the chain is followed and its rotations composed, rather than a field of one name being looked for - each transformation states its vector in the frame of the one it depends on, which is why the product is the whole placement. Translations are skipped; they are the distance and the beam centre, which the file states separately in the square-on frame. Vectors come from McStas through the same 180-degree turn about z the module directions already use, a proper rotation, so an axis carried through it turns the same way. The three rotations a file this system writes ARE that chain, and are also read as the PONI angles - so those three paths are skipped, or every tilted file we have ever written would come back tilted twice. That is the one way this change could have broken existing data, and the test for it writes a tilted file and reads it back. For miniCBF the arm turns about the base spindle axis: on the four-circle geometry those headers describe the two are one axis, and the imgCIF axis table such a header carries states them with the same vector. Both now come from one constant, so a later correction to the frame moves them together. Measured. On a swung NXmx sweep the chain gives rot2 = -0.34907 rad for the 20 degrees it states, and the sweep goes from "nothing was integrated" to 25000 reflections at 82.2% completeness and CC(1/2) 0.9993, in the same space group and the same cell to 0.03 A as the square-on sweep of that crystal; the opposite sign indexes nothing. A miniCBF sweep at 30 degrees goes the same way, to 0.585 A, and a second sweep of that crystal at 55 degrees reaches 0.476 A and reproduces the cell again - with a low-resolution limit of 2.36 A rather than 13 A, which is what a detector swung that far records. On all of them post-refinement recovers the header's own beam centre and distance, and the beam stop shadow sits within four pixels of where the swung geometry puts the direct beam, 417 and 537 pixels from where the unswung one does. Seven sets whose detector is square to the beam, three of them carrying a chain whose 2theta is zero, are byte-identical in .hkl, .mtz, .cif and the image statistics. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3yNBXk4wKdMZy1ak2NY7f
This commit is contained in:
@@ -90,6 +90,11 @@ std::vector<std::string> CollectSweep(const std::string &path) {
|
||||
return out;
|
||||
}
|
||||
|
||||
// The base rotation axis of the instrument, in the internal frame (x along increasing detector
|
||||
// column, y along increasing row, z along the beam). Both the spindle and the detector arm turn
|
||||
// about it: the spindle in RotationAxis below, and the 2theta arm in ReadFiles.
|
||||
const Coord BASE_AXIS(-1.0f, 0.0f, 0.0f);
|
||||
|
||||
// The axis a miniCBF sweep turns about, in the internal frame (x along increasing detector column,
|
||||
// y along increasing row, z along the beam).
|
||||
//
|
||||
@@ -106,7 +111,7 @@ std::vector<std::string> CollectSweep(const std::string &path) {
|
||||
// source; internal z points the other way, hence the minus. A kappa arm cannot be expressed at all:
|
||||
// its inclination is a property of the hardware that no miniCBF header states.
|
||||
Coord RotationAxis(const minicbf::Header &h) {
|
||||
const Coord base(-1.0f, 0.0f, 0.0f);
|
||||
const Coord base = BASE_AXIS;
|
||||
if (!minicbf::ScansPhi(h))
|
||||
return base;
|
||||
|
||||
@@ -161,6 +166,22 @@ void JFJochCBFReader::ReadFiles(const std::string &path) {
|
||||
dataset_->experiment.BeamX_pxl(static_cast<float>(header0_.beam_x_px));
|
||||
dataset_->experiment.BeamY_pxl(static_cast<float>(header0_.beam_y_px));
|
||||
dataset_->experiment.DetectorDistance_mm(static_cast<float>(header0_.distance_m * 1000.0));
|
||||
|
||||
// A detector swung out on a 2theta arm, which small-molecule collection uses routinely. The arm
|
||||
// turns the detector about the sample, so it carries the square-on geometry with it: the header's
|
||||
// Detector_distance stays the distance along the detector normal and Beam_xy stays the point of
|
||||
// normal incidence, neither of which the swing moves - which is exactly what the PONI convention
|
||||
// wants, so the swing is a PONI rotation and nothing else in the header changes. It turns about
|
||||
// the base spindle axis, the four-circle geometry these headers describe having the arm and the
|
||||
// spindle on one axis; the imgCIF axis table such a header carries states the two with the same
|
||||
// vector.
|
||||
if (header0_.two_theta_deg != 0.0) {
|
||||
float rot1 = 0, rot2 = 0, rot3 = 0;
|
||||
PoniAnglesFromMatrix(RotMatrix(static_cast<float>(header0_.two_theta_deg * PI / 180.0), BASE_AXIS),
|
||||
rot1, rot2, rot3);
|
||||
dataset_->experiment.PoniRot1_rad(rot1).PoniRot2_rad(rot2).PoniRot3_rad(rot3);
|
||||
}
|
||||
|
||||
dataset_->experiment.IncidentEnergy_keV(WVL_1A_IN_KEV / static_cast<float>(header0_.wavelength_A));
|
||||
dataset_->experiment.FrameTime(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
|
||||
Reference in New Issue
Block a user