Files
Jungfraujoch/reader/CrystFELGeometry.h
T
leonarski_fandClaude Opus 5.5 7c23b4befe CrystFEL geometry: read the pixel masks and bad regions instead of ignoring them
The .geom parser now takes the masking information the format defines:
- mask arrays: mask/mask_file/mask_good/mask_bad (mask 0) and maskN_data/maskN_file/maskN_goodbits/
  maskN_badbits for N = 0..7; global keys hold for the panels after them, a panel may override. A mask
  that is the same on every panel is one whole-frame mask, otherwise one per panel, applied on that
  panel's pixels only.
- a relative mask_file is looked for in the working directory (as CrystFEL does), then beside the .geom.
- bad regions (bad*): a lab-plane box (min_x..max_y) or a fs/ss range on a panel (or, old syntax, on
  the whole frame); mask_edge_pixels and no_index.

JFJochXFELReader already had the static pixel mask and the per-frame mask path for these; the masks
go through them unchanged. A mask whose path holds % (one per shot group) is applied frame by frame
like a 3D one. Where the geometry names mask arrays, the data file's own Cheetah masks (CXI
mask_shared and per-shot mask with Cheetah's generic bad bits, /metadata/pixelmask) are not added:
the geometry says which bits matter (e.g. an AGIPD mask_bad that includes bit 32). --mask-good /
--mask-bad still add their masks to these.

Tests: [CrystFELGeometry] (new keys, per-panel override, relative mask file), JFJochXFELReader_*
(new GeometryMasks case on a synthetic CXI + .geom), [JFJochMultiReader], JFJochXTCReader*.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
2026-10-21 12:42:08 +02:00

34 lines
1.8 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <string>
#include <vector>
#include "DetectorLayout.h"
#include "../common/DetectorModules.h"
// A CrystFEL detector geometry file (.geom): the panels with their pixel ranges in the stored frame,
// fast/slow-scan directions, corners, pixel size and depth offset (coffset), where the frames are (data,
// dimN), optionally the camera length - and which pixels to leave out: the mask arrays (mask, mask_file,
// mask_good, mask_bad, or maskN_data, maskN_file, maskN_goodbits, maskN_badbits for up to eight, per
// panel where a panel states its own), the bad regions (bad*, in the laboratory plane or as a pixel
// range on a panel), mask_edge_pixels and no_index. Photon energy, gain, saturation and value flags are
// the data file's or the command line's to state, or rugnux's to measure: such keywords are listed in
// `ignored` for the log. Both the current syntax and the older one (global keys that take effect for
// the panels after them) are read. A keyword that would move pixels in a way not supported (a tilted
// panel, a frame laid out by a module dimension, panels in different datasets, a detector shift) is
// refused.
namespace crystfel {
// The layout the file describes; keywords read past are added to ignored, for the log.
xfel::Layout Read(const std::string &filename, std::vector<std::string> &ignored);
// The panels of a geometry file as the modules of an image they are laid on: each panel's pixel range is
// the image's columns (fs) and rows (ss) it covers, and its corner places it relative to the beam, which
// the image has at (beam_x, beam_y). Fewer than two panels: none.
DetectorModules ModulesOnImage(const xfel::Layout &geom, double beam_x, double beam_y);
} // namespace crystfel