Commit c2e6d55e authored by Mark Smith's avatar Mark Smith
Browse files

Merge branch 'sfarry-fixjetmemory' into 'run2-patches'

Fix memory link in particle flow algorithms

See merge request !963
parents 30f40bd9 bb790f8b
Pipeline #2780114 passed with stage
in 21 seconds
/*****************************************************************************\
/***************************************************************************** \
* (c) Copyright 2019-2021 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
......@@ -66,7 +66,7 @@ private:
bool m_verbose;
/// this is the routine that does the actual work.
void flagClones( LHCb::ProtoParticles* protos, std::vector<bool>& isclone ) const;
void flagClones( std::vector<LHCb::ProtoParticle*> protos, std::vector<bool>& isclone ) const;
// track selector
ITrackSelector* m_trSel;
......@@ -173,9 +173,9 @@ namespace {
//=============================================================================
// Main execution
//=============================================================================
void PFlowProtoFilter::flagClones( LHCb::ProtoParticles* protos, std::vector<bool>& isclone ) const {
void PFlowProtoFilter::flagClones( std::vector<LHCb::ProtoParticle*> protos, std::vector<bool>& isclone ) const {
// initialize all values to false
size_t N = protos->size();
size_t N = protos.size();
isclone.resize( 0 );
isclone.resize( N, false );
......@@ -185,8 +185,7 @@ void PFlowProtoFilter::flagClones( LHCb::ProtoParticles* protos, std::vector<boo
std::vector<TrackData> alltracksstore;
alltracksstore.reserve( N );
size_t i( 0 );
for ( LHCb::ProtoParticles::const_iterator ip = protos->begin(); ip != protos->end(); ++ip )
alltracksstore.push_back( TrackData( ( *ip ), i++ ) );
for ( auto ip : protos ) alltracksstore.push_back( TrackData( ( ip ), i++ ) );
// create vector of pointers and sort it
std::vector<std::reference_wrapper<TrackData>> alltracks( std::begin( alltracksstore ), std::end( alltracksstore ) );
......@@ -270,7 +269,7 @@ StatusCode PFlowProtoFilter::execute() {
m_inputProtos = get<LHCb::ProtoParticles>( m_protosLocation );
LHCb::ProtoParticles* toFlag = new LHCb::ProtoParticles();
std::vector<LHCb::ProtoParticle*> toFlag;
int ntrackprotos = 0;
......@@ -280,22 +279,20 @@ StatusCode PFlowProtoFilter::execute() {
if ( ( *itr )->track() ) {
ntrackprotos++;
if ( m_trSel && m_trSel->accept( *( *itr )->track() ) ) {
toFlag->insert( const_cast<LHCb::ProtoParticle*>( *itr ) );
toFlag.push_back( const_cast<LHCb::ProtoParticle*>( *itr ) );
}
} else {
outputProtos->insert( const_cast<LHCb::ProtoParticle*>( *itr ) );
}
}
counter( "# input protos" ) += ( outputProtos->size() + ntrackprotos );
counter( "# input protos with track" ) += toFlag->size();
counter( "# input protos with track" ) += toFlag.size();
std::vector<bool> isclone( m_inputProtos->size(), false );
flagClones( toFlag, isclone );
int i( 0 );
for ( LHCb::ProtoParticles::iterator itr = toFlag->begin(); itr != toFlag->end(); ++itr, ++i )
if ( !isclone[i] ) outputProtos->insert( const_cast<LHCb::ProtoParticle*>( *itr ) );
for ( unsigned int i = 0; i < toFlag.size(); ++i )
if ( !isclone[i] ) outputProtos->insert( toFlag[i] );
counter( "# accepted protos" ) += outputProtos->size();
......
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