Make a library for writing and reading tiff, added tests (#347)

* removed Makefile for moench and integrated the build in CMake
* broke out tiff reading and writing to its own library
* moved tiff includes to include/sls
* moved tiffio source to src
* removed incorrectly used bps
* cleanup and tests for tiffio
* removed using namespace std from header
* some fixing for moench04
* Program for offline processing renamed

Co-authored-by: Anna Bergamaschi <anna.bergamaschi@psi.ch>
This commit is contained in:
Erik Fröjdh 2022-01-27 10:24:02 +01:00 committed by GitHub
parent 379d08dd03
commit f6e76145c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 4948 additions and 2143 deletions

View File

@ -56,6 +56,18 @@ option(SLS_TUNE_LOCAL "tune to local machine" OFF)
option(SLS_DEVEL_HEADERS "install headers for devel" OFF) option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF) option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF)
#Convenience option to switch off defaults when building Moench binaries only
option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF)
if(SLS_BUILD_ONLY_MOENCH)
message(STATUS "Build MOENCH binaries only!")
set(SLS_BUILD_SHARED_LIBRARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
set(SLS_USE_TEXTCLIENT OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
set(SLS_USE_DETECTOR OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
set(SLS_USE_RECEIVER OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
set(SLS_USE_RECEIVER_BINARIES OFF CACHE BOOL "Disabled for MOENCH_ONLY" FORCE)
set(SLS_USE_MOENCH ON CACHE BOOL "Enable" FORCE)
endif()
set(ClangFormat_EXCLUDE_PATTERNS "build/" set(ClangFormat_EXCLUDE_PATTERNS "build/"
"libs/" "libs/"
@ -263,6 +275,7 @@ if(SLS_BUILD_DOCS)
endif(SLS_BUILD_DOCS) endif(SLS_BUILD_DOCS)
if(SLS_USE_MOENCH) if(SLS_USE_MOENCH)
add_subdirectory(slsDetectorCalibration/tiffio)
add_subdirectory(slsDetectorCalibration/moenchExecutables) add_subdirectory(slsDetectorCalibration/moenchExecutables)
endif(SLS_USE_MOENCH) endif(SLS_USE_MOENCH)

View File

@ -21,9 +21,10 @@ fi
if [ -f "$infile" ] if [ -f "$infile" ]
then then
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ; dir=$(dirname $infile)
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir;
echo compiling echo compiling
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ; echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c -I$dir;
$exe ; $exe ;
echo cleaning echo cleaning
rm $exe rm $exe

View File

@ -3,33 +3,33 @@
### edit with hostname or IP address of your detector ### edit with hostname or IP address of your detector
############################################ ############################################
#hostname bchip181+ #hostname bchip181+
hostname bchip181+ hostname bchip119.psi.ch
############################################# #############################################
### edit with hostname or 1Gbs IP address of your server ### edit with hostname or 1Gbs IP address of your server
############################################ ############################################
rx_hostname mpc2011 rx_hostname mpc2011:1777
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
udp_dstip 10.1.1.102 udp_dstip 10.1.2.102
############################################# #############################################
### edit with any number in the subnet of your server (first 3 numbers as above) ### edit with any number in the subnet of your server (first 3 numbers as above)
############################################ ############################################
udp_srcip 10.1.1.19 udp_srcip 10.1.2.19
udp_dstport 32411 udp_dstport 32000
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
rx_zmqip 10.1.1.102 rx_zmqip 10.1.2.102
rx_zmqport 50003 rx_zmqport 77000
############################################# #############################################
### edit with 1 Gbs IP of PC where you will run the GUI ### edit with 1 Gbs IP of PC where you will run the GUI
############################################ ############################################
zmqip 129.129.202.98 zmqip 129.129.202.132
zmqport 50001 zmqport 77001
@ -38,7 +38,7 @@ rx_zmqstream 1
frames 100000 frames 1000
period 0.0006 period 0.0006
exptime 0.00035 exptime 0.00035
@ -62,3 +62,9 @@ highvoltage 90
#adcreg 0x14 0x40 #adcreg 0x14 0x40
frames 10
period 0.1
rx_jsonpara subframes 1
rx_jsonpara frameMode raw
rx_jsonpara detectorMode analog

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
#include "pedestalSubtraction.h" #include "pedestalSubtraction.h"
#include "slsDetectorData.h" #include "slsDetectorData.h"
#include "slsInterpolation.h" #include "slsInterpolation.h"
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <pthread.h> #include <pthread.h>
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM

View File

@ -107,8 +107,8 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
#endif #endif
if (dataMap[row][col] < 0 || if (dataMap[row][col] < 0 ||
dataMap[row][col] >= nSamples * 2 * 32) dataMap[row][col] >= nSamples * 2 * 32)
cout << "Error: pointer " << dataMap[row][col] std::cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << endl; << " out of range " << std::endl;
} }
} }
} }
@ -120,7 +120,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
ghost[iy][ix] = 0.; ghost[iy][ix] = 0.;
int ipacket; int ipacket;
int ibyte; uint ibyte;
int ii = 0; int ii = 0;
for (ibyte = 0; ibyte < sizeof(sls_detector_header) / 2; ibyte++) { for (ibyte = 0; ibyte < sizeof(sls_detector_header) / 2; ibyte++) {
xmap[ibyte] = -1; xmap[ibyte] = -1;
@ -298,17 +298,17 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
/* return NULL; */ /* return NULL; */
/* }; */ /* }; */
virtual char *readNextFrame(ifstream &filebin) { virtual char *readNextFrame(std::ifstream &filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(ifstream &filebin, int &ff) { virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
int np = -1; int np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) { virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
char *data = new char[dataSize]; char *data = new char[dataSize];
char *d = readNextFrame(filebin, ff, np, data); char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) { if (d == NULL) {
@ -318,17 +318,13 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
return data; return data;
} }
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np, virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
char *data) { char *data) {
char *retval = 0;
int nd;
int fnum = -1;
np = 0; np = 0;
int pn;
// cout << dataSize << endl; // cout << dataSize << endl;
if (ff >= 0)
fnum = ff;
if (filebin.is_open()) { if (filebin.is_open()) {
if (filebin.read(data, dataSize)) { if (filebin.read(data, dataSize)) {

View File

@ -29,7 +29,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
moench03T1ZmqDataNew(int ns = 5000, int oo = 2 * 2) moench03T1ZmqDataNew(int ns = 5000, int oo = 2 * 2)
: slsDetectorData<uint16_t>(400, 400, ns * 32 * 2 + oo), nSamples(ns), : slsDetectorData<uint16_t>(400, 400, ns * 32 * 2 + oo), nSamples(ns),
offset(oo), xtalk(0.00021) { offset(oo), xtalk(0.00021) {
cout << "M0.3" << endl; std::cout << "M0.3" << std::endl;
int nadc = 32; int nadc = 32;
int sc_width = 25; int sc_width = 25;
int sc_height = 200; int sc_height = 200;
@ -70,8 +70,8 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
dataMap[row][col] = dataMap[row][col] =
(nadc * i + iadc) * 2 + offset; //+16*(ip+1); (nadc * i + iadc) * 2 + offset; //+16*(ip+1);
if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize) if (dataMap[row][col] < 0 || dataMap[row][col] >= dataSize)
cout << "Error: pointer " << dataMap[row][col] std::cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << endl; << " out of range " << std::endl;
} }
} }
} }
@ -260,17 +260,17 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
/* return NULL; */ /* return NULL; */
/* }; */ /* }; */
virtual char *readNextFrame(ifstream &filebin) { virtual char *readNextFrame(std::ifstream &filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(ifstream &filebin, int &ff) { virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
int np = -1; int np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
}; };
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np) { virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
char *data = new char[32 * 2 * nSamples]; char *data = new char[32 * 2 * nSamples];
char *d = readNextFrame(filebin, ff, np, data); char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) { if (d == NULL) {
@ -280,7 +280,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
return data; return data;
} }
virtual char *readNextFrame(ifstream &filebin, int &ff, int &np, virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
char *data) { char *data) {
// char *retval=0; // char *retval=0;
// int nd; // int nd;

View File

@ -3,50 +3,9 @@
#ifndef MOENCH04ZMQ10GBDATA_H #ifndef MOENCH04ZMQ10GBDATA_H
#define MOENCH04ZMQ10GBDATA_H #define MOENCH04ZMQ10GBDATA_H
#include "slsDetectorData.h" #include "slsDetectorData.h"
#include "sls/sls_detector_defs.h"
#ifndef SLS_DETECTOR_HEADER using namespace std;
#define SLS_DETECTOR_HEADER
//#define VERSION_V2
/**
@short structure for a Detector Packet or Image Header
@li frameNumber is the frame number
@li expLength is the subframe number (32 bit eiger) or real time exposure
time in 100ns (others)
@li packetNumber is the packet number
@li bunchId is the bunch id from beamline
@li timestamp is the time stamp with 10 MHz clock
@li modId is the unique module id (unique even for left, right, top, bottom)
@li xCoord is the x coordinate in the complete detector system
@li yCoord is the y coordinate in the complete detector system
@li zCoord is the z coordinate in the complete detector system
@li debug is for debugging purposes
@li roundRNumber is the round robin set number
@li detType is the detector type see :: detectorType
@li version is the version number of this structure format
*/
typedef struct {
uint64_t frameNumber; /**< is the frame number */
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time
exposure time in 100ns (others) */
uint32_t packetNumber; /**< is the packet number */
uint64_t bunchId; /**< is the bunch id from beamline */
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
uint16_t modId; /**< is the unique module id (unique even for left, right,
top, bottom) */
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
uint32_t debug; /**< is for debugging purposes */
uint16_t roundRNumber; /**< is the round robin set number */
uint8_t detType; /**< is the detector type see :: detectorType */
uint8_t version; /**< is the version number of this structure format */
uint64_t
packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
#endif
class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> { class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
private: private:
@ -68,67 +27,40 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
// moench04CtbZmq10GbData(int nas=5000, int nds=0): // moench04CtbZmq10GbData(int nas=5000, int nds=0):
// slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), // slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas),
// dSamples(nds), nadc(32), sc_width(25), sc_height(200) { // dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
#ifndef RAWDATA
moench04CtbZmq10GbData(int nas = 5000, int nds = 0)
: slsDetectorData<uint16_t>(400, 400,
(nas > 0) && (nds > 0)
? max(nas, nds) * (32 * 2 + 8)
: nas * 32 * 2 + nds * 8),
nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
int off = 0;
#endif
#ifdef RAWDATA
moench04CtbZmq10GbData(int nas = 5000, int nds = 0) moench04CtbZmq10GbData(int nas = 5000, int nds = 0)
: slsDetectorData<uint16_t>(400, 400, : slsDetectorData<uint16_t>(400, 400,
sizeof(sls_detector_header) + #ifdef RAWDATA
sizeof(slsDetectorDefs::sls_receiver_header) +
#endif
((nas > 0) && (nds > 0) ((nas > 0) && (nds > 0)
? max(nas, nds) * (32 * 2 + 8) ? max(nas, nds) * (32 * 2 + 8)
: nas * 32 * 2 + nds * 8)), : nas * 32 * 2 + nds * 8)),
nadc(32), sc_width(25), sc_height(200), aSamples(nas), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
dSamples(nds) { #ifdef RAWDATA
int off = sizeof(sls_detector_header); off=sizeof(slsDetectorDefs::sls_receiver_header);
cout << "hh" << dataSize << endl; #endif
cout << sizeof(sls_detector_header) + #ifndef RAWDATA
((nas > 0) && (nds > 0) ? max(nas, nds) * (32 * 2 + 8) #ifndef CTB
: nas * 32 * 2 + nds * 8) off=sizeof(int);
<< endl; #endif
#ifdef CTB
off=0;
#endif
#endif #endif
/* int ds; */
/* if (nas && nds) */
/* if (nds>nas) */
/* ds=nds*(32*2+8); */
/* else */
/* ds=nas*(32*2+8); */
/* else */
/* ds=nas*32*2+nds*8; */
/* new slsDetectorData<uint16_t>(400, 400, ds); */
cout << "off is " << off << endl;
if (off>0)
cout << "M04 RAW DATA NEW " << endl;
else
cout << "M04 ZMQ DATA NEW " << endl;
int adc_nr[32] = {9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3, int adc_nr[32] = {9, 8, 11, 10, 13, 12, 15, 14, 1, 0, 3,
2, 5, 4, 7, 6, 23, 22, 21, 20, 19, 18, 2, 5, 4, 7, 6, 23, 22, 21, 20, 19, 18,
17, 16, 31, 30, 29, 28, 27, 26, 25, 24}; 17, 16, 31, 30, 29, 28, 27, 26, 25, 24};
/*
iadc=ptr%32
isample=ptr/32
col=(adc_nr[iadc]%16)*25+isample%25
if (adc_nr[iadc]<16)
row=199-isample/25;
else
row=200+isample/25
adc0 col(9*25..10*25-1) row(199..0)
adc1 col(8*25..9*25-1) row(199..0)
adc2 col(11*25..12*25-1) row(199..0)
adc3 col(10*25..11*25-1) row(199..0)
adc4 col(13*25..14*25-1) row(199..0)
adc5 col(12*25..13*25-1) row(199..0)
adc6 col(15*25..16*25-1) row(199..0)
adc7 col(14*25..15*25-1) row(199..0)
adc8 col(1*25..2*25-1) row(199..0)
*/
int row, col; int row, col;
@ -168,39 +100,11 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
/* } */
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe = 0; iframe = 0;
// cout << "data struct created" << endl; // cout << "data struct created" << endl;
} }
int getGain(char *data, int x, int y) { int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32; // int aoff=aSamples*2*32;
@ -253,10 +157,12 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
/* unsigned char bunchid[8]; */ /* unsigned char bunchid[8]; */
/* }; */ /* }; */
#ifdef RAWDATA
int getFrameNumber(char *buff) { int getFrameNumber(char *buff) {
return ((sls_detector_header *)buff)->frameNumber; #ifdef RAWDATA
}; //*((int*)(buff+5))&0xffffff;}; return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.frameNumber;
#endif
return (int)(*buff);
};
/** /**
@ -268,76 +174,15 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
*/ */
int getPacketNumber(char *buff) { int getPacketNumber(char *buff) {
return ((sls_detector_header *)buff)->packetNumber; #ifdef RAWDATA
} //((*(((int*)(buff+4))))&0xff)+1;}; return ((slsDetectorDefs::sls_receiver_header *)buff)->detHeader.packetNumber;
#endif #endif
#ifndef RAWDATA return 0;
int getFrameNumber(char *buff) { }
return iframe;
}; //((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
#endif
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
// int getPacketNumber(char *buff){return
// ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* 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 data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the
* frame, in case the frame is incomplete at the end of the memory slot
*/
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might
* be incomplete if ndata smaller than dataSize), or NULL if no frame is
* found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int
* dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e.
* all packets 0 to nPackets, same frame number). Can be overloaded for
* different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no
* frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream & filebin) { virtual char *readNextFrame(ifstream & filebin) {
int ff = -1, np = -1; int ff = -1, np = -1;
return readNextFrame(filebin, ff, np); return readNextFrame(filebin, ff, np);
@ -358,11 +203,12 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
return data; return data;
} }
#ifndef RAWDATA
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np, virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) { char *data) {
// char *retval=0; // char *retval=0;
#ifndef RAWDATA
// int nd; // int nd;
// int fnum = -1; // int fnum = -1;
np = 0; np = 0;
@ -380,19 +226,13 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
return NULL; return NULL;
};
#endif #endif
#ifdef RAWDATA #ifdef RAWDATA
//int nd;
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
char *retval = 0;
int nd;
int fnum = -1; int fnum = -1;
np = 0; np = 0;
int pn; //int pn;
// cout << dataSize << endl; // cout << dataSize << endl;
if (ff >= 0) if (ff >= 0)
@ -406,9 +246,9 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
} }
} }
return NULL; return NULL;
};
#endif #endif
};
/** /**
@ -433,3 +273,4 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
}; };
#endif #endif

View File

@ -0,0 +1,216 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MOENCHDATA_H
#define MOENCHDATA_H
#include "slsDetectorData.h"
#include "sls/sls_detector_defs.h"
using namespace std;
class moenchData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
int off;
int *adc_nr;
int *ibit;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
1286 large etc.) \param c crosstalk parameter for the output buffer
*/
moenchData(int off, int nadc_i, int *adc_nr_in, int *ibit_in, int nas = 5000, int nds = 0, int nx_i=400, int ny_i=400)
: nadc(nadc_i), slsDetectorData<uint16_t>(nx_i, ny_i,off+((nas > 0) && (nds > 0)
? max(nas, nds) * (nadc_i * 2 + 8)
: nas * nadc_i * 2 + nds * 8)),
sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
adc_nr=new int[nadc];
if (ibit_in)
ibit=new int[nadc];
else
ibit=NULL;
for (iadc=0; iadc<nadc; iadc++) {
adc_nr[iadc]=adc_nr_in[iadc];
if (ibit)
ibit[iadc]=ibit_in[iadc];
}
int row, col;
int iadc;
int i;
for (int is = 0; is < aSamples; is++) {
for (iadc = 0; iadc < nadc; iadc++) {
i = is;
// adc4=(int)iadc/4;
if (i < sc_width * sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col = (adc_nr[iadc] % 16) * sc_width + (i % sc_width);
// if (adc4%2==0) {
if (iadc < 16) {
row = 199 - i / sc_width;
} else {
row = 200 + i / sc_width;
}
if (nds > 0)
dataMap[row][col] =
((nadc + 4) * i + iadc) * 2 + off; //+16*(ip+1);
else
dataMap[row][col] =
(nadc * i + iadc) * 2 + off; //+16*(ip+1);
if (dataMap[row][col] < 0 ||
dataMap[row][col] >= aSamples * 2 * 32 + off)
cout << "Error: pointer " << dataMap[row][col]
<< " out of range " << endl;
}
}
}
iframe = 0;
}
virtual int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32;
if (ibit) {
int irow;
int isc = x / sc_width;
int icol = x % sc_width;
if (y < 200)
irow = sc_height - 1 - y;
else {
irow = y - sc_height;
isc++;
}
int isample = irow * sc_width + icol;
uint64_t sample;
char *ptr;
if (isc < 0 || isc >= 32)
return 0;
if (ibit[isc] < 0 || ibit[isc] >= 64)
return 0;
if (dSamples > isample) {
ptr = data + 32 * (isample + 1) + 8 * isample;
sample = *((uint64_t *)ptr);
if (sample & (1 << ibit[isc]))
return 1;
}
}
return 0;
}
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
int getFrameNumber(char *buff) {
return (int* buff)[0];
};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
int getPacketNumber(char *buff) {
return 0;
}
virtual char *readNextFrame(ifstream & filebin) {
int ff = -1, np = -1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream & filebin, int &ff) {
int np = -1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np) {
char *data = new char[dataSize];
char *d = readNextFrame(filebin, ff, np, data);
if (d == NULL) {
delete[] data;
data = NULL;
}
return data;
}
virtual char *readNextFrame(ifstream & filebin, int &ff, int &np,
char *data) {
char *retval = 0;
int nd;
int fnum = -1;
np = 0;
int pn;
// cout << dataSize << endl;
//if (ff >= 0)
// fnum = ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize)) {
ff = getFrameNumber(data);
np = getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
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
data pointer to the memory to be analyzed \param ndata reference to
the amount of data found for the frame, in case the frame is
incomplete at the end of the memory slot \param dsize size of the
memory slot to be analyzed \returns pointer to the beginning of the
last good frame (might be incomplete if ndata smaller than dataSize),
or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize) {
if (dsize < dataSize)
ndata = dsize;
else
ndata = dataSize;
return data;
}
};
#endif

