New Zmq header staructur implemented and works, still different number of pixels in the GUI should be fixed (but it does not crash)

This commit is contained in:
bergamaschi 2018-09-25 09:36:47 +02:00
parent 19e7ced332
commit ae8678cdc2
16 changed files with 1505 additions and 182 deletions

View File

@ -0,0 +1,471 @@
hostname bchip011
patword 0000 0000000000000000
patword 0001 0000000000000000
patword 0002 0008000900080000
patword 0003 0008000900080000
patword 0004 0008000900080000
patword 0005 0008000900080000
patword 0006 0008000900080000
patword 0007 0008000900080000
patword 0008 0008000900080000
patword 0009 0008000900080000
patword 000a 0008000900080000
patword 000b 0008000900080000
patword 000c 0008000900080000
patword 000d 0008000900080000
patword 000e 0008000900080000
patword 000f 0008000900080000
patword 0010 0008000900080000
patword 0011 0008000900080000
patword 0012 0008000900080000
patword 0013 0008000900080000
patword 0014 0008000900080000
patword 0015 0008000900080000
patword 0016 0008400900080020
patword 0017 0008400900080020
patword 0018 0008599f0418503a
patword 0019 0008599f0418503a
patword 001a 0108599f0418503a
patword 001b 0108599f0418503a
patword 001c 0108599f0418503a
patword 001d 0108599f0418503a
patword 001e 0108599f0418503a
patword 001f 0108599f0418503a
patword 0020 0108599f0418503a
patword 0021 0108599f0418503a
patword 0022 0108599f0418503a
patword 0023 0108599f0418503a
patword 0024 0108599f0418503a
patword 0025 0108599f0418503a
patword 0026 0108599f0418503a
patword 0027 0108599f0418503a
patword 0028 0108599f0418503a
patword 0029 0108599f0418503a
patword 002a 0108599f0418503a
patword 002b 0108599f0418503a
patword 002c 0108599f0418503a
patword 002d 0108599f0418503a
patword 002e 0108599f0418503a
patword 002f 0108599f0418503a
patword 0030 0108599f0418503a
patword 0031 0108599f0418503a
patword 0032 0108599f0418503a
patword 0033 0108599f0418503a
patword 0034 0108599f0418503a
patword 0035 0108599f0418503a
patword 0036 0108599f0418503a
patword 0037 0108599f0418503a
patword 0038 0108599f0418503a
patword 0039 0108599f0418503a
patword 003a 0108599f0418503a
patword 003b 0108599f0418503a
patword 003c 0108599f0418503a
patword 003d 0108599f0418503a
patword 003e 0108599f0418503a
patword 003f 0108599f0418503a
patword 0040 0108599f0418503a
patword 0041 0108599f0418503a
patword 0042 0108599f0418503a
patword 0043 0108599f0418503a
patword 0044 0108599f0418503a
patword 0045 0108599f0418503a
patword 0046 0108599f0418503a
patword 0047 0108599f0418503a
patword 0048 0108599f0418503a
patword 0049 0108599f0418503a
patword 004a 0108599f0418503a
patword 004b 0108599f0418503a
patword 004c 0108599f0418503a
patword 004d 0108599f0418503a
patword 004e 0108599f0418503a
patword 004f 0108599f0418503a
patword 0050 0108599f0418503a
patword 0051 0108599f0418503a
patword 0052 0108599f0418503a
patword 0053 0108599f0418503a
patword 0054 0108599f0418503a
patword 0055 0108599f0418503a
patword 0056 0108599f0418503a
patword 0057 0108599f0418503a
patword 0058 0108599f0418503a
patword 0059 0108599f0418503a
patword 005a 0108599f0418503a
patword 005b 0108599f0418503a
patword 005c 0108599f0418503a
patword 005d 0108599f0418503a
patword 005e 0108599f0418503a
patword 005f 0108599f0418503a
patword 0060 0108599f0418503a
patword 0061 0108599f0418503a
patword 0062 0108599f0418503a
patword 0063 0108599f0418503a
patword 0064 0108599f0418503a
patword 0065 0108599f0418503a
patword 0066 0108599f0418503a
patword 0067 0108599f0418503a
patword 0068 0108599f0418503a
patword 0069 0108599f0418503a
patword 006a 0108599f0418503a
patword 006b 0108599f0418503a
patword 006c 0108599f0418503a
patword 006d 0108599f0418503a
patword 006e 0108599f0418503a
patword 006f 0108599f0418503a
patword 0070 0108599f0418503a
patword 0071 0108599f0418503a
patword 0072 0108599f0418503a
patword 0073 0108599f0418503a
patword 0074 0108599f0418503a
patword 0075 0108599f0418503a
patword 0076 0108599f0418503a
patword 0077 0108599f0418503a
patword 0078 0108599f0418503a
patword 0079 0108599f0418503a
patword 007a 0108599f0418503a
patword 007b 0108599f0418503a
patword 007c 0108599f0418503a
patword 007d 0108599f0418503a
patword 007e 010859960418503a
patword 007f 010859960418503a
patword 0080 010859960418503a
patword 0081 010859960418503a
patword 0082 010859960418503a
patword 0083 010859960418503a
patword 0084 010859960418503a
patword 0085 010859960418503a
patword 0086 010859960418503a
patword 0087 010859960418503a
patword 0088 010859960418503a
patword 0089 010859960418503a
patword 008a 010859960418503a
patword 008b 010859960418503a
patword 008c 010859960418503a
patword 008d 010859960418503a
patword 008e 010859960418503a
patword 008f 010859960418503a
patword 0090 010859960418503a
patword 0091 010859960418503a
patword 0092 010819960418501a
patword 0093 010819960418501a
patword 0094 010819960418501a
patword 0095 010819960418501a
patword 0096 030819960418501a
patword 0097 030819960418501a
patword 0098 030819960418501a
patword 0099 030819960418501a
patword 009a 030819960418501a
patword 009b 030819960418501a
patword 009c 030819960418501a
patword 009d 030819960418501a
patword 009e 030819960418501a
patword 009f 030819960418501a
patword 00a0 030819960418501a
patword 00a1 030819960418501a
patword 00a2 030819960418501a
patword 00a3 030819960418501a
patword 00a4 030819960418501a
patword 00a5 030819960418501a
patword 00a6 030819960418501a
patword 00a7 030819960418501a
patword 00a8 030819960418501a
patword 00a9 030819960418501a
patword 00aa 030819960418501a
patword 00ab 030819960418501a
patword 00ac 030819960008501a
patword 00ad 030819960008501a
patword 00ae 030819960008501a
patword 00af 030819960008501a
patword 00b0 030819960008501a
patword 00b1 030819960008501a
patword 00b2 030819960008501a
patword 00b3 030819960008501a
patword 00b4 030819960008501a
patword 00b5 030819960008501a
patword 00b6 030819960008501a
patword 00b7 030819960008501a
patword 00b8 030819960008501a
patword 00b9 030819960008501a
patword 00ba 030819960008501a
patword 00bb 030819960008501a
patword 00bc 030819960008501a
patword 00bd 030819960008501a
patword 00be 030819960008501a
patword 00bf 030819960008501a
patword 00c0 0308199f0008501a
patword 00c1 0308199f0008501a
patword 00c2 0308199f0008501a
patword 00c3 0308199f0008501a
patword 00c4 0308199f0008501a
patword 00c5 0308199f0008501a
patword 00c6 0308199f0008501a
patword 00c7 0308199f0008501a
patword 00c8 0308199f0008501a
patword 00c9 0308199f0008501a
patword 00ca 0308199f0008501a
patword 00cb 0308199f0008501a
patword 00cc 0308199f0008501a
patword 00cd 0308199f0008501a
patword 00ce 0308199f0008501a
patword 00cf 0308199f0008501a
patword 00d0 0308199f0008501a
patword 00d1 0308199f0008501a
patword 00d2 0308199f0008501a
patword 00d3 0308199f0008501a
patword 00d4 0308599f0008503a
patword 00d5 0308599f0008503a
patword 00d6 030c599f000850ba
patword 00d7 030c599f000850ba
patword 00d8 030c599f000850ba
patword 00d9 030c599f000850ba
patword 00da 030c599f000850ba
patword 00db 030c599f000850ba
patword 00dc 030c599f000850ba
patword 00dd 030c599f000850ba
patword 00de 030c599f000850ba
patword 00df 030c599f000850ba
patword 00e0 030c599f000850ba
patword 00e1 030c599f000850ba
patword 00e2 030c599f000850ba
patword 00e3 030c599f000850ba
patword 00e4 030c599f000850ba
patword 00e5 030c599f000850ba
patword 00e6 030c599f000850ba
patword 00e7 030c599f000850ba
patword 00e8 030c599f000850ba
patword 00e9 030c599f000850ba
patword 00ea 030c799f010858ba
patword 00eb 030c799f010858ba
patword 00ec 030c599f000850ba
patword 00ed 030c599f000850ba
patword 00ee 030c599f000850ba
patword 00ef 030c599f000850ba
patword 00f0 030c599f000850ba
patword 00f1 030c599f000850ba
patword 00f2 030c599f000850ba
patword 00f3 030c599f000850ba
patword 00f4 030c599f000850ba
patword 00f5 030c599f000850ba
patword 00f6 030c599f000850ba
patword 00f7 030c599f000850ba
patword 00f8 030c599f000850ba
patword 00f9 030c599f000850ba
patword 00fa 030c599f000850ba
patword 00fb 030c599f000850ba
patword 00fc 030c599f000850ba
patword 00fd 030c599f000850ba
patword 00fe 030c599f000850ba
patword 00ff 030c599f000850ba
patword 0100 030c599f000850ba
patword 0101 030c599f000850ba
patword 0102 030c599f400850ba
patword 0103 030c599f400850ba
patword 0104 030c599f600850ba
patword 0105 030c599f400850ba
patword 0106 030c599f400850ba
patword 0107 030c599f400850ba
patword 0108 870c599f682e50ba
patword 0109 870c599f482850ba
patword 010a 870c599f000e50ba
patword 010b 870c599f000850ba
patword 010c 870c599f000e50ba
patword 010d 870c599f000850ba
patword 010e 870c599f000e50ba
patword 010f 870c599f000850ba
patword 0110 870c599f000e50ba
patword 0111 870c599f000850ba
patword 0112 870c599f000e50ba
patword 0113 870c599f000850ba
patword 0114 870c599f000e50ba
patword 0115 870c599f000850ba
patword 0116 870c599f000e50ba
patword 0117 870c599f000850ba
patword 0118 870c599f000e50ba
patword 0119 870c599f000850ba
patword 011a 870c599f000e50ba
patword 011b 870c599f000850ba
patword 011c 870c599f000e50ba
patword 011d 870c599f000850ba
patword 011e 870c599f000e50ba
patword 011f 870c599f000850ba
patword 0120 870c599f000e50ba
patword 0121 870c599f000850ba
patword 0122 870c599f200e50ba
patword 0123 870c599f000850ba
patword 0124 870c599f000e50ba
patword 0125 870c599f000850ba
patword 0126 870c599f000e50ba
patword 0127 870c599f000850ba
patword 0128 870c599f000e50ba
patword 0129 870c599f000850ba
patword 012a 870c599f000e50ba
patword 012b 870c599f000850ba
patword 012c 870c599f000e50ba
patword 012d 870c599f000850ba
patword 012e 870c599f000e50ba
patword 012f 870c599f000850ba
patword 0130 870c599f000e50ba
patword 0131 870c599f000850ba
patword 0132 870c599f000e50ba
patword 0133 870c599f000850ba
patword 0134 870c599f000e50ba
patword 0135 870c599f000850ba
patword 0136 870c599f000e50ba
patword 0137 870c599f000850ba
patword 0138 870c599f000e50ba
patword 0139 870c599f000850ba
patword 013a 870c599f282e50ba
patword 013b 870c599f082850ba
patword 013c 870c599f000e50ba
patword 013d 870c599f000850ba
patword 013e 870c599f000e50ba
patword 013f 870c599f000850ba
patword 0140 870c599f000e50ba
patword 0141 870c599f000850ba
patword 0142 870c599f000e50ba
patword 0143 870c599f000850ba
patword 0144 870c599f000e50ba
patword 0145 870c599f000850ba
patword 0146 870c599f000e50ba
patword 0147 870c599f000850ba
patword 0148 870c599f000e50ba
patword 0149 870c599f000850ba
patword 014a 870c599f000e50ba
patword 014b 870c599f000850ba
patword 014c 870c599f000e50ba
patword 014d 870c599f000850ba
patword 014e 870c599f000e50ba
patword 014f 870c599f000850ba
patword 0150 870c599f000e50ba
patword 0151 870c599f000850ba
patword 0152 870c599f000e50ba
patword 0153 870c599f000850ba
patword 0154 870c599f200e50ba
patword 0155 870c599f000850ba
patword 0156 870c599f000e50ba
patword 0157 870c599f000850ba
patword 0158 870c599f000e50ba
patword 0159 870c599f000850ba
patword 015a 870c599f000e50ba
patword 015b 870c599f000850ba
patword 015c 870c599f000e50ba
patword 015d 870c599f000850ba
patword 015e 870c599f000e50ba
patword 015f 870c599f000850ba
patword 0160 870c599f000e50ba
patword 0161 870c599f000850ba
patword 0162 870c599f000e50ba
patword 0163 870c599f000850ba
patword 0164 870c599f000e50ba
patword 0165 870c599f000850ba
patword 0166 870c599f000e50ba
patword 0167 870c599f000850ba
patword 0168 870c599f000e50ba
patword 0169 870c599f000850ba
patword 016a 870c599f000e50ba
patword 016b 870c599f000850ba
patword 016c 070c599f000850ba
patword 016d 070c599f000850ba
patword 016e 000c599f000850ba
patword 016f 000c599f000850ba
patword 0170 0008599f200e503a
patword 0171 0008599f0008503a
patword 0172 0008599f200e503a
patword 0173 0008599f0008503a
patword 0174 0008599f0008503a
patword 0175 0008599f0008503a
patword 0176 0008599f0008503a
patword 0177 0008599f0008503a
patword 0178 0008599f0008503a
patword 0179 0008599f0008503a
patword 017a 0008599f0008503a
patword 017b 0008599f0008503a
patword 017c 0008599f0008503a
patword 017d 0008599f0008503a
patword 017e 0008599f0008503a
patword 017f 0008599f0008503a
patword 0180 0008599f0008503a
patword 0181 0008599f0008503a
patword 0182 0008599f0008503a
patword 0183 0008599f0008503a
patword 0184 0008599f0008503a
patword 0185 0008599f0008503a
patword 0186 0008599f0008503a
patword 0187 0008599f0008503a
patword 0188 0008599f0008503a
patword 0189 0008599f0008503a
patword 018a 0008599f0008503a
patword 018b 0008599f0008503a
patword 018c 0008599f0008503a
patword 018d 0008599f0008503a
patioctrl 8f0effff6dbffdbf
patclkctrl 0000000000000000
patlimits 0000 018c
patloop0 013a 016b
patnloop0 199
patloop1 0400 0400
patnloop1 0
patloop2 0400 0400
patnloop2 0
patwait0 00aa
patwaittime0 40000
patwait1 0400
patwaittime1 0
patwait2 0400
patwaittime2 0
0:rx_udpip 10.1.1.102
0:detectorip 10.1.1.19
0:rx_udpport 32410
#0:detectormac 00:ab:bc:cd:de:ef
#0:rx_udpmac 70:10:6f:a0:b5:b1
#gui listening to
zmqip 129.129.202.131
zmqport 30001
#data streaming out of
rx_zmqip 10.1.2.103
rx_zmqport 30003
#turn on datastream from commandline
rx_datastream 1
r_readfreq 1
0:rx_hostname mpc2011
#0:configuremac -1
rx_datastream 1
r_readfreq 1
dac:6 800
dac:0 1300
dac:4 1428
dac:1 1000
dac:7 900
dac:3 680
dac:2 1400
dac:5 1200
adcinvert 4a342593
samples 5000
adcphase 90
adcpipeline 15
adcreg 14 40
powerchip 1
vhighvoltage 90
period 0.005
frames 100
period 0.1
outdir /scratch/
enablefwrite 0

