Fixed seg fault
This commit is contained in:
parent
7937ecea49
commit
952e30d926
@ -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<nph; iph++) {
|
||||
// read photons 1 by 1
|
||||
@ -118,7 +120,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;
|
||||
@ -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;
|
||||
}
|
||||
|
8
test.py
8
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)
|
||||
|
Reference in New Issue
Block a user