From 945e68986fd238fccf9de32003a6198d01f010a2 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Fri, 22 Nov 2024 16:52:56 +0100 Subject: [PATCH 01/21] Squashed commit --- Phys/TrackRefitting/CMakeLists.txt | 6 + .../src/UpdatePVCoordinates.cpp | 160 ++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinates.cpp diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index c019f96ee82..f6cde269bbe 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -16,15 +16,21 @@ Phys/TrackRefitting gaudi_add_module(TrackRefitting SOURCES src/RecombineDecayTrees.cpp +<<<<<<< HEAD src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp +======= + src/SelectTracksForParticles.cpp + src/UpdatePVCoordinates.cpp +>>>>>>> d15a411888 (Squashed commit) LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel LHCb::LHCbAlgsLib LHCb::PhysEvent LHCb::RecEvent + LHCb::LHCbDetLib LHCb::RelationsLib Rec::TrackInterfacesLib Rec::TrackKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp new file mode 100644 index 00000000000..6053c37c01d --- /dev/null +++ b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp @@ -0,0 +1,160 @@ +/*****************************************************************************\ +* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * +* * +* This software is distributed under the terms of the GNU General Public * +* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\*****************************************************************************/ + +/** + * Uses a dedicated conditon to interpet a primary vertex in an + * 'old' LHCb coordinate system, to a new one. This is useful + * when a the global alignment of the VELO changed. + * + * The vertex container returned is a *new* container, + * which thus takes space on the TES. To help with any + * pre-existing relations, the keys are used as-is from the + * old PVs. + * + * When the special condition is not present, or when running + * on DetDesc, the old container is always copied. This + * takes space on the TES, but mimics the behaviour for the + * data/dd4hep case. + * + * The reason why the condition contains both the *new* + * and *old* global frame information: + * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe + * + * @author Laurent Dufour + */ + +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Transform3DTypes.h" +#include "LHCbAlgs/Transformer.h" + +#include "Event/RecVertex.h" + +#include "DetDesc/DetectorElement.h" +#include "DetDesc/GenericConditionAccessorHolder.h" + +#ifdef USE_DD4HEP +# include +#endif + +namespace { + using Output_t = LHCb::RecVertices; + using In_t = LHCb::RecVertex::Range; + +#ifdef USE_DD4HEP + using Transformer_t = LHCb::Algorithm::Transformer>; + + // Checks whether the old and new coordinate systems are the same + bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { + return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && + LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); + } +#else + using Transformer_t = LHCb::Algorithm::Transformer; +#endif +} // namespace + +namespace LHCb { + class UpdatePVCoordinates final : public Transformer_t { + + private: + mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + + public: +#ifdef USE_DD4HEP + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, + {KeyValue{"InputPVs", ""}, + KeyValue { + "LHCbLocation", + LHCb::standard_geometry_top + }}, + {KeyValue { + "OutputVertices", + "" + }} ) {} + + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { + Output_t outputPVs{}; + outputPVs.reserve( originalPVs.size() ); + + const auto offlineCalib = lhcb.offlineCoordinateTransformation(); + + // deal with the NO UPDATE case first + if ( !offlineCalib || isZero( *offlineCalib ) ) { + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // *clone* the PV container as-is + } + + // example values in 2024: + // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; + const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; + const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; + + // example values in 2024: + // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; + const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; + const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; + + const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); + const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); + + for ( const auto& pv : originalPVs ) { + auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + + outputPVs.insert( newPV.release(), pv->key() ); + } + + m_updatedPVs += outputPVs.size(); + + return outputPVs; + } +#else + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + + Output_t operator()( In_t const& originalPVs ) const override { + Output_t outputPVs; + outputPVs.reserve( originalPVs.size() ); + + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // copy the PV container as-is + } +#endif + + private: + std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + Gaudi::Transform3D const& transformation ) const { + auto newPV = std::make_unique( originalPV ); + + auto position = transformation * newPV->position(); + newPV->setPosition( position ); + + return newPV; + } + }; + + DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinates, "UpdatePVCoordinates" ) +} // namespace LHCb \ No newline at end of file -- GitLab From a9bd933c8fac359537e642a4249c2e279afe8e63 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 13:20:35 +0100 Subject: [PATCH 02/21] Slightly rename the algorithm --- Phys/TrackRefitting/CMakeLists.txt | 6 +- .../src/UpdatePVCoordinates.cpp | 160 ------------------ 2 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinates.cpp diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index f6cde269bbe..9be07d28018 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -16,14 +16,10 @@ Phys/TrackRefitting gaudi_add_module(TrackRefitting SOURCES src/RecombineDecayTrees.cpp -<<<<<<< HEAD src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp -======= - src/SelectTracksForParticles.cpp - src/UpdatePVCoordinates.cpp ->>>>>>> d15a411888 (Squashed commit) + src/UpdatePVCoordinatesOffline.cpp LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp deleted file mode 100644 index 6053c37c01d..00000000000 --- a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -/** - * Uses a dedicated conditon to interpet a primary vertex in an - * 'old' LHCb coordinate system, to a new one. This is useful - * when a the global alignment of the VELO changed. - * - * The vertex container returned is a *new* container, - * which thus takes space on the TES. To help with any - * pre-existing relations, the keys are used as-is from the - * old PVs. - * - * When the special condition is not present, or when running - * on DetDesc, the old container is always copied. This - * takes space on the TES, but mimics the behaviour for the - * data/dd4hep case. - * - * The reason why the condition contains both the *new* - * and *old* global frame information: - * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe - * - * @author Laurent Dufour - */ - -#include "GaudiAlg/GaudiAlgorithm.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Transform3DTypes.h" -#include "LHCbAlgs/Transformer.h" - -#include "Event/RecVertex.h" - -#include "DetDesc/DetectorElement.h" -#include "DetDesc/GenericConditionAccessorHolder.h" - -#ifdef USE_DD4HEP -# include -#endif - -namespace { - using Output_t = LHCb::RecVertices; - using In_t = LHCb::RecVertex::Range; - -#ifdef USE_DD4HEP - using Transformer_t = LHCb::Algorithm::Transformer>; - - // Checks whether the old and new coordinate systems are the same - bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { - return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && - LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); - } -#else - using Transformer_t = LHCb::Algorithm::Transformer; -#endif -} // namespace - -namespace LHCb { - class UpdatePVCoordinates final : public Transformer_t { - - private: - mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; - mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; - - public: -#ifdef USE_DD4HEP - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, - {KeyValue{"InputPVs", ""}, - KeyValue { - "LHCbLocation", - LHCb::standard_geometry_top - }}, - {KeyValue { - "OutputVertices", - "" - }} ) {} - - Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { - Output_t outputPVs{}; - outputPVs.reserve( originalPVs.size() ); - - const auto offlineCalib = lhcb.offlineCoordinateTransformation(); - - // deal with the NO UPDATE case first - if ( !offlineCalib || isZero( *offlineCalib ) ) { - std::for_each( originalPVs.begin(), originalPVs.end(), - [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - - m_notUpdatedPVs += originalPVs.size(); - - return outputPVs; // *clone* the PV container as-is - } - - // example values in 2024: - // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; - const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; - const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; - - // example values in 2024: - // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; - const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; - const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; - - const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); - const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); - - for ( const auto& pv : originalPVs ) { - auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); - - outputPVs.insert( newPV.release(), pv->key() ); - } - - m_updatedPVs += outputPVs.size(); - - return outputPVs; - } -#else - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} - - Output_t operator()( In_t const& originalPVs ) const override { - Output_t outputPVs; - outputPVs.reserve( originalPVs.size() ); - - std::for_each( originalPVs.begin(), originalPVs.end(), - [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - - m_notUpdatedPVs += originalPVs.size(); - - return outputPVs; // copy the PV container as-is - } -#endif - - private: - std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, - Gaudi::Transform3D const& transformation ) const { - auto newPV = std::make_unique( originalPV ); - - auto position = transformation * newPV->position(); - newPV->setPosition( position ); - - return newPV; - } - }; - - DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinates, "UpdatePVCoordinates" ) -} // namespace LHCb \ No newline at end of file -- GitLab From ea8162ac8f454030f013ae331345ad2b6243c495 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 13:46:24 +0100 Subject: [PATCH 03/21] put back algorithm... --- .../src/UpdatePVCoordinatesOffline.cpp | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp new file mode 100644 index 00000000000..e691357a06e --- /dev/null +++ b/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp @@ -0,0 +1,160 @@ +/*****************************************************************************\ +* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * +* * +* This software is distributed under the terms of the GNU General Public * +* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\*****************************************************************************/ + +/** + * Uses a dedicated conditon to interpet a primary vertex in an + * 'old' LHCb coordinate system, to a new one. This is useful + * when a the global alignment of the VELO changed. + * + * The vertex container returned is a *new* container, + * which thus takes space on the TES. To help with any + * pre-existing relations, the keys are used as-is from the + * old PVs. + * + * When the special condition is not present, or when running + * on DetDesc, the old container is always copied. This + * takes space on the TES, but mimics the behaviour for the + * data/dd4hep case. + * + * The reason why the condition contains both the *new* + * and *old* global frame information: + * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe + * + * @author Laurent Dufour + */ + +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Transform3DTypes.h" +#include "LHCbAlgs/Transformer.h" + +#include "Event/RecVertex.h" + +#include "DetDesc/DetectorElement.h" +#include "DetDesc/GenericConditionAccessorHolder.h" + +#ifdef USE_DD4HEP +# include +#endif + +namespace { + using Output_t = LHCb::RecVertices; + using In_t = LHCb::RecVertex::Range; + +#ifdef USE_DD4HEP + using Transformer_t = LHCb::Algorithm::Transformer>; + + // Checks whether the old and new coordinate systems are the same + bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { + return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && + LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); + } +#else + using Transformer_t = LHCb::Algorithm::Transformer; +#endif +} // namespace + +namespace LHCb { + class UpdatePVCoordinatesOffline final : public Transformer_t { + + private: + mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + + public: +#ifdef USE_DD4HEP + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, + {KeyValue{"InputPVs", ""}, + KeyValue { + "LHCbLocation", + LHCb::standard_geometry_top + }}, + {KeyValue { + "OutputVertices", + "" + }} ) {} + + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { + Output_t outputPVs{}; + outputPVs.reserve( originalPVs.size() ); + + const auto offlineCalib = lhcb.offlineCoordinateTransformation(); + + // deal with the NO UPDATE case first + if ( !offlineCalib || isZero( *offlineCalib ) ) { + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // *clone* the PV container as-is + } + + // example values in 2024: + // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; + const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; + const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; + + // example values in 2024: + // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; + const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; + const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; + + const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); + const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); + + for ( const auto& pv : originalPVs ) { + auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + + outputPVs.insert( newPV.release(), pv->key() ); + } + + m_updatedPVs += outputPVs.size(); + + return outputPVs; + } +#else + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + + Output_t operator()( In_t const& originalPVs ) const override { + Output_t outputPVs; + outputPVs.reserve( originalPVs.size() ); + + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // copy the PV container as-is + } +#endif + + private: + std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + Gaudi::Transform3D const& transformation ) const { + auto newPV = std::make_unique( originalPV ); + + auto position = transformation * newPV->position(); + newPV->setPosition( position ); + + return newPV; + } + }; + + DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinatesOffline, "UpdatePVCoordinatesOffline" ) +} // namespace LHCb \ No newline at end of file -- GitLab From bba7f89f71f872c5d2ba7fee78afada15abc740c Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 14:30:10 +0100 Subject: [PATCH 04/21] Update name of PV coordinate transform --- Phys/TrackRefitting/CMakeLists.txt | 2 +- ...cpp => UpdateVertexCoordinatesOffline.cpp} | 38 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) rename Phys/TrackRefitting/src/{UpdatePVCoordinatesOffline.cpp => UpdateVertexCoordinatesOffline.cpp} (80%) diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index 9be07d28018..09c8cb554d9 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -19,7 +19,7 @@ gaudi_add_module(TrackRefitting src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp - src/UpdatePVCoordinatesOffline.cpp + src/UpdateVertexCoordinatesOffline.cpp LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp similarity index 80% rename from Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp rename to Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index e691357a06e..b177cc54d12 100644 --- a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -13,16 +13,20 @@ * Uses a dedicated conditon to interpet a primary vertex in an * 'old' LHCb coordinate system, to a new one. This is useful * when a the global alignment of the VELO changed. + * + * This algorithm is written purely for PVs, but since it acts + * on general RecVertices, it could be used for other types + * of vertices. * - * The vertex container returned is a *new* container, + * The vertex container returned is a new container, * which thus takes space on the TES. To help with any * pre-existing relations, the keys are used as-is from the - * old PVs. + * old vertices. * * When the special condition is not present, or when running - * on DetDesc, the old container is always copied. This - * takes space on the TES, but mimics the behaviour for the - * data/dd4hep case. + * on DetDesc, the old container is always copied without any + * change. This takes space on the TES, but mimics the behaviour + * for the data/dd4hep case where there is a correction present. * * The reason why the condition contains both the *new* * and *old* global frame information: @@ -68,17 +72,17 @@ namespace { } // namespace namespace LHCb { - class UpdatePVCoordinatesOffline final : public Transformer_t { + class UpdateVertexCoordinatesOffline final : public Transformer_t { private: - mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; - mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + mutable Gaudi::Accumulators::Counter<> m_updatedVertices{this, "Updated Vertices"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedVertices{this, "Unaltered Vertices"}; public: #ifdef USE_DD4HEP - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) : Transformer_t( name, pSvcLocator, - {KeyValue{"InputPVs", ""}, + {KeyValue{"InputVertices", ""}, KeyValue { "LHCbLocation", LHCb::standard_geometry_top @@ -99,7 +103,7 @@ namespace LHCb { std::for_each( originalPVs.begin(), originalPVs.end(), [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - m_notUpdatedPVs += originalPVs.size(); + m_notUpdatedVertices += originalPVs.size(); return outputPVs; // *clone* the PV container as-is } @@ -118,18 +122,18 @@ namespace LHCb { const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); for ( const auto& pv : originalPVs ) { - auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + auto newPV = UpdateVertex( *pv, newTransMatrix * oldTransMatrix.Inverse() ); outputPVs.insert( newPV.release(), pv->key() ); } - m_updatedPVs += outputPVs.size(); + m_updatedVertices += outputPVs.size(); return outputPVs; } #else - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputVertices", ""}}, {KeyValue{"OutputVertices", ""}} ) {} Output_t operator()( In_t const& originalPVs ) const override { Output_t outputPVs; @@ -145,7 +149,7 @@ namespace LHCb { #endif private: - std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + std::unique_ptr UpdateVertex( LHCb::RecVertex const& originalPV, Gaudi::Transform3D const& transformation ) const { auto newPV = std::make_unique( originalPV ); @@ -156,5 +160,5 @@ namespace LHCb { } }; - DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinatesOffline, "UpdatePVCoordinatesOffline" ) + DECLARE_COMPONENT_WITH_ID( UpdateVertexCoordinatesOffline, "UpdateVertexCoordinatesOffline" ) } // namespace LHCb \ No newline at end of file -- GitLab From 7ec547a60ad33b9071736e77e5933227fbbca039 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 6 Jan 2025 13:30:46 +0000 Subject: [PATCH 05/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/48937274 --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index b177cc54d12..cccf5d43ee8 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -13,7 +13,7 @@ * Uses a dedicated conditon to interpet a primary vertex in an * 'old' LHCb coordinate system, to a new one. This is useful * when a the global alignment of the VELO changed. - * + * * This algorithm is written purely for PVs, but since it acts * on general RecVertices, it could be used for other types * of vertices. @@ -25,7 +25,7 @@ * * When the special condition is not present, or when running * on DetDesc, the old container is always copied without any - * change. This takes space on the TES, but mimics the behaviour + * change. This takes space on the TES, but mimics the behaviour * for the data/dd4hep case where there is a correction present. * * The reason why the condition contains both the *new* @@ -150,7 +150,7 @@ namespace LHCb { private: std::unique_ptr UpdateVertex( LHCb::RecVertex const& originalPV, - Gaudi::Transform3D const& transformation ) const { + Gaudi::Transform3D const& transformation ) const { auto newPV = std::make_unique( originalPV ); auto position = transformation * newPV->position(); -- GitLab From f6b23503a24eba7a577bd20951d44ffda0b6c5c8 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Fri, 17 Jan 2025 14:22:32 +0100 Subject: [PATCH 06/21] Bugfix for detdesc builds. --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index cccf5d43ee8..a37bf301334 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -142,7 +142,7 @@ namespace LHCb { std::for_each( originalPVs.begin(), originalPVs.end(), [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - m_notUpdatedPVs += originalPVs.size(); + m_notUpdatedVertices += originalPVs.size(); return outputPVs; // copy the PV container as-is } -- GitLab From cdd0ec21ed8941f36a3c2346b49d8d88c72d2059 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Fri, 22 Nov 2024 16:52:56 +0100 Subject: [PATCH 07/21] Squashed commit --- Phys/TrackRefitting/CMakeLists.txt | 6 + .../src/UpdatePVCoordinates.cpp | 160 ++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinates.cpp diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index c019f96ee82..f6cde269bbe 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -16,15 +16,21 @@ Phys/TrackRefitting gaudi_add_module(TrackRefitting SOURCES src/RecombineDecayTrees.cpp +<<<<<<< HEAD src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp +======= + src/SelectTracksForParticles.cpp + src/UpdatePVCoordinates.cpp +>>>>>>> d15a411888 (Squashed commit) LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel LHCb::LHCbAlgsLib LHCb::PhysEvent LHCb::RecEvent + LHCb::LHCbDetLib LHCb::RelationsLib Rec::TrackInterfacesLib Rec::TrackKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp new file mode 100644 index 00000000000..6053c37c01d --- /dev/null +++ b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp @@ -0,0 +1,160 @@ +/*****************************************************************************\ +* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * +* * +* This software is distributed under the terms of the GNU General Public * +* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\*****************************************************************************/ + +/** + * Uses a dedicated conditon to interpet a primary vertex in an + * 'old' LHCb coordinate system, to a new one. This is useful + * when a the global alignment of the VELO changed. + * + * The vertex container returned is a *new* container, + * which thus takes space on the TES. To help with any + * pre-existing relations, the keys are used as-is from the + * old PVs. + * + * When the special condition is not present, or when running + * on DetDesc, the old container is always copied. This + * takes space on the TES, but mimics the behaviour for the + * data/dd4hep case. + * + * The reason why the condition contains both the *new* + * and *old* global frame information: + * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe + * + * @author Laurent Dufour + */ + +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Transform3DTypes.h" +#include "LHCbAlgs/Transformer.h" + +#include "Event/RecVertex.h" + +#include "DetDesc/DetectorElement.h" +#include "DetDesc/GenericConditionAccessorHolder.h" + +#ifdef USE_DD4HEP +# include +#endif + +namespace { + using Output_t = LHCb::RecVertices; + using In_t = LHCb::RecVertex::Range; + +#ifdef USE_DD4HEP + using Transformer_t = LHCb::Algorithm::Transformer>; + + // Checks whether the old and new coordinate systems are the same + bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { + return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && + LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); + } +#else + using Transformer_t = LHCb::Algorithm::Transformer; +#endif +} // namespace + +namespace LHCb { + class UpdatePVCoordinates final : public Transformer_t { + + private: + mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + + public: +#ifdef USE_DD4HEP + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, + {KeyValue{"InputPVs", ""}, + KeyValue { + "LHCbLocation", + LHCb::standard_geometry_top + }}, + {KeyValue { + "OutputVertices", + "" + }} ) {} + + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { + Output_t outputPVs{}; + outputPVs.reserve( originalPVs.size() ); + + const auto offlineCalib = lhcb.offlineCoordinateTransformation(); + + // deal with the NO UPDATE case first + if ( !offlineCalib || isZero( *offlineCalib ) ) { + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // *clone* the PV container as-is + } + + // example values in 2024: + // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; + const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; + const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; + + // example values in 2024: + // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; + const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; + const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; + + const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); + const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); + + for ( const auto& pv : originalPVs ) { + auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + + outputPVs.insert( newPV.release(), pv->key() ); + } + + m_updatedPVs += outputPVs.size(); + + return outputPVs; + } +#else + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + + Output_t operator()( In_t const& originalPVs ) const override { + Output_t outputPVs; + outputPVs.reserve( originalPVs.size() ); + + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // copy the PV container as-is + } +#endif + + private: + std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + Gaudi::Transform3D const& transformation ) const { + auto newPV = std::make_unique( originalPV ); + + auto position = transformation * newPV->position(); + newPV->setPosition( position ); + + return newPV; + } + }; + + DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinates, "UpdatePVCoordinates" ) +} // namespace LHCb \ No newline at end of file -- GitLab From 5c7cce17559da9f45931895d899d69614da86e2e Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 13:20:35 +0100 Subject: [PATCH 08/21] Slightly rename the algorithm --- Phys/TrackRefitting/CMakeLists.txt | 6 +- .../src/UpdatePVCoordinates.cpp | 160 ------------------ 2 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinates.cpp diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index f6cde269bbe..9be07d28018 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -16,14 +16,10 @@ Phys/TrackRefitting gaudi_add_module(TrackRefitting SOURCES src/RecombineDecayTrees.cpp -<<<<<<< HEAD src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp -======= - src/SelectTracksForParticles.cpp - src/UpdatePVCoordinates.cpp ->>>>>>> d15a411888 (Squashed commit) + src/UpdatePVCoordinatesOffline.cpp LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp deleted file mode 100644 index 6053c37c01d..00000000000 --- a/Phys/TrackRefitting/src/UpdatePVCoordinates.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ - -/** - * Uses a dedicated conditon to interpet a primary vertex in an - * 'old' LHCb coordinate system, to a new one. This is useful - * when a the global alignment of the VELO changed. - * - * The vertex container returned is a *new* container, - * which thus takes space on the TES. To help with any - * pre-existing relations, the keys are used as-is from the - * old PVs. - * - * When the special condition is not present, or when running - * on DetDesc, the old container is always copied. This - * takes space on the TES, but mimics the behaviour for the - * data/dd4hep case. - * - * The reason why the condition contains both the *new* - * and *old* global frame information: - * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe - * - * @author Laurent Dufour - */ - -#include "GaudiAlg/GaudiAlgorithm.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Transform3DTypes.h" -#include "LHCbAlgs/Transformer.h" - -#include "Event/RecVertex.h" - -#include "DetDesc/DetectorElement.h" -#include "DetDesc/GenericConditionAccessorHolder.h" - -#ifdef USE_DD4HEP -# include -#endif - -namespace { - using Output_t = LHCb::RecVertices; - using In_t = LHCb::RecVertex::Range; - -#ifdef USE_DD4HEP - using Transformer_t = LHCb::Algorithm::Transformer>; - - // Checks whether the old and new coordinate systems are the same - bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { - return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && - LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); - } -#else - using Transformer_t = LHCb::Algorithm::Transformer; -#endif -} // namespace - -namespace LHCb { - class UpdatePVCoordinates final : public Transformer_t { - - private: - mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; - mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; - - public: -#ifdef USE_DD4HEP - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, - {KeyValue{"InputPVs", ""}, - KeyValue { - "LHCbLocation", - LHCb::standard_geometry_top - }}, - {KeyValue { - "OutputVertices", - "" - }} ) {} - - Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { - Output_t outputPVs{}; - outputPVs.reserve( originalPVs.size() ); - - const auto offlineCalib = lhcb.offlineCoordinateTransformation(); - - // deal with the NO UPDATE case first - if ( !offlineCalib || isZero( *offlineCalib ) ) { - std::for_each( originalPVs.begin(), originalPVs.end(), - [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - - m_notUpdatedPVs += originalPVs.size(); - - return outputPVs; // *clone* the PV container as-is - } - - // example values in 2024: - // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; - const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; - const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; - - // example values in 2024: - // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; - const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; - const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; - - const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); - const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); - - for ( const auto& pv : originalPVs ) { - auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); - - outputPVs.insert( newPV.release(), pv->key() ); - } - - m_updatedPVs += outputPVs.size(); - - return outputPVs; - } -#else - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} - - Output_t operator()( In_t const& originalPVs ) const override { - Output_t outputPVs; - outputPVs.reserve( originalPVs.size() ); - - std::for_each( originalPVs.begin(), originalPVs.end(), - [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - - m_notUpdatedPVs += originalPVs.size(); - - return outputPVs; // copy the PV container as-is - } -#endif - - private: - std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, - Gaudi::Transform3D const& transformation ) const { - auto newPV = std::make_unique( originalPV ); - - auto position = transformation * newPV->position(); - newPV->setPosition( position ); - - return newPV; - } - }; - - DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinates, "UpdatePVCoordinates" ) -} // namespace LHCb \ No newline at end of file -- GitLab From 0b368f47cebbb4154aa2f1676c6a4daa332933d2 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 13:46:24 +0100 Subject: [PATCH 09/21] put back algorithm... --- .../src/UpdatePVCoordinatesOffline.cpp | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp new file mode 100644 index 00000000000..e691357a06e --- /dev/null +++ b/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp @@ -0,0 +1,160 @@ +/*****************************************************************************\ +* (c) Copyright 2024 CERN for the benefit of the LHCb Collaboration * +* * +* This software is distributed under the terms of the GNU General Public * +* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\*****************************************************************************/ + +/** + * Uses a dedicated conditon to interpet a primary vertex in an + * 'old' LHCb coordinate system, to a new one. This is useful + * when a the global alignment of the VELO changed. + * + * The vertex container returned is a *new* container, + * which thus takes space on the TES. To help with any + * pre-existing relations, the keys are used as-is from the + * old PVs. + * + * When the special condition is not present, or when running + * on DetDesc, the old container is always copied. This + * takes space on the TES, but mimics the behaviour for the + * data/dd4hep case. + * + * The reason why the condition contains both the *new* + * and *old* global frame information: + * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe + * + * @author Laurent Dufour + */ + +#include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Transform3DTypes.h" +#include "LHCbAlgs/Transformer.h" + +#include "Event/RecVertex.h" + +#include "DetDesc/DetectorElement.h" +#include "DetDesc/GenericConditionAccessorHolder.h" + +#ifdef USE_DD4HEP +# include +#endif + +namespace { + using Output_t = LHCb::RecVertices; + using In_t = LHCb::RecVertex::Range; + +#ifdef USE_DD4HEP + using Transformer_t = LHCb::Algorithm::Transformer>; + + // Checks whether the old and new coordinate systems are the same + bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { + return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && + LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && + LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && + LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); + } +#else + using Transformer_t = LHCb::Algorithm::Transformer; +#endif +} // namespace + +namespace LHCb { + class UpdatePVCoordinatesOffline final : public Transformer_t { + + private: + mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + + public: +#ifdef USE_DD4HEP + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, + {KeyValue{"InputPVs", ""}, + KeyValue { + "LHCbLocation", + LHCb::standard_geometry_top + }}, + {KeyValue { + "OutputVertices", + "" + }} ) {} + + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { + Output_t outputPVs{}; + outputPVs.reserve( originalPVs.size() ); + + const auto offlineCalib = lhcb.offlineCoordinateTransformation(); + + // deal with the NO UPDATE case first + if ( !offlineCalib || isZero( *offlineCalib ) ) { + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // *clone* the PV container as-is + } + + // example values in 2024: + // {-0.0005157705398491993, 7.011816237252315e-05, -0.00042666842206765687}; + const ROOT::Math::RotationZYX& oldRotation = offlineCalib->oldRotation; + const ROOT::Math::Translation3D& oldTranslation = offlineCalib->oldPosition; + + // example values in 2024: + // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; + const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; + const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; + + const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); + const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); + + for ( const auto& pv : originalPVs ) { + auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + + outputPVs.insert( newPV.release(), pv->key() ); + } + + m_updatedPVs += outputPVs.size(); + + return outputPVs; + } +#else + UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + + Output_t operator()( In_t const& originalPVs ) const override { + Output_t outputPVs; + outputPVs.reserve( originalPVs.size() ); + + std::for_each( originalPVs.begin(), originalPVs.end(), + [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); + + m_notUpdatedPVs += originalPVs.size(); + + return outputPVs; // copy the PV container as-is + } +#endif + + private: + std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + Gaudi::Transform3D const& transformation ) const { + auto newPV = std::make_unique( originalPV ); + + auto position = transformation * newPV->position(); + newPV->setPosition( position ); + + return newPV; + } + }; + + DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinatesOffline, "UpdatePVCoordinatesOffline" ) +} // namespace LHCb \ No newline at end of file -- GitLab From a95aa2be78c0593d55cfa27d145fd17354e49f4c Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Mon, 6 Jan 2025 14:30:10 +0100 Subject: [PATCH 10/21] Update name of PV coordinate transform --- Phys/TrackRefitting/CMakeLists.txt | 2 +- ...cpp => UpdateVertexCoordinatesOffline.cpp} | 38 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) rename Phys/TrackRefitting/src/{UpdatePVCoordinatesOffline.cpp => UpdateVertexCoordinatesOffline.cpp} (80%) diff --git a/Phys/TrackRefitting/CMakeLists.txt b/Phys/TrackRefitting/CMakeLists.txt index 9be07d28018..09c8cb554d9 100644 --- a/Phys/TrackRefitting/CMakeLists.txt +++ b/Phys/TrackRefitting/CMakeLists.txt @@ -19,7 +19,7 @@ gaudi_add_module(TrackRefitting src/ReplaceTracksInRecVertex.cpp src/SelectTracksForParticles.cpp src/SelectTracksForRecVertices.cpp - src/UpdatePVCoordinatesOffline.cpp + src/UpdateVertexCoordinatesOffline.cpp LINK Gaudi::GaudiAlgLib Gaudi::GaudiKernel diff --git a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp similarity index 80% rename from Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp rename to Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index e691357a06e..b177cc54d12 100644 --- a/Phys/TrackRefitting/src/UpdatePVCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -13,16 +13,20 @@ * Uses a dedicated conditon to interpet a primary vertex in an * 'old' LHCb coordinate system, to a new one. This is useful * when a the global alignment of the VELO changed. + * + * This algorithm is written purely for PVs, but since it acts + * on general RecVertices, it could be used for other types + * of vertices. * - * The vertex container returned is a *new* container, + * The vertex container returned is a new container, * which thus takes space on the TES. To help with any * pre-existing relations, the keys are used as-is from the - * old PVs. + * old vertices. * * When the special condition is not present, or when running - * on DetDesc, the old container is always copied. This - * takes space on the TES, but mimics the behaviour for the - * data/dd4hep case. + * on DetDesc, the old container is always copied without any + * change. This takes space on the TES, but mimics the behaviour + * for the data/dd4hep case where there is a correction present. * * The reason why the condition contains both the *new* * and *old* global frame information: @@ -68,17 +72,17 @@ namespace { } // namespace namespace LHCb { - class UpdatePVCoordinatesOffline final : public Transformer_t { + class UpdateVertexCoordinatesOffline final : public Transformer_t { private: - mutable Gaudi::Accumulators::Counter<> m_updatedPVs{this, "Updated PVs"}; - mutable Gaudi::Accumulators::Counter<> m_notUpdatedPVs{this, "Unaltered PVs"}; + mutable Gaudi::Accumulators::Counter<> m_updatedVertices{this, "Updated Vertices"}; + mutable Gaudi::Accumulators::Counter<> m_notUpdatedVertices{this, "Unaltered Vertices"}; public: #ifdef USE_DD4HEP - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) + UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) : Transformer_t( name, pSvcLocator, - {KeyValue{"InputPVs", ""}, + {KeyValue{"InputVertices", ""}, KeyValue { "LHCbLocation", LHCb::standard_geometry_top @@ -99,7 +103,7 @@ namespace LHCb { std::for_each( originalPVs.begin(), originalPVs.end(), [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - m_notUpdatedPVs += originalPVs.size(); + m_notUpdatedVertices += originalPVs.size(); return outputPVs; // *clone* the PV container as-is } @@ -118,18 +122,18 @@ namespace LHCb { const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); for ( const auto& pv : originalPVs ) { - auto newPV = updatePV( *pv, newTransMatrix * oldTransMatrix.Inverse() ); + auto newPV = UpdateVertex( *pv, newTransMatrix * oldTransMatrix.Inverse() ); outputPVs.insert( newPV.release(), pv->key() ); } - m_updatedPVs += outputPVs.size(); + m_updatedVertices += outputPVs.size(); return outputPVs; } #else - UpdatePVCoordinates( const std::string& name, ISvcLocator* pSvcLocator ) - : Transformer_t( name, pSvcLocator, {KeyValue{"InputPVs", ""}}, {KeyValue{"OutputVertices", ""}} ) {} + UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) + : Transformer_t( name, pSvcLocator, {KeyValue{"InputVertices", ""}}, {KeyValue{"OutputVertices", ""}} ) {} Output_t operator()( In_t const& originalPVs ) const override { Output_t outputPVs; @@ -145,7 +149,7 @@ namespace LHCb { #endif private: - std::unique_ptr updatePV( LHCb::RecVertex const& originalPV, + std::unique_ptr UpdateVertex( LHCb::RecVertex const& originalPV, Gaudi::Transform3D const& transformation ) const { auto newPV = std::make_unique( originalPV ); @@ -156,5 +160,5 @@ namespace LHCb { } }; - DECLARE_COMPONENT_WITH_ID( UpdatePVCoordinatesOffline, "UpdatePVCoordinatesOffline" ) + DECLARE_COMPONENT_WITH_ID( UpdateVertexCoordinatesOffline, "UpdateVertexCoordinatesOffline" ) } // namespace LHCb \ No newline at end of file -- GitLab From 3478dff58e0d9c4d54e1d47679d2ce20930b0e47 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Mon, 6 Jan 2025 13:30:46 +0000 Subject: [PATCH 11/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/48937274 --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index b177cc54d12..cccf5d43ee8 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -13,7 +13,7 @@ * Uses a dedicated conditon to interpet a primary vertex in an * 'old' LHCb coordinate system, to a new one. This is useful * when a the global alignment of the VELO changed. - * + * * This algorithm is written purely for PVs, but since it acts * on general RecVertices, it could be used for other types * of vertices. @@ -25,7 +25,7 @@ * * When the special condition is not present, or when running * on DetDesc, the old container is always copied without any - * change. This takes space on the TES, but mimics the behaviour + * change. This takes space on the TES, but mimics the behaviour * for the data/dd4hep case where there is a correction present. * * The reason why the condition contains both the *new* @@ -150,7 +150,7 @@ namespace LHCb { private: std::unique_ptr UpdateVertex( LHCb::RecVertex const& originalPV, - Gaudi::Transform3D const& transformation ) const { + Gaudi::Transform3D const& transformation ) const { auto newPV = std::make_unique( originalPV ); auto position = transformation * newPV->position(); -- GitLab From 566ba06f210f96be1d531cc360a0c25f853f5596 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Fri, 17 Jan 2025 14:22:32 +0100 Subject: [PATCH 12/21] Bugfix for detdesc builds. --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index cccf5d43ee8..a37bf301334 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -142,7 +142,7 @@ namespace LHCb { std::for_each( originalPVs.begin(), originalPVs.end(), [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - m_notUpdatedPVs += originalPVs.size(); + m_notUpdatedVertices += originalPVs.size(); return outputPVs; // copy the PV container as-is } -- GitLab From 64f43ec297ce6ffcba4e9360175c66f59a27ca85 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Wed, 22 Jan 2025 10:05:03 +0100 Subject: [PATCH 13/21] Rename condition accessor --- .../src/UpdateVertexCoordinatesOffline.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index a37bf301334..308131d5068 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -47,6 +47,7 @@ #ifdef USE_DD4HEP # include +# include #endif namespace { @@ -54,11 +55,11 @@ namespace { using In_t = LHCb::RecVertex::Range; #ifdef USE_DD4HEP - using Transformer_t = LHCb::Algorithm::Transformer>; + using Transformer_t = LHCb::Algorithm::Transformer>; // Checks whether the old and new coordinate systems are the same - bool isZero( LHCb::Detector::OfflineCoordinateTransform const& transform ) { + bool isZero( LHCb::Detector::VPGlobalCoordinateTransform const& transform ) { return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && @@ -86,17 +87,21 @@ namespace LHCb { KeyValue { "LHCbLocation", LHCb::standard_geometry_top + }, + KeyValue { + "VPLocation", + LHCb::standard_geometry_top }}, {KeyValue { "OutputVertices", "" }} ) {} - Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb ) const override { + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb, Detector::DeVP const& deVP ) const override { Output_t outputPVs{}; outputPVs.reserve( originalPVs.size() ); - const auto offlineCalib = lhcb.offlineCoordinateTransformation(); + const auto offlineCalib = lhcb.vpGlobalCoordinateTransformation(); // deal with the NO UPDATE case first if ( !offlineCalib || isZero( *offlineCalib ) ) { -- GitLab From 3e87605363ca0e51fa54c5a8d6665e4d2772e808 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 22 Jan 2025 09:05:50 +0000 Subject: [PATCH 14/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/49677719 --- .../src/UpdateVertexCoordinatesOffline.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 308131d5068..de7481f32b0 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -55,8 +55,9 @@ namespace { using In_t = LHCb::RecVertex::Range; #ifdef USE_DD4HEP - using Transformer_t = LHCb::Algorithm::Transformer>; + using Transformer_t = + LHCb::Algorithm::Transformer>; // Checks whether the old and new coordinate systems are the same bool isZero( LHCb::Detector::VPGlobalCoordinateTransform const& transform ) { @@ -83,11 +84,7 @@ namespace LHCb { #ifdef USE_DD4HEP UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) : Transformer_t( name, pSvcLocator, - {KeyValue{"InputVertices", ""}, - KeyValue { - "LHCbLocation", - LHCb::standard_geometry_top - }, + {KeyValue{"InputVertices", ""}, KeyValue{"LHCbLocation", LHCb::standard_geometry_top}, KeyValue { "VPLocation", LHCb::standard_geometry_top @@ -97,7 +94,8 @@ namespace LHCb { "" }} ) {} - Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb, Detector::DeVP const& deVP ) const override { + Output_t operator()( In_t const& originalPVs, Detector::DeLHCb const& lhcb, + Detector::DeVP const& deVP ) const override { Output_t outputPVs{}; outputPVs.reserve( originalPVs.size() ); -- GitLab From cd06bd4909a07895c65c04c22ec42cb5fa78f36e Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Wed, 22 Jan 2025 23:45:57 +0100 Subject: [PATCH 15/21] Use latest DeVP changes --- .../src/UpdateVertexCoordinatesOffline.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index de7481f32b0..0f99524f1de 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -59,15 +59,6 @@ namespace { LHCb::Algorithm::Transformer>; - // Checks whether the old and new coordinate systems are the same - bool isZero( LHCb::Detector::VPGlobalCoordinateTransform const& transform ) { - return ( LHCb::essentiallyEqual( transform.oldPosition.Vect().X(), transform.newPosition.Vect().X() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Y(), transform.newPosition.Vect().Y() ) && - LHCb::essentiallyEqual( transform.oldPosition.Vect().Z(), transform.newPosition.Vect().Z() ) && - LHCb::essentiallyEqual( transform.oldRotation.Phi(), transform.newRotation.Phi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Psi(), transform.newRotation.Psi() ) && - LHCb::essentiallyEqual( transform.oldRotation.Theta(), transform.newRotation.Theta() ) ); - } #else using Transformer_t = LHCb::Algorithm::Transformer; #endif @@ -102,7 +93,7 @@ namespace LHCb { const auto offlineCalib = lhcb.vpGlobalCoordinateTransformation(); // deal with the NO UPDATE case first - if ( !offlineCalib || isZero( *offlineCalib ) ) { + if ( !offlineCalib || !offlineCalib->enabled ) { std::for_each( originalPVs.begin(), originalPVs.end(), [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); @@ -118,8 +109,11 @@ namespace LHCb { // example values in 2024: // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; - const ROOT::Math::RotationZYX& newRotation = offlineCalib->newRotation; - const ROOT::Math::Translation3D& newTranslation = offlineCalib->newPosition; + const ROOT::Math::RotationZYX& newRotation = deVP.systemRotation(); + + const ROOT::Math::Translation3D newTranslation ( deVP.systemTranslation().X(), + deVP.systemTranslation().Y(), deVP.systemTranslation().Z()); + const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); -- GitLab From 486e8599d7d9c713d23d0eac34af7c744261bdf2 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Thu, 23 Jan 2025 16:58:39 +0100 Subject: [PATCH 16/21] Apply suggestions --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 0f99524f1de..fc20efbd804 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -48,6 +48,7 @@ #ifdef USE_DD4HEP # include # include +# include "VPDet/DeVP.h" // needed for the path #endif namespace { @@ -78,7 +79,7 @@ namespace LHCb { {KeyValue{"InputVertices", ""}, KeyValue{"LHCbLocation", LHCb::standard_geometry_top}, KeyValue { "VPLocation", - LHCb::standard_geometry_top + LHCb::Det::VP::det_path }}, {KeyValue { "OutputVertices", @@ -110,9 +111,7 @@ namespace LHCb { // example values in 2024: // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; const ROOT::Math::RotationZYX& newRotation = deVP.systemRotation(); - - const ROOT::Math::Translation3D newTranslation ( deVP.systemTranslation().X(), - deVP.systemTranslation().Y(), deVP.systemTranslation().Z()); + const ROOT::Math::Translation3D newTranslation { deVP.systemTranslation() }; const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); -- GitLab From 7cd39a4d4d1925d0dc49f090e67861f42aeb260d Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 23 Jan 2025 15:59:28 +0000 Subject: [PATCH 17/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/49780743 --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index fc20efbd804..3675e8ec58b 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -46,9 +46,9 @@ #include "DetDesc/GenericConditionAccessorHolder.h" #ifdef USE_DD4HEP +# include "VPDet/DeVP.h" // needed for the path # include # include -# include "VPDet/DeVP.h" // needed for the path #endif namespace { @@ -110,9 +110,8 @@ namespace LHCb { // example values in 2024: // {-0.000490856920288708, 7.977795380551605e-05, -0.0008505579346996768}; - const ROOT::Math::RotationZYX& newRotation = deVP.systemRotation(); - const ROOT::Math::Translation3D newTranslation { deVP.systemTranslation() }; - + const ROOT::Math::RotationZYX& newRotation = deVP.systemRotation(); + const ROOT::Math::Translation3D newTranslation{deVP.systemTranslation()}; const auto oldTransMatrix = Gaudi::Transform3D( oldTranslation * oldRotation ); const auto newTransMatrix = Gaudi::Transform3D( newTranslation * newRotation ); -- GitLab From e4d5bb3aef20bd24728f7c8242690e7f8bcb6fb1 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Wed, 29 Jan 2025 11:32:00 +0100 Subject: [PATCH 18/21] Simplify the detdesc algorithm - implement suggestions. --- .../src/UpdateVertexCoordinatesOffline.cpp | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 3675e8ec58b..27ac3cac57e 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -24,13 +24,11 @@ * old vertices. * * When the special condition is not present, or when running - * on DetDesc, the old container is always copied without any - * change. This takes space on the TES, but mimics the behaviour - * for the data/dd4hep case where there is a correction present. - * - * The reason why the condition contains both the *new* - * and *old* global frame information: - * https://mattermost.web.cern.ch/lhcb/pl/5w16oxjcq3dfbkk9ihjzo6gywe + * on DetDesc, the old container is always returned without any + * change. The return type is a Range of vertices, i.e. non- + * owning container, contrary to the dd4hep case. All downstream + * algorithms are recommended to always take the generic ::Range + * as input, and never require the owning container. * * @author Laurent Dufour */ @@ -61,7 +59,8 @@ namespace { LHCb::DetDesc::usesConditions>; #else - using Transformer_t = LHCb::Algorithm::Transformer; + // this is a dummy operation, just to keep the control flow in tact + using Transformer_t = LHCb::Algorithm::Transformer; #endif } // namespace @@ -131,15 +130,7 @@ namespace LHCb { : Transformer_t( name, pSvcLocator, {KeyValue{"InputVertices", ""}}, {KeyValue{"OutputVertices", ""}} ) {} Output_t operator()( In_t const& originalPVs ) const override { - Output_t outputPVs; - outputPVs.reserve( originalPVs.size() ); - - std::for_each( originalPVs.begin(), originalPVs.end(), - [&outputPVs]( const auto& pv ) { outputPVs.insert( pv->clone(), pv->key() ); } ); - - m_notUpdatedVertices += originalPVs.size(); - - return outputPVs; // copy the PV container as-is + return originalPVs; } #endif -- GitLab From ab85a789e01c30b2bf3085f11165d2c9c2ded296 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 29 Jan 2025 10:32:47 +0000 Subject: [PATCH 19/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/50044119 --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 27ac3cac57e..8cf384bb96a 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -129,9 +129,7 @@ namespace LHCb { UpdateVertexCoordinatesOffline( const std::string& name, ISvcLocator* pSvcLocator ) : Transformer_t( name, pSvcLocator, {KeyValue{"InputVertices", ""}}, {KeyValue{"OutputVertices", ""}} ) {} - Output_t operator()( In_t const& originalPVs ) const override { - return originalPVs; - } + Output_t operator()( In_t const& originalPVs ) const override { return originalPVs; } #endif private: -- GitLab From 17fdf8447da256dc3f55b379f42a3f786035fdba Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Thu, 30 Jan 2025 12:07:07 +0100 Subject: [PATCH 20/21] Fix output type --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 8cf384bb96a..7696a0fd11c 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -50,17 +50,20 @@ #endif namespace { - using Output_t = LHCb::RecVertices; using In_t = LHCb::RecVertex::Range; #ifdef USE_DD4HEP + using Output_t = LHCb::RecVertices; + using Transformer_t = LHCb::Algorithm::Transformer>; #else + using Output_t = LHCb::RecVertex::Range; + // this is a dummy operation, just to keep the control flow in tact - using Transformer_t = LHCb::Algorithm::Transformer; + using Transformer_t = LHCb::Algorithm::Transformer; #endif } // namespace -- GitLab From 74d4408972741e309c4ece5421a3c6c8bc4f635d Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Thu, 30 Jan 2025 11:08:05 +0000 Subject: [PATCH 21/21] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/50117744 --- Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp index 7696a0fd11c..0dc413eaa23 100644 --- a/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp +++ b/Phys/TrackRefitting/src/UpdateVertexCoordinatesOffline.cpp @@ -50,7 +50,7 @@ #endif namespace { - using In_t = LHCb::RecVertex::Range; + using In_t = LHCb::RecVertex::Range; #ifdef USE_DD4HEP using Output_t = LHCb::RecVertices; -- GitLab