View File

@ -8,6 +8,7 @@
#include "pedestalSubtraction.h"
#include "commonModeSubtraction.h"
#include "tiffIO.h"
#include "slsInterpolation.h"
#ifdef ROOTSPECTRUM
@ -1101,6 +1102,32 @@ FILE *setFilePointer(FILE *f){myFile=f; return myFile;};
\returns current file pointer
*/
FILE *getFilePointer(){return myFile;};
virtual slsInterpolation *getInterpolation(){
return NULL;
};
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){return NULL;}
virtual double setNSigma(double n) {return 0;};
virtual void setEnergyRange(double emi, double ema) {;};
protected:
slsDetectorData<dataType> *det; /**< slsDetectorData to be used */

View File

@ -121,6 +121,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
// int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
/**
@ -199,7 +200,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
int nd;
int fnum = -1;
np=0;
int pn;
int pn, po=0;
char aa[8224];
char *packet=(char *)aa;
// cout << packetSize*nPackets << endl;
@ -219,13 +220,14 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
if (fnum>=0) {
if (getFrameNumber(packet) !=fnum) {
if (getFrameNumber(packet) !=fnum || pn<po) {
if (np==0){
// delete [] data;
return NULL;
} else
filebin.seekg(-8208,ios_base::cur);
po =pn;
return data;
}
if (pn>nPackets) {
@ -234,6 +236,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
memcpy(data+(pn-1)*packetSize, packet, packetSize);
np++;
po =pn;
if (np==nPackets)
break;

View File

@ -90,11 +90,12 @@ class interpolatingDetector : public singlePhotonDetector {
/* writeGainMap(tit); */
/* } */
/* #endif */
if (interp){
pthread_mutex_lock(fi);
if (interp)
interp->prepareInterpolation(ok);
pthread_mutex_unlock(fi);
}
}
void clearImage() {
@ -187,7 +188,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
interp->addToImage(int_x, int_y);
}
}
pthread_mutex_lock(fi);
pthread_mutex_unlock(fi);
}
return nphFrame;
@ -196,11 +197,15 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
virtual void processData(char *data, int *val=NULL) {
switch (dMode) {
case eAnalog:
// cout << "an" << endl;
analogDetector<uint16_t>::processData(data,val);
break;
case ePhotonCounting:
// cout << "spc" << endl;
singlePhotonDetector::processData(data,val);
break;
default:
//cout << "int" << endl;
switch(fMode) {
case ePedestal:
addToPedestal(data);
@ -223,14 +228,20 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
virtual char *getInterpolation(){return (char*)interp;};
virtual char *setInterpolation(char *ii){
virtual slsInterpolation *getInterpolation(){
return interp;
};
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){
int ok;
interp=(slsInterpolation*)ii;
pthread_mutex_lock(fi);
interp=ii;
/* pthread_mutex_lock(fi);
if (interp)
interp->prepareInterpolation(ok);
pthread_mutex_unlock(fi);
return (char*)interp;};
pthread_mutex_unlock(fi); */
cout << "det" << endl;
return interp;
};
virtual void resetFlatField() { if (interp) {
pthread_mutex_lock(fi);

View File

@ -93,7 +93,7 @@ class noInterpolation : public slsInterpolation{
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay){return 0;};
virtual void resetFlatField(){};
protected:
;
// TRandom *eventGenerator;

View File

@ -194,8 +194,8 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
#ifndef MYROOT1
virtual int *getFlatField(){return NULL;};
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
void *writeFlatField(const char * imgname){return NULL;};
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
virtual void *writeFlatField(const char * imgname){return NULL;};
virtual void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
#endif

View File

@ -0,0 +1,242 @@
//#include "ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#include "moench03T1ReceiverDataNew.h"
#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 "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <stdio.h>
#include <map>
#include <fstream>
#include <sys/stat.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc<4) {
cout << "Usage is " << argv[0] << "indir outdir fname [pedfile] [threshold]" << endl;
return 1;
}
int p=10000;
int fifosize=1000;
int nthreads=8;
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
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
#ifndef ANALOG
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
// char tit[10000];
cout << "filter " << endl;
#endif
#ifdef ANALOG
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(decoder, 1, 0, nped);
// char tit[10000];
cout << "filter " << endl;
#endif
// 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];
char *pedfile=NULL;
if (argc>=5) {
pedfile=argv[4];
}
double thr=0;
if (argc>=6) {
thr=atoi(argv[5]);
}
char fname[10000];
char imgfname[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 << "input file is " << fformat << endl;
if (pedfile)
cout << "pedestal file is " << pedfile << endl;
if (thr>0) {
cout << "threshold is " << thr << endl;
filter->setThreshold(thr);
}
filter->setROI(0,150,0,150);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char* buff;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
mt->StartThreads();
mt->popFree(buff);
cout << "mt " << endl;
int ifr=0;
for (int irun=0; irun<2; irun++) {
if (irun>0) {
mt->setFrameMode(eFrame);
// sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,fformat);
// sprintf(outfname,"%s/%s.clust",outdir,fn);
sprintf(imgfname,"%s/%s.tiff",outdir,fformat);
} else {
mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,pedfile);
// sprintf(outfname,"%s/%s.clust",outdir,fn);
// sprintf(imgfname,"%s/%s.tiff",outdir,fn);
}
cout << fname << endl;
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
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);
if (irun>0) {
cout << "Writing tiff to " << imgfname << endl;
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

@ -0,0 +1,326 @@
//#include "ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#include "moench03T1ReceiverDataNew.h"
#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 "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
//#include "interpolatingDetector.h"
#include <stdio.h>
#include <map>
#include <fstream>
#include <sys/stat.h>
#include <ctime>
using namespace std;
int main(int argc, char *argv[]) {
if (argc<4) {
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
return 1;
}
int p=10000;
int fifosize=1000;
int nthreads=8;
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
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
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
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=0;
// cout << "argc is " << argc << endl;
if (argc>=5) {
runmin=atoi(argv[4]);
}
int runmax=runmin;
if (argc>=6) {
runmax=atoi(argv[5]);
}
char *pedfile=NULL;
if (argc>=7) {
pedfile=argv[6];
}
double thr=0;
double thr1=0;
if (argc>=8) {
thr=atoi(argv[7]);
}
int nframes=0;
if (argc>=9) {
nframes=atoi(argv[8]);
}
int xmin=0, xmax=400, ymin=0, ymax=400;
if (argc>=13) {
xmin=atoi(argv[9]);
xmax=atoi(argv[10]);
ymin=atoi(argv[11]);
ymax=atoi(argv[12]);
}
char ffname[10000];
char fname[10000];
char imgfname[10000];
char cfname[10000];
char fn[10000];
std::time_t end_time;
FILE *of=NULL;
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "input file is " << fformat << endl;
cout << "runmin is " << runmin << endl;
cout << "runmax is " << runmax << endl;
if (pedfile)
cout << "pedestal file is " << pedfile << endl;
#ifndef ANALOG
if (thr>0) {
cout << "threshold is " << thr << endl;
filter->setThreshold(thr);
}
#endif
filter->setROI(xmin,xmax,ymin,ymax);
#ifdef SOLEIL
filter->setROI(150,210,170,230);
nframes=-1;
#endif
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
char* buff;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
#ifndef ANALOG
if (thr>=0) {
mt->setDetectorMode(ePhotonCounting);
cout << "Counting!" << endl;
} else
#endif
{
mt->setDetectorMode(eAnalog);
cout << "Analog!" << endl;
#ifdef ANALOG
thr1=thr;
#endif
}
mt->StartThreads();
mt->popFree(buff);
cout << "mt " << endl;
int ifr=0;
if (pedfile) {
cout << "PEDESTAL " ;
sprintf(fname,"%s.raw",pedfile);
cout << fname << endl ;
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
std::time(&end_time);
cout << "aaa" << std::ctime(&end_time) << endl;
mt->setFrameMode(ePedestal);
// sprintf(fn,fformat,irun);
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
ff=-1;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
ifr++;
if (ifr%10000==0)
cout << ifr << " " << ff << " " << np << endl;
ff=-1;
}
filebin.close();
while (mt->isBusy()) {;}
mt->writePedestal(imgfname);
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
ifr=0;
int ifile=0;
for (int irun=runmin; irun<=runmax; irun++) {
cout << "DATA " ;
mt->setFrameMode(eFrame);
// sprintf(fn,fformat,irun);
sprintf(ffname,"%s/%s.raw",indir,fformat);
sprintf(fname,ffname,irun);
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
sprintf(imgfname,ffname,irun);
sprintf(ffname,"%s/%s.clust",outdir,fformat);
sprintf(cfname,ffname,irun);
cout << fname << " " ;
cout << imgfname << endl;
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
ifile=0;
if (filebin.is_open()){
if (thr<=0) {
if (of==NULL) {
of=fopen(cfname,"w");
if (of) {
mt->setFilePointer(of);
cout << "file pointer set " << endl;
} else {
cout << "Could not open "<< cfname << " for writing " << endl;
mt->setFilePointer(NULL);
return 1;
}
}
}
// //while read frame
ff=-1;
ifr=0;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
mt->pushData(buff);
// // //pop
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
ifr++;
if (ifr%1000==0) cout << ifr << " " << ff << endl;
if (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,ifile);
sprintf(imgfname,ffname,irun);
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
ifile++;
}
}
ff=-1;
}
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
while (mt->isBusy()) {;}
if (nframes>=0) {
if (nframes>0) {
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
}
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
sprintf(imgfname,ffname,irun);
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
if (of) {
fclose(of);
of=NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
return 0;
}

View File

@ -229,10 +229,10 @@ int main(int argc, char *argv[]) {
uint16_t yCoord = 0;
uint16_t zCoord = 0;
uint32_t debug = 0;
uint32_t dr = 16;
int16_t *dout;//=new int16_t [nnx*nny];
//uint32_t dr = 32;
//int32_t *dout=new int32_t [nnx*nny];
//uint32_t dr = 16;
//int16_t *dout;//=new int16_t [nnx*nny];
uint32_t dr = 32;
int32_t *dout=NULL;//=new int32_t [nnx*nny];
uint32_t nSigma=5;
uint16_t roundRNumber = 0;
uint8_t detType = 0;
@ -291,32 +291,47 @@ int main(int argc, char *argv[]) {
fclose(of);
of=NULL;
}
if (newFrame>0) {
cprintf(RED,"DIDn't receive any data!\n");
if (send) {
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
cprintf(RED, "Sent Dummy\n");
}
} else {
if (fMode==ePedestal) {
sprintf(ofname,"ped_%s_%d.tiff",fname,fileindex);
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl;
} else if (fMode==eFlat) {
mt->prepareInterpolation(ok);
sprintf(ofname,"eta_%s_%d.tiff",fname,fileindex);
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
mt->writeFlatField(ofname);
} else {
cout << "Writing eta to " << ofname << endl;
}
else {
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
mt->writeImage(ofname);
cout << "Writing image to " << ofname << endl;
}
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
if (send) {
if (fMode==ePedestal) {
cprintf(MAGENTA,"Get pedestal!\n");
nns=1;
nnx=npx;
nny=npy;
dout= new int16_t[nnx*nny*nns*nns];
//dout= new int16_t[nnx*nny*nns*nns];
dout= new int32_t[nnx*nny*nns*nns];
// cout << "get pedestal " << endl;
ped=mt->getPedestal();
// cout << "got pedestal " << endl;
for (int ix=0; ix<nnx*nny; ix++) {
dout[ix]=ped[ix];
// if (ix<100*400)
// cout << ix << " " << ped[ix] << endl;
}
} else if (fMode==eFlat) {
@ -325,19 +340,22 @@ int main(int argc, char *argv[]) {
int *ff=mt->getFlatField(nb, emi, ema);
nnx=nb;
nny=nb;
dout= new int16_t[nb*nb];
dout= new int32_t[nb*nb];
for (int ix=0; ix<nb*nb; ix++) {
dout[ix]=ff[ix];
}
} else {
}
else {
detimage=mt->getImage(nnx,nny,nns);
cprintf(MAGENTA,"Get image!\n");
cout << nnx << " " << nny << " " << nns << endl;
// nns=1;
// nnx=npx;
// nny=npy;
nnx=nnx*nns;
nny=nny*nns;
dout= new int16_t[nnx*nny];
for (int ix=0; ix<nnx*nns; ix++) {
// nnx=nnx*nns;
//nny=nny*nns;
dout= new int32_t[nnx*nny];
for (int ix=0; ix<nnx*nny; ix++) {
// for (int iy=0; iy<nny*nns; iy++) {
// for (int isx=0; isx<nns; isx++) {
// for (int isy=0; isy<nns; isy++) {
@ -350,6 +368,7 @@ int main(int argc, char *argv[]) {
// }
dout[ix]=detimage[ix];
if (dout[ix]<0) dout[ix]=0;
// cout << ix << " " << dout[ix] << endl;
// }
}
}
@ -357,7 +376,7 @@ int main(int argc, char *argv[]) {
#ifdef NEWZMQ
cout << "Sending image size " << nnx << " " << nny << endl;
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
#endif
@ -366,15 +385,17 @@ int main(int argc, char *argv[]) {
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
#endif
zmqsocket2->SendData((char*)dout,length);//nns*dr/8);
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
cprintf(GREEN, "Sent Data\n");
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
cprintf(RED, "Sent Dummy\n");
if (dout)
delete [] dout;
dout=NULL;
}
}
mt->clearImage();
@ -468,10 +489,16 @@ int main(int argc, char *argv[]) {
} else if (frameMode_s == "newFlatfield") {
mt->resetFlatField();
isFlat=1;
//cprintf(MAGENTA, "Resetting flatfield\n");
cprintf(MAGENTA, "Resetting flatfield\n");
fMode=eFlat;
} else
}
else {
fMode=eFrame;
isPedestal=0;
isFlat=0;
fMode=eFrame;
frameMode_s="frame";
}
}
}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
@ -512,12 +539,12 @@ int main(int argc, char *argv[]) {
}
}
cprintf(MAGENTA, "ROI: %d %d %d %d\n", xmin, xmax, ymin, ymax);
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
mt->setROI(xmin, xmax, ymin, ymax);
if (doc.HasMember("dynamicRange")) {
dr=doc["dynamicRange"].GetUint();
dr=16;
dr=32;
}
dMode=eAnalog;
@ -528,58 +555,61 @@ int main(int argc, char *argv[]) {
detectorMode_s=doc["detectorMode"].GetString();
if (detectorMode_s == "interpolating"){
dMode=eInterpolating;
mt->setInterpolation(interp);
} else if (detectorMode_s == "counting"){
dMode=ePhotonCounting;
mt->setInterpolation(NULL);
} else {
dMode=eAnalog;
mt->setInterpolation(NULL);
}
}
}
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
mt->setDetectorMode(dMode);
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
// cout << "done " << endl;
// /* Single Photon Detector commands */
// nSigma=5;
// if (doc.HasMember("nSigma")) {
// if (doc["nSigma"].IsInt())
// nSigma=doc["nSigma"].GetInt();
// mt->setNSigma(nSigma);
// }
/* Single Photon Detector commands */
nSigma=5;
if (doc.HasMember("nSigma")) {
if (doc["nSigma"].IsInt())
nSigma=doc["nSigma"].GetInt();
mt->setNSigma(nSigma);
}
// emin=-1;
// emax=-1;
// if (doc.HasMember("energyRange")) {
// if (doc["energyRange"].IsArray()) {
// if (doc["energyRange"].Size() > 0 )
// if (doc["energyRange"][0].IsInt())
// emin=doc["energyRange"][0].GetInt();
emin=-1;
emax=-1;
if (doc.HasMember("energyRange")) {
if (doc["energyRange"].IsArray()) {
if (doc["energyRange"].Size() > 0 )
if (doc["energyRange"][0].IsInt())
emin=doc["energyRange"][0].GetInt();
// if (doc["energyRange"].Size() > 1 )
// if (doc["energyRange"][1].IsInt())
// emax=doc["energyRange"][1].GetUint();
// }
// }
// if (doc.HasMember("eMin")) {
// if (doc["eMin"][1].IsInt())
// emin=doc["eMin"].GetInt();
// }
// if (doc.HasMember("eMax")) {
// if (doc["eMax"][1].IsInt())
// emin=doc["eMax"].GetInt();
// }
// mt->setEnergyRange(emin,emax);
if (doc["energyRange"].Size() > 1 )
if (doc["energyRange"][1].IsInt())
emax=doc["energyRange"][1].GetUint();
}
}
if (doc.HasMember("eMin")) {
if (doc["eMin"][1].IsInt())
emin=doc["eMin"].GetInt();
}
if (doc.HasMember("eMax")) {
if (doc["eMax"][1].IsInt())
emin=doc["eMax"].GetInt();
}
mt->setEnergyRange(emin,emax);
// /* interpolating detector commands */
/* interpolating detector commands */
if (doc.HasMember("nSubPixels")) {
if (doc["nSubPixels"].IsUint())
nSubPixels=doc["nSubPixels"].GetUint();
mt->setNSubPixels(nSubPixels);
}
// if (doc.HasMember("nSubPixels")) {
// if (doc["nSubPixels"].IsUint())
// nSubPixels=doc["nSubPixels"].GetUint();
// mt->setNSubPixels(nSubPixels);
// }
newFrame=0;
@ -587,6 +617,8 @@ int main(int argc, char *argv[]) {
}
#endif
// cout << "file" << endl;
// cout << "data " << endl;
if (of==NULL) {
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
of=fopen(ofname,"w");
@ -599,7 +631,7 @@ int main(int argc, char *argv[]) {
}
// cout << "data" << endl;
// get data
length = zmqsocket->ReceiveData(0, buff, size);
mt->pushData(buff);

View File

@ -109,7 +109,7 @@ public:
//protected:
/** Implement this method in your subclass with the code you want your thread to run. */
//virtual void InternalThreadEntry() = 0;
virtual void *writeImage(const char * imgname) {cout << "a" <<endl; return det->writeImage(imgname);};
virtual void *writeImage(const char * imgname) {return det->writeImage(imgname);};
virtual void clearImage(){det->clearImage();};
@ -140,6 +140,74 @@ FILE *getFilePointer(){return det->getFilePointer();};
virtual double setNSigma(double n) {return det->setNSigma(n);};
virtual void setEnergyRange(double emi, double ema) {det->setEnergyRange(emi,ema);};
virtual void prepareInterpolation(int &ok){
slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation();
if (interp)
interp->prepareInterpolation(ok);
}
virtual int *getFlatField(){
slsInterpolation *interp=(det)->getInterpolation();
if (interp)
return interp->getFlatField();
else
return NULL;
}
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
slsInterpolation *interp=(det)->getInterpolation();
if (interp)
return interp->setFlatField(ff, nb, emin, emax);
else
return NULL;
}
void *writeFlatField(const char * imgname) {
slsInterpolation *interp=(det)->getInterpolation();
cout << "interp " << interp << endl;
if (interp) {
cout << imgname << endl;
interp->writeFlatField(imgname);
}
}
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
slsInterpolation *interp=(det)->getInterpolation();
if (interp)
interp->readFlatField(imgname, nb, emin, emax);
}
virtual int *getFlatField(int &nb, double emi, double ema){
slsInterpolation *interp=(det)->getInterpolation();
int *ff=NULL;
if (interp) {
ff=interp->getFlatField(nb,emi,ema);
}
return ff;
}
virtual slsInterpolation *getInterpolation() {
return (det)->getInterpolation();
}
virtual void resetFlatField() {
slsInterpolation *interp=(det)->getInterpolation();
if (interp) interp->resetFlatField();//((interpolatingDetector*)det)->resetFlatField();
}
virtual int setNSubPixels(int ns) {
slsInterpolation *interp=(det)->getInterpolation();
if (interp) return interp->setNSubPixels(ns);
else return 1;};
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
return (det)->setInterpolation(f);
};
protected:
analogDetector<uint16_t> *det;
int fMode;
@ -199,9 +267,7 @@ public:
dets[i]=new threadedAnalogDetector(dd[i], fs);
}
int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns);
image=new int[nn];
image=NULL;
ff=NULL;
ped=NULL;
cout << "Ithread is " << ithread << endl;
@ -213,7 +279,7 @@ public:
delete dets[i];
for (int i=1; i<nThreads; i++)
delete dd[i];
delete [] image;
//delete [] image;
}
@ -228,7 +294,14 @@ public:
virtual int *getImage(int &nnx, int &nny, int &ns) {
int *img;
// int nnx, nny, ns;
// int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns);
if (image) {
delete image;
image=NULL;
}
image=new int[nn];
//int nn=dets[0]->getImageSize(nnx, nny, ns);
//for (i=0; i<nn; i++) image[i]=0;
for (int ii=0; ii<nThreads; ii++) {
@ -256,7 +329,7 @@ public:
}
virtual void *writeImage(const char * imgname) {
virtual void *writeImage(const char * imgname, double t=1) {
/* #ifdef SAVE_ALL */
/* for (int ii=0; ii<nThreads; ii++) { */
/* char tit[10000];cout << "m" <<endl; */
@ -271,7 +344,11 @@ public:
float *gm=new float[nn];
if (gm) {
for (int ix=0; ix<nn; ix++) {
if (t)
gm[ix]=(image[ix])/t;
else
gm[ix]=image[ix];
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
}
//cout << "image " << nnx << " " << nny << endl;
@ -314,7 +391,7 @@ public:
}
virtual bool popFree(char* &ptr) {
cout << ithread << endl;
// cout << ithread << endl;
dets[ithread]->popFree(ptr);
}
@ -337,11 +414,19 @@ public:
// cout << i << endl;
p0=dets[i]->getPedestal(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
ped[ib]=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
ped[ib]+=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;

View File

@ -10,17 +10,13 @@
using namespace std;
class threadedCountingDetector : public threadedAnalogDetector
{
public:
threadedCountingDetector(singlePhotonDetector *d, int fs=10000) : threadedAnalogDetector(d,fs) {};
/* class threadedCountingDetector : public threadedAnalogDetector */
/* { */
/* public: */
/* threadedCountingDetector(singlePhotonDetector *d, int fs=10000) : threadedAnalogDetector(d,fs) {}; */
virtual double setNSigma(double n) {return ((singlePhotonDetector*)det)->setNSigma(n);};
virtual void setEnergyRange(double emi, double ema) {return ((singlePhotonDetector*)det)->setEnergyRange(emi,ema);};
};
/* }; */
@ -29,8 +25,8 @@ class multiThreadedCountingDetector : public multiThreadedAnalogDetector
public:
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=((threadedCountingDetector*)dets[i])->setNSigma(n); return ret;};
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) ((threadedCountingDetector*)dets[i])->setEnergyRange(emi,ema);};
virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=(dets[i])->setNSigma(n); return ret;};
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);};
};

