Skip to content
Snippets Groups Projects
Commit 7d4beb52 authored by Rosen Matev's avatar Rosen Matev :sunny:
Browse files

Protect nullptr dereference and fix counters (follow !3188)

This should fix the throughput tests that are failing since !3188 was merged.
parent a165d59e
No related branches found
No related tags found
1 merge request!3256Protect nullptr dereference and fix counters (follow !3188)
Pipeline #4932450 passed with stages
in 27 seconds
......@@ -94,9 +94,8 @@ public:
out_parts parts_out;
Table p2p_out;
m_candidateCount += parts.size();
for ( const LHCb::Particle* orig_p : parts ) {
m_candidateCount += parts.size();
if ( orig_p->daughters().size() < 2 ) continue;
const LHCb::Particle* orig_jpsi_particle = ( orig_p->daughters() ).at( 0 );
......@@ -133,6 +132,7 @@ public:
Gaudi::XYZPoint DV_point = orig_p->endVertex()->position();
Gaudi::XYZVector B_momentum = my_total_momentum.Vect();
auto [bpv, ip2] = bpvAndMinImpactParameterSquared( vertices, m_min_pv_tracks, DV_point, B_momentum );
if ( !bpv ) continue;
Gaudi::LorentzVector PV_constrained_probe_momentum( my_probe_momentum );
......@@ -148,36 +148,35 @@ public:
float CosThetaDira = ( B_momentum.Dot( FD_vector ) ) / ( sqrt( B_momentum.Mag2() ) * sqrt( FD_vector.Mag2() ) );
float CosThetaDiraLOG = 1.0 - log( 1.0 - CosThetaDira );
if ( bpv != nullptr && !parts.empty() ) {
const LHCb::VertexBase* vx = orig_p->endVertex();
const Gaudi::XYZVector dir = vx->position() - bpv->position();
// Another scale is computed. This time we force the momentum of the B to align with its flight distance
// (defined as line connecting BPV and B DV). The scale of the probe is obtained satisfying this condition.
auto prb_p_PERP = transverseMomentumDir( my_probe_momentum.Vect(), dir );
auto tag_p_perp = transverseMomentumDir( total_tag_momentum.Vect(), dir );
const auto scalePVConst = ( tag_p_perp ) / ( prb_p_PERP );
PV_constrained_probe_momentum.SetPxPyPzE(
scalePVConst * my_probe_momentum.x(), scalePVConst * my_probe_momentum.y(),
scalePVConst * my_probe_momentum.z(),
sqrt( my_probe_momentum.M2() + scalePVConst * scalePVConst * my_probe_momentum.P2() ) );
PV_constrained_total_momentum = PV_constrained_probe_momentum + total_tag_momentum;
PV_constrained_twobody_momentum = PV_constrained_probe_momentum + orig_tag_lepton->momentum();
// We apply a series of cuts.
if ( my_total_momentum.M() > m_mass_min && my_total_momentum.M() < m_mass_max &&
PV_constrained_total_momentum.M() > m_pvconstr_mass_min &&
PV_constrained_total_momentum.M() < m_pvconstr_mass_max &&
( PV_constrained_total_momentum.M() - PV_constrained_twobody_momentum.M() ) > Deltam_pvconstr_mass_min &&
( PV_constrained_total_momentum.M() - PV_constrained_twobody_momentum.M() ) < Deltam_pvconstr_mass_max &&
my_total_momentum.pt() > m_massconstrained_pt_min && ip2 < m_ip_max * m_ip_max &&
CosThetaDiraLOG > m_costhetadiralog_min && dir.Mag2() > m_fd_min * m_fd_min &&
my_probe_momentum.P() > m_probe_p_min && my_probe_momentum.Pt() > m_probe_pt_min
) {
parts_out_sel.push_back( orig_p );
}
const LHCb::VertexBase* vx = orig_p->endVertex();
const Gaudi::XYZVector dir = vx->position() - bpv->position();
// Another scale is computed. This time we force the momentum of the B to align with its flight distance
// (defined as line connecting BPV and B DV). The scale of the probe is obtained satisfying this condition.
auto prb_p_PERP = transverseMomentumDir( my_probe_momentum.Vect(), dir );
auto tag_p_perp = transverseMomentumDir( total_tag_momentum.Vect(), dir );
const auto scalePVConst = ( tag_p_perp ) / ( prb_p_PERP );
PV_constrained_probe_momentum.SetPxPyPzE(
scalePVConst * my_probe_momentum.x(), scalePVConst * my_probe_momentum.y(),
scalePVConst * my_probe_momentum.z(),
sqrt( my_probe_momentum.M2() + scalePVConst * scalePVConst * my_probe_momentum.P2() ) );
PV_constrained_total_momentum = PV_constrained_probe_momentum + total_tag_momentum;
PV_constrained_twobody_momentum = PV_constrained_probe_momentum + orig_tag_lepton->momentum();
// We apply a series of cuts.
if ( my_total_momentum.M() > m_mass_min && my_total_momentum.M() < m_mass_max &&
PV_constrained_total_momentum.M() > m_pvconstr_mass_min &&
PV_constrained_total_momentum.M() < m_pvconstr_mass_max &&
( PV_constrained_total_momentum.M() - PV_constrained_twobody_momentum.M() ) > Deltam_pvconstr_mass_min &&
( PV_constrained_total_momentum.M() - PV_constrained_twobody_momentum.M() ) < Deltam_pvconstr_mass_max &&
my_total_momentum.pt() > m_massconstrained_pt_min && ip2 < m_ip_max * m_ip_max &&
CosThetaDiraLOG > m_costhetadiralog_min && dir.Mag2() > m_fd_min * m_fd_min &&
my_probe_momentum.P() > m_probe_p_min && my_probe_momentum.Pt() > m_probe_pt_min
) {
parts_out_sel.push_back( orig_p );
}
}
m_okCount += parts_out_sel.size();
return parts_out_sel;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment