From 33d177afc70eddb197b8c20ebe98cf33e8e3b9cf Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Wed, 23 Oct 2024 12:05:11 +0200
Subject: [PATCH 1/3] Improve docs

---
 src/hardware.jl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hardware.jl b/src/hardware.jl
index 9f8b75cd..6f62f060 100644
--- a/src/hardware.jl
+++ b/src/hardware.jl
@@ -385,7 +385,7 @@ end
 """
     function Detector(filename::AbstractString)
 
-Create a `Detector` instance from a DETX file.
+Create a `Detector` instance from a DETX/DATX file.
 """
 function Detector(filename::AbstractString)::Detector
     _, ext = splitext(filename)
-- 
GitLab


From 7260044705d00a5887765532de66f79f5611704b Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Wed, 23 Oct 2024 14:00:20 +0200
Subject: [PATCH 2/3] Add preliminary address map

---
 src/hardware.jl | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/hardware.jl b/src/hardware.jl
index 6f62f060..5c5d2570 100644
--- a/src/hardware.jl
+++ b/src/hardware.jl
@@ -23,6 +23,51 @@ function Base.isapprox(lhs::PMT, rhs::PMT; kwargs...)
     end
 end
 
+struct PMTPhysicalAddress
+    ring::Char
+    position::Int
+end
+
+
+const PMTAddressMap = Dict(
+	22 => PMTPhysicalAddress('A', 1),
+
+	14 => PMTPhysicalAddress('B', 1),
+	19 => PMTPhysicalAddress('B', 2),
+	25 => PMTPhysicalAddress('B', 3),
+	24 => PMTPhysicalAddress('B', 4),
+	26 => PMTPhysicalAddress('B', 5),
+	18 => PMTPhysicalAddress('B', 6),
+
+	13 => PMTPhysicalAddress('C', 1),
+	21 => PMTPhysicalAddress('C', 2),
+	29 => PMTPhysicalAddress('C', 3),
+	28 => PMTPhysicalAddress('C', 4),
+	20 => PMTPhysicalAddress('C', 5),
+	17 => PMTPhysicalAddress('C', 6),
+
+	12 => PMTPhysicalAddress('D', 1),
+	15 => PMTPhysicalAddress('D', 2),
+	23 => PMTPhysicalAddress('D', 3),
+	30 => PMTPhysicalAddress('D', 4),
+	27 => PMTPhysicalAddress('D', 5),
+	16 => PMTPhysicalAddress('D', 6),
+
+	10 => PMTPhysicalAddress('E', 1),
+	 6 => PMTPhysicalAddress('E', 2),
+	 3 => PMTPhysicalAddress('E', 3),
+	 2 => PMTPhysicalAddress('E', 4),
+	 1 => PMTPhysicalAddress('E', 5),
+	11 => PMTPhysicalAddress('E', 6),
+
+	 9 => PMTPhysicalAddress('F', 1),
+	 8 => PMTPhysicalAddress('F', 2),
+	 4 => PMTPhysicalAddress('F', 3),
+	 0 => PMTPhysicalAddress('F', 4),
+	 5 => PMTPhysicalAddress('F', 5),
+	 7 => PMTPhysicalAddress('F', 6)
+)
+
 
 """
 A module's location in the detector where string represents the
-- 
GitLab


From 0585d73c1b2f527d1e7f48e5d12c8756b5dd473d Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Mon, 10 Mar 2025 11:13:23 +0100
Subject: [PATCH 3/3] Add access for physical address of PMTs

---
 docs/src/api.md |  4 ++-
 src/exports.jl  |  2 ++
 src/hardware.jl | 77 +++++++++++++++++++++++++------------------------
 3 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/docs/src/api.md b/docs/src/api.md
index 63319831..d9401330 100644
--- a/docs/src/api.md
+++ b/docs/src/api.md
@@ -66,9 +66,11 @@ DetectorModule
 Detector
 PMTFile
 PMTData
+PMTPhysicalAddress
 modules
 getmodule
 getpmt
+getaddress
 haslocation
 hasstring
 isbasemodule
@@ -183,4 +185,4 @@ hashistory
 ```@docs
 angle
 distance
-```
\ No newline at end of file
+```
diff --git a/src/exports.jl b/src/exports.jl
index d531fdf6..efb725a2 100644
--- a/src/exports.jl
+++ b/src/exports.jl
@@ -24,10 +24,12 @@ StringMechanicsParameters,
 Tripod,
 PMTFile,
 PMTData,
+PMTPhysicalAddress,
 center,
 getmodule,
 getpmt,
 getpmts,
+getaddress,
 haslocation,
 hasstring,
 isbasemodule,
diff --git a/src/hardware.jl b/src/hardware.jl
index 5c5d2570..7eac34a8 100644
--- a/src/hardware.jl
+++ b/src/hardware.jl
@@ -23,50 +23,53 @@ function Base.isapprox(lhs::PMT, rhs::PMT; kwargs...)
     end
 end
 
+"""
+The physical address of a PMT consisting of the ring (A-F) and the position (1-6).
+"""
 struct PMTPhysicalAddress
     ring::Char
     position::Int
 end
 
 
-const PMTAddressMap = Dict(
-	22 => PMTPhysicalAddress('A', 1),
-
-	14 => PMTPhysicalAddress('B', 1),
-	19 => PMTPhysicalAddress('B', 2),
-	25 => PMTPhysicalAddress('B', 3),
-	24 => PMTPhysicalAddress('B', 4),
-	26 => PMTPhysicalAddress('B', 5),
-	18 => PMTPhysicalAddress('B', 6),
-
-	13 => PMTPhysicalAddress('C', 1),
-	21 => PMTPhysicalAddress('C', 2),
-	29 => PMTPhysicalAddress('C', 3),
-	28 => PMTPhysicalAddress('C', 4),
-	20 => PMTPhysicalAddress('C', 5),
-	17 => PMTPhysicalAddress('C', 6),
-
-	12 => PMTPhysicalAddress('D', 1),
-	15 => PMTPhysicalAddress('D', 2),
-	23 => PMTPhysicalAddress('D', 3),
-	30 => PMTPhysicalAddress('D', 4),
-	27 => PMTPhysicalAddress('D', 5),
-	16 => PMTPhysicalAddress('D', 6),
-
-	10 => PMTPhysicalAddress('E', 1),
-	 6 => PMTPhysicalAddress('E', 2),
-	 3 => PMTPhysicalAddress('E', 3),
-	 2 => PMTPhysicalAddress('E', 4),
-	 1 => PMTPhysicalAddress('E', 5),
-	11 => PMTPhysicalAddress('E', 6),
-
-	 9 => PMTPhysicalAddress('F', 1),
-	 8 => PMTPhysicalAddress('F', 2),
-	 4 => PMTPhysicalAddress('F', 3),
-	 0 => PMTPhysicalAddress('F', 4),
-	 5 => PMTPhysicalAddress('F', 5),
-	 7 => PMTPhysicalAddress('F', 6)
+const _PMTAddressMapSV = SVector(
+    PMTPhysicalAddress('F', 4),
+    PMTPhysicalAddress('E', 5),
+    PMTPhysicalAddress('E', 4),
+    PMTPhysicalAddress('E', 3),
+    PMTPhysicalAddress('F', 3),
+    PMTPhysicalAddress('F', 5),
+    PMTPhysicalAddress('E', 2),
+    PMTPhysicalAddress('F', 6),
+    PMTPhysicalAddress('F', 2),
+    PMTPhysicalAddress('F', 1),
+    PMTPhysicalAddress('E', 1),
+    PMTPhysicalAddress('E', 6),
+    PMTPhysicalAddress('D', 1),
+    PMTPhysicalAddress('C', 1),
+    PMTPhysicalAddress('B', 1),
+    PMTPhysicalAddress('D', 2),
+    PMTPhysicalAddress('D', 6),
+    PMTPhysicalAddress('C', 6),
+    PMTPhysicalAddress('B', 6),
+    PMTPhysicalAddress('B', 2),
+    PMTPhysicalAddress('C', 5),
+    PMTPhysicalAddress('C', 2),
+    PMTPhysicalAddress('A', 1),
+    PMTPhysicalAddress('D', 3),
+    PMTPhysicalAddress('B', 4),
+    PMTPhysicalAddress('B', 3),
+    PMTPhysicalAddress('B', 5),
+    PMTPhysicalAddress('D', 5),
+    PMTPhysicalAddress('C', 4),
+    PMTPhysicalAddress('C', 3),
+    PMTPhysicalAddress('D', 4)
 )
+"""
+Get the physical address of a PMT.
+"""
+getaddress(pmt::PMT) = _PMTAddressMap[pmt.id + 1]
+getaddress(channel_id::Integer) = _PMTAddressMap[channel_id + 1]
 
 
 """
-- 
GitLab