Files
leonarski_fandClaude Opus 5.5 6557ba87f4 rugnux: several stills inputs in one run; inputs are files, never a directory
Every input is a file named on the command line, read in the order given (a shell glob gives them
sorted by name); a directory is refused with the glob form to use instead.

- Several Jungfraujoch/NXmx masters of stills are read as one run (JFJochMultiReader): their images
  one after another, the pixel masks combined, the per-image efficiency placed at each input's
  images. They must share the detector, wavelength (0.1%), distance (0.1 mm) and beam centre (1 px),
  since stills geometry refinement refines one geometry for all frames; rotation sweeps are refused.
  The log gives the indexing rate of each input beside the run's (ProcessResult::image_indexed).
- SACLA HDF5 / CXI (JFJochCrystFELReader::ReadFiles, ReadCXI, Open) and XTC
  (JFJochXTCReader::ReadFiles) take the list of files instead of scanning a directory;
  CanReadCXI and xtc::CanRead accept only a file; ListFiles and xtc::CollectStreams are gone.
- Several inputs must be one format, --mode mx, and stored files (no broker, no --simulate-live);
  one frame of a CBF/marCCD/SMV sweep still names the whole sweep.

Validated: two Jungfraujoch lysozyme stills runs together (49,920 frames, known cell) 57.1% indexed (59.3% /
54.9% per run), 1.22 A, CC1/2 0.986, R_split 8.8%, REFMAC R/R-free 0.253/0.269 against 0.257/0.273
for the earlier hand-built combined master. Rotation: 5reo and lyso_x10sa_90deg_1 unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
2026-10-20 23:30:17 +02:00

69 lines
2.6 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JFJOCHIMAGEREADER_H
#define JFJOCHIMAGEREADER_H
#include <unordered_set>
#include <map>
#include <mutex>
#include "../common/JFJochMessages.h"
#include "../common/Plot.h"
#include "../common/ROIBox.h"
#include "../common/DiffractionExperiment.h"
#include "JFJochReaderDataset.h"
#include "JFJochReaderImage.h"
#include "JFJochReaderSpots.h"
class JFJochReader {
// Reads each of its inputs' frames through them (JFJochMultiReader.h).
friend class JFJochMultiReader;
mutable std::mutex m;
std::shared_ptr<JFJochReaderDataset> dataset;
virtual bool LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset,
DataMessage& message,
std::vector<uint8_t> &buffer,
int64_t image_number,
bool update_dataset) = 0;
mutable std::mutex summation_mutex;
void SummationThread(int64_t image0,
int64_t n_image,
int64_t image_jump,
JFJochReaderImage &image);
protected:
void SetStartMessage(const std::shared_ptr<JFJochReaderDataset> &val);
DiffractionExperiment default_experiment;
public:
virtual ~JFJochReader() = default;
JFJochReader& Experiment(const DiffractionExperiment& experiment);
std::shared_ptr<const JFJochReaderDataset> GetDataset() const;
[[nodiscard]] virtual uint64_t GetNumberOfImages() const = 0;
virtual void Close() = 0;
std::shared_ptr<JFJochReaderImage> LoadImage(int64_t image_number, int64_t summation_factor = 1);
void UpdateGeomMetadata(const DiffractionExperiment& experiment);
void UpdateUserMask(const std::vector<uint32_t>& mask);
// Read one image into a raw image the caller owns, false where there is nothing to read. A
// worker that walks a whole sweep hands the same object back on every frame and so keeps its
// buffer: GetRawImage() allocates a fresh one per call, which on a 4-byte 16 Mpx frame is 72 MB
// of untouched pages the decoder then faults in one by one, measurably more than the decode.
virtual bool ReadRawImage(int64_t image_number, JFJochReaderRawImage &image) = 0;
// The same image in a freshly allocated raw image.
std::shared_ptr<JFJochReaderRawImage> GetRawImage(int64_t image_number);
virtual std::vector<SpotToSave> ReadSpots(int64_t image) const = 0;
std::shared_ptr<JFJochReaderSpots> ReadAllSpots(int64_t start_image, int64_t end_image, int64_t stride = 1) const;
};
#endif //JFJOCHIMAGEREADER_H