diff --git a/docs/src/api.md b/docs/src/api.md index 6331983141aafa297596a060d5dca08f32d5a640..d9401330f4029edfbfc6acbe5e1ddda4b8fb6c20 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 d531fdf6e0152b0c85b66e1bfff6ef14d39fd382..efb725a2210eedf1d497014ab244bff54525c9e9 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 9f8b75cd4d178b1d839d3f81c4d66304b16e088d..7eac34a818795f5144c1bb9f0799c2da1010414e 100644 --- a/src/hardware.jl +++ b/src/hardware.jl @@ -23,6 +23,54 @@ 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 _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] + """ A module's location in the detector where string represents the @@ -385,7 +433,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)