File indexing completed on 2026-10-29 09:13:53
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <vector>
0011
0012 #include "corecel/Assert.hh"
0013 #include "corecel/cont/LabelIdMultiMap.hh"
0014 #include "corecel/cont/Span.hh"
0015 #include "corecel/data/ParamsDataInterface.hh"
0016 #include "corecel/data/ParamsDataStore.hh"
0017
0018 #include "DetectorData.hh"
0019 #include "inp/Model.hh"
0020
0021 namespace celeritas
0022 {
0023 class VolumeParams;
0024
0025
0026
0027
0028
0029 class DetectorParams final : public ParamsDataInterface<DetectorParamsData>
0030 {
0031 public:
0032
0033
0034 using SpanVol = Span<VolumeId const>;
0035 using DetectorMap = LabelIdMultiMap<DetectorId>;
0036
0037
0038 public:
0039
0040 DetectorParams() = default;
0041
0042
0043 DetectorParams(inp::Detectors detectors, VolumeParams const& volumes);
0044
0045
0046 bool empty() const { return !static_cast<bool>(mirror_); }
0047
0048
0049 DetectorId::size_type num_detectors() const
0050 {
0051 return detectors_.detectors.size();
0052 }
0053
0054
0055 DetectorMap const& detector_labels() const { return det_labels_; }
0056
0057
0058 inline DetectorId detector_id(VolumeId vol_id) const;
0059
0060
0061 inline SpanVol volume_ids(DetectorId det_id) const;
0062
0063
0064
0065
0066
0067 HostRef const& host_ref() const final { return mirror_.host_ref(); }
0068
0069 DeviceRef const& device_ref() const final { return mirror_.device_ref(); }
0070
0071
0072 private:
0073 ParamsDataStore<DetectorParamsData> mirror_;
0074 inp::Detectors detectors_;
0075 DetectorMap det_labels_;
0076 };
0077
0078
0079
0080
0081
0082
0083
0084 DetectorId DetectorParams::detector_id(VolumeId vol_id) const
0085 {
0086 return host_ref().detector_ids[vol_id];
0087 }
0088
0089
0090
0091
0092
0093 auto DetectorParams::volume_ids(DetectorId det_id) const -> SpanVol
0094 {
0095 CELER_EXPECT(det_id < this->num_detectors());
0096 return make_span(detectors_.detectors[det_id.get()].volumes);
0097 }
0098
0099
0100 }