diff --git a/reader/JFJochXTCReader.cpp b/reader/JFJochXTCReader.cpp index baea3d85d..0ad5f1ba4 100644 --- a/reader/JFJochXTCReader.cpp +++ b/reader/JFJochXTCReader.cpp @@ -123,15 +123,29 @@ void JFJochXTCReader::ReadFiles(const std::string &path) { f.file + ": the images are not all the same size"); const std::string expt = FindExpt(frames_.front().file); - if (expt.empty()) - throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, - "XTC carries no detector geometry: put the DIALS experiment list (.expt) of " - "the run beside the XTC files, or in the directory above them"); - Logger("XTCReader").Info("{} images in XTC, geometry from {}", frames_.size(), expt); - dataset_ = std::make_shared(); dataset_->experiment = default_experiment; - ReadGeometry(expt); + has_geometry_ = !expt.empty(); + if (has_geometry_) { + Logger("XTCReader").Info("{} images in XTC, geometry from {}", frames_.size(), expt); + ReadGeometry(expt); + } else { + // XTC states no geometry. One flat panel, square-on, with its middle on the beam - the run + // measures the centre - and the pixel size, distance and wavelength to be given by the caller. + Logger("XTCReader").Info("{} images in XTC, no .expt beside them: one flat panel centred on the beam", + frames_.size()); + const auto &f0 = frames_.front(); + DetectorSetup detector = DetDECTRIS(f0.width, f0.height, "XTC camera", {}); + detector.SensorThickness_um(0); + detector.SaturationLimit(65535); + detector.BitDepthImage(32); + detector.MinFrameTime(std::chrono::microseconds(0)); + detector.MinCountTime(std::chrono::microseconds(0)); + detector.ReadOutTime(std::chrono::nanoseconds(0)); + dataset_->experiment.Detector(detector); + dataset_->experiment.BeamX_pxl(0.5f * static_cast(f0.width)); + dataset_->experiment.BeamY_pxl(0.5f * static_cast(f0.height)); + } dataset_->error_value = -1; dataset_->experiment.ImagesPerTrigger(static_cast(frames_.size())); dataset_->pixel_mask = std::make_shared(frames_.front().width, frames_.front().height); diff --git a/reader/JFJochXTCReader.h b/reader/JFJochXTCReader.h index 6b22eb4ef..17fe30f69 100644 --- a/reader/JFJochXTCReader.h +++ b/reader/JFJochXTCReader.h @@ -15,9 +15,10 @@ // not read here. // // XTC records the events and not the experiment: there is no distance, beam centre or wavelength -// in it that this reader can use. Those come from a DIALS experiment list (.expt) beside the XTC -// files, or in their parent directory - the geometry a deposition ships for cctbx.xfel, and what -// cctbx.xfel itself reads them with. Without one the run is refused rather than guessed. +// in it that this reader can use. Where a DIALS experiment list (.expt) lies beside the XTC files, or +// in their parent directory - the geometry a deposition ships for cctbx.xfel - it is read; otherwise +// the panel is placed square-on with its middle on the beam, the run measures the centre, and the +// pixel size, distance and wavelength are given on the command line. // // The images are stills: no goniometer. Each is decoded on demand. The pixels are passed on as // stored - the CCD's constant offset of a few counts is left in, as it is in an SMV image, and the @@ -25,6 +26,7 @@ class JFJochXTCReader : public JFJochReader { std::vector frames_; std::shared_ptr dataset_; + bool has_geometry_ = false; bool LoadImage_i(std::shared_ptr &dataset, DataMessage &message, @@ -44,6 +46,9 @@ public: // path is one XTC stream, or a directory whose streams are all read. void ReadFiles(const std::string &path); + // Whether a DIALS .expt beside the streams gave the geometry; without one the pixel size, the + // distance and the wavelength are the caller's to give. + [[nodiscard]] bool HasGeometry() const { return has_geometry_; } [[nodiscard]] uint64_t GetNumberOfImages() const override; void Close() override; diff --git a/rugnux/rugnux_cli.cpp b/rugnux/rugnux_cli.cpp index 4f385d706..071cc599a 100644 --- a/rugnux/rugnux_cli.cpp +++ b/rugnux/rugnux_cli.cpp @@ -1794,6 +1794,11 @@ static int RunRugnux(int argc, char **argv, bool no_gpu) { smv_reader.GetNumberOfImages(), input_file); } else if (input_is_xtc) { xtc_reader.ReadFiles(input_file); + if (!xtc_reader.HasGeometry() && (!pixel_size_um || !detector_distance_mm || !wavelength_A)) { + logger.Error("XTC states no geometry and no DIALS .expt lies beside it: give --pixel-size, " + "--detector-distance and --wavelength (the beam centre is measured)"); + exit(EXIT_FAILURE); + } reader_ptr = &xtc_reader; logger.Info("Read {} XTC still images from {}", xtc_reader.GetNumberOfImages(), input_file); } else if (std::filesystem::is_directory(input_file)) { @@ -3203,7 +3208,8 @@ static int RunRugnux(int argc, char **argv, bool no_gpu) { config.detect_beam_stop = detect_beam_stop; config.beam_center_check = beam_center_check; config.detect_saturation = !saturation_value - && (input_is_cbf || input_is_marccd || input_is_smv || input_is_crystfel || input_is_cxi); + && (input_is_cbf || input_is_marccd || input_is_smv + || input_is_crystfel || input_is_cxi || input_is_xtc); config.adaptive_integration_radius = adaptive_integration_radius; config.counts_in_adu = input_is_smv || input_is_marccd || input_is_xtc || ((input_is_crystfel || input_is_cxi) && !crystfel_reader.CountsInPhotons());