Merge branch 'detector_geometry' into 'main'
Detector Geometry customization See merge request jungfraujoch/nextgendcu!2
This commit is contained in:
@@ -33,7 +33,8 @@ int main (int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
DiffractionExperiment experiment(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2, 8, 36));
|
||||
experiment.DataStreams(2);
|
||||
experiment.PedestalG0Frames(2000).PedestalG1Frames(300).PedestalG2Frames(300);
|
||||
experiment.MaskChipEdges(true).MaskModuleEdges(true);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ ADD_LIBRARY( CommonFunctions STATIC
|
||||
SpotToSave.h
|
||||
NetworkAddressConvert.h NetworkAddressConvert.cpp
|
||||
grpcToJson.h jsonToGrpc.h to_fixed.h
|
||||
DiffractionExperiment.h DiffractionGeometry.cpp)
|
||||
DetectorGeometry.cpp DetectorGeometry.h DetectorModuleGeometry.cpp DetectorModuleGeometry.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(CommonFunctions Compression FrameSerialize libzmq JFCalibration JFJochProtoBuf -lrt)
|
||||
|
||||
|
||||
86
common/DetectorGeometry.cpp
Normal file
86
common/DetectorGeometry.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "DetectorGeometry.h"
|
||||
#include "JFJochException.h"
|
||||
#include "Definitions.h"
|
||||
|
||||
DetectorGeometry::DetectorGeometry(const std::vector<DetectorModuleGeometry> &in_modules)
|
||||
: modules(in_modules) {
|
||||
if (modules.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Module number must be positive");
|
||||
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
for (auto &m: modules) {
|
||||
width = std::max<int64_t>(width, m.GetMaxX()+1);
|
||||
height = std::max<int64_t>(height, m.GetMaxY()+1);
|
||||
}
|
||||
}
|
||||
|
||||
DetectorGeometry::DetectorGeometry(int32_t nmodules, int32_t horizontal_stacking, int32_t gap_x,
|
||||
int32_t gap_y, bool mirror_y) {
|
||||
if (horizontal_stacking <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Horizontal stacking must be positive");
|
||||
if (nmodules <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Module number must be positive");
|
||||
if (gap_x < 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Gap x has to be non-negative");
|
||||
if (gap_y < 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Gap y has to be non-negative");
|
||||
|
||||
width = horizontal_stacking * CONVERTED_MODULE_COLS + (horizontal_stacking - 1) * gap_x;
|
||||
int64_t conv_lines = nmodules / horizontal_stacking + (nmodules % horizontal_stacking > 0 ? 1 : 0);
|
||||
height = conv_lines * CONVERTED_MODULE_LINES + (conv_lines - 1) * gap_y;
|
||||
|
||||
for (int module = 0; module < nmodules; module++) {
|
||||
int64_t module_x = module % horizontal_stacking;
|
||||
int64_t module_y = module / horizontal_stacking;
|
||||
|
||||
int64_t x0 = module_x * (CONVERTED_MODULE_COLS + gap_x);
|
||||
int64_t y0 = module_y * (CONVERTED_MODULE_LINES + gap_y);
|
||||
|
||||
DetectorModuleGeometry::Direction fast = DetectorModuleGeometry::Direction::Xpos;
|
||||
DetectorModuleGeometry::Direction slow;
|
||||
if (mirror_y) {
|
||||
y0 = height - y0 - 1;
|
||||
slow = DetectorModuleGeometry::Direction::Yneg;
|
||||
} else
|
||||
slow = DetectorModuleGeometry::Direction::Ypos;
|
||||
|
||||
modules.emplace_back(x0, y0, fast, slow);
|
||||
}
|
||||
}
|
||||
|
||||
DetectorGeometry::operator JFJochProtoBuf::DetectorGeometry() const {
|
||||
JFJochProtoBuf::DetectorGeometry ret;
|
||||
ret.set_height_pxl(height);
|
||||
ret.set_width_pxl(width);
|
||||
for (auto &m: modules) {
|
||||
auto mpbf = ret.add_module_geometry();
|
||||
mpbf->set_pixel0(m.GetPixel0_X() + width * m.GetPixel0_Y());
|
||||
mpbf->set_fast_direction_step(GetDirectionStep(m.GetFastAxis()));
|
||||
mpbf->set_slow_direction_step(GetDirectionStep(m.GetSlowAxis()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetDirectionStep(DetectorModuleGeometry::Direction direction) const {
|
||||
switch (direction) {
|
||||
case DetectorModuleGeometry::Direction::Xneg:
|
||||
return -1;
|
||||
case DetectorModuleGeometry::Direction::Xpos:
|
||||
return 1;
|
||||
case DetectorModuleGeometry::Direction::Yneg:
|
||||
return -width;
|
||||
case DetectorModuleGeometry::Direction::Ypos:
|
||||
return width;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetModulesNum() const {
|
||||
return modules.size();
|
||||
}
|
||||
28
common/DetectorGeometry.h
Normal file
28
common/DetectorGeometry.h
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef JUNGFRAUJOCH_DETECTORGEOMETRY_H
|
||||
#define JUNGFRAUJOCH_DETECTORGEOMETRY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <jfjoch.pb.h>
|
||||
#include "DetectorModuleGeometry.h"
|
||||
|
||||
class DetectorGeometry {
|
||||
int64_t width;
|
||||
int64_t height;
|
||||
std::vector<DetectorModuleGeometry> modules;
|
||||
int64_t GetDirectionStep(DetectorModuleGeometry::Direction direction) const;
|
||||
public:
|
||||
DetectorGeometry(const std::vector<DetectorModuleGeometry> &pixel_0);
|
||||
DetectorGeometry(int32_t nmodules,
|
||||
int32_t horizontal_stacking = 1,
|
||||
int32_t gap_x = 0,
|
||||
int32_t gap_y = 0,
|
||||
bool mirror_y = true); // regular geometry
|
||||
operator JFJochProtoBuf::DetectorGeometry() const;
|
||||
int64_t GetModulesNum() const;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_DETECTORGEOMETRY_H
|
||||
71
common/DetectorModuleGeometry.cpp
Normal file
71
common/DetectorModuleGeometry.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "DetectorModuleGeometry.h"
|
||||
#include "JFJochException.h"
|
||||
|
||||
inline bool dir_x(DetectorModuleGeometry::Direction direction) {
|
||||
if ((direction == DetectorModuleGeometry::Direction::Xpos) ||
|
||||
(direction == DetectorModuleGeometry::Direction::Xneg))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
DetectorModuleGeometry::DetectorModuleGeometry(int64_t in_x0, int64_t in_y0,
|
||||
DetectorModuleGeometry::Direction in_fast,
|
||||
DetectorModuleGeometry::Direction in_slow) :
|
||||
x0(in_x0), y0(in_y0), fast(in_fast), slow(in_slow) {
|
||||
if ((dir_x(fast) && dir_x(slow)) || (!dir_x(fast) && !dir_x(slow)))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"One of axes (fast/slow) has to be X and another one Y.");
|
||||
if (dir_x(fast) && (fast == Direction::Xneg) && (x0 - fast_pixels + 1 < 0))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Edge of module in X is outside of the area.");
|
||||
|
||||
if (dir_x(slow) && (slow == Direction::Xneg) && (x0 - slow_pixels + 1 < 0))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Edge of module in X is outside of the area.");
|
||||
|
||||
if (dir_x(fast) && (slow == Direction::Yneg) && (y0 - slow_pixels + 1 < 0))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Edge of module in Y is outside of the area.");
|
||||
|
||||
if (dir_x(slow) && (fast == Direction::Yneg) && (y0 - fast_pixels + 1 < 0))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Edge of module in Y is outside of the area.");
|
||||
}
|
||||
|
||||
int64_t DetectorModuleGeometry::GetMaxX() const {
|
||||
if (fast == Direction::Xpos)
|
||||
return x0 + fast_pixels - 1;
|
||||
else if (slow == Direction::Xpos)
|
||||
return x0 + slow_pixels - 1;
|
||||
else
|
||||
return x0;
|
||||
}
|
||||
|
||||
int64_t DetectorModuleGeometry::GetMaxY() const {
|
||||
if (fast == Direction::Ypos)
|
||||
return y0 + fast_pixels - 1;
|
||||
else if (slow == Direction::Ypos)
|
||||
return y0 + slow_pixels - 1;
|
||||
else
|
||||
return y0;
|
||||
}
|
||||
|
||||
int64_t DetectorModuleGeometry::GetPixel0_X() const {
|
||||
return x0;
|
||||
}
|
||||
|
||||
int64_t DetectorModuleGeometry::GetPixel0_Y() const {
|
||||
return y0;
|
||||
}
|
||||
|
||||
DetectorModuleGeometry::Direction DetectorModuleGeometry::GetSlowAxis() const {
|
||||
return slow;
|
||||
}
|
||||
|
||||
DetectorModuleGeometry::Direction DetectorModuleGeometry::GetFastAxis() const {
|
||||
return fast;
|
||||
}
|
||||
34
common/DetectorModuleGeometry.h
Normal file
34
common/DetectorModuleGeometry.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef JUNGFRAUJOCH_DETECTORMODULEGEOMETRY_H
|
||||
#define JUNGFRAUJOCH_DETECTORMODULEGEOMETRY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "Definitions.h"
|
||||
|
||||
class DetectorModuleGeometry {
|
||||
public:
|
||||
enum class Direction {Xneg, Xpos, Yneg, Ypos};
|
||||
private:
|
||||
const int64_t x0;
|
||||
const int64_t y0;
|
||||
|
||||
constexpr static const int64_t fast_pixels = CONVERTED_MODULE_COLS;
|
||||
constexpr static const int64_t slow_pixels = CONVERTED_MODULE_LINES;
|
||||
|
||||
const Direction fast;
|
||||
const Direction slow;
|
||||
public:
|
||||
DetectorModuleGeometry(int64_t x0, int64_t y0, Direction fast, Direction slow);
|
||||
[[nodiscard]] int64_t GetMaxX() const;
|
||||
[[nodiscard]] int64_t GetMaxY() const;
|
||||
|
||||
[[nodiscard]] int64_t GetPixel0_X() const;
|
||||
[[nodiscard]] int64_t GetPixel0_Y() const;
|
||||
[[nodiscard]] Direction GetSlowAxis() const;
|
||||
[[nodiscard]] Direction GetFastAxis() const;
|
||||
};
|
||||
|
||||
|
||||
#endif //JUNGFRAUJOCH_DETECTORMODULEGEOMETRY_H
|
||||
@@ -31,29 +31,10 @@ DiffractionExperiment::operator JFJochProtoBuf::JungfraujochSettings() const {
|
||||
return settings;
|
||||
}
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment() : DiffractionExperiment(2, {4,4}, 0, 0, true)
|
||||
DiffractionExperiment::DiffractionExperiment() : DiffractionExperiment(DetectorGeometry(8, 2))
|
||||
{}
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment(int64_t horizontal_stacking, const std::vector<int64_t> &vec, int64_t gap_x,
|
||||
int64_t gap_y, bool mirror_y_in_conversion) {
|
||||
check_min("Gap X",gap_x, 0);
|
||||
check_min("Gap Y",gap_y, 0);
|
||||
check_min("Horizontal module stacking",horizontal_stacking, 1);
|
||||
|
||||
if (gap_x % 2 == 1)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Gap X has to be even number");
|
||||
|
||||
if (gap_y % 2 == 1)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Gap Y has to be even number");
|
||||
|
||||
if (vec.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "At least one data stream with one module needs to be defined");
|
||||
|
||||
for (const auto& val: vec) {
|
||||
if (val == 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Cannot define data stream with zero modules");
|
||||
}
|
||||
|
||||
DiffractionExperiment::DiffractionExperiment(const DetectorGeometry& geom) {
|
||||
dataset.set_photon_energy_kev(WVL_1A_IN_KEV);
|
||||
dataset.set_detector_distance_mm(100);
|
||||
dataset.mutable_scattering_vector()->set_x(0);
|
||||
@@ -70,7 +51,8 @@ DiffractionExperiment::DiffractionExperiment(int64_t horizontal_stacking, const
|
||||
|
||||
dataset.set_compression(JFJochProtoBuf::BSHUF_LZ4);
|
||||
|
||||
*internal.mutable_data_stream_modules() = {vec.begin(), vec.end()};
|
||||
internal.set_ndatastreams(1);
|
||||
internal.set_nmodules(geom.GetModulesNum());
|
||||
|
||||
internal.set_frame_time_us(MIN_FRAME_TIME_HALF_SPEED_IN_US);
|
||||
internal.set_count_time_us(MIN_FRAME_TIME_HALF_SPEED_IN_US - READOUT_TIME_IN_US);
|
||||
@@ -96,42 +78,11 @@ DiffractionExperiment::DiffractionExperiment(int64_t horizontal_stacking, const
|
||||
internal.set_storage_cells(1);
|
||||
internal.set_storage_cell_start(15);
|
||||
|
||||
CalculateGeometry(horizontal_stacking, vec, gap_x, gap_y, mirror_y_in_conversion);
|
||||
*internal.mutable_conv_geometry() = geom;
|
||||
|
||||
Mode(DetectorMode::Conversion);
|
||||
}
|
||||
|
||||
void DiffractionExperiment::CalculateGeometry(int64_t horizontal_stacking, const std::vector<int64_t> &v, int64_t gap_x,
|
||||
int64_t gap_y, bool mirror_y_in_conversion) {
|
||||
auto nmodules = GetModulesNum();
|
||||
|
||||
const auto cgeom = internal.mutable_conv_geometry();
|
||||
|
||||
cgeom->set_width_pxl(horizontal_stacking * CONVERTED_MODULE_COLS + (horizontal_stacking - 1) * gap_x);
|
||||
int64_t conv_lines = nmodules / horizontal_stacking + (nmodules % horizontal_stacking > 0 ? 1 : 0);
|
||||
cgeom->set_height_pxl(conv_lines * CONVERTED_MODULE_LINES + (conv_lines - 1) * gap_y);
|
||||
cgeom->set_mirror_modules_in_y(mirror_y_in_conversion);
|
||||
|
||||
for (int module = 0; module < nmodules; module++) {
|
||||
int64_t module_x = module % horizontal_stacking;
|
||||
int64_t module_y = module / horizontal_stacking;
|
||||
|
||||
int64_t pixel_x = module_x * (CONVERTED_MODULE_COLS + gap_x);
|
||||
int64_t pixel_y = module_y * (CONVERTED_MODULE_LINES + gap_y);
|
||||
|
||||
if (mirror_y_in_conversion)
|
||||
pixel_y = cgeom->height_pxl() - pixel_y - 1;
|
||||
|
||||
cgeom->add_pixel0_of_module(pixel_y * cgeom->width_pxl() + pixel_x);
|
||||
}
|
||||
|
||||
const auto rgeom = internal.mutable_raw_geometry();
|
||||
rgeom->set_width_pxl(RAW_MODULE_COLS);
|
||||
rgeom->set_height_pxl(nmodules * RAW_MODULE_LINES);
|
||||
rgeom->set_mirror_modules_in_y(false);
|
||||
for (int module = 0; module < nmodules; module++)
|
||||
rgeom->add_pixel0_of_module( module * RAW_MODULE_SIZE);
|
||||
}
|
||||
|
||||
// setter functions
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::Mode(DetectorMode input) {
|
||||
@@ -152,11 +103,13 @@ DiffractionExperiment &DiffractionExperiment::Mode(DetectorMode input) {
|
||||
internal.set_mode(JFJochProtoBuf::PEDESTAL_G2);
|
||||
break;
|
||||
}
|
||||
if (input == DetectorMode::Conversion)
|
||||
*internal.mutable_geometry() = internal.conv_geometry();
|
||||
else
|
||||
*internal.mutable_geometry() = internal.raw_geometry();
|
||||
return *this;
|
||||
}
|
||||
|
||||
DiffractionExperiment &DiffractionExperiment::DataStreams(int64_t input) {
|
||||
check_max("Number of data streams", input, 7);
|
||||
check_min("Number of data streams", input, 1);
|
||||
internal.set_ndatastreams(input);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -660,20 +613,20 @@ bool DiffractionExperiment::IsPixelSigned() const {
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetDataStreamsNum() const {
|
||||
return internal.data_stream_modules_size();
|
||||
return std::min(internal.ndatastreams(), internal.nmodules());
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetModulesNum(uint16_t data_stream) const {
|
||||
if (data_stream == TASK_NO_DATA_STREAM)
|
||||
return std::accumulate(internal.data_stream_modules().begin(), internal.data_stream_modules().end(), 0);
|
||||
return internal.nmodules();
|
||||
|
||||
if (data_stream >= GetDataStreamsNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Non exisiting data stream");
|
||||
return internal.data_stream_modules(data_stream);
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Non existing data stream");
|
||||
|
||||
return (internal.nmodules() + (GetDataStreamsNum() - 1) - data_stream) / GetDataStreamsNum();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetFirstModuleOfDataStream(uint16_t data_stream) const {
|
||||
if (data_stream == TASK_NO_DATA_STREAM)
|
||||
return 0;
|
||||
if (data_stream >= GetDataStreamsNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Non exisiting data stream");
|
||||
|
||||
@@ -690,35 +643,46 @@ int64_t DiffractionExperiment::GetPixelsNum() const {
|
||||
return GetXPixelsNum() * GetYPixelsNum();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetPixelsNumFullImage() const {
|
||||
return GetXPixelsNumFullImage() * GetYPixelsNumFullImage();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetXPixelsNumFullImage() const {
|
||||
if (GetDetectorMode() != DetectorMode::Conversion)
|
||||
return RAW_MODULE_COLS;
|
||||
else
|
||||
return internal.conv_geometry().width_pxl();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetXPixelsNum() const {
|
||||
if (GetBinning2x2())
|
||||
return internal.geometry().width_pxl() / 2;
|
||||
return GetXPixelsNumFullImage() / 2;
|
||||
else
|
||||
return internal.geometry().width_pxl();
|
||||
return GetXPixelsNumFullImage();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetYPixelsNum() const {
|
||||
if (GetBinning2x2())
|
||||
return internal.geometry().height_pxl() / 2;
|
||||
return GetYPixelsNumFullImage() / 2;
|
||||
else
|
||||
return internal.geometry().height_pxl();
|
||||
return GetYPixelsNumFullImage();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetYPixelsNumFullImage() const {
|
||||
if (GetDetectorMode() != DetectorMode::Conversion)
|
||||
return RAW_MODULE_LINES * GetModulesNum();
|
||||
else
|
||||
return internal.conv_geometry().height_pxl();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetPixel0OfModule(uint16_t module_number) const {
|
||||
if (module_number >= internal.geometry().pixel0_of_module_size())
|
||||
if (module_number >= GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Module number out of bounds");
|
||||
|
||||
if (GetBinning2x2()) {
|
||||
auto tmp = internal.geometry().pixel0_of_module(module_number);
|
||||
auto col = tmp % internal.geometry().width_pxl();
|
||||
auto line = tmp / internal.geometry().width_pxl();
|
||||
return line / 2 * (internal.geometry().width_pxl() / 2) + col / 2;
|
||||
} else
|
||||
return internal.geometry().pixel0_of_module(module_number);
|
||||
}
|
||||
|
||||
bool DiffractionExperiment::IsUpsideDown() const {
|
||||
return internal.geometry().mirror_modules_in_y();
|
||||
if (GetDetectorMode() != DetectorMode::Conversion)
|
||||
return RAW_MODULE_SIZE * module_number;
|
||||
else
|
||||
return internal.conv_geometry().module_geometry(module_number).pixel0();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetOverflow() const {
|
||||
@@ -1242,3 +1206,17 @@ std::string DiffractionExperiment::GetInstrumentName() const {
|
||||
std::string DiffractionExperiment::GetInstrumentNameShort() const {
|
||||
return internal.instrument_name_short();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetModuleFastDirectionStep(uint16_t module_number) const {
|
||||
if (module_number >= GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Module number out of bounds");
|
||||
|
||||
return internal.conv_geometry().module_geometry(module_number).fast_direction_step();
|
||||
}
|
||||
|
||||
int64_t DiffractionExperiment::GetModuleSlowDirectionStep(uint16_t module_number) const {
|
||||
if (module_number >= GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Module number out of bounds");
|
||||
|
||||
return internal.conv_geometry().module_geometry(module_number).slow_direction_step();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Definitions.h"
|
||||
#include "../frame_serialize/StartMessage.h"
|
||||
#include "../frame_serialize/EndMessage.h"
|
||||
#include "DetectorGeometry.h"
|
||||
|
||||
enum class DetectorMode : int {
|
||||
Conversion, Raw, PedestalG0, PedestalG1, PedestalG2
|
||||
@@ -26,19 +27,17 @@ class DiffractionExperiment {
|
||||
JFJochProtoBuf::DatasetSettings dataset;
|
||||
JFJochProtoBuf::InternalSettings internal;
|
||||
|
||||
void CalculateGeometry(int64_t horizontal_stacking, const std::vector<int64_t> &v, int64_t gap_x, int64_t gap_y,
|
||||
bool mirror_y_in_conversion);
|
||||
constexpr static const int64_t max_spot_count = 100;
|
||||
DiffractionExperiment& SetUnitCell(const JFJochProtoBuf::UnitCell &input);
|
||||
public:
|
||||
// Public methods are atomic
|
||||
DiffractionExperiment();
|
||||
DiffractionExperiment(int64_t horizontal_stacking, const std::vector<int64_t> &v, int64_t gap_x = 0, int64_t gap_y = 0,
|
||||
bool mirror_y_in_conversion = true);
|
||||
DiffractionExperiment(const DetectorGeometry& geom);
|
||||
explicit DiffractionExperiment(const JFJochProtoBuf::JungfraujochSettings &settings);
|
||||
|
||||
// Methods below can be chained together
|
||||
DiffractionExperiment& Mode(DetectorMode input);
|
||||
DiffractionExperiment& DataStreams(int64_t input);
|
||||
|
||||
DiffractionExperiment& Import(const JFJochProtoBuf::JungfraujochSettings &settings);
|
||||
|
||||
@@ -154,11 +153,17 @@ public:
|
||||
int64_t GetFirstModuleOfDataStream(uint16_t data_stream) const;
|
||||
|
||||
int64_t GetPixelsNum() const;
|
||||
int64_t GetYPixelsNum() const;
|
||||
int64_t GetXPixelsNum() const; // X pixels must be the same for all modules
|
||||
int64_t GetPixelsNumFullImage() const; // before filters, like ROI or binning
|
||||
|
||||
int64_t GetPixel0OfModule(uint16_t module_number) const;
|
||||
bool IsUpsideDown() const;
|
||||
int64_t GetYPixelsNum() const;
|
||||
int64_t GetYPixelsNumFullImage() const; // before filters, like ROI or binning
|
||||
|
||||
int64_t GetXPixelsNum() const;
|
||||
int64_t GetXPixelsNumFullImage() const; // before filters, like ROI or binning
|
||||
|
||||
int64_t GetPixel0OfModule(uint16_t module_number) const; // before filters, like ROI or binning
|
||||
int64_t GetModuleFastDirectionStep(uint16_t module_number) const; // before filters, like ROI or binning
|
||||
int64_t GetModuleSlowDirectionStep(uint16_t module_number) const; // before filters, like ROI or binning
|
||||
|
||||
std::chrono::microseconds GetPreviewPeriod() const;
|
||||
int64_t GetPreviewStride() const;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <cmath>
|
||||
#include "DiffractionGeometry.h"
|
||||
|
||||
DiffractionGeometry::DiffractionGeometry(float in_beam_x_pxl, float in_beam_y_pxl, float in_detector_distance_mm,
|
||||
float in_pixel_size_mm, float in_wavelength_A, Coord in_scattering_vector)
|
||||
: beam_x_pxl(in_beam_x_pxl),
|
||||
beam_y_pxl(in_beam_y_pxl),
|
||||
detector_distance_mm(in_detector_distance_mm),
|
||||
pixel_size_mm(in_pixel_size_mm),
|
||||
wavelength_A(in_wavelength_A),
|
||||
scattering_vector(in_scattering_vector) {}
|
||||
|
||||
Coord DiffractionGeometry::DetectorToLab(float x_pxl, float y_pxl) const {
|
||||
// Assumes planar detector, 90 deg towards beam
|
||||
return {(x_pxl - beam_x_pxl) * pixel_size_mm ,
|
||||
(y_pxl - beam_y_pxl) * pixel_size_mm ,
|
||||
detector_distance_mm};
|
||||
}
|
||||
|
||||
Coord DiffractionGeometry::DetectorToRecip(float x_pxl, float y_pxl) const {
|
||||
return DetectorToLab(x_pxl, y_pxl).Normalize() / wavelength_A - scattering_vector;
|
||||
}
|
||||
|
||||
float DiffractionGeometry::PxlToRes(float detector_x, float detector_y) const {
|
||||
auto lab = DetectorToLab(detector_x, detector_y);
|
||||
|
||||
float beam_path = lab.Length();
|
||||
if (beam_path == detector_distance_mm) return INFINITY;
|
||||
|
||||
float cos_2theta = detector_distance_mm / beam_path;
|
||||
// cos(2theta) = cos(theta)^2 - sin(theta)^2
|
||||
// cos(2theta) = 1 - 2*sin(theta)^2
|
||||
// Technically two solutions for two theta, but it makes sense only to take positive one in this case
|
||||
float sin_theta = sqrt((1-cos_2theta)/2);
|
||||
return wavelength_A / (2 * sin_theta);
|
||||
}
|
||||
|
||||
float DiffractionGeometry::ResToPxl(float resolution) const {
|
||||
if (resolution == 0)
|
||||
return INFINITY;
|
||||
|
||||
float sin_theta = wavelength_A / (2 * resolution);
|
||||
float theta = asin(sin_theta);
|
||||
float tan_2theta = tan(2 * theta);
|
||||
return tan_2theta * detector_distance_mm / pixel_size_mm;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#ifndef DIFFRACTIONGEOMETRY_H
|
||||
#define DIFFRACTIONGEOMETRY_H
|
||||
|
||||
#include "Coord.h"
|
||||
#include "DiffractionSpot.h"
|
||||
|
||||
class DiffractionGeometry {
|
||||
const float beam_x_pxl;
|
||||
const float beam_y_pxl;
|
||||
const float detector_distance_mm;
|
||||
const float pixel_size_mm;
|
||||
const float wavelength_A;
|
||||
const Coord scattering_vector;
|
||||
public:
|
||||
DiffractionGeometry(float beam_x_pxl,
|
||||
float beam_y_pxl,
|
||||
float detector_distance_mm,
|
||||
float pixel_size_mm,
|
||||
float wavelength_A,
|
||||
Coord scattering_vector);
|
||||
Coord DetectorToLab(float x_pxl, float y_pxl) const;
|
||||
Coord DetectorToRecip(float x_pxl, float y_pxl) const;
|
||||
|
||||
float ResToPxl(float resolution) const;
|
||||
float PxlToRes(float detector_x, float detector_y) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,8 +12,6 @@
|
||||
FrameTransformation::FrameTransformation(const DiffractionExperiment &in_experiment) :
|
||||
experiment(in_experiment), summation(experiment.GetSummation()),
|
||||
pixel_depth(experiment.GetPixelDepth()), compressor(in_experiment.GetCompressionAlgorithmEnum()),
|
||||
compression_algorithm(in_experiment.GetCompressionAlgorithmEnum()),
|
||||
line_shift((experiment.IsUpsideDown() ? -1 : 1) * experiment.GetXPixelsNum()),
|
||||
binning_2x2(experiment.GetBinning2x2()) {
|
||||
|
||||
if ((experiment.GetDetectorMode() == DetectorMode::Conversion) && (summation > 1)) {
|
||||
@@ -25,6 +23,9 @@ FrameTransformation::FrameTransformation(const DiffractionExperiment &in_experim
|
||||
if (pixel_depth == 4)
|
||||
image16bit.resize(experiment.GetPixelsNum(), 0);
|
||||
|
||||
if (binning_2x2)
|
||||
full_image_buffer.resize(experiment.GetPixelsNumFullImage() * pixel_depth);
|
||||
|
||||
if (experiment.GetApplyPixelMaskInFPGA()) {
|
||||
// Mask gaps
|
||||
if (pixel_depth == 2) {
|
||||
@@ -56,24 +57,32 @@ template <class Td> void AddToFramesSum(Td *destination, const int16_t *source)
|
||||
|
||||
void FrameTransformation::PackSummation() {
|
||||
for (int m = 0; m < experiment.GetModulesNum(); m++) {
|
||||
void *output = precompression_buffer.data() + sizeof(int32_t) * experiment.GetPixel0OfModule(m);
|
||||
int32_t *output;
|
||||
if (binning_2x2)
|
||||
TransferModuleAdjustMultipixelsBin2x2((int32_t *) output,
|
||||
(int32_t *) summation_buffer[m].data(),
|
||||
line_shift,
|
||||
static_cast<int32_t>(INT32_MIN),
|
||||
static_cast<int32_t>(INT32_MAX));
|
||||
output = (int32_t *) full_image_buffer.data();
|
||||
else
|
||||
TransferModuleAdjustMultipixels((int32_t *) output,
|
||||
(int32_t *) summation_buffer[m].data(),
|
||||
line_shift,
|
||||
static_cast<int32_t>(INT32_MIN),
|
||||
static_cast<int32_t>(INT32_MAX));
|
||||
output = (int32_t *) precompression_buffer.data();
|
||||
|
||||
TransferModuleAdjustMultipixels(output,
|
||||
(int32_t *) summation_buffer[m].data(),
|
||||
experiment.GetModuleSlowDirectionStep(m),
|
||||
static_cast<int32_t>(INT32_MIN),
|
||||
static_cast<int32_t>(INT32_MAX),
|
||||
experiment.GetModuleFastDirectionStep(m),
|
||||
experiment.GetPixel0OfModule(m));
|
||||
|
||||
for (auto &i: summation_buffer[m])
|
||||
i = 0;
|
||||
}
|
||||
|
||||
if (binning_2x2)
|
||||
Bin2x2_sum<int32_t>((int32_t *) precompression_buffer.data(),
|
||||
(int32_t *) full_image_buffer.data(),
|
||||
experiment.GetXPixelsNumFullImage(),
|
||||
experiment.GetYPixelsNumFullImage(),
|
||||
static_cast<int32_t>(experiment.GetUnderflow()),
|
||||
static_cast<int32_t>(experiment.GetOverflow()));
|
||||
|
||||
if (pixel_depth == 4) {
|
||||
// Generate 16-bit preview image
|
||||
auto arr = (int32_t *) precompression_buffer.data();
|
||||
@@ -92,13 +101,19 @@ void FrameTransformation::PackSummation() {
|
||||
size_t FrameTransformation::PackStandardOutput() {
|
||||
if (summation > 1)
|
||||
PackSummation();
|
||||
|
||||
else {
|
||||
if (binning_2x2)
|
||||
Bin2x2_sum<int16_t>((int16_t *) precompression_buffer.data(),
|
||||
(int16_t *) full_image_buffer.data(),
|
||||
experiment.GetXPixelsNumFullImage(),
|
||||
experiment.GetYPixelsNumFullImage(),
|
||||
INT16_MIN, INT16_MAX);
|
||||
}
|
||||
return compressor.Compress(standard_output, precompression_buffer.data(),
|
||||
experiment.GetPixelsNum(), pixel_depth);
|
||||
}
|
||||
|
||||
void FrameTransformation::ProcessModule(const int16_t *input, size_t frame_number, uint16_t module_number,
|
||||
int data_stream) {
|
||||
void FrameTransformation::ProcessModule(const int16_t *input, uint16_t module_number, int data_stream) {
|
||||
if (standard_output == nullptr)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Default stream output not initialized");
|
||||
|
||||
@@ -107,18 +122,22 @@ void FrameTransformation::ProcessModule(const int16_t *input, size_t frame_numbe
|
||||
if (summation == 1) {
|
||||
int16_t *output;
|
||||
|
||||
output = ((int16_t *) precompression_buffer.data()) + experiment.GetPixel0OfModule(module_number_abs);
|
||||
if (binning_2x2)
|
||||
output = (int16_t *) full_image_buffer.data();
|
||||
else
|
||||
output = (int16_t *) precompression_buffer.data();
|
||||
|
||||
if (experiment.GetDetectorMode() != DetectorMode::Conversion)
|
||||
memcpy(output, input, RAW_MODULE_SIZE * experiment.GetPixelDepth());
|
||||
else if (binning_2x2)
|
||||
TransferModuleAdjustMultipixelsBin2x2((int16_t *) output, (int16_t *) input, line_shift,
|
||||
static_cast<int16_t>(INT16_MIN),
|
||||
static_cast<int16_t>(INT16_MAX));
|
||||
memcpy(output + RAW_MODULE_SIZE * module_number_abs,
|
||||
input,
|
||||
RAW_MODULE_SIZE * experiment.GetPixelDepth());
|
||||
else
|
||||
TransferModuleAdjustMultipixels((int16_t *) output, (int16_t *) input, line_shift,
|
||||
TransferModuleAdjustMultipixels(output, (int16_t *) input,
|
||||
experiment.GetModuleSlowDirectionStep(module_number_abs),
|
||||
static_cast<int16_t>(INT16_MIN),
|
||||
static_cast<int16_t>(INT16_MAX));
|
||||
static_cast<int16_t>(INT16_MAX),
|
||||
experiment.GetModuleFastDirectionStep(module_number_abs),
|
||||
experiment.GetPixel0OfModule(module_number_abs));
|
||||
} else {
|
||||
AddToFramesSum(summation_buffer[module_number_abs].data(), input);
|
||||
}
|
||||
@@ -131,18 +150,30 @@ int16_t *FrameTransformation::GetPreview16BitImage() {
|
||||
return image16bit.data();
|
||||
}
|
||||
|
||||
void FrameTransformation::ProcessModule(JFConversion &conv, const int16_t *input, size_t frame_number,
|
||||
uint16_t module_number, int data_stream) {
|
||||
void FrameTransformation::ProcessModule(JFConversion &conv, const int16_t *input, uint16_t module_number, int data_stream) {
|
||||
if (standard_output == nullptr)
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Default stream output not initialized");
|
||||
|
||||
size_t module_number_abs = experiment.GetFirstModuleOfDataStream(data_stream) + module_number;
|
||||
|
||||
auto output = ((int16_t *) precompression_buffer.data()) + experiment.GetPixel0OfModule(module_number_abs);
|
||||
if (summation == 1) {
|
||||
int16_t *output;
|
||||
|
||||
if (experiment.GetDetectorMode() != DetectorMode::Conversion)
|
||||
memcpy(output, input, RAW_MODULE_SIZE * experiment.GetPixelDepth());
|
||||
else
|
||||
conv.ConvertAdjustGeom((int16_t *) output, (uint16_t *) input, line_shift);
|
||||
if (binning_2x2)
|
||||
output = (int16_t *) full_image_buffer.data();
|
||||
else
|
||||
output = (int16_t *) precompression_buffer.data();
|
||||
|
||||
if (experiment.GetDetectorMode() != DetectorMode::Conversion)
|
||||
memcpy(output + RAW_MODULE_SIZE * module_number_abs, input, RAW_MODULE_SIZE * experiment.GetPixelDepth());
|
||||
else
|
||||
conv.ConvertAdjustGeom((int16_t *) output, (uint16_t *) input,
|
||||
experiment.GetModuleSlowDirectionStep(module_number_abs),
|
||||
experiment.GetModuleFastDirectionStep(module_number_abs),
|
||||
experiment.GetPixel0OfModule(module_number_abs));
|
||||
} else {
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Summation with CPU conversion not supported at the moment");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ class FrameTransformation {
|
||||
const DiffractionExperiment& experiment;
|
||||
JFJochBitShuffleCompressor compressor;
|
||||
|
||||
CompressionAlgorithm compression_algorithm;
|
||||
|
||||
std::vector<std::vector<int32_t> > summation_buffer;
|
||||
std::vector<char> precompression_buffer;
|
||||
std::vector<int16_t> image16bit;
|
||||
@@ -22,15 +20,15 @@ class FrameTransformation {
|
||||
|
||||
const size_t summation;
|
||||
const size_t pixel_depth;
|
||||
const int64_t line_shift;
|
||||
|
||||
std::vector<char> full_image_buffer;
|
||||
bool binning_2x2;
|
||||
void PackSummation(); // transfer summed image to converted coordinates, clear summation buffer, no compression
|
||||
public:
|
||||
FrameTransformation(const DiffractionExperiment &experiment);
|
||||
FrameTransformation& SetOutput(void *output);
|
||||
void ProcessModule(const int16_t *input, size_t frame_number, uint16_t module_number, int data_stream);
|
||||
void ProcessModule(JFConversion &conv, const int16_t *input, size_t frame_number, uint16_t module_number,
|
||||
void ProcessModule(const int16_t *input, uint16_t module_number, int data_stream);
|
||||
void ProcessModule(JFConversion &conv, const int16_t *input, uint16_t module_number,
|
||||
int data_stream);
|
||||
size_t PackStandardOutput(); // transfer summed image to converted coordinates, clear summation buffer, compress
|
||||
|
||||
|
||||
@@ -8,61 +8,70 @@
|
||||
#include "DiffractionExperiment.h"
|
||||
|
||||
// Take half of the number, but only if not bad pixel/overload
|
||||
template <typename T> T half(T in, T min, T max) {
|
||||
template<typename T>
|
||||
T half(T in, T min, T max) {
|
||||
T tmp = in;
|
||||
if ((in > min) && (in < max)) tmp /= 2;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <typename T> T quarter(T in, T min, T max) {
|
||||
template<typename T>
|
||||
T quarter(T in, T min, T max) {
|
||||
T tmp = in;
|
||||
if ((in > min) && (in < max)) tmp /= 4;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// Copy line, divide everything by 2 and extend multipixels + divide them by additional factor of 2
|
||||
template <typename Td, typename Ts> void LineCopyAndAdjustMultipixelMidRow(Td *destination, const Ts* source, Ts min, Ts max) {
|
||||
template<typename Td, typename Ts>
|
||||
void LineCopyAndAdjustMultipixelMidRow(Td *destination, const Ts *source, Ts min, Ts max,
|
||||
int64_t fast_dir_step = 1, int64_t offset_0 = 0) {
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
destination[i+chip*258] = half(source[i+chip*256], min, max);
|
||||
destination[offset_0 + (i + chip * 258) * fast_dir_step] = half(source[i + chip * 256], min, max);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
destination[255+i*258] = quarter(source[255 + i*256], min, max);
|
||||
destination[256+i*258] = quarter(source[255 + i*256], min, max);
|
||||
destination[257+i*258] = quarter(source[256 + i*256], min, max);
|
||||
destination[258+i*258] = quarter(source[256 + i*256], min, max);
|
||||
destination[offset_0 + (255 + i * 258) * fast_dir_step] = quarter(source[255 + i * 256], min, max);
|
||||
destination[offset_0 + (256 + i * 258) * fast_dir_step] = quarter(source[255 + i * 256], min, max);
|
||||
destination[offset_0 + (257 + i * 258) * fast_dir_step] = quarter(source[256 + i * 256], min, max);
|
||||
destination[offset_0 + (258 + i * 258) * fast_dir_step] = quarter(source[256 + i * 256], min, max);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy line and extend multipixels + divide them by 2
|
||||
template <typename Td, typename Ts> void LineCopyAndAdjustMultipixel(Td *destination, const Ts* source, Ts min, Ts max) {
|
||||
template<typename Td, typename Ts>
|
||||
void LineCopyAndAdjustMultipixel(Td *destination, const Ts *source, Ts min, Ts max,
|
||||
int64_t fast_dir_step = 1, int64_t offset_0 = 0) {
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
destination[i + chip * 258] = source[i + chip * 256];
|
||||
destination[offset_0 + (i + chip * 258) * fast_dir_step] = source[i + chip * 256];
|
||||
}
|
||||
}
|
||||
for (int chip = 0; chip < 3; chip++) {
|
||||
destination[255+chip*258] = half(source[255 + chip*256], min, max);
|
||||
destination[256+chip*258] = half(source[255 + chip*256], min, max);
|
||||
destination[257+chip*258] = half(source[256 + chip*256], min, max);
|
||||
destination[258+chip*258] = half(source[256 + chip*256], min, max);
|
||||
destination[offset_0 + (255 + chip * 258) * fast_dir_step] = half(source[255 + chip * 256], min, max);
|
||||
destination[offset_0 + (256 + chip * 258) * fast_dir_step] = half(source[255 + chip * 256], min, max);
|
||||
destination[offset_0 + (257 + chip * 258) * fast_dir_step] = half(source[256 + chip * 256], min, max);
|
||||
destination[offset_0 + (258 + chip * 258) * fast_dir_step] = half(source[256 + chip * 256], min, max);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy line and copy multipixels (e.g. for mask)
|
||||
template <typename Td, typename Ts> void LineCopyAndAddMultipixel(Td *destination, const Ts* source) {
|
||||
template<typename Td, typename Ts>
|
||||
void LineCopyAndAddMultipixel(Td *destination, const Ts *source,
|
||||
int64_t fast_dir_step = 1, int64_t offset_0 = 0) {
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 0; i < 256; i++)
|
||||
destination[i+chip*258] = source[i+chip*256];
|
||||
destination[offset_0 + (i + chip * 258) * fast_dir_step] = source[i + chip * 256];
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
destination[256+i*258] = source[255 + i*256];
|
||||
destination[257+i*258] = source[256 + i*256];
|
||||
destination[offset_0 + (256 + i * 258) * fast_dir_step] = source[255 + i * 256];
|
||||
destination[offset_0 + (257 + i * 258) * fast_dir_step] = source[256 + i * 256];
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Tint = int32_t>
|
||||
|
||||
template<class T, class Tint = int32_t>
|
||||
T Bin2x2_sum(T a, T b, T c, T d, T underload, T overload) {
|
||||
T ret;
|
||||
if ((a <= underload) || (b <= underload) || (c <= underload) || (d <= underload))
|
||||
@@ -70,7 +79,7 @@ T Bin2x2_sum(T a, T b, T c, T d, T underload, T overload) {
|
||||
else if ((a >= overload) || (b >= overload) || (c >= overload) || (d >= overload))
|
||||
ret = overload;
|
||||
else {
|
||||
Tint sum = a + b + c +d;
|
||||
Tint sum = a + b + c + d;
|
||||
if (sum > overload)
|
||||
ret = overload;
|
||||
else
|
||||
@@ -79,198 +88,92 @@ T Bin2x2_sum(T a, T b, T c, T d, T underload, T overload) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Copy line and copy multipixels (e.g. for mask)
|
||||
template <class Ts, class Tint = int32_t>
|
||||
void LineCopyAndAdjustMultipixelBin2x2(Ts *destination, const Ts* source, Ts min, Ts max) {
|
||||
|
||||
destination[0] = Bin2x2_sum<Ts, Tint>(source[0], source[1], source[1024], source[1025], min, max);
|
||||
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 1; i < 127; i++)
|
||||
destination[i + 129 * chip] = Bin2x2_sum<Ts, Tint>(source[2 * i + 256*chip],
|
||||
source[2 * i + 1 + 256*chip],
|
||||
source[2 * i + 1024 + 256*chip],
|
||||
source[2 * i + 1025 + 256*chip],
|
||||
min, max);
|
||||
}
|
||||
|
||||
destination[514] = Bin2x2_sum<Ts, Tint>(source[1022], source[1023], source[2046], source[2047], min, max);
|
||||
|
||||
for (int chip = 0; chip < 3; chip++) {
|
||||
destination[127 + chip * 129] = Bin2x2_sum<Ts, Tint>(source[254 + chip * 256],
|
||||
half(source[255 + chip * 256], min, max),
|
||||
source[254 + chip * 256 + 1024],
|
||||
half(source[255 + chip * 256 + 1024], min, max),
|
||||
min, max);
|
||||
destination[128 + chip * 129] = Bin2x2_sum<Ts, Tint>(half(source[255 + chip * 256], min, max),
|
||||
half(source[256 + chip * 256], min, max),
|
||||
half(source[255 + chip * 256 + 1024], min, max),
|
||||
half(source[256 + chip * 256 + 1024], min, max),
|
||||
min, max);
|
||||
destination[129 + chip * 129] = Bin2x2_sum<Ts, Tint>(source[257 + chip * 256],
|
||||
half(source[256 + chip * 256], min, max),
|
||||
source[257 + chip * 256 + 1024],
|
||||
half(source[256 + chip * 256 + 1024], min, max),
|
||||
min, max);
|
||||
};
|
||||
}
|
||||
|
||||
template <class Ts, class Tint = int32_t>
|
||||
void LineCopyAndAdjustMultipixelBin2x2MidRow(Ts *destination, const Ts* source, Ts min, Ts max) {
|
||||
|
||||
destination[0] = Bin2x2_sum<Ts, Tint>(source[0], source[1], 0, 0, min, max);
|
||||
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 1; i < 127; i++)
|
||||
destination[i + 129*chip] = Bin2x2_sum<Ts, Tint>(source[2 * i + 256*chip],
|
||||
source[2 * i + 1 + 256*chip],
|
||||
0,
|
||||
0,
|
||||
min, max);
|
||||
}
|
||||
|
||||
destination[514] = Bin2x2_sum<Ts, Tint>(source[1022], source[1023], 0, 0, min, max);
|
||||
|
||||
for (int chip = 0; chip < 3; chip++) {
|
||||
destination[127+chip*129] = Bin2x2_sum<Ts, Tint>(source[254 + chip * 256],
|
||||
half(source[255 + chip * 256], min, max),
|
||||
0,
|
||||
0,
|
||||
min, max);
|
||||
destination[128+chip*129] = Bin2x2_sum<Ts, Tint>(half(source[255 + chip * 256], min, max),
|
||||
half(source[256 + chip * 256], min, max),
|
||||
0,
|
||||
0,
|
||||
min, max);
|
||||
destination[129+chip*129] = Bin2x2_sum<Ts, Tint>(source[257 + chip * 256],
|
||||
half(source[256 + chip * 256], min, max),
|
||||
0,
|
||||
0,
|
||||
min, max);
|
||||
template<class T, class Tint = int32_t>
|
||||
void Bin2x2_sum(T *destination, const T *source, size_t width, size_t height, T underload, T overload) {
|
||||
for (int y = 0; y < height / 2; y++) {
|
||||
for (int x = 0; x < width / 2; x++)
|
||||
destination[y * (width / 2) + x] = Bin2x2_sum<T, Tint>(source[(y * 2) * width + (x * 2)],
|
||||
source[(y * 2 + 1) * width + (x * 2)],
|
||||
source[(y * 2) * width + (x * 2 + 1)],
|
||||
source[(y * 2 + 1) * width + (x * 2 + 1)],
|
||||
underload, overload);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Td, class Ts> void TransferModule(Td *destination, const Ts *source, int64_t line_shift) {
|
||||
template<class Td, class Ts>
|
||||
void TransferModule(Td *destination, const Ts *source,
|
||||
int64_t slow_dir_step,
|
||||
int64_t fast_dir_step = 1,
|
||||
int64_t offset_0 = 0) {
|
||||
for (size_t line = 0; line < RAW_MODULE_LINES; line++) {
|
||||
if ((line == 255) || (line == 256)) {
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + line_shift * (line + 1), source + RAW_MODULE_COLS * line);
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + line_shift * (line + ((line > 255) ? 2 : 0)), source + RAW_MODULE_COLS * line);
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + slow_dir_step * (line + 1),
|
||||
source + RAW_MODULE_COLS * line,
|
||||
fast_dir_step, offset_0);
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
source + RAW_MODULE_COLS * line,
|
||||
fast_dir_step, offset_0);
|
||||
} else {
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + line_shift * (line + ((line > 255) ? 2 : 0)), source + RAW_MODULE_COLS * line);
|
||||
LineCopyAndAddMultipixel<Td, Ts>(destination + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
source + RAW_MODULE_COLS * line,
|
||||
fast_dir_step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Td, class Ts> void TransferModuleAdjustMultipixels(Td *destination, const Ts *source, int64_t line_shift, Ts min, Ts max) {
|
||||
template<class Td, class Ts>
|
||||
void TransferModuleAdjustMultipixels(Td *destination, const Ts *source, int64_t slow_dir_step, Ts min, Ts max,
|
||||
int64_t fast_dir_step = 1, int64_t offset_0 = 0) {
|
||||
for (size_t line = 0; line < RAW_MODULE_LINES; line++) {
|
||||
if ((line != 255) && (line != 256))
|
||||
LineCopyAndAdjustMultipixel<Td, Ts>(destination + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
source + RAW_MODULE_COLS * line, min, max);
|
||||
LineCopyAndAdjustMultipixel<Td, Ts>(destination + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
source + RAW_MODULE_COLS * line, min, max, fast_dir_step,
|
||||
offset_0);
|
||||
else {
|
||||
LineCopyAndAdjustMultipixelMidRow<Td, Ts>(destination + line_shift * (line + 1),
|
||||
source + RAW_MODULE_COLS * line, min, max);
|
||||
memcpy(destination + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
destination + line_shift * (line + 1),CONVERTED_MODULE_COLS*sizeof(Td));
|
||||
LineCopyAndAdjustMultipixelMidRow<Td, Ts>(destination + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
source + RAW_MODULE_COLS * line, min, max,
|
||||
fast_dir_step, offset_0);
|
||||
LineCopyAndAdjustMultipixelMidRow<Td, Ts>(destination + slow_dir_step * (line + 1),
|
||||
source + RAW_MODULE_COLS * line, min, max,
|
||||
fast_dir_step, offset_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Ts, class Tint = int32_t>
|
||||
void TransferModuleAdjustMultipixelsBin2x2(Ts *destination, const Ts *source,
|
||||
int64_t line_shift, Ts min, Ts max) {
|
||||
for (size_t line = 0; line < RAW_MODULE_LINES/2; line++) {
|
||||
if (line == 127)
|
||||
LineCopyAndAdjustMultipixelBin2x2MidRow<Ts, Tint>(destination + line_shift * 128,
|
||||
source + 255 * RAW_MODULE_COLS, min, max);
|
||||
if (line == 128)
|
||||
LineCopyAndAdjustMultipixelBin2x2MidRow<Ts, Tint>(destination + line_shift * 129,
|
||||
source + 256 * RAW_MODULE_COLS, min, max);
|
||||
else
|
||||
LineCopyAndAdjustMultipixelBin2x2<Ts, Tint>(destination + line_shift * (line + ((line > 127) ? 1 : 0)),
|
||||
source + line * 2 * RAW_MODULE_COLS, min, max);
|
||||
}
|
||||
}
|
||||
|
||||
inline std::pair<int64_t, int64_t> RawToConvertedCoordinate(const DiffractionExperiment& experiment,
|
||||
uint32_t module_number,
|
||||
uint32_t pixel_within_module) {
|
||||
int64_t line0 = experiment.GetPixel0OfModule(module_number) / experiment.GetXPixelsNum();
|
||||
int64_t col0 = experiment.GetPixel0OfModule(module_number) % experiment.GetXPixelsNum();
|
||||
|
||||
int64_t line = pixel_within_module / RAW_MODULE_COLS;
|
||||
int64_t col = pixel_within_module % RAW_MODULE_COLS;
|
||||
|
||||
line += (line / 256) * 2;
|
||||
col += (col / 256) * 2;
|
||||
|
||||
return {col0 + col, line0 + (experiment.IsUpsideDown() ? -1 : 1) * line};
|
||||
}
|
||||
|
||||
inline Coord RawToConvertedCoordinate(const DiffractionExperiment& experiment, uint16_t data_stream, const Coord &raw) {
|
||||
if (experiment.GetDetectorMode() == DetectorMode::Conversion) {
|
||||
size_t module_number = experiment.GetFirstModuleOfDataStream(data_stream) + raw.y / RAW_MODULE_LINES;
|
||||
double line = raw.y - floor(raw.y / RAW_MODULE_LINES) * RAW_MODULE_LINES;
|
||||
double col = raw.x;
|
||||
|
||||
line += floor(line / 256) * 2;
|
||||
col += floor(col / 256) * 2;
|
||||
|
||||
Coord out(experiment.GetPixel0OfModule(module_number) % experiment.GetXPixelsNum(),
|
||||
experiment.GetPixel0OfModule(module_number) / experiment.GetXPixelsNum(),
|
||||
raw.z);
|
||||
out.x += col;
|
||||
out.y += (experiment.IsUpsideDown() ? -1 : 1) * line;
|
||||
|
||||
return out;
|
||||
} else return raw;
|
||||
}
|
||||
|
||||
// Input coord is column + 1024 * (line + 512 * module)
|
||||
// Copies result over multipixel - can be used for example for mask calculation
|
||||
template <class Td, class Ts> void RawToConvertedGeometry(const DiffractionExperiment& experiment, Td *destination, const Ts *source) {
|
||||
template<class Td, class Ts>
|
||||
void RawToConvertedGeometry(const DiffractionExperiment &experiment, Td *destination, const Ts *source) {
|
||||
for (size_t module_number = 0; module_number < experiment.GetModulesNum(); module_number++)
|
||||
TransferModule<Td, Ts>(destination + experiment.GetPixel0OfModule(module_number),
|
||||
source + module_number * RAW_MODULE_SIZE,
|
||||
(experiment.IsUpsideDown() ? -1 : 1) * experiment.GetXPixelsNum());
|
||||
experiment.GetModuleSlowDirectionStep(module_number),
|
||||
experiment.GetModuleFastDirectionStep(module_number));
|
||||
}
|
||||
|
||||
|
||||
// Input coord is column + 1024 * (line + 512 * module)
|
||||
template <class Ts> void RawToConvertedGeometryAdjustMultipixels(const DiffractionExperiment& experiment, Ts *destination, const Ts *source) {
|
||||
Ts min = experiment.GetUnderflow() + 1;
|
||||
if (min > 0) min = 0;
|
||||
Ts max = experiment.GetOverflow() - 1;
|
||||
|
||||
for (size_t module_number = 0; module_number < experiment.GetModulesNum(); module_number++) {
|
||||
if (experiment.GetBinning2x2())
|
||||
TransferModuleAdjustMultipixelsBin2x2<Ts, float>(destination + experiment.GetPixel0OfModule(module_number),
|
||||
source + module_number * RAW_MODULE_SIZE,
|
||||
(experiment.IsUpsideDown() ? -1 : 1) * experiment.GetXPixelsNum(), min, max);
|
||||
else
|
||||
TransferModuleAdjustMultipixels<Ts, Ts>(destination + experiment.GetPixel0OfModule(module_number),
|
||||
source + module_number * RAW_MODULE_SIZE,
|
||||
(experiment.IsUpsideDown() ? -1 : 1) * experiment.GetXPixelsNum(), min, max);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void LineConvtToRaw(T *destination, const T* source) {
|
||||
template<class T>
|
||||
void LineConvtToRaw(T *destination, const T *source) {
|
||||
for (int chip = 0; chip < 4; chip++) {
|
||||
for (int i = 0; i < 256; i++)
|
||||
destination[i+chip*256] = source[i+chip*258];
|
||||
destination[i + chip * 256] = source[i + chip * 258];
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void ConvertedToRawGeometry(const DiffractionExperiment& experiment, T *destination, const T* source) {
|
||||
template<class T>
|
||||
void ConvertedToRawGeometry(const DiffractionExperiment &experiment, T *destination, const T *source) {
|
||||
for (size_t module_number = 0; module_number < experiment.GetModulesNum(); module_number++) {
|
||||
for (size_t line = 0; line < RAW_MODULE_LINES; line++) {
|
||||
LineConvtToRaw<T>(destination + module_number * RAW_MODULE_SIZE + RAW_MODULE_COLS * line,
|
||||
source + experiment.GetPixel0OfModule(module_number) + (experiment.IsUpsideDown() ? -1 : 1) * experiment.GetXPixelsNum() * (line + ((line > 255) ? 2 : 0))
|
||||
source + experiment.GetPixel0OfModule(module_number) +
|
||||
experiment.GetModuleSlowDirectionStep(module_number) *
|
||||
(line + ((line > 255) ? 2 : 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void Bin2x2_or(T *destination, const T* source, size_t width, size_t height) {
|
||||
template<class T>
|
||||
void Bin2x2_or(T *destination, const T *source, size_t width, size_t height) {
|
||||
for (int y = 0; y < height / 2; y++) {
|
||||
for (int x = 0; x < width / 2; x++) {
|
||||
T tmp[4];
|
||||
@@ -278,20 +181,42 @@ template <class T> void Bin2x2_or(T *destination, const T* source, size_t width,
|
||||
tmp[1] = source[(y * 2 + 1) * width + (x * 2)];
|
||||
tmp[2] = source[(y * 2) * width + (x * 2 + 1)];
|
||||
tmp[3] = source[(y * 2 + 1) * width + (x * 2 + 1)];
|
||||
destination[y * (width/2) + x] = tmp[0] | tmp[1] | tmp[2] | tmp[3];
|
||||
destination[y * (width / 2) + x] = tmp[0] | tmp[1] | tmp[2] | tmp[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T, class Tint = int32_t>
|
||||
void Bin2x2_sum(T *destination, const T* source, size_t width, size_t height, T underload, T overload) {
|
||||
for (int y = 0; y < height / 2; y++) {
|
||||
for (int x = 0; x < width / 2; x++)
|
||||
destination[y * (width/2) + x] = Bin2x2_sum<T, Tint>(source[(y * 2) * width + (x * 2)],
|
||||
source[(y * 2 + 1) * width + (x * 2)],
|
||||
source[(y * 2) * width + (x * 2 + 1)],
|
||||
source[(y * 2 + 1) * width + (x * 2 + 1)],
|
||||
underload, overload);
|
||||
// Input coord is column + 1024 * (line + 512 * module)
|
||||
template<class Ts>
|
||||
void RawToConvertedGeometryAdjustMultipixels(const DiffractionExperiment &experiment, Ts *destination, const Ts *source) {
|
||||
Ts min = experiment.GetUnderflow() + 1;
|
||||
if (min > 0) min = 0;
|
||||
Ts max = experiment.GetOverflow() - 1;
|
||||
|
||||
if (experiment.GetBinning2x2()) {
|
||||
std::vector<Ts> tmp(experiment.GetPixelsNumFullImage());
|
||||
for (size_t module_number = 0; module_number < experiment.GetModulesNum(); module_number++) {
|
||||
TransferModuleAdjustMultipixels<Ts, Ts>(tmp.data(),
|
||||
source + module_number * RAW_MODULE_SIZE,
|
||||
experiment.GetModuleSlowDirectionStep(module_number),
|
||||
min, max,
|
||||
experiment.GetModuleFastDirectionStep(module_number),
|
||||
experiment.GetPixel0OfModule(module_number));
|
||||
Bin2x2_sum(destination,
|
||||
tmp.data(),
|
||||
experiment.GetXPixelsNumFullImage(),
|
||||
experiment.GetYPixelsNumFullImage(),
|
||||
min, max);
|
||||
}
|
||||
} else {
|
||||
for (size_t module_number = 0; module_number < experiment.GetModulesNum(); module_number++) {
|
||||
TransferModuleAdjustMultipixels<Ts, Ts>(destination,
|
||||
source + module_number * RAW_MODULE_SIZE,
|
||||
experiment.GetModuleSlowDirectionStep(module_number),
|
||||
min, max,
|
||||
experiment.GetModuleFastDirectionStep(module_number),
|
||||
experiment.GetPixel0OfModule(module_number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Submodule detector_control/slsDetectorPackage updated: 77c558a7be...ae0a54a774
@@ -117,11 +117,16 @@ message DetectorSettings {
|
||||
bool conversion_on_cpu = 9;
|
||||
}
|
||||
|
||||
message DetectorModuleGeometry {
|
||||
int64 pixel0 = 1;
|
||||
int64 fast_direction_step = 2;
|
||||
int64 slow_direction_step = 3;
|
||||
}
|
||||
|
||||
message DetectorGeometry {
|
||||
int64 width_pxl = 1;
|
||||
int64 height_pxl = 2;
|
||||
repeated int64 pixel0_of_module = 3;
|
||||
bool mirror_modules_in_y = 4;
|
||||
repeated DetectorModuleGeometry module_geometry = 3;
|
||||
}
|
||||
|
||||
message InternalSettings {
|
||||
@@ -130,9 +135,9 @@ message InternalSettings {
|
||||
int64 frame_time_us = 3;
|
||||
int64 count_time_us = 4;
|
||||
|
||||
repeated int64 data_stream_modules = 5;
|
||||
DetectorGeometry geometry = 6;
|
||||
DetectorGeometry raw_geometry = 7;
|
||||
int64 nmodules = 5;
|
||||
int64 ndatastreams = 6;
|
||||
|
||||
DetectorGeometry conv_geometry = 8;
|
||||
|
||||
bool internal_fpga_packet_generator = 9;
|
||||
|
||||
@@ -22,7 +22,8 @@ public:
|
||||
ConvertPacket(dest + i * 4 * RAW_MODULE_COLS, source + i * 4 * RAW_MODULE_COLS, i);
|
||||
}
|
||||
|
||||
virtual void ConvertAdjustGeom(int16_t* dest, const uint16_t* source, int64_t line_shift) = 0;
|
||||
virtual void ConvertAdjustGeom(int16_t* dest, const uint16_t* source, int64_t slow_dir_step,
|
||||
int64_t fast_dir_step, int64_t offset) = 0;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_JFCONVERSION_H
|
||||
|
||||
@@ -109,19 +109,20 @@ void JFConversionFixedPoint::ConvertPacket(int16_t *dest, const uint16_t *source
|
||||
ConvertLine(dest + i * RAW_MODULE_COLS, source + i * RAW_MODULE_COLS, 4 * packet_number + i);
|
||||
}
|
||||
|
||||
void JFConversionFixedPoint::ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t line_shift) {
|
||||
void JFConversionFixedPoint::ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t slow_dir_step,
|
||||
int64_t fast_dir_step, int64_t offset) {
|
||||
for (int line = 0; line < RAW_MODULE_LINES; line++) {
|
||||
int16_t tmp[RAW_MODULE_COLS];
|
||||
ConvertLine(tmp, source + line * RAW_MODULE_COLS, line);
|
||||
|
||||
if ((line != 255) && (line != 256)) {
|
||||
LineCopyAndAdjustMultipixel<int16_t, int16_t>(dest + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
tmp, INT16_MIN, INT16_MAX);
|
||||
LineCopyAndAdjustMultipixel<int16_t, int16_t>(dest + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
tmp, INT16_MIN, INT16_MAX, fast_dir_step, offset);
|
||||
} else {
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + line_shift * (line + 1),
|
||||
tmp, INT16_MIN, INT16_MAX);
|
||||
memcpy(dest + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
dest + line_shift * (line + 1),CONVERTED_MODULE_COLS*sizeof(uint16_t));
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + slow_dir_step * (line + 1),
|
||||
tmp, INT16_MIN, INT16_MAX, fast_dir_step, offset);
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
tmp, INT16_MIN, INT16_MAX, fast_dir_step, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ public:
|
||||
const JFModulePedestal &pedestal_g2,
|
||||
double energy) override;
|
||||
void ConvertPacket(int16_t* dest, const uint16_t* source, uint16_t packet_number) override;
|
||||
void ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t line_shift) override;
|
||||
void ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t slow_dir_step,
|
||||
int64_t fast_dir_step, int64_t offset) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -76,18 +76,22 @@ void JFConversionFloatingPoint::ConvertFP(float *dest, const uint16_t *source) {
|
||||
}
|
||||
}
|
||||
|
||||
void JFConversionFloatingPoint::ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t line_shift) {
|
||||
void JFConversionFloatingPoint::ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t slow_dir_step,
|
||||
int64_t fast_dir_step, int64_t offset) {
|
||||
for (int line = 0; line < RAW_MODULE_LINES; line++) {
|
||||
int16_t tmp[RAW_MODULE_COLS];
|
||||
ConvertLine(tmp, source + line * RAW_MODULE_COLS, line);
|
||||
|
||||
if ((line != 255) && (line != 256)) {
|
||||
LineCopyAndAdjustMultipixel<int16_t, int16_t>(dest + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
tmp, INT16_MIN, INT16_MAX);
|
||||
LineCopyAndAdjustMultipixel<int16_t, int16_t>(dest + slow_dir_step * (line + ((line > 255) ? 2 : 0)),
|
||||
tmp, INT16_MIN, INT16_MAX, fast_dir_step, offset);
|
||||
} else {
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + line_shift * (line + 1), tmp, INT16_MIN, INT16_MAX);
|
||||
memcpy(dest + line_shift * (line + ((line > 255) ? 2 : 0)),
|
||||
dest + line_shift * (line + 1), CONVERTED_MODULE_COLS*sizeof(uint16_t));
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + slow_dir_step * (line + 1), tmp,
|
||||
INT16_MIN, INT16_MAX,
|
||||
fast_dir_step, offset);
|
||||
LineCopyAndAdjustMultipixelMidRow<int16_t, int16_t>(dest + slow_dir_step * ((line > 255) ? 2 : 0), tmp,
|
||||
INT16_MIN, INT16_MAX,
|
||||
fast_dir_step, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ public:
|
||||
double energy) override;
|
||||
void ConvertPacket(int16_t* dest, const uint16_t* source, uint16_t packet_number) override;
|
||||
void ConvertFP(float *dest, const uint16_t *source);
|
||||
void ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t line_shift) override;
|
||||
void ConvertAdjustGeom(int16_t *dest, const uint16_t *source, int64_t slow_dir_step,
|
||||
int64_t fast_dir_step, int64_t offset) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -337,9 +337,9 @@ int64_t JFJochReceiver::FrameTransformationThread() {
|
||||
|
||||
if (experiment.GetConversionOnCPU()) {
|
||||
auto &conv = fixed_point_conversion.at(experiment.GetFirstModuleOfDataStream(d) + m);
|
||||
transformation.ProcessModule(conv,src, frame_number, m, d);
|
||||
transformation.ProcessModule(conv, src, m, d);
|
||||
} else
|
||||
transformation.ProcessModule(src, frame_number, m, d);
|
||||
transformation.ProcessModule(src, m, d);
|
||||
|
||||
acquisition_device[d]->FrameBufferRelease(frame_number, m);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../receiver/host/AcquisitionOnlineCounters.h"
|
||||
|
||||
TEST_CASE("AcquisitionDeviceCountersTest","[AcquisitionDeviceCounters]") {
|
||||
DiffractionExperiment x(1,{2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
x.NumTriggers(1).ImagesPerTrigger(50);
|
||||
|
||||
AcquisitionOnlineCounters counters;
|
||||
@@ -59,7 +59,7 @@ TEST_CASE("AcquisitionDeviceCountersTest","[AcquisitionDeviceCounters]") {
|
||||
}
|
||||
|
||||
TEST_CASE("AcquisitionDeviceCountersTest_OutOfBounds","[AcquisitionDeviceCounters]") {
|
||||
DiffractionExperiment x(1,{2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
x.NumTriggers(1).ImagesPerTrigger(50);
|
||||
|
||||
AcquisitionOnlineCounters counters;
|
||||
|
||||
@@ -24,7 +24,7 @@ ADD_EXECUTABLE(CatchTest
|
||||
JFCalibrationTest.cpp
|
||||
RadialIntegrationTest.cpp
|
||||
StatusVectorTest.cpp ProcessRawPacketTest.cpp
|
||||
CBORTest.cpp JFConversionTest.cpp)
|
||||
CBORTest.cpp JFConversionTest.cpp DetectorGeometryTest.cpp)
|
||||
|
||||
target_link_libraries(CatchTest JFJochBroker JFJochReceiver JFJochWriter ImageAnalysis CommonFunctions HLSSimulation)
|
||||
target_include_directories(CatchTest PRIVATE .)
|
||||
|
||||
161
tests/DetectorGeometryTest.cpp
Normal file
161
tests/DetectorGeometryTest.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include "../common/DetectorGeometry.h"
|
||||
|
||||
TEST_CASE("DetectorGeometry_Regular", "[DetectorGeometry]") {
|
||||
DetectorGeometry geometry(18, 3, 8, 36, false);
|
||||
|
||||
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
|
||||
REQUIRE(pbuf.module_geometry_size() == 18);
|
||||
|
||||
REQUIRE(pbuf.width_pxl() == 3 * 1030 + 2 * 8);
|
||||
REQUIRE(pbuf.height_pxl() == 6 * 514 + 5 * 36);
|
||||
REQUIRE(pbuf.module_geometry(0).pixel0() == 0);
|
||||
REQUIRE(pbuf.module_geometry(2).pixel0() == 2 * 1030 + 2 * 8);
|
||||
|
||||
REQUIRE(pbuf.module_geometry(15).pixel0() == pbuf.width_pxl() * (514 * 5 + 36 * 5));
|
||||
REQUIRE(pbuf.module_geometry(15).fast_direction_step() == 1);
|
||||
REQUIRE(pbuf.module_geometry(15).slow_direction_step() == pbuf.width_pxl());
|
||||
}
|
||||
|
||||
TEST_CASE("DetectorGeometry_RegularMirror", "[DetectorGeometry]") {
|
||||
DetectorGeometry geometry(18, 3, 8, 36, true);
|
||||
|
||||
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
|
||||
REQUIRE(pbuf.module_geometry_size() == 18);
|
||||
|
||||
REQUIRE(pbuf.width_pxl() == 3 * 1030 + 2 * 8);
|
||||
REQUIRE(pbuf.height_pxl() == 6 * 514 + 5 * 36);
|
||||
REQUIRE(pbuf.module_geometry(0).pixel0() == pbuf.width_pxl() * (pbuf.height_pxl() - 1));
|
||||
REQUIRE(pbuf.module_geometry(2).pixel0() == pbuf.width_pxl() * (pbuf.height_pxl() - 1) + 2 * 1030 + 2 * 8);
|
||||
|
||||
CHECK(pbuf.module_geometry(15).pixel0() == pbuf.width_pxl() * 513);
|
||||
CHECK(pbuf.module_geometry(17).pixel0() == pbuf.width_pxl() * (513) + 2 * 1030 + 2 * 8);
|
||||
REQUIRE(pbuf.module_geometry(15).fast_direction_step() == 1);
|
||||
REQUIRE(pbuf.module_geometry(15).slow_direction_step() == -pbuf.width_pxl());
|
||||
}
|
||||
|
||||
TEST_CASE("DetectorModuleGeometry_SameAxis", "[DetectorGeometry]") {
|
||||
std::unique_ptr<DetectorModuleGeometry> geometry;
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
||||
DetectorModuleGeometry::Direction::Xpos,
|
||||
DetectorModuleGeometry::Direction::Xpos));
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
||||
DetectorModuleGeometry::Direction::Ypos,
|
||||
DetectorModuleGeometry::Direction::Ypos));
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
||||
DetectorModuleGeometry::Direction::Yneg,
|
||||
DetectorModuleGeometry::Direction::Ypos));
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
||||
DetectorModuleGeometry::Direction::Xpos,
|
||||
DetectorModuleGeometry::Direction::Xneg));
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
||||
DetectorModuleGeometry::Direction::Xneg,
|
||||
DetectorModuleGeometry::Direction::Ypos));
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
||||
DetectorModuleGeometry::Direction::Ypos,
|
||||
DetectorModuleGeometry::Direction::Xpos));
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("DetectorModuleGeometry_NoSpace", "[DetectorGeometry]") {
|
||||
std::unique_ptr<DetectorModuleGeometry> geometry;
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(1022,0,
|
||||
DetectorModuleGeometry::Direction::Xneg,
|
||||
DetectorModuleGeometry::Direction::Ypos));
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(1022,512,
|
||||
DetectorModuleGeometry::Direction::Xpos,
|
||||
DetectorModuleGeometry::Direction::Yneg));
|
||||
|
||||
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(1029,513,
|
||||
DetectorModuleGeometry::Direction::Yneg,
|
||||
DetectorModuleGeometry::Direction::Xneg));
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(1029,513,
|
||||
DetectorModuleGeometry::Direction::Xneg,
|
||||
DetectorModuleGeometry::Direction::Yneg));
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(513,1029,
|
||||
DetectorModuleGeometry::Direction::Yneg,
|
||||
DetectorModuleGeometry::Direction::Xneg));
|
||||
}
|
||||
|
||||
TEST_CASE("DetectorModuleGeometry_GetMaxX_GetMaxY", "[DetectorGeometry]") {
|
||||
std::unique_ptr<DetectorModuleGeometry> geometry;
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
||||
DetectorModuleGeometry::Direction::Xpos,
|
||||
DetectorModuleGeometry::Direction::Ypos));
|
||||
|
||||
REQUIRE(geometry->GetMaxX() == 1029);
|
||||
REQUIRE(geometry->GetMaxY() == 513);
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
||||
DetectorModuleGeometry::Direction::Xneg,
|
||||
DetectorModuleGeometry::Direction::Yneg));
|
||||
|
||||
REQUIRE(geometry->GetMaxX() == 2029);
|
||||
REQUIRE(geometry->GetMaxY() == 1513);
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
||||
DetectorModuleGeometry::Direction::Yneg,
|
||||
DetectorModuleGeometry::Direction::Xneg));
|
||||
|
||||
REQUIRE(geometry->GetMaxX() == 2029);
|
||||
REQUIRE(geometry->GetMaxY() == 1513);
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
||||
DetectorModuleGeometry::Direction::Yneg,
|
||||
DetectorModuleGeometry::Direction::Xpos));
|
||||
|
||||
REQUIRE(geometry->GetMaxX() == 2029 + 513);
|
||||
REQUIRE(geometry->GetMaxY() == 1513);
|
||||
|
||||
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
||||
DetectorModuleGeometry::Direction::Ypos,
|
||||
DetectorModuleGeometry::Direction::Xneg));
|
||||
|
||||
REQUIRE(geometry->GetMaxX() == 2029);
|
||||
REQUIRE(geometry->GetMaxY() == 1513 + 1029);
|
||||
}
|
||||
|
||||
TEST_CASE("DetectorGeometry_Custom", "[DetectorGeometry]") {
|
||||
std::vector<DetectorModuleGeometry> module_geom;
|
||||
|
||||
REQUIRE_NOTHROW(module_geom.emplace_back(2999, 2999, DetectorModuleGeometry::Direction::Xneg,
|
||||
DetectorModuleGeometry::Direction::Yneg));
|
||||
|
||||
REQUIRE_NOTHROW(module_geom.emplace_back(0, 0, DetectorModuleGeometry::Direction::Ypos,
|
||||
DetectorModuleGeometry::Direction::Xpos));
|
||||
|
||||
REQUIRE_NOTHROW(module_geom.emplace_back(5000, 0, DetectorModuleGeometry::Direction::Ypos,
|
||||
DetectorModuleGeometry::Direction::Xpos));
|
||||
|
||||
DetectorGeometry geometry(module_geom);
|
||||
|
||||
REQUIRE(geometry.GetModulesNum() == 3);
|
||||
JFJochProtoBuf::DetectorGeometry pbuf_geom = geometry;
|
||||
|
||||
CHECK(pbuf_geom.height_pxl() == 2999+1);
|
||||
CHECK(pbuf_geom.width_pxl() == 5513+1);
|
||||
CHECK(pbuf_geom.module_geometry(0).pixel0() == 2999 * pbuf_geom.width_pxl() + 2999);
|
||||
CHECK(pbuf_geom.module_geometry(1).pixel0() == 0);
|
||||
CHECK(pbuf_geom.module_geometry(2).pixel0() == 5000);
|
||||
|
||||
CHECK(pbuf_geom.module_geometry(0).fast_direction_step() == -1);
|
||||
CHECK(pbuf_geom.module_geometry(1).fast_direction_step() == pbuf_geom.width_pxl());
|
||||
CHECK(pbuf_geom.module_geometry(2).fast_direction_step() == pbuf_geom.width_pxl());
|
||||
|
||||
CHECK(pbuf_geom.module_geometry(0).slow_direction_step() == -pbuf_geom.width_pxl());
|
||||
CHECK(pbuf_geom.module_geometry(1).slow_direction_step() == 1);
|
||||
CHECK(pbuf_geom.module_geometry(2).slow_direction_step() == 1);
|
||||
}
|
||||
@@ -172,10 +172,11 @@ TEST_CASE("DiffractionExperiment_UnitCell","[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_IPv4Address","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(1, {4, 4, 4});
|
||||
DiffractionExperiment x(DetectorGeometry(12));
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
|
||||
uint32_t ndatastreams = 3;
|
||||
x.DataStreams(ndatastreams);
|
||||
|
||||
REQUIRE(x.GetDestIPv4Address(0) == 0x0132010a);
|
||||
REQUIRE(x.GetDestIPv4Address(1) == 0x0232010a);
|
||||
@@ -226,8 +227,8 @@ TEST_CASE("MacAddressFromStr","") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_UDPAddress","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(1, {4, 4, 4});
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
DiffractionExperiment x(DetectorGeometry(12));
|
||||
x.Mode(DetectorMode::Conversion).DataStreams(3);
|
||||
|
||||
REQUIRE(x.GetDestUDPPort(0, 0) % 64 == 0);
|
||||
REQUIRE(x.GetDestUDPPort(0, 2) % 64 == 0);
|
||||
@@ -251,85 +252,124 @@ TEST_CASE("DiffractionExperiment_UDPAddress","[DiffractionExperiment]") {
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DataStreams","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(DetectorGeometry(18)); // 9M
|
||||
|
||||
x.DataStreams(4);
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
REQUIRE(x.GetDataStreamsNum() == 4);
|
||||
|
||||
REQUIRE(x.GetModulesNum(0) == 5);
|
||||
REQUIRE(x.GetModulesNum(1) == 5);
|
||||
REQUIRE(x.GetModulesNum(2) == 4);
|
||||
REQUIRE(x.GetModulesNum(3) == 4);
|
||||
REQUIRE_THROWS(x.GetModulesNum(4));
|
||||
|
||||
x.DataStreams(2);
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
REQUIRE(x.GetDataStreamsNum() == 2);
|
||||
|
||||
REQUIRE(x.GetModulesNum(0) == 9);
|
||||
REQUIRE(x.GetModulesNum(1) == 9);
|
||||
REQUIRE_THROWS(x.GetModulesNum(2));
|
||||
|
||||
x = DiffractionExperiment(DetectorGeometry(2));
|
||||
|
||||
x.DataStreams(2);
|
||||
REQUIRE(x.GetModulesNum() == 2);
|
||||
REQUIRE(x.GetDataStreamsNum() == 2);
|
||||
|
||||
REQUIRE(x.GetModulesNum(0) == 1);
|
||||
REQUIRE(x.GetModulesNum(1) == 1);
|
||||
|
||||
x.DataStreams(5);
|
||||
REQUIRE(x.GetModulesNum() == 2);
|
||||
REQUIRE(x.GetDataStreamsNum() == 2);
|
||||
|
||||
REQUIRE(x.GetModulesNum(0) == 1);
|
||||
REQUIRE(x.GetModulesNum(1) == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorGeometry","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(1, {4, 4, 6, 6}); // 10M configuration #1 - via constructor
|
||||
DiffractionExperiment x(DetectorGeometry(18)); // 9M configuration #1 - via constructor
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.DataStreams(4);
|
||||
|
||||
REQUIRE(x.GetDataStreamsNum() == 4);
|
||||
|
||||
REQUIRE(x.GetXPixelsNum() == 1030);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 20);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 18);
|
||||
|
||||
REQUIRE(x.GetModulesNum() == 20);
|
||||
REQUIRE(x.GetModulesNum(TASK_NO_DATA_STREAM) == 20);
|
||||
REQUIRE(x.GetModulesNum(0) == 4);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
REQUIRE(x.GetModulesNum(TASK_NO_DATA_STREAM) == 18);
|
||||
REQUIRE(x.GetModulesNum(0) == 5);
|
||||
REQUIRE(x.GetModulesNum(2) == 4);
|
||||
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(TASK_NO_DATA_STREAM) == 0);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(0) == 0);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(1) == 4);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(2) == 8);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(1) == 5);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(2) == 10);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(3) == 14);
|
||||
|
||||
REQUIRE(x.GetPixelsNum() == 20 * 514 * 1030);
|
||||
REQUIRE(x.GetPixelsNum() == 18 * 514 * 1030);
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
|
||||
REQUIRE(x.GetPixelsNum() == 20 * 512 * 1024);
|
||||
REQUIRE(x.GetPixelsNum() == 18 * 512 * 1024);
|
||||
REQUIRE(x.GetXPixelsNum() == 1024);
|
||||
REQUIRE(x.GetYPixelsNum() == 512 * 20);
|
||||
REQUIRE(x.GetYPixelsNum() == 512 * 18);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
|
||||
x = DiffractionExperiment(2, {4, 4, 6, 6}, 0, 0, true); // 10M configuration #2
|
||||
x = DiffractionExperiment(DetectorGeometry(18, 2)); // 9M configuration #2
|
||||
|
||||
REQUIRE(x.GetPixelsNum() == 1030 * 514 * 20);
|
||||
REQUIRE(x.GetPixelsNum() == 1030 * 514 * 18);
|
||||
REQUIRE(x.GetXPixelsNum() == 1030 * 2);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 20 / 2);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 18 / 2);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(0) == 18 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(1) == 18 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
REQUIRE(x.GetPixel0OfModule(0) == 16 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(1) == 16 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(12) == 6 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(13) == 6 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
REQUIRE(x.GetPixel0OfModule(12) == 4 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(13) == 4 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(14) == 4 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(15) == 4 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
REQUIRE(x.GetPixel0OfModule(14) == 2 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(15) == 2 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(16) == 2 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(17) == 2 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
REQUIRE(x.GetPixel0OfModule(16) == 0 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(17) == 0 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(18) == 0 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2);
|
||||
REQUIRE(x.GetPixel0OfModule(19) == 0 * CONVERTED_MODULE_SIZE + 513 * CONVERTED_MODULE_COLS * 2 + CONVERTED_MODULE_COLS);
|
||||
REQUIRE_THROWS(x.GetPixel0OfModule(20));
|
||||
REQUIRE_THROWS(x.GetPixel0OfModule(18));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
|
||||
REQUIRE(x.GetPixelsNum() == 1024 * 512 * 20);
|
||||
REQUIRE(x.GetPixelsNum() == 1024 * 512 * 18);
|
||||
REQUIRE(x.GetXPixelsNum() == 1024);
|
||||
REQUIRE(x.GetYPixelsNum() == 512 * 20);
|
||||
REQUIRE(x.GetYPixelsNum() == 512 * 18);
|
||||
REQUIRE(x.GetPixel0OfModule(15) == 15 * RAW_MODULE_SIZE);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorGeometry_gaps","[DiffractionExperiment]") {
|
||||
const size_t gap_x = 8;
|
||||
const size_t gap_y = 36;
|
||||
|
||||
DiffractionExperiment x(2, {4, 4, 6, 6}, gap_x,gap_y, false);
|
||||
DiffractionExperiment x(DetectorGeometry(18, 2, gap_x, gap_y, false));
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.DataStreams(4);
|
||||
|
||||
REQUIRE(x.GetDataStreamsNum() == 4);
|
||||
REQUIRE(x.GetPixelsNum() == (1030 * 2 + gap_x) * (514 * 10 + (10-1) * gap_y) );
|
||||
REQUIRE(x.GetXPixelsNum() == 1030 * 2 +gap_x);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 10 + (10-1) * gap_y);
|
||||
REQUIRE(x.GetPixelsNum() == (1030 * 2 + gap_x) * (514 * 9 + (9-1) * gap_y) );
|
||||
REQUIRE(x.GetXPixelsNum() == 1030 * 2 + gap_x);
|
||||
REQUIRE(x.GetYPixelsNum() == 514 * 9 + (9-1) * gap_y);
|
||||
|
||||
REQUIRE(x.GetModulesNum() == 20);
|
||||
REQUIRE(x.GetModulesNum(0) == 4);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
REQUIRE(x.GetModulesNum(0) == 5);
|
||||
REQUIRE(x.GetModulesNum(2) == 4);
|
||||
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(0) == 0);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(1) == 4);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(2) == 8);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(1) == 5);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(2) == 10);
|
||||
REQUIRE(x.GetFirstModuleOfDataStream(3) == 14);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(0) == (2*1030 + gap_x) * (514 + gap_y) * (0/2));
|
||||
@@ -340,16 +380,15 @@ TEST_CASE("DiffractionExperiment_DetectorGeometry_gaps","[DiffractionExperiment]
|
||||
REQUIRE(x.GetPixel0OfModule(0) == (2*1030 + gap_x) * 0 * (514 + gap_y));
|
||||
REQUIRE(x.GetPixel0OfModule(1) == (2*1030 + gap_x) * 0 * (514 + gap_y) + 1030 + gap_x);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(18) == (2*1030 + gap_x) * 9 * (514 + gap_y));
|
||||
REQUIRE(x.GetPixel0OfModule(19) == (2*1030 + gap_x) * 9 * (514 + gap_y) + 1030 + gap_x);
|
||||
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(16) == (2*1030 + gap_x) * 8 * (514 + gap_y));
|
||||
REQUIRE(x.GetPixel0OfModule(17) == (2*1030 + gap_x) * 8 * (514 + gap_y) + 1030 + gap_x);
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorGeometry_gaps_mirror_y","[DiffractionExperiment]") {
|
||||
const size_t gap_x = 8;
|
||||
const size_t gap_y = 36;
|
||||
|
||||
DiffractionExperiment x(2, {4, 4, 6, 6}, gap_x,gap_y, true);
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, gap_x, gap_y, true));
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
|
||||
REQUIRE(x.GetPixel0OfModule(0) == (2*1030+gap_x) * 513 + (2*1030 + gap_x) * 9 * (514 + gap_y));
|
||||
@@ -502,7 +541,8 @@ TEST_CASE("DiffractionExperiment_FrameCountTime","[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_ExportProtobuf","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(4, {4, 4, 8}, 0, 0, false),y;
|
||||
DiffractionExperiment x(DetectorGeometry(16, 4, 0, 0, false)),y;
|
||||
x.DataStreams(3);
|
||||
|
||||
std::vector<DetectorMode> v = {DetectorMode::Raw, DetectorMode::Conversion,
|
||||
DetectorMode::PedestalG0, DetectorMode::PedestalG1, DetectorMode::PedestalG2};
|
||||
@@ -517,8 +557,7 @@ TEST_CASE("DiffractionExperiment_ExportProtobuf","[DiffractionExperiment]") {
|
||||
JFJochProtoBuf::JungfraujochSettings settings_in_protobuf = x;
|
||||
REQUIRE_NOTHROW(y.Import(settings_in_protobuf));
|
||||
|
||||
REQUIRE(! y.IsUpsideDown());
|
||||
REQUIRE(y.GetFilePrefix() == x.GetFilePrefix());
|
||||
REQUIRE(y.GetFilePrefix() == x.GetFilePrefix());
|
||||
REQUIRE(x.GetDataStreamsNum() == y.GetDataStreamsNum());
|
||||
REQUIRE(x.GetXPixelsNum() == y.GetXPixelsNum());
|
||||
REQUIRE(x.GetModulesNum(2) == y.GetModulesNum(2));
|
||||
@@ -577,7 +616,7 @@ TEST_CASE("DiffractionExperiment_CopyConstructor", "[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_ResToPxl","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(75).PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
|
||||
// sin(theta) = 1/2
|
||||
@@ -592,7 +631,7 @@ TEST_CASE("DiffractionExperiment_ResToPxl","[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_RadialIntegration_LowQ","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
REQUIRE_THROWS(x.LowQForRadialInt_recipA(0));
|
||||
REQUIRE_THROWS(x.LowQForRadialInt_recipA(-1));
|
||||
@@ -613,7 +652,7 @@ TEST_CASE("DiffractionExperiment_RadialIntegration_LowQ","[DiffractionExperiment
|
||||
|
||||
|
||||
TEST_CASE("DiffractionExperiment_RadialIntegration_HighQ","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
REQUIRE_THROWS(x.HighQForRadialInt_recipA(0));
|
||||
REQUIRE_THROWS(x.HighQForRadialInt_recipA(-1));
|
||||
@@ -633,7 +672,7 @@ TEST_CASE("DiffractionExperiment_RadialIntegration_HighQ","[DiffractionExperimen
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_RadialIntegration_QSpacing","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
x.QSpacingForRadialInt_recipA(0.456);
|
||||
REQUIRE(x.GetQSpacingForRadialInt_recipA() == Approx(0.456));
|
||||
@@ -643,7 +682,7 @@ TEST_CASE("DiffractionExperiment_RadialIntegration_QSpacing","[DiffractionExperi
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_IndexingPeriod","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(75).PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
x.FrameTime(1ms).Summation(3);
|
||||
x.IndexingPeriod(9ms);
|
||||
@@ -729,7 +768,7 @@ TEST_CASE("DiffractionExperiment_DetectorType","[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_MultiTriggger","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(700us).Summation(1).ImagesPerTrigger(350).NumTriggers(7);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
@@ -742,7 +781,7 @@ TEST_CASE("DiffractionExperiment_DetectorInput_MultiTriggger","[DiffractionExper
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_NoTriggger","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).Summation(1).ImagesPerTrigger(350).NumTriggers(1);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
@@ -755,7 +794,7 @@ TEST_CASE("DiffractionExperiment_DetectorInput_NoTriggger","[DiffractionExperime
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_PedestalG2","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).Summation(1).PedestalG2Frames(4560).NumTriggers(1).Mode(DetectorMode::PedestalG2);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
@@ -767,7 +806,7 @@ TEST_CASE("DiffractionExperiment_DetectorInput_PedestalG2","[DiffractionExperime
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_DetectorInput_StorageCell","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.FrameTime(1200us).Summation(1).NumTriggers(4560).StorageCells(8);
|
||||
JFJochProtoBuf::DetectorInput ret = x;
|
||||
REQUIRE(ret.modules_num() == 8);
|
||||
@@ -958,7 +997,7 @@ TEST_CASE("DiffractionExperiment_ConversionOnCPU","[DiffractionExperiment]") {
|
||||
}
|
||||
|
||||
TEST_CASE("DiffractionExperiment_Binning","[DiffractionExperiment]") {
|
||||
DiffractionExperiment x(2,{4,4}, 8, 36, true);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36, true));
|
||||
x.Mode(DetectorMode::Conversion).BeamX_pxl(200.0).BeamY_pxl(400.0);
|
||||
|
||||
REQUIRE(!x.GetBinning2x2());
|
||||
@@ -966,6 +1005,10 @@ TEST_CASE("DiffractionExperiment_Binning","[DiffractionExperiment]") {
|
||||
REQUIRE(x.GetXPixelsNum() == 2068);
|
||||
REQUIRE(x.GetYPixelsNum() == 2164);
|
||||
|
||||
REQUIRE(x.GetXPixelsNumFullImage() == 2068);
|
||||
REQUIRE(x.GetYPixelsNumFullImage() == 2164);
|
||||
REQUIRE(x.GetPixelsNumFullImage() == 2164*2068);
|
||||
|
||||
REQUIRE(x.GetBeamX_pxl() == Approx(200.0));
|
||||
REQUIRE(x.GetBeamY_pxl() == Approx(400.0));
|
||||
REQUIRE(x.GetPixel0OfModule(0) == (2164 - 1)*2068);
|
||||
@@ -974,16 +1017,19 @@ TEST_CASE("DiffractionExperiment_Binning","[DiffractionExperiment]") {
|
||||
REQUIRE(x.GetBinning2x2());
|
||||
REQUIRE(x.GetPixelSize_mm() == Approx(2*PIXEL_SIZE_IN_MM));
|
||||
|
||||
REQUIRE(x.GetXPixelsNumFullImage() == 2068);
|
||||
REQUIRE(x.GetXPixelsNum() == 2068/2);
|
||||
REQUIRE(x.GetYPixelsNumFullImage() == 2164);
|
||||
REQUIRE(x.GetYPixelsNum() == 2164/2);
|
||||
REQUIRE(x.GetPixelsNumFullImage() == 2164*2068);
|
||||
REQUIRE(x.GetPixelsNum() == (2164/2)*(2068/2));
|
||||
|
||||
REQUIRE(x.GetBeamX_pxl() == Approx(100.0));
|
||||
REQUIRE(x.GetBeamY_pxl() == Approx(200.0));
|
||||
REQUIRE(x.GetPixel0OfModule(0) == ((2164 - 1)/2)*(2068/2));
|
||||
REQUIRE(x.GetPixel0OfModule(1) == ((2164 - 1)/2)*(2068/2) + (1030+8)/2);
|
||||
REQUIRE(x.GetPixel0OfModule(6) == ((2164 - 1)/2)*(2068/2) - 3 * ((514+36)/2)*(2068/2));
|
||||
REQUIRE(x.GetPixel0OfModule(7) == ((2164 - 1)/2)*(2068/2) - 3 * ((514+36)/2)*(2068/2) + (1030+8)/2);
|
||||
REQUIRE(x.GetPixel0OfModule(0) == ((2164 - 1))*(2068));
|
||||
REQUIRE(x.GetPixel0OfModule(1) == ((2164 - 1))*(2068) + (1030+8));
|
||||
REQUIRE(x.GetPixel0OfModule(6) == ((2164 - 1))*(2068) - 3 * ((514+36))*(2068));
|
||||
REQUIRE(x.GetPixel0OfModule(7) == ((2164 - 1))*(2068) - 3 * ((514+36))*(2068) + (1030+8));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
REQUIRE(!x.GetBinning2x2());
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace std::literals::chrono_literals;
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator", "[FPGA][Full]") {
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment x(1, {nmodules});
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0);
|
||||
@@ -53,7 +53,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator", "[FPGA][Full]") {
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_custom_frame", "[FPGA][Full]") {
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment x(1, {nmodules});
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
std::vector<uint16_t> test_frame(RAW_MODULE_SIZE);
|
||||
|
||||
@@ -95,7 +95,8 @@ TEST_CASE("HLS_C_Simulation_check_raw", "[FPGA][Full]") {
|
||||
LoadBinaryFile("../../tests/test_data/mod5_raw" + std::to_string(i)+".bin", raw_frames.data() + i * RAW_MODULE_SIZE, RAW_MODULE_SIZE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
@@ -135,7 +136,10 @@ TEST_CASE("HLS_C_Simulation_check_raw", "[FPGA][Full]") {
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_cancel", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1,{4});
|
||||
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
@@ -158,7 +162,9 @@ TEST_CASE("HLS_C_Simulation_check_cancel", "[FPGA][Full]") {
|
||||
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_cancel_conversion", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -183,7 +189,10 @@ TEST_CASE("HLS_C_Simulation_check_delay", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frames(RAW_MODULE_SIZE*20);
|
||||
|
||||
Completion c;
|
||||
DiffractionExperiment x(1,{4});
|
||||
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
@@ -223,7 +232,9 @@ TEST_CASE("HLS_C_Simulation_check_delay", "[FPGA][Full]") {
|
||||
TEST_CASE("HLS_C_Simulation_check_lost_frame_raw", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frames(RAW_MODULE_SIZE*20);
|
||||
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
for (int i = 0; i < 4096; i++) data[i] = i;
|
||||
@@ -253,7 +264,9 @@ TEST_CASE("HLS_C_Simulation_check_lost_frame_raw", "[FPGA][Full]") {
|
||||
TEST_CASE("HLS_C_Simulation_check_lost_frame_conversion", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frames(RAW_MODULE_SIZE*20);
|
||||
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
for (int i = 0; i < 4096; i++) data[i] = i;
|
||||
@@ -282,7 +295,9 @@ TEST_CASE("HLS_C_Simulation_check_lost_frame_conversion", "[FPGA][Full]") {
|
||||
TEST_CASE("HLS_C_Simulation_check_single_packet", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frames(RAW_MODULE_SIZE*20);
|
||||
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
@@ -358,7 +373,9 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") {
|
||||
|
||||
std::vector<double> energy_values = {6.0, 12.4, 17.7, 5, 4.5, 3.7};
|
||||
|
||||
DiffractionExperiment x(1, {1});
|
||||
const uint16_t nmodules = 1;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
@@ -397,7 +414,9 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") {
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPGA][Full]") {
|
||||
double energy = 6.0;
|
||||
|
||||
DiffractionExperiment x(1, {1});
|
||||
const uint16_t nmodules = 1;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
JFModulePedestal pedestal_g0, pedestal_g1, pedestal_g2;
|
||||
std::vector<double> gain(3 * RAW_MODULE_SIZE);
|
||||
@@ -445,7 +464,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_apply_pixel_mask", "[FPGA][Full]") {
|
||||
double energy = 6.0;
|
||||
|
||||
DiffractionExperiment x(1, {1});
|
||||
const uint16_t nmodules = 1;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
JFModulePedestal pedestal_g0, pedestal_g1, pedestal_g2;
|
||||
std::vector<double> gain(3 * RAW_MODULE_SIZE);
|
||||
@@ -526,7 +546,9 @@ TEST_CASE("HLS_C_Simulation_check_2_trigger_convert", "[FPGA][Full]") {
|
||||
LoadBinaryFile("../../tests/test_data/mod5_conv" + std::to_string(i)+".bin", conv_frames.data() + i * RAW_MODULE_SIZE, RAW_MODULE_SIZE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -598,7 +620,9 @@ TEST_CASE("HLS_C_Simulation_check_2_trigger_convert", "[FPGA][Full]") {
|
||||
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_detect_last_frame", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1,{4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[4096];
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -619,7 +643,9 @@ TEST_CASE("HLS_C_Simulation_check_detect_last_frame", "[FPGA][Full]") {
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_wrong_packet_size", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1,{1});
|
||||
const uint16_t nmodules = 1;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
uint16_t data[8192];
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -838,7 +864,8 @@ TEST_CASE("HLS_DataCollectionFSM","[OpenCAPI]") {
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_storage_cell_convert_G0", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1, {2});
|
||||
const uint16_t nmodules = 2;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(16).UseInternalPacketGenerator(true)
|
||||
@@ -880,7 +907,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_storage_cell_convert_G0",
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_storage_cell_convert_G1", "[FPGA][Full]") {
|
||||
DiffractionExperiment x(1, {2});
|
||||
const uint16_t nmodules = 2;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(16).UseInternalPacketGenerator(true)
|
||||
|
||||
@@ -32,7 +32,8 @@ struct RAW_ARP_Packet
|
||||
TEST_CASE("HLS_Network_ARP_Gratuitous") {
|
||||
HLSSimulatedDevice device(0, 64);
|
||||
|
||||
DiffractionExperiment x(2, {4});
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
auto gain_from_file = GainCalibrationFromTestFile();
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ TEST_CASE("Bshuf_SSE", "[bitshuffle]") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Raw_NoCompression" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(1,{nmodules, nmodules});
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 1));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Raw);
|
||||
experiment.Compression(JFJochProtoBuf::NO_COMPRESSION);
|
||||
@@ -41,8 +42,8 @@ TEST_CASE("FrameTransformation_Raw_NoCompression" ,"") {
|
||||
transformation.SetOutput(output.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
REQUIRE(transformation.PackStandardOutput() == experiment.GetPixelDepth() * experiment.GetPixelsNum());
|
||||
@@ -59,9 +60,10 @@ TEST_CASE("FrameTransformation_Raw_NoCompression" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_NoCompression" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::NO_COMPRESSION);
|
||||
|
||||
FrameTransformation transformation(experiment);
|
||||
@@ -82,8 +84,8 @@ TEST_CASE("FrameTransformation_Converted_NoCompression" ,"") {
|
||||
transformation.SetOutput(output.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
REQUIRE(transformation.PackStandardOutput() == experiment.GetPixelDepth() * experiment.GetPixelsNum());
|
||||
@@ -109,9 +111,10 @@ TEST_CASE("FrameTransformation_Converted_NoCompression" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_lz4" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::BSHUF_LZ4);
|
||||
|
||||
@@ -134,8 +137,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_lz4" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
@@ -170,9 +173,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_lz4" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
@@ -195,8 +199,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
@@ -231,9 +235,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_bin_2x2" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, false);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2, 0, 0, false));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::BSHUF_ZSTD).Binning2x2(true);
|
||||
|
||||
@@ -255,8 +260,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_bin_2x2" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
@@ -278,9 +283,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_bin_2x2" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_rle" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::BSHUF_ZSTD_RLE);
|
||||
|
||||
@@ -303,8 +309,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_rle" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
@@ -339,9 +345,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_rle" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
@@ -365,23 +372,23 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 1,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 1,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 2,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 2,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 3,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 3,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
@@ -409,9 +416,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, false);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2, 0, 0, false));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD).Binning2x2(true);
|
||||
|
||||
@@ -436,8 +444,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
|
||||
|
||||
for (int frame = 0; frame < experiment.GetSummation(); frame++) {
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, frame, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, frame, i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,9 +468,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_16bit_preview_summation" ,"") {
|
||||
uint16_t nmodules = 1;
|
||||
|
||||
DiffractionExperiment experiment(1,{nmodules}, 0, 0, false);
|
||||
const uint16_t nmodules = 1;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 1, 0, 0, false));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
@@ -486,10 +495,10 @@ TEST_CASE("FrameTransformation_Converted_16bit_preview_summation" ,"") {
|
||||
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0,0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 1,0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 2,0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 3,0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
|
||||
|
||||
size_t compressed_size;
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
|
||||
@@ -528,9 +537,10 @@ TEST_CASE("FrameTransformation_Converted_16bit_preview_summation" ,"") {
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
|
||||
// Ensure that previous frame is properly cleaned with PackStandardOutput()
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
@@ -554,36 +564,36 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 2,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 2,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 2,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 2,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 1,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 1,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 2,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 2,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 3,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 3,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
|
||||
@@ -610,9 +620,10 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_negatives" ,"") {
|
||||
uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment experiment(2,{nmodules, nmodules}, 0, 0, true);
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
@@ -636,23 +647,23 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_negatives" ,"") {
|
||||
transformation.SetOutput(output_compressed.data());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 0,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 0,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 1,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 1,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 2,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 2,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, 3,i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, 3,i, 1));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
size_t compressed_size;
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
|
||||
|
||||
@@ -117,7 +117,8 @@ TEST_CASE("HDF5File_Delete", "[HDF5][Unit]") {
|
||||
TEST_CASE("HDF5MasterFile", "[HDF5][Full]") {
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
x.FilePrefix("test01").ImagesPerTrigger(950);
|
||||
|
||||
StartMessage start_message;
|
||||
@@ -139,7 +140,7 @@ TEST_CASE("HDF5MasterFile", "[HDF5][Full]") {
|
||||
TEST_CASE("HDF5Writer", "[HDF5][Full]") {
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
x.FilePrefix("test02_1p10").ImagesPerTrigger(5).DataFileCount(2).Compression(JFJochProtoBuf::NO_COMPRESSION);
|
||||
@@ -166,7 +167,7 @@ TEST_CASE("HDF5Writer", "[HDF5][Full]") {
|
||||
TEST_CASE("HDF5Writer_Spots", "[HDF5][Full]") {
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
spots.push_back({10,10,7});
|
||||
@@ -195,7 +196,8 @@ TEST_CASE("HDF5Writer_Spots", "[HDF5][Full]") {
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
|
||||
x.ImagesPerTrigger(5).DataFileCount(5)
|
||||
.Compression(JFJochProtoBuf::NO_COMPRESSION).FilePrefix("vds");
|
||||
|
||||
@@ -250,9 +252,8 @@ TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
x.ImagesPerTrigger(5).DataFileCount(5)
|
||||
.Compression(JFJochProtoBuf::NO_COMPRESSION).FilePrefix("vds_missing");
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.ImagesPerTrigger(5).DataFileCount(5).Compression(JFJochProtoBuf::NO_COMPRESSION).FilePrefix("vds_missing");
|
||||
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
@@ -307,9 +308,8 @@ TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
|
||||
|
||||
|
||||
TEST_CASE("HDF5Writer_VDS_zero_images", "[HDF5][Full]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
x.ImagesPerTrigger(5).DataFileCount(5)
|
||||
.Compression(JFJochProtoBuf::NO_COMPRESSION).FilePrefix("vds_zero");
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.ImagesPerTrigger(5).DataFileCount(5).Compression(JFJochProtoBuf::NO_COMPRESSION).FilePrefix("vds_zero");
|
||||
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../jungfrau/JFCalibration.h"
|
||||
|
||||
TEST_CASE("JFCalibration_Constructor","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4,4});
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2));
|
||||
experiment.StorageCells(16);
|
||||
|
||||
JFCalibration c(experiment);
|
||||
@@ -163,7 +163,7 @@ TEST_CASE("JFCalibration_Statistics_All","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_MaskModuleEdges","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(1,{4});
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 1));
|
||||
experiment.MaskModuleEdges(true).Mode(DetectorMode::Raw);
|
||||
|
||||
JFCalibration calibration(experiment);
|
||||
@@ -182,7 +182,7 @@ TEST_CASE("JFCalibration_MaskModuleEdges","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_MaskChipEdges","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(1,{4});
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 1));
|
||||
experiment.MaskChipEdges(true).Mode(DetectorMode::Raw);
|
||||
|
||||
JFCalibration calibration(experiment);
|
||||
@@ -205,7 +205,7 @@ TEST_CASE("JFCalibration_MaskChipEdges","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_CalculateNexusMask","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(1, {4}, 8, 36, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 1, 8, 36, false));
|
||||
experiment.MaskModuleEdges(false).MaskChipEdges(false);
|
||||
JFCalibration calibration(4, 2);
|
||||
|
||||
@@ -240,7 +240,7 @@ TEST_CASE("JFCalibration_CalculateNexusMask","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_CalculateNexusMask_Bin2x2","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4}, 8, 36, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 2, 8, 36, false));
|
||||
experiment.MaskModuleEdges(false).MaskChipEdges(true).Binning2x2(true);
|
||||
JFCalibration calibration(4, 2);
|
||||
|
||||
@@ -266,7 +266,7 @@ TEST_CASE("JFCalibration_CalculateNexusMask_Bin2x2","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_CalculateOneByteMask","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(1, {4}, 8, 36, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 1, 8, 36, false));
|
||||
experiment.MaskModuleEdges(false).MaskChipEdges(false);
|
||||
JFCalibration calibration(experiment);
|
||||
calibration.Mask(0) = 50;
|
||||
@@ -287,7 +287,7 @@ TEST_CASE("JFCalibration_CalculateOneByteMask","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_CalculateOneByteMask_Bin2x2","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4}, 8, 36, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(4, 2, 8, 36, false));
|
||||
experiment.MaskModuleEdges(false).MaskChipEdges(true).Binning2x2(true);
|
||||
JFCalibration calibration(experiment);
|
||||
calibration.Mask(0) = 50;
|
||||
@@ -312,7 +312,7 @@ TEST_CASE("JFCalibration_CalculateOneByteMask_Bin2x2","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_LoadMask_Bitwise","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4, 4}, 8, 36, true);
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2, 8, 36, true));
|
||||
|
||||
experiment.PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
|
||||
@@ -346,7 +346,7 @@ TEST_CASE("JFCalibration_LoadMask_Bitwise","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_LoadMask","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4, 4}, 8, 36, true);
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2, 8, 36, true));
|
||||
|
||||
experiment.PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
|
||||
@@ -364,7 +364,7 @@ TEST_CASE("JFCalibration_LoadMask","[JFCalibration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFCalibration_MaskDetectorGaps","[JFCalibration]") {
|
||||
DiffractionExperiment experiment(2, {4, 4}, 8, 36, true);
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2, 8, 36, true));
|
||||
|
||||
experiment.PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
JFCalibration calibration(experiment);
|
||||
@@ -387,7 +387,7 @@ TEST_CASE("JFCalibration_Serialize","[ProtoBuf][JFCalibration]") {
|
||||
uint16_t nmodules = 2;
|
||||
uint16_t nstorage_cells = 2;
|
||||
|
||||
DiffractionExperiment experiment(1, {nmodules}, 0, 0, true);
|
||||
DiffractionExperiment experiment(DetectorGeometry(1));
|
||||
|
||||
experiment.PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ TEST_CASE("JFJochStateMachine_GainCalibration") {
|
||||
Logger logger("JFJochBrokerService_GainCalibration");
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(1, {2,2});
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(DetectorGeometry(4));
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
state_machine.LoadGainFile("../../tests/test_data/gainMaps_M049.bin");
|
||||
state_machine.LoadGainFile("../../tests/test_data/gainMaps_M049.bin");
|
||||
|
||||
@@ -23,7 +23,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ", "[JFJochReceiver]") {
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
@@ -31,7 +31,8 @@ TEST_CASE("JFJochIntegrationTest_ZMQ", "[JFJochReceiver]") {
|
||||
REQUIRE(!state_machine.GetMeasurementStatistics().has_value());
|
||||
|
||||
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
@@ -42,11 +43,11 @@ TEST_CASE("JFJochIntegrationTest_ZMQ", "[JFJochReceiver]") {
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -56,7 +57,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ", "[JFJochReceiver]") {
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -118,14 +119,15 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_2DataStreams_4Devices", "[JFJochReceiver]")
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
|
||||
REQUIRE(!state_machine.GetMeasurementStatistics().has_value());
|
||||
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
@@ -136,11 +138,11 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_2DataStreams_4Devices", "[JFJochReceiver]")
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -150,7 +152,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_2DataStreams_4Devices", "[JFJochReceiver]")
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -212,14 +214,15 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
|
||||
REQUIRE(!state_machine.GetMeasurementStatistics().has_value());
|
||||
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().Mode(DetectorMode::Conversion);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
@@ -230,11 +233,11 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -243,7 +246,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
JFJochProtoBuf::DetectorSettings detector_settings;
|
||||
detector_settings.set_frame_time_us(500);
|
||||
@@ -292,7 +295,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
REQUIRE(statistics.images_written() == 5);
|
||||
REQUIRE(statistics.file_prefix() == "integration_raw_test");
|
||||
REQUIRE(statistics.detector_width() == 1024);
|
||||
REQUIRE(statistics.detector_height() == 8*512);
|
||||
REQUIRE(statistics.detector_height() == 8 * 512);
|
||||
REQUIRE(statistics.detector_pixel_depth() == 2);
|
||||
|
||||
fpga_receiver_server->Shutdown();
|
||||
@@ -300,7 +303,6 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE("JFJochIntegrationTest_ZMQ_3Writers", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochIntegrationTest_ZMQ_3Writers");
|
||||
ZMQContext zmq_context;
|
||||
@@ -309,11 +311,12 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_3Writers", "[JFJochReceiver]") {
|
||||
|
||||
int64_t nimages = 37;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0);
|
||||
services
|
||||
.Writer("unix:writer_test_0", "inproc://#0")
|
||||
@@ -328,11 +331,11 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_3Writers", "[JFJochReceiver]") {
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -344,9 +347,9 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_3Writers", "[JFJochReceiver]") {
|
||||
JFJochWriterService writer_2(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server_0 = gRPCServer("unix:writer_test_0", writer_0);
|
||||
auto writer_server_1 = gRPCServer("unix:writer_test_1", writer_1);
|
||||
auto writer_server_2 = gRPCServer("unix:writer_test_2", writer_2);
|
||||
auto writer_server_0 = gRPCServer("unix:writer_test_0", writer_0);
|
||||
auto writer_server_1 = gRPCServer("unix:writer_test_1", writer_1);
|
||||
auto writer_server_2 = gRPCServer("unix:writer_test_2", writer_2);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -406,11 +409,12 @@ TEST_CASE("JFJochIntegrationTest_Cancel", "[JFJochReceiver]") {
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
@@ -421,16 +425,16 @@ TEST_CASE("JFJochIntegrationTest_Cancel", "[JFJochReceiver]") {
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
test->EnableLogging(&logger);
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(i); m++) {
|
||||
for (int frame = 1; frame <= nimages; frame ++)
|
||||
for (int frame = 1; frame <= nimages; frame++)
|
||||
test->AddModule(frame, m, image.data());
|
||||
}
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -439,7 +443,7 @@ TEST_CASE("JFJochIntegrationTest_Cancel", "[JFJochReceiver]") {
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -483,12 +487,14 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview", "[JFJochReceiver]") {
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0).PreviewPeriod(5ms);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0).PreviewPeriod(
|
||||
5ms);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
logger.Verbose(true);
|
||||
@@ -498,7 +504,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview", "[JFJochReceiver]") {
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(i); m++) {
|
||||
for (int image_num = 1; image_num <= nimages; image_num++)
|
||||
test->AddModule(image_num, m, image.data());
|
||||
@@ -508,7 +514,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview", "[JFJochReceiver]") {
|
||||
}
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -524,7 +530,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview", "[JFJochReceiver]") {
|
||||
rcv_preview_socket.SubscribeAll();
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -601,12 +607,14 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview_no_writer", "[JFJochReceiver]"
|
||||
|
||||
int64_t nimages = 5;
|
||||
int64_t ndatastream = 2;
|
||||
std::vector<int64_t> nmodules = {4, 4};
|
||||
int64_t nmodules = 4;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0).PreviewPeriod(5ms);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0).PreviewPeriod(
|
||||
5ms);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
logger.Verbose(true);
|
||||
@@ -616,7 +624,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview_no_writer", "[JFJochReceiver]"
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
for (int i = 0; i < ndatastream; i++) {
|
||||
auto *test = new MockAcquisitionDevice(i , 256);
|
||||
auto *test = new MockAcquisitionDevice(i, 256);
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(i); m++) {
|
||||
for (int image_num = 1; image_num <= nimages; image_num++)
|
||||
test->AddModule(image_num, m, image.data());
|
||||
@@ -626,7 +634,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview_no_writer", "[JFJochReceiver]"
|
||||
}
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -642,7 +650,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_with_preview_no_writer", "[JFJochReceiver]"
|
||||
rcv_preview_socket.SubscribeAll();
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -717,11 +725,12 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_background_estimation", "[JFJochReceiver]")
|
||||
|
||||
size_t nimages = 10;
|
||||
int64_t ndatastream = 1;
|
||||
std::vector<int64_t> nmodules = {8};
|
||||
int64_t nmodules = 8;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0)
|
||||
.MaskChipEdges(true).MaskModuleEdges(true).SpotFindingPeriod(1ms).FrameTime(1ms);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
@@ -732,10 +741,10 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_background_estimation", "[JFJochReceiver]")
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
auto *test = new MockAcquisitionDevice(0 , 256);
|
||||
auto *test = new MockAcquisitionDevice(0, 256);
|
||||
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
for (auto & j: image_raw_geom)
|
||||
for (auto &j: image_raw_geom)
|
||||
j = 2 * i + 5;
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(); m++)
|
||||
test->AddModule(i + 1, m, image_raw_geom.data());
|
||||
@@ -747,7 +756,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_background_estimation", "[JFJochReceiver]")
|
||||
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -760,7 +769,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_background_estimation", "[JFJochReceiver]")
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -806,7 +815,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_background_estimation", "[JFJochReceiver]")
|
||||
REQUIRE(plots.bkg_estimate().x_size() == 1);
|
||||
REQUIRE(plots.bkg_estimate().y_size() == 1);
|
||||
REQUIRE(plots.bkg_estimate().x(0) == Approx(4.5));
|
||||
REQUIRE(plots.bkg_estimate().y(0) == Approx((5+23) / 2.0));
|
||||
REQUIRE(plots.bkg_estimate().y(0) == Approx((5 + 23) / 2.0));
|
||||
|
||||
auto tmp = state_machine.GetMeasurementStatistics();
|
||||
REQUIRE(tmp.has_value());
|
||||
@@ -826,11 +835,12 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot", "[JFJochReceiver]") {
|
||||
|
||||
size_t nimages = 1;
|
||||
int64_t ndatastream = 1;
|
||||
std::vector<int64_t> nmodules = {8};
|
||||
int64_t nmodules = 8;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
|
||||
@@ -842,22 +852,24 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot", "[JFJochReceiver]") {
|
||||
HDF5DataSet dataset(data, "/entry/data/data");
|
||||
HDF5DataSpace file_space(dataset);
|
||||
|
||||
std::vector<int16_t> image_conv ( nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
std::vector<int16_t> image_conv(nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
std::vector<hsize_t> start = {0,0,0};
|
||||
std::vector<hsize_t> start = {0, 0, 0};
|
||||
std::vector<hsize_t> file_size = {nimages, file_space.GetDimensions()[1], file_space.GetDimensions()[2]};
|
||||
dataset.ReadVector(image_conv, start, file_size);
|
||||
|
||||
std::vector<int16_t> image_raw_geom(nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
std::vector<int16_t> image_raw_geom(
|
||||
nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
for (int i = 0; i < nimages; i++)
|
||||
ConvertedToRawGeometry(state_machine.NotThreadSafe_Experiment(),
|
||||
image_raw_geom.data() + i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_raw_geom.data() +
|
||||
i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_conv.data() + i * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
auto *test = new MockAcquisitionDevice(0 , 256);
|
||||
auto *test = new MockAcquisitionDevice(0, 256);
|
||||
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(0); m++) {
|
||||
test->AddModule(1, m, (uint16_t *) (image_raw_geom.data() + m * RAW_MODULE_SIZE));
|
||||
@@ -868,7 +880,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot", "[JFJochReceiver]") {
|
||||
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -877,7 +889,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot", "[JFJochReceiver]") {
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -934,11 +946,12 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index", "[JFJochReceiver]
|
||||
|
||||
size_t nimages = 24;
|
||||
int64_t ndatastream = 1;
|
||||
std::vector<int64_t> nmodules = {8};
|
||||
int64_t nmodules = 8;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0)
|
||||
.SpotFindingPeriod(10ms).IndexingPeriod(10ms);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
@@ -951,27 +964,31 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index", "[JFJochReceiver]
|
||||
HDF5DataSet dataset(data, "/entry/data/data");
|
||||
HDF5DataSpace file_space(dataset);
|
||||
|
||||
std::vector<int16_t> image_conv ( nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
std::vector<int16_t> image_conv(nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
std::vector<hsize_t> start = {0,0,0};
|
||||
std::vector<hsize_t> start = {0, 0, 0};
|
||||
std::vector<hsize_t> file_size = {nimages, file_space.GetDimensions()[1], file_space.GetDimensions()[2]};
|
||||
dataset.ReadVector(image_conv, start, file_size);
|
||||
|
||||
std::vector<int16_t> image_raw_geom(nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
std::vector<int16_t> image_raw_geom(
|
||||
nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
for (int i = 0; i < nimages; i++)
|
||||
ConvertedToRawGeometry(state_machine.NotThreadSafe_Experiment(),
|
||||
image_raw_geom.data() + i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_raw_geom.data() +
|
||||
i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_conv.data() + i * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
auto *test = new MockAcquisitionDevice(0 , 512);
|
||||
auto *test = new MockAcquisitionDevice(0, 512);
|
||||
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(0); m++) {
|
||||
for (int image_num = 1; image_num <= nimages; image_num++)
|
||||
test->AddModule(image_num, m, (uint16_t *) (image_raw_geom.data()
|
||||
+ (m + (image_num-1) * state_machine.NotThreadSafe_Experiment().GetModulesNum(0))
|
||||
+ (m + (image_num - 1) *
|
||||
state_machine.NotThreadSafe_Experiment().GetModulesNum(
|
||||
0))
|
||||
* RAW_MODULE_SIZE));
|
||||
}
|
||||
test->Terminate();
|
||||
@@ -980,7 +997,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index", "[JFJochReceiver]
|
||||
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -989,7 +1006,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index", "[JFJochReceiver]
|
||||
JFJochWriterService writer(zmq_context, logger);;
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -1049,11 +1066,12 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
|
||||
size_t nimages = 24;
|
||||
int64_t ndatastream = 1;
|
||||
std::vector<int64_t> nmodules = {8};
|
||||
int64_t nmodules = 8;
|
||||
|
||||
JFJochServices services(logger);
|
||||
JFJochStateMachine state_machine(services, logger);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(2, nmodules, 8, 36);
|
||||
state_machine.NotThreadSafe_Experiment() = DiffractionExperiment(
|
||||
DetectorGeometry(ndatastream * nmodules, 2, 8, 36)).DataStreams(ndatastream);
|
||||
state_machine.NotThreadSafe_Experiment().PedestalG0Frames(0).PedestalG1Frames(0).PedestalG2Frames(0)
|
||||
.SpotFindingPeriod(10ms).IndexingPeriod(10ms);
|
||||
services.Writer("unix:writer_test", "inproc://#1").Receiver("unix:fpga_receiver_test");
|
||||
@@ -1066,29 +1084,33 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
HDF5DataSet dataset(data, "/entry/data/data");
|
||||
HDF5DataSpace file_space(dataset);
|
||||
|
||||
std::vector<int16_t> image_conv ( nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
std::vector<int16_t> image_conv(nimages * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
std::vector<hsize_t> start = {0,0,0};
|
||||
std::vector<hsize_t> start = {0, 0, 0};
|
||||
std::vector<hsize_t> file_size = {nimages, file_space.GetDimensions()[1], file_space.GetDimensions()[2]};
|
||||
dataset.ReadVector(image_conv, start, file_size);
|
||||
|
||||
std::vector<int16_t> image_raw_geom(nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
std::vector<int16_t> image_raw_geom(
|
||||
nimages * state_machine.NotThreadSafe_Experiment().GetModulesNum() * RAW_MODULE_SIZE * sizeof(int16_t));
|
||||
for (int i = 0; i < nimages; i++)
|
||||
ConvertedToRawGeometry(state_machine.NotThreadSafe_Experiment(),
|
||||
image_raw_geom.data() + i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_raw_geom.data() +
|
||||
i * RAW_MODULE_SIZE * state_machine.NotThreadSafe_Experiment().GetModulesNum(),
|
||||
image_conv.data() + i * file_space.GetDimensions()[1] * file_space.GetDimensions()[2]);
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
|
||||
auto *test = new MockAcquisitionDevice(0 , 512);
|
||||
auto *test = new MockAcquisitionDevice(0, 512);
|
||||
|
||||
std::vector<uint16_t> pedestal(RAW_MODULE_SIZE, 3500);
|
||||
|
||||
for (int m = 0; m < state_machine.NotThreadSafe_Experiment().GetModulesNum(0); m++) {
|
||||
for (int image_num = 1; image_num <= nimages; image_num++)
|
||||
test->AddModule(image_num, m, (uint16_t *) (image_raw_geom.data()
|
||||
+ (m + (image_num-1) * state_machine.NotThreadSafe_Experiment().GetModulesNum(0))
|
||||
+ (m + (image_num - 1) *
|
||||
state_machine.NotThreadSafe_Experiment().GetModulesNum(
|
||||
0))
|
||||
* RAW_MODULE_SIZE));
|
||||
}
|
||||
test->Terminate();
|
||||
@@ -1097,7 +1119,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
|
||||
ZMQContext zmq_context;
|
||||
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
std::vector<AcquisitionDevice *> tmp_devices;
|
||||
for (const auto &i: aq_devices)
|
||||
tmp_devices.emplace_back(i.get());
|
||||
|
||||
@@ -1106,7 +1128,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
JFJochWriterService writer(zmq_context, logger);
|
||||
|
||||
auto fpga_receiver_server = gRPCServer("unix:fpga_receiver_test", fpga_receiver);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
auto writer_server = gRPCServer("unix:writer_test", writer);
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
@@ -1116,7 +1138,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
setup.set_detector_distance_mm(75);
|
||||
setup.set_summation(3);
|
||||
setup.set_file_prefix("spot_finding_test");
|
||||
setup.set_images_per_trigger(nimages/3);
|
||||
setup.set_images_per_trigger(nimages / 3);
|
||||
setup.set_photon_energy_kev(12.4);
|
||||
setup.set_beam_x_pxl(1090);
|
||||
setup.set_beam_y_pxl(1136);
|
||||
@@ -1150,7 +1172,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_lysozyme_spot_and_index_sum", "[JFJochRecei
|
||||
auto statistics = tmp.value();
|
||||
|
||||
REQUIRE(statistics.collection_efficiency() == 1.0);
|
||||
REQUIRE(statistics.images_collected() == nimages/3);
|
||||
REQUIRE(statistics.images_collected() == nimages / 3);
|
||||
REQUIRE(statistics.has_indexing_rate());
|
||||
REQUIRE(statistics.indexing_rate() == 1.0);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_Raw", "[JFJochReceiver]") {
|
||||
DiffractionExperiment x(1, {4});
|
||||
DiffractionExperiment x(DetectorGeometry(4));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
@@ -42,7 +42,7 @@ TEST_CASE("JFJochReceiverTest_Raw", "[JFJochReceiver]") {
|
||||
TEST_CASE("JFJochReceiverTest_Conversion", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochReceiverTest_Conversion");
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -72,7 +72,7 @@ TEST_CASE("JFJochReceiverTest_Conversion", "[JFJochReceiver]") {
|
||||
TEST_CASE("JFJochReceiverTest_Conversion_Bin2x2", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochReceiverTest_Conversion_Bin2x2");
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -100,9 +100,9 @@ TEST_CASE("JFJochReceiverTest_Conversion_Bin2x2", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_ConversionOnCPU", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochReceiverTest_Conversion");
|
||||
Logger logger("JFJochReceiverTest_ConversionOnCPU");
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -129,10 +129,41 @@ TEST_CASE("JFJochReceiverTest_ConversionOnCPU", "[JFJochReceiver]") {
|
||||
REQUIRE(!output.cancelled());
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_ConversionOnCPU_Bin2x2", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochReceiverTest_ConversionOnCPU_Bin2x2");
|
||||
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true).ConversionOnCPU(true).Binning2x2(true)
|
||||
.ImagesPerTrigger(32).DataFileCount(16).PhotonEnergy_keV(12.4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
|
||||
AcquisitionDevice *test;
|
||||
test = new HLSSimulatedDevice(i, 64);
|
||||
test->EnableLogging(&logger);
|
||||
aq_devices.emplace_back(test);
|
||||
}
|
||||
|
||||
JFJochProtoBuf::ReceiverOutput output;
|
||||
bool ret;
|
||||
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, nthreads, false));
|
||||
REQUIRE(ret);
|
||||
REQUIRE(output.efficiency() == 1.0);
|
||||
REQUIRE(output.images_sent() == x.GetImageNum());
|
||||
|
||||
REQUIRE(output.device_statistics(0).timestamp_size() == 32 * 2);
|
||||
REQUIRE(output.device_statistics(0).timestamp(30 * 2) == 0xABCDEF);
|
||||
REQUIRE(!output.cancelled());
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_Conversion_StorageCell", "[JFJochReceiver]") {
|
||||
Logger logger("JFJochReceiverTest_Conversion_StorageCell");
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
@@ -182,7 +213,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG1", "[JFJochReceiver]") {
|
||||
i = 16384 | number;
|
||||
}
|
||||
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::PedestalG1).PedestalG0Frames(0)
|
||||
.PedestalG1Frames(nframes).NumTriggers(1).UseInternalPacketGenerator(false)
|
||||
.ImagesPerTrigger(0).PhotonEnergy_keV(12.4);
|
||||
@@ -242,7 +273,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG2_storage_cell", "[JFJochReceiver]") {
|
||||
if (number > 16300) number = 16300;
|
||||
i = 32768 | 16384 | number;
|
||||
}
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::PedestalG2).PedestalG0Frames(0)
|
||||
.PedestalG2Frames(nframes).NumTriggers(1).UseInternalPacketGenerator(false)
|
||||
.ImagesPerTrigger(0).PhotonEnergy_keV(12.4).StorageCells(16);
|
||||
@@ -285,7 +316,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG2_storage_cell", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_PedestalG0", "[JFJochReceiver]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
const uint16_t nthreads = 4;
|
||||
size_t nframes = 500;
|
||||
|
||||
@@ -338,7 +369,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG0", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_PedestalG0_StorageCell", "[JFJochReceiver]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
const uint16_t nthreads = 4;
|
||||
size_t nframes = 140;
|
||||
|
||||
@@ -390,7 +421,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG0_StorageCell", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_PedestalG1_NoFrames", "[JFJochReceiver]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
const uint16_t nthreads = 4;
|
||||
size_t nframes = 256;
|
||||
|
||||
@@ -423,7 +454,7 @@ TEST_CASE("JFJochReceiverTest_PedestalG1_NoFrames", "[JFJochReceiver]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochReceiverTest_PacketLost_Raw", "[JFJochReceiver]") {
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
const uint16_t nthreads = 4;
|
||||
|
||||
std::vector<uint16_t> frame_in(RAW_MODULE_SIZE);
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
TEST_CASE("MockAcquisitionDevice") {
|
||||
std::vector<uint16_t> module_data(RAW_MODULE_SIZE, 765);
|
||||
|
||||
DiffractionExperiment experiment(2, {4,4});
|
||||
DiffractionExperiment experiment(DetectorGeometry(8, 2));
|
||||
experiment.DataStreams(2);
|
||||
|
||||
experiment.NumTriggers(1).ImagesPerTrigger(5);
|
||||
MockAcquisitionDevice device(0, 128);
|
||||
|
||||
@@ -9,7 +9,7 @@ TEST_CASE("JFPedestalCalc", "[JFPedestalCalc]") {
|
||||
uint16_t base_value;
|
||||
uint16_t wrong_value;
|
||||
uint16_t mask_value;
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
|
||||
switch (gain_level) {
|
||||
case 1:
|
||||
@@ -91,7 +91,7 @@ TEST_CASE("JFPedestalCalc", "[JFPedestalCalc]") {
|
||||
}
|
||||
|
||||
TEST_CASE("PedestalCalc_ImagesLessThanWindow", "[JFPedestalCalc]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::PedestalG2);
|
||||
JFModulePedestal calib;
|
||||
JFPedestalCalc calc(x);
|
||||
@@ -125,7 +125,7 @@ TEST_CASE("PedestalCalc_ImagesLessThanWindow", "[JFPedestalCalc]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFPedestal_line0","[JFModulePedestal]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::PedestalG0);
|
||||
JFModulePedestal calib;
|
||||
|
||||
@@ -167,7 +167,7 @@ TEST_CASE("JFPedestal_line0","[JFModulePedestal]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFPedestal_wrong_size","[JFModulePedestal]") {
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
|
||||
std::unique_ptr<JFPedestalCalc> calc;
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ TEST_CASE("ProcessRawPacketTest") {
|
||||
wr_fifo.Put(ProcessWorkRequest{.ptr = array_1.data(), .handle = 1});
|
||||
wr_fifo.Put(ProcessWorkRequest{.ptr = array_2.data(), .handle = 2});
|
||||
|
||||
DiffractionExperiment experiment(2, {4,4});
|
||||
DiffractionExperiment experiment(DetectorGeometry(8));
|
||||
experiment.DataStreams(2);
|
||||
|
||||
{
|
||||
ProcessJFPacket process(c_fifo, wr_fifo, 4);
|
||||
|
||||
@@ -14,7 +14,7 @@ TEST_CASE("RadialIntegrationMapping_Constructor","[RadialIntegration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationMapping_Constructor_Mask","[RadialIntegration]") {
|
||||
DiffractionExperiment x{2,{8}, 8, 36};
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.001).HighQForRadialInt_recipA(9.9);
|
||||
@@ -32,7 +32,7 @@ TEST_CASE("RadialIntegrationMapping_Constructor_Mask","[RadialIntegration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationMapping_GetBinNumber","[RadialIntegration]") {
|
||||
DiffractionExperiment x{2,{8}, 8, 36};
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
RadialIntegrationMapping mapping(x);
|
||||
@@ -40,7 +40,7 @@ TEST_CASE("RadialIntegrationMapping_GetBinNumber","[RadialIntegration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationMapping_GetBinNumber_DetectorLimit","[RadialIntegration]") {
|
||||
DiffractionExperiment x{2,{8}, 8, 36};
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(9.9);
|
||||
@@ -49,7 +49,7 @@ TEST_CASE("RadialIntegrationMapping_GetBinNumber_DetectorLimit","[RadialIntegrat
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationMapping_GetBinToQ","[RadialIntegration]") {
|
||||
DiffractionExperiment x{2,{8}, 8, 36};
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
|
||||
@@ -63,7 +63,7 @@ TEST_CASE("RadialIntegrationMapping_GetBinToQ","[RadialIntegration]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationMapping_QToBin","[RadialIntegration]") {
|
||||
DiffractionExperiment x{2,{8}, 8, 36};
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
|
||||
|
||||
@@ -65,74 +65,6 @@ TEST_CASE("RawToConvertedGeometry_LineCopyAndAddMultipixelNormalRow","[RawToConv
|
||||
REQUIRE(out[1029] == 1029 - 6);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_LineCopyAndAdjustMultipixelBin2x2","[RawToConvertedGeometry]") {
|
||||
int16_t in[2048];
|
||||
int16_t out[514];
|
||||
for (int16_t i = 0; i < 2048; i++)
|
||||
in[i] = i;
|
||||
|
||||
LineCopyAndAdjustMultipixelBin2x2<int16_t>(out, in, -1, 6000);
|
||||
CHECK(out[0] == 0+1+1024+1025);
|
||||
CHECK(out[100] == 200+201+1224+1225);
|
||||
CHECK(out[127] == 254+255/2+254+1024+255/2+1024/2);
|
||||
CHECK(out[128] == 255/2+256/2+1024/2+255/2+256/2+1024/2);
|
||||
CHECK(out[129] == 257+256/2+1024/2+257+1024+256/2);
|
||||
CHECK(out[201] == 400+401+400+401+1024+1024);
|
||||
CHECK(out[302] == 600+601+600+601+1024+1024);
|
||||
CHECK(out[385] == 766+767/2+1024+766+767/2+1024/2);
|
||||
CHECK(out[386] == 767/2+768/2+1024/2+1024/2+767/2+768/2);
|
||||
CHECK(out[403] == 800+801+800+801+1024+1024);
|
||||
CHECK(out[513] == 6000); // overload
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_LineCopyAndAdjustMultipixelBin2x2MidRow","[RawToConvertedGeometry]") {
|
||||
int16_t in[1024];
|
||||
int16_t out[514];
|
||||
for (int16_t i = 0; i < 1024; i++)
|
||||
in[i] = i;
|
||||
|
||||
LineCopyAndAdjustMultipixelBin2x2MidRow<int16_t>(out, in, -1, 2000);
|
||||
REQUIRE(out[0] == 0+1);
|
||||
REQUIRE(out[100] == 200 + 201);
|
||||
REQUIRE(out[127] == 254 + 255/2);
|
||||
REQUIRE(out[128] == 256/2 + 255/2);
|
||||
REQUIRE(out[129] == 256/2 + 257);
|
||||
REQUIRE(out[201] == 400+401);
|
||||
REQUIRE(out[302] == 600+601);
|
||||
REQUIRE(out[385] == 766+767/2);
|
||||
REQUIRE(out[386] == 767/2+768/2);
|
||||
REQUIRE(out[403] == 800+801);
|
||||
REQUIRE(out[513] == 2000); // overload
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_TransferModuleAdjustMultipixelsBin2x2","[RawToConvertedGeometry]") {
|
||||
int16_t in[RAW_MODULE_SIZE];
|
||||
int16_t out[(CONVERTED_MODULE_COLS/2) * (CONVERTED_MODULE_LINES/2)];
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
in[i] = i % 1024;
|
||||
|
||||
TransferModuleAdjustMultipixelsBin2x2<int16_t>(out, in, (CONVERTED_MODULE_COLS/2), -1, 8000);
|
||||
|
||||
CHECK(out[0] == 0 + 1 + 0 + 1);
|
||||
CHECK(out[1] == 2 + 3 + 2 + 3);
|
||||
CHECK(out[513] == 1020 + 1021 + 1020 + 1021);
|
||||
CHECK(out[514] == 1022 + 1023 + 1022 + 1023);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 100 + 1] == 2 + 3 + 2 + 3);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 100 + 127] == 2*(254 + 255/2));
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 100 + 128] == 2*(255/2 + 256/2));
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 128] == 0 + 1);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 128 + 1] == 2 + 3);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 128 + 127] == 254+255/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 128 + 128] == 255/2+256/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 128 + 128 + 129 * 2] == 767/2+768/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 129] == 0 + 1);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 129 + 1] == 2 + 3);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 129 + 127] == 254+255/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 129 + 128] == 255/2+256/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * 129 + 128 + 129 * 2] == 767/2+768/2);
|
||||
CHECK(out[(CONVERTED_MODULE_COLS/2) * (CONVERTED_MODULE_LINES/2) - 1] == 1022+1023+1022+1023);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_LineCopyAndAddMultipixelMiddleRow","[RawToConvertedGeometry]") {
|
||||
int16_t in[1024];
|
||||
int16_t out[1030];
|
||||
@@ -157,21 +89,23 @@ TEST_CASE("RawToConvertedGeometry_LineCopyAndAddMultipixelMiddleRow","[RawToConv
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_Transform","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2, {4,4,6,6}, 0,0, false);
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, 0, 0, false));
|
||||
x.DataStreams(4);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
REQUIRE(x.GetModulesNum(2) == 5);
|
||||
REQUIRE(x.GetPixelsNum() == CONVERTED_MODULE_SIZE * x.GetModulesNum());
|
||||
|
||||
std::vector<uint32_t> input(x.GetModulesNum(3) * RAW_MODULE_SIZE);
|
||||
std::vector<uint32_t> input(x.GetModulesNum(0) * RAW_MODULE_SIZE);
|
||||
std::vector<uint32_t> output(x.GetPixelsNum());
|
||||
|
||||
for (uint32_t i = 0; i < x.GetModulesNum(3) * RAW_MODULE_SIZE; i++) input[i] = i;
|
||||
for (uint32_t i = 0; i < x.GetModulesNum(0) * RAW_MODULE_SIZE; i++) input[i] = i;
|
||||
|
||||
for (int i = 0; i < x.GetModulesNum(3); i++)
|
||||
TransferModule<uint32_t, uint32_t>(output.data() + x.GetPixel0OfModule(i),
|
||||
for (int i = 0; i < x.GetModulesNum(0); i++)
|
||||
TransferModule<uint32_t, uint32_t>(output.data() + x.GetPixel0OfModule(i + x.GetFirstModuleOfDataStream(0)),
|
||||
input.data() + i * RAW_MODULE_SIZE,
|
||||
(x.IsUpsideDown() ? -1 : 1) * x.GetXPixelsNum());
|
||||
x.GetModuleSlowDirectionStep(i + x.GetFirstModuleOfDataStream(0)),
|
||||
x.GetModuleFastDirectionStep(i + x.GetFirstModuleOfDataStream(0)));
|
||||
|
||||
REQUIRE(output[0] == input[0]);
|
||||
REQUIRE(output[253] == input[253]);
|
||||
@@ -215,25 +149,27 @@ TEST_CASE("RawToConvertedGeometry_Transform","[RawToConvertedGeometry]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_Transform_AdjustMultipixels","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2, {4,4,6,6}, 0, 0, false);
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, 0, 0, false));
|
||||
x.DataStreams(4);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.Summation(2); // Ensure the image is 32-bit
|
||||
REQUIRE(x.GetPixelDepth() == 4);
|
||||
|
||||
REQUIRE(x.GetModulesNum(3) == 6);
|
||||
REQUIRE(x.GetModulesNum(0) == 5);
|
||||
REQUIRE(x.GetPixelsNum() == CONVERTED_MODULE_SIZE * x.GetModulesNum());
|
||||
|
||||
std::vector<int32_t> input(x.GetModulesNum(3) * RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> input(x.GetModulesNum(0) * RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> output(x.GetPixelsNum());
|
||||
|
||||
for (int32_t i = 0; i < x.GetModulesNum(3) * RAW_MODULE_SIZE; i++) input[i] = i % x.GetOverflow();
|
||||
for (int32_t i = 0; i < x.GetModulesNum(0) * RAW_MODULE_SIZE; i++) input[i] = i % x.GetOverflow();
|
||||
|
||||
for (int i = 0; i < x.GetModulesNum(3); i++)
|
||||
TransferModuleAdjustMultipixels<int32_t, int32_t>(output.data() + x.GetPixel0OfModule(i),
|
||||
for (int i = 0; i < x.GetModulesNum(0); i++)
|
||||
TransferModuleAdjustMultipixels<int32_t, int32_t>(output.data() + x.GetPixel0OfModule(i + x.GetFirstModuleOfDataStream(0)),
|
||||
input.data() + i * RAW_MODULE_SIZE,
|
||||
(x.IsUpsideDown() ? -1 : 1) * x.GetXPixelsNum(),
|
||||
x.GetUnderflow(), x.GetOverflow());
|
||||
x.GetModuleSlowDirectionStep(i + x.GetFirstModuleOfDataStream(0)),
|
||||
x.GetUnderflow(), x.GetOverflow(),
|
||||
x.GetModuleFastDirectionStep(i + x.GetFirstModuleOfDataStream(0)));
|
||||
|
||||
REQUIRE(output[0] == input[0]);
|
||||
REQUIRE(output[253] == input[253]);
|
||||
@@ -276,46 +212,9 @@ TEST_CASE("RawToConvertedGeometry_Transform_AdjustMultipixels","[RawToConvertedG
|
||||
REQUIRE(output[1030*514*2 + 256] == input[512*1024*2 + 255] / 2);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_Transform_AdjustMultipixelsBin2x2","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36, true);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.Summation(2).Binning2x2(true);
|
||||
|
||||
REQUIRE(x.GetPixelDepth() == 4);
|
||||
|
||||
std::vector<int32_t> input(x.GetModulesNum() * RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> output(x.GetPixelsNum());
|
||||
|
||||
for (int32_t i = 0; i < x.GetModulesNum() * RAW_MODULE_SIZE; i++)
|
||||
input[i] = i % 98765;
|
||||
|
||||
for (int i = 0; i < x.GetModulesNum(); i++)
|
||||
TransferModuleAdjustMultipixelsBin2x2<int32_t>(output.data() + x.GetPixel0OfModule(i),
|
||||
input.data() + i * RAW_MODULE_SIZE,
|
||||
(x.IsUpsideDown() ? -1 : 1) * x.GetXPixelsNum(),
|
||||
x.GetUnderflow(),
|
||||
x.GetOverflow());
|
||||
|
||||
|
||||
CHECK(output[0] == input[(6*RAW_MODULE_LINES+511)*RAW_MODULE_COLS] + input[(6*RAW_MODULE_LINES+511)*RAW_MODULE_COLS+1]
|
||||
+ input[(6*RAW_MODULE_LINES+510)*RAW_MODULE_COLS] + input[(6*RAW_MODULE_LINES+510)*RAW_MODULE_COLS+1]);
|
||||
|
||||
CHECK(output[124/2] == input[(6*RAW_MODULE_LINES+511)*RAW_MODULE_COLS+124] + input[(6*RAW_MODULE_LINES+511)*RAW_MODULE_COLS+125]
|
||||
+ input[(6*RAW_MODULE_LINES+510)*RAW_MODULE_COLS+124] + input[(6*RAW_MODULE_LINES+510)*RAW_MODULE_COLS+125]);
|
||||
|
||||
CHECK(output[1038/2] == input[(7*RAW_MODULE_LINES+511)*RAW_MODULE_COLS] + input[(7*RAW_MODULE_LINES+511)*RAW_MODULE_COLS+1]
|
||||
+ input[(7*RAW_MODULE_LINES+510)*RAW_MODULE_COLS] + input[(7*RAW_MODULE_LINES+510)*RAW_MODULE_COLS+1]);
|
||||
|
||||
CHECK(output[((514+36)/2+513/2)*x.GetXPixelsNum()] == input[(4*RAW_MODULE_LINES)*RAW_MODULE_COLS] + input[(4*RAW_MODULE_LINES)*RAW_MODULE_COLS+1]
|
||||
+ input[(4*RAW_MODULE_LINES+1)*RAW_MODULE_COLS] + input[(4*RAW_MODULE_LINES+1)*RAW_MODULE_COLS+1]);
|
||||
|
||||
CHECK(output[(x.GetYPixelsNum()-1)*x.GetXPixelsNum()] == input[0] + input[1] + input[1024] + input[1025]);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_Transform_upside_down","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2,{4,4,6,6}, 0, 0, true);
|
||||
DiffractionExperiment x(DetectorGeometry(24, 2, 0, 0, true));
|
||||
x.DataStreams(4);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(3) == 6);
|
||||
@@ -328,7 +227,7 @@ TEST_CASE("RawToConvertedGeometry_Transform_upside_down","[RawToConvertedGeometr
|
||||
for (int i = 0; i < x.GetModulesNum(3); i++)
|
||||
TransferModule<uint32_t, uint32_t>(output + x.GetPixel0OfModule(i + x.GetFirstModuleOfDataStream(3)),
|
||||
input + i * RAW_MODULE_SIZE,
|
||||
(x.IsUpsideDown() ? -1 : 1) * x.GetXPixelsNum());
|
||||
x.GetModuleSlowDirectionStep(i + x.GetFirstModuleOfDataStream(3)));
|
||||
|
||||
REQUIRE(output[514*1030*4+0] == input[511*1024+0]);
|
||||
REQUIRE(output[514*1030*4+253] == input[511*1024+253]);
|
||||
@@ -374,11 +273,103 @@ TEST_CASE("RawToConvertedGeometry_Transform_upside_down","[RawToConvertedGeometr
|
||||
free(output);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_TransformModule_rotate","[RawToConvertedGeometry]") {
|
||||
std::vector<int32_t> raw_image(RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> conv_image(CONVERTED_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < raw_image.size(); i++)
|
||||
raw_image[i] = i;
|
||||
|
||||
TransferModule(conv_image.data(), raw_image.data(), 1, CONVERTED_MODULE_LINES, 0);
|
||||
|
||||
CHECK(conv_image[0] == raw_image[0]);
|
||||
CHECK(conv_image[1] == raw_image[RAW_MODULE_COLS]);
|
||||
CHECK(conv_image[5] == raw_image[RAW_MODULE_COLS*5]);
|
||||
CHECK(conv_image[255] == raw_image[RAW_MODULE_COLS*255]);
|
||||
CHECK(conv_image[256] == raw_image[RAW_MODULE_COLS*255]);
|
||||
CHECK(conv_image[257] == raw_image[RAW_MODULE_COLS*256]);
|
||||
CHECK(conv_image[258] == raw_image[RAW_MODULE_COLS*256]);
|
||||
CHECK(conv_image[513] == raw_image[RAW_MODULE_COLS*511]);
|
||||
|
||||
CHECK(conv_image[5 * CONVERTED_MODULE_LINES] == raw_image[5]);
|
||||
CHECK(conv_image[255 * CONVERTED_MODULE_LINES] == raw_image[255]);
|
||||
CHECK(conv_image[256 * CONVERTED_MODULE_LINES] == raw_image[255]);
|
||||
CHECK(conv_image[257 * CONVERTED_MODULE_LINES] == raw_image[256]);
|
||||
CHECK(conv_image[258 * CONVERTED_MODULE_LINES] == raw_image[256]);
|
||||
CHECK(conv_image[1029 * CONVERTED_MODULE_LINES] == raw_image[1023]);
|
||||
|
||||
CHECK(conv_image[CONVERTED_MODULE_SIZE-1] == raw_image[RAW_MODULE_SIZE-1]);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_TransformModuleAdjustMultipixel_rotate","[RawToConvertedGeometry]") {
|
||||
std::vector<int32_t> raw_image(RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> conv_image(CONVERTED_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < raw_image.size(); i++)
|
||||
raw_image[i] = i;
|
||||
|
||||
TransferModuleAdjustMultipixels(conv_image.data(), raw_image.data(), 1, INT32_MIN, INT32_MAX,
|
||||
CONVERTED_MODULE_LINES, 0);
|
||||
|
||||
CHECK(conv_image[0] == raw_image[0]);
|
||||
CHECK(conv_image[1] == raw_image[RAW_MODULE_COLS]);
|
||||
CHECK(conv_image[5] == raw_image[RAW_MODULE_COLS*5]);
|
||||
CHECK(conv_image[513] == raw_image[RAW_MODULE_COLS*511]);
|
||||
|
||||
CHECK(conv_image[255] == raw_image[RAW_MODULE_COLS*255]/2);
|
||||
CHECK(conv_image[256] == raw_image[RAW_MODULE_COLS*255]/2);
|
||||
CHECK(conv_image[257] == raw_image[RAW_MODULE_COLS*256]/2);
|
||||
CHECK(conv_image[258] == raw_image[RAW_MODULE_COLS*256]/2);
|
||||
|
||||
CHECK(conv_image[5 * CONVERTED_MODULE_LINES] == raw_image[5]);
|
||||
CHECK(conv_image[255 * CONVERTED_MODULE_LINES] == raw_image[255]/2);
|
||||
CHECK(conv_image[256 * CONVERTED_MODULE_LINES] == raw_image[255]/2);
|
||||
CHECK(conv_image[257 * CONVERTED_MODULE_LINES] == raw_image[256]/2);
|
||||
CHECK(conv_image[258 * CONVERTED_MODULE_LINES] == raw_image[256]/2);
|
||||
CHECK(conv_image[1029 * CONVERTED_MODULE_LINES] == raw_image[1023]);
|
||||
|
||||
CHECK(conv_image[CONVERTED_MODULE_SIZE-1] == raw_image[RAW_MODULE_SIZE-1]);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_TransformModuleAdjustMultipixel_rotate_negative","[RawToConvertedGeometry]") {
|
||||
std::vector<int32_t> raw_image(RAW_MODULE_SIZE);
|
||||
std::vector<int32_t> conv_image(CONVERTED_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < raw_image.size(); i++)
|
||||
raw_image[i] = i;
|
||||
|
||||
TransferModuleAdjustMultipixels(conv_image.data(), raw_image.data(),
|
||||
-1,
|
||||
INT32_MIN, INT32_MAX,
|
||||
-CONVERTED_MODULE_LINES,
|
||||
CONVERTED_MODULE_SIZE - 1);
|
||||
|
||||
CHECK(conv_image[0] == raw_image[RAW_MODULE_SIZE - 1]);
|
||||
CHECK(conv_image[1] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS]);
|
||||
CHECK(conv_image[5] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*5]);
|
||||
CHECK(conv_image[513] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*511]);
|
||||
|
||||
CHECK(conv_image[255] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*255]/2);
|
||||
CHECK(conv_image[256] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*255]/2);
|
||||
CHECK(conv_image[257] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*256]/2);
|
||||
CHECK(conv_image[258] == raw_image[RAW_MODULE_SIZE - 1 - RAW_MODULE_COLS*256]/2);
|
||||
|
||||
CHECK(conv_image[5 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 5]);
|
||||
CHECK(conv_image[255 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 255]/2);
|
||||
CHECK(conv_image[256 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 255]/2);
|
||||
CHECK(conv_image[257 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 256]/2);
|
||||
CHECK(conv_image[258 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 256]/2);
|
||||
CHECK(conv_image[1029 * CONVERTED_MODULE_LINES] == raw_image[RAW_MODULE_SIZE - 1 - 1023]);
|
||||
|
||||
CHECK(conv_image[CONVERTED_MODULE_SIZE-1] == raw_image[0]);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2,{4,4,6,6}, 0, 0, true);
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, 0, 0, true));
|
||||
x.DataStreams(4);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
REQUIRE(x.GetModulesNum(2) == 5);
|
||||
REQUIRE(x.GetPixelsNum() == CONVERTED_MODULE_SIZE * x.GetModulesNum());
|
||||
|
||||
auto input = (uint32_t *) calloc(x.GetModulesNum() * RAW_MODULE_SIZE, sizeof(uint32_t));
|
||||
@@ -404,10 +395,11 @@ TEST_CASE("RawToConvertedGeometry","[RawToConvertedGeometry]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_int64","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2,{4,4,6,6}, 0, 0, true);
|
||||
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, 0, 0, true));
|
||||
x.DataStreams(4);
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
|
||||
REQUIRE(x.GetModulesNum(2) == 5);
|
||||
REQUIRE(x.GetPixelsNum() == CONVERTED_MODULE_SIZE * x.GetModulesNum());
|
||||
|
||||
std::vector<uint32_t> input(x.GetModulesNum() * RAW_MODULE_SIZE);
|
||||
@@ -428,10 +420,10 @@ TEST_CASE("RawToConvertedGeometry_int64","[RawToConvertedGeometry]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_FP","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2,{4,4,6,6}, 0, 0, true);
|
||||
|
||||
DiffractionExperiment x(DetectorGeometry(20, 2, 0, 0, true));
|
||||
x.DataStreams(4);
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(2) == 6);
|
||||
REQUIRE(x.GetModulesNum(2) == 5);
|
||||
REQUIRE(x.GetPixelsNum() == CONVERTED_MODULE_SIZE * x.GetModulesNum());
|
||||
|
||||
std::vector<uint32_t> input(x.GetModulesNum() * RAW_MODULE_SIZE);
|
||||
@@ -452,7 +444,8 @@ TEST_CASE("RawToConvertedGeometry_FP","[RawToConvertedGeometry]") {
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedGeometry_Gaps","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment x(2,{4,4}, 8, 36, true);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36, true));
|
||||
x.DataStreams(2);
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
REQUIRE(x.GetModulesNum(1) == 4);
|
||||
@@ -481,27 +474,3 @@ TEST_CASE("RawToConvertedGeometry_Gaps","[RawToConvertedGeometry]") {
|
||||
free(output);
|
||||
free(input2);
|
||||
}
|
||||
|
||||
TEST_CASE("RawToConvertedCoordinate","[RawToConvertedGeometry]") {
|
||||
DiffractionExperiment experiment(2,{4,4}, 8, 36, true);
|
||||
|
||||
auto [x1,y1] = RawToConvertedCoordinate(experiment, 0, 0);
|
||||
REQUIRE(x1 == 0);
|
||||
REQUIRE(y1 == 2163);
|
||||
|
||||
auto [x2,y2] = RawToConvertedCoordinate(experiment, 1, RAW_MODULE_COLS-1);
|
||||
REQUIRE(x2 == 2067);
|
||||
REQUIRE(y2 == 2163);
|
||||
|
||||
auto [x3,y3] = RawToConvertedCoordinate(experiment, 6, RAW_MODULE_COLS* (RAW_MODULE_LINES-1));
|
||||
REQUIRE(x3 == 0);
|
||||
REQUIRE(y3 == 0);
|
||||
|
||||
auto [x4,y4] = RawToConvertedCoordinate(experiment, 3, RAW_MODULE_COLS*258 + 811);
|
||||
REQUIRE(x4 == 1030+8+811 + 3*2);
|
||||
REQUIRE(y4 == 2163-(514+36+258+2));
|
||||
|
||||
auto [x5,y5] = RawToConvertedCoordinate(experiment, 7, RAW_MODULE_SIZE-1);
|
||||
REQUIRE(x5 == 2067);
|
||||
REQUIRE(y5 == 0);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void naive_spot_finder(StrongPixelSet& set, const int16_t *buffer, const spot_pa
|
||||
}
|
||||
|
||||
TEST_CASE("SpotFinder_GPU", "[GPUImageAnalysis]") {
|
||||
DiffractionExperiment experiment(1, {1});
|
||||
DiffractionExperiment experiment(DetectorGeometry(1));
|
||||
experiment.Mode(DetectorMode::Raw);
|
||||
|
||||
const uint16_t nbx = 5;
|
||||
@@ -115,7 +115,7 @@ TEST_CASE("SpotFinder_GPU", "[GPUImageAnalysis]") {
|
||||
}
|
||||
|
||||
TEST_CASE("SpotFinder_GPU_Mask", "[GPUImageAnalysis]") {
|
||||
DiffractionExperiment experiment(1, {1});
|
||||
DiffractionExperiment experiment(DetectorGeometry(1));
|
||||
experiment.Mode(DetectorMode::Raw);
|
||||
|
||||
const uint16_t nbx = 5;
|
||||
|
||||
@@ -21,7 +21,7 @@ TEST_CASE("StreamWriterTest_ZMQ","[JFJochWriter]") {
|
||||
grpc::ServerContext grpc_context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
x.FilePrefix("subdir/JFJochWriterTest").NumTriggers(1).ImagesPerTrigger(5)
|
||||
.UseInternalPacketGenerator(true).Mode(DetectorMode::Raw).PedestalG0Frames(0);
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST_CASE("JFJochWriterServiceTest_ZMQ","[JFJochWriter]") {
|
||||
grpc::ServerContext grpc_context;
|
||||
JFJochProtoBuf::Empty empty;
|
||||
|
||||
DiffractionExperiment x(1, {2});
|
||||
DiffractionExperiment x(DetectorGeometry(2));
|
||||
x.FilePrefix("JFJochWriterTest").NumTriggers(1).ImagesPerTrigger(5)
|
||||
.UseInternalPacketGenerator(true)
|
||||
.Mode(DetectorMode::Raw).PedestalG0Frames(0);
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_CASE("ZMQImageCommTest_1Writer","[ZeroMQ]") {
|
||||
|
||||
ZMQContext context;
|
||||
Logger logger("test");
|
||||
DiffractionExperiment x(1,{1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).PhotonEnergy_keV(12.4)
|
||||
.ImagesPerTrigger(nframes);
|
||||
@@ -123,7 +123,7 @@ TEST_CASE("ZMQImageCommTest_2Writers","[ZeroMQ]") {
|
||||
|
||||
ZMQContext context;
|
||||
Logger logger("test");
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).PhotonEnergy_keV(12.4)
|
||||
.ImagesPerTrigger(nframes);
|
||||
@@ -209,7 +209,7 @@ TEST_CASE("ZMQImageCommTest_4Writers","[ZeroMQ]") {
|
||||
|
||||
ZMQContext context;
|
||||
Logger logger("test");
|
||||
DiffractionExperiment x(1, {1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).PhotonEnergy_keV(12.4)
|
||||
.ImagesPerTrigger(nframes);
|
||||
@@ -296,8 +296,8 @@ TEST_CASE("ZMQImageCommTest_4Writers","[ZeroMQ]") {
|
||||
|
||||
TEST_CASE("ZMQImagePuller_abort","[ZeroMQ]") {
|
||||
const size_t nframes = 256;
|
||||
std::string zmq_addr = "inproc://#1";
|
||||
DiffractionExperiment x, x_out(1, {1});
|
||||
|
||||
DiffractionExperiment x;
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).PhotonEnergy_keV(12.4)
|
||||
.ImagesPerTrigger(nframes);
|
||||
|
||||
@@ -13,7 +13,7 @@ TEST_CASE("ZMQPreviewPublisher","[ZSTD]") {
|
||||
socket.Connect("inproc://#5");
|
||||
socket.SubscribeAll();
|
||||
|
||||
DiffractionExperiment experiment(1,{1}, 0, 0, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(1, 1, 0, 0, false));
|
||||
|
||||
JFCalibration calibration(experiment);
|
||||
publisher.Start(experiment, calibration);
|
||||
@@ -54,7 +54,7 @@ TEST_CASE("ZMQPreviewPublisher_GetPreviewImage","[ZSTD]") {
|
||||
ZMQContext context;
|
||||
ZMQPreviewPublisher publisher(context, "inproc://#5");
|
||||
|
||||
DiffractionExperiment experiment(1,{1}, 0, 0, false);
|
||||
DiffractionExperiment experiment(DetectorGeometry(1, 1, 0, 0, false));
|
||||
|
||||
JFCalibration calibration(experiment);
|
||||
publisher.Start(experiment, calibration);
|
||||
|
||||
@@ -227,7 +227,7 @@ TEST_CASE("JFjochZstdCompressor_Frame_ones","[ZSTD]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochCompressor_JFJochDecompressor_ZSTD","[ZSTD]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.Compression(JFJochProtoBuf::BSHUF_ZSTD).Summation(34);
|
||||
|
||||
std::vector<int32_t> image(x.GetPixelsNum());
|
||||
@@ -249,7 +249,7 @@ TEST_CASE("JFJochCompressor_JFJochDecompressor_ZSTD","[ZSTD]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochCompressor_JFJochDecompressor_LZ4","[ZSTD]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.Compression(JFJochProtoBuf::BSHUF_LZ4).Summation(45);
|
||||
|
||||
std::vector<int32_t> image(x.GetPixelsNum());
|
||||
@@ -271,7 +271,7 @@ TEST_CASE("JFJochCompressor_JFJochDecompressor_LZ4","[ZSTD]") {
|
||||
}
|
||||
|
||||
TEST_CASE("JFJochDecompressor_None","[ZSTD]") {
|
||||
DiffractionExperiment x(2, {4,4}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.Compression(JFJochProtoBuf::NO_COMPRESSION).Summation(45);
|
||||
|
||||
std::vector<int32_t> image(x.GetPixelsNum());
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../../common/ZMQImagePusher.h"
|
||||
|
||||
TEST_CASE("JFJochReceiver_gRPC_server", "[gRPC]") {
|
||||
DiffractionExperiment x(2, {4});
|
||||
DiffractionExperiment x(DetectorGeometry(4, 2));
|
||||
|
||||
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
|
||||
AcquisitionDevice *test = new HLSSimulatedDevice(0, 64);
|
||||
|
||||
@@ -23,8 +23,7 @@ std::string CheckCompression(const DiffractionExperiment &x, size_t nimages, con
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
transformation.SetOutput(output.data() + i * x.GetMaxCompressedSize());
|
||||
for (int j = 0; j < x.GetModulesNum(); j++ ) {
|
||||
transformation.ProcessModule(image.data() + (j + i * x.GetModulesNum()) * RAW_MODULE_SIZE,
|
||||
i, j, 0);
|
||||
transformation.ProcessModule(image.data() + (j + i * x.GetModulesNum()) * RAW_MODULE_SIZE, j, 0);
|
||||
}
|
||||
compressed_size += transformation.PackStandardOutput();
|
||||
}
|
||||
@@ -50,8 +49,7 @@ std::string CheckDecompression(const DiffractionExperiment &x, size_t nimages, c
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
transformation.SetOutput(output[i].data());
|
||||
for (int j = 0; j < x.GetModulesNum(); j++ ) {
|
||||
transformation.ProcessModule(image.data() + (j + i * x.GetModulesNum()) * RAW_MODULE_SIZE,
|
||||
i, j, 0);
|
||||
transformation.ProcessModule(image.data() + (j + i * x.GetModulesNum()) * RAW_MODULE_SIZE, j, 0);
|
||||
}
|
||||
compressed_size[i] = transformation.PackStandardOutput();
|
||||
output[i].resize(compressed_size[i]);
|
||||
@@ -91,7 +89,7 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(2, {8}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
if ((file_space.GetDimensions()[1] == 2164) && (file_space.GetDimensions()[2] == 2068)) {
|
||||
std::cout << "JF4M with gaps detected (2068 x 2164)" << std::endl;
|
||||
|
||||
@@ -236,7 +236,7 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(2, {8}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
if ((file_space.GetDimensions()[1] == 2164) && (file_space.GetDimensions()[2] == 2068)) {
|
||||
logger.Info("JF4M with gaps detected (2068 x 2164)");
|
||||
|
||||
@@ -42,7 +42,7 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(2, {8}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.Summation(1);
|
||||
|
||||
// Set metadata for the compression_benchmark.h5 dataset
|
||||
@@ -89,8 +89,7 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i < nimages; i++) {
|
||||
transformation.SetOutput(output[i].data());
|
||||
for (int j = 0; j < 8; j++)
|
||||
transformation.ProcessModule(image + (i * x.GetModulesNum() + j) * RAW_MODULE_SIZE ,
|
||||
i, j, 0);
|
||||
transformation.ProcessModule(image + (i * x.GetModulesNum() + j) * RAW_MODULE_SIZE, j, 0);
|
||||
output_size[i] = transformation.PackStandardOutput();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
void test_pedestal(Logger &logger) {
|
||||
size_t nframes = 5000;
|
||||
DiffractionExperiment x(1,{1});
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
|
||||
std::vector<uint16_t> data(nframes * RAW_MODULE_SIZE);
|
||||
|
||||
@@ -53,7 +53,7 @@ template <class T> void test_conversion(Logger &logger) {
|
||||
int64_t nmodules = 8;
|
||||
int64_t ntries = 8;
|
||||
|
||||
DiffractionExperiment x(1,{nmodules});
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
std::vector<uint16_t> input(nframes * nmodules * RAW_MODULE_SIZE);
|
||||
std::vector<int16_t> output(nframes * nmodules * RAW_MODULE_SIZE);
|
||||
@@ -105,7 +105,7 @@ template <class T> void test_conversion_with_geom(Logger &logger) {
|
||||
int64_t nmodules = 8;
|
||||
int64_t ntries = 8;
|
||||
|
||||
DiffractionExperiment x(1,{nmodules});
|
||||
DiffractionExperiment x(DetectorGeometry(nmodules, 1, 0, 0, false));
|
||||
|
||||
std::vector<uint16_t> input(nframes * nmodules * RAW_MODULE_SIZE);
|
||||
std::vector<int16_t> output(nframes * nmodules * CONVERTED_MODULE_SIZE);
|
||||
@@ -140,7 +140,10 @@ template <class T> void test_conversion_with_geom(Logger &logger) {
|
||||
for (int i = 0; i < nframes; i++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
v[m].ConvertAdjustGeom(output.data() + (i * nmodules + m) * CONVERTED_MODULE_SIZE,
|
||||
input.data() + (i * nmodules + m) * RAW_MODULE_SIZE, 1);
|
||||
input.data() + (i * nmodules + m) * RAW_MODULE_SIZE,
|
||||
x.GetModuleSlowDirectionStep(m),
|
||||
x.GetModuleFastDirectionStep(m),
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ int main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
DiffractionExperiment x(2, {8}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
x.BeamX_pxl(1090).BeamY_pxl(1136).DetectorDistance_mm(75).PhotonEnergy_keV(WVL_1A_IN_KEV);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void GetGeometry(DiffractionExperiment &x, HDF5Object &master_file) {
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
hsize_t first, last;
|
||||
DiffractionExperiment x(2, {8}, 8, 36);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
|
||||
RegisterHDF5Filter();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
int64_t nimages_out = atoi(argv[2]);
|
||||
|
||||
DiffractionExperiment x(2, {8}, 8, 36, true);
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.Summation(1).ImagesPerTrigger(nimages_out).Mode(DetectorMode::Conversion);
|
||||
|
||||
HDF5File data(argv[1], false, false, false);
|
||||
@@ -81,8 +81,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
transformation.SetOutput(output[i].data());
|
||||
for (int j = 0; j < x.GetModulesNum(); j++)
|
||||
transformation.ProcessModule(image_tmp_raw.data() + j * RAW_MODULE_SIZE,
|
||||
i, j, 0);
|
||||
transformation.ProcessModule(image_tmp_raw.data() + j * RAW_MODULE_SIZE, j, 0);
|
||||
output_size[i] = transformation.PackStandardOutput();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user