From 56bff777aad84c9f63ae2c8972cd7df3d1d1435f Mon Sep 17 00:00:00 2001 From: Chris Jones <jonesc@hep.phy.cam.ac.uk> Date: Wed, 16 May 2018 17:11:59 +0100 Subject: [PATCH 1/5] Add implementation of bulk ISmartIDTool::globalPositions method to determine the global positions of a vector of clusters --- Rich/RichFutureTools/src/RichSmartIDTool.cpp | 86 ++++++++++++++++++++ Rich/RichFutureTools/src/RichSmartIDTool.h | 5 ++ 2 files changed, 91 insertions(+) diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.cpp b/Rich/RichFutureTools/src/RichSmartIDTool.cpp index 5d4e56eb9..a2823e4fc 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.cpp +++ b/Rich/RichFutureTools/src/RichSmartIDTool.cpp @@ -58,6 +58,92 @@ StatusCode SmartIDTool::initialize() return sc; } +//============================================================================= +// Finds the average positions of a vector of clusters, in global LHCb +// coordinates on the PD entrance window +//============================================================================= +LHCb::STL::Vector<Gaudi::XYZPoint> +SmartIDTool::globalPositions( const Rich::PDPixelCluster::Vector& clusters, + const bool ignoreClusters ) const +{ + // allocate the vector + LHCb::STL::Vector<Gaudi::XYZPoint> points; + points.reserve( clusters.size() ); + + // Do we need to take the full cluster info into account + if ( UNLIKELY( !ignoreClusters ) ) + { + // scalar loop using full cluster info + for ( const auto & clus : clusters ) + { + points.emplace_back(); + const auto ok = globalPosition( clus, points.back() ); + if ( msgLevel(MSG::DEBUG) ) + { + if ( UNLIKELY(!ok) ) + { _ri_debug << "Failed to compute global position for " << clus << endmsg; } + else + { _ri_debug << clus.primaryID() << " " << points.back() << endmsg; } + } + } + } + else + { + // Speed things up using only the primary IDs and SIMD methods... + + // scalar FP type for SIMD objects + using FP = Rich::SIMD::DefaultScalarFP; + // SIMD float type + using SIMDFP = Rich::SIMD::FP<FP>; + // SIMD Point + using SIMDPoint = Rich::SIMD::Point<FP>; + // Type for SmartIDs container. + using SmartIDs = Rich::SIMD::STDArray<LHCb::RichSmartID>; + + // working SIMD objects + SmartIDs ids; + SIMDPoint point; + // SIMD index + std::size_t index = 0; + // Last PD pointer + const DeRichPD * lastPD{nullptr}; + + // Save functor + auto saveInfo = [&]() + { + // Compute SIMD position + lastPD->detectionPoint( ids, point, m_hitPhotoCathSide ); + // save scalar info to container + for ( std::size_t i = 0; i < index; ++i ) + { + points.emplace_back( Gaudi::XYZPoint{ point.X()[i], point.Y()[i], point.Z()[i] } ); + } + // reset SIMD index + index = 0; + lastPD = nullptr; + }; + + // loop over the cluster info + for ( const auto & clus : clusters ) + { + // If new PD, or SIMD data is full, save and reset. + if ( lastPD && ( lastPD != clus.dePD() || index >= SIMDFP::Size ) ) { saveInfo(); } + // Fill info + lastPD = clus.dePD(); + ids[index] = clus.primaryID(); + // increment index for next time + ++index; + } + + // Save the last one + if ( lastPD && index > 0 ) { saveInfo(); } + + } + + // return + return points; +} + //============================================================================= // Returns the position of a RichSmartID cluster in global coordinates // on the PD entrance window diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.h b/Rich/RichFutureTools/src/RichSmartIDTool.h index 1e47637b0..b54cfd4e9 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.h +++ b/Rich/RichFutureTools/src/RichSmartIDTool.h @@ -76,6 +76,11 @@ namespace Rich // Finds the average position of a cluster of RichSmartIDs, in global LHCb coordinates virtual bool globalPosition( const Rich::PDPixelCluster& cluster, Gaudi::XYZPoint& detectPoint ) const override; + + // Finds the average positions of a vector of clusters, in global LHCb coordinates + virtual LHCb::STL::Vector<Gaudi::XYZPoint> + globalPositions( const Rich::PDPixelCluster::Vector& clusters, + const bool ignoreClusters = false ) const override; // Converts an PD RichSmartID identification into a position in global LHCb coordinates. virtual bool pdPosition( const LHCb::RichSmartID& pdid, -- GitLab From d4dc6dfce2090be24a1b9bd40c16349f96b92052 Mon Sep 17 00:00:00 2001 From: Chris Jones <jonesc@hep.phy.cam.ac.uk> Date: Wed, 16 May 2018 17:25:14 +0100 Subject: [PATCH 2/5] Add sanity check assert on vector sizes --- Rich/RichFutureTools/src/RichSmartIDTool.cpp | 3 +++ Rich/RichFutureTools/src/RichSmartIDTool.h | 1 + 2 files changed, 4 insertions(+) diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.cpp b/Rich/RichFutureTools/src/RichSmartIDTool.cpp index a2823e4fc..4442ea815 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.cpp +++ b/Rich/RichFutureTools/src/RichSmartIDTool.cpp @@ -140,6 +140,9 @@ SmartIDTool::globalPositions( const Rich::PDPixelCluster::Vector& clusters, } + // debug sanity check + assert( points.size() == clusters.size() ); + // return return points; } diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.h b/Rich/RichFutureTools/src/RichSmartIDTool.h index b54cfd4e9..5c16892ac 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.h +++ b/Rich/RichFutureTools/src/RichSmartIDTool.h @@ -15,6 +15,7 @@ // STL #include <vector> #include <array> +#include <cassert> // Base class #include "RichFutureKernel/RichToolBase.h" -- GitLab From 849879d8881d87e4041ee8c1a6c05910f095f577 Mon Sep 17 00:00:00 2001 From: Chris Jones <jonesc@hep.phy.cam.ac.uk> Date: Wed, 16 May 2018 17:26:48 +0100 Subject: [PATCH 3/5] Remove unneccessary constructor --- Rich/RichFutureTools/src/RichSmartIDTool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.cpp b/Rich/RichFutureTools/src/RichSmartIDTool.cpp index 4442ea815..faa5606fa 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.cpp +++ b/Rich/RichFutureTools/src/RichSmartIDTool.cpp @@ -116,7 +116,7 @@ SmartIDTool::globalPositions( const Rich::PDPixelCluster::Vector& clusters, // save scalar info to container for ( std::size_t i = 0; i < index; ++i ) { - points.emplace_back( Gaudi::XYZPoint{ point.X()[i], point.Y()[i], point.Z()[i] } ); + points.emplace_back( point.X()[i], point.Y()[i], point.Z()[i] ); } // reset SIMD index index = 0; -- GitLab From 410d9c2256da57cb5097fbf6c827bc5572c32334 Mon Sep 17 00:00:00 2001 From: Chris Jones <jonesc@hep.phy.cam.ac.uk> Date: Thu, 17 May 2018 13:17:34 +0100 Subject: [PATCH 4/5] Add new method to RichSmartIDTool for SIMD global -> local coordinates with rich and side enums --- Rich/RichFutureTools/src/RichSmartIDTool.cpp | 11 +++++++++++ Rich/RichFutureTools/src/RichSmartIDTool.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.cpp b/Rich/RichFutureTools/src/RichSmartIDTool.cpp index faa5606fa..6e2483783 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.cpp +++ b/Rich/RichFutureTools/src/RichSmartIDTool.cpp @@ -299,6 +299,17 @@ SmartIDTool::globalToPDPanel ( const Gaudi::XYZPoint& globalPoint ) const panel(Rich::Rich2,Rich::right) ->globalToPDPanelMatrix()*globalPoint ) ); } +//============================================================================= +// Converts a SIMD position in global coordinates to the local coordinate system +//============================================================================= +SmartIDTool::SIMDPoint +SmartIDTool::globalToPDPanel ( const Rich::DetectorType rich, + const Rich::Side side, + const SIMDPoint& globalPoint ) const +{ + return panel(rich,side) -> globalToPDPanelMatrixSIMD() * globalPoint; +} + //============================================================================= // Converts a SIMD position in global coordinates to the local coordinate system //============================================================================= diff --git a/Rich/RichFutureTools/src/RichSmartIDTool.h b/Rich/RichFutureTools/src/RichSmartIDTool.h index 5c16892ac..ce3b8c3a3 100755 --- a/Rich/RichFutureTools/src/RichSmartIDTool.h +++ b/Rich/RichFutureTools/src/RichSmartIDTool.h @@ -106,6 +106,11 @@ namespace Rich virtual SIMDPoint globalToPDPanel ( const Rich::DetectorType rich, const SIMDPoint& globalPoint ) const override; + // Converts a SIMD position in global coordinates to the local coordinate system + virtual SIMDPoint globalToPDPanel ( const Rich::DetectorType rich, + const Rich::Side side, + const SIMDPoint& globalPoint ) const override; + private: /// photodetector panels per rich -- GitLab From f2275889765c1b73052db92719bcdffaac60386d Mon Sep 17 00:00:00 2001 From: Chris Jones <jonesc@hep.phy.cam.ac.uk> Date: Fri, 18 May 2018 16:54:11 +0100 Subject: [PATCH 5/5] remove unneccessary .dataBitsOnly() strip from sorting lambda function --- Rich/RichFutureAlgorithms/src/RichSmartIDClustering.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Rich/RichFutureAlgorithms/src/RichSmartIDClustering.cpp b/Rich/RichFutureAlgorithms/src/RichSmartIDClustering.cpp index 901a3a170..67f64217c 100644 --- a/Rich/RichFutureAlgorithms/src/RichSmartIDClustering.cpp +++ b/Rich/RichFutureAlgorithms/src/RichSmartIDClustering.cpp @@ -87,10 +87,13 @@ SmartIDClustering::operator()( const Rich::Future::DAQ::L1Map& data ) const // Sort PD data pointer vector by region. // Faster than sorting final cluster container + //std::sort( pdDataV.begin(), pdDataV.end(), + // []( const auto a, const auto b ) + // { return ( a->pdID().dataBitsOnly().key() < + // b->pdID().dataBitsOnly().key() ); } ); std::sort( pdDataV.begin(), pdDataV.end(), []( const auto a, const auto b ) - { return ( a->pdID().dataBitsOnly().key() < - b->pdID().dataBitsOnly().key() ); } ); + { return ( a->pdID().key() < b->pdID().key() ); } ); // Loop over the PD vector and cluster for ( const auto PD : pdDataV ) -- GitLab