From 3c84018c86b2b07618f0afa4b403e8b26f9aae55 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Tue, 27 Sep 2022 15:17:27 +0200 Subject: [PATCH 1/4] Dropped unused class RichDetectorTool --- Rich/RichTools/CMakeLists.txt | 1 - Rich/RichTools/src/RichDetectorTool.cpp | 47 -------------------- Rich/RichTools/src/RichDetectorTool.h | 57 ------------------------- 3 files changed, 105 deletions(-) delete mode 100644 Rich/RichTools/src/RichDetectorTool.cpp delete mode 100644 Rich/RichTools/src/RichDetectorTool.h diff --git a/Rich/RichTools/CMakeLists.txt b/Rich/RichTools/CMakeLists.txt index 69e848343..9166bb535 100644 --- a/Rich/RichTools/CMakeLists.txt +++ b/Rich/RichTools/CMakeLists.txt @@ -15,7 +15,6 @@ Rich/RichTools gaudi_add_module(RichTools SOURCES - src/RichDetectorTool.cpp src/RichSmartIDTool.cpp LINK Boost::headers diff --git a/Rich/RichTools/src/RichDetectorTool.cpp b/Rich/RichTools/src/RichDetectorTool.cpp deleted file mode 100644 index 953d12d59..000000000 --- a/Rich/RichTools/src/RichDetectorTool.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 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. * -\*****************************************************************************/ - -//----------------------------------------------------------------------------- -/** @file RichDetectorTool.cpp - * - * Implementation file for class : Rich::DetectorTool - * - * @author Antonis Papanestis - * @date 2012-10-26 - */ -//----------------------------------------------------------------------------- - -// local -#include "RichDetectorTool.h" - -DECLARE_COMPONENT( Rich::DetectorTool ) - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -Rich::DetectorTool::DetectorTool( const std::string& type, const std::string& name, const IInterface* parent ) - : Rich::ToolBase( type, name, parent ) { - // Interface - declareInterface( this ); -} - -//========================================================================= -// deRichDetectors -//========================================================================= -std::vector Rich::DetectorTool::deRichDetectors() const { - std::vector deRichDets; - auto locations = {DeRichLocations::OldRich1, DeRichLocations::OldRich2}; - deRichDets.reserve( locations.size() ); - - for ( const auto& loc : locations ) { deRichDets.push_back( getDet( loc ) ); } - - return deRichDets; -} diff --git a/Rich/RichTools/src/RichDetectorTool.h b/Rich/RichTools/src/RichDetectorTool.h deleted file mode 100644 index 5c289a64c..000000000 --- a/Rich/RichTools/src/RichDetectorTool.h +++ /dev/null @@ -1,57 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 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. * -\*****************************************************************************/ - -//----------------------------------------------------------------------------- -/** @file RichDetectorTool.h - * - * Header file for tool : Rich::DetectorTool - * - * @author Antonis Papanestis - * @date 2012-10-26 - */ -//----------------------------------------------------------------------------- - -#pragma once - -// STL -#include - -// Base class and interface -#include "RichInterfaces/IRichDetectorTool.h" -#include "RichKernel/RichToolBase.h" - -// RichDet -#include "RichDet/DeRich.h" - -namespace Rich { - //--------------------------------------------------------------------------- - /** @class DetectorTool RichDetectorTool.h - * - * A tool to preform the manipulation of RichDetector channel identifiers - * - * @author Antonis Papanestis - * @date 2012-11-01 - * - */ - //--------------------------------------------------------------------------- - - class DetectorTool final : public Rich::ToolBase, virtual public IDetectorTool { - - public: // Methods for Gaudi Framework - /// Standard constructor - DetectorTool( const std::string& type, const std::string& name, const IInterface* parent ); - - public: // methods (and doxygen comments) inherited from interface - // method to return pointer to existing Rich detectors - std::vector deRichDetectors() const override; - }; - -} // namespace Rich -- GitLab From 97951d73eb616ed42903796eff694c300826029b Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Tue, 27 Sep 2022 15:18:17 +0200 Subject: [PATCH 2/4] do not compile RichTools in DD4hep mode --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bb22a07e..2679b5aef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,19 @@ list(PREPEND CMAKE_MODULE_PATH set(WITH_Lbcom_PRIVATE_DEPENDENCIES TRUE) include(LbcomDependencies) + +if (NOT USE_DD4HEP) + set(VarName DetDescOnlySubDirs) +else() + set(VarName LHCB_IGNORE_SUBDIRS) +endif() +set(${VarName} + Rich/RichTools +) + # -- Subdirectories lhcb_add_subdirectories( + ${DetDescOnlySubDirs} Associators/Associators Calo/CaloAssociators Calo/CaloCheckers @@ -36,7 +47,6 @@ lhcb_add_subdirectories( Rich/RichFutureAlgorithms Rich/RichFutureTools Rich/RichMCTools - Rich/RichTools Si/SiTools UT/UTAlgorithms UT/UTAssociators -- GitLab From 6b5e86a17e93866246aa8f1db323795b11ca93f8 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Thu, 29 Sep 2022 16:03:36 +0200 Subject: [PATCH 3/4] Use derived conditions in RichSmartIDTool --- Rich/RichTools/src/RichSmartIDTool.cpp | 94 +++++++------------------- Rich/RichTools/src/RichSmartIDTool.h | 42 +++++------- 2 files changed, 42 insertions(+), 94 deletions(-) diff --git a/Rich/RichTools/src/RichSmartIDTool.cpp b/Rich/RichTools/src/RichSmartIDTool.cpp index 6b319c10b..066eee11e 100644 --- a/Rich/RichTools/src/RichSmartIDTool.cpp +++ b/Rich/RichTools/src/RichSmartIDTool.cpp @@ -23,44 +23,26 @@ // local #include "RichSmartIDTool.h" -DECLARE_COMPONENT( Rich::SmartIDTool ) +#include "RichDetectors/Rich1.h" +#include "RichDetectors/Rich2.h" -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -Rich::SmartIDTool::SmartIDTool( const std::string& type, const std::string& name, const IInterface* parent ) - : Rich::ToolBase( type, name, parent ) { - // Interface - declareInterface( this ); - // JOs - declareProperty( "HitOnPhotoCathSide", m_hitPhotoCathSide = false ); - // setProperty( "OutputLevel", 1 ); -} +DECLARE_COMPONENT( Rich::SmartIDTool ) -//============================================================================= StatusCode Rich::SmartIDTool::initialize() { - - // Initialise base class - const StatusCode sc = Rich::ToolBase::initialize(); - if ( sc.isFailure() ) return sc; - - m_deRichTool = tool( "Rich::DetectorTool", "RichDetectorTool" ); - - // Get the Riches and Rich System - const auto deRiches = m_deRichTool->deRichDetectors(); - m_richS = deRiches[0]->deRichSystem(); - - // loop over riches and photo detector panels - for ( unsigned int r = 0; r < deRiches.size(); ++r ) { - m_photoDetPanels[deRiches[r]->rich()] = PDPanelsPerRich( Rich::NPDPanelsPerRICH, nullptr ); - for ( unsigned int panel = 0; panel < Rich::NPDPanelsPerRICH; ++panel ) { - ( m_photoDetPanels[deRiches[r]->rich()] )[panel] = deRiches[r]->pdPanel( (Rich::Side)panel ); - _ri_debug << "Stored photodetector panel " << m_photoDetPanels[deRiches[r]->rich()][panel]->name() - << " offset=" << m_photoDetPanels[deRiches[r]->rich()][panel]->localOffset() << endmsg; - } - } - - return sc; + return ConditionAccessorHolder::initialize().andThen( [&] { + addConditionDerivation( {DeRichLocations::OldRich1, DeRichLocations::OldRich2}, m_photoDetPanels.key(), + [&]( DeRich const& r1, DeRich const& r2 ) { + RichPDPanels photoDetPanels; + for ( DeRich const* r : {&r1, &r2} ) { + photoDetPanels[r->rich()] = PDPanelsPerRich( Rich::NPDPanelsPerRICH, nullptr ); + for ( unsigned int panel = 0; panel < Rich::NPDPanelsPerRICH; ++panel ) { + photoDetPanels[r->rich()][panel] = r->pdPanel( (Rich::Side)panel ); + } + } + return photoDetPanels; + } ); + return StatusCode::SUCCESS; + } ); } //============================================================================= @@ -95,7 +77,7 @@ bool Rich::SmartIDTool::globalPosition( const Rich::PDPixelCluster& cluster, Gau // on the PD entrance window //============================================================================= bool Rich::SmartIDTool::globalPosition( const LHCb::RichSmartID& smartID, Gaudi::XYZPoint& detectPoint ) const { - const auto& richIndex = m_photoDetPanels[smartID.rich()]; + const auto& richIndex = m_photoDetPanels.get()[smartID.rich()]; return ( richIndex[smartID.panel()]->detectionPoint( smartID, detectPoint, m_hitPhotoCathSide ) ); } @@ -104,7 +86,7 @@ bool Rich::SmartIDTool::globalPosition( const LHCb::RichSmartID& smartID, Gaudi: //============================================================================= Gaudi::XYZPoint Rich::SmartIDTool::globalPosition( const Gaudi::XYZPoint& localPoint, const Rich::DetectorType rich, const Rich::Side side ) const { - const auto& richIndex = m_photoDetPanels[rich]; + const auto& richIndex = m_photoDetPanels.get()[rich]; return richIndex[side]->PDPanelToGlobalMatrix() * localPoint; } @@ -134,7 +116,7 @@ bool Rich::SmartIDTool::pdPosition( const LHCb::RichSmartID& pdid, Gaudi::XYZPoi //============================================================================= bool Rich::SmartIDTool::smartID( const Gaudi::XYZPoint& globalPoint, LHCb::RichSmartID& smartid ) const { // check to see if the smartID is set, and if PD is active - if ( smartid.pdIsSet() && !m_richS->pdIsActive( smartid ) ) { return false; } + if ( smartid.pdIsSet() ) { return false; } try { if ( globalPoint.z() < 8000.0 ) { @@ -144,7 +126,7 @@ bool Rich::SmartIDTool::smartID( const Gaudi::XYZPoint& globalPoint, LHCb::RichS smartid.setRich( Rich::Rich2 ); smartid.setPanel( globalPoint.x() > 0.0 ? Rich::left : Rich::right ); } - const auto& richIndex = m_photoDetPanels[smartid.rich()]; + const auto& richIndex = m_photoDetPanels.get()[smartid.rich()]; return richIndex[smartid.panel()]->smartID( globalPoint, smartid ); } @@ -168,26 +150,22 @@ bool Rich::SmartIDTool::smartID( const Gaudi::XYZPoint& globalPoint, LHCb::RichS Gaudi::XYZPoint Rich::SmartIDTool::globalToPDPanel( const Gaudi::XYZPoint& globalPoint ) const { if ( globalPoint.z() < 8000.0 ) { // Rich1 + const auto& richIndex = m_photoDetPanels.get()[Rich::Rich1]; if ( globalPoint.y() > 0.0 ) { // top side - const auto& richIndex = m_photoDetPanels[Rich::Rich1]; return richIndex[Rich::top]->globalToPDPanelMatrix() * globalPoint; - - // return m_photoDetPanels[Rich::Rich1][Rich::top]->globalToPDPanelMatrix()*globalPoint; } else { // bottom side - const auto& richIndex = m_photoDetPanels[Rich::Rich1]; return richIndex[Rich::bottom]->globalToPDPanelMatrix() * globalPoint; } } else // Rich2 { + const auto& richIndex = m_photoDetPanels.get()[Rich::Rich2]; if ( globalPoint.x() > 0.0 ) { // left side - const auto& richIndex = m_photoDetPanels[Rich::Rich2]; return richIndex[Rich::left]->globalToPDPanelMatrix() * globalPoint; } else { // right side - const auto& richIndex = m_photoDetPanels[Rich::Rich2]; return richIndex[Rich::right]->globalToPDPanelMatrix() * globalPoint; } } @@ -196,45 +174,25 @@ Gaudi::XYZPoint Rich::SmartIDTool::globalToPDPanel( const Gaudi::XYZPoint& globa //============================================================================= // Returns a list with all valid smartIDs //============================================================================= -LHCb::RichSmartID::Vector Rich::SmartIDTool::readoutChannelList() const { - +LHCb::RichSmartID::Vector Rich::SmartIDTool::readoutChannelList( RichPDPanels const& photoDetPanels ) const { // the list to return LHCb::RichSmartID::Vector readoutChannels; - // Reserve rough size ( RICH1 + RICH2 ) readoutChannels.reserve( 400000 ); - bool sc = true; - // Fill for RICH1 - const auto& rich1Index = m_photoDetPanels[Rich::Rich1]; + const auto& rich1Index = photoDetPanels[Rich::Rich1]; sc = sc && rich1Index[Rich::top]->readoutChannelList( readoutChannels ); sc = sc && rich1Index[Rich::bottom]->readoutChannelList( readoutChannels ); const auto nRich1 = readoutChannels.size(); - // Fill for RICH2 - const auto& rich2Index = m_photoDetPanels[Rich::Rich2]; + const auto& rich2Index = photoDetPanels[Rich::Rich2]; sc = sc && rich2Index[Rich::left]->readoutChannelList( readoutChannels ); sc = sc && rich2Index[Rich::right]->readoutChannelList( readoutChannels ); const auto nRich2 = readoutChannels.size() - nRich1; - if ( !sc ) Exception( "Problem reading readout channel lists from DeRichPDPanels" ); - // Sort the list SmartIDSorter::sortByRegion( readoutChannels ); - info() << "Created active PD channel list : # channels RICH(1/2) = " << nRich1 << " / " << nRich2 << endmsg; - - if ( msgLevel( MSG::VERBOSE ) ) { - for ( const auto& ID : readoutChannels ) { - Gaudi::XYZPoint gPos; - sc = globalPosition( ID, gPos ); - if ( !sc ) Exception( "Problem converting RichSmartID to global coordinate" ); - verbose() << " RichSmartID " << ID << " " << ID.dataBitsOnly().key() << endmsg - << " -> global Position : " << gPos << endmsg - << " -> local Position : " << globalToPDPanel( gPos ) << endmsg; - } - } - return readoutChannels; } diff --git a/Rich/RichTools/src/RichSmartIDTool.h b/Rich/RichTools/src/RichSmartIDTool.h index a28b4e5ab..90b48b5b1 100644 --- a/Rich/RichTools/src/RichSmartIDTool.h +++ b/Rich/RichTools/src/RichSmartIDTool.h @@ -22,15 +22,12 @@ #pragma once -// STL -#include -#include +#include "DetDesc/GenericConditionAccessorHolder.h" // Base class #include "RichKernel/RichToolBase.h" // Interfaces -#include "RichInterfaces/IRichDetectorTool.h" #include "RichInterfaces/IRichSmartIDTool.h" // Utils @@ -43,6 +40,9 @@ #include "RichDet/DeRichPDPanel.h" #include "RichDet/DeRichSystem.h" +#include +#include + namespace Rich { //----------------------------------------------------------------------------- @@ -59,13 +59,10 @@ namespace Rich { */ //----------------------------------------------------------------------------- - class SmartIDTool final : public Rich::ToolBase, virtual public ISmartIDTool { + class SmartIDTool final : public LHCb::DetDesc::ConditionAccessorHolder> { public: // Methods for Gaudi Framework - /// Standard constructor - SmartIDTool( const std::string& type, const std::string& name, const IInterface* parent ); - - // Initialization of the tool after creation + using ConditionAccessorHolder::ConditionAccessorHolder; StatusCode initialize() override; public: // methods (and doxygen comments) inherited from interface @@ -86,31 +83,24 @@ namespace Rich { bool smartID( const Gaudi::XYZPoint& globalPoint, LHCb::RichSmartID& smartid ) const override; // Supplies a vector of all currently active and valid channels in the RICH detectors - LHCb::RichSmartID::Vector readoutChannelList() const override; + LHCb::RichSmartID::Vector readoutChannelList() const override { + return readoutChannelList( m_photoDetPanels.get() ); + } + + // Supplies a vector of all currently active and valid channels in the RICH detectors + LHCb::RichSmartID::Vector readoutChannelList( RichPDPanels const& ) const override; // Converts a position in global coordinates to the local coordinate system. Gaudi::XYZPoint globalToPDPanel( const Gaudi::XYZPoint& globalPoint ) const override; - private: - /// photodetector panels per rich - using PDPanelsPerRich = std::vector; - - /// typedef for photodetector for each rich - // typedef Rich::Map RichPDPanels; - using RichPDPanels = std::array; + std::string_view getPDPanelsPath() const override { return m_photoDetPanels.key(); } private: /// photodetector for each rich - RichPDPanels m_photoDetPanels; - - /// RichSystem object - DeRichSystem* m_richS = nullptr; - - /// false to get the hit on the outside of PD window (inlcuding refraction) - bool m_hitPhotoCathSide; + ConditionAccessor m_photoDetPanels{this, name() + "-PhotoDetPanels"}; - /// Pointer to detector tool for DeRich objects - const IDetectorTool* m_deRichTool = nullptr; + Gaudi::Property m_hitPhotoCathSide{this, "HitOnPhotoCathSide", false, + "false to get the hit on the outside of PD window (inlcuding refraction)"}; }; } // namespace Rich -- GitLab From 1e5f5550c85e260438b77e17437bfa4d54a36f19 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Mon, 3 Oct 2022 08:58:56 +0200 Subject: [PATCH 4/4] Always use GenericConditionAccessHolder to be DD4hep compatible --- UT/UTTools/src/UTSelectChannelIDByElement.cpp | 2 +- VP/VPAlgorithms/src/VPClustering.cpp | 3 +-- VP/VPCheckers/src/VPClusterMonitor.cpp | 3 +-- VP/VPCheckers/src/VPTrackEff.cpp | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/UT/UTTools/src/UTSelectChannelIDByElement.cpp b/UT/UTTools/src/UTSelectChannelIDByElement.cpp index 6c689a8fe..ef0823935 100644 --- a/UT/UTTools/src/UTSelectChannelIDByElement.cpp +++ b/UT/UTTools/src/UTSelectChannelIDByElement.cpp @@ -12,7 +12,7 @@ #include "Kernel/IUTChannelIDSelector.h" #include "Kernel/UTNames.h" -#include "DetDesc/ConditionAccessorHolder.h" +#include "DetDesc/GenericConditionAccessorHolder.h" #include "UTDet/DeUTDetector.h" #include "UTDet/DeUTLayer.h" #include "UTDet/DeUTSector.h" diff --git a/VP/VPAlgorithms/src/VPClustering.cpp b/VP/VPAlgorithms/src/VPClustering.cpp index 369481721..6e1fe4abe 100644 --- a/VP/VPAlgorithms/src/VPClustering.cpp +++ b/VP/VPAlgorithms/src/VPClustering.cpp @@ -8,8 +8,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -#include "DetDesc/ConditionAccessor.h" -#include "DetDesc/ConditionAccessorHolder.h" +#include "DetDesc/GenericConditionAccessorHolder.h" #include "Event/VPCluster.h" #include "Event/VPDigit.h" #include "GaudiAlg/Transformer.h" diff --git a/VP/VPCheckers/src/VPClusterMonitor.cpp b/VP/VPCheckers/src/VPClusterMonitor.cpp index 1e2643450..2d4dbd3ca 100644 --- a/VP/VPCheckers/src/VPClusterMonitor.cpp +++ b/VP/VPCheckers/src/VPClusterMonitor.cpp @@ -8,8 +8,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -#include "DetDesc/ConditionAccessor.h" -#include "DetDesc/ConditionAccessorHolder.h" +#include "DetDesc/GenericConditionAccessorHolder.h" #include "Event/MCHit.h" #include "Event/MCParticle.h" #include "Event/VPCluster.h" diff --git a/VP/VPCheckers/src/VPTrackEff.cpp b/VP/VPCheckers/src/VPTrackEff.cpp index aaa729726..69b54c9cd 100644 --- a/VP/VPCheckers/src/VPTrackEff.cpp +++ b/VP/VPCheckers/src/VPTrackEff.cpp @@ -8,8 +8,7 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -#include "DetDesc/ConditionAccessor.h" -#include "DetDesc/ConditionAccessorHolder.h" +#include "DetDesc/GenericConditionAccessorHolder.h" #include "Event/MCHit.h" #include "Event/MCParticle.h" #include "Event/Track.h" -- GitLab