Skip to content
Snippets Groups Projects

Include back in master MPChannelID and MPVolumeID

Merged Renato Quagliani requested to merge rquaglia_run5_addbackChannelID_VolumeID into master
All threads resolved!
2 files
+ 26
27
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -15,10 +15,10 @@
#include <climits>
#include <cstdint>
#include <exception>
#include <fmt/format.h>
#include <functional>
#include <iostream>
#include <type_traits>
#include <fmt/format.h>
#include <utility>
namespace LHCb::Detector {
@@ -27,19 +27,19 @@ namespace LHCb::Detector {
* This class encodes a MIGHTY tracker channel ID. It has the following
* features:
*
* - It uses the MCKey of the particle.
* - It uses the MCKey of the particle.
* - There is no physical meaning to the LHCBID
*/
class MPChannelID final {
/// Bitmasks
enum struct Mask : unsigned {
key = 0x1ffff, // 00011111111111111111 -> 131071
layer = 0x20000, // 00100000000000000000
station = 0xc0000, // 11000000000000000000
uniqueLayer = layer | station,
key = 0x1ffff, // 00011111111111111111 -> 131071
layer = 0x20000, // 00100000000000000000
station = 0xc0000, // 11000000000000000000
uniqueLayer = layer | station,
};
template <Mask m>
template <Mask m>
[[nodiscard]] static constexpr unsigned int extract( unsigned int i ) {
constexpr auto b =
__builtin_ctz( static_cast<unsigned int>( m ) ); // FIXME: C++20 replace __builtin_ctz with std::countr_zero
@@ -59,6 +59,7 @@ namespace LHCb::Detector {
[[nodiscard]] static constexpr unsigned int shift( T i ) {
return shift<m>( to_unsigned( i ) );
}
public:
enum struct StationID : unsigned int {};
[[nodiscard]] friend constexpr unsigned int to_unsigned( StationID id ) { return static_cast<unsigned>( id ); }
@@ -88,8 +89,7 @@ namespace LHCb::Detector {
/// Explicit constructor from the geometrical location and key
constexpr MPChannelID( unsigned int station, unsigned int layer, unsigned int key )
: MPChannelID{shift<Mask::station>( station ) | shift<Mask::layer>( layer ) |
shift<Mask::key>( key )} {}
: MPChannelID{shift<Mask::station>( station ) | shift<Mask::layer>( layer ) | shift<Mask::key>( key )} {}
// Operator overload, to cast channel ID to unsigned int. Used by linkers where the key (channel id) is an int
constexpr operator unsigned int() const { return m_channelID; }
@@ -146,7 +146,7 @@ namespace LHCb::Detector {
friend std::ostream& operator<<( std::ostream& s, const MPChannelID& obj ) {
return s << "{ MPChannelID : "
<< " key =" << obj.key() << " layer=" << to_unsigned( obj.layer() )
<< " key =" << obj.key() << " layer=" << to_unsigned( obj.layer() )
<< " station=" << to_unsigned( obj.station() ) << " }";
}
@@ -164,5 +164,4 @@ namespace LHCb::Detector {
unsigned int m_channelID{0}; /// MP Channel ID
}; // class MPChannelID
} // namespace std
} // namespace LHCb::Detector
Loading