diff --git a/Utils/src/PDFWeightProducer.cc b/Utils/src/PDFWeightProducer.cc index 0a882fbb35ea9b2e281e51826656926c70b3a03a..2ae2a7c3abe552c9d9cedba298133df68ce274b5 100644 --- a/Utils/src/PDFWeightProducer.cc +++ b/Utils/src/PDFWeightProducer.cc @@ -25,9 +25,10 @@ class PDFWeightHelper { public: PDFWeightHelper(const P* prod) : product_(prod) {} bool fillWeights(std::vector<double>* output, unsigned offset, unsigned nWeights, wtype wt) { - if(offset > this->getMax()) return false; + unsigned max = this->getMax(); + if(max==0 or offset > max) return false; double norm = 1./this->getNorm(offset,wt); - unsigned max = std::min(nWeights+offset,this->getMax()); + max = std::min(nWeights+offset,max); output->reserve(max-offset); for (unsigned int i = offset; i < max; i++) { output->push_back(this->getWeight(i)*norm);