Skip to content

Commit

Permalink
Merge pull request #44281 from slava77/patch-125
Browse files Browse the repository at this point in the history
add non-empty checks in DAClusterizer to avoid reading null refs
  • Loading branch information
cmsbuild authored Mar 7, 2024
2 parents 2910a78 + f2c0197 commit ff51428
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZT_vect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@ DAClusterizerInZT_vect::track_t DAClusterizerInZT_vect::fill(const vector<reco::
sumtkwt += t_tkwt;
}

tks.extractRaw();
tks.osumtkwt = sumtkwt > 0 ? 1. / sumtkwt : 0.;
if (sumtkwt > 0) {
tks.extractRaw();
tks.osumtkwt = 1. / sumtkwt;
} else {
tks.osumtkwt = 0.;
}

#ifdef DEBUG
if (DEBUGLEVEL > 0) {
Expand Down Expand Up @@ -1109,15 +1113,14 @@ bool DAClusterizerInZT_vect::split(const double beta, track_t& tks, vertex_t& y,

vector<TransientVertex> DAClusterizerInZT_vect::vertices(const vector<reco::TransientTrack>& tracks) const {
track_t&& tks = fill(tracks);
vector<TransientVertex> clusters;
if (tks.getSize() == 0)
return clusters;
tks.extractRaw();

unsigned int nt = tks.getSize();
double rho0 = 0.0; // start with no outlier rejection

vector<TransientVertex> clusters;
if (tks.getSize() == 0)
return clusters;

vertex_t y; // the vertex prototypes

// initialize:single vertex at infinite temperature
Expand Down
15 changes: 9 additions & 6 deletions RecoVertex/PrimaryVertexProducer/src/DAClusterizerInZ_vect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ DAClusterizerInZ_vect::track_t DAClusterizerInZ_vect::fill(const vector<reco::Tr
sumtkwt += t_tkwt;
}

tks.extractRaw();
tks.osumtkwt = sumtkwt > 0 ? 1. / sumtkwt : 0.;
if (sumtkwt > 0) {
tks.extractRaw();
tks.osumtkwt = 1. / sumtkwt;
} else {
tks.osumtkwt = 0.;
}

#ifdef DEBUG
if (DEBUGLEVEL > 0) {
Expand Down Expand Up @@ -768,13 +772,12 @@ bool DAClusterizerInZ_vect::split(const double beta, track_t& tks, vertex_t& y,

vector<TransientVertex> DAClusterizerInZ_vect::vertices_no_blocks(const vector<reco::TransientTrack>& tracks) const {
track_t&& tks = fill(tracks);
tks.extractRaw();

double rho0 = 0.0; // start with no outlier rejection

vector<TransientVertex> clusters;
if (tks.getSize() == 0)
return clusters;
tks.extractRaw();

double rho0 = 0.0; // start with no outlier rejection

vertex_t y; // the vertex prototypes

Expand Down

0 comments on commit ff51428

Please sign in to comment.