Files
Jungfraujoch/writer/HDF5NXmx.h
T
leonarski_fandClaude Opus 4.8 03814b1425 writer: save ROI bitmap and definitions in the master file
Persist regions of interest so an acquisition's ROI layout can be
recovered from the master (_master.h5 / _process.h5):

- /entry/roi/roi_map: uint16 per-pixel bitmask (bit i == ROI i).
- /entry/roi/<name>: logical definition (type + geometry params, incl.
  azimuthal phi sector) plus bit_index tying it to the bitmap plane.

The bitmap rides along in the StartMessage (CBOR, mirroring az_int_map)
and is filled both online (JFJochReceiver::SendStartMessage) and offline
(jfjoch_process). Definitions come from the already-transmitted rois.
Both are dataset-wide metadata, so they are written by the NXmx master
writer (new NXmx::ROI), not the per-image data-file plugin.

Documented the /entry/roi layout in docs/HDF5.md and the master-vs-data
writer convention in CLAUDE.md; added a CBOR roi_map round-trip test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 09:41:26 +02:00

70 lines
2.8 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "../common/JFJochMessages.h"
#include "HDF5Objects.h"
namespace HDF5Metadata {
std::string MasterFileName(const StartMessage &msg);
std::string DataFileName(const StartMessage &msg, int64_t file_number);
}
class NXmx {
std::shared_ptr<HDF5File> hdf5_file;
const StartMessage start_message;
const std::string filename;
std::string tmp_filename;
bool overwrite = false;
bool calibration_group_created = false;
void LinkToData(const StartMessage &start, const EndMessage &end);
void LinkToData_VDS(const StartMessage &start, const EndMessage &end);
void LinkToData_ProcessingVDS(const StartMessage &start, const EndMessage &end);
void LinkToReflections_VDS(const StartMessage &start, const EndMessage &end);
std::unique_ptr<HDF5DataSet> VDS(const StartMessage &start,
const std::string& name,
const std::vector<hsize_t> &dim,
const HDF5DataType &data_type);
std::unique_ptr<HDF5DataSet> VDS(const StartMessage &start,
const std::string& name_src,
const std::string& name_dest,
const std::vector<hsize_t> &dim,
const HDF5DataType &data_type);
void Detector(const StartMessage &start);
void Detector(const StartMessage &start, const EndMessage &end);
void DetectorModule(const std::string &name, const std::vector<int32_t> &origin,
const std::vector<int32_t> &size, const std::vector<double> &fast_axis,
const std::vector<double> &slow_axis, const std::string &nx_axis, double pixel_size_mm);
void Facility(const StartMessage &start);
void Beam(const StartMessage &start);
void Metrology(const StartMessage &start);
void Sample(const StartMessage &start, const EndMessage &end);
void Attenuator(const StartMessage &start);
void SaveCBORImage(const std::string& hdf5_path, const CompressedImage &image);
void AzimuthalIntegration(const StartMessage &start, const EndMessage &end);
void ADUHistogram(const EndMessage &end);
void EndResultVectors(const EndMessage &end);
void UserData(const StartMessage &start);
void MX(const StartMessage &start);
void ROI(const StartMessage &start);
void Fluorescence(const StartMessage &start);
public:
NXmx(const StartMessage& start);
~NXmx();
NXmx(const NXmx &other) = delete;
NXmx& operator=(const NXmx &other) = delete;
void Finalize(const EndMessage &end);
void WriteCalibration(const CompressedImage &image);
std::shared_ptr<HDF5File> GetFile();
};