From 5ae165004a3be66bd7fa4af99711b6b164e846bf Mon Sep 17 00:00:00 2001
From: Wouter Hulsbergen <wouter.hulsbergen@nikhef.nl>
Date: Mon, 11 Mar 2024 09:14:13 +0100
Subject: [PATCH] added specialization of uniqueVeloSegmentIDFromPrVelo for
 PrVeloTrack

---
 Event/RecEvent/include/Event/PrimaryVertices.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Event/RecEvent/include/Event/PrimaryVertices.h b/Event/RecEvent/include/Event/PrimaryVertices.h
index 362c8308b60..cc05adda6ae 100644
--- a/Event/RecEvent/include/Event/PrimaryVertices.h
+++ b/Event/RecEvent/include/Event/PrimaryVertices.h
@@ -466,12 +466,20 @@ namespace LHCb::Event::PV {
     updateDerivatives();
   }
 
-  template <typename LHCbIDContainer, typename HashType = uint32_t>
+  // Methods to compute a uniqueVeloSegmentID from a set of LHCbIDs
+  template <bool checkIsVelo = true, typename LHCbIDContainer, typename HashType = uint32_t>
   auto uniqueVeloSegmentID( const LHCbIDContainer& lhcbids ) {
     // create a unique ID from the LHCbIDs. we choose the sum because that is independent of the order.
     HashType hash{0};
     for ( const auto id : lhcbids )
-      if ( id.isVP() ) hash += id.lhcbID();
+      if ( !checkIsVelo || id.isVP() ) hash += id.lhcbID();
+    return hash;
+  }
+  // Unfortunate that we need special version for PrVeloTrack but wrapper was expensive
+  template <typename PrVeloTrackProxyScalar, typename HashType = uint32_t>
+  auto uniqueVeloSegmentIDFromPrVelo( const PrVeloTrackProxyScalar& trk ) {
+    HashType hash{0};
+    for ( int ihit = 0; ihit < trk.nHits().cast(); ++ihit ) hash += trk.vp_lhcbID( ihit ).LHCbID().lhcbID();
     return hash;
   }
 } // namespace LHCb::Event::PV
-- 
GitLab