WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 88cedef

Browse files
Merge pull request #146 from ETSInitiative/fix-detection-bin-efficiencies
fix get_detection_efficiency python helper
2 parents e02643b + 71a4266 commit 88cedef

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

python/petsird/helpers/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,19 @@ def get_detection_efficiency(scanner: petsird.ScannerInformation,
8787
type_of_module_pair: petsird.TypeOfModulePair,
8888
event: petsird.CoincidenceEvent) -> float:
8989
"""Compute the detection efficiency for a coincidence event"""
90-
eff = 1
90+
if scanner.detection_efficiencies is None:
91+
# should never happen really, but this way, we don't crash.
92+
return 1.
93+
94+
eff = 1.
9195

9296
# per detection_bin efficiencies
93-
if scanner.detection_efficiencies is not None:
97+
detection_bin_efficiencies = scanner.detection_efficiencies.detection_bin_efficiencies
98+
if detection_bin_efficiencies is not None:
9499
detection_bin_efficiencies0 = (
95-
scanner.detection_efficiencies.detection_bin_efficiencies[
96-
type_of_module_pair[0]])
100+
detection_bin_efficiencies[type_of_module_pair[0]])
97101
detection_bin_efficiencies1 = (
98-
scanner.detection_efficiencies.detection_bin_efficiencies[
99-
type_of_module_pair[1]])
102+
detection_bin_efficiencies[type_of_module_pair[1]])
100103
eff *= (detection_bin_efficiencies0[event.detection_bins[0]] *
101104
detection_bin_efficiencies1[event.detection_bins[1]])
102105
if eff == 0:

0 commit comments

Comments
 (0)