mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
Merge branch 'developer' into eiger2udp
This commit is contained in:
commit
193ab75ebe
@ -32,11 +32,11 @@ using namespace std;
|
||||
/**
|
||||
enum to define the flags of the data set, which are needed to seect the type of processing it should undergo: frame, pedestal, flat
|
||||
*/
|
||||
enum frameMode { eFrame, ePedestal, eFlat };
|
||||
enum frameMode { eFrame, ePedestal, eFlat, eRaw };
|
||||
/**
|
||||
enum to define the detector mode
|
||||
*/
|
||||
enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
|
||||
enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
|
||||
#endif
|
||||
|
||||
|
||||
@ -1034,7 +1034,7 @@ template <class dataType> class analogDetector {
|
||||
\returns converted number of photons. If no threshold is set, returns gain converted pedestal subtracted data.
|
||||
*/
|
||||
|
||||
virtual int getNPhotons(char *data, int ix, int iy=0) {
|
||||
int convertToPhotons(char *data, int ix, int iy=0) {
|
||||
int nph=0;
|
||||
double v;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
@ -1068,20 +1068,35 @@ template <class dataType> class analogDetector {
|
||||
\param nph pointer where the photons should added. If NULL,the internal image is used
|
||||
\returns pointer to array containing the number of photons
|
||||
*/
|
||||
int *getNPhotons(char *data, int *nph=NULL) {
|
||||
virtual int *getNPhotons(char *data, int *nph=NULL) {
|
||||
|
||||
//double val;
|
||||
if (nph==NULL)
|
||||
nph=image;
|
||||
|
||||
newFrame(data);
|
||||
|
||||
/* cout << fMode << endl; */
|
||||
|
||||
/* switch(fMode) { */
|
||||
/* case eRaw: */
|
||||
/* cout << "raw" << endl; */
|
||||
/* break; */
|
||||
/* default: */
|
||||
/* cout << "analog" << endl; */
|
||||
/* } */
|
||||
//calcGhost(data);
|
||||
addToCommonMode(data);
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy))
|
||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
switch(fMode) {
|
||||
case eRaw:
|
||||
//cout << "raw" << endl;
|
||||
nph[iy*nx+ix]=det->getChannel(data,ix,iy);
|
||||
break;
|
||||
default:
|
||||
if (det->isGood(ix,iy))
|
||||
nph[iy*nx+ix]+=convertToPhotons(data, ix, iy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nph;
|
||||
@ -1164,7 +1179,7 @@ template <class dataType> class analogDetector {
|
||||
for (ix=xmi; ix<xma; ++ix)
|
||||
if (det->isGood(ix,iy)) {
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
val+=getNPhotons(data, ix, iy);
|
||||
val+=convertToPhotons(data, ix, iy);
|
||||
}
|
||||
|
||||
return val;
|
||||
@ -1187,9 +1202,9 @@ template <class dataType> class analogDetector {
|
||||
addToPedestal(data,1);
|
||||
break;
|
||||
default:
|
||||
// cout << "analog " << endl;
|
||||
//cout << "analog frame" << endl;
|
||||
//subtractPedestal(data);
|
||||
getNPhotons(data);
|
||||
analogDetector<dataType>::getNPhotons(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
//int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
|
@ -30,7 +30,7 @@ template <class dataType> class ghostSummation {
|
||||
ghost=new double[nx*ny];
|
||||
|
||||
}
|
||||
~ghostSummation() {delete [] ghost;};
|
||||
virtual ~ghostSummation() {delete [] ghost;};
|
||||
|
||||
virtual ghostSummation *Clone() {
|
||||
return new ghostSummation(this);
|
||||
|
@ -302,7 +302,11 @@ float *gethhx()
|
||||
double diff=0, d;
|
||||
//double bsize=1./nSubPixels;
|
||||
int nbad=0;
|
||||
double p_tot_x[nSubPixelsX], p_tot_y[nSubPixelsY], p_tot[nSubPixelsX*nSubPixelsY];
|
||||
double *p_tot_x=new double[nSubPixelsX];
|
||||
double *p_tot_y=new double[nSubPixelsY];
|
||||
double *p_tot= new double[nSubPixelsX*nSubPixelsY];
|
||||
|
||||
|
||||
double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY;
|
||||
|
||||
int ipx, ipy;
|
||||
@ -362,6 +366,10 @@ float *gethhx()
|
||||
|
||||
|
||||
// cout << "Bad pixels: " << 100.*(float)nbad/((float)(nSubPixels*nSubPixels)) << " %" << endl;
|
||||
delete [] p_tot_x;
|
||||
delete [] p_tot_y;
|
||||
delete [] p_tot;
|
||||
|
||||
return sqrt(diff);
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,10 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
|
||||
|
||||
double hx[nbetaX]; //profile x
|
||||
double hy[nbetaY]; //profile y
|
||||
double hix[nbetaX]; //integral of projection x
|
||||
double hiy[nbetaY]; //integral of projection y
|
||||
double *hx=new double[nbetaX]; //profile x
|
||||
double *hy=new double[nbetaY]; //profile y
|
||||
double *hix=new double[nbetaX]; //integral of projection x
|
||||
double *hiy=new double[nbetaY]; //integral of projection y
|
||||
// int ii=0;
|
||||
double etax, etay;
|
||||
for (int ib=0; ib<nbetaX; ib++) {
|
||||
@ -166,7 +166,12 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
debugSaveAll();
|
||||
#endif
|
||||
#endif
|
||||
delete [] hx;
|
||||
delete [] hy;
|
||||
delete [] hix;
|
||||
delete [] hiy;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,8 @@ class slsInterpolation
|
||||
hint=new int[nSubPixelsX*nx*nSubPixelsY*ny];
|
||||
|
||||
};
|
||||
|
||||
virtual ~slsInterpolation(){ delete [] hint;}
|
||||
|
||||
slsInterpolation(slsInterpolation *orig){
|
||||
nPixelsX=orig->nPixelsX;
|
||||
nPixelsY=orig->nPixelsY;
|
||||
|
@ -7,14 +7,15 @@ LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess moenchZmq04Process
|
||||
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
|
||||
#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
|
||||
|
@ -68,8 +68,9 @@ int main(int argc, char *argv[]) {
|
||||
int etabins=1000, etabinsy=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int nSubPixelsX=2;
|
||||
// int emin, emax;
|
||||
int emin, emax;
|
||||
int nSubPixelsY=2;
|
||||
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
@ -159,7 +160,7 @@ int main(int argc, char *argv[]) {
|
||||
//int multisize=size;
|
||||
//int dataSize=size;
|
||||
|
||||
char dummybuff[size];
|
||||
char *dummybuff=new char[size];
|
||||
|
||||
|
||||
moench03CommonMode *cm=NULL;
|
||||
@ -355,7 +356,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// int resetFlat=0;
|
||||
//int resetPed=0;
|
||||
// int nsubPixels=1;
|
||||
//int nsubPixels=1;
|
||||
//int isPedestal=0;
|
||||
//int isFlat=0;
|
||||
int newFrame=1;
|
||||
@ -393,7 +394,7 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Measurement lasted " << (end-begin).count()*0.000001 << " ms" << endl;
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
usleep(100);
|
||||
if (of) {
|
||||
mt->setFilePointer(NULL);
|
||||
fclose(of);
|
||||
@ -626,40 +627,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//strcpy(fname,filename.c_str());
|
||||
fname=filename;
|
||||
// cprintf(BLUE, "Header Info:\n"
|
||||
// "size: %u\n"
|
||||
// "multisize: %u\n"
|
||||
// "dynamicRange: %u\n"
|
||||
// "nPixelsX: %u\n"
|
||||
// "nPixelsY: %u\n"
|
||||
// "currentFileName: %s\n"
|
||||
// "currentAcquisitionIndex: %lu\n"
|
||||
// "currentFrameIndex: %lu\n"
|
||||
// "currentFileIndex: %lu\n"
|
||||
// "currentSubFrameIndex: %u\n"
|
||||
// "xCoordX: %u\n"
|
||||
// "yCoordY: %u\n"
|
||||
// "zCoordZ: %u\n"
|
||||
// "flippedDataX: %u\n"
|
||||
// "packetNumber: %u\n"
|
||||
// "bunchId: %u\n"
|
||||
// "timestamp: %u\n"
|
||||
// "modId: %u\n"
|
||||
// "debug: %u\n"
|
||||
// "roundRNumber: %u\n"
|
||||
// "detType: %u\n"
|
||||
// "version: %u\n",
|
||||
// size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
// filename.c_str(), acqIndex,
|
||||
// frameIndex, fileindex, subFrameIndex,
|
||||
// xCoord, yCoord,zCoord,
|
||||
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
addJsonHeader=zHeader.addJsonHeader;
|
||||
|
||||
/* Analog detector commands */
|
||||
//isPedestal=0;
|
||||
//isFlat=0;
|
||||
rms=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
@ -682,6 +651,11 @@ int main(int argc, char *argv[]) {
|
||||
fMode=ePedestal;
|
||||
//isPedestal=1;
|
||||
rms=1;
|
||||
} else if (frameMode_s == "raw"){
|
||||
//mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=eRaw;
|
||||
//isPedestal=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
@ -695,7 +669,6 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
//#endif
|
||||
else {
|
||||
fMode=eFrame;
|
||||
//isPedestal=0;
|
||||
//isFlat=0;
|
||||
fMode=eFrame;
|
||||
@ -710,14 +683,8 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(MAGENTA, "Threshold: ");
|
||||
if (addJsonHeader.find("threshold")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("threshold")) >>threshold;
|
||||
// threshold=atoi(addJsonHeader.at("threshold").c_str());//doc["frameMode"].GetString();
|
||||
}
|
||||
//if (doc.HasMember("threshold")) {
|
||||
//if (doc["threshold"].IsInt()) {
|
||||
// threshold=doc["threshold"].GetInt();
|
||||
mt->setThreshold(threshold);
|
||||
// }
|
||||
// }
|
||||
cprintf(MAGENTA, "%d\n", threshold);
|
||||
|
||||
xmin=0;
|
||||
@ -728,24 +695,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (addJsonHeader.find("roi")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("roi")) >> xmin >> xmax >> ymin >> ymax ;
|
||||
// if (doc.HasMember("roi")) {
|
||||
//if (doc["roi"].IsArray()) {
|
||||
// if (doc["roi"].Size() > 0 )
|
||||
// if (doc["roi"][0].IsInt())
|
||||
// xmin=doc["roi"][0].GetInt();
|
||||
|
||||
// if (doc["roi"].Size() > 1 )
|
||||
// if (doc["roi"][1].IsInt())
|
||||
// xmax=doc["roi"][1].GetInt();
|
||||
|
||||
// if (doc["roi"].Size() > 2 )
|
||||
// if (doc["roi"][2].IsInt())
|
||||
// ymin=doc["roi"][2].GetInt();
|
||||
|
||||
// if (doc["roi"].Size() > 3 )
|
||||
// if (doc["roi"][3].IsInt())
|
||||
// ymax=doc["roi"][3].GetInt();
|
||||
// }
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||
@ -754,17 +703,10 @@ int main(int argc, char *argv[]) {
|
||||
istringstream(addJsonHeader.at("dynamicRange")) >> dr ;
|
||||
dr=32;
|
||||
}
|
||||
// if (doc.HasMember("dynamicRange")) {
|
||||
// dr=doc["dynamicRange"].GetUint();
|
||||
// dr=32;
|
||||
// }
|
||||
|
||||
dMode=eAnalog;
|
||||
detectorMode_s="analog";
|
||||
cprintf(MAGENTA, "Detector mode: ");
|
||||
if (addJsonHeader.find("detectorMode")!= addJsonHeader.end()) {;
|
||||
//if (doc.HasMember("detectorMode")) {
|
||||
//if (doc["detectorMode"].IsString()) {
|
||||
detectorMode_s=addJsonHeader.at("detectorMode");//=doc["detectorMode"].GetString();
|
||||
#ifdef INTERP
|
||||
if (detectorMode_s == "interpolating"){
|
||||
@ -783,98 +725,69 @@ int main(int argc, char *argv[]) {
|
||||
mt->setInterpolation(NULL);
|
||||
#endif
|
||||
}
|
||||
// }
|
||||
// }
|
||||
if (fMode==eRaw) {
|
||||
detectorMode_s = "analog";
|
||||
dMode=eAnalog;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mt->setDetectorMode(dMode);
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
|
||||
// cout << "done " << endl;
|
||||
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;
|
||||
|
||||
// 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 (addJsonHeader.find("nSigma")!= addJsonHeader.end()) {;
|
||||
istringstream(addJsonHeader.at("nSigma")) >> nSigma ;
|
||||
mt->setNSigma(nSigma);
|
||||
}
|
||||
|
||||
// /* interpolating detector commands */
|
||||
|
||||
// if (doc.HasMember("nSubPixels")) {
|
||||
// if (doc["nSubPixels"].IsUint())
|
||||
// nSubPixels=doc["nSubPixels"].GetUint();
|
||||
emin=-1;
|
||||
emax=-1;
|
||||
if (addJsonHeader.find("energyRange")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("energyRange")) >> emin >> emax ;
|
||||
}
|
||||
if (addJsonHeader.find("eMin")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("eMin")) >> emin ;
|
||||
}
|
||||
|
||||
if (addJsonHeader.find("eMax")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("eMax")) >> emax ;
|
||||
}
|
||||
|
||||
mt->setEnergyRange(emin,emax);
|
||||
|
||||
/* interpolating detector commands */
|
||||
//must set subpixels X and Y separately
|
||||
// if (addJsonHeader.find("nSubPixels")!= addJsonHeader.end()) {
|
||||
// istringstream(addJsonHeader.at("nSubPixels")) >> nSubPixels ;
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
// threshold=0;
|
||||
// cprintf(MAGENTA, "Subframes: ");
|
||||
// subframes=0;
|
||||
// //isubframe=0;
|
||||
// insubframe=0;
|
||||
// subnorm=1;
|
||||
// f0=0;
|
||||
// nnsubframe=0;
|
||||
// if (doc.HasMember("subframes")) {
|
||||
// if (doc["subframes"].IsInt()) {
|
||||
// subframes=doc["subframes"].GetInt();
|
||||
// }
|
||||
// }
|
||||
// cprintf(MAGENTA, "%ld\n", subframes);
|
||||
|
||||
threshold=0;
|
||||
cprintf(MAGENTA, "Subframes: ");
|
||||
subframes=0;
|
||||
//isubframe=0;
|
||||
insubframe=0;
|
||||
subnorm=1;
|
||||
f0=0;
|
||||
nnsubframe=0;
|
||||
if (addJsonHeader.find("subframes")!= addJsonHeader.end()) {
|
||||
istringstream(addJsonHeader.at("subframes")) >> subframes ;
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%ld\n", subframes);
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
}
|
||||
#endif
|
||||
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL) {
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust",filename.c_str(),fileindex);
|
||||
#endif
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cout << "data" << endl;
|
||||
// get data
|
||||
// acqIndex = doc["acqIndex"].GetUint64();
|
||||
|
||||
frameIndex = zHeader.frameIndex;////doc["fIndex"].GetUint64();
|
||||
|
||||
@ -891,11 +804,45 @@ int main(int argc, char *argv[]) {
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (fMode!=ePedestal || dMode!=eAnalog) {
|
||||
if (of==NULL) {
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust",filename.c_str(),fileindex);
|
||||
#endif
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
insubframe++;
|
||||
nsubframes=frameIndex+1-f0;
|
||||
// cout << "insubframe " << insubframe << endl;
|
||||
// cout << "nsubframes " << nsubframes << endl;
|
||||
// cout << "f0 " << f0 << endl;
|
||||
// cout << "frameIndex " << frameIndex << endl;
|
||||
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
@ -905,9 +852,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
|
||||
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
|
||||
if (subframes>0 && insubframe>=subframes && (fMode==eFrame ||fMode==eRaw) ) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
usleep(100);
|
||||
|
||||
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
|
||||
|
||||
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
dout= new int32_t[nnx*nny];
|
||||
doutf= new float[nnx*nny];
|
||||
@ -932,9 +883,37 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
zHeader.data = true;
|
||||
zmqsocket2->SendHeader(0,zHeader);
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
|
||||
|
||||
|
||||
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
|
||||
outHeader.data=true;
|
||||
outHeader.dynamicRange=dr;
|
||||
outHeader.fileIndex=fileindex;
|
||||
outHeader.ndetx=1;
|
||||
outHeader.ndety=1;
|
||||
outHeader.npixelsx=nnx;
|
||||
outHeader.npixelsy=nny;
|
||||
outHeader.imageSize=nnx*nny*dr/8;
|
||||
outHeader.acqIndex=acqIndex;
|
||||
outHeader.frameIndex=frameIndex;
|
||||
outHeader.fname=fname;
|
||||
outHeader.frameNumber=acqIndex;
|
||||
outHeader.expLength=expLength;
|
||||
outHeader.packetNumber=packetNumber;
|
||||
outHeader.bunchId=bunchId;
|
||||
outHeader.timestamp=timestamp;
|
||||
outHeader.modId=modId;
|
||||
outHeader.row=xCoord;
|
||||
outHeader.column=yCoord;
|
||||
outHeader.debug=debug;
|
||||
outHeader.roundRNumber=roundRNumber;
|
||||
outHeader.detType=detType;
|
||||
outHeader.version=version;
|
||||
|
||||
zmqsocket2->SendHeader(0,outHeader);
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent subdata\n");
|
||||
|
||||
|
||||
@ -950,18 +929,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
||||
|
@ -125,8 +125,20 @@ public:
|
||||
return fifoFree->pop(ptr);
|
||||
}
|
||||
|
||||
virtual int isBusy() {if (fifoData->isEmpty() && busy==0) return 0; return 1;}
|
||||
// virtual int isBusy() {if (fifoData->isEmpty() && busy==0) return 0; return 1;}
|
||||
|
||||
virtual int isBusy() {
|
||||
if (busy==0) {
|
||||
usleep(100);
|
||||
if (busy==0) {
|
||||
if (fifoData->isEmpty()) {
|
||||
usleep(100);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//protected:
|
||||
/** Implement this method in your subclass with the code you want your thread to run. */
|
||||
//virtual void InternalThreadEntry() = 0;
|
||||
@ -254,10 +266,15 @@ protected:
|
||||
// busy=1;
|
||||
while (!stop) {
|
||||
if (fifoData->isEmpty()) {
|
||||
busy=0;
|
||||
usleep(100);
|
||||
} else {
|
||||
if (fifoData->isEmpty()) {
|
||||
busy=0;
|
||||
} else
|
||||
busy=1;
|
||||
} else
|
||||
busy=1;
|
||||
|
||||
if (busy==1) {
|
||||
fifoData->pop(data); //blocking!
|
||||
det->processData(data);
|
||||
fifoFree->push(data);
|
||||
@ -298,7 +315,7 @@ public:
|
||||
cout << "Ithread is " << ithread << endl;
|
||||
}
|
||||
|
||||
~multiThreadedAnalogDetector() {
|
||||
virtual ~multiThreadedAnalogDetector() {
|
||||
StopThreads();
|
||||
for (int i=0; i<nThreads; i++)
|
||||
delete dets[i];
|
||||
|
@ -26,7 +26,7 @@ class multiThreadedCountingDetector : public multiThreadedAnalogDetector
|
||||
{
|
||||
public:
|
||||
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
|
||||
|
||||
//virtual ~multiThreadedCountingDetector{multiThreadedAnalogDetector::~multiThreadedAnalogDetector();};
|
||||
virtual double setNSigma(double n) {double ret=(dets[0])->setNSigma(n); for (int i=1; i<nThreads; i++) (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);};
|
||||
|
||||
|
@ -17,7 +17,7 @@ class multiThreadedInterpolatingDetector : public multiThreadedCountingDetector
|
||||
{
|
||||
public:
|
||||
multiThreadedInterpolatingDetector(interpolatingDetector *d, int n, int fs=1000) : multiThreadedCountingDetector(d,n,fs) { };
|
||||
|
||||
//virtual ~multiThreadedInterpolatingDetector() {multiThreadedCountingDetector::~multiThreadedCountingDetector();};
|
||||
virtual void prepareInterpolation(int &ok){
|
||||
/* getFlatField(); //sum up all etas */
|
||||
/* setFlatField(); //set etas to all detectors */
|
||||
|
@ -189,14 +189,13 @@ public analogDetector<uint16_t> {
|
||||
*/
|
||||
|
||||
virtual int *getNPhotons(char *data, int *nph=NULL) {
|
||||
|
||||
// cout << "spc frame" << endl;
|
||||
nphFrame=0;
|
||||
double val;
|
||||
if (nph==NULL)
|
||||
nph=image;
|
||||
//nph=new int[nx*ny];
|
||||
|
||||
double rest[ny][nx];
|
||||
//int cy=(clusterSizeY+1)/2; //quad size
|
||||
//int cs=(clusterSize+1)/2; //quad size
|
||||
|
||||
@ -226,6 +225,7 @@ public analogDetector<uint16_t> {
|
||||
return nph;
|
||||
} else {
|
||||
if (thr>0) {
|
||||
double *rest=new double[ny*nx];
|
||||
newFrame(data);
|
||||
if (cmSub) {
|
||||
cout << "add to common mode?"<< endl;
|
||||
@ -236,14 +236,14 @@ public analogDetector<uint16_t> {
|
||||
if (det->isGood(ix,iy)) {
|
||||
val=subtractPedestal(data,ix,iy, cm);
|
||||
|
||||
nn=analogDetector<uint16_t>::getNPhotons(data,ix,iy);//val/thr;//
|
||||
nn=analogDetector<uint16_t>::convertToPhotons(data,ix,iy);//val/thr;//
|
||||
if (nn>0) {
|
||||
nph[ix+nx*iy]+=nn;
|
||||
rest[iy][ix]=(val-nn*thr);//?+0.5*thr
|
||||
rest[iy*nx+ix]=(val-nn*thr);//?+0.5*thr
|
||||
nphFrame+=nn;
|
||||
nphTot+=nn;
|
||||
} else
|
||||
rest[iy][ix]=val;
|
||||
rest[iy*nx+ix]=val;
|
||||
|
||||
}
|
||||
}
|
||||
@ -262,7 +262,7 @@ public analogDetector<uint16_t> {
|
||||
tot=0;
|
||||
quadTot=0;
|
||||
|
||||
if (rest[iy][ix]>0.25*thr) {
|
||||
if (rest[iy*nx+ix]>0.25*thr) {
|
||||
eventMask[iy][ix]=NEIGHBOUR;
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
@ -270,7 +270,7 @@ public analogDetector<uint16_t> {
|
||||
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
|
||||
|
||||
v=rest[iy+ir][ix+ic];//clusters->get_data(ic,ir);
|
||||
v=rest[(iy+ir)*nx+ix+ic];//clusters->get_data(ic,ir);
|
||||
tot+=v;
|
||||
|
||||
if (ir<=0 && ic<=0)
|
||||
@ -290,7 +290,7 @@ public analogDetector<uint16_t> {
|
||||
}
|
||||
}
|
||||
|
||||
if (rest[iy][ix]>=max) {
|
||||
if (rest[iy*nx+ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
@ -327,7 +327,7 @@ public analogDetector<uint16_t> {
|
||||
if (tot>tthr1 || quadTot>tthr2 || max>tthr) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
nph[ix+nx*iy]++;
|
||||
rest[iy][ix]-=thr;
|
||||
rest[iy*nx+ix]-=thr;
|
||||
nphFrame++;
|
||||
nphTot++;
|
||||
|
||||
@ -338,6 +338,7 @@ public analogDetector<uint16_t> {
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] rest;
|
||||
} else return getClusters(data, nph);
|
||||
}
|
||||
return NULL;
|
||||
@ -372,7 +373,6 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
//quadrant quad;
|
||||
double rms;
|
||||
//if (cmSub) cm=1;
|
||||
double val[ny][nx];
|
||||
if (ph==NULL)
|
||||
ph=image;
|
||||
|
||||
@ -389,6 +389,8 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
cm=1;
|
||||
}
|
||||
|
||||
double *val=new double[ny*nx];
|
||||
|
||||
for (iy=ymin; iy<ymax; ++iy) {
|
||||
for (ix=xmin; ix<xmax; ++ix) {
|
||||
if (det->isGood(ix,iy)==0) continue;
|
||||
@ -416,8 +418,8 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
val[(iy+ir)*nx+ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
v=&(val[(iy+ir)*nx+ix+ic]);
|
||||
tot+=*v;
|
||||
if (ir<=0 && ic<=0)
|
||||
bl+=*v;
|
||||
@ -438,14 +440,14 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
}
|
||||
/* if (ix==50 && iy==50) */
|
||||
/* cout << id << " " << ix << " " << iy << " " << det->getValue(data,ix,iy)<< " " << val[iy][ix] << " " << getPedestal(ix,iy) << " " << rms << endl; */
|
||||
if (val[iy][ix]<-nSigma*rms){
|
||||
if (val[iy*nx+ix]<-nSigma*rms){
|
||||
ee=NEGATIVE_PEDESTAL;
|
||||
continue;
|
||||
}
|
||||
if (max>nSigma*rms){
|
||||
// cout << "ph1 " << max << " " << nSigma*rms << endl;
|
||||
ee=PHOTON;
|
||||
if (val[iy][ix]<max)
|
||||
if (val[iy*nx+ix]<max)
|
||||
continue;
|
||||
}
|
||||
else if (tot>c3*nSigma*rms) {
|
||||
@ -478,7 +480,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
#ifndef WRITE_QUAD
|
||||
}
|
||||
#endif
|
||||
if (ee==PHOTON && val[iy][ix]==max) {
|
||||
if (ee==PHOTON && val[iy*nx+ix]==max) {
|
||||
ee=PHOTON_MAX;
|
||||
// cout << "**" <<id<< " " << iframe << " " << nDark << " " << ix << " " << iy << " " << rms << " " << max << " " << quadTot << " " << tot << endl;
|
||||
(clusters+nph)->tot=tot;
|
||||
@ -493,7 +495,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
for (ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx)
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
(clusters+nph)->set_data(val[(iy+ir)*nx+ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
good=1;
|
||||
@ -519,6 +521,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
//cout << nphFrame << endl;
|
||||
//cout <<id << " **********************************"<< iframe << " " << det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||
writeClusters(det->getFrameNumber(data));
|
||||
delete [] val;
|
||||
return image;
|
||||
|
||||
};
|
||||
@ -652,7 +655,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
analogDetector<uint16_t>::processData(data,val);
|
||||
break;
|
||||
default:
|
||||
// cout <<"spc " << endl;
|
||||
//cout <<"spc " << endl;
|
||||
getNPhotons(data,val);
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +690,23 @@ void Module::setImageTestMode(const int value) {
|
||||
}
|
||||
|
||||
int Module::getADC(dacIndex index) const {
|
||||
return sendToDetectorStop<int>(F_GET_ADC, index);
|
||||
switch (index) {
|
||||
case TEMPERATURE_ADC:
|
||||
case TEMPERATURE_FPGA:
|
||||
case TEMPERATURE_FPGAEXT:
|
||||
case TEMPERATURE_10GE:
|
||||
case TEMPERATURE_DCDC:
|
||||
case TEMPERATURE_SODL:
|
||||
case TEMPERATURE_SODR:
|
||||
case TEMPERATURE_FPGA2:
|
||||
case TEMPERATURE_FPGA3:
|
||||
// only the temperatures go to the control server, others need
|
||||
// configuration of adc in control server
|
||||
return sendToDetectorStop<int>(F_GET_ADC, index);
|
||||
|
||||
default:
|
||||
return sendToDetector<int>(F_GET_ADC, index);
|
||||
}
|
||||
}
|
||||
|
||||
int Module::getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user