View File

@ -4,11 +4,8 @@
#define SLSDETECTORDATA_H #define SLSDETECTORDATA_H
#include <fstream> #include <fstream>
#include <inttypes.h>
#include <iostream> #include <iostream>
using namespace std;
template <class dataType> class slsDetectorData { template <class dataType> class slsDetectorData {
protected: protected:
@ -369,7 +366,7 @@ template <class dataType> class slsDetectorData {
is incomplete is incomplete
*/ */
virtual char *readNextFrame(ifstream &filebin) = 0; virtual char *readNextFrame(std::ifstream &filebin) = 0;
}; };
#endif #endif

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H #ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
#define ETA_INTERPOLATION_ADAPTIVEBINS_H #define ETA_INTERPOLATION_ADAPTIVEBINS_H
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <cmath> #include <cmath>
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationPosXY.h" #include "etaInterpolationPosXY.h"

View File

@ -10,7 +10,7 @@
#include <TTree.h> #include <TTree.h>
#endif #endif
#include "slsInterpolation.h" #include "slsInterpolation.h"
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <cmath> #include <cmath>
class etaInterpolationBase : public slsInterpolation { class etaInterpolationBase : public slsInterpolation {

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H #ifndef ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
#define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H #define ETA_INTERPOLATION_CLEVER_ADAPTIVEBINS_H
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <cmath> #include <cmath>
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationAdaptiveBins.h" #include "etaInterpolationAdaptiveBins.h"

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_POSXY_H #ifndef ETA_INTERPOLATION_POSXY_H
#define ETA_INTERPOLATION_POSXY_H #define ETA_INTERPOLATION_POSXY_H
//#include "tiffIO.h" //#include "sls/tiffIO.h"
#include "eta2InterpolationBase.h" #include "eta2InterpolationBase.h"
#include "eta3InterpolationBase.h" #include "eta3InterpolationBase.h"
#include "etaInterpolationBase.h" #include "etaInterpolationBase.h"

View File

@ -3,7 +3,7 @@
#ifndef ETA_INTERPOLATION_RANDOMBINS_H #ifndef ETA_INTERPOLATION_RANDOMBINS_H
#define ETA_INTERPOLATION_RANDOMBINS_H #define ETA_INTERPOLATION_RANDOMBINS_H
#include "tiffIO.h" #include "sls/tiffIO.h"
//#include "etaInterpolationBase.h" //#include "etaInterpolationBase.h"
#include "etaInterpolationPosXY.h" #include "etaInterpolationPosXY.h"
#include <algorithm> #include <algorithm>

View File

@ -5,7 +5,7 @@
#include <cstdlib> #include <cstdlib>
#ifndef MY_TIFF_IO_H #ifndef MY_TIFF_IO_H
#include "tiffIO.h" #include "sls/tiffIO.h"
#endif #endif
#ifndef DEF_QUAD #ifndef DEF_QUAD

View File

@ -23,7 +23,7 @@
#endif #endif
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>

View File

@ -20,7 +20,7 @@ class commonModeSubtractionColumn : public commonModeSubtraction {
mean2[iroi] += val * val; mean2[iroi] += val * val;
nCm[iroi]++; nCm[iroi]++;
if (nCm[iroi] > rows) if (nCm[iroi] > rows)
cout << "Too many pixels added " << nCm[iroi] << endl; std::cout << "Too many pixels added " << nCm[iroi] << std::endl;
/* if (ix==10 && iy<20) */ /* if (ix==10 && iy<20) */
/* cout << " ** "<<val << " " << mean[iroi] << " " << /* cout << " ** "<<val << " " << mean[iroi] << " " <<
* nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */ * nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */

View File

@ -1,19 +1,53 @@
# SPDX-License-Identifier: LGPL-3.0-or-other # SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package # Copyright (C) 2021 Contributors to the SLS Detector Package
find_package(TIFF REQUIRED)
set(MOENCH_EXECUTABLES)
#Moench ZMQ #Moench ZMQ
add_executable(moenchZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp) add_executable(moench03ZmqProcess moenchZmqProcess.cpp)
target_compile_definitions(moenchZmqProcess PRIVATE NEWZMQ INTERP) target_compile_definitions(moench03ZmqProcess PRIVATE NEWZMQ INTERP)
list(APPEND MOENCH_EXECUTABLES moench03ZmqProcess)
#Moench HighZ ZMQ
add_executable(moenchHighZZmqProcess moenchZmqProcess.cpp)
target_compile_definitions(moenchHighZZmqProcess PRIVATE NEWZMQ INTERP HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchHighZZmqProcess)
#Moench04 ZMQ #Moench04 ZMQ
add_executable(moench04ZmqProcess moenchZmqProcess.cpp ../tiffIO.cpp) add_executable(moench04ZmqProcess moenchZmqProcess.cpp)
target_compile_definitions(moench04ZmqProcess PRIVATE NEWZMQ INTERP MOENCH04) target_compile_definitions(moench04ZmqProcess PRIVATE NEWZMQ INTERP MOENCH04)
list(APPEND MOENCH_EXECUTABLES moench04ZmqProcess)
#Both executables should have the same includes and output dirs #OFFLINE Processing?
set(MOENCH_EXECUTABLES "moenchZmqProcess" "moench04ZmqProcess") add_executable(moench03RawDataProcess moenchRawDataProcess.cpp)
target_compile_definitions(moench03RawDataProcess PRIVATE)
list(APPEND MOENCH_EXECUTABLES moench03RawDataProcess)
add_executable(moenchHighZRawDataProcess moenchRawDataProcess.cpp)
target_compile_definitions(moenchHighZRawDataProcess PRIVATE HIGHZ)
list(APPEND MOENCH_EXECUTABLES moenchHighZRawDataProcess)
add_executable(moench04RawDataProcess moenchRawDataProcess.cpp)
target_compile_definitions(moench04RawDataProcess PRIVATE MOENCH04)
list(APPEND MOENCH_EXECUTABLES moench04RawDataProcess)
#interpolation stuff
add_executable(moench03MakeEta moench03Interpolation.cpp)
target_compile_definitions(moench03MakeEta PRIVATE FF)
list(APPEND MOENCH_EXECUTABLES moench03MakeEta)
add_executable(moench03Interpolation moench03Interpolation.cpp)
#no compile defs
list(APPEND MOENCH_EXECUTABLES moench03Interpolation)
add_executable(moench03NoInterpolation moench03NoInterpolation.cpp)
#no compile defs
list(APPEND MOENCH_EXECUTABLES moench03NoInterpolation)
foreach(exe ${MOENCH_EXECUTABLES}) foreach(exe ${MOENCH_EXECUTABLES})
#TODO! At a later stage clean up include dirs and have a proper lib #TODO! At a later stage clean up include dirs and have a proper lib
@ -22,6 +56,7 @@ foreach(exe ${MOENCH_EXECUTABLES})
../dataStructures ../dataStructures
../interpolations ../interpolations
../../slsReceiverSoftware/include/ ../../slsReceiverSoftware/include/
../../slsSupportLib/include/
) )
target_link_libraries(${exe} target_link_libraries(${exe}
@ -29,10 +64,11 @@ foreach(exe ${MOENCH_EXECUTABLES})
slsSupportStatic slsSupportStatic
${ZeroMQ_LIBRARIES} ${ZeroMQ_LIBRARIES}
pthread pthread
TIFF::TIFF tiffio
PRIVATE PRIVATE
slsProjectWarnings slsProjectWarnings
slsProjectOptions
) )
@ -44,8 +80,6 @@ foreach(exe ${MOENCH_EXECUTABLES})
endif() endif()
endforeach(exe ${MOENCH_EXECUTABLES}) endforeach(exe ${MOENCH_EXECUTABLES})
install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin) install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin)

