Commit 768b0a72 authored by Rosen Matev's avatar Rosen Matev
Browse files

Merge branch 'NN_checkoverlap' into 'master'

alternative branch for overlap checking if all particles are basics

See merge request Phys!996

Moved from Phys@e640c264
parents 25109cde 99e561c5
......@@ -27,6 +27,21 @@
// Declaration of the Tool Factory
DECLARE_COMPONENT( CheckOverlap )
namespace detail {
template <typename... Particles>
bool find_overlap_in_basics( Particles const*... particles ) {
static_assert( ( std::is_same_v<Particles, LHCb::ProtoParticle> && ... ),
"All Particles must be LHCb::ProtoParticle" );
std::array ps{particles...};
for ( auto i = 0u; i < ps.size(); ++i ) {
for ( auto j = i + 1; j < ps.size(); ++j ) {
if ( ps[i] == ps[j] || ( ps[i]->track() != nullptr && ps[i]->track() == ps[j]->track() ) ) { return true; }
}
}
return false;
}
} // namespace detail
//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
......@@ -99,6 +114,9 @@ bool CheckOverlap::foundOverlap( const LHCb::Particle* particle1 ) const {
bool CheckOverlap::foundOverlap( const LHCb::Particle* particle1, const LHCb::Particle* particle2 ) const {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << "foundOverlap(2)" << endmsg;
if ( !particle1 || !particle2 ) Exception( "Null pointer" );
if ( particle1->proto() != nullptr && particle2->proto() != nullptr ) {
return detail::find_overlap_in_basics( particle1->proto(), particle2->proto() );
}
LHCb::Particle::ConstVector parts( 2 );
parts[0] = particle1;
parts[1] = particle2;
......@@ -111,6 +129,9 @@ bool CheckOverlap::foundOverlap( const LHCb::Particle* particle1, const LHCb::Pa
const LHCb::Particle* particle3 ) const {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << "foundOverlap(3)" << endmsg;
if ( !particle1 || !particle2 || !particle3 ) Exception( "Null pointer" );
if ( particle1->proto() != nullptr && particle2->proto() != nullptr && particle3->proto() != nullptr ) {
return detail::find_overlap_in_basics( particle1->proto(), particle2->proto(), particle3->proto() );
}
LHCb::Particle::ConstVector parts( 3 );
parts[0] = particle1;
parts[1] = particle2;
......@@ -124,6 +145,11 @@ bool CheckOverlap::foundOverlap( const LHCb::Particle* particle1, const LHCb::Pa
const LHCb::Particle* particle3, const LHCb::Particle* particle4 ) const {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << "foundOverlap(4)" << endmsg;
if ( !particle1 || !particle2 || !particle3 || !particle4 ) Exception( "Null pointer" );
if ( particle1->proto() != nullptr && particle2->proto() != nullptr && particle3->proto() != nullptr &&
particle4->proto() != nullptr ) {
return detail::find_overlap_in_basics( particle1->proto(), particle2->proto(), particle3->proto(),
particle4->proto() );
}
LHCb::Particle::ConstVector parts( 4 );
parts[0] = particle1;
parts[1] = particle2;
......
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