Skip to content
Snippets Groups Projects

Modify CaloCellID for pin data decoding

Merged Jean-Francois Marchand requested to merge jmarchan-pinDataDecoding into master
All threads resolved!
1 file
+ 49
9
Compare changes
  • Side-by-side
  • Inline
@@ -146,18 +146,22 @@ namespace LHCb::Detector::Calo {
// Hcal,Inner [18,29] : [0,13][14,17][18,31] ( 12 ) * ( 14 | 4 | 14 )
//
using Area = CellCode::CaloArea;
template <typename C>
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 <typename C>
constexpr auto offsetAfter() {
return C::global_offset + nCells<C>();
}
using Area = CellCode::CaloArea;
template <CellCode::Index, Area>
struct Constants;
@@ -167,6 +171,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<CellCode::Index::EcalCalo, Area::Middle> {
@@ -174,6 +179,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<CellCode::Index::EcalCalo, Area::Inner> {
@@ -181,13 +187,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<CellCode::Index::HcalCalo, Area::Outer> {
struct Constants<CellCode::Index::EcalCalo, Area::PinArea> {
static constexpr auto global_offset = offsetAfter<Constants<CellCode::Index::EcalCalo, Area::Inner>>();
static constexpr auto id0 = std::array{0, 0};
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<CellCode::Index::HcalCalo, Area::Outer> {
static constexpr auto global_offset = offsetAfter<Constants<CellCode::Index::EcalCalo, Area::PinArea>>();
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 <>
@@ -196,6 +212,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<CellCode::Index::HcalCalo, Area::PinArea> {
static constexpr auto global_offset = offsetAfter<Constants<CellCode::Index::HcalCalo, Area::Inner>>();
static constexpr auto id0 = std::array{0, 0};
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 <CellCode::Index calo, Area area>
@@ -224,8 +249,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 <CellCode::Index calo, Area area>
@@ -269,15 +299,21 @@ namespace LHCb::Detector::Calo {
if ( id < Constants<CellCode::Index::EcalCalo, Area::Inner>::global_offset ) {
return cellID<CellCode::Index::EcalCalo, Area::Middle>( id );
}
if ( id < Constants<CellCode::Index::HcalCalo, Area::Outer>::global_offset ) {
if ( id < Constants<CellCode::Index::EcalCalo, Area::PinArea>::global_offset ) {
return cellID<CellCode::Index::EcalCalo, Area::Inner>( id );
}
if ( id < Constants<CellCode::Index::HcalCalo, Area::Outer>::global_offset ) {
return cellID<CellCode::Index::EcalCalo, Area::PinArea>( id );
}
if ( id < Constants<CellCode::Index::HcalCalo, Area::Inner>::global_offset ) {
return cellID<CellCode::Index::HcalCalo, Area::Outer>( id );
}
if ( id < offsetAfter<Constants<CellCode::Index::HcalCalo, Area::Inner>>() ) {
return cellID<CellCode::Index::HcalCalo, Area::Middle>( id );
}
if ( id < offsetAfter<Constants<CellCode::Index::HcalCalo, Area::PinArea>>() ) {
return cellID<CellCode::Index::HcalCalo, Area::PinArea>( id );
}
return CellID{};
}
} // namespace DenseIndex::details
@@ -293,6 +329,8 @@ namespace LHCb::Detector::Calo {
return index<CellCode::Index::EcalCalo, Area::Middle>( id.row(), id.col() );
case Area::Inner:
return index<CellCode::Index::EcalCalo, Area::Inner>( id.row(), id.col() );
case Area::PinArea:
return index<CellCode::Index::EcalCalo, Area::PinArea>( id.row(), id.col() );
default:
return -1;
}
@@ -303,6 +341,8 @@ namespace LHCb::Detector::Calo {
case Area::Middle: // empty on purpose...
case Area::Inner:
return index<CellCode::Index::HcalCalo, Area::Inner>( id.row(), id.col() );
case Area::PinArea:
return index<CellCode::Index::HcalCalo, Area::PinArea>( id.row(), id.col() );
default:
return -1;
}
@@ -354,7 +394,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<CellCode::Index::HcalCalo, DenseIndex::details::Area::Inner>>();
DenseIndex::details::Constants<CellCode::Index::HcalCalo, DenseIndex::details::Area::PinArea>>();
}
};
Loading