View File

@ -1,49 +0,0 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
#module add CBFlib/0.9.5
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11
MAIN=moench03ClusterFinder.cpp
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinderHighZ moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DHIGHZ
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounterHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog

View File

@ -1,26 +0,0 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
#-L../../bin -lhdf5 -L.
#DESTDIR?=../bin
all: moenchZmqProcess
#moenchZmq04Process
#moenchZmqProcessCtbGui
moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
#moenchZmq04Process: moenchZmqProcess.cpp clean#
# g++ -o moench04ZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DMOENCH04
#moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
# g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean:
rm -f moenchZmqProcess

View File

@ -1,219 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
//#include "sls/ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#ifndef RECT
#include "moench03T1ReceiverDataNew.h"
#endif
#ifdef RECT
#include "moench03T1ReceiverDataNewRect.h"
#endif
#endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
#ifdef REORDERED
#include "moench03T1ReorderedData.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <fstream>
#include <map>
#include <stdio.h>
#include <sys/stat.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc < 6) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax "
<< endl;
return 1;
}
int p = 10000;
int fifosize = 1000;
int nthreads = 1;
int nsubpix = 25;
int etabins = nsubpix * 10;
double etamin = -1, etamax = 2;
int csize = 3;
int nx = 400, ny = 400;
int save = 1;
int nsigma = 5;
int nped = 1000;
int ndark = 100;
int ok;
int iprog = 0;
#ifdef NEWRECEIVER
#ifdef RECT
cout << "Should be rectangular!" << endl;
#endif
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
cout << "RECEIVER DATA WITH ONE HEADER!" << endl;
#endif
#ifdef CSAXS_FP
moench03T1ReceiverData *decoder = new moench03T1ReceiverData();
cout << "RECEIVER DATA WITH ALL HEADERS!" << endl;
#endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder = new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!" << endl;
#endif
#ifdef REORDERED
moench03T1ReorderedData *decoder = new moench03T1ReorderedData();
cout << "REORDERED DATA!" << endl;
#endif
decoder->getDetectorSize(nx, ny);
cout << "nx " << nx << " ny " << ny << endl;
// moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter =
new singlePhotonDetector(decoder, csize, nsigma, 1, 0, nped, 200);
// char tit[10000];
cout << "filter " << endl;
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680; ////atoi(argv[3]);
int *image;
// int* image =new int[327680/sizeof(int)];
filter->newDataSet();
int ff, np;
int dsize = decoder->getDataSize();
cout << " data size is " << dsize;
char data[dsize];
ifstream filebin;
char *indir = argv[1];
char *outdir = argv[2];
char *fformat = argv[3];
int runmin = atoi(argv[4]);
int runmax = atoi(argv[5]);
char fname[10000];
char outfname[10000];
char imgfname[10000];
char pedfname[10000];
// strcpy(pedfname,argv[6]);
char fn[10000];
std::time_t end_time;
FILE *of = NULL;
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "fileformat is " << fformat << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char *buff;
multiThreadedAnalogDetector *mt =
new multiThreadedAnalogDetector(filter, nthreads, fifosize);
mt->setDetectorMode(ePhotonCounting);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
cout << "mt " << endl;
int ifr = 0;
for (int irun = runmin; irun < runmax; irun++) {
sprintf(fn, fformat, irun);
sprintf(fname, "%s/%s.raw", indir, fn);
sprintf(outfname, "%s/%s.clust", outdir, fn);
sprintf(imgfname, "%s/%s.tiff", outdir, fn);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
cout << fname << " " << outfname << " " << imgfname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()) {
of = fopen(outfname, "w");
if (of) {
mt->setFilePointer(of);
// cout << "file pointer set " << endl;
} else {
cout << "Could not open " << outfname << " for writing "
<< endl;
mt->setFilePointer(NULL);
return 1;
}
// //while read frame
ff = -1;
while (decoder->readNextFrame(filebin, ff, np, buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
// for (int ix=0; ix<400; ix++)
// for (int iy=0; iy<400; iy++) {
// if (decoder->getChannel(buff, ix, iy)<3000 ||
// decoder->getChannel(buff, ix, iy)>8000) {
// cout << ifr << " " << ff << " " << ix << " " << iy <<
// " " << decoder->getChannel(buff, ix, iy) << endl ;
// }
// }
mt->pushData(buff);
// // //pop
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
ifr++;
if (ifr % 10000 == 0)
cout << ifr << " " << ff << endl;
ff = -1;
}
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
while (mt->isBusy()) {
;
} // wait until all data are processed from the queues
if (of)
fclose(of);
mt->writeImage(imgfname);
mt->clearImage();
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open " << fname << " for reading " << endl;
}
return 0;
}

