From edaa191490add2ddea23f90620fdfdb80a38dc9e Mon Sep 17 00:00:00 2001 From: "xiangyu.xie" Date: Wed, 10 Jun 2026 11:28:38 +0200 Subject: [PATCH] Update 2-ph sample size to 6; optimize MC logics --- GeneratePileupSample.py | 6 ++++-- UsefulFuncs.py | 5 +---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/GeneratePileupSample.py b/GeneratePileupSample.py index ec1cad0..8074968 100644 --- a/GeneratePileupSample.py +++ b/GeneratePileupSample.py @@ -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 diff --git a/UsefulFuncs.py b/UsefulFuncs.py index 851df99..0ecda13 100644 --- a/UsefulFuncs.py +++ b/UsefulFuncs.py @@ -13,7 +13,7 @@ _pedestalAduFrame = None ### global pedestalAduFrame _noiseEneFrame = None ### global noiseEneFrame nChunks = 16 clusterSize3Photon = 9 -clusterSize2Photon = 7 +clusterSize2Photon = 6 clusterSize1Photon = 3 def init(cfg): @@ -410,9 +410,6 @@ def _processFrames(idxChunk): ### for both single and double photon events, usin cluster_2Photon += signalEneFrame[int(ref_y):int(ref_y)+clusterSize2Photon, int(ref_x):int(ref_x)+clusterSize2Photon] _hists['h1_2PhotonClusterEnergy'].Fill(np.sum(cluster_2Photon)) - for i in range(clusterSize2Photon): - for j in range(clusterSize2Photon): - _hists['h2_2PhotonSumSample'].Fill(i, j, cluster_2Photon[i, j]) if 'writeClusters' in _cfg and _cfg['writeClusters'] == True: cluster_2Photon_list.append(cluster_2Photon) refpoint_2Photon_list.append([int(ref_x)+Roi[0], int(ref_y)+Roi[2]])