diff --git a/examples/cluster_example.py b/examples/cluster_example.py index cd99218..1fd4749 100644 --- a/examples/cluster_example.py +++ b/examples/cluster_example.py @@ -17,7 +17,7 @@ emax=30 ecutmin=8 ecutmax=12 etabins=251 -csize=3 +csize=2 gain=150 nbins=100 indmin=1 diff --git a/src/ClusterReader.c b/src/ClusterReader.c index 37ac6d1..5f8ad11 100644 --- a/src/ClusterReader.c +++ b/src/ClusterReader.c @@ -95,7 +95,6 @@ static PyObject *ClusterFileReader_read(ClusterFileReader *self, npy_intp dims[] = {size}; // If possible numpy will ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc // use the underlying buffer, otherwise it will create a copy, for example // if data type is different or we pass in a list. The // NPY_ARRAY_C_CONTIGUOUS flag ensures that we have contiguous memory. diff --git a/src/cluster_reader.c b/src/cluster_reader.c index 2c952bd..7837482 100644 --- a/src/cluster_reader.c +++ b/src/cluster_reader.c @@ -58,34 +58,6 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, double noise; // read photons left from previous frame if (nph) { -<<<<<<< HEAD - for (int iph=0; iphx>=0 && ptr->xy>=0 && ptr->ydata[4]; - analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, NULL, NULL, NULL); - noise=noise_map[ptr->y*nx+ptr->x]; - if (tot1>noise && t2max>2*noise && tot3>3*noise) { - ; - } else - good=0; - } else { - printf("Bad pixel number %d %d\n",ptr->x,ptr->y); - good=0; - } - } - if (good) { - ptr++; - nph_read++; - (*n_left)--; - } - if (nph_read >= n_clusters) - break; - } -======= for (int iph = 0; iph < nph; iph++) { // read photons 1 by 1 fread((void *)(ptr), sizeof(Cluster), 1, fp); @@ -94,7 +66,7 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, if (ptr->x >= 0 && ptr->x < nx && ptr->y >= 0 && ptr->y < ny) { tot1 = ptr->data[4]; analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL); + NULL); noise = noise_map[ptr->y * nx + ptr->x]; if (tot1 > noise && t2max > 2 * noise && tot3 > 3 * noise) { ; @@ -113,13 +85,11 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, if (nph_read >= n_clusters) break; } ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc } if (nph_read < n_clusters) { // keep on reading frames and photons until reaching n_clusters while (fread(&iframe, sizeof(iframe), 1, fp)) { -<<<<<<< HEAD //printf("%d\n",nph_read); if (fread(&nph, sizeof(nph), 1, fp)) { @@ -157,55 +127,12 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, if (nph_read >= n_clusters) break; } -======= - // printf("%d\n",nph_read); - - if (fread(&nph, sizeof(nph), 1, fp)) { - // printf("** %d\n",nph); - *n_left = nph; - for (int iph = 0; iph < nph; iph++) { - // read photons 1 by 1 - fread((void *)(ptr), sizeof(Cluster), 1, fp); - good = 1; - if (noise_map) { - if (ptr->x >= 0 && ptr->x < nx && ptr->y >= 0 && - ptr->y < ny) { - tot1 = ptr->data[4]; - analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - NULL); - noise = noise_map[ptr->y * nx + ptr->x]; - if (tot1 > noise && t2max > 2 * noise && - tot3 > 3 * noise) { - ; - } else - good = 0; - } else { - printf("Bad pixel number %d %d\n", ptr->x, ptr->y); - good = 0; - } - } - if (good) { - ptr++; - nph_read++; - (*n_left)--; - } - if (nph_read >= n_clusters) - break; - } - } - - if (nph_read >= n_clusters) - break; - } ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc } // printf("%d\n",nph_read); assert(nph_read <= n_clusters); // sanity check in debug mode return nph_read; } -<<<<<<< HEAD @@ -213,9 +140,6 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int analyze_clusters(int64_t n_clusters, int32_t *cin, ClusterAnalysis *co, int csize) { -======= -int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) { ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc int32_t tot2[4], t2max; char quad; @@ -224,9 +148,7 @@ int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) { int nc=0; //printf("csize is %d\n",csize); int ret; - for (int ic = 0; ic < n_clusters; ic++) { -<<<<<<< HEAD - + for (int ic = 0; ic < n_clusters; ic++) { switch (csize) { case 2: ret=analyze_data((cin+9*ic), &tot, NULL, &quad, &etax,&etay, NULL, NULL); @@ -248,22 +170,11 @@ int analyze_clusters(int64_t n_clusters, Cluster *cin, ClusterAnalysis *cout) { /* if (tot<=0) */ /* printf("%d %d %d %d %d %d\n",ic,(cin+ic)->x, (cin+ic)->y, */ /* (cout+ic)->c, (cout+ic)->tot2, (cout+ic)->tot3); */ -======= - analyze_cluster(*(cin + ic), &t2max, &tot3, &quad, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL); - - (cout + ic)->c = quad; - (cout + ic)->tot2 = t2max; - (cout + ic)->tot3 = tot3; - // printf("%d %d %d %d %d %d\n",ic,(cin+ic)->x, (cin+ic)->y, - // (cout+ic)->c, (cout+ic)->tot2, (cout+ic)->tot3); ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc } return nc; } -<<<<<<< HEAD int analyze_cluster(Cluster cl, int32_t *t2, int32_t *t3, char *quad, double *eta2x, double *eta2y, double *eta3x, double *eta3y) { return analyze_data(cl.data, t2, t3, quad, eta2x, eta2y, eta3x, eta3y); @@ -274,14 +185,6 @@ int analyze_data(int32_t *data, int32_t *t2, int32_t *t3, char *quad, double *et int ok=1; -======= -int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, - double *eta2x, double *eta2y, double *eta3x, double *eta3y, - double *eta2Lx, double *eta2Ly, double *eta3Xx, - double *eta3Xy) { - - int ok = 1; ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc int32_t tot2[4], t2max; char c; @@ -292,7 +195,7 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, tot2[i] = 0; // t2max=0; for (int ix = 0; ix < 3; ix++) { -<<<<<<< HEAD + for (int iy = 0; iy < 3; iy++) { val = data[iy * 3 + ix]; // printf ("%d ",data[iy * 3 + ix]); @@ -307,34 +210,12 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, tot2[cTopRight] += val; } // printf ("\n"); -======= - for (int iy = 0; iy < 3; iy++) { - val = cin.data[iy * 3 + ix]; - tot3 += val; - if (ix <= 1 && iy <= 1) - tot2[0] += val; - if (ix >= 1 && iy <= 1) - tot2[1] += val; - if (ix <= 1 && iy >= 1) - tot2[2] += val; - if (ix >= 1 && iy >= 1) - tot2[3] += val; - } ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc + } //printf ("\n"); if (t2 || quad) { -<<<<<<< HEAD - t2max = -1000; - c = 0; - for (int i = 0; i < 4; i++) { - if (tot2[i] > t2max) { - t2max = tot2[i]; - c = i; - } - } -======= + t2max = tot2[0]; c = cBottomLeft; for (int i = 1; i < 4; i++) { @@ -343,14 +224,13 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, c = i; } } ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc - } + if (quad) *quad = c; if (t2) *t2 = t2max; + } if (t3) -<<<<<<< HEAD *t3 = tot3; if (eta2x || eta2y) { @@ -395,22 +275,6 @@ int analyze_cluster(Cluster cin, int32_t *t2, int32_t *t3, char *quad, *eta3y=(double)(-data[1]+data[2*3+1])/(data[1]+data[4]+data[7]); } - /* if (tot3<=0) { */ - /* printf("*"); // t2max=0; */ - /* for (int ix = 0; ix < 3; ix++) { */ - /* for (int iy = 0; iy < 3; iy++) { */ - /* printf ("%d ",data[iy * 3 + ix]); */ - /* } */ - /* printf ("\n"); */ - /* } */ - /* printf ("\n"); */ - /* //return 0; */ - /* } */ - - -======= - *t3 = tot3; ->>>>>>> e1f22fd014eb86d40e0ecb78bd65cb7a9bef71bc return ok; }