Skip to content

Commit

Permalink
avoid overflowing firstStrip_ in case of approximated clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Jul 15, 2022
1 parent ac7a17a commit bd09b48
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions DataFormats/SiStripCluster/src/SiStripCluster.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#include "FWCore/Utilities/interface/Likely.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"

SiStripCluster::SiStripCluster(const SiStripDigiRange& range) : firstStrip_(range.first->strip()), error_x(-99999.9) {
Expand Down Expand Up @@ -27,8 +27,13 @@ SiStripCluster::SiStripCluster(const SiStripApproximateCluster cluster) : error_
charge_ = cluster.width() * cluster.avgCharge();
amplitudes_.resize(cluster.width(), cluster.avgCharge());

float halfwidth_ = 0.5f * float(cluster.width());

//initialize firstStrip_
firstStrip_ = cluster.barycenter() - cluster.width() / 2;
firstStrip_ = std::max(barycenter_ - halfwidth_, 0.f);
if UNLIKELY (firstStrip_ + cluster.width() > 767) {
firstStrip_ = 767 - cluster.width();
}
}

int SiStripCluster::charge() const {
Expand Down

0 comments on commit bd09b48

Please sign in to comment.