mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-04 20:04:14 +02:00
Merge remote-tracking branch 'origin/eiger' into eiger
This commit is contained in:
@@ -12,14 +12,6 @@ const std::string DETECTOR_TYPE = "eiger";
|
||||
#define BYTES_PER_PACKET 4144
|
||||
#define DATA_BYTES_PER_PACKET 4096
|
||||
|
||||
// EIGER 1M
|
||||
// Each packet line is made of 2 chip lines -> [CHIP1]<gap>[CHIP2]
|
||||
// gaps between chips
|
||||
// For a 1M:
|
||||
// 0 gap 1
|
||||
// gap gap
|
||||
// 2 gap 3
|
||||
|
||||
#define MODULE_X_SIZE 256
|
||||
#define MODULE_Y_SIZE 512
|
||||
#define MODULE_N_PIXELS 131072
|
||||
@@ -29,11 +21,6 @@ const std::string DETECTOR_TYPE = "eiger";
|
||||
#define GAP_X_EIGERMOD_PIXELS 8
|
||||
#define GAP_Y_EIGERMOD_PIXELS 36
|
||||
|
||||
|
||||
#define N_BYTES_PER_MODULE_LINE(bit_depth) ((MODULE_X_SIZE * bit_depth) / 8)
|
||||
#define N_BYTES_PER_MODULE_FRAME(bit_depth) ((MODULE_N_PIXELS * bit_depth) / 8)
|
||||
|
||||
|
||||
// #define N_BYTES_PER_IMAGE_LINE(bit_depth, n_submodules) ((n_submodules / 2 * MODULE_X_SIZE * bit_depth) / 8)
|
||||
|
||||
// DR 16
|
||||
|
||||
@@ -95,13 +95,8 @@ echo "Starting the ${UDP_SYNC}..."
|
||||
COUNTER=0
|
||||
if [ -f "${BUILD_PATH}${UDP_SYNC}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
if [ ${BIT_DEPTH} -ne 0 ]; then
|
||||
${BUILD_PATH}${UDP_SYNC} ${CONFIG_FILE} ${BIT_DEPTH} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Error: ${BIT_DEPTH} can't be zero..."
|
||||
exit
|
||||
fi
|
||||
${BUILD_PATH}${UDP_SYNC} ${CONFIG_FILE} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Something went wrong while starting the ${UDP_SYNC}..."
|
||||
exit
|
||||
@@ -133,19 +128,19 @@ else
|
||||
fi
|
||||
|
||||
# Start the eiger writer
|
||||
echo "Starting the ${STD_DET_WRITER}..."
|
||||
export PATH="/usr/lib64/mpich/bin:${PATH}";
|
||||
export LD_LIBRARY_PATH="/usr/lib64/mpich/lib:${LD_LIBRARY_PATH}";
|
||||
# echo "Starting the ${STD_DET_WRITER}..."
|
||||
# export PATH="/usr/lib64/mpich/bin:${PATH}";
|
||||
# export LD_LIBRARY_PATH="/usr/lib64/mpich/lib:${LD_LIBRARY_PATH}";
|
||||
|
||||
if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Something went wrong while starting the ${STD_DET_WRITER}..."
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo "Error: ${STD_DET_WRITER} wasn't found..."
|
||||
exit
|
||||
fi
|
||||
# if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then
|
||||
# if [ -f "${CONFIG_FILE}" ]; then
|
||||
# mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} &
|
||||
# sleep 0.5
|
||||
# else
|
||||
# echo "Something went wrong while starting the ${STD_DET_WRITER}..."
|
||||
# exit
|
||||
# fi
|
||||
# else
|
||||
# echo "Error: ${STD_DET_WRITER} wasn't found..."
|
||||
# exit
|
||||
# fi
|
||||
@@ -8,19 +8,22 @@ plt.ion()
|
||||
dacs = np.array([ 0, 2480, 2900, 1400, 4000, 2556, 898, 848, 0, 855, 1100,
|
||||
1100, 982, 895, 2000, 1550, 570, 0], dtype=np.int32)
|
||||
|
||||
tb = np.zeros((512,1024), dtype = np.int32)
|
||||
tb = np.zeros((256,1024), dtype = np.int32)
|
||||
|
||||
# Create the desired pattern
|
||||
for row in range(0,512,64):
|
||||
for row in range(0,256,64):
|
||||
for col in range(0,1024,64):
|
||||
print(f'{row}, {col}')
|
||||
tb[row:row+32, col:col+32] = 63
|
||||
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
im = ax.imshow(tb)
|
||||
|
||||
fig.savefig('trim.png')
|
||||
|
||||
with open('trimbits.sn000', 'wb') as f:
|
||||
|
||||
with open('trimbits.sn001', 'wb') as f:
|
||||
dacs.tofile(f)
|
||||
tb.tofile(f)
|
||||
@@ -13,7 +13,7 @@ class EigerAssembler {
|
||||
int last_image_status_;
|
||||
|
||||
const uint32_t n_bytes_per_frame_;
|
||||
const uint32_t n_bytes_per_module_line_;
|
||||
const uint32_t n_bytes_per_frame_line_;
|
||||
const uint32_t n_packets_per_frame_;
|
||||
const uint32_t n_bytes_per_x_gap_;
|
||||
const uint32_t n_bytes_per_y_gap_;
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const EigerAssembler& p)
|
||||
{
|
||||
return os << "( n_bytes_per_frame_"
|
||||
<< p.n_bytes_per_frame_ << ", n_bytes_per_module_line_"
|
||||
<< p.n_bytes_per_module_line_ << ", n_packets_per_frame_"
|
||||
<< p.n_bytes_per_frame_ << ", n_bytes_per_frame_line_"
|
||||
<< p.n_bytes_per_frame_line_ << ", n_packets_per_frame_"
|
||||
<< p.n_packets_per_frame_ << ", n_bytes_per_x_gap_"
|
||||
<< p.n_bytes_per_x_gap_ << ", n_bytes_per_y_gap_"
|
||||
<< p.n_bytes_per_y_gap_ << ", n_bytes_per_eiger_x_gap_"
|
||||
|
||||
@@ -17,16 +17,15 @@ EigerAssembler::EigerAssembler(const int n_modules, const int bit_depth):
|
||||
n_eiger_modules_(n_modules/4),
|
||||
bit_depth_(bit_depth),
|
||||
n_bytes_per_frame_(MODULE_N_PIXELS * bit_depth / 8),
|
||||
n_bytes_per_module_line_(N_BYTES_PER_MODULE_LINE(bit_depth)),
|
||||
n_bytes_per_frame_line_(MODULE_X_SIZE * bit_depth / 8),
|
||||
n_packets_per_frame_(n_bytes_per_frame_ / DATA_BYTES_PER_PACKET),
|
||||
n_bytes_per_x_gap_(GAP_X_MODULE_PIXELS * bit_depth / 8),
|
||||
n_bytes_per_y_gap_(GAP_Y_MODULE_PIXELS * bit_depth / 8),
|
||||
n_bytes_per_eiger_x_gap_(GAP_X_EIGERMOD_PIXELS * bit_depth / 8),
|
||||
n_bytes_per_eiger_y_gap_(GAP_Y_EIGERMOD_PIXELS * bit_depth / 8),
|
||||
n_bytes_per_image_line_(n_bytes_per_module_line_ * 2 + n_bytes_per_x_gap_),
|
||||
n_lines_per_frame_(DATA_BYTES_PER_PACKET / n_bytes_per_module_line_
|
||||
* n_packets_per_frame_),
|
||||
image_bytes_((n_modules_ * MODULE_N_PIXELS * bit_depth_ / 8) + ((n_eiger_modules_) * (MODULE_Y_SIZE * 2) * bit_depth_ / 8) + ((n_eiger_modules_) * (2 * n_bytes_per_image_line_)))
|
||||
n_bytes_per_image_line_(n_bytes_per_frame_line_ * 2 + n_bytes_per_x_gap_),
|
||||
n_lines_per_frame_(DATA_BYTES_PER_PACKET / n_bytes_per_frame_line_ * n_packets_per_frame_),
|
||||
image_bytes_((n_modules_ * n_bytes_per_frame_) + (2 * (MODULE_Y_SIZE * 2) * bit_depth_ / 8) + ((n_eiger_modules_) * (2 * n_bytes_per_image_line_)))
|
||||
{
|
||||
|
||||
}
|
||||
@@ -69,6 +68,7 @@ void EigerAssembler::assemble_image(const char* src_meta,
|
||||
image_meta->dtype = (bit_depth_ <= 8) ? 1 : bit_depth_ / 8;
|
||||
image_meta->encoding = 0;
|
||||
image_meta->source_id = 0;
|
||||
// TODO: proper user ids
|
||||
image_meta->user_1 = 0;
|
||||
image_meta->user_2 = 0;
|
||||
is_pulse_init = 1;
|
||||
@@ -104,7 +104,7 @@ void EigerAssembler::assemble_image(const char* src_meta,
|
||||
reverse_factor = MODULE_Y_SIZE - 1;
|
||||
dest_offset += n_bytes_per_image_line_ *
|
||||
(MODULE_Y_SIZE + GAP_Y_MODULE_PIXELS);
|
||||
source_offset = (MODULE_Y_SIZE-1) * n_bytes_per_module_line_;
|
||||
source_offset = (MODULE_Y_SIZE-1) * n_bytes_per_frame_line_;
|
||||
}
|
||||
|
||||
const auto i_module_row = frame_meta->pos_x;
|
||||
@@ -114,7 +114,7 @@ void EigerAssembler::assemble_image(const char* src_meta,
|
||||
uint32_t dest_module_line = line_number;
|
||||
|
||||
if (i_module_column == 1) {
|
||||
dest_offset += n_bytes_per_module_line_ + n_bytes_per_x_gap_;
|
||||
dest_offset += n_bytes_per_frame_line_ + n_bytes_per_x_gap_;
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
@@ -125,15 +125,43 @@ void EigerAssembler::assemble_image(const char* src_meta,
|
||||
memcpy (
|
||||
(char*)(dst_data + dest_offset),
|
||||
(char*)(src_data + source_offset),
|
||||
n_bytes_per_module_line_
|
||||
n_bytes_per_frame_line_
|
||||
);
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
// verifies the addresses for
|
||||
// beginning and end of each frame
|
||||
if (counter < 5 || counter > 508){
|
||||
cout << " [" << std::chrono::system_clock::now();
|
||||
cout << "] [MODULE " << i_module;
|
||||
cout << "] (row " << i_module_row;
|
||||
cout << ",column " << i_module_column;
|
||||
cout << ") source_offset" << source_offset;
|
||||
cout << " || dest_offset " << dest_offset;
|
||||
cout << " || frame_line " << frame_line;
|
||||
cout << " || COUNTER " << counter;
|
||||
cout << endl;
|
||||
}
|
||||
#endif
|
||||
counter += 1;
|
||||
source_offset += reverse * n_bytes_per_module_line_;
|
||||
source_offset += reverse * n_bytes_per_frame_line_;
|
||||
dest_offset += reverse * n_bytes_per_image_line_;
|
||||
}
|
||||
line_number += n_lines_per_frame_;
|
||||
dest_module_line = line_number + n_lines_per_frame_ - 1;
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
// if (i_module == 0){
|
||||
cout << " [" << std::chrono::system_clock::now();
|
||||
cout << "] [MODULE " << i_module;
|
||||
cout << "] (row " << i_module_row;
|
||||
cout << " , column" << i_module_column;
|
||||
cout << ") || reverse_factor" << reverse_factor;
|
||||
cout << " || line_number" << line_number;
|
||||
cout << " || N_RECV_PACKETS" << frame_meta->n_recv_packets;
|
||||
cout << endl;
|
||||
// }
|
||||
#endif
|
||||
|
||||
// last module sets the last_image_status_
|
||||
if (i_module == n_modules_ - 1){
|
||||
|
||||
Reference in New Issue
Block a user