fixed some interpolation issues (#796)

This commit is contained in:
anberga
2023-08-28 13:38:19 +02:00
committed by GitHub
parent f0b2a6f6f9
commit b367b7e431
5 changed files with 101 additions and 33 deletions

View File

@ -3,33 +3,34 @@
### edit with hostname or IP address of your detector ### edit with hostname or IP address of your detector
############################################ ############################################
#hostname bchip181+ #hostname bchip181+
hostname bchip135 hostname bchip296
############################################# #############################################
### edit with hostname or 1Gbs IP address of your server ### edit with hostname or 1Gbs IP address of your server
############################################ ############################################
rx_hostname mpc2011 rx_hostname mpc2011:7777
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
udp_dstip 10.1.1.102 udp_dstip 10.1.2.102
############################################# #############################################
### edit with any number in the subnet of your server (first 3 numbers as above) ### edit with any number in the subnet of your server (first 3 numbers as above)
############################################ ############################################
udp_srcip 10.1.1.19 udp_srcip 10.1.2.19
udp_dstport 32411 udp_dstport 32777
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
rx_zmqip 10.1.1.102 rx_zmqip 10.1.2.102
rx_zmqport 50003 rx_zmqport 8003
############################################# #############################################
### edit with 1 Gbs IP of PC where you will run the GUI ### edit with 1 Gbs IP of PC where you will run the GUI
############################################ ############################################
zmqip 129.129.202.57 zmqip 129.129.202.57
zmqport 50001 zmqport 8001
@ -38,7 +39,7 @@ rx_zmqstream 1
frames 100000 frames 1
period 0.0006 period 0.0006
exptime 0.00035 exptime 0.00035
@ -49,8 +50,8 @@ fpath /mnt/moench_data/scratch1/
fwrite 0 fwrite 0
rx_jsonpara frameMode frame rx_jsonpara frameMode pedestal
rx_jsonpara detectorMode counting rx_jsonpara detectorMode analog
rx_discardpolicy discardpartial rx_discardpolicy discardpartial

View File

@ -357,6 +357,16 @@ class slsInterpolation {
} }
} }
/* cout << "(((" << totquad << "\t" << corner << endl; */
/* for (int iy=0; iy<3; iy++) { */
/* for (int ix=0; ix<3; ix++) */
/* cout << cl[ix+iy*3] <<"\t"; */
/* cout << endl; */
/* } */
/* cout << ")))" << endl; */
return corner; return corner;
} }
@ -370,6 +380,10 @@ class slsInterpolation {
etax = r / totquad; etax = r / totquad;
etay = t / totquad; etay = t / totquad;
} }
/* cout << "************" << endl; */
/* cout << sDum[0][0]<< "\t"<<sDum[0][1] << endl << sDum[1][0]<< "\t"<<sDum[1][1] << endl; */
/* cout << "***************" <<endl; */
/* cout << etax << " " << etay << endl; */
return 0; return 0;
} }

View File

