diff --git a/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp b/Phys/RelatedInfoTools/src/MuonProbeToLongMatcher.cpp index fa1b8bdc1497ae6a2818b555c7bb158987f667ff..f1118743ef1f8b3ee53531998ef26861b9ee6570 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{ @@ -60,12 +66,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(); @@ -122,6 +152,7 @@ MuonProbeToLongMatcher::operator() // we use a mulitransformer to define multipl 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. );