diff --git a/slsDetectorCalibration/interpolatingDetector.h b/slsDetectorCalibration/interpolatingDetector.h index ed7623a37..48d1508b2 100644 --- a/slsDetectorCalibration/interpolatingDetector.h +++ b/slsDetectorCalibration/interpolatingDetector.h @@ -149,7 +149,7 @@ class interpolatingDetector : public singlePhotonDetector { { nph = addFrame(data, val, 1); if (interp) - return interp->getFlatField(); + return interp->getFlatFieldDistribution(); else return NULL; }; diff --git a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h index 88b61cc02..92f4cb3f2 100644 --- a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h @@ -238,96 +238,96 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { // cout <<"******"<< etax << " " << etay << endl; - return addToFlatField(etax, etay); + return addToFlatFieldDistribution(etax, etay); } - virtual int addToFlatField(double totquad, int quad, double *cl, - double &etax, double &etay) { - double cc[2][2]; - int xoff = 0, yoff = 0; + /* virtual int addToFlatField(double totquad, int quad, double *cl, */ + /* double &etax, double &etay) { */ + /* double cc[2][2]; */ + /* int xoff = 0, yoff = 0; */ - switch (quad) { - case BOTTOM_LEFT: - xoff = 0; - yoff = 0; - break; - case BOTTOM_RIGHT: - xoff = 1; - yoff = 0; - break; - case TOP_LEFT: - xoff = 0; - yoff = 1; - break; - case TOP_RIGHT: - xoff = 1; - yoff = 1; - break; - default:; - } - cc[0][0] = cl[xoff + 3 * yoff]; - cc[1][0] = cl[(yoff + 1) * 3 + xoff]; - cc[0][1] = cl[yoff * 3 + xoff + 1]; - cc[1][1] = cl[(yoff + 1) * 3 + xoff + 1]; + /* switch (quad) { */ + /* case BOTTOM_LEFT: */ + /* xoff = 0; */ + /* yoff = 0; */ + /* break; */ + /* case BOTTOM_RIGHT: */ + /* xoff = 1; */ + /* yoff = 0; */ + /* break; */ + /* case TOP_LEFT: */ + /* xoff = 0; */ + /* yoff = 1; */ + /* break; */ + /* case TOP_RIGHT: */ + /* xoff = 1; */ + /* yoff = 1; */ + /* break; */ + /* default:; */ + /* } */ + /* cc[0][0] = cl[xoff + 3 * yoff]; */ + /* cc[1][0] = cl[(yoff + 1) * 3 + xoff]; */ + /* cc[0][1] = cl[yoff * 3 + xoff + 1]; */ + /* cc[1][1] = cl[(yoff + 1) * 3 + xoff + 1]; */ - /* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */ - /* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */ - /* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */ - /* cout <<"******"<Fill(etax, etay); -#endif -#ifndef MYROOT1 - int ex, ey; - ex = (etax - etamin) / etastepX; - ey = (etay - etamin) / etastepY; - if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) - heta[ey * nbetaX + ex]++; -#endif - return 0; - }; +/* virtual int addToFlatFieldDistribution(double etax, double etay) { */ +/* #ifdef MYROOT1 */ +/* heta->Fill(etax, etay); */ +/* #endif */ +/* #ifndef MYROOT1 */ +/* int ex, ey; */ +/* ex = (etax - etamin) / etastepX; */ +/* ey = (etay - etamin) / etastepY; */ +/* if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) */ +/* heta[ey * nbetaX + ex]++; */ +/* #endif */ +/* return 0; */ +/* }; */ virtual int *getInterpolatedImage() { int ipx, ipy; diff --git a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h index 3b1eabab6..da2551964 100644 --- a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h @@ -205,44 +205,44 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { double &etay) { calcEta3(cl, etax, etay, totquad); - return addToFlatField(etax, etay); + return addToFlatFieldDistribution(etax, etay); } - virtual int addToFlatField(double totquad, int quad, double *cl, - double &etax, double &etay) { + /* virtual int addToFlatField(double totquad, int quad, double *cl, */ + /* double &etax, double &etay) { */ - calcEta3(cl, etax, etay, totquad); - return addToFlatField(etax, etay); - } + /* calcEta3(cl, etax, etay, totquad); */ + /* return addToFlatField(etax, etay); */ + /* } */ ////////////////////////////////////////////////////////////////////////////////////// - virtual int addToFlatField(double *cluster, double &etax, double &etay) { - double totquad; - calcEta3(cluster, etax, etay, totquad); - return addToFlatField(etax, etay); - }; + /* virtual int addToFlatField(double *cluster, double &etax, double &etay) { */ + /* double totquad; */ + /* calcEta3(cluster, etax, etay, totquad); */ + /* return addToFlatField(etax, etay); */ + /* }; */ - virtual int addToFlatField(int *cluster, double &etax, double &etay) { + /* virtual int addToFlatField(int *cluster, double &etax, double &etay) { */ - double totquad; + /* double totquad; */ - calcEta3(cluster, etax, etay, totquad); - return addToFlatField(etax, etay); - }; + /* calcEta3(cluster, etax, etay, totquad); */ + /* return addToFlatField(etax, etay); */ + /* }; */ - virtual int addToFlatField(double etax, double etay) { -#ifdef MYROOT1 - heta->Fill(etax, etay); -#endif -#ifndef MYROOT1 - int ex, ey; - ex = (etax - etamin) / etastepX; - ey = (etay - etamin) / etastepY; - if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) - heta[ey * nbetaX + ex]++; -#endif - return 0; - }; +/* virtual int addToFlatField(double etax, double etay) { */ +/* #ifdef MYROOT1 */ +/* heta->Fill(etax, etay); */ +/* #endif */ +/* #ifndef MYROOT1 */ +/* int ex, ey; */ +/* ex = (etax - etamin) / etastepX; */ +/* ey = (etay - etamin) / etastepY; */ +/* if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) */ +/* heta[ey * nbetaX + ex]++; */ +/* #endif */ +/* return 0; */ +/* }; */ /* protected: */ diff --git a/slsDetectorCalibration/interpolations/etaInterpolationBase.h b/slsDetectorCalibration/interpolations/etaInterpolationBase.h index 20a4ff403..89b2d34de 100644 --- a/slsDetectorCalibration/interpolations/etaInterpolationBase.h +++ b/slsDetectorCalibration/interpolations/etaInterpolationBase.h @@ -128,7 +128,7 @@ class etaInterpolationBase : public slsInterpolation { return NULL; }; - int readFlatField(const char *imgname, double emin = 1, double emax = 0) { + void *readFlatField(const char *imgname, double emin = 1, double emax = 0) { if (emax >= 1) etamax = emax; if (emin <= 0) @@ -169,9 +169,9 @@ class etaInterpolationBase : public slsInterpolation { } } delete[] gm; - return 1; + return heta; } - return 0; + return NULL; }; float *gethhx() { @@ -183,12 +183,17 @@ class etaInterpolationBase : public slsInterpolation { // hhy->Scale((double)nSubPixels); return hhy; }; - virtual int addToFlatField(double etax, double etay) { + virtual int addToFlatFieldDistribution(double etax, double etay) { +#ifdef MYROOT1 + heta->Fill(etax, etay); +#endif +#ifndef MYROOT1 int ex, ey; ex = (etax - etamin) / etastepX; ey = (etay - etamin) / etastepY; if (ey < nbetaY && ex < nbetaX && ex >= 0 && ey >= 0) heta[ey * nbetaX + ex]++; +#endif return 0; }; diff --git a/slsDetectorCalibration/interpolations/noInterpolation.h b/slsDetectorCalibration/interpolations/noInterpolation.h index 1ccaed431..e88475954 100644 --- a/slsDetectorCalibration/interpolations/noInterpolation.h +++ b/slsDetectorCalibration/interpolations/noInterpolation.h @@ -78,20 +78,20 @@ class noInterpolation : public slsInterpolation { }; ////////////////////////////////////////////////////////////////////////////////////// - virtual int addToFlatField(double *cluster, double &etax, double &etay) { - return 0; - }; + /* virtual int addToFlatField(double *cluster, double &etax, double &etay) { */ + /* return 0; */ + /* }; */ - virtual int addToFlatField(int *cluster, double &etax, double &etay) { - return 0; - }; + /* virtual int addToFlatField(int *cluster, double &etax, double &etay) { */ + /* return 0; */ + /* }; */ - virtual int addToFlatField(double etax, double etay) { return 0; }; + virtual int addToFlatFieldDistribution(double etax, double etay) { return 0; }; - virtual int addToFlatField(double totquad, int quad, double *cl, - double &etax, double &etay) { - return 0; - }; + /* virtual int addToFlatField(double totquad, int quad, double *cl, */ + /* double &etax, double &etay) { */ + /* return 0; */ + /* }; */ virtual int addToFlatField(double totquad, int quad, int *cl, double &etax, double &etay) { diff --git a/slsDetectorCalibration/interpolations/slsInterpolation.h b/slsDetectorCalibration/interpolations/slsInterpolation.h index 2d1538594..11152adcf 100644 --- a/slsDetectorCalibration/interpolations/slsInterpolation.h +++ b/slsDetectorCalibration/interpolations/slsInterpolation.h @@ -175,29 +175,31 @@ class slsInterpolation { return hint; }; - virtual int addToFlatField(double *cluster, double &etax, double &etay) = 0; - virtual int addToFlatField(int *cluster, double &etax, double &etay) = 0; + //virtual int addToFlatField(double *cluster, double &etax, double &etay) = 0; + //virtual int addToFlatField(int *cluster, double &etax, double &etay) = 0; virtual int addToFlatField(double totquad, int quad, int *cl, double &etax, double &etay) = 0; - virtual int addToFlatField(double totquad, int quad, double *cluster, - double &etax, double &etay) = 0; - virtual int addToFlatField(double etax, double etay) = 0; + //virtual int addToFlatField(double totquad, int quad, double *cluster, + // double &etax, double &etay) = 0; + virtual int addToFlatFieldDistribution(double etax, double etay) = 0; - virtual int *getFlatField() { return NULL; }; - virtual int *setFlatField(int *h, int nb = -1, double emin = -1, + virtual int *getFlatFieldDistribution() { return NULL; }; + virtual int *setFlatField(int *h, int nbx = -1, int nby = -1, + double emin = -1, double emax = -1) { 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) { + virtual void *readFlatField(const char *imgname, + double emin = 1, double emax = 0) { return NULL; }; - virtual int *getFlatField(int &nb, double &emin, double &emax) { - nb = 0; + virtual int *getFlatField(int &nbx, int &nby, double &emin, double &emax) { + nbx = 0; + nby=0; emin = 0; emax = 0; - return getFlatField(); + return getFlatFieldDistribution(); }; virtual void resetFlatField() = 0; diff --git a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp index 889022679..36d370896 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp @@ -47,7 +47,6 @@ int main(int argc, char *argv[]) { #endif int iarg = 4; char infname[10000]; - char fname[10000]; char outfname[10000]; #ifndef FF iarg = 4; @@ -74,18 +73,17 @@ int main(int argc, char *argv[]) { int etabins = 1000; // nsubpix*2*100; double etamin = -1, etamax = 2; // double etamin=-0.1, etamax=1.1; - double eta3min = -2, eta3max = 2; - int quad; + // double eta3min = -2, eta3max = 2; double sum, totquad; double sDum[2][2]; - double etax, etay, int_x, int_y; - double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; - int ok; - int f0 = -1; + double etax, etay; + // double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y; + int ix, iy, isx, isy; int nframes = 0, lastframe = -1; - double d_x, d_y, res = 5, xx, yy; - int nph = 0, badph = 0, totph = 0; + //double d_x, d_y, res = 5, xx, yy; + int nph = 0, totph = 0; + //badph = 0, FILE *f = NULL; #ifdef DOUBLE_SPH @@ -96,7 +94,8 @@ int main(int argc, char *argv[]) { single_photon_hit cl(3, 3); #endif - int nSubPixels = nsubpix; + //int f0 = -1; + // int nSubPixels = nsubpix; #ifndef NOINTERPOLATION eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax); @@ -109,7 +108,12 @@ int main(int argc, char *argv[]) { #endif #ifndef FF + int quad; #ifndef NOINTERPOLATION + char fname[10000]; + int ok; + double int_x, int_y; + int *img; cout << "read ff " << argv[2] << endl; sprintf(fname, "%s", argv[2]); interp->readFlatField(fname); @@ -121,7 +125,6 @@ int main(int argc, char *argv[]) { cout << "Will write eta file " << argv[2] << endl; #endif - int *img; float *totimg = new float[NC * NR * nsubpix * nsubpix]; for (ix = 0; ix < NC; ix++) { for (iy = 0; iy < NR; iy++) { @@ -149,7 +152,7 @@ int main(int argc, char *argv[]) { if (f) { cout << infname << endl; nframes = 0; - f0 = -1; + //f0 = -1; while (cl.read(f)) { totph++; @@ -157,14 +160,21 @@ int main(int argc, char *argv[]) { lastframe = cl.iframe; // cout << cl.iframe << endl; // f0=cl.iframe; - if (nframes == 0) - f0 = lastframe; + // if (nframes == 0) + // f0 = lastframe; nframes++; } // quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum); +#ifndef FF quad = interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum); - if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 && +#endif +#ifdef FF + interp->calcEta(cl.get_cluster(), etax, etay, sum, + totquad, sDum); +#endif + + if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 && sum < cmax) { nph++; // if (sum>200 && sum<580) { @@ -199,7 +209,7 @@ int main(int argc, char *argv[]) { // if (cl.x>50) // #endif // if (etax!=0 && etay!=0 && etax!=1 && etay!=1) - interp->addToFlatField(etax, etay); + interp->addToFlatFieldDistribution(etax, etay); // if (etax==0 || etay==0) cout << cl.x << " " << cl.y << // endl; @@ -242,9 +252,9 @@ int main(int argc, char *argv[]) { } } } - cout << "Read " << nframes << " frames (first frame: " << f0 - << " last frame: " << lastframe << " delta:" << lastframe - f0 - << ") nph=" << nph << endl; + // cout << "Read " << nframes << " frames (first frame: " << f0 + // << " last frame: " << lastframe << " delta:" << lastframe - f0 + // << ") nph=" << nph << endl; interp->clearInterpolatedImage(); #endif diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index 431416f8d..1617057fe 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -502,13 +502,13 @@ int main(int argc, char *argv[]) { } #ifdef INTERP else if (fMode == eFlat) { - int nb; + int nbx, nby; double emi = 0, ema = 1; - int *ff = mt->getFlatField(nb, emi, ema); - nnx = nb; - nny = nb; - dout = new int32_t[nb * nb]; - for (int ix = 0; ix < nb * nb; ix++) { + int *ff = mt->getFlatField(nbx, nby, emi, ema); + nnx = nbx; + nny = nby; + dout = new int32_t[nbx * nby]; + for (int ix = 0; ix < nbx * nby; ix++) { dout[ix] = ff[ix]; } } diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index a7695c286..090be60b4 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -182,10 +182,10 @@ class threadedAnalogDetector { interp->prepareInterpolation(ok); } - virtual int *getFlatField() { + virtual int *getFlatFieldDistribution() { slsInterpolation *interp = (det)->getInterpolation(); if (interp) - return interp->getFlatField(); + return interp->getFlatFieldDistribution(); else return NULL; } @@ -208,19 +208,19 @@ class threadedAnalogDetector { return NULL; } - void *readFlatField(const char *imgname, int nb = -1, double emin = 1, + void *readFlatField(const char *imgname, double emin = 1, double emax = 0) { slsInterpolation *interp = (det)->getInterpolation(); if (interp) - return interp->readFlatField(imgname, nb, emin, emax); + return interp->readFlatField(imgname, emin, emax); return NULL; } - virtual int *getFlatField(int &nb, double emi, double ema) { + virtual int *getFlatField(int &nbx, int &nby, double &emi, double &ema) { slsInterpolation *interp = (det)->getInterpolation(); int *ff = NULL; if (interp) { - ff = interp->getFlatField(nb, emi, ema); + ff = interp->getFlatField(nbx, nby, emi, ema); } return ff; } diff --git a/slsDetectorCalibration/multiThreadedInterpolatingDetector.h b/slsDetectorCalibration/multiThreadedInterpolatingDetector.h index 53994ea9e..fd6cd0643 100644 --- a/slsDetectorCalibration/multiThreadedInterpolatingDetector.h +++ b/slsDetectorCalibration/multiThreadedInterpolatingDetector.h @@ -25,10 +25,10 @@ class multiThreadedInterpolatingDetector // } } - virtual int *getFlatField() { return (dets[0])->getFlatField(); } + virtual int *getFlatFieldDistribution() { return (dets[0])->getFlatFieldDistribution(); } - virtual int *getFlatField(int &nb, double emi, double ema) { - return (dets[0])->getFlatField(nb, emi, ema); + virtual int *getFlatField(int &nbx, int &nby, double &emi, double &ema) { + return (dets[0])->getFlatField(nbx, nby, emi, ema); } virtual int *setFlatField(int *h = NULL, int nb = -1, double emin = 1, @@ -40,9 +40,9 @@ class multiThreadedInterpolatingDetector return dets[0]->writeFlatField(imgname); }; - void *readFlatField(const char *imgname, int nb = -1, double emin = 1, + void *readFlatField(const char *imgname, double emin = 1, double emax = 0) { - return (dets[0])->readFlatField(imgname, nb, emin, emax); + return (dets[0])->readFlatField(imgname, emin, emax); }; /* virtual int setNSubPixels(int ns) { return