@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
#ifndef FF #ifndef FF
if (argc < 9) { if (argc < 9) {
cout << "Wrong usage! Should be: " << argv[0] cout << "Wrong usage! Should be: " << argv[0]
<< " infile etafile outfile runmin runmax ns cmin cmax" << endl; << " infile etafile outfile runmin runmax ns [cmin cmax xmin xmax ymin ymax]" << endl;
return 1; return 1;
} }
#endif #endif
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
#ifdef FF #ifdef FF
if (argc < 7) { if (argc < 7) {
cout << "Wrong usage! Should be: " << argv[0] cout << "Wrong usage! Should be: " << argv[0]
<< " infile etafile runmin runmax cmin cmax" << endl; << " infile etafile runmin runmax [cmin cmax xmin xmax ymin ymax]" << endl;
return 1; return 1;
} }
#endif #endif
@ -65,13 +65,30 @@ int main(int argc, char *argv[]) {
nsubpix = atoi(argv[iarg++]); nsubpix = atoi(argv[iarg++]);
cout << "Subpix: " << nsubpix << endl; cout << "Subpix: " << nsubpix << endl;
#endif #endif
float cmin = atof(argv[iarg++]);
float cmax = atof(argv[iarg++]); float cmin = 0;
float cmax=1000000;
if (argc>iarg)
cmin=atof(argv[iarg++]);
if (argc>iarg)
cmax= atof(argv[iarg++]);
cout << "Energy min: " << cmin << endl; cout << "Energy min: " << cmin << endl;
cout << "Energy max: " << cmax << endl; cout << "Energy max: " << cmax << endl;
int xmin=0, xmax=NC, ymin=0, ymax=NR;
if (argc>iarg)
xmin=atof(argv[iarg++]);
if (argc>iarg)
xmax= atof(argv[iarg++]);
if (argc>iarg)
ymin=atof(argv[iarg++]);
if (argc>iarg)
ymax= atof(argv[iarg++]);
// int etabins=500; // int etabins=500;
int etabins = 1000; // nsubpix*2*100; int etabins = 1000; // nsubpix*2*100;
double etamin = -1, etamax = 2; double etamin = -0.25, etamax = 1.25;
// double etamin=-0.1, etamax=1.1; // double etamin=-0.1, etamax=1.1;
// double eta3min = -2, eta3max = 2; // double eta3min = -2, eta3max = 2;
double sum, totquad; double sum, totquad;
@ -80,7 +97,7 @@ int main(int argc, char *argv[]) {
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; // double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
int ix, iy, isx, isy; int ix, iy, isx, isy;
int nframes = 0, lastframe = -1; int nframes = 0, lastframe = -1, iframe, nphFrame;
//double d_x, d_y, res = 5, xx, yy; //double d_x, d_y, res = 5, xx, yy;
int nph = 0, totph = 0; int nph = 0, totph = 0;
//badph = 0, //badph = 0,
@ -98,7 +115,7 @@ int main(int argc, char *argv[]) {
// int nSubPixels = nsubpix; // int nSubPixels = nsubpix;
#ifndef NOINTERPOLATION #ifndef NOINTERPOLATION
eta2InterpolationPosXY *interp = eta2InterpolationPosXY *interp =
new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix, etabins, etabins, etamin, etamax);
// eta2InterpolationCleverAdaptiveBins *interp=new // eta2InterpolationCleverAdaptiveBins *interp=new
// eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, // eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin,
// etamax); // etamax);
@ -107,8 +124,8 @@ int main(int argc, char *argv[]) {
noInterpolation *interp = new noInterpolation(NC, NR, nsubpix); noInterpolation *interp = new noInterpolation(NC, NR, nsubpix);
#endif #endif
#ifndef FF
int quad; int quad;
#ifndef FF
#ifndef NOINTERPOLATION #ifndef NOINTERPOLATION
char fname[10000]; char fname[10000];
int ok; int ok;
@ -142,19 +159,26 @@ int main(int argc, char *argv[]) {
#endif #endif
int irun; int irun;
for (irun = runmin; irun < runmax; irun++) { for (irun = runmin; irun <= runmax; irun++) {
sprintf(infname, argv[1], irun); sprintf(infname, argv[1], irun);
#ifndef FF #ifndef FF
sprintf(outfname, argv[3], irun); sprintf(outfname, argv[3], irun);
#endif #endif
f = fopen(infname, "r"); f = fopen(infname, "r");
if (f) { if (f) {
cout << infname << endl; cout << infname << endl;
nframes = 0; nframes = 0;
//f0 = -1; //f0 = -1;
while (cl.read(f)) { //iff=0;
while (fread((void*)&iframe, 1, sizeof(int), f)) {
//n=0;
if (fread((void*)&nphFrame, 1, sizeof(int), f)) {
for (int iph=0; iph<nphFrame; iph++) {
//while (cl.read(f)) {
if (cl.read(f)) {
totph++; totph++;
if (lastframe != cl.iframe) { if (lastframe != cl.iframe) {
lastframe = cl.iframe; lastframe = cl.iframe;
@ -165,18 +189,28 @@ 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);
#ifndef FF // #ifndef FF
// quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
// totquad, sDum);
// #endif
// #ifdef FF
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum, quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
totquad, sDum); totquad, sDum);
#endif
#ifdef FF
interp->calcEta(cl.get_cluster(), etax, etay, sum, /* cl.print();
totquad, sDum); cout << "(" << etax <<","<< etay <<")"<< quad<< endl;
#endif */
//#endif
if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 && if (totquad > cmin && cl.x >= xmin && cl.x <= xmax &&
sum < cmax) { cl.y >= ymin && cl.y <= ymax &&
nph++; totquad < cmax) {
// if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
// sum < cmax) {
nph++;
// if (sum>200 && sum<580) { // if (sum>200 && sum<580) {
// interp->getInterpolatedPosition(cl.x,cl.y, // interp->getInterpolatedPosition(cl.x,cl.y,
// totquad,quad,cl.get_cluster(),int_x, int_y); // totquad,quad,cl.get_cluster(),int_x, int_y);
@ -227,9 +261,12 @@ int main(int argc, char *argv[]) {
#ifdef FF #ifdef FF
interp->writeFlatField(outfname); interp->writeFlatField(outfname);
#endif #endif
}
} }
} }
} }
}
}
fclose(f); fclose(f);
#ifdef FF #ifdef FF

View File

@ -720,6 +720,22 @@ int main(int argc, char *argv[]) {
ymin >> ymax; ymin >> ymax;
} }
if (addJsonHeader.find("xMin") != addJsonHeader.end()) {
istringstream(addJsonHeader.at("xMin")) >> xmin;
}
if (addJsonHeader.find("yMin") != addJsonHeader.end()) {
istringstream(addJsonHeader.at("yMin")) >> ymin;
}
if (addJsonHeader.find("xMax") != addJsonHeader.end()) {
istringstream(addJsonHeader.at("xMax")) >> xmax;
}
if (addJsonHeader.find("yMax") != addJsonHeader.end()) {
istringstream(addJsonHeader.at("yMax")) >> ymax;
}
cprintf(MAGENTA, "%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); mt->setROI(xmin, xmax, ymin, ymax);
if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) { if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {

View File

@ -533,7 +533,7 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
(clusters + nph)->print(); (clusters + nph)->print();
cout << max << " " << val[iy * nx + ix] << endl; cout << max << " " << val[iy * nx + ix] << endl;
} }
good = 1; //good = 1;
if (eMin > 0 && tot < eMin) if (eMin > 0 && tot < eMin)
good = 0; good = 0;
if (eMax > 0 && tot > eMax) if (eMax > 0 && tot > eMax)
@ -542,7 +542,7 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
nph++; nph++;
image[iy * nx + ix]++; image[iy * nx + ix]++;
} }
good=1;
} else if (ee == PEDESTAL) { } else if (ee == PEDESTAL) {
addToPedestal(data, ix, iy, cm); addToPedestal(data, ix, iy, cm);
} /*else { } /*else {