From f3d1de666385b97c8471588c3e9ebaf781f00661 Mon Sep 17 00:00:00 2001 From: Miroslav Saur <miroslav.saur@cern.ch> Date: Fri, 21 Feb 2025 09:08:01 +0000 Subject: [PATCH] Merge branch 'decianm-AdditionalMuonHitsForMatching' into '2024-patches' add option to add neighbouring muon hits for overlap checking See merge request lhcb/Rec!4150 (cherry picked from commit 14c6805aa823334f03bf7294d251c518d62d5ab2) 9086e612 add option to add neighbouring muon hits for overlap checking 82c7ab7c add additional hits for the long track instead of the probe track cc400461 Formatting fix Co-authored-by: Miroslav Saur <miroslav.saur@cern.ch> --- .../src/MuonProbeToLongMatcher.cpp | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp b/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp index 63957af42ac..15d86b400cf 100644 --- a/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp +++ b/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp @@ -10,6 +10,7 @@ \*****************************************************************************/ #include "Event/Particle.h" +#include "Event/PrHits.h" #include "Kernel/HashIDs.h" #include "Kernel/LHCbID.h" #include "LHCbAlgs/Transformer.h" @@ -25,15 +26,18 @@ class MuonProbeToLongMatcher : public LHCb::Algorithm::MultiTransformerFilter<std::tuple<LHCb::Particle::Selection, LHCb::Particle::Selection>( - LHCb::Particle::Range const&, LHCb::Particle::Range const& )> { + LHCb::Particle::Range const&, LHCb::Particle::Range const&, MuonHitContainer const& )> { public: MuonProbeToLongMatcher( const std::string& name, ISvcLocator* pSvcLocator ); std::tuple<bool, LHCb::Particle::Selection, LHCb::Particle::Selection> - operator()( LHCb::Particle::Range const& composites, LHCb::Particle::Range const& longparts ) const override; + operator()( LHCb::Particle::Range const& composites, LHCb::Particle::Range const& longparts, + MuonHitContainer const& ) const override; private: + void addNeighbouringMuonIDs( std::vector<LHCb::LHCbID>& muonIDs, const MuonHitContainer& muonHits ) const; + // properties are members of the class // need to specify owner, name, default value, doc Gaudi::Property<double> m_thresMuon{this, "MinMuonFrac", 0.4}; // overlap threshold of Muon stations @@ -46,6 +50,8 @@ private: Gaudi::Property<bool> p_checkUT{this, "checkUT", false}; Gaudi::Property<bool> p_checkFT{this, "checkFT", false}; + Gaudi::Property<bool> p_addNeighbouringMuonHits{this, "addNeighbouringMuonHits", false}; + mutable Gaudi::Accumulators::StatCounter<unsigned int> m_all{this, "#Input composites"}; // Number of JPsi candidates mutable Gaudi::Accumulators::StatCounter<unsigned int> m_matched{ this, "#Matched composites"}; // Number of JPsi candidates with a matched probe track @@ -59,12 +65,36 @@ DECLARE_COMPONENT( MuonProbeToLongMatcher ) // Implementation MuonProbeToLongMatcher::MuonProbeToLongMatcher( const std::string& name, ISvcLocator* pSvcLocator ) - : MultiTransformerFilter( name, pSvcLocator, {KeyValue{"TwoBodyComposites", ""}, KeyValue{"LongTracks", ""}}, - {KeyValue{"MatchedComposites", ""}, KeyValue{"MatchedLongTracks", ""}} ) {} + : MultiTransformerFilter( + name, pSvcLocator, + {KeyValue{"TwoBodyComposites", ""}, KeyValue{"LongTracks", ""}, KeyValue{"MuonHitContainer", ""}}, + {KeyValue{"MatchedComposites", ""}, KeyValue{"MatchedLongTracks", ""}} ) {} + +void MuonProbeToLongMatcher::addNeighbouringMuonIDs( std::vector<LHCb::LHCbID>& muonIDs, + const MuonHitContainer& muonHits ) const { + + const auto muonIDsToLoop = muonIDs; + + for ( auto id : muonIDsToLoop ) { + auto tileID = id.muonID(); + const auto station = tileID.station(); + auto hits = muonHits.hits( station ); + for ( auto const& hit : hits ) { + // -- Add hits which are identical in X but neighbouring in Y, or vide versa + if ( ( (int)hit.tile().nX() == (int)tileID.nX() && std::abs( (int)hit.tile().nY() - (int)tileID.nY() ) == 1 ) || + ( (int)hit.tile().nY() == (int)tileID.nY() && std::abs( (int)hit.tile().nX() - (int)tileID.nX() ) == 1 ) ) { + muonIDs.push_back( LHCb::LHCbID( hit.tile() ) ); + } + } + } + + std::sort( muonIDs.begin(), muonIDs.end() ); +} std::tuple<bool, LHCb::Particle::Selection, LHCb::Particle::Selection> MuonProbeToLongMatcher:: operator() // we use a mulitransformer to define multiple outputs - ( LHCb::Particle::Range const& composites, LHCb::Particle::Range const& longparts ) const { + ( LHCb::Particle::Range const& composites, LHCb::Particle::Range const& longparts, + MuonHitContainer const& muonhits ) const { // initialize counter m_all += composites.size(); @@ -121,6 +151,7 @@ std::tuple<bool, LHCb::Particle::Selection, LHCb::Particle::Selection> MuonProbe std::vector<LHCb::LHCbID> longmuonids; longmuonids.reserve( 10 ); LHCb::HashIDs::lhcbIDs( longmuonpid, longmuonids ); + if ( p_addNeighbouringMuonHits ) addNeighbouringMuonIDs( longmuonids, muonhits ); // evaluate the overlap std::pair<double, double> fracVP( 0., 0. ), fracUT( 0., 0. ), fracFT( 0., 0. ), fracMuon( 0., 0. ); -- GitLab