* Enhancements for XFEL
* Enhancements for EIGER * Writer is more flexible and capable of handling DECTRIS data
This commit is contained in:
+310
-85
@@ -18,7 +18,14 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator", "[FPGA][Full]") {
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.SetInternalGeneratorFrame();
|
||||
|
||||
std::vector<uint16_t> ref_data(RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
ref_data[i] = i % 65536;
|
||||
|
||||
for (int m = 0; m < nmodules; m++)
|
||||
test.SetInternalGeneratorFrame(ref_data.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
@@ -54,7 +61,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_custom_frame", "[FPGA][Ful
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(nframes).PedestalG0Frames(0);
|
||||
|
||||
HLSSimulatedDevice test(0, 128);
|
||||
test.SetInternalGeneratorFrame(test_frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(test_frame.data() + RAW_MODULE_SIZE * m, m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -66,8 +74,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_custom_frame", "[FPGA][Ful
|
||||
for (int image = 0; image < nframes; image++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.timestamp == INT_PKT_GEN_EXPTTIME * image);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.bunchid == INT_PKT_GEN_BUNCHID + image);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.pulse_id == INT_PKT_GEN_BUNCHID + image);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.exptime == INT_PKT_GEN_EXPTTIME);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.detector_type == SLS_DETECTOR_TYPE_JUNGFRAU);
|
||||
|
||||
auto imageBuf = (uint16_t *) test.GetDeviceOutput(image, m)->pixels;
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++) {
|
||||
@@ -92,7 +101,7 @@ TEST_CASE("HLS_C_Simulation_check_raw", "[FPGA][Full]") {
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(5).NumTriggers(1);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.CreatePackets(x, 1, 5, 0, raw_frames.data(), true);
|
||||
test.CreateJFPackets(x, 1, 5, 0, raw_frames.data());
|
||||
test.CreateFinalPacket(x);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -180,20 +189,20 @@ TEST_CASE("HLS_C_Simulation_check_delay", "[FPGA][Full]") {
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.CreatePacketJF(x, 1, 0, 0, data, false);
|
||||
test.CreatePacketJF(x, 1, 0, 1, data, false);
|
||||
test.CreatePacketJF(x, 1, 0, 2, data, false);
|
||||
test.CreatePacketJF(x, 1, 0, 3, data, false);
|
||||
test.CreateJFPacket(x, 1, 0, 0, data);
|
||||
test.CreateJFPacket(x, 1, 0, 1, data);
|
||||
test.CreateJFPacket(x, 1, 0, 2, data);
|
||||
test.CreateJFPacket(x, 1, 0, 3, data);
|
||||
|
||||
test.CreatePacketJF(x, 2, 0, 0, data, false);
|
||||
test.CreatePacketJF(x, 2, 0, 1, data, false);
|
||||
test.CreatePacketJF(x, 2, 0, 2, data, false);
|
||||
test.CreatePacketJF(x, 2, 0, 3, data, false);
|
||||
test.CreateJFPacket(x, 2, 0, 0, data);
|
||||
test.CreateJFPacket(x, 2, 0, 1, data);
|
||||
test.CreateJFPacket(x, 2, 0, 2, data);
|
||||
test.CreateJFPacket(x, 2, 0, 3, data);
|
||||
|
||||
test.CreatePacketJF(x, 3, 0, 0, data, false);
|
||||
test.CreatePacketJF(x, 3, 0, 1, data, false);
|
||||
test.CreatePacketJF(x, 3, 0, 2, data, false);
|
||||
test.CreatePacketJF(x, 3, 0, 3, data, false);
|
||||
test.CreateJFPacket(x, 3, 0, 0, data);
|
||||
test.CreateJFPacket(x, 3, 0, 1, data);
|
||||
test.CreateJFPacket(x, 3, 0, 2, data);
|
||||
test.CreateJFPacket(x, 3, 0, 3, data);
|
||||
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
@@ -223,7 +232,7 @@ TEST_CASE("HLS_C_Simulation_check_lost_frame_raw", "[FPGA][Full]") {
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.CreatePacketJF(x, 1, 0, 0, data, false);
|
||||
test.CreateJFPacket(x, 1, 0, 0, data);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -255,7 +264,7 @@ TEST_CASE("HLS_C_Simulation_check_lost_frame_conversion", "[FPGA][Full]") {
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.CreatePacketJF(x, 1, 0, 0, data, false);
|
||||
test.CreateJFPacket(x, 1, 0, 0, data);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -290,28 +299,28 @@ TEST_CASE("HLS_C_Simulation_check_single_packet", "[FPGA][Full]") {
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1);
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.CreatePacketJF(x, 1, 0, 0, data, false);
|
||||
test.CreatePacketJF(x, 1, 64, 0, data, false);
|
||||
test.CreatePacketJF(x, 1, 0, 2, data, false);
|
||||
test.CreateJFPacket(x, 1, 0, 0, data);
|
||||
test.CreateJFPacket(x, 1, 64, 0, data);
|
||||
test.CreateJFPacket(x, 1, 0, 2, data);
|
||||
|
||||
test.CreatePacketJF(x, 1, 2, 3, data, false);
|
||||
test.CreatePacketJF(x, 1, 3, 3, data, false);
|
||||
test.CreateJFPacket(x, 1, 2, 3, data);
|
||||
test.CreateJFPacket(x, 1, 3, 3, data);
|
||||
|
||||
test.CreatePacketJF(x, 1, 1, 3, data, false);
|
||||
test.CreatePacketJF(x, 1, 0, 3, data, false);
|
||||
test.CreatePacketJF(x, 1, 64, 3, data, false);
|
||||
test.CreateJFPacket(x, 1, 1, 3, data);
|
||||
test.CreateJFPacket(x, 1, 0, 3, data);
|
||||
test.CreateJFPacket(x, 1, 64, 3, data);
|
||||
|
||||
test.CreatePacketJF(x, 1, 5, 0, data, false);
|
||||
test.CreatePacketJF(x, 1, 4, 0, data, false);
|
||||
test.CreateJFPacket(x, 1, 5, 0, data);
|
||||
test.CreateJFPacket(x, 1, 4, 0, data);
|
||||
|
||||
test.CreatePacketJF(x, 1, 67, 1, data, false);
|
||||
test.CreatePacketJF(x, 1, 66, 1, data, false);
|
||||
test.CreatePacketJF(x, 1, 68, 1, data, false);
|
||||
test.CreateJFPacket(x, 1, 67, 1, data);
|
||||
test.CreateJFPacket(x, 1, 66, 1, data);
|
||||
test.CreateJFPacket(x, 1, 68, 1, data);
|
||||
|
||||
test.CreatePacketJF(x, 3, 1, 0, data, false);
|
||||
test.CreatePacketJF(x, 2, 1, 0, data, false);
|
||||
test.CreateJFPacket(x, 3, 1, 0, data);
|
||||
test.CreateJFPacket(x, 2, 1, 0, data);
|
||||
|
||||
test.CreatePacketJF(x, 4, 1, 0, data, false);
|
||||
test.CreateJFPacket(x, 4, 1, 0, data);
|
||||
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
@@ -334,8 +343,7 @@ TEST_CASE("HLS_C_Simulation_check_single_packet", "[FPGA][Full]") {
|
||||
|
||||
REQUIRE(memcmp(test.GetDeviceOutput(0,1)->pixels + 67 * JUNGFRAU_PACKET_SIZE_BYTES/2, data, JUNGFRAU_PACKET_SIZE_BYTES) == 0);
|
||||
REQUIRE(memcmp(test.GetDeviceOutput(0,1)->pixels + 65 * JUNGFRAU_PACKET_SIZE_BYTES/2, wrong, JUNGFRAU_PACKET_SIZE_BYTES) == 0);
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 15 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
REQUIRE(test.GetDeviceOutput(0,0)->module_statistics.detector_type == SLS_DETECTOR_TYPE_JUNGFRAU);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") {
|
||||
@@ -372,7 +380,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -423,7 +431,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_HG0", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -453,7 +461,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_HG0", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -504,7 +512,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_fixedG1", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -554,7 +562,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_I32", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -608,7 +616,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_sum4", "[FPGA][Full]") {
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
for (int i = 0; i < nsummation; i++)
|
||||
test.CreatePackets(x, i+1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, i + 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -659,7 +667,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range_U16", "[FPGA][Full]") {
|
||||
c_in.GainCalibration(i) = gain_from_file;
|
||||
|
||||
test.InitializeCalibration(x, c_in);
|
||||
test.CreatePackets(x, 1, 1, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, 1, 0, data.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -708,7 +716,14 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG
|
||||
}
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.SetInternalGeneratorFrame();
|
||||
|
||||
std::vector<uint16_t> ref_data(RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
ref_data[i] = i % 65536;
|
||||
|
||||
for (int m = 0; m < nmodules; m++)
|
||||
test.SetInternalGeneratorFrame(ref_data.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.InitializeCalibration(x, c));
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -723,7 +738,6 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG
|
||||
REQUIRE(mean_error < 0.5);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range_adu_histo", "[FPGA][Full]") {
|
||||
double energy = 6.0;
|
||||
const uint16_t nmodules = 4;
|
||||
@@ -757,7 +771,14 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range_adu_his
|
||||
}
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.SetInternalGeneratorFrame();
|
||||
|
||||
std::vector<uint16_t> ref_data(RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
ref_data[i] = i % 65536;
|
||||
|
||||
for (int m = 0; m < nmodules; m++)
|
||||
test.SetInternalGeneratorFrame(ref_data.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.InitializeCalibration(x, c));
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -823,7 +844,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_apply_pixel_mask", "[FPGA]
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(test_frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(test_frame.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.InitializeCalibration(x, c));
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -880,7 +902,7 @@ TEST_CASE("HLS_C_Simulation_check_2_trigger_convert", "[FPGA][Full]") {
|
||||
REQUIRE_NOTHROW(test.InitializeCalibration(x, c));
|
||||
|
||||
// send some frames without trigger (to be ignored)
|
||||
test.CreatePackets(x, 1, 10, 0, raw_frames.data(), true);
|
||||
test.CreateJFPackets(x, 1, 10, 0, raw_frames.data());
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
@@ -930,7 +952,7 @@ TEST_CASE("HLS_C_Simulation_check_detect_last_frame", "[FPGA][Full]") {
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
test.CreatePacketJF(x, 15, 0, 0, data, true);
|
||||
test.CreateJFPacket(x, 15, 0, 0, data);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE(!test.Counters().IsAcquisitionFinished());
|
||||
|
||||
@@ -954,21 +976,21 @@ TEST_CASE("HLS_C_Simulation_check_wrong_packet_size", "[FPGA][Full]") {
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
// send some frames with wrong size or tuser=1
|
||||
test.CreatePacketJF(x, 1, 0, 0, data, true, 0);
|
||||
test.CreatePacketJF(x, 1, 1, 0, data, true, -1);
|
||||
test.CreatePacketJF(x, 1, 2, 0, data, true, 2);
|
||||
test.CreatePacketJF(x, 1, 3, 0, data, true, 0);
|
||||
test.CreatePacketJF(x, 1, 4, 0, data, true, -5);
|
||||
test.CreatePacketJF(x, 1, 5, 0, data, true, 0, 1);
|
||||
test.CreatePacketJF(x, 1, 6, 0, data, true, 0);
|
||||
test.CreatePacketJF(x, 1, 7, 0, data, true, 0);
|
||||
test.CreatePacketJF(x, 1, 8, 0, data, true, 7);
|
||||
test.CreatePacketJF(x, 1, 9, 0, data, true, 100);
|
||||
test.CreatePacketJF(x, 1, 10, 0, data, true, 2);
|
||||
test.CreatePacketJF(x, 1, 11, 0, data, true, 0);
|
||||
test.CreatePacketJF(x, 1, 12, 0, data, true, -80);
|
||||
test.CreatePacketJF(x, 1, 13, 0, data, true, 100);
|
||||
test.CreatePacketJF(x, 1, 118, 0, data, true, 0);
|
||||
test.CreateJFPacket(x, 1, 0, 0, data, 0);
|
||||
test.CreateJFPacket(x, 1, 1, 0, data, -1);
|
||||
test.CreateJFPacket(x, 1, 2, 0, data, 2);
|
||||
test.CreateJFPacket(x, 1, 3, 0, data, 0);
|
||||
test.CreateJFPacket(x, 1, 4, 0, data, -5);
|
||||
test.CreateJFPacket(x, 1, 5, 0, data, 0, 1);
|
||||
test.CreateJFPacket(x, 1, 6, 0, data, 0);
|
||||
test.CreateJFPacket(x, 1, 7, 0, data, 0);
|
||||
test.CreateJFPacket(x, 1, 8, 0, data, 7);
|
||||
test.CreateJFPacket(x, 1, 9, 0, data, 100);
|
||||
test.CreateJFPacket(x, 1, 10, 0, data, 2);
|
||||
test.CreateJFPacket(x, 1, 11, 0, data, 0);
|
||||
test.CreateJFPacket(x, 1, 12, 0, data, -80);
|
||||
test.CreateJFPacket(x, 1, 13, 0, data, 100);
|
||||
test.CreateJFPacket(x, 1, 118, 0, data, 0);
|
||||
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
@@ -1201,7 +1223,10 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_15_storage_cell_convert_G0
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
for (auto &i: data)
|
||||
i = 16000;
|
||||
REQUIRE_NOTHROW(test.SetInternalGeneratorFrameForAllModules(data));
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(data.data(), m);
|
||||
|
||||
|
||||
JFCalibration c(x);
|
||||
for (int i = 0; i < nstoragecells; i++) {
|
||||
@@ -1249,7 +1274,10 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_8_storage_cell_convert_G0"
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
for (auto &i: data)
|
||||
i = 16000;
|
||||
REQUIRE_NOTHROW(test.SetInternalGeneratorFrameForAllModules(data));
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(data.data(), m);
|
||||
|
||||
|
||||
JFCalibration c(x);
|
||||
for (int i = 0; i < nstoragecells; i++) {
|
||||
@@ -1297,7 +1325,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_16_storage_cell_convert_G0
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
for (auto &i: data)
|
||||
i = 16000;
|
||||
REQUIRE_NOTHROW(test.SetInternalGeneratorFrameForAllModules(data));
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(data.data(), m);
|
||||
|
||||
JFCalibration c(x);
|
||||
for (int i = 0; i < nstoragecells; i++) {
|
||||
@@ -1337,7 +1367,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_storage_cell_convert_G1",
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
for (auto &i: data)
|
||||
i = 16384 | 10;
|
||||
REQUIRE_NOTHROW(test.SetInternalGeneratorFrameForAllModules(data));
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(data.data(), m);
|
||||
|
||||
|
||||
JFCalibration c(x);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
@@ -1384,16 +1416,18 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration", "[FPGA][Full
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
frame[i] = 32754;
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
|
||||
std::vector<uint16_t> integration_map(nmodules * RAW_MODULE_SIZE, 54);
|
||||
for (int i = 0; i < RAW_MODULE_SIZE/2; i++) {
|
||||
integration_map[2 * i] = 0;
|
||||
integration_map[2 * i + 1] = FPGA_INTEGRATION_BIN_COUNT - 1;
|
||||
}
|
||||
|
||||
std::vector<float> weights(nmodules * RAW_MODULE_SIZE, 1.0);
|
||||
integration_map[RAW_MODULE_SIZE - 1] = FPGA_INTEGRATION_BIN_COUNT;
|
||||
test.InitializeIntegrationMap(x, integration_map);
|
||||
test.InitializeIntegrationMap(x, integration_map, weights);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -1461,7 +1495,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_count_threshol
|
||||
frame [ 89*1024 + 300] = 8;
|
||||
frame [300*1024 + 0] = 9;
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
@@ -1512,7 +1548,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_connectivity",
|
||||
frame [101*1024+200] = 12;
|
||||
frame [RAW_MODULE_SIZE - 1] = 20;
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
@@ -1593,7 +1631,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_min_pix_per_sp
|
||||
frame [101*1024+200] = 12;
|
||||
frame [RAW_MODULE_SIZE - 1] = 20;
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
@@ -1634,7 +1673,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_d_min_max", "[
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<float> d_map(RAW_MODULE_SIZE * nmodules, 0.0);
|
||||
std::vector<float> d_map(RAW_MODULE_SIZE, 0.0);
|
||||
d_map[0] = 2.5;
|
||||
d_map[1] = 4.0;
|
||||
d_map[2] = 1.0;
|
||||
@@ -1646,8 +1685,10 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_d_min_max", "[
|
||||
frame [ 2] = 12;
|
||||
frame [ 3] = 12;
|
||||
|
||||
test.InitializeSpotFinderResolutionMap(x, d_map);
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
test.InitializeSpotFinderResolutionMap(d_map.data(), 0);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
@@ -1701,7 +1742,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_snr_threshold"
|
||||
frame [ 89*1024 + 300] = 7;
|
||||
frame [300*1024 + 0] = 3;
|
||||
|
||||
test.SetInternalGeneratorFrameForAllModules(frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 10.0,
|
||||
.photon_count_threshold = 0,
|
||||
@@ -1746,7 +1789,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_32bit", "[FPGA][Full]") {
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(nframes).PedestalG0Frames(0).FPGAOutputMode(FPGAPixelOutput::Int32);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.SetInternalGeneratorFrame(test_frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(test_frame.data() + m * RAW_MODULE_SIZE, m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -1760,11 +1804,13 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_32bit", "[FPGA][Full]") {
|
||||
for (int image = 0; image < nframes; image++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.frame_number == image);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_count == 128);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_count == 256);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_mask[0] == UINT64_MAX);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_mask[1] == UINT64_MAX);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_mask[2] == UINT64_MAX);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.packet_mask[3] == UINT64_MAX);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.timestamp == INT_PKT_GEN_EXPTTIME * image);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.bunchid == INT_PKT_GEN_BUNCHID + image);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.pulse_id == INT_PKT_GEN_BUNCHID + image);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.exptime == INT_PKT_GEN_EXPTTIME);
|
||||
|
||||
auto imageBuf = (int32_t *) test.GetDeviceOutput(image, m)->pixels;
|
||||
@@ -1793,7 +1839,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_summation", "[FPGA][Full]"
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(nframes).PedestalG0Frames(0).Summation(nsummation);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.SetInternalGeneratorFrame(test_frame);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(test_frame.data() + m * RAW_MODULE_SIZE, m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -1806,7 +1853,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_summation", "[FPGA][Full]"
|
||||
for (int image = 0; image < nframes; image++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.timestamp == INT_PKT_GEN_EXPTTIME * image * nsummation);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.bunchid == INT_PKT_GEN_BUNCHID + image * nsummation);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.pulse_id == INT_PKT_GEN_BUNCHID + image * nsummation);
|
||||
REQUIRE(test.GetDeviceOutput(image, m)->module_statistics.exptime == INT_PKT_GEN_EXPTTIME);
|
||||
|
||||
auto imageBuf = (int32_t *) test.GetDeviceOutput(image, m)->pixels;
|
||||
@@ -1862,7 +1909,7 @@ TEST_CASE("HLS_C_Simulation_check_convert_pedestal", "[FPGA][Full]") {
|
||||
data[1 + 4096 * 3] = 0x8000 + 1; // gain_bit always 2
|
||||
data[2 + 4096 * 100] = 0xc000 + 1; // gain_bit always 3
|
||||
|
||||
test.CreatePackets(x, 1, NFRAMES_PEDESTAL_CHECK, 0, data.data(), false);
|
||||
test.CreateJFPackets(x, 1, NFRAMES_PEDESTAL_CHECK, 0, data.data());
|
||||
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
@@ -1916,7 +1963,9 @@ TEST_CASE("HLS_C_Simulation_count_sat_and_err_pixels", "[FPGA][Full]") {
|
||||
v[RAW_MODULE_COLS * 250 + 233] = 0xffff;
|
||||
v[0] = 0xffff;
|
||||
v[RAW_MODULE_SIZE-1] = 0xffff;
|
||||
test.SetInternalGeneratorFrameForAllModules(v);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(v.data(), m);
|
||||
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
@@ -1931,3 +1980,179 @@ TEST_CASE("HLS_C_Simulation_count_sat_and_err_pixels", "[FPGA][Full]") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_bunchid", "[FPGA][Full]") {
|
||||
|
||||
const uint64_t bunchid = 0xAAAAAAAA87345600;
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1);
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
test.CreateXfelBunchIDPacket(bunchid, 0);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE_NOTHROW(test.OutputStream().read());
|
||||
REQUIRE(test.OutputStream().size() == 0);
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 0);
|
||||
REQUIRE(test.GetDataCollectionStatus().current_pulseid == bunchid);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_raw_eiger", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frame(RAW_MODULE_SIZE);
|
||||
std::vector<uint16_t> raw_frame_eiger(RAW_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
raw_frame[i] = i % (UINT16_MAX - 11);
|
||||
|
||||
RawToEigerInput(raw_frame_eiger.data(), raw_frame.data());
|
||||
const uint16_t nmodules = 1;
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(1).NumTriggers(1);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
// bottom half module is reversed
|
||||
for (int i = 0; i < 64; i++)
|
||||
test.CreateEIGERPacket(x, 1, i, 0, 0, 0, raw_frame_eiger.data() + 2048 * (2 * i));
|
||||
for (int i = 0; i < 64; i++)
|
||||
test.CreateEIGERPacket(x, 1, i, 0, 1, 0, raw_frame_eiger.data() + 2048 * (1 + 2 * i));
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
test.CreateEIGERPacket(x, 1, i, 0, 0, 1, raw_frame_eiger.data() + 2048 * (128 + 2 * i));
|
||||
for (int i = 0; i < 64; i++)
|
||||
test.CreateEIGERPacket(x, 1, i, 0, 1, 1, raw_frame_eiger.data() + 2048 * (129 + 2 * i));
|
||||
|
||||
test.CreateFinalPacket(x);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.Counters().GetSlowestFrameNumber() == 0);
|
||||
|
||||
REQUIRE_NOTHROW(test.OutputStream().read());
|
||||
REQUIRE(test.OutputStream().size() == 0);
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 256 * 4096);
|
||||
|
||||
uint64_t diffs = 0;
|
||||
for (int j = 0; j < RAW_MODULE_SIZE; j++) {
|
||||
if (raw_frame[j] != ((uint16_t *) test.GetDeviceOutput(0, 0)->pixels)[j])
|
||||
diffs++;
|
||||
}
|
||||
|
||||
REQUIRE(diffs == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_eiger", "[FPGA][Full]") {
|
||||
std::vector<uint16_t> raw_frame(RAW_MODULE_SIZE), raw_frame_eiger(RAW_MODULE_SIZE);
|
||||
std::mt19937 g1(1387);
|
||||
std::uniform_int_distribution<uint16_t> dist(0, 65535);
|
||||
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
raw_frame[i] = dist(g1);
|
||||
|
||||
RawToEigerInput(raw_frame_eiger.data(), raw_frame.data());
|
||||
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment x(DetectorSetup(DetectorGeometry(nmodules), DetectorType::EIGER));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(raw_frame_eiger.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.OutputStream().size() == 1);
|
||||
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nmodules * 4 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
for (int image = 0; image < 4; image++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
auto imageBuf = (uint16_t *) test.GetDeviceOutput(image, m)->pixels;
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
REQUIRE(imageBuf[i] == raw_frame[i]);
|
||||
}
|
||||
}
|
||||
REQUIRE(test.GetExpectedDescriptorsPerModule() == DMA_DESCRIPTORS_PER_MODULE);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_roi_calc", "[FPGA][Full]") {
|
||||
const uint16_t nmodules = 4;
|
||||
const size_t nimages = 4;
|
||||
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(nimages).PedestalG0Frames(0);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<uint16_t> frame(RAW_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
frame[i] = 135;
|
||||
|
||||
frame[12+RAW_MODULE_COLS*3] = 83;
|
||||
frame[13+RAW_MODULE_COLS*3] = 95;
|
||||
frame[12+RAW_MODULE_COLS*4] = 13;
|
||||
frame[13+RAW_MODULE_COLS*4] = 125;
|
||||
|
||||
frame[812+RAW_MODULE_COLS*303] = 83;
|
||||
frame[813+RAW_MODULE_COLS*303] = 95;
|
||||
frame[812+RAW_MODULE_COLS*304] = 13;
|
||||
frame[813+RAW_MODULE_COLS*304] = 125;
|
||||
|
||||
std::vector<uint16_t> roi_map(RAW_MODULE_SIZE, UINT16_MAX);
|
||||
roi_map[12+RAW_MODULE_COLS*3] = 0;
|
||||
roi_map[13+RAW_MODULE_COLS*3] = 0;
|
||||
roi_map[12+RAW_MODULE_COLS*4] = 0;
|
||||
roi_map[13+RAW_MODULE_COLS*4] = 0;
|
||||
|
||||
roi_map[812+RAW_MODULE_COLS*303] = 1;
|
||||
roi_map[813+RAW_MODULE_COLS*303] = 1;
|
||||
roi_map[812+RAW_MODULE_COLS*304] = 1;
|
||||
roi_map[813+RAW_MODULE_COLS*304] = 1;
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++) {
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
test.InitializeROIMap(roi_map.data(), m);
|
||||
}
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.OutputStream().size() == 1);
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nimages * nmodules * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
auto imageBuf = test.GetDeviceOutput(0, 0)->pixels;
|
||||
REQUIRE(memcmp(imageBuf, frame.data(), RAW_MODULE_SIZE * sizeof(uint16_t)) == 0);
|
||||
|
||||
for (int i = 0; i < x.GetImageNum(); i++) {
|
||||
for (int m = 0; m < x.GetModulesNum(); m++) {
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum == 83 + 95 + 13 + 125);
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum2 == 83 * 83 + 95 * 95 + 13 * 13 + 125 * 125);
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_x_weighted == Approx(83 * 12 + 95 * 13 + 13 * 12 + 125 * 13));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].sum_y_weighted == Approx(83 * 3 + 95 * 3 + 13 * 4 + 125 * 4));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].max_value == 125);
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].good_pixels == 4);
|
||||
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_x_weighted == Approx(83 * (812+6) + 95 * (813+6) + 13 * (812+6) + 125 * (813+6)));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_y_weighted == Approx(83 * (303+2) + 95 * (303+2) + 13 * (304+2) + 125 * (304+2)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user