diff --git a/Detector/Rich/include/Detector/Rich/DeRichMirror.h b/Detector/Rich/include/Detector/Rich/DeRichMirror.h index 25b3e71524fd92ab8e4c5d893fbca751f932be7c..2aaa238c817ad9f201444e9eb1f29eb1df902928 100644 --- a/Detector/Rich/include/Detector/Rich/DeRichMirror.h +++ b/Detector/Rich/include/Detector/Rich/DeRichMirror.h @@ -23,11 +23,12 @@ namespace LHCb::Detector { struct DeRichMirrorSegObject : DeIOVObject { public: - int m_mirrorNumber = -1; ///< id number which is same as the copy number. - Rich::Side m_mirrorSide = Rich::InvalidSide; ///< side number 0 for top and 1 for bottom - double m_SegmentROC = 0; ///< Mirror radius of curvature - double m_SegmentXSize = 0; ///< Mirror X size - double m_SegmentYSize = 0; ///< Mirror Y size + int m_mirrorNumber = -1; ///< id number which is same as the copy number. + Rich::DetectorType m_rich = Rich::InvalidDetector; ///< RICH Detector + Rich::Side m_mirrorSide = Rich::InvalidSide; ///< side number 0 for top and 1 for bottom + double m_SegmentROC = 0; ///< Mirror radius of curvature + double m_SegmentXSize = 0; ///< Mirror X size + double m_SegmentYSize = 0; ///< Mirror Y size dd4hep::Position m_SegmentLocalCOC; ///< local COC in the corresponding Rich1Mirro2Master system dd4hep::Position m_SegmentGlobalCOC; ///< COC in the global coordinate system dd4hep::Position m_MirrorSurfCentrePtn; ///< Centre point of mirror segment surface in global frame @@ -93,6 +94,7 @@ namespace LHCb::Detector { auto mirrorNumber() const noexcept { return this->access()->m_mirrorNumber; } auto mirrorSide() const noexcept { return this->access()->m_mirrorSide; } + auto rich() const noexcept { return this->access()->m_rich; } auto SegXSize() const noexcept { return toLHCbLengthUnits( this->access()->m_SegmentXSize ); } auto SegYSize() const noexcept { return toLHCbLengthUnits( this->access()->m_SegmentYSize ); } diff --git a/Detector/Rich/include/Detector/Rich/Types.h b/Detector/Rich/include/Detector/Rich/Types.h index 9e32436c3331b7375cab424c45a4e64644e6687d..ab30e8aeb02292bd80af4ef49e7cac1c17ecd83c 100644 --- a/Detector/Rich/include/Detector/Rich/Types.h +++ b/Detector/Rich/include/Detector/Rich/Types.h @@ -13,35 +13,30 @@ // Boost #include -#include // ROOT #include "Math/Plane3D.h" #include "Math/Point3D.h" #include "Math/Vector3D.h" -// STL files +// STL #include #include #include #include +#include #include -// Hack to work around cling issue -#define N_SIDE_TYPES 2 -#define N_DETECTOR_TYPES 2 -#define N_RADIATOR_TYPES 3 - namespace Rich { /// Number of RICH detectors - inline constexpr std::uint16_t NRiches = N_DETECTOR_TYPES; + inline constexpr std::uint16_t NRiches = 2u; /// Number of PD panels per RICH detector - inline constexpr uint16_t NPDPanelsPerRICH = N_SIDE_TYPES; + inline constexpr std::uint16_t NPDPanelsPerRICH = 2u; /// Total number of PD panels - inline constexpr uint16_t NTotalPDPanels = NRiches * NPDPanelsPerRICH; + inline constexpr std::uint16_t NTotalPDPanels = NRiches * NPDPanelsPerRICH; /// Number of RICH radiators - inline constexpr std::uint16_t NRadiatorTypes = N_RADIATOR_TYPES; + inline constexpr std::uint16_t NRadiatorTypes = 3u; /// RICH enum enum DetectorType : std::int8_t { @@ -52,7 +47,7 @@ namespace Rich { }; /// Detector side enum - enum Side : int32_t { + enum Side : std::int8_t { InvalidSide = -1, ///< Invalid side // RICH1 top = 0, ///< Upper panel in RICH1 @@ -94,12 +89,48 @@ namespace Rich { template using RadiatorArray = std::array; + /// Array class with enforced index type + template + struct TypedIndexArray : public std::array { + // Only allow the defined index type in access calls + template + T& operator[]( const I index ) { + static_assert( std::is_same_v ); + return this->std::array::operator[]( index ); + } + template + const T& operator[]( const I index ) const { + static_assert( std::is_same_v ); + return this->std::array::operator[]( index ); + } + template + T& at( const I index ) { + static_assert( std::is_same_v ); + return this->std::array::at( index ); + } + template + const T& at( const I index ) const { + static_assert( std::is_same_v ); + return this->std::array::at( index ); + } + }; + + /// Type for enforced index type fixed size arrays for data for each RICH + template + using DetectorEnumArray = TypedIndexArray; + /// Type for enforced index type fixed size arrays with RICH panel information + template + using PanelEnumArray = TypedIndexArray; + /// Type for enforced index type fixed size arrays with radiator information + template + using RadiatorEnumArray = TypedIndexArray; + /// Type for container of detector types - using Detectors = boost::container::small_vector; + using Detectors = boost::container::small_vector; /// Type for container of side types - using Sides = boost::container::small_vector; + using Sides = boost::container::small_vector; /// Type for container of radiator types - using Radiators = boost::container::small_vector; + using Radiators = boost::container::small_vector; /// Access all valid detector types inline Detectors detectors() noexcept { return {Rich::Rich1, Rich::Rich2}; } @@ -110,11 +141,6 @@ namespace Rich { } // namespace Rich -// remove clang hack -#undef N_SIDE_TYPES -#undef N_DETECTOR_TYPES -#undef N_RADIATOR_TYPES - namespace Rich::Detector { // Geometrical Types diff --git a/Detector/Rich1/src/Rich1DEA/DeRich1Mirror1.cpp b/Detector/Rich1/src/Rich1DEA/DeRich1Mirror1.cpp index f5d811a9e6619c5dcc4a368963cec64905982629..c38a321b38c175ced5a5f4a28c8f41ee246312af 100644 --- a/Detector/Rich1/src/Rich1DEA/DeRich1Mirror1.cpp +++ b/Detector/Rich1/src/Rich1DEA/DeRich1Mirror1.cpp @@ -33,6 +33,9 @@ DeRich1Mirror1SegObject::DeRich1Mirror1SegObject( const dd4hep::DetElement& dd4hep::cond::ConditionUpdateContext& ctxt ) : DeRichMirrorSegObject( de, ctxt ) { + // RICH + m_rich = Rich::Rich1; + // mirror number m_mirrorNumber = de.parent().id(); diff --git a/Detector/Rich1/src/Rich1DEA/DeRich1Mirror2.cpp b/Detector/Rich1/src/Rich1DEA/DeRich1Mirror2.cpp index a5b2335da45269891017a2bf20c0c352e33b99cb..c3b7c9942cee0970bfa350febb61cd18ea36d5fb 100644 --- a/Detector/Rich1/src/Rich1DEA/DeRich1Mirror2.cpp +++ b/Detector/Rich1/src/Rich1DEA/DeRich1Mirror2.cpp @@ -33,6 +33,9 @@ DeRich1Mirror2SegObject::DeRich1Mirror2SegObject( const dd4hep::DetElement& dd4hep::cond::ConditionUpdateContext& ctxt ) : DeRichMirrorSegObject( de, ctxt ) { + // RICH + m_rich = Rich::Rich1; + // mirror number m_mirrorNumber = de.id(); diff --git a/Detector/Rich2/src/Rich2DEA/DeRich2SecMirror.cpp b/Detector/Rich2/src/Rich2DEA/DeRich2SecMirror.cpp index dfa66049ad805187ef7e1eb97c27f8279c6b4228..509065a0221e9e6ad26b4b88ac13c0464b23a995 100644 --- a/Detector/Rich2/src/Rich2DEA/DeRich2SecMirror.cpp +++ b/Detector/Rich2/src/Rich2DEA/DeRich2SecMirror.cpp @@ -34,6 +34,9 @@ DeRich2SecMirrorSegObject::DeRich2SecMirrorSegObject( const dd4hep::DetElement& dd4hep::cond::ConditionUpdateContext& ctxt ) : DeRichMirrorSegObject( de, ctxt ) { + // RICH + m_rich = Rich::Rich2; + // mirror number m_mirrorNumber = de.id(); diff --git a/Detector/Rich2/src/Rich2DEA/DeRich2SphMirror.cpp b/Detector/Rich2/src/Rich2DEA/DeRich2SphMirror.cpp index c7824508102468ebeb966a883e01d1bd50cf6fd8..a70c090bbd6af185a729d74987aea50cb74e8b55 100644 --- a/Detector/Rich2/src/Rich2DEA/DeRich2SphMirror.cpp +++ b/Detector/Rich2/src/Rich2DEA/DeRich2SphMirror.cpp @@ -34,6 +34,9 @@ DeRich2SphMirrorSegObject::DeRich2SphMirrorSegObject( const dd4hep::DetElement& dd4hep::cond::ConditionUpdateContext& ctxt ) : DeRichMirrorSegObject( de, ctxt ) { + // RICH + m_rich = Rich::Rich2; + // mirror number m_mirrorNumber = de.id();