Update 2-ph sample size to 6; optimize MC logics

This commit is contained in:
2026-06-10 11:28:38 +02:00
parent 09de999c72
commit edaa191490
2 changed files with 5 additions and 6 deletions
+4 -2
View File
@@ -12,7 +12,7 @@ def generate_sample(input_tuple):
### generate samples with given number of photons, energy, sample size, and noise level
'''
input file contains single photon clusters (3x3)
assemble them into multi-photon pile-up clusters (e.g. 7x7 for 2 photons, 9x9 for 3 photons)
assemble them into multi-photon pile-up clusters (e.g. 6x6 for 2 photons, 9x9 for 3 photons)
'''
output_path = conf.output_folder
all_samples, all_labels = None, None
@@ -49,7 +49,9 @@ def generate_sample(input_tuple):
_sample = all_samples[_idx]
_label = all_labels[_idx].copy() ### copy the label to avoid modifying the original label in all_labels
_ref_x, _ref_y = np.random.randint(conf.sample_size, conf.sample_size*2-2), np.random.randint(conf.sample_size, conf.sample_size*2-2) ### random reference point of the lower-left photon in the sample, make sure the 3x3 cluster can fit in the sample
_ref_x, _ref_y = np.random.randint(0, sample.shape[1]-3), np.random.randint(0, sample.shape[0]-3) ### random reference point of the lower-left photon in the sample, make sure the 3x3 cluster can fit in the sample
if _ == 0:
_ref_x, _ref_y = sample.shape[1]//2-1, sample.shape[0]//2-1 ### for the first photon, place it in the center of the sample, to reduce the phase space
sample[_ref_y:_ref_y+3, _ref_x:_ref_x+3] += _sample ### add the 3x3 cluster to the sample
_label[0] += _ref_x
_label[1] += _ref_y