Files
Jungfraujoch/common/DetectorSettings.h
leonarski_fandClaude Opus 5.5 1135beb74e jfjoch_fpga_stills_test: the file's module layout, the firmware's generator limits
- Layout from the file: its NXmx module groups, else the modules the gaps of
  its pixel mask mark (any placement and orientation of 1030 x 514 modules);
  a module without a stated readout direction is read out along its long
  side from its box's corner (the multipixels are symmetric, so the frames
  are the same). The file's modules also go to the analysis.
- Distinct images per card = (its generator module frames - 1) / its
  modules, the run takes the smallest over the cards, at most
  FPGA_INTERNAL_GENERATOR_MAX_IMAGES (frame_cell, 128) and within
  FPGA_INTERNAL_GENERATOR_MAX_MODULE_FRAMES (mem_cell, 1024). The broker's
  64-image limit stays: DetectorSettings::InternalGeneratorImages takes the
  maximum as a parameter, defaulting to it. The mapping (cards, modules,
  module frames used) is printed at start.
- -K defaults to 64 MiB of mock generator memory = 128 module frames.
- Squeeze round-trip tests for a 4M and a 9M layout and a 16-module layout
  with turned and standing modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdHHZ4cogS1mrGUtfN7
2026-11-18 09:43:57 +01:00

84 lines
3.7 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <cstdint>
#include <chrono>
#include <optional>
#include "DarkMaskSettings.h"
#include "../common/Definitions.h"
enum class DetectorTiming {Auto, Trigger, Burst, Gated};
class DetectorSettings {
std::chrono::nanoseconds frame_time_pedestalG1G2 = FRAME_TIME_PEDE_G1G2;
bool internal_fpga_packet_generator = false;
int64_t internal_fpga_packet_generator_images = 1;
int64_t storage_cells = 1;
int64_t storage_cell_start = 15;
std::chrono::nanoseconds storage_cell_delay = MIN_STORAGE_CELL_DELAY;
std::chrono::nanoseconds detector_delay = std::chrono::nanoseconds{0};
int64_t pedestal_g0_frames = 0;
int64_t pedestal_g1_frames = 0;
int64_t pedestal_g2_frames = 0;
bool use_gain_hg0 = false;
bool fix_gain_g1 = false;
std::chrono::nanoseconds frame_time = std::chrono::microseconds{500};
std::optional<std::chrono::nanoseconds> count_time;
int64_t pedestal_min_image_count = PEDESTAL_MIN_IMAGE_COUNT;
std::optional<float> eiger_threshold_keV;
std::optional<int64_t> eiger_bitwidth;
DetectorTiming timing = DetectorTiming::Trigger;
public:
DetectorSettings& InternalGeneratorEnable(bool input);
// The broker's limit; the firmware's own is FPGA_INTERNAL_GENERATOR_MAX_IMAGES
static constexpr int64_t DefaultMaxInternalGeneratorImages = 64;
DetectorSettings& InternalGeneratorImages(int64_t input, int64_t max_images = DefaultMaxInternalGeneratorImages);
DetectorSettings& StorageCells(int64_t input);
DetectorSettings& StorageCellStart(int64_t input);
DetectorSettings& StorageCellDelay(const std::chrono::nanoseconds &input);
DetectorSettings& DetectorDelay(const std::chrono::nanoseconds &input);
DetectorSettings& PedestalG0Frames(int64_t input);
DetectorSettings& PedestalG1Frames(int64_t input);
DetectorSettings& PedestalG2Frames(int64_t input);
DetectorSettings& UseGainHG0(bool input);
DetectorSettings& FixGainG1(bool input);
DetectorSettings& FrameTime(const std::chrono::nanoseconds& input);
DetectorSettings& FrameTime(const std::chrono::nanoseconds& input,
const std::chrono::nanoseconds &count_time);
DetectorSettings& PedestalMinImageCount(uint32_t input);
DetectorSettings& EigerThreshold_keV(const std::optional<float> &input);
DetectorSettings& Timing(DetectorTiming input);
DetectorSettings& EigerBitDepth(const std::optional<int64_t> &input);
[[nodiscard]] bool IsInternalGeneratorEnable() const;
[[nodiscard]] int64_t GetInternalGeneratorImages() const;
[[nodiscard]] int64_t GetStorageCells() const;
[[nodiscard]] int64_t GetStorageCellStart() const;
[[nodiscard]] std::chrono::nanoseconds GetStorageCellDelay() const;
[[nodiscard]] std::chrono::nanoseconds GetDetectorDelay() const;
[[nodiscard]] int64_t GetPedestalG0Frames() const;
[[nodiscard]] int64_t GetPedestalG1Frames() const;
[[nodiscard]] int64_t GetPedestalG2Frames() const;
[[nodiscard]] bool IsUseGainHG0() const;
[[nodiscard]] bool IsFixGainG1() const;
[[nodiscard]] std::chrono::nanoseconds GetFrameTime() const;
[[nodiscard]] std::optional<std::chrono::nanoseconds> GetCountTime() const;
[[nodiscard]] std::chrono::nanoseconds GetFrameTimePedestalG1G2() const;
[[nodiscard]] uint32_t GetPedestalMinImageCount() const;
[[nodiscard]] std::optional<float> GetEigerThreshold_keV() const;
[[nodiscard]] std::optional<int64_t> GetEigerBitDepth() const;
[[nodiscard]] DetectorTiming GetTiming() const;
[[nodiscard]] bool NeedsJUNGFRAURecalibration(const DetectorSettings& other) const;
};