Local loop indicies in analogDetector (#709)

* making ix and iy local variables in analogDetector
This commit is contained in:
Erik Fröjdh 2023-05-03 09:18:09 +02:00 committed by GitHub
parent 80fc7eb220
commit 61f290441e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 54 deletions

View File

@ -78,7 +78,7 @@ template <class dataType> class analogDetector {
stat[i] = new pedestalSubtraction[nx]; stat[i] = new pedestalSubtraction[nx];
/* pedMean[i]=new double[nx]; */ /* pedMean[i]=new double[nx]; */
/* pedVariance[i]=new double[nx]; */ /* pedVariance[i]=new double[nx]; */
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
stat[i][ix].SetNPedestals(nped); stat[i][ix].SetNPedestals(nped);
/* stat[i][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix])); /* stat[i][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix]));
*/ */
@ -166,8 +166,8 @@ template <class dataType> class analogDetector {
int nped = orig->SetNPedestals(); int nped = orig->SetNPedestals();
// cout << nped << " " << orig->getPedestal(ix,iy) << // cout << nped << " " << orig->getPedestal(ix,iy) <<
// orig->getPedestalRMS(ix,iy) << endl; // orig->getPedestalRMS(ix,iy) << endl;
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
// stat[iy][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix])); // stat[iy][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix]));
stat[iy][ix].SetNPedestals(nped); stat[iy][ix].SetNPedestals(nped);
setPedestal(ix, iy, orig->getPedestal(ix, iy), setPedestal(ix, iy, orig->getPedestal(ix, iy),
@ -298,8 +298,8 @@ template <class dataType> class analogDetector {
if (gmap) if (gmap)
delete[] gmap; delete[] gmap;
gmap = new double[nnx * nny]; gmap = new double[nnx * nny];
for (iy = 0; iy < static_cast<int>(nny); ++iy) { for (int iy = 0; iy < static_cast<int>(nny); ++iy) {
for (ix = 0; ix < static_cast<int>(nnx); ++ix) { for (int ix = 0; ix < static_cast<int>(nnx); ++ix) {
gmap[iy * nnx + ix] = gm[iy * nnx + ix]; gmap[iy * nnx + ix] = gm[iy * nnx + ix];
// cout << gmap[iy*nnx+ix] << " " ; // cout << gmap[iy*nnx+ix] << " " ;
} }
@ -319,8 +319,8 @@ template <class dataType> class analogDetector {
void *ret; void *ret;
if (gmap) { if (gmap) {
gm = new float[nx * ny]; gm = new float[nx * ny];
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
gm[iy * nx + ix] = gmap[iy * nx + ix]; gm[iy * nx + ix] = gmap[iy * nx + ix];
} }
} }
@ -335,8 +335,8 @@ template <class dataType> class analogDetector {
virtual void newDataSet() { virtual void newDataSet() {
iframe = -1; iframe = -1;
for (iy = 0; iy < ny; ++iy) for (int iy = 0; iy < ny; ++iy)
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
stat[iy][ix].Clear(); stat[iy][ix].Clear();
image[iy * nx + ix] = 0; image[iy * nx + ix] = 0;
} }
@ -445,8 +445,8 @@ template <class dataType> class analogDetector {
// cout << "+"<< getId() << endl; // cout << "+"<< getId() << endl;
if (cmSub) { if (cmSub) {
// cout << "*" << endl; // cout << "*" << endl;
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
// if (getNumpedestals(ix,iy)>0) // if (getNumpedestals(ix,iy)>0)
// if (det->isGood(ix,iy)) { // if (det->isGood(ix,iy)) {
addToCommonMode(data, ix, iy); addToCommonMode(data, ix, iy);
@ -539,8 +539,8 @@ template <class dataType> class analogDetector {
if (ped == NULL) { if (ped == NULL) {
ped = new double[nx * ny]; ped = new double[nx * ny];
} }
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
ped[iy * nx + ix] = stat[iy][ix].getPedestal(); ped[iy * nx + ix] = stat[iy][ix].getPedestal();
// cout << ped[iy*nx+ix] << " " ; // cout << ped[iy*nx+ix] << " " ;
} }
@ -558,8 +558,8 @@ template <class dataType> class analogDetector {
if (ped == NULL) { if (ped == NULL) {
ped = new double[nx * ny]; ped = new double[nx * ny];
} }
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
ped[iy * nx + ix] = stat[iy][ix].getPedestalRMS(); ped[iy * nx + ix] = stat[iy][ix].getPedestalRMS();
} }
} }
@ -592,8 +592,8 @@ template <class dataType> class analogDetector {
*/ */
virtual void setPedestal(double *ped, double *rms = NULL, int m = -1) { virtual void setPedestal(double *ped, double *rms = NULL, int m = -1) {
double rr = 0; double rr = 0;
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (rms) if (rms)
rr = rms[iy * nx + ix]; rr = rms[iy * nx + ix];
stat[iy][ix].setPedestal(ped[iy * nx + ix], rr, m); stat[iy][ix].setPedestal(ped[iy * nx + ix], rr, m);
@ -619,8 +619,8 @@ template <class dataType> class analogDetector {
\param rms pointer to array of pedestal rms \param rms pointer to array of pedestal rms
*/ */
virtual void setPedestalRMS(double *rms) { virtual void setPedestalRMS(double *rms) {
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
stat[iy][ix].setPedestalRMS(rms[iy * nx + ix]); stat[iy][ix].setPedestalRMS(rms[iy * nx + ix]);
}; };
}; };
@ -662,8 +662,8 @@ template <class dataType> class analogDetector {
#endif #endif
gm = new float[nx * ny]; gm = new float[nx * ny];
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
gm[iy * nx + ix] = image[iy * nx + ix]; gm[iy * nx + ix] = image[iy * nx + ix];
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
hmap->SetBinContent(ix + 1, iy + 1, image[iy * nx + ix]); hmap->SetBinContent(ix + 1, iy + 1, image[iy * nx + ix]);
@ -710,8 +710,8 @@ template <class dataType> class analogDetector {
new TH2F("hmap", "hmap", nx, -0.5, nx - 0.5, ny, -0.5, ny - 0.5); new TH2F("hmap", "hmap", nx, -0.5, nx - 0.5, ny, -0.5, ny - 0.5);
#endif #endif
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
/* if (cmSub) */ /* if (cmSub) */
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); /* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode();
*/ */
@ -758,8 +758,8 @@ template <class dataType> class analogDetector {
nny = ny; nny = ny;
if (gm) { if (gm) {
for (iy = 0; iy < nny; ++iy) { for (int iy = 0; iy < nny; ++iy) {
for (ix = 0; ix < nnx; ++ix) { for (int ix = 0; ix < nnx; ++ix) {
stat[iy][ix].setPedestal(gm[iy * nx + ix], -1, -1); stat[iy][ix].setPedestal(gm[iy * nx + ix], -1, -1);
} }
} }
@ -783,8 +783,8 @@ template <class dataType> class analogDetector {
nny = ny; nny = ny;
if (gm) { if (gm) {
for (iy = 0; iy < nny; ++iy) { for (int iy = 0; iy < nny; ++iy) {
for (ix = 0; ix < nnx; ++ix) { for (int ix = 0; ix < nnx; ++ix) {
image[iy * nx + ix] = gm[iy * nx + ix]; image[iy * nx + ix] = gm[iy * nx + ix];
} }
} }
@ -808,8 +808,8 @@ template <class dataType> class analogDetector {
float *gm = NULL; float *gm = NULL;
void *ret; void *ret;
gm = new float[nx * ny]; gm = new float[nx * ny];
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
gm[iy * nx + ix] = stat[iy][ix].getPedestalRMS(); gm[iy * nx + ix] = stat[iy][ix].getPedestalRMS();
} }
} }
@ -832,8 +832,8 @@ template <class dataType> class analogDetector {
if (nny > ny) if (nny > ny)
nny = ny; nny = ny;
if (gm) { if (gm) {
for (iy = 0; iy < nny; ++iy) { for (uint32_t iy = 0; iy < nny; ++iy) {
for (ix = 0; ix < nnx; ++ix) { for (uint32_t ix = 0; ix < nnx; ++ix) {
stat[iy][ix].setPedestalRMS(gm[iy * nx + ix]); stat[iy][ix].setPedestalRMS(gm[iy * nx + ix]);
} }
} }
@ -862,8 +862,8 @@ template <class dataType> class analogDetector {
// cout << xmin << " " << xmax << endl; // cout << xmin << " " << xmax << endl;
// cout << ymin << " " << ymax << endl; // cout << ymin << " " << ymax << endl;
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (det->isGood(ix, iy)) { if (det->isGood(ix, iy)) {
// addToPedestal(data,ix,iy,1); // addToPedestal(data,ix,iy,1);
addToPedestal(data, ix, iy, cm); addToPedestal(data, ix, iy, cm);
@ -997,14 +997,13 @@ template <class dataType> class analogDetector {
virtual int *subtractPedestal(char *data, int *val = NULL, int cm = 0) { virtual int *subtractPedestal(char *data, int *val = NULL, int cm = 0) {
newFrame(data); newFrame(data);
if (val == NULL) if (val == NULL)
val = image; // new double[nx*ny]; val = image; // new double[nx*ny];
// calcGhost(data); // calcGhost(data);
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (det->isGood(ix, iy)) if (det->isGood(ix, iy))
val[iy * nx + ix] += subtractPedestal(data, ix, iy, cm); val[iy * nx + ix] += subtractPedestal(data, ix, iy, cm);
} }
@ -1152,8 +1151,6 @@ template <class dataType> class analogDetector {
image is used \returns pointer to array containing the number of photons image is used \returns pointer to array containing the number of photons
*/ */
virtual int *getNPhotons(char *data, int *nph = NULL) { virtual int *getNPhotons(char *data, int *nph = NULL) {
// double val;
if (nph == NULL) if (nph == NULL)
nph = image; nph = image;
@ -1169,8 +1166,8 @@ template <class dataType> class analogDetector {
/* } */ /* } */
// calcGhost(data); // calcGhost(data);
addToCommonMode(data); addToCommonMode(data);
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
switch (fMode) { switch (fMode) {
case eRaw: case eRaw:
// cout << "raw" << endl; // cout << "raw" << endl;
@ -1190,8 +1187,8 @@ template <class dataType> class analogDetector {
*/ */
virtual void clearImage() { virtual void clearImage() {
for (iy = 0; iy < ny; ++iy) { for (int iy = 0; iy < ny; ++iy) {
for (ix = 0; ix < nx; ++ix) { for (int ix = 0; ix < nx; ++ix) {
image[iy * nx + ix] = 0; image[iy * nx + ix] = 0;
} }
} }
@ -1219,10 +1216,9 @@ template <class dataType> class analogDetector {
\returns actual number of samples \returns actual number of samples
*/ */
int SetNPedestals(int i = -1) { int SetNPedestals(int i = -1) {
int ix = 0, iy = 0;
if (i > 0) if (i > 0)
for (iy = 0; iy < ny; ++iy) for (int iy = 0; iy < ny; ++iy)
for (ix = 0; ix < nx; ++ix) for (int ix = 0; ix < nx; ++ix)
stat[iy][ix].SetNPedestals(i); stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals(); return stat[0][0].SetNPedestals();
}; };
@ -1264,8 +1260,8 @@ template <class dataType> class analogDetector {
newFrame(data); newFrame(data);
// calcGhost(data); // calcGhost(data);
addToCommonMode(data); addToCommonMode(data);
for (iy = ymi; iy < yma; ++iy) for (int iy = ymi; iy < yma; ++iy)
for (ix = xmi; ix < xma; ++ix) for (int ix = xmi; ix < xma; ++ix)
if (det->isGood(ix, iy)) { if (det->isGood(ix, iy)) {
if (ix >= 0 && ix < nx && iy >= 0 && iy < ny) if (ix >= 0 && ix < nx && iy >= 0 && iy < ny)
val += convertToPhotons(data, ix, iy); val += convertToPhotons(data, ix, iy);
@ -1379,7 +1375,6 @@ template <class dataType> class analogDetector {
frameMode fMode; /**< current detector frame mode */ frameMode fMode; /**< current detector frame mode */
detectorMode dMode; /**< current detector frame mode */ detectorMode dMode; /**< current detector frame mode */
FILE *myFile; /**< file pointer to write to */ FILE *myFile; /**< file pointer to write to */
int ix, iy;
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
TH2F *hs; TH2F *hs;
#ifdef ROOTCLUST #ifdef ROOTCLUST

View File

@ -233,8 +233,8 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
//cout << "add to common mode?" << endl; //cout << "add to common mode?" << endl;
addToCommonMode(data); addToCommonMode(data);
} }
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (det->isGood(ix, iy)) { if (det->isGood(ix, iy)) {
val = subtractPedestal(data, ix, iy, cm); val = subtractPedestal(data, ix, iy, cm);
@ -252,8 +252,8 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
} }
} }
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (det->isGood(ix, iy)) { if (det->isGood(ix, iy)) {
eventMask[iy][ix] = PEDESTAL; eventMask[iy][ix] = PEDESTAL;
@ -404,8 +404,8 @@ class singlePhotonDetector : public analogDetector<uint16_t> {
double *val = new double[ny * nx]; double *val = new double[ny * nx];
for (iy = ymin; iy < ymax; ++iy) { for (int iy = ymin; iy < ymax; ++iy) {
for (ix = xmin; ix < xmax; ++ix) { for (int ix = xmin; ix < xmax; ++ix) {
if (det->isGood(ix, iy) == 0) if (det->isGood(ix, iy) == 0)
continue; continue;