ComputationalRadiationPhysics / jungfrau-photoncounter

Conversion of Jungfrau pixel detector data to photon count rate
GNU General Public License v3.0
2 stars 2 forks source link

Reference Code #54

Closed kloppstock closed 4 years ago

kloppstock commented 5 years ago

I managed to identify and fix the bug mentioned in issue #34. I uploaded the current code to the reference branch in the reference directory. There seemed to be two problems in the singlePhotonDetector.h file:

  1. for some reason it crashed when allocating the variable double var[ny][nx] on the stack. The current workaround is to allocate this matrix on the heap like this (lines 336-338):

    double **val = new double *[ny];
    for (int i = 0; i < ny; ++i)
    val[i] = new double[nx];

    and free this at the end (lines 460 - 462) like this:

    for (int i = 0; i < ny; ++i)
    delete[] val[i];
    delete[] val;
  2. The loops beginning in line 362 iterated over the full detector. In addition to this some inner loops iterate from -(clusterSizeY / 2) to (clusterSizeY / 2) + 1 and are added onto the main index resulting into indices which are outside of the frame by (clusterSizeY / 2). This was fixed by taking these cluster sizes into account in the outer loops like this (lines 362, 363):

    for (int iy = ymin + (clusterSizeY / 2); iy < ymax - ((clusterSizeY / 2) + 1); iy++) {
    for (int ix = xmin + (clusterSizeY / 2); ix < xmax - ((clusterSizeY / 2) + 1); ix++) {
    // ...
    }
    }

Additionally, it seems that no frame numbers were stored which was fixed by changing lines 555 to 560 to:

for (int i = 0; i < nph; i++) {
  // save the frame number
  (cl + i)->iframe = fn + i;
  (cl + i)->write(f);
}

To adapt the program to take pedestal input, we also modified moench03ClusterFinder.cpp (see all parts annotated with //NOTE: modified).

Now the program compiles and runs. But generates a very large cluster file with your ordered data set. It was executed like this: ./moenchClusterFinderReordered ../../../ordered outdir e17050_1_00018_00000_image 1 2 ../../../../moench_data/1000_frames_pede_e17050_1_00018_00000.dat

Could you verify that this program still works as intended and if it doesn't give some hints on what went wrong?

Cheers, Jonas

kloppstock commented 4 years ago

Since no further feedback was given, I assume that the main branch outputs the desired result. If there are any unexpected outputs from this code, feel free to create a new issue for these problems.

Cheers, Jonas