Add background pixels to 2-ph cluster

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-13 16:12:50 +02:00
parent ae5f2ef0c9
commit 9ede062c68
+6 -3
View File
@@ -5,7 +5,6 @@ from ROOT import TH1D, TH2D, TCanvas, TF1, TFile
from multiprocessing import Pool
from array import array
import h5py
from multiprocessing import Pool
import aare
_cfg = {} ### global config
@@ -197,6 +196,8 @@ def _processFrames(idxChunk): ### for both single and double photon events, usin
CF = aare.VarClusterFinder((nyROI, nxROI), 5) ### arg1: frame size, arg2: threshold
CF.set_peripheralThresholdFactor(3)
CF.set_noiseMap(_noiseEneFrame)
CF.set_numberOfNeighbours(4)
CF.set_empty_surroundingPixels(False)
if 'writeClusters' in _cfg and _cfg['writeClusters'] == True:
h5_1Photon_file = h5py.File(f'{_cfg["outputFolder"]}/1Photon_CS{clusterSize1Photon}_chunk{idxChunk}.h5', 'w')
@@ -266,7 +267,7 @@ def _processFrames(idxChunk): ### for both single and double photon events, usin
signalEneFrame = convertAduFrameToEnergyFrame(signalAduFrame)
sumFrame += signalEneFrame
signalEneFrame = signalEneFrame[Roi[2]:Roi[3], Roi[0]:Roi[1]]
signalEneFrame = signalEneFrame[Roi[2]:Roi[3], Roi[0]:Roi[1]].copy() ### to avoid the 'view' problem: the modified signalEneFrame will be discarded otherwise
_signalEneFrame = np.copy(signalEneFrame) ### make a copy of the original energy frame for cluster energy correction later, since the cluster finder will modify the input energy frame
CF.find_clusters_X(signalEneFrame)
clusters = CF.hits()
@@ -338,6 +339,7 @@ def _processFrames(idxChunk): ### for both single and double photon events, usin
_hists['h1_2PhotonClusterDiameterX'].Fill(diameterX)
_hists['h1_2PhotonClusterDiameterY'].Fill(diameterY)
### filling the 2-photon cluster. Add background as well.
cluster_2Photon = np.zeros((clusterSize2Photon, clusterSize2Photon), dtype=np.float32)
for i in range(len(xs)):
x_rel = xs[i] - int(ref_x)
@@ -345,7 +347,8 @@ def _processFrames(idxChunk): ### for both single and double photon events, usin
if 0 <= x_rel < clusterSize2Photon and 0 <= y_rel < clusterSize2Photon:
cluster_2Photon[y_rel, x_rel] = enes[i]
_hists['h2_2PhotonSumSample'].Fill(x_rel, y_rel, enes[i])
# cluster_2Photon = signalEneFrame[int(ref_y):int(ref_y)+clusterSize2Photon, int(ref_x):int(ref_x)+clusterSize2Photon]
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):