diff --git a/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp b/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp index e03bcda9a24899c49140ba16d23c33eda49ca37f..1f00d963b3ee9c0606a2810b6e3e82dc8dc65f71 100644 --- a/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp +++ b/CaloFuture/CaloFuturePIDs/src/SelectiveElectronMatchAlg.cpp @@ -261,9 +261,9 @@ namespace LHCb::Calo { if ( calo_obj == hypoindex.end() ) continue; // adapt track state to calo obj location - double delta_z = calo_obj->position().z() - state.z(); - track_pos_local( 0 ) = track_pos( 0 ) + state.tx() * delta_z; - track_pos_local( 1 ) = track_pos( 1 ) + state.ty() * delta_z; + const auto delta_z = calo_obj->position().z() - state.z(); + track_pos_local( 0 ) = track_pos( 0 ) + ( state.tx() * delta_z ); + track_pos_local( 1 ) = track_pos( 1 ) + ( state.ty() * delta_z ); // obtain calo obj info calo_pos = {calo_obj->position().x(), calo_obj->position().y(), calo_obj->energy()}; @@ -278,7 +278,7 @@ namespace LHCb::Calo { m_nMatchFailure += 1; continue; } - auto chi2 = ROOT::Math::Similarity( diff_pos, comb_cov ); + const auto chi2 = ROOT::Math::Similarity( diff_pos, comb_cov ); // check if it has proper value if ( chi2 > m_threshold ) { @@ -295,7 +295,10 @@ namespace LHCb::Calo { // monitor statistics: number of links and average chi2 const auto nLinks = output_table.size(); m_nLinks += nLinks; - for ( auto const& proxy : output_table.scalar() ) m_chi2 += proxy.get<ElectronMatch>().cast() / nLinks; + if ( nLinks > 0 ) { + auto chi2 = m_chi2.buffer(); + for ( auto const& proxy : output_table.scalar() ) { chi2 += proxy.get<ElectronMatch>().cast() / nLinks; } + } return output_table; }