mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 04:17:15 +02:00
Implemenging common mode and ghost corrections for moench03 (and generalized)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#define CORR
|
||||
|
||||
//#define VERSION_V1
|
||||
|
||||
@ -28,8 +28,11 @@
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "multiThreadedCountingDetector.h"
|
||||
//#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -89,7 +92,18 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
int ncol_cm=20;
|
||||
double xt_ghost=0.00045;
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs;
|
||||
double *gainmap=NULL;
|
||||
#ifdef CORR
|
||||
cout << "Applying common mode and ghost correction " << endl;
|
||||
cm=new moench03CommonMode(ncol_cm);
|
||||
gs=new moench03GhostSummation(decoder, xt_ghost);
|
||||
#endif
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
@ -171,9 +185,10 @@ int main(int argc, char *argv[]) {
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
|
||||
//#ifndef ANALOG
|
||||
#ifndef ANALOG
|
||||
filter->setThreshold(thr);
|
||||
//#endif
|
||||
#endif
|
||||
cf=0;
|
||||
|
||||
} else
|
||||
cf=1;
|
||||
@ -181,17 +196,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
@ -204,7 +215,7 @@ int main(int argc, char *argv[]) {
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cout << "Analog!" << endl;
|
||||
cf=0;
|
||||
// thr1=thr;
|
||||
thr1=thr;
|
||||
#endif
|
||||
// }
|
||||
|
||||
@ -240,7 +251,7 @@ int main(int argc, char *argv[]) {
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0)
|
||||
if (ifr%100==0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
@ -308,7 +319,7 @@ int main(int argc, char *argv[]) {
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%1000==0) cout << ifr << " " << ff << endl;
|
||||
if (ifr%100==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...)
|
||||
@ -334,9 +345,10 @@ int main(int argc, char *argv[]) {
|
||||
if (nframes>0) {
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
} else {
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
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();
|
||||
@ -351,6 +363,13 @@ int main(int argc, char *argv[]) {
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
}
|
||||
if (nframes<0){
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
strcpy(imgfname,ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -3,13 +3,15 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
//#include <zmq.h>
|
||||
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
|
||||
#include<iostream>
|
||||
@ -110,12 +112,16 @@ int main(int argc, char *argv[]) {
|
||||
int dataSize=size;
|
||||
|
||||
char dummybuff[size];
|
||||
|
||||
|
||||
|
||||
|
||||
int ncol_cm=20;
|
||||
double xt_ghost=0.00045;
|
||||
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
|
||||
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
|
||||
double *gainmap=NULL;
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
|
||||
@ -126,7 +132,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
@ -654,7 +660,12 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL) {
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%d.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
#endif
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
|
Reference in New Issue
Block a user