From e1fc435ef6cc32bbb96b4f45b64ee952f7210735 Mon Sep 17 00:00:00 2001 From: Hangyi Wu Date: Thu, 15 May 2025 05:32:43 +0200 Subject: [PATCH 1/2] fix!: unify determination of last strip index pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Detector/-/jobs/55816257 --- Detector/UT/include/Detector/UT/DeUTSector.h | 5 +++-- Detector/UT/include/Detector/UT/DeUTSensor.h | 19 ++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Detector/UT/include/Detector/UT/DeUTSector.h b/Detector/UT/include/Detector/UT/DeUTSector.h index 0d0e693a81..b923749471 100644 --- a/Detector/UT/include/Detector/UT/DeUTSector.h +++ b/Detector/UT/include/Detector/UT/DeUTSector.h @@ -188,6 +188,7 @@ namespace LHCb::Detector::UT { using DeIOVElement::DeIOVElement; unsigned int firstStrip() const { return this->access()->m_sensor.m_firstStrip; } + unsigned int lastStrip() const { return nStrip() - 1u + firstStrip(); } unsigned int firstBeetle() const { return this->access()->m_firstBeetle; } unsigned int nStrip() const { return this->access()->m_sensor.m_nStrip; } bool stripflip() const { return this->access()->m_sensor.m_stripflip; } @@ -215,7 +216,7 @@ namespace LHCb::Detector::UT { return sensor().trajectory( strip, offset ); } LineTraj trajectoryFirstStrip() const { return createTraj( firstStrip(), 0. ); } - LineTraj trajectoryLastStrip() const { return createTraj( nStrip() - 1u + firstStrip(), 0. ); } + LineTraj trajectoryLastStrip() const { return createTraj( lastStrip(), 0. ); } ROOT::Math::XYZPoint globalCentre() const { return this->toGlobal( ROOT::Math::XYZPoint( 0.0, 0.0, 0.0 ) ); } @@ -575,7 +576,7 @@ namespace LHCb::Detector::UT { void trajectory( unsigned int strip, double offset, double& dxdy, double& dzdy, double& xAtYEq0, double& zAtYEq0, double& ybegin, double& yend ) const { auto i = offset + strip; - auto numstrips = ( ( stripflip() && xInverted() ) ? ( nStrip() - i ) : i ); + auto numstrips = ( ( stripflip() && xInverted() ) ? ( lastStrip() - i ) : i ); dxdy = this->access()->m_dxdy; dzdy = this->access()->m_dzdy; diff --git a/Detector/UT/include/Detector/UT/DeUTSensor.h b/Detector/UT/include/Detector/UT/DeUTSensor.h index 650d700be1..5a93d9759a 100644 --- a/Detector/UT/include/Detector/UT/DeUTSensor.h +++ b/Detector/UT/include/Detector/UT/DeUTSensor.h @@ -89,26 +89,23 @@ namespace LHCb::Detector::UT { float activeHeight() const { return fabs( this->access()->m_vMinLocal - this->access()->m_vMaxLocal ); } bool getStripflip() const { return this->access()->m_stripflip; } unsigned int firstStrip() const { return this->access()->m_firstStrip; }; + unsigned int lastStrip() const { return nStrip() - 1u + firstStrip(); }; unsigned int version() const { return this->access()->m_version; }; using DeIOVElement::DeIOVElement; bool contains( const ChannelID aChannel ) const { return ( aChannel == channelID() ); } - bool isStrip( const unsigned int strip ) const { - return ( strip >= firstStrip() ) && strip < nStrip() + firstStrip(); - } + bool isStrip( const unsigned int strip ) const { return ( strip >= firstStrip() ) && strip <= lastStrip(); } LineTraj trajectory( unsigned int strip, double offset ) const { if ( this->access()->m_useCorrectP0Parameter && !isStrip( strip ) ) { - throw std::out_of_range( - fmt::format( "DeUTSector::createTraj: strip out of range, given {strip}, expect [{first}, {last}]", - fmt::arg( "strip", strip ), fmt::arg( "first", firstStrip() ), - fmt::arg( "last", firstStrip() + nStrip() - 1 ) ) ); + throw std::out_of_range( fmt::format( + "DeUTSector::createTraj: strip out of range, given {strip}, expect [{first}, {last}]", + fmt::arg( "strip", strip ), fmt::arg( "first", firstStrip() ), fmt::arg( "last", lastStrip() ) ) ); } - const double arclen = - ( ( xInverted() && getStripflip() ) ? ( nStrip() - offset - strip - ( firstStrip() + 1 ) % 2 ) - : ( offset + strip - firstStrip() ) ) * - pitch(); + const double arclen = ( ( xInverted() && getStripflip() ) ? ( lastStrip() - ( offset + strip ) ) + : ( ( offset + strip ) - firstStrip() ) ) * + pitch(); ROOT::Math::XYZPoint midPoint = this->access()->m_midTraj->position( arclen + this->access()->m_midTraj->beginRange() ); return { midPoint, this->access()->m_direction, this->access()->m_range, -- GitLab From b9dbf55b0625aba0eb992359a5a741dbcfd66d1a Mon Sep 17 00:00:00 2001 From: Hangyi Wu Date: Tue, 15 Jul 2025 15:19:23 +0200 Subject: [PATCH 2/2] refactor: unify lastStrip() method --- Detector/UT/include/Detector/UT/DeUTSector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detector/UT/include/Detector/UT/DeUTSector.h b/Detector/UT/include/Detector/UT/DeUTSector.h index b923749471..843920214a 100644 --- a/Detector/UT/include/Detector/UT/DeUTSector.h +++ b/Detector/UT/include/Detector/UT/DeUTSector.h @@ -188,7 +188,7 @@ namespace LHCb::Detector::UT { using DeIOVElement::DeIOVElement; unsigned int firstStrip() const { return this->access()->m_sensor.m_firstStrip; } - unsigned int lastStrip() const { return nStrip() - 1u + firstStrip(); } + unsigned int lastStrip() const { return sensor().lastStrip(); } unsigned int firstBeetle() const { return this->access()->m_firstBeetle; } unsigned int nStrip() const { return this->access()->m_sensor.m_nStrip; } bool stripflip() const { return this->access()->m_sensor.m_stripflip; } -- GitLab