View File

@ -2,43 +2,33 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
//#include "sls/ansi.h" //#include "sls/ansi.h"
#include <iostream> #include <iostream>
#define CORR #undef CORR
#define C_GHOST 0.0004 #define C_GHOST 0.0004
#define CM_ROWS 50 #define CM_ROWS 50
//#define VERSION_V1 #define RAWDATA
//#include "moench03T1ZmqData.h" #ifndef MOENCH04
#ifdef NEWRECEIVER
#ifndef RECT #ifndef RECT
#include "moench03T1ReceiverDataNew.h" #include "moench03T1ReceiverDataNew.h"
#endif #endif
#endif
#ifdef RECT #ifdef RECT
#include "moench03T1ReceiverDataNewRect.h" #include "moench03T1ReceiverDataNewRect.h"
#endif #endif
#ifdef MOENCH04
#include "moench04CtbZmq10GbData.h"
#endif #endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedCountingDetector.h" #include "multiThreadedCountingDetector.h"
//#include "multiThreadedAnalogDetector.h"
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "singlePhotonDetector.h" #include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <fstream> #include <fstream>
#include <map> #include <map>
@ -52,7 +42,7 @@ int main(int argc, char *argv[]) {
if (argc < 4) { if (argc < 4) {
cout << "Usage is " << argv[0] cout << "Usage is " << argv[0]
<< "indir outdir fname [runmin] [runmax] [pedfile] [threshold] " << "indir outdir fname(no extension) [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
"[nframes] [xmin xmax ymin ymax] [gainmap]" "[nframes] [xmin xmax ymin ymax] [gainmap]"
<< endl; << endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; " cout << "threshold <0 means analog; threshold=0 means cluster finder; "
@ -64,55 +54,39 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
int p = 10000;
int fifosize = 1000; int fifosize = 1000;
int nthreads = 10; int nthreads = 10;
int nsubpix = 25;
int etabins = nsubpix * 10;
double etamin = -1, etamax = 2;
int csize = 3; int csize = 3;
int save = 1;
int nsigma = 5; int nsigma = 5;
int nped = 10000; int nped = 10000;
int ndark = 100;
int ok;
int iprog = 0;
int cf = 0; int cf = 0;
#ifdef NEWRECEIVER
#ifdef RECT #ifdef RECT
cout << "Should be rectangular!" << endl; cout << "Should be rectangular but now it will crash! No data structure defined!" << endl;
#endif #endif
#ifndef MOENCH04
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew(); moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
cout << "RECEIVER DATA WITH ONE HEADER!" << endl; cout << "MOENCH03!" << endl;
#endif #endif
#ifdef CSAXS_FP #ifdef MOENCH04
moench03T1ReceiverData *decoder = new moench03T1ReceiverData(); moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData();
cout << "RECEIVER DATA WITH ALL HEADERS!" << endl; cout << "MOENCH04!" << endl;
#endif #endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder = new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!" << endl;
#endif
int nx = 400, ny = 400; int nx = 400, ny = 400;
decoder->getDetectorSize(nx, ny); decoder->getDetectorSize(nx, ny);
#ifdef CORR
int ncol_cm = CM_ROWS; int ncol_cm = CM_ROWS;
double xt_ghost = C_GHOST; double xt_ghost = C_GHOST;
#endif
moench03CommonMode *cm = NULL; moench03CommonMode *cm = NULL;
moench03GhostSummation *gs; moench03GhostSummation *gs;
double *gainmap = NULL; double *gainmap = NULL;
float *gm; //float *gm;
int size = 327680; ////atoi(argv[3]);
int *image;
// int* image =new int[327680/sizeof(int)];
int ff, np; int ff, np;
// cout << " data size is " << dsize; // cout << " data size is " << dsize;
@ -169,7 +143,6 @@ int main(int argc, char *argv[]) {
char fname[10000]; char fname[10000];
char imgfname[10000]; char imgfname[10000];
char cfname[10000]; char cfname[10000];
char fn[10000];
std::time_t end_time; std::time_t end_time;
@ -186,19 +159,6 @@ int main(int argc, char *argv[]) {
cout << "Nframes is " << nframes << endl; cout << "Nframes is " << nframes << endl;
uint32_t nnx, nny; uint32_t nnx, nny;
double *gmap;
// if (gainfname) {
// gm=ReadFromTiff(gainfname, nny, nnx);
// if (gm && nnx==nx && nny==ny) {
// gmap=new double[nx*ny];
// for (int i=0; i<nx*ny; i++) {
// gmap[i]=gm[i];
// }
// delete gm;
// } else
// cout << "Could not open gain map " << gainfname << endl;
// }
#ifdef CORR #ifdef CORR
cout << "Applying common mode " << ncol_cm << endl; cout << "Applying common mode " << ncol_cm << endl;
@ -220,21 +180,15 @@ int main(int argc, char *argv[]) {
} else } else
thr = 0.15 * thr; thr = 0.15 * thr;
filter->newDataSet(); filter->newDataSet();
int dsize = decoder->getDataSize(); //int dsize = decoder->getDataSize();
char data[dsize];
//#ifndef ANALOG
if (thr > 0) { if (thr > 0) {
cout << "threshold is " << thr << endl; cout << "threshold is " << thr << endl;
//#ifndef ANALOG
filter->setThreshold(thr); filter->setThreshold(thr);
//#endif
cf = 0; cf = 0;
} else } else
cf = 1; cf = 1;
//#endif
filter->setROI(xmin, xmax, ymin, ymax); filter->setROI(xmin, xmax, ymin, ymax);
std::time(&end_time); std::time(&end_time);
@ -269,7 +223,7 @@ int main(int argc, char *argv[]) {
int ifr = 0; int ifr = 0;
double ped[nx * ny], *ped1; double *ped=new double[nx * ny];//, *ped1;
if (pedfile) { if (pedfile) {
@ -277,10 +231,10 @@ int main(int argc, char *argv[]) {
sprintf(imgfname, "%s/pedestals.tiff", outdir); sprintf(imgfname, "%s/pedestals.tiff", outdir);
if (string(pedfile).find(".tif") == std::string::npos) { if (string(pedfile).find(".tif") == std::string::npos) {
sprintf(fname, "%s.raw", pedfile); sprintf(fname, "%s", pedfile);
cout << fname << endl; cout << fname << endl;
std::time(&end_time); std::time(&end_time);
cout << "aaa" << std::ctime(&end_time) << endl; //cout << "aaa" << std::ctime(&end_time) << endl;
mt->setFrameMode(ePedestal); mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun); // sprintf(fn,fformat,irun);
@ -310,18 +264,12 @@ int main(int argc, char *argv[]) {
<< " for reading " << endl; << " for reading " << endl;
} else { } else {
float *pp = ReadFromTiff(pedfile, nny, nnx); float *pp = ReadFromTiff(pedfile, nny, nnx);
if (pp && nnx == nx && nny == ny) { if (pp && (int)nnx == nx && (int)nny == ny) {
for (int i = 0; i < nx * ny; i++) { for (int i = 0; i < nx * ny; i++) {
ped[i] = pp[i]; ped[i] = pp[i];
} }
delete[] pp; delete[] pp;
mt->setPedestal(ped); mt->setPedestal(ped);
// ped1=mt->getPedestal();
// for (int i=0; i<nx*ny; i++) {
// cout << ped[i]<<"/"<<ped1[i] << " " ;
// }
cout << "Pedestal set from tiff file " << pedfile << endl; cout << "Pedestal set from tiff file " << pedfile << endl;
} else { } else {
cout << "Could not open pedestal tiff file " << pedfile cout << "Could not open pedestal tiff file " << pedfile
@ -342,11 +290,11 @@ int main(int argc, char *argv[]) {
cout << "DATA "; cout << "DATA ";
// sprintf(fn,fformat,irun); // sprintf(fn,fformat,irun);
sprintf(ffname, "%s/%s.raw", indir, fformat); sprintf(ffname, "%s/%s.raw", indir, fformat);
sprintf(fname, ffname, irun); sprintf(fname, (const char*)ffname, irun);
sprintf(ffname, "%s/%s.tiff", outdir, fformat); sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, ffname, irun); sprintf(imgfname, (const char*)ffname, irun);
sprintf(ffname, "%s/%s.clust", outdir, fformat); sprintf(ffname, "%s/%s.clust", outdir, fformat);
sprintf(cfname, ffname, irun); sprintf(cfname, (const char*)ffname, irun);
cout << fname << " "; cout << fname << " ";
cout << imgfname << endl; cout << imgfname << endl;
std::time(&end_time); std::time(&end_time);
@ -375,13 +323,10 @@ int main(int argc, char *argv[]) {
ifr = 0; ifr = 0;
while (decoder->readNextFrame(filebin, ff, np, buff)) { while (decoder->readNextFrame(filebin, ff, np, buff)) {
if (np == 40) { if (np == 40) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push // //push
mt->pushData(buff); mt->pushData(buff);
// // //pop // // //pop
mt->nextThread(); mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff); mt->popFree(buff);
ifr++; ifr++;
@ -389,15 +334,9 @@ int main(int argc, char *argv[]) {
cout << ifr << " " << ff << endl; cout << ifr << " " << ff << endl;
if (nframes > 0) { if (nframes > 0) {
if (ifr % nframes == 0) { if (ifr % nframes == 0) {
// The name has an additional "_fXXXXX" at the end,
// where "XXXXX" is the initial frame number of the
// image (0,1000,2000...)
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
ifile); ifile);
sprintf(imgfname, ffname, irun); sprintf(imgfname, (const char*)ffname, irun);
// cout << "Writing tiff to " << imgfname << " " <<
// thr1 << endl;
mt->writeImage(imgfname, thr1); mt->writeImage(imgfname, thr1);
mt->clearImage(); mt->clearImage();
ifile++; ifile++;
@ -409,18 +348,16 @@ int main(int argc, char *argv[]) {
} }
cout << "--" << endl; cout << "--" << endl;
filebin.close(); filebin.close();
// //close file
// //join threads
while (mt->isBusy()) { while (mt->isBusy()) {
; ;
} }
if (nframes >= 0) { if (nframes >= 0) {
if (nframes > 0) { if (nframes > 0) {
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile); sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
sprintf(imgfname, ffname, irun); sprintf(imgfname, (const char*)ffname, irun);
} else { } else {
sprintf(ffname, "%s/%s.tiff", outdir, fformat); sprintf(ffname, "%s/%s.tiff", outdir, fformat);
sprintf(imgfname, ffname, irun); sprintf(imgfname, (const char*)ffname, irun);
} }
cout << "Writing tiff to " << imgfname << " " << thr1 << endl; cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1); mt->writeImage(imgfname, thr1);

View File

@ -1,9 +1,9 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
//#define WRITE_QUAD //#define WRITE_QUAD
#define DEVELOPER //#define DEVELOPER
#undef CORR #undef CORR
#undef MOENCH04 //#undef MOENCH04
#define C_GHOST 0.0004 #define C_GHOST 0.0004
@ -11,21 +11,21 @@
#include "sls/ZmqSocket.h" #include "sls/ZmqSocket.h"
#include "sls/sls_detector_defs.h" #include "sls/sls_detector_defs.h"
#ifndef RECT
#ifndef MOENCH04 #ifndef MOENCH04
//#ifndef RECT
#include "moench03T1ZmqDataNew.h" #include "moench03T1ZmqDataNew.h"
//#endif
//#ifdef RECT
//#include "moench03T1ZmqDataNewRect.h"
//#endif
#endif #endif
#ifdef MOENCH04 #ifdef MOENCH04
#include "moench04CtbZmq10GbData.h" #include "moench04CtbZmq10GbData.h"
#endif #endif
#endif
#ifdef RECT
#include "moench03T1ZmqDataNewRect.h"
#endif
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "tiffIO.h" #include "sls/tiffIO.h"
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
int send_something = 0; int send_something = 0;
int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]); int maxSize = npx * npy * 2; // 32*2*8192;//5000;//atoi(argv[3]);
int size = maxSize; // 32*2*5000; int size = maxSize+sizeof(int); // 32*2*5000;
// int multisize=size; // int multisize=size;
// int dataSize=size; // int dataSize=size;
@ -305,10 +305,10 @@ int main(int argc, char *argv[]) {
// header variables // header variables
uint64_t acqIndex = -1; uint64_t acqIndex = -1;
uint64_t frameIndex = -1; uint64_t frameIndex = -1;
#ifdef MOENCH_BRANCH // #ifdef MOENCH_BRANCH
uint32_t subFrameIndex = -1; // uint32_t subFrameIndex = -1;
int *flippedData = 0; // int *flippedData = 0;
#endif // #endif
uint64_t subframes = 0; uint64_t subframes = 0;
// uint64_t isubframe=0; // uint64_t isubframe=0;

View File

@ -1,35 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MY_TIFF_IO_H
#define MY_TIFF_IO_H
#include <fstream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
/*****************************************************************************/
//
// CBFlib must be installed to use this program
//
/*****************************************************************************/
#include <tiffio.h>
#undef cbf_failnez
#define cbf_failnez(x) \
{ \
int err; \
err = (x); \
if (err) { \
fprintf(stderr, "\nCBFlib fatal error %x \n", err); \
exit(-1); \
} \
}
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol);
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol);
#endif

View File

@ -0,0 +1,14 @@
find_package(TIFF REQUIRED)
add_library(tiffio STATIC src/tiffIO.cpp)
target_include_directories(tiffio PUBLIC include/)
target_link_libraries(tiffio
PUBLIC
TIFF::TIFF
PRIVATE
slsProjectWarnings
slsProjectOptions
)
if(SLS_USE_TESTS)
add_subdirectory(tests)
endif()

View File

@ -0,0 +1,16 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include <cstdint>
//Write 32bit float data to tiff file
//Always returns nullptr, prints message on failure
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol);
//Read 32bit float data from tiff file, returns pointer to data and sets
//image dimensions in the out parameters nrow, ncol.
//Returns nullptr on failure
//The caller is responsible to deallocate the memory that the returned
//pointer points to.
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol);

View File

@ -1,26 +1,12 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#ifndef MY_TIFF_IO_H
#include "tiffIO.h" #include "sls/tiffIO.h"
#endif
#include <iostream> #include <iostream>
using namespace std; #include <tiffio.h>
// #undef cbf_failnez
// #define cbf_failnez(x)
// {
// int err;
// err = (x);
// if (err) {
// fprintf(stderr,"\nCBFlib fatal error %x \n",err);
// exit(-1);
// }
// }
void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) { void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) {
int sampleperpixel = 1; constexpr uint32_t sampleperpixel = 1;
// unsigned char * buff=NULL;
// tsize_t linebytes;
// cout << "--" <<endl;
TIFF *tif = TIFFOpen(imgname, "w"); TIFF *tif = TIFFOpen(imgname, "w");
if (tif) { if (tif) {
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncol); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncol);
@ -31,50 +17,32 @@ void *WriteToTiff(float *imgData, const char *imgname, int nrow, int ncol) {
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
// linebytes = sampleperpixel*ncol;
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
TIFFDefaultStripSize(tif, ncol * sampleperpixel)); TIFFDefaultStripSize(tif, ncol * sampleperpixel));
for (int irow = 0; irow < nrow; irow++) { for (int irow = 0; irow < nrow; irow++) {
TIFFWriteScanline(tif, &imgData[irow * ncol], irow, 0); TIFFWriteScanline(tif, &imgData[irow * ncol], irow, 0);
} }
TIFFClose(tif); TIFFClose(tif);
} else } else {
cout << "could not open file " << imgname << " for writing " << endl; std::cout << "could not open file " << imgname << " for writing\n";
}
return NULL; return nullptr;
}; }
float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol) { float *ReadFromTiff(const char *imgname, uint32_t &nrow, uint32_t &ncol) {
// unsigned char * buff=NULL;
TIFF *tif = TIFFOpen(imgname, "r"); TIFF *tif = TIFFOpen(imgname, "r");
if (tif) { if (tif) {
uint32_t bps;
uint32_t sampleperpixel = 1;
// tsize_t linebytes;
uint32_t imagelength;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ncol); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ncol);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &nrow); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &nrow);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
float *imgData = new float[ncol * nrow]; float *imgData = new float[ncol * nrow];
// linebytes = sampleperpixel*ncol; for (uint32_t irow = 0; irow < nrow; ++irow) {
// TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif,
// ncol*sampleperpixel));
for (uint32_t irow = 0; irow < nrow; irow++) {
// tiffreadscanline(tif, buf, row);
TIFFReadScanline(tif, &imgData[irow * ncol], irow); TIFFReadScanline(tif, &imgData[irow * ncol], irow);
} }
TIFFClose(tif); TIFFClose(tif);
return imgData; return imgData;
} else } else {
cout << "could not open file " << imgname << " for reading " << endl; std::cout << "could not open file " << imgname << " for reading\n";
return NULL; return nullptr;
}; }
}

View File

@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-tiffio.cpp
)

