Skip to content
Snippets Groups Projects
Commit e450c308 authored by Miroslav Saur's avatar Miroslav Saur
Browse files

Merge branch 'VPMicroCluster-setters-use-uint8_t' into '2024-patches'

VPMicroCluster: Define setters for interstrip fraction from uint8_t instead of float

See merge request !4620
parents 55e9fc28 c59a1e58
No related branches found
No related tags found
2 merge requests!4620VPMicroCluster: Define setters for interstrip fraction from uint8_t instead of float,!4597Synchronize master branch with 2024-patches
Pipeline #7628632 passed
......@@ -14,6 +14,7 @@
#include "Detector/VP/VPChannelID.h"
#include "Kernel/VPConstants.h"
#include <cstdint>
#include <ostream>
#include <vector>
......@@ -39,12 +40,16 @@ namespace LHCb {
}
class VPMicroCluster final {
public:
using FracType = std::uint8_t;
public:
/// Default Constructor, used by packing/unpacking
VPMicroCluster() = default;
/// Constructor
VPMicroCluster( const unsigned char xfraction, const unsigned char yfraction, const unsigned vpID )
VPMicroCluster( const FracType xfraction, const FracType yfraction, const Detector::VPChannelID vpID )
: m_fx( xfraction ), m_fy( yfraction ), m_vpID( vpID ) {}
/// Return the cluster channelID
......@@ -56,27 +61,29 @@ namespace LHCb {
/// Print the cluster information
std::ostream& fillStream( std::ostream& s ) const {
s << "{VPCluster channelID: " << channelID() //
<< ", fx: " << (unsigned int)xfraction() //
<< ", fy: " << (unsigned int)yfraction() << "}";
s << "{VPCluster channelID: "
<< channelID()
// Note, cast these from 8 to 16 bit types as otherwise they do not
// appear as numerical values in the output.
<< ", fx: " << static_cast<std::uint16_t>( xfraction() ) //
<< ", fy: " << static_cast<std::uint16_t>( yfraction() ) << "}";
return s;
}
// ! conversion from float to unsigned char
// (to be compatible with the output type of the VPLightCluster)
void setXfraction( const float fx ) { m_fx = fx; }
void setYfraction( const float fy ) { m_fy = fy; }
void setChannelID( const Detector::VPChannelID channelID ) { m_vpID = channelID; }
// setters
void setXfraction( const FracType fx ) noexcept { m_fx = fx; }
void setYfraction( const FracType fy ) noexcept { m_fy = fy; }
void setChannelID( const Detector::VPChannelID channelID ) noexcept { m_vpID = channelID; }
bool operator==( const VPMicroCluster& other ) const {
bool operator==( const VPMicroCluster& other ) const noexcept {
return ( xfraction() == other.xfraction() && //
yfraction() == other.yfraction() && //
channelID() == other.channelID() );
}
private:
unsigned char m_fx{0}; ///< inter-pixel fraction in x coordinate
unsigned char m_fy{0}; ///< inter-pixel fraction in y coordinate
FracType m_fx{0}; ///< inter-pixel fraction in x coordinate
FracType m_fy{0}; ///< inter-pixel fraction in y coordinate
Detector::VPChannelID m_vpID; ///< channelID of cluster
}; // class VPMicroCluster
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment