Commit 5fb312ef authored by Christoph Hasse's avatar Christoph Hasse 🤸🏻
Browse files

Merge branch 'particle_container_merger' into 'master'

Implement a thread-safe particle container merger.

See merge request !994
parents ab933d2f d55ab7ec
Pipeline #3094188 passed with stage
in 21 seconds
...@@ -34,6 +34,7 @@ gaudi_add_module(ParticleCombiners ...@@ -34,6 +34,7 @@ gaudi_add_module(ParticleCombiners
src/Filter.cpp src/Filter.cpp
src/NBodyDecays.cpp src/NBodyDecays.cpp
src/ParticleCombiner.cpp src/ParticleCombiner.cpp
src/ParticleContainerMerger.cpp
src/ThOrCombiner_ChargedBasics.cpp src/ThOrCombiner_ChargedBasics.cpp
src/ThOrCombiner_Composites.cpp src/ThOrCombiner_Composites.cpp
src/ThOrCombiner_Particles.cpp src/ThOrCombiner_Particles.cpp
...@@ -70,7 +71,7 @@ gaudi_add_tests(QMTest) ...@@ -70,7 +71,7 @@ gaudi_add_tests(QMTest)
gaudi_add_executable(test_thor_combiner gaudi_add_executable(test_thor_combiner
SOURCES tests/src/test_thor_combiner.cpp SOURCES tests/src/test_thor_combiner.cpp
LINK LINK
Boost::unit_test_framework Boost::unit_test_framework
LHCb::EventBase LHCb::EventBase
Phys::VertexFitLib Phys::VertexFitLib
......
/*****************************************************************************\
* (c) Copyright 2000-2021 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/Particle.h"
#include "LHCbAlgs/MergingTransformer.h"
#include <string>
namespace {
using counter_t = Gaudi::Accumulators::SummingCounter<unsigned int>;
using inputs_t = const Gaudi::Functional::vector_of_const_<LHCb::Particle::Range>&;
using output_t = std::tuple<LHCb::Particles>;
using filter_output_t = std::tuple<bool, LHCb::Particles>;
using base_t = LHCb::Algorithm::MergingMultiTransformerFilter<output_t( inputs_t )>;
} // namespace
namespace LHCb {
struct ParticleContainerMergerT final : base_t {
ParticleContainerMergerT( const std::string& name, ISvcLocator* pSvcLocator )
: base_t( name, pSvcLocator, {"InputContainers", {}}, {KeyValue{"OutputContainer", ""}} ) {}
filter_output_t operator()( inputs_t lists ) const override {
LHCb::Particles out_particles;
bool out_decision = false;
auto ninput_buffer = m_ninput_particles.buffer();
auto noutput_buffer = m_noutput_particles.buffer();
for ( const auto& list : lists ) {
ninput_buffer += list.size();
for ( const auto& particle : list ) {
// make sure the particle is not yet there!
if ( std::find( out_particles.begin(), out_particles.end(), particle ) == out_particles.end() ) {
out_particles.insert( new LHCb::Particle( *particle ) );
noutput_buffer++;
}
}
}
if ( out_particles.size() > 0 ) { out_decision = true; }
return {out_decision, std::move( out_particles )};
}
private:
mutable counter_t m_ninput_particles{this, "# input particles"};
mutable counter_t m_noutput_particles{this, "# output particles"};
};
DECLARE_COMPONENT_WITH_ID( ParticleContainerMergerT, "ParticleContainerMerger" )
} // namespace LHCb
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment