mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 15:50:03 +02:00
fixed probelem with multiThreadedInterpolatingDetector
This commit is contained in:
parent
4aa720eecb
commit
38a6393dde
@ -127,7 +127,6 @@ class interpolatingDetector : public singlePhotonDetector {
|
|||||||
return interp->getInterpolatedImage();
|
return interp->getInterpolatedImage();
|
||||||
else
|
else
|
||||||
return analogDetector<uint16_t>::getImage();
|
return analogDetector<uint16_t>::getImage();
|
||||||
//cout << "null " << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MYROOT1
|
#ifdef MYROOT1
|
||||||
@ -179,6 +178,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
|||||||
double int_x, int_y;
|
double int_x, int_y;
|
||||||
double eta_x, eta_y;
|
double eta_x, eta_y;
|
||||||
if (interp) {
|
if (interp) {
|
||||||
|
cout << "int" << endl;
|
||||||
pthread_mutex_lock(fi);
|
pthread_mutex_lock(fi);
|
||||||
for (nph=0; nph<nphFrame; nph++) {
|
for (nph=0; nph<nphFrame; nph++) {
|
||||||
if (ff) {
|
if (ff) {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
ZMQLIB=../../slsReceiverSoftware/include
|
||||||
|
INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||||
|
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3
|
||||||
|
#-L../../bin -lhdf5 -L.
|
||||||
|
|
||||||
|
#DESTDIR?=../bin
|
||||||
|
|
||||||
|
all: moenchZmqProcess
|
||||||
|
|
||||||
|
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||||
|
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f moenchZmqProcess
|
||||||
|
|
||||||
|
|
@ -143,10 +143,13 @@ int main(int argc, char *argv[]) {
|
|||||||
nframes++;
|
nframes++;
|
||||||
}
|
}
|
||||||
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
|
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||||
nph++;
|
nph++;
|
||||||
// if (sum>200 && sum<580) {
|
// if (sum>200 && sum<580) {
|
||||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||||
|
#ifdef SOLEIL
|
||||||
|
if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||||
|
#endif
|
||||||
#ifndef FF
|
#ifndef FF
|
||||||
interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||||
interp->addToImage(int_x, int_y);
|
interp->addToImage(int_x, int_y);
|
||||||
@ -154,7 +157,9 @@ int main(int argc, char *argv[]) {
|
|||||||
#ifdef FF
|
#ifdef FF
|
||||||
interp->addToFlatField(cl.get_cluster(), etax, etay);
|
interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SOLEIL
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nph%1000000==0) cout << nph << endl;
|
if (nph%1000000==0) cout << nph << endl;
|
||||||
if (nph%100000000==0) {
|
if (nph%100000000==0) {
|
||||||
|
@ -109,18 +109,25 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
|
|
||||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||||
// singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
#ifndef INTERP
|
||||||
|
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||||
|
|
||||||
|
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||||
|
|
||||||
|
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
#endif
|
||||||
|
#ifdef INTERP
|
||||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
||||||
|
|
||||||
if (etafname) interp->readFlatField(etafname);
|
if (etafname) interp->readFlatField(etafname);
|
||||||
|
|
||||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||||
cout << " filter" <<endl;
|
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char* buff;
|
char* buff;
|
||||||
// multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
|
||||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
|
||||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
|
||||||
mt->setFrameMode(eFrame);
|
mt->setFrameMode(eFrame);
|
||||||
mt->StartThreads();
|
mt->StartThreads();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
@ -302,12 +309,15 @@ int main(int argc, char *argv[]) {
|
|||||||
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
||||||
mt->writePedestal(ofname);
|
mt->writePedestal(ofname);
|
||||||
cout << "Writing pedestal to " << ofname << endl;
|
cout << "Writing pedestal to " << ofname << endl;
|
||||||
} else if (fMode==eFlat) {
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (fMode==eFlat) {
|
||||||
mt->prepareInterpolation(ok);
|
mt->prepareInterpolation(ok);
|
||||||
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
||||||
mt->writeFlatField(ofname);
|
mt->writeFlatField(ofname);
|
||||||
cout << "Writing eta to " << ofname << endl;
|
cout << "Writing eta to " << ofname << endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
||||||
mt->writeImage(ofname);
|
mt->writeImage(ofname);
|
||||||
@ -334,7 +344,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// cout << ix << " " << ped[ix] << endl;
|
// cout << ix << " " << ped[ix] << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (fMode==eFlat) {
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (fMode==eFlat) {
|
||||||
int nb;
|
int nb;
|
||||||
double emi, ema;
|
double emi, ema;
|
||||||
int *ff=mt->getFlatField(nb, emi, ema);
|
int *ff=mt->getFlatField(nb, emi, ema);
|
||||||
@ -345,6 +357,7 @@ int main(int argc, char *argv[]) {
|
|||||||
dout[ix]=ff[ix];
|
dout[ix]=ff[ix];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
detimage=mt->getImage(nnx,nny,nns);
|
detimage=mt->getImage(nnx,nny,nns);
|
||||||
cprintf(MAGENTA,"Get image!\n");
|
cprintf(MAGENTA,"Get image!\n");
|
||||||
@ -483,7 +496,9 @@ int main(int argc, char *argv[]) {
|
|||||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||||
fMode=ePedestal;
|
fMode=ePedestal;
|
||||||
isPedestal=1;
|
isPedestal=1;
|
||||||
} else if (frameMode_s == "flatfield") {
|
}
|
||||||
|
#ifdef INTERP
|
||||||
|
else if (frameMode_s == "flatfield") {
|
||||||
fMode=eFlat;
|
fMode=eFlat;
|
||||||
isFlat=1;
|
isFlat=1;
|
||||||
} else if (frameMode_s == "newFlatfield") {
|
} else if (frameMode_s == "newFlatfield") {
|
||||||
@ -492,6 +507,7 @@ int main(int argc, char *argv[]) {
|
|||||||
cprintf(MAGENTA, "Resetting flatfield\n");
|
cprintf(MAGENTA, "Resetting flatfield\n");
|
||||||
fMode=eFlat;
|
fMode=eFlat;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
fMode=eFrame;
|
fMode=eFrame;
|
||||||
isPedestal=0;
|
isPedestal=0;
|
||||||
@ -553,15 +569,22 @@ int main(int argc, char *argv[]) {
|
|||||||
if (doc.HasMember("detectorMode")) {
|
if (doc.HasMember("detectorMode")) {
|
||||||
if (doc["detectorMode"].IsString()) {
|
if (doc["detectorMode"].IsString()) {
|
||||||
detectorMode_s=doc["detectorMode"].GetString();
|
detectorMode_s=doc["detectorMode"].GetString();
|
||||||
|
#ifdef INTERP
|
||||||
if (detectorMode_s == "interpolating"){
|
if (detectorMode_s == "interpolating"){
|
||||||
dMode=eInterpolating;
|
dMode=eInterpolating;
|
||||||
mt->setInterpolation(interp);
|
mt->setInterpolation(interp);
|
||||||
} else if (detectorMode_s == "counting"){
|
} else
|
||||||
|
#endif
|
||||||
|
if (detectorMode_s == "counting"){
|
||||||
dMode=ePhotonCounting;
|
dMode=ePhotonCounting;
|
||||||
|
#ifdef INTERP
|
||||||
mt->setInterpolation(NULL);
|
mt->setInterpolation(NULL);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
dMode=eAnalog;
|
dMode=eAnalog;
|
||||||
|
#ifdef INTERP
|
||||||
mt->setInterpolation(NULL);
|
mt->setInterpolation(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,74 +10,6 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
/* class threadedInterpolatingDetector : public threadedCountingDetector */
|
|
||||||
/* { */
|
|
||||||
/* public: */
|
|
||||||
/* threadedInterpolatingDetector(interpolatingDetector *d, int fs=10000) : threadedCountingDetector(d,fs) {}; */
|
|
||||||
|
|
||||||
/* virtual void prepareInterpolation(int &ok){ */
|
|
||||||
/* slsInterpolation *interp=((interpolatingDetector*)det)->getInterpolation(); */
|
|
||||||
/* if (interp) */
|
|
||||||
/* interp->prepareInterpolation(ok); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* 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=((interpolatingDetector*)det)->getInterpolation(); */
|
|
||||||
/* if (interp) */
|
|
||||||
/* return interp->setFlatField(ff, nb, emin, emax); */
|
|
||||||
/* else */
|
|
||||||
/* return NULL; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* void *writeFlatField(const char * 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=((interpolatingDetector*)det)->getInterpolation(); */
|
|
||||||
/* if (interp) */
|
|
||||||
/* interp->readFlatField(imgname, nb, emin, emax); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* 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 slsInterpolation *getInterpolation() { */
|
|
||||||
/* return ((interpolatingDetector*)det)->getInterpolation(); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* virtual void resetFlatField() { ((interpolatingDetector*)det)->resetFlatField();}; */
|
|
||||||
|
|
||||||
|
|
||||||
/* 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; */
|
|
||||||
/* }; */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class multiThreadedInterpolatingDetector : public multiThreadedCountingDetector
|
class multiThreadedInterpolatingDetector : public multiThreadedCountingDetector
|
||||||
{
|
{
|
||||||
@ -125,13 +57,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||||
int ok;
|
int ok;
|
||||||
// for (int i=0; i<nThreads; i++) {
|
for (int i=0; i<nThreads; i++)
|
||||||
cout << "mt" << endl;
|
(dets[i])->setInterpolation(f);
|
||||||
return (dets[0])->setInterpolation(f);
|
return (dets[0])->getInterpolation();
|
||||||
//dets[i]->setMutex(&fmutex);
|
|
||||||
// }
|
|
||||||
//dets[0]->prepareInterpolation(ok);
|
|
||||||
//return (slsInterpolation*)((interpolatingDetector*)dets[0])->getInterpolation();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual slsInterpolation *getInterpolation(){
|
virtual slsInterpolation *getInterpolation(){
|
||||||
@ -141,6 +69,25 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual int *getImage(int &nnx, int &nny, int &ns) {
|
||||||
|
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns);
|
||||||
|
//if one interpolates, the whole image is stored in detector 0;
|
||||||
|
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];
|
||||||
|
img=dets[0]->getImage();
|
||||||
|
for (int i=0; i<nn; i++) {
|
||||||
|
image[i]=img[i];
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user