View File

@ -10,67 +10,72 @@
using namespace std;
class threadedInterpolatingDetector : public threadedCountingDetector
{
public:
threadedInterpolatingDetector(interpolatingDetector *d, int fs=10000) : threadedCountingDetector(d,fs) {};
/* class threadedInterpolatingDetector : public threadedCountingDetector */
/* { */
/* public: */
/* threadedInterpolatingDetector(interpolatingDetector *d, int fs=10000) : threadedCountingDetector(d,fs) {}; */
virtual void prepareInterpolation(int &ok){
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
if (interp)
interp->prepareInterpolation(ok);
}
/* virtual void prepareInterpolation(int &ok){ */
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* if (interp) */
/* interp->prepareInterpolation(ok); */
/* } */
virtual int *getFlatField(){
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
if (interp)
return interp->getFlatField();
else
return NULL;
}
/* virtual int *getFlatField(){ */
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* if (interp) */
/* return interp->getFlatField(); */
/* else */
/* return NULL; */
/* } */
virtual int *setFlatField(int *ff, int nb, double emin, double emax){
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
if (interp)
return interp->setFlatField(ff, nb, emin, emax);
else
return NULL;
}
/* virtual int *setFlatField(int *ff, int nb, double emin, double emax){ */
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* if (interp) */
/* return interp->setFlatField(ff, nb, emin, emax); */
/* else */
/* return NULL; */
/* } */
void *writeFlatField(const char * imgname) {
/* void *writeFlatField(const char * imgname) { */
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
if (interp)
interp->writeFlatField(imgname);
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* if (interp) */
/* interp->writeFlatField(imgname); */
}
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
if (interp)
interp->readFlatField(imgname, nb, emin, emax);
}
/* } */
/* void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){ */
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* if (interp) */
/* interp->readFlatField(imgname, nb, emin, emax); */
/* } */
virtual int *getFlatField(int &nb, double emi, double ema){
slsInterpolation *interp=(slsInterpolation*)((interpolatingDetector*)det)->getInterpolation();
int *ff=NULL;
if (interp) {
ff=interp->getFlatField(nb,emi,ema);
}
return ff;
}
/* virtual int *getFlatField(int &nb, double emi, double ema){ */
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
/* int *ff=NULL; */
/* if (interp) { */
/* ff=interp->getFlatField(nb,emi,ema); */
/* } */
/* return ff; */
/* } */
virtual char *getInterpolation() {
return ((interpolatingDetector*)det)->getInterpolation();
}
/* virtual slsInterpolation *getInterpolation() { */
/* return ((interpolatingDetector*)det)->getInterpolation(); */
/* } */
virtual void resetFlatField() { ((interpolatingDetector*)det)->resetFlatField();};
/* virtual void resetFlatField() { ((interpolatingDetector*)det)->resetFlatField();}; */
virtual int setNSubPixels(int ns) { return ((interpolatingDetector*)det)->setNSubPixels(ns);};
/* virtual int setNSubPixels(int ns) { return ((interpolatingDetector*)det)->setNSubPixels(ns);}; */
};
/* virtual slsInterpolation *setInterpolation(slsInterpolation *f){ */
/* cout << "thr" << endl; */
/* return ((interpolatingDetector*)det)->setInterpolation(f); */
/* }; */
/* protected: */
/* interpolatingDetector *det; */
/* }; */
@ -83,34 +88,58 @@ public:
/* getFlatField(); //sum up all etas */
/* setFlatField(); //set etas to all detectors */
/* for (int i=0; i<nThreads; i++) { */
((threadedInterpolatingDetector*)dets[0])->prepareInterpolation(ok);
(dets[0])->prepareInterpolation(ok);
// }
}
virtual int *getFlatField(){
return ((threadedInterpolatingDetector*)dets[0])->getFlatField();
return (dets[0])->getFlatField();
}
virtual int *getFlatField(int &nb, double emi, double ema){
return ((threadedInterpolatingDetector*)dets[0])->getFlatField(nb,emi,ema);
return (dets[0])->getFlatField(nb,emi,ema);
}
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
return ((threadedInterpolatingDetector*)dets[0])->setFlatField(h,nb,emin,emax);
return (dets[0])->setFlatField(h,nb,emin,emax);
};
void *writeFlatField(const char * imgname){
((threadedInterpolatingDetector*)dets[0])->writeFlatField(imgname);
dets[0]->writeFlatField(imgname);
};
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
((threadedInterpolatingDetector*)dets[0])->readFlatField(imgname, nb, emin, emax);
(dets[0])->readFlatField(imgname, nb, emin, emax);
};
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);};
virtual void resetFlatField() {(dets[0])->resetFlatField();};
/** sets file pointer where to write the clusters to
\param f file pointer
\returns current file pointer
*/
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
int ok;
// for (int i=0; i<nThreads; i++) {
cout << "mt" << endl;
return (dets[0])->setInterpolation(f);
//dets[i]->setMutex(&fmutex);
// }
//dets[0]->prepareInterpolation(ok);
//return (slsInterpolation*)((interpolatingDetector*)dets[0])->getInterpolation();
};
virtual slsInterpolation *getInterpolation(){
return (dets[0])->getInterpolation();
};
virtual int setNSubPixels(int ns) { return ((threadedInterpolatingDetector*)dets[0])->setNSubPixels(ns);};
virtual void resetFlatField() {((threadedInterpolatingDetector*)dets[0])->resetFlatField();};
};

