mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-03 11:20:03 +02:00
Polish data structure
This commit is contained in:
parent
3e2d34bec7
commit
01d3dc7115
@ -9,9 +9,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "slsDetectorData.h"
|
#include "slsDetectorData.h"
|
||||||
|
|
||||||
//This needs to be linked correctly
|
// This needs to be linked correctly
|
||||||
#include "HDF5File.h" //this includes hdf5.h and hdf5_hl.h
|
|
||||||
#include "HDF5File.cpp"
|
#include "HDF5File.cpp"
|
||||||
|
#include "HDF5File.h" //this includes hdf5.h and hdf5_hl.h
|
||||||
|
|
||||||
// #define VERSION_V2
|
// #define VERSION_V2
|
||||||
/**
|
/**
|
||||||
@ -32,42 +32,40 @@
|
|||||||
@li version is the version number of this structure format
|
@li version is the version number of this structure format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include <algorithm>
|
// #include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace strixelQuad {
|
namespace strixelQuad {
|
||||||
constexpr int nc_rawimg = 1024; // for full images //256;
|
constexpr int nc_rawimg = 1024; // for full images //256;
|
||||||
constexpr int nc_quad = 512;
|
constexpr int nc_quad = 512;
|
||||||
constexpr int nr_rawimg = 512;
|
constexpr int nr_rawimg = 512;
|
||||||
constexpr int nr_chip = 256;
|
constexpr int nr_chip = 256;
|
||||||
constexpr int gr = 9;
|
constexpr int gr = 9;
|
||||||
|
|
||||||
//shift due to extra pixels
|
// shift due to extra pixels
|
||||||
constexpr int shift_x = 2; //left
|
constexpr int shift_x = 2; // left
|
||||||
|
|
||||||
constexpr int nc_strixel = ( nc_quad - shift_x - 2*gr ) / 3; //164
|
|
||||||
constexpr int nr_strixel = ( nr_chip - 1 - gr ) * 3; //one half (-1 because double sided pixel) //738
|
|
||||||
constexpr int nr_center = 12; //double sided pixels to be skipped
|
|
||||||
|
|
||||||
// boundaries in ASIC coordinates (pixels at both bounds are included)
|
constexpr int nc_strixel = (nc_quad - shift_x - 2 * gr) / 3; // 164
|
||||||
constexpr int xstart = 256 + gr; // 265
|
constexpr int nr_strixel =
|
||||||
constexpr int xend = 255 + nc_quad - gr; // 758
|
(nr_chip - 1 - gr) * 3; // one half (-1 because double sided pixel) //738
|
||||||
constexpr int bottom_ystart = gr; // 9
|
constexpr int nr_center = 12; // double sided pixels to be skipped
|
||||||
constexpr int bottom_yend = nr_chip - 2; // 254
|
|
||||||
constexpr int top_ystart = nr_chip + 1; // 257
|
|
||||||
constexpr int top_yend = nr_chip*2 - gr - 1; // 502
|
|
||||||
|
|
||||||
// x shift because of 2-pixel strixels on one side
|
// boundaries in ASIC coordinates (pixels at both bounds are included)
|
||||||
constexpr int shift = 2;
|
constexpr int xstart = 256 + gr; // 265
|
||||||
|
constexpr int xend = 255 + nc_quad - gr; // 758
|
||||||
|
constexpr int bottom_ystart = gr; // 9
|
||||||
|
constexpr int bottom_yend = nr_chip - 2; // 254
|
||||||
|
constexpr int top_ystart = nr_chip + 1; // 257
|
||||||
|
constexpr int top_yend = nr_chip * 2 - gr - 1; // 502
|
||||||
|
|
||||||
|
// x shift because of 2-pixel strixels on one side
|
||||||
|
constexpr int shift = 2;
|
||||||
|
|
||||||
} // namespace strixelQuad
|
} // namespace strixelQuad
|
||||||
|
|
||||||
//to account for module rotation
|
// to account for module rotation
|
||||||
enum rotation {
|
enum rotation { NORMAL = 0, INVERSE = 1 };
|
||||||
NORMAL = 0,
|
|
||||||
INVERSE = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
const int rota = NORMAL;
|
const int rota = NORMAL;
|
||||||
|
|
||||||
@ -85,232 +83,230 @@ class jungfrauLGADStrixelsDataQuadH5 : public slsDetectorData<uint16_t> {
|
|||||||
int iframe;
|
int iframe;
|
||||||
int x0, y0, x1, y1, shifty;
|
int x0, y0, x1, y1, shifty;
|
||||||
struct {
|
struct {
|
||||||
uint16_t xmin;
|
uint16_t xmin;
|
||||||
uint16_t xmax;
|
uint16_t xmax;
|
||||||
uint16_t ymin;
|
uint16_t ymin;
|
||||||
uint16_t ymax;
|
uint16_t ymax;
|
||||||
int nc;
|
int nc;
|
||||||
} globalROI;
|
} globalROI;
|
||||||
|
|
||||||
//to account for the inverted routing of the two different quad halfs
|
// to account for the inverted routing of the two different quad halfs
|
||||||
enum location {
|
enum location { BOTTOM = 0, TOP = 1 };
|
||||||
BOTTOM = 0,
|
|
||||||
TOP = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
int multiplicator = 3;
|
int multiplicator = 3;
|
||||||
std::vector<int> mods{ 0, 1, 2 };
|
std::vector<int> mods{0, 1, 2};
|
||||||
|
|
||||||
void reverseVector( std::vector<int>& v ) {
|
void reverseVector(std::vector<int> &v) {
|
||||||
std::reverse( v.begin(), v.end() );
|
std::reverse(v.begin(), v.end());
|
||||||
std::cout << "mods reversed ";
|
std::cout << "mods reversed ";
|
||||||
for ( auto i : v )
|
for (auto i : v)
|
||||||
std::cout << i << " ";
|
std::cout << i << " ";
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMappingShifts( const int rot, const int half ) {
|
void setMappingShifts(const int rot, const int half) {
|
||||||
|
|
||||||
x0 = xstart;
|
x0 = xstart;
|
||||||
x1 = xend;
|
x1 = xend;
|
||||||
|
|
||||||
if (rot==NORMAL) {
|
if (rot == NORMAL) {
|
||||||
x0 += shift;
|
x0 += shift;
|
||||||
} else {
|
} else {
|
||||||
x1-=shift;
|
x1 -= shift;
|
||||||
reverseVector(mods);
|
reverseVector(mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (half==BOTTOM) {
|
|
||||||
y0 = bottom_ystart;
|
|
||||||
y1 = bottom_yend;
|
|
||||||
shifty = 0;
|
|
||||||
} else {
|
|
||||||
y0 = top_ystart;
|
|
||||||
y1 = top_yend;
|
|
||||||
reverseVector(mods);
|
|
||||||
shifty = nr_strixel + nr_center; //double-sided pixels in the center have to be jumped
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (half == BOTTOM) {
|
||||||
|
y0 = bottom_ystart;
|
||||||
|
y1 = bottom_yend;
|
||||||
|
shifty = 0;
|
||||||
|
} else {
|
||||||
|
y0 = top_ystart;
|
||||||
|
y1 = top_yend;
|
||||||
|
reverseVector(mods);
|
||||||
|
shifty = nr_strixel + nr_center; // double-sided pixels in the
|
||||||
|
// center have to be jumped
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remap( int xmin=0, int xmax=0, int ymin=0, int ymax=0 ) {
|
void remap(int xmin = 0, int xmax = 0, int ymin = 0, int ymax = 0) {
|
||||||
|
|
||||||
int ix, iy = 0;
|
int ix, iy = 0;
|
||||||
// remapping loop
|
// remapping loop
|
||||||
for (int ipy = y0; ipy <= y1; ++ipy) {
|
for (int ipy = y0; ipy <= y1; ++ipy) {
|
||||||
for (int ipx = x0; ipx <= x1; ++ipx) {
|
for (int ipx = x0; ipx <= x1; ++ipx) {
|
||||||
|
|
||||||
ix = int((ipx - x0) / multiplicator);
|
ix = int((ipx - x0) / multiplicator);
|
||||||
for (int m = 0; m < multiplicator; ++m) {
|
for (int m = 0; m < multiplicator; ++m) {
|
||||||
if ((ipx - x0) % multiplicator == m)
|
if ((ipx - x0) % multiplicator == m)
|
||||||
iy = (ipy - y0) * multiplicator + mods[m] + shifty;
|
iy = (ipy - y0) * multiplicator + mods[m] + shifty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (iy< 40) cout << iy << " " << ix <<endl;
|
// if (iy< 40) cout << iy << " " << ix <<endl;
|
||||||
if (xmin < xmax && ymin < ymax) {
|
if (xmin < xmax && ymin < ymax) { // if ROI
|
||||||
if ( ipx>=xmin && ipx<=xmax && ipy>=ymin && ipy <=ymax )
|
if (ipx >= xmin && ipx <= xmax && ipy >= ymin &&
|
||||||
dataMap[iy][ix] =
|
ipy <= ymax)
|
||||||
(globalROI.nc * (ipy - globalROI.ymin) + (ipx - globalROI.xmin)) * 2;
|
dataMap[iy][ix] =
|
||||||
} else {
|
(globalROI.nc * (ipy - globalROI.ymin) +
|
||||||
dataMap[iy][ix] = (nc_rawimg * ipy + ipx) * 2;
|
(ipx - globalROI.xmin)) *
|
||||||
}
|
2;
|
||||||
|
} else { // if full Quad
|
||||||
|
dataMap[iy][ix] = (nc_rawimg * ipy + ipx) * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remapQuad(const int rot) {
|
void remapQuad(const int rot) {
|
||||||
|
|
||||||
setMappingShifts( rot, BOTTOM );
|
setMappingShifts(rot, BOTTOM);
|
||||||
remap();
|
remap();
|
||||||
setMappingShifts( rot, TOP );
|
setMappingShifts(rot, TOP);
|
||||||
remap();
|
remap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::tuple<uint16_t, uint16_t, uint16_t, uint16_t>
|
||||||
std::tuple< uint16_t, uint16_t, uint16_t, uint16_t > adjustROItoLimits(uint16_t xmin,
|
adjustROItoLimits(uint16_t xmin, uint16_t xmax, uint16_t ymin,
|
||||||
uint16_t xmax,
|
uint16_t ymax, uint16_t lim_roi_xmin,
|
||||||
uint16_t ymin,
|
uint16_t lim_roi_xmax, uint16_t lim_roi_ymin,
|
||||||
uint16_t ymax,
|
uint16_t lim_roi_ymax) {
|
||||||
uint16_t lim_roi_xmin,
|
uint16_t xmin_roi, xmax_roi, ymin_roi, ymax_roi;
|
||||||
uint16_t lim_roi_xmax,
|
if (xmin < lim_roi_xmin)
|
||||||
uint16_t lim_roi_ymin,
|
xmin_roi = lim_roi_xmin;
|
||||||
uint16_t lim_roi_ymax) {
|
else
|
||||||
uint16_t xmin_roi, xmax_roi, ymin_roi, ymax_roi;
|
xmin_roi = xmin;
|
||||||
if ( xmin < lim_roi_xmin)
|
if (xmax > lim_roi_xmax)
|
||||||
xmin_roi = lim_roi_xmin;
|
xmax_roi = lim_roi_xmax;
|
||||||
else
|
else
|
||||||
xmin_roi = xmin;
|
xmax_roi = xmax;
|
||||||
if ( xmax > lim_roi_xmax )
|
if (ymin < lim_roi_ymin)
|
||||||
xmax_roi = lim_roi_xmax;
|
ymin_roi = lim_roi_ymin;
|
||||||
else
|
else
|
||||||
xmax_roi = xmax;
|
ymin_roi = ymin;
|
||||||
if ( ymin < lim_roi_ymin )
|
if (ymax > lim_roi_ymax)
|
||||||
ymin_roi = lim_roi_ymin;
|
ymax_roi = lim_roi_ymax;
|
||||||
else
|
else
|
||||||
ymin_roi = ymin;
|
ymax_roi = ymax;
|
||||||
if ( ymax > lim_roi_ymax )
|
return std::make_tuple(xmin_roi, xmax_roi, ymin_roi, ymax_roi);
|
||||||
ymax_roi = lim_roi_ymax;
|
|
||||||
else
|
|
||||||
ymax_roi = ymax;
|
|
||||||
return std::make_tuple(xmin_roi, xmax_roi, ymin_roi, ymax_roi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector < std::tuple< int, uint16_t, uint16_t, uint16_t, uint16_t > > mapSubROIs(uint16_t xmin,
|
// The strixel Quad has a mirrored symmetry from the center axis
|
||||||
uint16_t xmax,
|
// So we need to distinguish between bottom and top half for remapping
|
||||||
uint16_t ymin,
|
std::vector<std::tuple<int, uint16_t, uint16_t, uint16_t, uint16_t>>
|
||||||
uint16_t ymax) {
|
mapSubROIs(uint16_t xmin, uint16_t xmax, uint16_t ymin, uint16_t ymax) {
|
||||||
bool bottom = false;
|
bool bottom = false;
|
||||||
bool top = false;
|
bool top = false;
|
||||||
|
|
||||||
for ( int x=xmin; x!=xmax+1; ++x ) {
|
for (int x = xmin; x != xmax + 1; ++x) {
|
||||||
for ( int y=ymin; y!=ymax; ++y ) {
|
for (int y = ymin; y != ymax; ++y) {
|
||||||
if ( xstart<=x && x<=xend && bottom_ystart<=y && y<=bottom_yend )
|
if (xstart <= x && x <= xend && bottom_ystart <= y &&
|
||||||
bottom = true;
|
y <= bottom_yend)
|
||||||
if ( xstart<=x && x<=xend && top_ystart<=y && y<=top_yend )
|
bottom = true;
|
||||||
top = true;
|
if (xstart <= x && x <= xend && top_ystart <= y &&
|
||||||
}
|
y <= top_yend)
|
||||||
}
|
top = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t xmin_roi{}, xmax_roi{}, ymin_roi{}, ymax_roi{};
|
uint16_t xmin_roi{}, xmax_roi{}, ymin_roi{}, ymax_roi{};
|
||||||
std::vector < std::tuple< int, uint16_t, uint16_t, uint16_t, uint16_t > > rois{};
|
std::vector<std::tuple<int, uint16_t, uint16_t, uint16_t, uint16_t>>
|
||||||
|
rois{};
|
||||||
|
|
||||||
if (bottom) {
|
if (bottom) {
|
||||||
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
|
std::tie(xmin_roi, xmax_roi, ymin_roi, ymax_roi) =
|
||||||
adjustROItoLimits( xmin, xmax, ymin, ymax,
|
adjustROItoLimits(xmin, xmax, ymin, ymax, xstart, xend,
|
||||||
xstart, xend, bottom_ystart, bottom_yend );
|
bottom_ystart, bottom_yend);
|
||||||
rois.push_back( std::make_tuple( BOTTOM, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
|
rois.push_back(std::make_tuple(BOTTOM, xmin_roi, xmax_roi, ymin_roi,
|
||||||
}
|
ymax_roi));
|
||||||
if (top) {
|
}
|
||||||
std::tie( xmin_roi, xmax_roi, ymin_roi, ymax_roi ) =
|
if (top) {
|
||||||
adjustROItoLimits( xmin, xmax, ymin, ymax,
|
std::tie(xmin_roi, xmax_roi, ymin_roi, ymax_roi) =
|
||||||
xstart, xend, top_ystart, top_yend );
|
adjustROItoLimits(xmin, xmax, ymin, ymax, xstart, xend,
|
||||||
rois.push_back( std::make_tuple( TOP, xmin_roi, xmax_roi, ymin_roi, ymax_roi ) );
|
top_ystart, top_yend);
|
||||||
}
|
rois.push_back(
|
||||||
|
std::make_tuple(TOP, xmin_roi, xmax_roi, ymin_roi, ymax_roi));
|
||||||
|
}
|
||||||
|
|
||||||
return rois;
|
return rois;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remapROI(std::tuple< int, uint16_t, uint16_t, uint16_t, uint16_t > roi, const int rot ) {
|
void remapROI(std::tuple<int, uint16_t, uint16_t, uint16_t, uint16_t> roi,
|
||||||
|
const int rot) {
|
||||||
|
|
||||||
int half, xmin, xmax, ymin, ymax;
|
int half, xmin, xmax, ymin, ymax;
|
||||||
std::tie( half, xmin, xmax, ymin, ymax ) = roi;
|
std::tie(half, xmin, xmax, ymin, ymax) = roi;
|
||||||
|
|
||||||
setMappingShifts(rot, half);
|
|
||||||
|
|
||||||
std::cout << "remapping roi: "
|
setMappingShifts(rot, half);
|
||||||
<< ", x0: " << x0 << ", x1: " << x1 << ", y0: " << y0
|
|
||||||
<< ", y1: " << y1 << std::endl;
|
|
||||||
std::cout << "Adjusted roi: [" << xmin << ", " << xmax << ", " << ymin << ", " << ymax << "]" << std::endl;
|
|
||||||
|
|
||||||
remap( xmin, xmax, ymin, ymax );
|
std::cout << "remapping roi: "
|
||||||
|
<< ", x0: " << x0 << ", x1: " << x1 << ", y0: " << y0
|
||||||
|
<< ", y1: " << y1 << std::endl;
|
||||||
|
std::cout << "Adjusted roi: [" << xmin << ", " << xmax << ", " << ymin
|
||||||
|
<< ", " << ymax << "]" << std::endl;
|
||||||
|
|
||||||
|
remap(xmin, xmax, ymin, ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The following functions are pure virtual in the base class. But I don't want them to be accessible here!
|
// The following functions are pure virtual in the base class. But I don't
|
||||||
//Implement the functions as private (to satisfy the linker)
|
// want them to be accessible here! Implement the functions as private (to
|
||||||
//int getFrameNumber(char* buff){return 0;} //This is actually needed because the cluster finder writes the framenumber
|
// satisfy the linker) int getFrameNumber(char* buff){return 0;} //This is
|
||||||
int getPacketNumber(char* buff){return 0;} //Not provided
|
// actually needed because the cluster finder writes the framenumber
|
||||||
|
int getPacketNumber(char *buff) { return 0; } // Not provided
|
||||||
|
|
||||||
//Mark overwritten functions as override final
|
// Mark overwritten functions as override final
|
||||||
char* readNextFrame( std::ifstream &filebin ) override final {return nullptr;}
|
char *readNextFrame(std::ifstream &filebin) override final {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using header = sls::defs::sls_receiver_header;
|
using header = sls::defs::sls_receiver_header;
|
||||||
|
|
||||||
jungfrauLGADStrixelsDataQuadH5(uint16_t xmin = 0, uint16_t xmax = 0,
|
jungfrauLGADStrixelsDataQuadH5(uint16_t xmin = 0, uint16_t xmax = 0,
|
||||||
uint16_t ymin = 0, uint16_t ymax = 0)
|
uint16_t ymin = 0, uint16_t ymax = 0)
|
||||||
: slsDetectorData<uint16_t>(
|
: slsDetectorData<uint16_t>(
|
||||||
//nc_strixel,
|
// nc_strixel,
|
||||||
//nr_strixel * 2 + nr_center,
|
// nr_strixel * 2 + nr_center,
|
||||||
//nc_strixel * ( nr_strixel * 2 + nr_center ) * 2
|
// nc_strixel * ( nr_strixel * 2 + nr_center ) * 2
|
||||||
512/2,
|
512 / 2, 1024 * 2, 512 * 1024 * 2) {
|
||||||
1024*2,
|
|
||||||
512 * 1024 * 2 ) {
|
|
||||||
std::cout << "Jungfrau strixels quad with full module data "
|
std::cout << "Jungfrau strixels quad with full module data "
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// Fill all strixels with dummy values
|
// Fill all strixels with dummy values
|
||||||
//for (int ix = 0; ix != nc_strixel; ++ix) {
|
// for (int ix = 0; ix != nc_strixel; ++ix) {
|
||||||
// for (int iy = 0; iy != nr_strixel * 2 + nr_center; ++iy) {
|
// for (int iy = 0; iy != nr_strixel * 2 + nr_center; ++iy) {
|
||||||
for (int ix = 0; ix != 512/2; ++ix) {
|
for (int ix = 0; ix != 512 / 2; ++ix) {
|
||||||
for (int iy = 0; iy != 1024*2; ++iy) {
|
for (int iy = 0; iy != 1024 * 2; ++iy) {
|
||||||
dataMap[iy][ix] = sizeof(header); //maybe another value is safer
|
// Set everything to dummy value
|
||||||
|
dataMap[iy][ix] = sizeof(header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globalROI.xmin = xmin;
|
globalROI.xmin = xmin;
|
||||||
globalROI.xmax = xmax;
|
globalROI.xmax = xmax;
|
||||||
globalROI.ymin = ymin;
|
globalROI.ymin = ymin;
|
||||||
globalROI.ymax = ymax;
|
globalROI.ymax = ymax;
|
||||||
|
|
||||||
//std::cout << "sizeofheader = " << sizeof(header) << std::endl;
|
// std::cout << "sizeofheader = " << sizeof(header) << std::endl;
|
||||||
std::cout << "Jungfrau strixels quad with full module data "
|
std::cout << "Jungfrau strixels quad with full module data "
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
if (xmin < xmax && ymin < ymax) {
|
if (xmin < xmax && ymin < ymax) {
|
||||||
|
|
||||||
// get ROI raw image number of columns
|
// get ROI raw image number of columns
|
||||||
globalROI.nc = xmax - xmin + 1;
|
globalROI.nc = xmax - xmin + 1;
|
||||||
std::cout << "nc_roi = " << globalROI.nc << std::endl;
|
std::cout << "nc_roi = " << globalROI.nc << std::endl;
|
||||||
|
|
||||||
dataSize =
|
|
||||||
(xmax - xmin + 1) * (ymax - ymin + 1) * 2;
|
|
||||||
std::cout << "datasize " << dataSize << std::endl;
|
|
||||||
|
|
||||||
auto rois = mapSubROIs(xmin, xmax, ymin, ymax);
|
dataSize = (xmax - xmin + 1) * (ymax - ymin + 1) * 2;
|
||||||
//function to fill vector of rois from globalROI
|
std::cout << "datasize " << dataSize << std::endl;
|
||||||
|
|
||||||
for ( auto roi : rois )
|
auto rois = mapSubROIs(xmin, xmax, ymin, ymax);
|
||||||
remapROI(roi, rota);
|
// function to fill vector of rois from globalROI
|
||||||
|
|
||||||
|
for (auto roi : rois)
|
||||||
|
remapROI(roi, rota);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
remapQuad(rota);
|
||||||
remapQuad( rota );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe = 0;
|
iframe = 0;
|
||||||
@ -325,78 +321,86 @@ class jungfrauLGADStrixelsDataQuadH5 : public slsDetectorData<uint16_t> {
|
|||||||
required as double
|
required as double
|
||||||
|
|
||||||
*/
|
*/
|
||||||
virtual double getValue(char* data, int ix, int iy = 0) {
|
virtual double getValue(char *data, int ix, int iy = 0) {
|
||||||
|
|
||||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
char* readNextFrame( HDF5File& hfile ) {
|
char *readNextFrame(HDF5File &hfile) {
|
||||||
int fn = 0;
|
int fn = 0;
|
||||||
std::vector<hsize_t> h5offset(1);
|
std::vector<hsize_t> h5offset(1);
|
||||||
return readNextFrame(hfile, fn, h5offset);
|
return readNextFrame(hfile, fn, h5offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
char* readNextFrame( HDF5File& hfile, int& fn ) {
|
char *readNextFrame(HDF5File &hfile, int &fn) {
|
||||||
std::vector<hsize_t> h5offset(1);
|
std::vector<hsize_t> h5offset(1);
|
||||||
return readNextFrame(hfile, fn, h5offset);
|
return readNextFrame(hfile, fn, h5offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
char* readNextFrame( HDF5File& hfile, int& fn, std::vector<hsize_t>& h5offset ) {
|
char *readNextFrame(HDF5File &hfile, int &fn,
|
||||||
|
std::vector<hsize_t> &h5offset) {
|
||||||
|
|
||||||
// Ensure dataSize is a valid size for allocation
|
// Ensure dataSize is a valid size for allocation
|
||||||
if (dataSize <= 0) {
|
if (dataSize <= 0) {
|
||||||
// Handle error case appropriately, e.g., log an error message
|
// Handle error case appropriately, e.g., log an error message
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* data = new char[dataSize];
|
char *data = new char[dataSize];
|
||||||
char* readResult = readNextFrame(hfile, fn, h5offset, data);
|
char *readResult = readNextFrame(hfile, fn, h5offset, data);
|
||||||
|
|
||||||
// Check if reading failed
|
// Check if reading failed
|
||||||
if (readResult == nullptr) {
|
if (readResult == nullptr) {
|
||||||
delete[] data; // Free allocated memory
|
delete[] data; // Free allocated memory
|
||||||
data = nullptr; // Set to nullptr to avoid dangling pointer
|
data = nullptr; // Set to nullptr to avoid dangling pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
return data; //returning data is equivalent to returning reinterpret_cast<char*>(data_ptr) as they both point to the same memory
|
return data; // returning data is equivalent to returning
|
||||||
|
// reinterpret_cast<char*>(data_ptr) as they both point to
|
||||||
|
// the same memory
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the most recent function. This is used in the cluster finder!
|
* This is the most recent function. This is used in the cluster finder!
|
||||||
* The overloads are legacy!
|
* The overloads are legacy!
|
||||||
* Note that caller has to allocate and deallocate memory for data!
|
* Note that caller has to allocate and deallocate memory for data!
|
||||||
* \param hfile object of type HDF5File (reader class)
|
* \param hfile object of type HDF5File (reader class)
|
||||||
* \param framenumber frame number as read from the HDF5 file
|
* \param framenumber frame number as read from the HDF5 file
|
||||||
* \param h5offset vector defining offset parameters for HDF5 hyperslab selection (dimensions Z and S), incremented automatially
|
* \param h5offset vector defining offset parameters for HDF5 hyperslab
|
||||||
* \param data pointer to image buffer (converted to hold uint16_t by definition of HDF5File)
|
* selection (dimensions Z and S), incremented automatially
|
||||||
|
* \param data pointer to image buffer (converted to hold uint16_t by
|
||||||
|
* definition of HDF5File)
|
||||||
*/
|
*/
|
||||||
char* readNextFrame( HDF5File& hfile, int& framenumber, std::vector<hsize_t>& h5offset, char* data ) {
|
char *readNextFrame(HDF5File &hfile, int &framenumber,
|
||||||
|
std::vector<hsize_t> &h5offset, char *data) {
|
||||||
|
|
||||||
if (framenumber >= 0) {
|
if (framenumber >= 0) {
|
||||||
if (h5offset[0] % 10 == 0)
|
if (h5offset[0] % 10 == 0)
|
||||||
std::cout << "*";
|
std::cout << "*";
|
||||||
|
|
||||||
//Storing the reinterpret_cast in the variable data_ptr ensures that I can pass it to a function that expects at uint16_t*
|
// Storing the reinterpret_cast in the variable data_ptr ensures
|
||||||
uint16_t* data_ptr = reinterpret_cast<uint16_t*>(data); //now data_ptr points where data points (thus modifies the same memory)
|
// that I can pass it to a function that expects at uint16_t*
|
||||||
|
uint16_t *data_ptr = reinterpret_cast<uint16_t *>(
|
||||||
|
data); // now data_ptr points where data points (thus modifies
|
||||||
|
// the same memory)
|
||||||
|
|
||||||
framenumber = hfile.ReadImage( data_ptr, h5offset );
|
framenumber = hfile.ReadImage(data_ptr, h5offset);
|
||||||
iframe = h5offset[0]; //iframe is a class member!
|
iframe = h5offset[0]; // iframe is a class member!
|
||||||
return data; // return reinterpret_cast<char*>(data_ptr); // Equivalent
|
return data; // return reinterpret_cast<char*>(data_ptr); //
|
||||||
}
|
// Equivalent
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "#";
|
std::cout << "#";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
int getFrameNumber(char* buff){return iframe;} //Provided via public method readNextFrame
|
int getFrameNumber(char *buff) {
|
||||||
//It is debatable if one might not instead want to provide the "real" frame number as read from the file here
|
return iframe;
|
||||||
//For now, this is the frame offset counter (that always has to start at 0 for each new file)
|
} // Provided via public method readNextFrame
|
||||||
|
// It is debatable if one might not instead want to provide the "real" frame
|
||||||
|
// number as read from the file here For now, this is the frame offset
|
||||||
|
// counter (that always has to start at 0 for each new file)
|
||||||
|
|
||||||
/* Loops over a memory slot until a complete frame is found (i.e. all */
|
/* Loops over a memory slot until a complete frame is found (i.e. all */
|
||||||
/* packets 0 to nPackets, same frame number). purely virtual func \param
|
/* packets 0 to nPackets, same frame number). purely virtual func \param
|
||||||
@ -414,7 +418,7 @@ class jungfrauLGADStrixelsDataQuadH5 : public slsDetectorData<uint16_t> {
|
|||||||
/* found */
|
/* found */
|
||||||
|
|
||||||
/* *\/ */
|
/* *\/ */
|
||||||
virtual char* findNextFrame(char* data, int& ndata, int dsize) {
|
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
|
||||||
if (dsize < dataSize)
|
if (dsize < dataSize)
|
||||||
ndata = dsize;
|
ndata = dsize;
|
||||||
else
|
else
|
||||||
|
@ -221,7 +221,7 @@ int main(int argc, char *argv[]) {
|
|||||||
auto firstfileh5 = std::make_unique<HDF5File>();
|
auto firstfileh5 = std::make_unique<HDF5File>();
|
||||||
firstfileh5->SetFrameIndexPath(frameindexpath);
|
firstfileh5->SetFrameIndexPath(frameindexpath);
|
||||||
firstfileh5->SetImageDataPath(datasetpath);
|
firstfileh5->SetImageDataPath(datasetpath);
|
||||||
std::cout << "Debug: Attempting to open file " << filenames[0].c_str() << std::endl;
|
//std::cout << "Debug: Attempting to open file " << filenames[0].c_str() << std::endl;
|
||||||
if ( firstfileh5->OpenResources(filenames[0].c_str(), validate_rank) ) {
|
if ( firstfileh5->OpenResources(filenames[0].c_str(), validate_rank) ) {
|
||||||
|
|
||||||
// Validate number of threads
|
// Validate number of threads
|
||||||
|
Loading…
x
Reference in New Issue
Block a user