From c20ebc20ccc7ab3efb2a75e8b664c39de9eef0fe Mon Sep 17 00:00:00 2001 From: Jean-Francois Marchand Date: Mon, 4 Apr 2022 11:08:59 +0200 Subject: [PATCH 1/3] Moddify CaloCellID for pin data decoding --- .../Calo/include/Detector/Calo/CaloCellID.h | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Detector/Calo/include/Detector/Calo/CaloCellID.h b/Detector/Calo/include/Detector/Calo/CaloCellID.h index e2d444adad..13e73767d0 100644 --- a/Detector/Calo/include/Detector/Calo/CaloCellID.h +++ b/Detector/Calo/include/Detector/Calo/CaloCellID.h @@ -195,6 +195,13 @@ namespace LHCb::Detector::Calo { static constexpr auto rows = std::array{12, 12, 12}; }; template <> + struct Constants { + static constexpr auto global_offset = offsetAfter>(); + static constexpr auto id0 = std::array{0, 0}; + static constexpr auto cols = std::array{4, 4, 4}; + static constexpr auto rows = std::array{4, 4, 4}; + }; + template <> struct Constants { static constexpr auto global_offset = offsetAfter>(); static constexpr auto id0 = std::array{3, 0}; @@ -209,6 +216,13 @@ namespace LHCb::Detector::Calo { static constexpr auto cols = std::array{14, 4, 14}; static constexpr auto rows = std::array{12, 4, 12}; }; + template <> + struct Constants { + static constexpr auto global_offset = offsetAfter>(); + static constexpr auto id0 = std::array{0, 0}; + static constexpr auto cols = std::array{4, 4, 4}; + static constexpr auto rows = std::array{4, 4, 4}; + }; template constexpr inline bool valid( int row, int col ) { @@ -281,15 +295,21 @@ namespace LHCb::Detector::Calo { if ( id < Constants::global_offset ) { return cellID( id ); } - if ( id < Constants::global_offset ) { + if ( id < Constants::global_offset ) { return cellID( id ); } + if ( id < Constants::global_offset ) { + return cellID( id ); + } if ( id < Constants::global_offset ) { return cellID( id ); } if ( id < offsetAfter>() ) { return cellID( id ); } + if ( id < offsetAfter>() ) { + return cellID( id ); + } return CellID{}; } } // namespace DenseIndex::details @@ -305,6 +325,8 @@ namespace LHCb::Detector::Calo { return index( id.row(), id.col() ); case Area::Inner: return index( id.row(), id.col() ); + case Area::PinArea: + return index( id.row(), id.col() ); default: return -1; } @@ -315,6 +337,8 @@ namespace LHCb::Detector::Calo { case Area::Middle: // empty on purpose... case Area::Inner: return index( id.row(), id.col() ); + case Area::PinArea: + return index( id.row(), id.col() ); default: return -1; } @@ -366,7 +390,7 @@ namespace LHCb::Detector::Calo { constexpr operator CellID() const { return DenseIndex::details::toCellID( m_idx ); } static constexpr int max() { return DenseIndex::details::offsetAfter< - DenseIndex::details::Constants>(); + DenseIndex::details::Constants>(); } }; -- GitLab From 746507b7eb088a5d81b9560155303ed97e25bf5c Mon Sep 17 00:00:00 2001 From: Jean-Francois Marchand Date: Tue, 12 Jul 2022 10:50:51 +0200 Subject: [PATCH 2/3] Fix CaloCellID for PinArea --- .../Calo/include/Detector/Calo/CaloCellID.h | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Detector/Calo/include/Detector/Calo/CaloCellID.h b/Detector/Calo/include/Detector/Calo/CaloCellID.h index 13e73767d0..290ae9d0e5 100644 --- a/Detector/Calo/include/Detector/Calo/CaloCellID.h +++ b/Detector/Calo/include/Detector/Calo/CaloCellID.h @@ -158,18 +158,22 @@ namespace LHCb::Detector::Calo { // Hcal,Inner [18,29] : [0,13][14,17][18,31] ( 12 ) * ( 14 | 4 | 14 ) // + using Area = CellCode::CaloArea; + template constexpr auto nCells() { - return C::rows[0] * ( C::cols[0] + C::cols[1] + C::cols[2] ) + C::rows[1] * ( C::cols[0] + C::cols[2] ) + - C::rows[2] * ( C::cols[0] + C::cols[1] + C::cols[2] ); + if ( C::area == Area::PinArea ) { + return C::rows[0] * C::cols[0] + C::rows[2] * C::cols[2]; + } else { + return C::rows[0] * ( C::cols[0] + C::cols[1] + C::cols[2] ) + C::rows[1] * ( C::cols[0] + C::cols[2] ) + + C::rows[2] * ( C::cols[0] + C::cols[1] + C::cols[2] ); + } } template constexpr auto offsetAfter() { return C::global_offset + nCells(); } - using Area = CellCode::CaloArea; - template struct Constants; @@ -179,6 +183,7 @@ namespace LHCb::Detector::Calo { static constexpr auto id0 = std::array{6, 0}; static constexpr auto cols = std::array{16, 32, 16}; static constexpr auto rows = std::array{16, 20, 16}; + static constexpr auto area = Area::Outer; }; template <> struct Constants { @@ -186,6 +191,7 @@ namespace LHCb::Detector::Calo { static constexpr auto id0 = std::array{12, 0}; static constexpr auto cols = std::array{16, 32, 16}; static constexpr auto rows = std::array{8, 24, 8}; + static constexpr auto area = Area::Middle; }; template <> struct Constants { @@ -193,20 +199,23 @@ namespace LHCb::Detector::Calo { static constexpr auto id0 = std::array{14, 8}; static constexpr auto cols = std::array{16, 16, 16}; static constexpr auto rows = std::array{12, 12, 12}; + static constexpr auto area = Area::Inner; }; template <> struct Constants { static constexpr auto global_offset = offsetAfter>(); static constexpr auto id0 = std::array{0, 0}; - static constexpr auto cols = std::array{4, 4, 4}; - static constexpr auto rows = std::array{4, 4, 4}; + static constexpr auto cols = std::array{16, 32, 16}; + static constexpr auto rows = std::array{4, 0, 4}; + static constexpr auto area = Area::PinArea; }; template <> struct Constants { - static constexpr auto global_offset = offsetAfter>(); + static constexpr auto global_offset = offsetAfter>(); static constexpr auto id0 = std::array{3, 0}; static constexpr auto cols = std::array{8, 16, 8}; static constexpr auto rows = std::array{6, 14, 6}; + static constexpr auto area = Area::Outer; }; template <> @@ -215,13 +224,15 @@ namespace LHCb::Detector::Calo { static constexpr auto id0 = std::array{2, 0}; static constexpr auto cols = std::array{14, 4, 14}; static constexpr auto rows = std::array{12, 4, 12}; + static constexpr auto area = Area::Inner; }; template <> struct Constants { static constexpr auto global_offset = offsetAfter>(); static constexpr auto id0 = std::array{0, 0}; - static constexpr auto cols = std::array{4, 4, 4}; - static constexpr auto rows = std::array{4, 4, 4}; + static constexpr auto cols = std::array{16, 32, 16}; + static constexpr auto rows = std::array{4, 0, 4}; + static constexpr auto area = Area::PinArea; }; template @@ -250,8 +261,13 @@ namespace LHCb::Detector::Calo { constexpr auto bound = std::array{std::array{C::id0[0] + C::rows[0], C::id0[0] + C::rows[0] + C::rows[1]}, std::array{C::id0[1] + C::cols[0], C::id0[1] + C::cols[0] + C::cols[1]}}; - int r = ( ( row < bound[0][0] ) ? 0 : ( ( row < bound[0][1] ) ? 1 : 2 ) ); - return offsets[r] + row * strides[r] + col - ( r == 1 && col >= bound[1][1] ) * C::cols[1]; + if ( area == Area::PinArea ) { + int off = ( row >= C::rows[0] && col >= ( C::cols[0] + C::cols[1] ) ) ? ( C::cols[0] + C::cols[1] ) : 0; + return C::global_offset + row * C::cols[0] + col - off; + } else { + int r = ( ( row < bound[0][0] ) ? 0 : ( ( row < bound[0][1] ) ? 1 : 2 ) ); + return offsets[r] + row * strides[r] + col - ( r == 1 && col >= bound[1][1] ) * C::cols[1]; + } } template -- GitLab From ac673917bae32c99c51bf46747a26c9fbd3d29d2 Mon Sep 17 00:00:00 2001 From: Jean-Francois Marchand Date: Thu, 28 Sep 2023 12:26:35 +0200 Subject: [PATCH 3/3] Fix denseIndex to col,row for PinArea --- .../Calo/include/Detector/Calo/CaloCellID.h | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/Detector/Calo/include/Detector/Calo/CaloCellID.h b/Detector/Calo/include/Detector/Calo/CaloCellID.h index 290ae9d0e5..ab81cdc152 100644 --- a/Detector/Calo/include/Detector/Calo/CaloCellID.h +++ b/Detector/Calo/include/Detector/Calo/CaloCellID.h @@ -276,31 +276,46 @@ namespace LHCb::Detector::Calo { Constants, Constants>; id -= C::global_offset; assert( id < nCells() ); - constexpr auto strides = std::array{C::cols[0] + C::cols[1] + C::cols[2], C::cols[0] + C::cols[2], - C::cols[0] + C::cols[1] + C::cols[2]}; - constexpr auto rows = - std::array{C::rows[0] * ( C::cols[0] + C::cols[1] + C::cols[2] ), C::rows[1] * ( C::cols[0] + C::cols[2] ), - C::rows[2] * ( C::cols[0] + C::cols[1] + C::cols[2] )}; - if ( id < rows[0] ) { - int r = C::id0[0] + id / strides[0]; - int c = C::id0[1] + id % strides[0]; - return CellID{calo, static_cast( area ), static_cast( r ), - static_cast( c )}; - } - id -= rows[0]; - if ( id < rows[1] ) { - int r = C::id0[0] + C::rows[0] + id / strides[1]; - int c = C::id0[1] + id % strides[1]; - if ( c >= C::id0[1] + C::cols[0] ) c += C::cols[1]; + + if ( area == Area::PinArea ) { + if ( id < C::cols[0] + C::cols[1] + C::cols[2] ) { + int c = id % C::cols[0]; + int r = id / C::cols[0]; + return CellID{calo, static_cast( area ), static_cast( r ), + static_cast( c )}; + } else { + int c = id % C::cols[0] + C::cols[0] + C::cols[1]; + int r = id / C::cols[0]; + return CellID{calo, static_cast( area ), static_cast( r ), + static_cast( c )}; + } + } else { + constexpr auto strides = std::array{C::cols[0] + C::cols[1] + C::cols[2], C::cols[0] + C::cols[2], + C::cols[0] + C::cols[1] + C::cols[2]}; + constexpr auto rows = + std::array{C::rows[0] * ( C::cols[0] + C::cols[1] + C::cols[2] ), C::rows[1] * ( C::cols[0] + C::cols[2] ), + C::rows[2] * ( C::cols[0] + C::cols[1] + C::cols[2] )}; + if ( id < rows[0] ) { + int r = C::id0[0] + id / strides[0]; + int c = C::id0[1] + id % strides[0]; + return CellID{calo, static_cast( area ), static_cast( r ), + static_cast( c )}; + } + id -= rows[0]; + if ( id < rows[1] ) { + int r = C::id0[0] + C::rows[0] + id / strides[1]; + int c = C::id0[1] + id % strides[1]; + if ( c >= C::id0[1] + C::cols[0] ) c += C::cols[1]; + return CellID{calo, static_cast( area ), static_cast( r ), + static_cast( c )}; + } + id -= rows[1]; + assert( id < rows[2] ); + int r = C::id0[0] + C::rows[0] + C::rows[1] + id / strides[2]; + int c = C::id0[1] + id % strides[2]; return CellID{calo, static_cast( area ), static_cast( r ), static_cast( c )}; } - id -= rows[1]; - assert( id < rows[2] ); - int r = C::id0[0] + C::rows[0] + C::rows[1] + id / strides[2]; - int c = C::id0[1] + id % strides[2]; - return CellID{calo, static_cast( area ), static_cast( r ), - static_cast( c )}; } constexpr CellID toCellID( int id ) { -- GitLab