View File

@ -0,0 +1,54 @@
#include "catch.hpp"
#include "sls/tiffIO.h"
#include <cstdio>
#include <ftw.h>
#include <iostream>
#include <vector>
/* Call-back to the 'remove()' function called by nftw() */
static int remove_callback(const char *pathname,
__attribute__((unused)) const struct stat *sbuf,
__attribute__((unused)) int type,
__attribute__((unused)) struct FTW *ftwb) {
return remove(pathname);
}
TEST_CASE("Write and read back data from tiff file") {
std::vector<float> data{1, 2, 3, 4, 5, 6, 7, 8, 9};
/* Create the temporary directory */
char tmp[] = "/tmp/tmpdir.XXXXXX";
char *tmp_dirname = mkdtemp(tmp);
if (tmp_dirname == NULL) {
perror("tempdir: error: Could not create tmp directory");
CHECK(false);
}
std::string fname = std::string(tmp_dirname) + std::string("/test.tif");
std::cout << "Writing to: " << fname<< '\n';
WriteToTiff(data.data(), fname.c_str(), 3, 3);
//Readback
uint32_t nrow, ncol;
float* ptr = ReadFromTiff(fname.c_str(), nrow, ncol);
CHECK(nrow == 3);
CHECK(ncol == 3);
uint32_t size = nrow*ncol;
for (uint32_t i = 0; i!=size; ++i){
CHECK(data[i] == ptr[i]);
}
delete[] ptr;
/* Delete the temporary directory */
if (nftw(tmp_dirname, remove_callback, FOPEN_MAX,
FTW_DEPTH | FTW_MOUNT | FTW_PHYS) == -1) {
perror("tempdir: error: ");
exit(EXIT_FAILURE);
}
}

