Skip to content

Commit

Permalink
name 170, add const to vector size
Browse files Browse the repository at this point in the history
  • Loading branch information
VinInn committed Feb 20, 2023
1 parent 84faa67 commit e43317c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions SimCalorimetry/HcalSimAlgos/src/HcalSiPM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const HcalSiPM::cdfpair& HcalSiPM::BorelCDF(unsigned int k) {
// EPSILON determines the min and max # of xtalk cells that can be
// simulated.
constexpr double EPSILON = 1e-6;
constexpr uint32_t maxCDFsize = 170; // safe max to avoid factorial to be infinite
auto it = borelcdfs.find(k);
if (it == borelcdfs.end()) {
vector<double> cdf;
Expand All @@ -90,7 +91,7 @@ const HcalSiPM::cdfpair& HcalSiPM::BorelCDF(unsigned int k) {
unsigned int i;
double sumb = 0.;
double iFact = 1.;
for (i = 0; i < 170; i++) {
for (i = 0; i < maxCDFsize; i++) {
if (i > 0)
iFact *= double(i);
sumb += Borel(i, theCrossTalk, k, iFact);
Expand All @@ -102,7 +103,7 @@ const HcalSiPM::cdfpair& HcalSiPM::BorelCDF(unsigned int k) {
unsigned int borelstartn = i;

// calculate cdf[i] limit to 170 to avoid iFact to become infinite
for (++i; i < 170; ++i) {
for (++i; i < maxCDFsize; ++i) {
iFact *= double(i);
sumb += Borel(i, theCrossTalk, k, iFact);
cdf.push_back(sumb);
Expand Down
2 changes: 1 addition & 1 deletion SimCalorimetry/HcalSimAlgos/src/HcalSiPMHitResponse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CaloSamples HcalSiPMHitResponse::makeSiPMSignal(DetId const& id,

LogDebug("HcalSiPMHitResponse") << "makeSiPMSignal for " << HcalDetId(id);

int nptb = photonTimeBins.size();
const int nptb = photonTimeBins.size();
double sum[nptb];
for (auto i = 0; i < nptb; ++i)
sum[i] = 0;
Expand Down

0 comments on commit e43317c

Please sign in to comment.