diff --git a/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp b/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp index 63957af42acb2b2ec78beca59288de949f39ac66..15d86b400cfa57248fc4ed4b605aaef5b8c2b14b 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. );