View File

@ -5,4 +5,4 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-CircularFifo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CircularFifo.cpp
) )
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>") target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")

View File

@ -10,12 +10,12 @@ set(SLS_TEST_SOURCES
) )
add_executable(testclient src/testclient.cpp) add_executable(testclient src/testclient.cpp)
target_link_libraries(testclient slsSupportShared) target_link_libraries(testclient slsSupportStatic)
set_target_properties(testclient PROPERTIES set_target_properties(testclient PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_executable(testserver src/testserver.cpp) add_executable(testserver src/testserver.cpp)
target_link_libraries(testserver slsSupportShared) target_link_libraries(testserver slsSupportStatic)
set_target_properties(testserver PROPERTIES set_target_properties(testserver PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -38,10 +38,14 @@ endif (SLS_USE_DETECTOR)
if (SLS_USE_RECEIVER) if (SLS_USE_RECEIVER)
target_link_libraries(tests PUBLIC target_link_libraries(tests PUBLIC
slsReceiverShared slsReceiverStatic
) )
endif (SLS_USE_RECEIVER) endif (SLS_USE_RECEIVER)
if (SLS_USE_MOENCH)
target_link_libraries(tests PUBLIC
tiffio
)
endif()
if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE)
set_property(TARGET tests PROPERTY INTERPROCEDURAL_OPTIMIZATION True) set_property(TARGET tests PROPERTY INTERPROCEDURAL_OPTIMIZATION True)