diff --git a/Phys/RelatedInfoTools/src/WeightedRelationTable.cpp b/Phys/RelatedInfoTools/src/WeightedRelationTable.cpp index 5a18b24b2e02d9cca26efccec6c0cf7fdd6c3616..d4a93f5e3bb378cbfc203426e83f5d6803cc50ef 100644 --- a/Phys/RelatedInfoTools/src/WeightedRelationTable.cpp +++ b/Phys/RelatedInfoTools/src/WeightedRelationTable.cpp @@ -22,9 +22,10 @@ namespace { using WeightedRelationTable = LHCb::Relation1D<LHCb::Particle, LHCb::Particle>; - using Transformer = + using RelTableTransformer = LHCb::Algorithm::Transformer<WeightedRelationTable( const LHCb::Particle::Range&, const LHCb::Particle::Range& )>; - using weight_t = bool; + using SelectionTransformer = LHCb::Algorithm::Transformer<LHCb::Particle::Selection( const WeightedRelationTable& )>; + using weight_t = bool; struct Funct { constexpr static auto PropertyName = "Cut"; @@ -60,14 +61,14 @@ namespace { // This algorithm includes GetPhotonsForDalitzDecay -struct WeightedRelTableAlg : with_functors<Transformer, Funct> { +struct WeightedRelTableAlg final : with_functors<RelTableTransformer, Funct> { // ========================================================================== /** the standard constructor * @param name algorithm instance name * @param pSvc service locator */ WeightedRelTableAlg( const std::string& name, ISvcLocator* pSvc ) - : with_functors<Transformer, Funct>::with_functors( + : with_functors<RelTableTransformer, Funct>::with_functors( name, pSvc, {KeyValue{"InputCandidates", ""}, KeyValue{"ReferenceParticles", ""}}, KeyValue{"OutputRelations", ""} ) {} @@ -102,4 +103,22 @@ private: mutable Gaudi::Accumulators::SummingCounter<> m_outCount{this, "#OutputParticles"}; }; +struct SelectionFromWeightedRelationTable final : SelectionTransformer { + // ========================================================================== + /** the standard constructor + * @param name algorithm instance name + * @param pSvc service locator + */ + + SelectionFromWeightedRelationTable( const std::string& name, ISvcLocator* svcLoc ) + : Transformer( name, svcLoc, KeyValue( "InputRelations", "" ), KeyValue( "OutputLocation", "" ) ) {} + + LHCb::Particle::Selection operator()( const WeightedRelationTable& input ) const override { + LHCb::Particle::Selection selection; + for ( const auto& rel : input.relations() ) selection.push_back( rel.to() ); + return selection; + } +}; + DECLARE_COMPONENT( WeightedRelTableAlg ) +DECLARE_COMPONENT( SelectionFromWeightedRelationTable )