ADU histogram: Save

This commit is contained in:
leonarski_f committed 2023-10-21 19:51:25 +02:00
1 parent 53f4f4acf9
commit 99741ae5c5
13 files changed
+125 -41

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
// Copyright (2019-2023) Paul Scherrer Institute
#include "ADUHistogram.h"
ADUHistogram::ADUHistogram() : histogram(ADU_HISTO_BIN_COUNT) {
}
void ADUHistogram::Add(const DeviceOutput &output) {
std::unique_lock<std::mutex> ul(m);
for (int i = 0; i < ADU_HISTO_BIN_COUNT; i++)
histogram[i] += output.adu_histogram[i];
}
const std::vector<uint64_t> &ADUHistogram::GetHistogram() const {
return histogram;
}
void ADUHistogram::GetPlot(JFJochProtoBuf::Plot &plot) const {
std::unique_lock<std::mutex> ul(m);
for (int i = 0; i < ADU_HISTO_BIN_COUNT; i++) {
plot.add_x(ADU_HISTO_BIN_WIDTH * i + ADU_HISTO_BIN_WIDTH / 2);
plot.add_y(histogram[i]);
}
}
+20
View File
@@ -0,0 +1,20 @@
// Copyright (2019-2023) Paul Scherrer Institute
#ifndef JUNGFRAUJOCH_ADUHISTOGRAM_H
#define JUNGFRAUJOCH_ADUHISTOGRAM_H
#include <mutex>
#include <jfjoch.pb.h>
#include "../receiver/AcquisitionDevice.h"
class ADUHistogram {
mutable std::mutex m;
std::vector<uint64_t> histogram;
public:
explicit ADUHistogram();
void Add(const DeviceOutput &output);
const std::vector<uint64_t>& GetHistogram() const;
void GetPlot(JFJochProtoBuf::Plot &plot) const;
};
#endif //JUNGFRAUJOCH_ADUHISTOGRAM_H
+3 -1
View File
@@ -48,7 +48,9 @@ ADD_LIBRARY( CommonFunctions STATIC
CUDAWrapper.cpp
CUDAWrapper.h
NUMAHWPolicy.cpp
NUMAHWPolicy.h)
NUMAHWPolicy.h
ADUHistogram.cpp
ADUHistogram.h)
TARGET_LINK_LIBRARIES(CommonFunctions Compression FrameSerialize libzmq JFCalibration JFJochProtoBuf -lrt)
+2
View File
@@ -48,6 +48,8 @@ struct DataMessage {
std::string series_unique_id;
uint64_t series_id;
std::vector<uint64_t> adu_histogram;
};
struct GoniometerAxis {
+3
View File
@@ -8,6 +8,7 @@
constexpr const CborTag TagMultiDimArray = 40;
constexpr const CborTag TagDECTRISCompression = 56500;
// rfc8746
constexpr const CborTag TagFloatLE = 0b01010101;
constexpr const CborTag TagUnsignedInt8Bit = 0b01000000;
constexpr const CborTag TagSignedInt8Bit = 0b01001000;
@@ -18,4 +19,6 @@ constexpr const CborTag TagSignedInt16BitLE = 0b01001101;
constexpr const CborTag TagUnsignedInt32BitLE = 0b01000110;
constexpr const CborTag TagSignedInt32BitLE = 0b01001110;
constexpr const CborTag TagUnsignedInt64BitLE = 0b01000111;
#endif //JUNGFRAUJOCH_CBORUTIL_H
+28 -20
View File
@@ -108,26 +108,6 @@ inline std::pair<uint64_t, uint64_t> GetRational(CborValue &value) {
return ret;
}
inline void GetCBORFloatArray(CborValue &value, std::vector<float> &v) {
if (GetCBORTag(value) != TagFloatLE)
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
auto len = GetCBORArrayLen(value);
if (len > 0) {
CborValue array_value;
v.resize(len);
cborErr(cbor_value_enter_container(&value, &array_value));
for (int i = 0; i < len; i++)
v[i] = GetCBORFloat(array_value);
cborErr(cbor_value_leave_container(&value, &array_value));
} else
cbor_value_advance(&value);
}
inline std::pair<uint64_t, uint64_t> GetCBORDimension2DArray(CborValue &value) {
std::pair<uint64_t, uint64_t> ret;
@@ -179,6 +159,32 @@ inline std::pair<const uint8_t *, size_t> GetCBORByteString(CborValue &value) {
return {ptr, len};
}
inline void GetCBORFloatArray(CborValue &value, std::vector<float> &v) {
if (GetCBORTag(value) != TagFloatLE)
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
auto [ptr, len] = GetCBORByteString(value);
if (len % sizeof(float))
throw JFJochException(JFJochExceptionCategory::CBORError, "Size mismatch");
v.resize(len / sizeof(float));
memcpy(v.data(), ptr, len);
}
inline void GetCBORUInt64Array(CborValue &value, std::vector<uint64_t> &v) {
if (GetCBORTag(value) != TagUnsignedInt64BitLE)
throw JFJochException(JFJochExceptionCategory::CBORError, "Incorrect array type tag");
auto [ptr, len] = GetCBORByteString(value);
if (len % sizeof(uint64_t))
throw JFJochException(JFJochExceptionCategory::CBORError, "Size mismatch");
v.resize(len / sizeof(uint64_t));
memcpy(v.data(), ptr, len);
}
inline void GetCBORTypedArray(CBORImage &v, CborValue &value) {
CborTag tag = GetCBORTag(value);
@@ -401,6 +407,8 @@ void JFJochFrameDeserializer::ProcessImageMessageUserDataElement(CborValue &valu
data_message.storage_cell = GetCBORUInt(map_value) & UINT32_MAX;
else if (key == "bunch_id")
data_message.bunch_id = GetCBORUInt(map_value);
else if (key == "adu_histogram")
GetCBORUInt64Array(map_value, data_message.adu_histogram);
else
cbor_value_advance(&map_value);
}
+9 -7
View File
@@ -126,16 +126,16 @@ inline void CBOR_ENC_2D_TYPED_ARRAY(CborEncoder &encoder, const CBORImage& image
}
inline void CBOR_ENC(CborEncoder &encoder, const char* key, const std::vector<float>& v) {
CborEncoder arrayEncoder;
cborErr(cbor_encode_text_stringz(&encoder, key));
cborErr(cbor_encode_tag(&encoder, TagFloatLE));
cborErr(cbor_encoder_create_array(&encoder, &arrayEncoder, v.size()));
cborErr(cbor_encode_byte_string(&encoder, (uint8_t *) v.data(), v.size() * sizeof(float)));
}
for (const auto &i : v)
cborErr(cbor_encode_float(&arrayEncoder, i));
cborErr(cbor_encoder_close_container(&encoder, &arrayEncoder));
inline void CBOR_ENC(CborEncoder &encoder, const char* key, const std::vector<uint64_t>& v) {
cborErr(cbor_encode_text_stringz(&encoder, key));
cborErr(cbor_encode_tag(&encoder, TagUnsignedInt64BitLE));
cborErr(cbor_encode_byte_string(&encoder, (uint8_t *) v.data(), v.size() * sizeof(uint64_t)));
}
inline void CBOR_ENC_RATIONAL(CborEncoder &encoder, const char* key, uint64_t numerator, uint64_t denominator) {
@@ -422,7 +422,7 @@ void JFJochFrameSerializer::SerializeImage(const DataMessage& message) {
message.timestamp_base);
cborErr(cbor_encode_text_stringz(&mapEncoder, "user_data"));
cborErr(cbor_encoder_create_map(&mapEncoder, &userDataMapEncoder, 10));
cborErr(cbor_encoder_create_map(&mapEncoder, &userDataMapEncoder, 11));
CBOR_ENC(userDataMapEncoder, "magic_number", user_data_magic_number);
CBOR_ENC(userDataMapEncoder, "spots", message.spots);
@@ -434,6 +434,8 @@ void JFJochFrameSerializer::SerializeImage(const DataMessage& message) {
CBOR_ENC(userDataMapEncoder, "receiver_available_send_buffers", message.receiver_available_send_buffers);
CBOR_ENC(userDataMapEncoder, "receiver_aq_dev_delay", message.receiver_aq_dev_delay);
CBOR_ENC(userDataMapEncoder, "storage_cell", (uint64_t) message.storage_cell);
CBOR_ENC(userDataMapEncoder, "adu_histogram", message.adu_histogram);
cborErr(cbor_encoder_close_container(&mapEncoder, &userDataMapEncoder));
CBOR_ENC(mapEncoder, "data", message.image);
+1
View File
@@ -285,6 +285,7 @@ enum PlotType {
SPOT_COUNT = 2;
INDEXING_RATE = 3;
INDEXING_RATE_PER_FILE = 4;
ADU_HISTOGRAM = 5;
}
message PlotRequest {
+10 -10
View File
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cjfjoch.proto\x12\x0eJFJochProtoBuf\"\x07\n\x05\x45mpty\"W\n\x08UnitCell\x12\t\n\x01\x61\x18\x01 \x01(\x02\x12\t\n\x01\x62\x18\x02 \x01(\x02\x12\t\n\x01\x63\x18\x03 \x01(\x02\x12\r\n\x05\x61lpha\x18\x04 \x01(\x02\x12\x0c\n\x04\x62\x65ta\x18\x05 \x01(\x02\x12\r\n\x05gamma\x18\x06 \x01(\x02\")\n\x06Vector\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\x12\t\n\x01z\x18\x03 \x01(\x02\"|\n\x10RotationSettings\x12\x17\n\x0fstart_angle_deg\x18\x01 \x01(\x02\x12 \n\x18\x61ngle_incr_per_image_deg\x18\x02 \x01(\x02\x12-\n\rrotation_axis\x18\x03 \x01(\x0b\x32\x16.JFJochProtoBuf.Vector\"\x1c\n\x04Plot\x12\t\n\x01x\x18\x01 \x03(\x02\x12\t\n\x01y\x18\x02 \x03(\x02\"E\n\x0cROIRectangle\x12\n\n\x02x0\x18\x01 \x01(\x05\x12\n\n\x02y0\x18\x02 \x01(\x05\x12\r\n\x05width\x18\x03 \x01(\x05\x12\x0e\n\x06height\x18\x04 \x01(\x05\"\xf2\x04\n\x0f\x44\x61tasetSettings\x12\x1a\n\x12images_per_trigger\x18\x01 \x01(\x03\x12\x10\n\x08ntrigger\x18\x02 \x01(\x03\x12\x13\n\tsummation\x18\x03 \x01(\x03H\x00\x12\x17\n\rimage_time_us\x18\x04 \x01(\x03H\x00\x12\x12\n\nbeam_x_pxl\x18\x05 \x01(\x02\x12\x12\n\nbeam_y_pxl\x18\x06 \x01(\x02\x12\x1c\n\x14\x64\x65tector_distance_mm\x18\x07 \x01(\x02\x12\x19\n\x11photon_energy_keV\x18\x08 \x01(\x02\x12\x13\n\x0b\x66ile_prefix\x18\t \x01(\t\x12\x17\n\x0f\x64\x61ta_file_count\x18\n \x01(\x03\x12\x30\n\x0b\x63ompression\x18\x0b \x01(\x0e\x32\x1b.JFJochProtoBuf.Compression\x12\x13\n\x0bsample_name\x18\x0c \x01(\t\x12\x30\n\tunit_cell\x18\r \x01(\x0b\x32\x18.JFJochProtoBuf.UnitCellH\x01\x88\x01\x01\x12\x1a\n\x12space_group_number\x18\x0e \x01(\x03\x12\x12\n\nbinning2x2\x18\x11 \x01(\x08\x12 \n\x18rad_int_solid_angle_corr\x18\x12 \x01(\x08\x12!\n\x19rad_int_polarization_corr\x18\x13 \x01(\x08\x12#\n\x1brad_int_polarization_factor\x18\x14 \x01(\x02\x12\x18\n\x10save_calibration\x18\x15 \x01(\x08\x12/\n\tuser_mask\x18\x16 \x03(\x0b\x32\x1c.JFJochProtoBuf.ROIRectangleB\x08\n\x06timingB\x0c\n\n_unit_cell\"\xb5\x03\n\x10\x44\x65tectorSettings\x12\x15\n\rframe_time_us\x18\x01 \x01(\x03\x12\x1a\n\rcount_time_us\x18\x02 \x01(\x03H\x00\x88\x01\x01\x12\x1a\n\x12storage_cell_count\x18\x03 \x01(\x03\x12%\n\x1duse_internal_packet_generator\x18\x04 \x01(\x08\x12\x18\n\x10\x63ollect_raw_data\x18\x05 \x01(\x08\x12\x1f\n\x12pedestal_g0_frames\x18\x06 \x01(\x03H\x01\x88\x01\x01\x12\x1f\n\x12pedestal_g1_frames\x18\x07 \x01(\x03H\x02\x88\x01\x01\x12\x1f\n\x12pedestal_g2_frames\x18\x08 \x01(\x03H\x03\x88\x01\x01\x12\x19\n\x11\x63onversion_on_cpu\x18\t \x01(\x08\x12\"\n\x15storage_cell_delay_ns\x18\n \x01(\x03H\x04\x88\x01\x01\x42\x10\n\x0e_count_time_usB\x15\n\x13_pedestal_g0_framesB\x15\n\x13_pedestal_g1_framesB\x15\n\x13_pedestal_g2_framesB\x18\n\x16_storage_cell_delay_ns\"b\n\x16\x44\x65tectorModuleGeometry\x12\x0e\n\x06pixel0\x18\x01 \x01(\x03\x12\x1b\n\x13\x66\x61st_direction_step\x18\x02 \x01(\x03\x12\x1b\n\x13slow_direction_step\x18\x03 \x01(\x03\"z\n\x10\x44\x65tectorGeometry\x12\x11\n\twidth_pxl\x18\x01 \x01(\x03\x12\x12\n\nheight_pxl\x18\x02 \x01(\x03\x12?\n\x0fmodule_geometry\x18\x03 \x03(\x0b\x32&.JFJochProtoBuf.DetectorModuleGeometry\"\xde\x01\n\x08\x44\x65tector\x12\x10\n\x08nmodules\x18\x01 \x01(\x03\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x15\n\rpixel_size_mm\x18\x03 \x01(\x02\x12\x17\n\x0fmodule_hostname\x18\x04 \x03(\t\x12\x32\n\x08geometry\x18\x05 \x01(\x0b\x32 .JFJochProtoBuf.DetectorGeometry\x12*\n\x04type\x18\x06 \x01(\x0e\x32\x1c.JFJochProtoBuf.DetectorType\x12\x1b\n\x13udp_interface_count\x18\x07 \x01(\x03\"\xe2\x06\n\x10InternalSettings\x12\"\n\x1a\x66rame_time_pedestalG1G2_us\x18\x01 \x01(\x03\x12\x15\n\rframe_time_us\x18\x03 \x01(\x03\x12\x15\n\rcount_time_us\x18\x04 \x01(\x03\x12*\n\x08\x64\x65tector\x18\x05 \x01(\x0b\x32\x18.JFJochProtoBuf.Detector\x12\x14\n\x0cndatastreams\x18\x06 \x01(\x03\x12&\n\x1einternal_fpga_packet_generator\x18\t \x01(\x08\x12\x15\n\rstorage_cells\x18\n \x01(\x03\x12\x1a\n\x12storage_cell_start\x18\x0b \x01(\x03\x12\x1d\n\x15storage_cell_delay_ns\x18\' \x01(\x03\x12\x1a\n\x12pedestal_g0_frames\x18\x0c \x01(\x03\x12\x1a\n\x12pedestal_g1_frames\x18\r \x01(\x03\x12\x1a\n\x12pedestal_g2_frames\x18\x0e \x01(\x03\x12\x19\n\x11preview_period_us\x18\x0f \x01(\x03\x12\x1e\n\x16spot_finding_period_us\x18\x10 \x01(\x03\x12*\n\x04mode\x18\x13 \x01(\x0e\x32\x1c.JFJochProtoBuf.DetectorMode\x12\x19\n\x11mask_module_edges\x18\x14 \x01(\x08\x12\x17\n\x0fmask_chip_edges\x18\x15 \x01(\x08\x12\x16\n\x0eipv4_base_addr\x18\x16 \x01(\x03\x12\r\n\x05low_q\x18\x1a \x01(\x02\x12\x0e\n\x06high_q\x18\x1b \x01(\x02\x12\x11\n\tq_spacing\x18\x1c \x01(\x02\x12\x10\n\x08git_sha1\x18\x1d \x01(\t\x12\x10\n\x08git_date\x18\x1e \x01(\t\x12\x19\n\x11\x63onversion_on_cpu\x18\x1f \x01(\x08\x12\x13\n\x0bsource_name\x18 \x01(\t\x12\x19\n\x11source_name_short\x18! \x01(\t\x12\x17\n\x0finstrument_name\x18\" \x01(\t\x12\x1d\n\x15instrument_name_short\x18# \x01(\t\x12\x33\n\rroi_rectangle\x18$ \x03(\x0b\x32\x1c.JFJochProtoBuf.ROILine truncated
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cjfjoch.proto\x12\x0eJFJochProtoBuf\"\x07\n\x05\x45mpty\"W\n\x08UnitCell\x12\t\n\x01\x61\x18\x01 \x01(\x02\x12\t\n\x01\x62\x18\x02 \x01(\x02\x12\t\n\x01\x63\x18\x03 \x01(\x02\x12\r\n\x05\x61lpha\x18\x04 \x01(\x02\x12\x0c\n\x04\x62\x65ta\x18\x05 \x01(\x02\x12\r\n\x05gamma\x18\x06 \x01(\x02\")\n\x06Vector\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\x12\t\n\x01z\x18\x03 \x01(\x02\"|\n\x10RotationSettings\x12\x17\n\x0fstart_angle_deg\x18\x01 \x01(\x02\x12 \n\x18\x61ngle_incr_per_image_deg\x18\x02 \x01(\x02\x12-\n\rrotation_axis\x18\x03 \x01(\x0b\x32\x16.JFJochProtoBuf.Vector\"\x1c\n\x04Plot\x12\t\n\x01x\x18\x01 \x03(\x02\x12\t\n\x01y\x18\x02 \x03(\x02\"E\n\x0cROIRectangle\x12\n\n\x02x0\x18\x01 \x01(\x05\x12\n\n\x02y0\x18\x02 \x01(\x05\x12\r\n\x05width\x18\x03 \x01(\x05\x12\x0e\n\x06height\x18\x04 \x01(\x05\"\xf2\x04\n\x0f\x44\x61tasetSettings\x12\x1a\n\x12images_per_trigger\x18\x01 \x01(\x03\x12\x10\n\x08ntrigger\x18\x02 \x01(\x03\x12\x13\n\tsummation\x18\x03 \x01(\x03H\x00\x12\x17\n\rimage_time_us\x18\x04 \x01(\x03H\x00\x12\x12\n\nbeam_x_pxl\x18\x05 \x01(\x02\x12\x12\n\nbeam_y_pxl\x18\x06 \x01(\x02\x12\x1c\n\x14\x64\x65tector_distance_mm\x18\x07 \x01(\x02\x12\x19\n\x11photon_energy_keV\x18\x08 \x01(\x02\x12\x13\n\x0b\x66ile_prefix\x18\t \x01(\t\x12\x17\n\x0f\x64\x61ta_file_count\x18\n \x01(\x03\x12\x30\n\x0b\x63ompression\x18\x0b \x01(\x0e\x32\x1b.JFJochProtoBuf.Compression\x12\x13\n\x0bsample_name\x18\x0c \x01(\t\x12\x30\n\tunit_cell\x18\r \x01(\x0b\x32\x18.JFJochProtoBuf.UnitCellH\x01\x88\x01\x01\x12\x1a\n\x12space_group_number\x18\x0e \x01(\x03\x12\x12\n\nbinning2x2\x18\x11 \x01(\x08\x12 \n\x18rad_int_solid_angle_corr\x18\x12 \x01(\x08\x12!\n\x19rad_int_polarization_corr\x18\x13 \x01(\x08\x12#\n\x1brad_int_polarization_factor\x18\x14 \x01(\x02\x12\x18\n\x10save_calibration\x18\x15 \x01(\x08\x12/\n\tuser_mask\x18\x16 \x03(\x0b\x32\x1c.JFJochProtoBuf.ROIRectangleB\x08\n\x06timingB\x0c\n\n_unit_cell\"\xb5\x03\n\x10\x44\x65tectorSettings\x12\x15\n\rframe_time_us\x18\x01 \x01(\x03\x12\x1a\n\rcount_time_us\x18\x02 \x01(\x03H\x00\x88\x01\x01\x12\x1a\n\x12storage_cell_count\x18\x03 \x01(\x03\x12%\n\x1duse_internal_packet_generator\x18\x04 \x01(\x08\x12\x18\n\x10\x63ollect_raw_data\x18\x05 \x01(\x08\x12\x1f\n\x12pedestal_g0_frames\x18\x06 \x01(\x03H\x01\x88\x01\x01\x12\x1f\n\x12pedestal_g1_frames\x18\x07 \x01(\x03H\x02\x88\x01\x01\x12\x1f\n\x12pedestal_g2_frames\x18\x08 \x01(\x03H\x03\x88\x01\x01\x12\x19\n\x11\x63onversion_on_cpu\x18\t \x01(\x08\x12\"\n\x15storage_cell_delay_ns\x18\n \x01(\x03H\x04\x88\x01\x01\x42\x10\n\x0e_count_time_usB\x15\n\x13_pedestal_g0_framesB\x15\n\x13_pedestal_g1_framesB\x15\n\x13_pedestal_g2_framesB\x18\n\x16_storage_cell_delay_ns\"b\n\x16\x44\x65tectorModuleGeometry\x12\x0e\n\x06pixel0\x18\x01 \x01(\x03\x12\x1b\n\x13\x66\x61st_direction_step\x18\x02 \x01(\x03\x12\x1b\n\x13slow_direction_step\x18\x03 \x01(\x03\"z\n\x10\x44\x65tectorGeometry\x12\x11\n\twidth_pxl\x18\x01 \x01(\x03\x12\x12\n\nheight_pxl\x18\x02 \x01(\x03\x12?\n\x0fmodule_geometry\x18\x03 \x03(\x0b\x32&.JFJochProtoBuf.DetectorModuleGeometry\"\xde\x01\n\x08\x44\x65tector\x12\x10\n\x08nmodules\x18\x01 \x01(\x03\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x15\n\rpixel_size_mm\x18\x03 \x01(\x02\x12\x17\n\x0fmodule_hostname\x18\x04 \x03(\t\x12\x32\n\x08geometry\x18\x05 \x01(\x0b\x32 .JFJochProtoBuf.DetectorGeometry\x12*\n\x04type\x18\x06 \x01(\x0e\x32\x1c.JFJochProtoBuf.DetectorType\x12\x1b\n\x13udp_interface_count\x18\x07 \x01(\x03\"\xe2\x06\n\x10InternalSettings\x12\"\n\x1a\x66rame_time_pedestalG1G2_us\x18\x01 \x01(\x03\x12\x15\n\rframe_time_us\x18\x03 \x01(\x03\x12\x15\n\rcount_time_us\x18\x04 \x01(\x03\x12*\n\x08\x64\x65tector\x18\x05 \x01(\x0b\x32\x18.JFJochProtoBuf.Detector\x12\x14\n\x0cndatastreams\x18\x06 \x01(\x03\x12&\n\x1einternal_fpga_packet_generator\x18\t \x01(\x08\x12\x15\n\rstorage_cells\x18\n \x01(\x03\x12\x1a\n\x12storage_cell_start\x18\x0b \x01(\x03\x12\x1d\n\x15storage_cell_delay_ns\x18\' \x01(\x03\x12\x1a\n\x12pedestal_g0_frames\x18\x0c \x01(\x03\x12\x1a\n\x12pedestal_g1_frames\x18\r \x01(\x03\x12\x1a\n\x12pedestal_g2_frames\x18\x0e \x01(\x03\x12\x19\n\x11preview_period_us\x18\x0f \x01(\x03\x12\x1e\n\x16spot_finding_period_us\x18\x10 \x01(\x03\x12*\n\x04mode\x18\x13 \x01(\x0e\x32\x1c.JFJochProtoBuf.DetectorMode\x12\x19\n\x11mask_module_edges\x18\x14 \x01(\x08\x12\x17\n\x0fmask_chip_edges\x18\x15 \x01(\x08\x12\x16\n\x0eipv4_base_addr\x18\x16 \x01(\x03\x12\r\n\x05low_q\x18\x1a \x01(\x02\x12\x0e\n\x06high_q\x18\x1b \x01(\x02\x12\x11\n\tq_spacing\x18\x1c \x01(\x02\x12\x10\n\x08git_sha1\x18\x1d \x01(\t\x12\x10\n\x08git_date\x18\x1e \x01(\t\x12\x19\n\x11\x63onversion_on_cpu\x18\x1f \x01(\x08\x12\x13\n\x0bsource_name\x18 \x01(\t\x12\x19\n\x11source_name_short\x18! \x01(\t\x12\x17\n\x0finstrument_name\x18\" \x01(\t\x12\x1d\n\x15instrument_name_short\x18# \x01(\t\x12\x33\n\rroi_rectangle\x18$ \x03(\x0b\x32\x1c.JFJochProtoBuf.ROILine truncated
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'jfjoch_pb2', globals())
@@ -31,7 +31,7 @@ if _descriptor._USE_C_DESCRIPTORS == False:
_STATE._serialized_start=9365
_STATE._serialized_end=9459
_PLOTTYPE._serialized_start=9461
_PLOTTYPE._serialized_end=9565
_PLOTTYPE._serialized_end=9584
_EMPTY._serialized_start=32
_EMPTY._serialized_end=39
_UNITCELL._serialized_start=41
@@ -128,12 +128,12 @@ if _descriptor._USE_C_DESCRIPTORS == False:
_DETECTORLIST._serialized_end=9055
_DETECTORSELECTION._serialized_start=9057
_DETECTORSELECTION._serialized_end=9088
_GRPC_JFJOCHRECEIVER._serialized_start=9568
_GRPC_JFJOCHRECEIVER._serialized_end=10335
_GRPC_JFJOCHWRITER._serialized_start=10338
_GRPC_JFJOCHWRITER._serialized_end=10540
_GRPC_JFJOCHDETECTOR._serialized_start=10543
_GRPC_JFJOCHDETECTOR._serialized_end=10929
_GRPC_JFJOCHBROKER._serialized_start=10932
_GRPC_JFJOCHBROKER._serialized_end=12621
_GRPC_JFJOCHRECEIVER._serialized_start=9587
_GRPC_JFJOCHRECEIVER._serialized_end=10354
_GRPC_JFJOCHWRITER._serialized_start=10357
_GRPC_JFJOCHWRITER._serialized_end=10559
_GRPC_JFJOCHDETECTOR._serialized_start=10562
_GRPC_JFJOCHDETECTOR._serialized_end=10948
_GRPC_JFJOCHBROKER._serialized_start=10951
_GRPC_JFJOCHBROKER._serialized_end=12640
# @@protoc_insertion_point(module_scope)
+14 -2
View File
@@ -8,6 +8,7 @@
#include "../jungfrau/JFPedestalCalc.h"
#include "../image_analysis/IndexerWrapper.h"
#include "../common/DiffractionGeometry.h"
#include "../common/ADUHistogram.h"
inline std::string time_UTC(const std::chrono::time_point<std::chrono::system_clock> &input) {
auto time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(input.time_since_epoch()).count();
@@ -344,7 +345,7 @@ void JFJochReceiver::MeasurePedestalThread(uint16_t data_stream, uint16_t module
void JFJochReceiver::MiniSummationThread(int d, int m, size_t image_number, bool &send_image,
FrameTransformation &transformation, DataMessage &message,
std::vector<JFConversionFixedPoint> &conversion,
RadialIntegrationProfile *profile) {
ADUHistogram& adu_histogram, RadialIntegrationProfile *profile) {
for (int j = 0; j < experiment.GetSummation(); j++) {
size_t frame_number = image_number * experiment.GetSummation() + j;
acquisition_device[d]->Counters().WaitForFrame(frame_number + 2);
@@ -370,6 +371,9 @@ void JFJochReceiver::MiniSummationThread(int d, int m, size_t image_number, bool
if (profile)
profile->Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
adu_histogram.Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
adu_histogram_total.Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
if (experiment.GetConversionOnCPU()) {
auto &conv = conversion.at(experiment.GetFirstModuleOfDataStream(d) + m);
transformation.ProcessModule(conv, src, m, d);
@@ -434,6 +438,7 @@ void JFJochReceiver::FrameTransformationThread() {
message.timestamp_base = 10*1000*1000;
message.exptime_base = 10*1000*1000;
message.indexing_result = 0;
ADUHistogram adu_histogram;
bool send_preview = false;
bool send_bkg_estimate = false;
@@ -463,7 +468,7 @@ void JFJochReceiver::FrameTransformationThread() {
this, d, m, image_number,
std::ref(send_image), std::ref(transformation),
std::ref(message), std::ref(*conversion),
rad_int_profile_image.get()));
std::ref(adu_histogram), rad_int_profile_image.get()));
message.receiver_aq_dev_delay = max_delay;
} else {
for (int j = 0; j < experiment.GetSummation(); j++) {
@@ -497,6 +502,8 @@ void JFJochReceiver::FrameTransformationThread() {
} else
transformation.ProcessModule(src, m, d);
adu_histogram.Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
adu_histogram_total.Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
if (rad_int_profile_image)
rad_int_profile_image->Add(*acquisition_device[d]->GetDeviceOutput(frame_number, m));
@@ -572,6 +579,8 @@ void JFJochReceiver::FrameTransformationThread() {
*rad_int_profile_per_file[image_number % experiment.GetDataFileCount()] += *rad_int_profile_image;
}
message.adu_histogram = adu_histogram.GetHistogram();
if (send_preview)
preview_publisher->Publish(experiment,
transformation.GetPreview16BitImage(),
@@ -784,6 +793,9 @@ JFJochProtoBuf::Plot JFJochReceiver::GetPlots(const JFJochProtoBuf::PlotRequest
case JFJochProtoBuf::INDEXING_RATE_PER_FILE:
indexing_solution_per_file.GetPlot(ret);
break;
case JFJochProtoBuf::ADU_HISTOGRAM:
adu_histogram_total.GetPlot(ret);
break;
default:
// Do nothing
break;
+4 -1
View File
@@ -29,6 +29,7 @@
#include "../jungfrau/JFCalibration.h"
#include "../jungfrau/JFConversionFixedPoint.h"
#include "../common/ADUHistogram.h"
class JFJochReceiver {
DiffractionExperiment experiment;
@@ -42,6 +43,8 @@ class JFJochReceiver {
std::vector<std::future<void>> frame_transformation_futures;
std::vector<std::future<void>> data_acquisition_futures;
ADUHistogram adu_histogram_total;
std::unique_ptr<RadialIntegrationMapping> rad_int_mapping;
std::unique_ptr<RadialIntegrationProfile> rad_int_profile;
std::vector<std::unique_ptr<RadialIntegrationProfile>> rad_int_profile_per_file;
@@ -111,7 +114,7 @@ class JFJochReceiver {
void MiniSummationThread(int d, int m, size_t image_number, bool &send_image,
FrameTransformation &transformation, DataMessage &message,
std::vector<JFConversionFixedPoint> &conversion,
RadialIntegrationProfile *profile);
ADUHistogram& adu_histogram, RadialIntegrationProfile *profile);
void Cancel(const JFJochException &e);
void FinalizeMeasurement();
JFJochProtoBuf::DataProcessingSettings GetDataProcessingSettings();
+4
View File
@@ -61,6 +61,7 @@ void HDF5DataFile::CreateFile() {
result_group->NXClass("NXcollection");
rad_int_group = std::make_unique<HDF5Group>(*data_file, "/entry/result/rad_int");
adu_histo_group = std::make_unique<HDF5Group>(*data_file, "/entry/result/adu_histogram");
HDF5DataSpace data_space({1, ypixel, xpixel},{H5S_UNLIMITED, ypixel, xpixel});
data_set = std::make_unique<HDF5DataSet>(*data_file, "/entry/data/data", data_type, data_space, dcpl);
@@ -154,6 +155,9 @@ void HDF5DataFile::Write(const DataMessage &msg, uint64_t image_number) {
if (!msg.rad_int_profile.empty() && (msg.rad_int_profile.size() == rad_int_bin_to_q.size()))
rad_int_group->SaveVector("img" + std::to_string(image_number), msg.rad_int_profile);
if (!msg.adu_histogram.empty())
adu_histo_group->SaveVector("img" + std::to_string(image_number), msg.adu_histogram);
}
HDF5DataFileStatistics HDF5DataFile::GetStatistics() const {
+1
View File
@@ -29,6 +29,7 @@ class HDF5DataFile {
std::unique_ptr<HDF5Group> result_group = nullptr;
std::unique_ptr<HDF5Group> rad_int_group = nullptr;
std::unique_ptr<HDF5Group> adu_histo_group = nullptr;
size_t xpixel;
size_t ypixel;