clang-format
Build on RHEL8 / build (push) Successful in 2m30s
Build on RHEL9 / build (push) Successful in 2m34s
Run tests using data on local RHEL8 / build (push) Failing after 3m10s

This commit is contained in:
2026-02-19 15:35:19 +01:00
parent 1f7a87cc30
commit 5dbc746462
34 changed files with 327 additions and 350 deletions
+3 -1
View File
@@ -378,7 +378,9 @@ ClusterFile<ClusterType, Enable>::read_frame_without_cut() {
else if (ferror(fp))
throw std::runtime_error(LOCATION + "Error reading from file");
throw std::runtime_error(LOCATION + "Unexpected error (not feof or ferror) when reading frame number");
throw std::runtime_error(
LOCATION +
"Unexpected error (not feof or ferror) when reading frame number");
}
int32_t n_clusters; // Saved as 32bit integer in the cluster file
+2 -1
View File
@@ -40,7 +40,8 @@ struct FileConfig {
// ", cols: " + std::to_string(cols) +
// ", geometry: " + geometry.to_string() +
// ", detector_type: " + ToString(detector_type) +
// ", max_frames_per_file: " + std::to_string(max_frames_per_file) +
// ", max_frames_per_file: " +
// std::to_string(max_frames_per_file) +
// ", total_frames: " + std::to_string(total_frames) + " }";
// }
};
+1 -1
View File
@@ -36,7 +36,7 @@ class NDArray : public ArrayExpr<NDArray<T, Ndim>, Ndim> {
* @brief Default constructor. Constructs an empty NDArray.
*
*/
NDArray() : shape_(), strides_(c_strides<Ndim>(shape_)), data_(nullptr) {};
NDArray() : shape_(), strides_(c_strides<Ndim>(shape_)), data_(nullptr){};
/**
* @brief Construct a new NDArray object with a given shape.
+12 -18
View File
@@ -27,15 +27,14 @@ Shape<Ndim> make_shape(const std::vector<size_t> &shape) {
return arr;
}
/**
* @brief Helper function to drop the first dimension of a shape.
* This is useful when you want to create a 2D view from a 3D array.
* @param shape The shape to drop the first dimension from.
* @return A new shape with the first dimension dropped.
*/
template<size_t Ndim>
Shape<Ndim-1> drop_first_dim(const Shape<Ndim> &shape) {
template <size_t Ndim>
Shape<Ndim - 1> drop_first_dim(const Shape<Ndim> &shape) {
static_assert(Ndim > 1, "Cannot drop first dimension from a 1D shape");
Shape<Ndim - 1> new_shape;
std::copy(shape.begin() + 1, shape.end(), new_shape.begin());
@@ -43,13 +42,12 @@ Shape<Ndim-1> drop_first_dim(const Shape<Ndim> &shape) {
}
/**
* @brief Helper function when constructing NDArray/NDView. Calculates the number
* of elements in the resulting array from a shape.
* @brief Helper function when constructing NDArray/NDView. Calculates the
* number of elements in the resulting array from a shape.
* @param shape The shape to calculate the number of elements for.
* @return The number of elements in and NDArray/NDView of that shape.
*/
template <size_t Ndim>
size_t num_elements(const Shape<Ndim> &shape) {
template <size_t Ndim> size_t num_elements(const Shape<Ndim> &shape) {
return std::accumulate(shape.begin(), shape.end(), 1,
std::multiplies<size_t>());
}
@@ -94,28 +92,28 @@ class NDView : public ArrayExpr<NDView<T, Ndim>, Ndim> {
: buffer_(buffer), strides_(c_strides<Ndim>(shape)), shape_(shape),
size_(std::accumulate(std::begin(shape), std::end(shape), 1,
std::multiplies<>())) {}
template <typename... Ix>
std::enable_if_t<sizeof...(Ix) == Ndim, T &> operator()(Ix... index) {
return buffer_[element_offset(strides_, index...)];
}
template <typename... Ix>
std::enable_if_t<sizeof...(Ix) == 1 && (Ndim > 1), NDView<T, Ndim - 1>> operator()(Ix... index) {
std::enable_if_t<sizeof...(Ix) == 1 && (Ndim > 1), NDView<T, Ndim - 1>>
operator()(Ix... index) {
// return a view of the next dimension
std::array<ssize_t, Ndim - 1> new_shape{};
std::copy_n(shape_.begin() + 1, Ndim - 1, new_shape.begin());
return NDView<T, Ndim - 1>(&buffer_[element_offset(strides_, index...)],
new_shape);
}
template <typename... Ix>
std::enable_if_t<sizeof...(Ix) == Ndim, const T &> operator()(Ix... index) const {
std::enable_if_t<sizeof...(Ix) == Ndim, const T &>
operator()(Ix... index) const {
return buffer_[element_offset(strides_, index...)];
}
ssize_t size() const { return static_cast<ssize_t>(size_); }
size_t total_bytes() const { return size_ * sizeof(T); }
std::array<ssize_t, Ndim> strides() const noexcept { return strides_; }
@@ -124,15 +122,11 @@ class NDView : public ArrayExpr<NDView<T, Ndim>, Ndim> {
T *end() { return buffer_ + size_; }
T const *begin() const { return buffer_; }
T const *end() const { return buffer_ + size_; }
/**
* @brief Access element at index i.
*/
T &operator[](ssize_t i) { return buffer_[i]; }
T &operator[](ssize_t i) { return buffer_[i]; }
/**
* @brief Access element at index i.
@@ -207,7 +201,7 @@ class NDView : public ArrayExpr<NDView<T, Ndim>, Ndim> {
void print_all() const;
/**
* @brief Create a subview of a range of the first dimension.
* @brief Create a subview of a range of the first dimension.
* This is useful for splitting a batches of frames in parallel processing.
* @param first The first index of the subview (inclusive).
* @param last The last index of the subview (exclusive).
+1 -1
View File
@@ -27,8 +27,8 @@
#include <atomic>
#include <cassert>
#include <cstdlib>
#include <cstddef>
#include <cstdlib>
#include <memory>
#include <stdexcept>
#include <type_traits>
+2 -3
View File
@@ -49,7 +49,6 @@ class RawFile : public FileInterface {
Frame read_frame(size_t frame_number) override;
std::vector<Frame> read_n(size_t n_frames) override;
/**
* @brief Read one ROI defined in the master file
* @param roi_index index of the ROI to read
@@ -63,7 +62,7 @@ class RawFile : public FileInterface {
* @brief Read all ROIs defined in the master file
* @return vector of Frames (one Frame per ROI)
*/
std::vector<Frame>read_rois();
std::vector<Frame> read_rois();
/**
* @brief Read n frames for the given ROI index
@@ -72,7 +71,7 @@ class RawFile : public FileInterface {
* @return vector of Frames
*/
std::vector<Frame> read_n_with_roi(const size_t n_frames,
const size_t roi_index);
const size_t roi_index);
void read_into(std::byte *image_buf) override;
void read_into(std::byte *image_buf, size_t n_frames) override;
-2
View File
@@ -175,11 +175,9 @@ calculate_pedestal(NDView<uint16_t, 3> raw_data, ssize_t n_threads) {
count += cnt;
}
// Will move to a NDArray<T, 3 - static_cast<ssize_t>(only_gain0)>
// if only_gain0 is true
return safe_divide<T>(accumulator, count);
}
/**
+11 -9
View File
@@ -6,12 +6,11 @@
#include <vector>
namespace aare {
uint16_t adc_sar_05_06_07_08decode64to16(uint64_t input);
uint16_t adc_sar_05_decode64to16(uint64_t input);
uint16_t adc_sar_04_decode64to16(uint64_t input);
void adc_sar_05_06_07_08decode64to16(NDView<uint64_t, 2> input,
NDView<uint16_t, 2> output);
NDView<uint16_t, 2> output);
void adc_sar_05_decode64to16(NDView<uint64_t, 2> input,
NDView<uint16_t, 2> output);
void adc_sar_04_decode64to16(NDView<uint64_t, 2> input,
@@ -22,19 +21,22 @@ void adc_sar_04_decode64to16(NDView<uint64_t, 2> input,
* and then return the lower 24 bits as an 32 bit integer
* @param input 32-ibt input value
* @param offset (should be in range 0-7 to allow for full 24 bits)
* @return uint32_t
* @return uint32_t
*/
uint32_t mask32to24bits(uint32_t input, BitOffset offset={});
uint32_t mask32to24bits(uint32_t input, BitOffset offset = {});
/**
* @brief Expand 24 bit values in a 8bit buffer to 32bit unsigned integers
* Used for detectors with 24bit counters in combination with CTB
*
* @param input View of the 24 bit data as uint8_t (no 24bit native data type exists)
* @param output Destination of the expanded data (32bit, unsigned)
* @param offset Offset within the first byte to where the data starts (0-7 bits)
*
* @param input View of the 24 bit data as uint8_t (no 24bit native data type
* exists)
* @param output Destination of the expanded data (32bit, unsigned)
* @param offset Offset within the first byte to where the data starts (0-7
* bits)
*/
void expand24to32bit(NDView<uint8_t,1> input, NDView<uint32_t,1> output, BitOffset offset={});
void expand24to32bit(NDView<uint8_t, 1> input, NDView<uint32_t, 1> output,
BitOffset offset = {});
/**
* @brief Apply custom weights to a 16-bit input value. Will sum up
+6 -7
View File
@@ -353,16 +353,15 @@ using DataTypeVariants = std::variant<uint16_t, uint32_t>;
constexpr uint16_t ADC_MASK =
0x3FFF; // used to mask out the gain bits in Jungfrau
class BitOffset{
class BitOffset {
uint8_t m_offset{};
public:
public:
BitOffset() = default;
explicit BitOffset(uint32_t offset);
uint8_t value() const {return m_offset;}
bool operator==(const BitOffset& other) const;
bool operator<(const BitOffset& other) const;
uint8_t value() const { return m_offset; }
bool operator==(const BitOffset &other) const;
bool operator<(const BitOffset &other) const;
};
} // namespace aare
+2 -2
View File
@@ -106,8 +106,8 @@ class Logger {
}
std::ostringstream &Get() {
os << Color(m_level) << "- " << Timestamp() << " " << Logger::ToString(m_level)
<< ": ";
os << Color(m_level) << "- " << Timestamp() << " "
<< Logger::ToString(m_level) << ": ";
return os;
}
+1 -2
View File
@@ -20,9 +20,8 @@ void RunInParallel(F func, const std::vector<std::pair<int, int>> &tasks) {
}
}
template <typename T>
std::vector<NDView<T,3>> make_subviews(NDView<T, 3> &data, ssize_t n_threads) {
std::vector<NDView<T, 3>> make_subviews(NDView<T, 3> &data, ssize_t n_threads) {
std::vector<NDView<T, 3>> subviews;
subviews.reserve(n_threads);
auto limits = split_task(0, data.shape(0), n_threads);