diff --git a/src/cluster_reader.c b/src/cluster_reader.c index 2be9298..4207c72 100644 --- a/src/cluster_reader.c +++ b/src/cluster_reader.c @@ -84,7 +84,7 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le if (good) { ptr++; nph_read++; - *n_left--; + (*n_left)--; } if (nph_read >= n_clusters) break; @@ -94,8 +94,10 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le if (nph_read < n_clusters) { // keep on reading frames and photons until reaching n_clusters while (fread(&iframe, sizeof(iframe), 1, fp)) { + //printf("%d\n",nph_read); if (fread(&nph, sizeof(nph), 1, fp)) { + //printf("** %d\n",nph); *n_left = nph; for (int iph=0; iph= n_clusters) break; @@ -130,7 +132,7 @@ int read_clusters_with_cut(FILE *fp, int64_t n_clusters, Cluster *buf, int *n_le break; } } - + //printf("%d\n",nph_read); assert(nph_read <= n_clusters); // sanity check in debug mode return nph_read; } diff --git a/test.py b/test.py index 29dc96b..0d69015 100644 --- a/test.py +++ b/test.py @@ -1,14 +1,14 @@ from creader import ClusterFileReader, clusterize import numpy as np -# maxph=100000000 -maxph=100 +maxph=100000000 +#maxph=100 from pathlib import Path fpath = Path("/mnt/sls_det_storage/moench_data/Moench_LGAD_SIM_Nov22/moenchLGAD202211/clustW17new/beam_En800eV_-40deg_300V_10us_d0_f5_0.clust") # r = ClusterFileReader() -a=np.zeros([400,400]) -#a=None #np.array([]) +#a=np.zeros([400,400]) +a=None #np.array([]) r = ClusterFileReader(fpath.as_posix()) a=r.read(maxph,a)