View File

@ -391,6 +391,8 @@ enum dacIndex {
M_vIbiasSh, /**< mythen 3 >*/
M_vIcin, /**< mythen 3 >*/
M_vIpreOut, /**< mythen 3 >*/
ZMQ_emin, /**< ZMQ */
ZMQ_emax,/**< ZMQ */
V_POWER_A = 100, /**new chiptest board */
V_POWER_B = 101, /**new chiptest board */
V_POWER_C = 102, /**new chiptest board */

View File

@ -4619,10 +4619,10 @@ int slsDetector::getDataBytesInclGapPixels() {
dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) {
dacs_t retval[2];
retval[0] = -1;
retval[1] = -1;
if (index!=ZMQ_emin && index!=ZMQ_emax) {
int fnum=F_SET_DAC;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
@ -4683,6 +4683,89 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod) {
}
if(mV)
return retval[1];
} else if(thisDetector->myDetectorType==JUNGFRAUCTB) {
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Old json header: " << header << std::endl;
if (index==ZMQ_emin) {
size_t pos0, pos1;
pos0=header.find(",\"eMin\"");
if (pos0==std::string::npos) {
pos0=header.find("\"eMin\"");
} else pos0++;
if (pos0!=std::string::npos) {
pos1=header.find_first_of(",",pos0);
// std::cout << pos0 << " " << pos1 << std::endl;
std::cout<< "Replacing old eMin: " << header.substr(pos0,pos1-pos0) << std::endl;
// if (pos1!=std::string::npos)
if (val>=0)
header.erase(pos0,pos1-pos0);
// else
// header.erase(pos0);
}
if (val>=0) {
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
// std::cout<< "Left: " << header << std::endl;
char h[1000];
sprintf(h,"\"eMin\":%d",val);
// std::cout<< "new ROI: " << h << std::endl;
header.append(h);
} else {
sscanf(header.substr(pos0,pos1-pos0).c_str(),"\"eMin\":%d",&val);
}
} else if (index==ZMQ_emax) {
size_t pos0, pos1;
pos0=header.find(",\"eMax\"");
if (pos0==std::string::npos) {
pos0=header.find("\"eMax\"");
} else pos0++;
if (pos0!=std::string::npos) {
pos1=header.find_first_of(",",pos0);
// std::cout << pos0 << " " << pos1 << std::endl;
std::cout<< "Replacing old eMax: " << header.substr(pos0,pos1-pos0) << std::endl;
// if (pos1!=std::string::npos)
if (val>=0)
header.erase(pos0,pos1-pos0);
// else
// header.erase(pos0);
}
if (val>=0) {
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
// std::cout<< "Left: " << header << std::endl;
char h[1000];
sprintf(h,"\"eMax\":%d",val);
// std::cout<< "new ROI: " << h << std::endl;
header.append(h);
} else {
sscanf(header.substr(pos0,pos1-pos0).c_str(),"\"eMax\":%d",&val);
}
}
std::cout<< "New json header: " << header << std::endl;
setReceiverOnline(ONLINE_FLAG);
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
/***** END FOR ZMQ HEADER */
retval[0]=val;
}
return retval[0];
}
@ -4892,7 +4975,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
thisDetector->roFlags=flag;
}
std::cout<< "***ZMQ: " << hex<< flag << std::endl;
// std::cout<< "***ZMQ: " << hex<< flag << std::endl;
if (flag & (PEDESTAL | NEWPEDESTAL | NEWFLAT | FLAT | FRAME)) {

View File

@ -1106,7 +1106,19 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
\section settingsdacs DACs
commands to configure DACs of detector
*/
/*! \page settings
- <b>emin [i] </b> Sets/gets detector minimum energy threshold for the CTB (soft setting)
*/
descrToFuncMap[i].m_pFuncName="emin"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>emax [i] </b> Sets/gets detector maximum energy threshold for the CTB (soft setting)
*/
descrToFuncMap[i].m_pFuncName="emax"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
++i;
/*! \page settings
- <b>vthreshold [i] [mv]</b> Sets/gets detector threshold voltage for single photon counters. Normally in DAC units unless \c mv is specified at the end of the command line. \c Returns \c (int ["mV"])
*/
@ -5228,6 +5240,10 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
dac=M_vIbiasSh;
else if (cmd== "vIpreOut")
dac=M_vIpreOut;
else if (cmd== "emin")
dac=ZMQ_emin;
else if (cmd== "emax")
dac=ZMQ_emax;
else
return string("cannot decode dac ")+cmd;