diff --git a/common/BraggIntegrationSettings.cpp b/common/BraggIntegrationSettings.cpp index 57d4b2519..ae8086b26 100644 --- a/common/BraggIntegrationSettings.cpp +++ b/common/BraggIntegrationSettings.cpp @@ -195,3 +195,12 @@ BraggIntegrationSettings &BraggIntegrationSettings::OverlapMinPeak(float input) float BraggIntegrationSettings::GetOverlapMinPeak() const { return overlap_min_peak; } + +BraggIntegrationSettings &BraggIntegrationSettings::FlightPath(FlightPathMedium input) { + flight_path = input; + return *this; +} + +FlightPathMedium BraggIntegrationSettings::GetFlightPath() const { + return flight_path; +} diff --git a/common/BraggIntegrationSettings.h b/common/BraggIntegrationSettings.h index e5b50bffd..4e4b5645e 100644 --- a/common/BraggIntegrationSettings.h +++ b/common/BraggIntegrationSettings.h @@ -23,6 +23,13 @@ enum class IntegratorMode { BoxSum, ProfileGaussian, ProfileEmpirical }; // Reject acts on it. enum class OverlapMode { Off, Reject, Exclude }; +// What the diffracted beam flies through between the sample and the detector. Air is what a beamline +// has unless it was built not to have one; helium and vacuum are what long-wavelength stations use, +// because air absorbs unusably at low energy. It is an explicit choice, not something detected: no +// field of the NXmx application definition, and no field of any master file rugnux reads, describes +// the medium in the flight path - see sensor_absorption::FlightPathAttenuation. +enum class FlightPathMedium { Air, Helium, Vacuum }; + // The hkl half-width the broker bootstraps when a config carries no bragg_integration block. Matches // the max_hkl default in broker/jfjoch_api.yaml, so an omitting client and an omitting config agree. constexpr int BRAGG_ONLINE_DEFAULT_MAX_HKL = 100; @@ -129,6 +136,18 @@ class BraggIntegrationSettings { // it can read (dials calls that valid_foreground_threshold, and defaults it to the same 0.75). OverlapMode overlap_mode = OverlapMode::Exclude; float overlap_min_peak = 0.75f; + // What the diffracted beam crosses between the sample and its pixel, which sets the flight-path + // attenuation correction (sensor_absorption::FlightPathAttenuation). Air by default; the + // correction is computed from the NIST attenuation coefficient of the medium, the stated + // sample-to-detector distance and the stated wavelength, and nothing about it is fitted. + // + // It is a declared choice rather than a detected one, and that is not a gap waiting to be + // closed. Nothing in the files says what the medium was, and the implied transmission does not + // separate the cases either: in this corpus a CONFIRMED helium station sits at 51% implied air + // transmission and a CONFIRMED air station at 63%, so any rule dividing them would be a + // threshold fitted between two points rather than a physical criterion. The honest design is an + // explicit option, a stated default, and the assumption printed in the report. + FlightPathMedium flight_path = FlightPathMedium::Air; public: BraggIntegrationSettings& R1(float input); @@ -145,6 +164,7 @@ public: BraggIntegrationSettings& MaxHKL(std::optional input); BraggIntegrationSettings& Overlap(OverlapMode input); BraggIntegrationSettings& OverlapMinPeak(float input); + BraggIntegrationSettings& FlightPath(FlightPathMedium input); [[nodiscard]] IntegratorMode GetIntegrator() const; @@ -164,4 +184,6 @@ public: [[nodiscard]] std::optional GetMaxHKL() const; [[nodiscard]] OverlapMode GetOverlap() const; [[nodiscard]] float GetOverlapMinPeak() const; + // See flight_path: air unless the user said otherwise, which no file can say for them. + [[nodiscard]] FlightPathMedium GetFlightPath() const; }; diff --git a/common/Reflection.h b/common/Reflection.h index 1f78c921f..79be1d9fb 100644 --- a/common/Reflection.h +++ b/common/Reflection.h @@ -39,9 +39,17 @@ struct Reflection { // multiplies the two. Defaulted to 1 so a reflection read from a file written before this // existed is a no-op rather than a zero. float qe_corr = 1.0f; + // The air in the sample-to-pixel flight path, exp(D/L * (1/cos(alpha) - 1)): always >= 1, and + // exactly 1 when the air correction is switched off. Carried beside the two above for the same + // reason they are carried apart - it is neither beam geometry nor detector response but the + // medium in between, and unlike either of them it is set by the flight distance. The total + // deterministic correction on a reflection is prescaling_corr * qe_corr * flight_corr, and every + // site that corrects an intensity multiplies all three. Defaulted to 1 so a reflection read + // from a file written before this existed is a no-op rather than a zero. + float flight_corr = 1.0f; float partiality; // fraction of the reflection recorded in the sampled (rocking) slice float zeta; - float image_scale_corr; // I_true = image_scale_corr * I; = prescaling_corr * qe_corr / (partiality * image_scale) + float image_scale_corr; // I_true = image_scale_corr * I; = prescaling_corr * qe_corr * flight_corr / (partiality * image_scale) bool observed = false; bool on_ice_ring = false; // sits on a hexagonal-ice powder ring: excluded from scaling, kept for merging }; diff --git a/docs/ACKNOWLEDGEMENT.md b/docs/ACKNOWLEDGEMENT.md index 1f0705d63..d8ec01a59 100644 --- a/docs/ACKNOWLEDGEMENT.md +++ b/docs/ACKNOWLEDGEMENT.md @@ -282,10 +282,12 @@ S. C. Abrahams, H. D. Flack, E. Prince and A. J. C. Wilson, "Statistical descrip crystallography. II. Report of a Working Group on Expression of Uncertainty in Measurement" (1995), Acta Cryst. A51, 565-569 [doi:10.1107/S0108767395002340](https://doi.org/10.1107/S0108767395002340). -**Sensor absorption at oblique incidence** — the angle-dependent quantum efficiency of a flat -sensor, and the radial parallax variance that comes from the same integral, are the Beer-Lambert law -taken along a ray that crosses t/cos(alpha) of sensor and converts at a random depth. The -attenuation coefficients are the NIST tabulation: J. H. Hubbell and S. M. Seltzer, "Tables of X-Ray +**Sensor absorption at oblique incidence, and the flight path** — the angle-dependent quantum +efficiency of a flat sensor, the radial parallax variance that comes from the same integral, and the +attenuation of a reflection in the air between the sample and its pixel are all the Beer-Lambert law +taken along a ray that crosses t/cos(alpha) of sensor, or D/cos(alpha) of air, and converts at a +random depth. The attenuation coefficients, for silicon, CdTe, dry air and helium alike, are the +NIST tabulation: J. H. Hubbell and S. M. Seltzer, "Tables of X-Ray Mass Attenuation Coefficients and Mass Energy-Absorption Coefficients from 1 keV to 20 MeV for Elements Z = 1 to 92 and 48 Additional Substances of Dosimetric Interest" (1995, data updated 2004), NIST Standard Reference Database 126 diff --git a/docs/CBOR.md b/docs/CBOR.md index d827d5aa3..bfae3fe1f 100644 --- a/docs/CBOR.md +++ b/docs/CBOR.md @@ -169,6 +169,7 @@ See [DECTRIS documentation](https://github.com/dectris/documentation/tree/main/s | - rp | float | Distance to Ewald sphere \[Angstrom^-1\] | | | | - rlp | float | Reciprocal Lorentz-polarization factor: the multiplier taking the raw integrated count toward a quantity proportional to \|F\|^2. Lorentz x polarization only - a still has no Lorentz term, so there it is the polarization alone | | | | - qe | float | Sensor efficiency at the reflection's angle of incidence, QE(0)/QE(alpha); <= 1, and 1 where the sensor is opaque or unknown. Carried beside `rlp`, not inside it: the total correction is `rlp * qe`. Optional | | | +| - flight | float | Attenuation of the reflection in the flight path between the sample and its pixel, normalised to normal incidence; >= 1, and exactly 1 for a vacuum path. Carried beside `rlp` and `qe`: the total correction is `rlp * qe * flight`. Optional | | | | - partiality | float | Partiality of the reflection | | | | - phi | float | phi angle from XDS: difference from middle of current frame, not absolute \[deg\] | | | | - zeta | float | Lorentz zeta factor (reciprocal-space geometry term) | | | diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fe9ba6b5c..abc696de1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,8 @@ * `rugnux` applies the sensor quantum-efficiency correction to still images processed on a GPU, which were left uncorrected while the same data on a CPU-only machine was corrected. * The unmerged MTZ keeps the sensor efficiency out of its `LP` column and records it in a new `QE` column, as XDS and DIALS do, so raw counts are `I / LP * QE`; `_process.h5` keeps it out of `lp` in the same way, in a new optional `qe` dataset, and the merged intensities are unchanged. * `rugnux` takes the sensor attenuation length from tabulated coefficients rather than a wavelength-cubed approximation, which corrects the parallax term of the spot-width variance on CdTe sensors. +* `rugnux` corrects each reflection for the attenuation in the flight path it crossed between the sample and its pixel; `--flight-path air|helium|vacuum` declares the medium, which defaults to air because no file states it, and the results report says which medium was assumed and what assuming it was worth. +* The unmerged MTZ records the flight-path factor in a new `FLIGHT` column and `_process.h5` in a new optional `flight` dataset, so raw counts are `I / LP * QE * FLIGHT`. * `rugnux --model` treats the model as a hypothesis: it decides the enantiomorph and the indexing only where its R-work beats that of the same model in random orientations, and a model the data reject is still scored, placed and mapped, but leaves the reflection files byte for byte what a run with no model writes. * `rugnux --model` places the model against the data as a rigid body before scoring it, writes sigma_A-weighted 2mFo-DFc and mFo-DFc maps in place of the unweighted 2Fo-Fc and Fo-Fc, and writes the model as it was placed - `_model.cif`, and `_model.pdb` where the PDB format can express the cell - in the cell and space group of the reflection files beside it. * `rugnux` and `jfjoch_viewer` read PILATUS miniCBF sweeps natively, and open masters written at other facilities, including Eiger 1.x and third-party NXmx. diff --git a/docs/CPU_DATA_ANALYSIS_INTEGRATION.md b/docs/CPU_DATA_ANALYSIS_INTEGRATION.md index 4820b9220..f85021ef1 100644 --- a/docs/CPU_DATA_ANALYSIS_INTEGRATION.md +++ b/docs/CPU_DATA_ANALYSIS_INTEGRATION.md @@ -161,18 +161,13 @@ The integrator is selected by `--integrator boxsum|gaussian|empirical` (default ### 9.4 The prescaling correction -The deterministic per-reflection corrections are carried as two multiplicative factors. `prescaling_corr` holds the reciprocal Lorentz factor (rotation only — a still's Lorentz factor is one) times the reciprocal polarization factor from the geometry-based term (§2.2), and nothing else: it is Lorentz x polarization, which is what `LP` means in every format the field reads. `qe_corr` holds the sensor's angle-dependent efficiency (§9.6) beside it, because detector response and beam/crystal geometry are different things. The total deterministic correction on a reflection is the product `prescaling_corr * qe_corr`, and every site that corrects an intensity — the integrator, the scaling fits, the merge ingest, the anisotropy analysis and the unmerged export — multiplies the two. Neither is a scale: the fitted per-image scale and the partiality are separate. The two reach the unmerged MTZ as its `LP` and `QE` columns unchanged (`QE` as a divisor normalised to 1 at normal incidence), so raw counts are `I / LP * QE`. +The deterministic per-reflection corrections are carried as three multiplicative factors. `prescaling_corr` holds the reciprocal Lorentz factor (rotation only — a still's Lorentz factor is one) times the reciprocal polarization factor from the geometry-based term (§2.2), and nothing else: it is Lorentz x polarization, which is what `LP` means in every format the field reads. Beside it sit the two terms that describe what happened to the photon between leaving the sample and being counted, and that are kept apart from `LP` because detector response and beam/crystal geometry are different things: `qe_corr`, the sensor's angle-dependent efficiency, and `flight_corr`, the medium in the flight path (§9.6). The total deterministic correction on a reflection is the product `prescaling_corr * qe_corr * flight_corr`, and every site that corrects an intensity — the integrator, the scaling fits, the merge ingest, the anisotropy analysis and the unmerged export — multiplies all three. None of them is a scale: the fitted per-image scale and the partiality are separate. The three reach the unmerged MTZ as its `LP`, `QE` and `FLIGHT` columns unchanged (`QE` and `FLIGHT` as divisors normalised to 1 at normal incidence), so raw counts are `I / LP * QE * FLIGHT`. -Two terms are deliberately **not** in it. The **per-pixel solid angle**, which the azimuthal profile +One term is deliberately **not** in it. The **per-pixel solid angle**, which the azimuthal profile does divide out (§2.2), is correctly absent here: a Bragg integration sums all the photons in a reflection, and how many pixels the detector happens to tile that footprint with does not change the count. Detector obliquity does stretch the footprint, and that enters as the parallax term of the -spot-width variance rather than as an intensity scale. The **air flight path** between sample and -sensor — which carries the same $\cos\alpha$ dependence as the sensor crossing, with the opposite -sign — is not modelled; it is below 1.5% for any geometry in use and, like the sensor term, cancels -within a resolution shell on an untilted detector. - ---- +spot-width variance rather than as an intensity scale. ### 9.5 Choosing the signal radius from the crystal's own spots (rotation) @@ -200,6 +195,71 @@ Every integration pass, adaptive or not, now logs the radii it used together wit --- +### 9.6 The flight path + +A reflection leaving the sample at incidence angle $\alpha$ to the detector normal reaches its pixel +after $D/\cos\alpha$ of flight rather than $D$, so it crosses more of whatever fills the flight path +than one arriving head-on and arrives attenuated. This is the **same $\cos\alpha$ geometry as the +sensor crossing of §9.4, with the opposite sign**: the sensor makes an oblique reflection read high, +the medium makes it read low. + +$$T(\alpha) = \exp\!\left(-\frac{D}{L\cos\alpha}\right), \qquad +\text{correction to } I = \frac{T(0)}{T(\alpha)} = \exp\!\left[\frac{D}{L}\left(\frac{1}{\cos\alpha} - 1\right)\right]$$ + +with $L = 1/\mu$ the attenuation length of the medium at the photon energy, from the same NIST +tabulation the sensor uses. Nothing here is fitted: $\mu$ is tabulated, and $D$ and $\lambda$ are +stated by the file. Normalising at $\alpha = 0$ divides out $\exp(-D/L)$, a constant for the dataset +that the fitted per-image scale absorbs; what is left is the only part of the flight path that is not +degenerate with that scale. + +For **air**, $L$ falls steeply toward low energy — **8.2 m at 18 keV, 3.0 m at 12.4 keV, 0.089 m at +3.8 keV** — and the size of the correction follows it: + +| photon energy | $L$ (air) | $D/L$ at 160 mm | correction at $\alpha = 30°$ | at $\alpha = 55°$ | +| --- | --- | --- | --- | --- | +| 18 keV | 8.17 m | 0.0196 | +0.30 % | +1.5 % | +| 12.4 keV | 2.99 m | 0.0535 | +0.83 % | +4.1 % | +| 8 keV | 0.84 m | 0.191 | +3.0 % | +15 % | +| 3.8 keV | 0.089 m | 1.80 | ×1.32 | ×3.8 | + +**Helium** attenuates about 1/600 of air at 3.8 keV — two electrons an atom against nitrogen and +oxygen, and a seventh of the density — which is exactly why long-wavelength stations use it. It is +not vacuum, and is modelled rather than treated as one, though at these distances it is worth well +under a per cent. **Vacuum** leaves every intensity untouched. + +#### What it does to merged data + +On an **untilted** detector $\alpha$ is the scattering angle, so the correction is a pure function of +resolution. It therefore cancels within a resolution shell and cannot move $R_\mathrm{meas}$ or +CC$_{1/2}$ there; **its whole effect on merged data is a shift in the Wilson $B$**. Friedel mates +share $2\theta$ and so receive an identical factor, which also means it cannot act on an anomalous +difference at all. Both statements are quantitative predictions with no free parameter, and both are +confirmed: the Wilson-$B$ shift is reproduced to within 8 % on three datasets spanning an order of +magnitude in $D/L$, and where a pooled statistic does move, every resolution shell is unchanged and +the pooled shift is reproduced by re-weighting alone. + +That is what `FLIGHT_PATH_WILSON_B` in the results report quotes: the correction's worth, in the one +number it can move. + +#### Why the medium is declared and not detected + +**No field of the NXmx application definition, and no field of any master file `rugnux` reads, +describes the medium in the flight path** — there is no air, helium, vacuum, flight-tube or pressure +entry anywhere to detect it from. + +Inferring it from the physics was considered and **refuted**. The natural idea is that air becomes +unusable at low energy, so an implausibly low implied air transmission would mean helium; but in this +corpus a **confirmed helium** station sits at 51 % implied transmission and a **confirmed air** +station at 63 %. No criterion separates those two without being a threshold fitted between two +points, so there is none. + +`rugnux` therefore **assumes air** — which is what a beamline has unless it was built not to have one +— and `--flight-path helium|vacuum` declares otherwise. Because that is an assumption made on the +user's behalf, the report states it (`FLIGHT_PATH`) together with what it was worth +(`FLIGHT_PATH_WILSON_B`), and warns where it is worth enough to matter. + +--- + ## 10. Scaling and merging After per-image integration, Jungfraujoch scales observations and merges them into unique reflections. The design is intentionally compatible with XDS/XSCALE concepts, and handles both still and rotation data. diff --git a/docs/HDF5.md b/docs/HDF5.md index 63694963b..63defde82 100644 --- a/docs/HDF5.md +++ b/docs/HDF5.md @@ -437,6 +437,7 @@ mostly onto the standard | `observed_frame` | | standard | image number of the reflection | | `lp` | | standard | the Lorentz-polarization factor, stored as the reciprocal of the multiplier that is applied. Lorentz x polarization only, which is what the NXreflections name means; the sensor efficiency is `qe`, beside it | | `qe` | | **extension** | the sensor efficiency, in the same reciprocal convention as `lp`, so the whole correction applied to a raw count is `1/lp * 1/qe`. Absent in files written before it existed; the reader then takes the whole of `lp` for Lorentz–polarization, which is what those files mean | +| `flight` | | **extension** | the flight path between sample and pixel, in the same reciprocal convention as `lp` and `qe`, so the whole correction applied to a raw count is `1/lp * 1/qe * 1/flight`. It runs the opposite way to `qe` — at most 1 where `qe` is at least 1 — because the medium attenuates an oblique reflection where the sensor favours it. Exactly 1 under `--flight-path vacuum`, and absent in files written before it existed; the reader then takes it as 1 | | `partiality` | | standard | recorded fraction of the reflection | | `delta_phi` | deg | **extension** | XDS Δφ: offset from the centre of the current frame | | `zeta` | | **extension** | Lorentz ζ factor (reciprocal-space geometry term) | diff --git a/docs/RUGNUX_ADVANCED.md b/docs/RUGNUX_ADVANCED.md index c1e30bdbd..af15196d9 100644 --- a/docs/RUGNUX_ADVANCED.md +++ b/docs/RUGNUX_ADVANCED.md @@ -335,7 +335,7 @@ Scaling and merging: | `--reference-column