Skip to content

Commit

Permalink
add protection for rare infinite loop in ecal multifit
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavid committed Sep 9, 2015
1 parent f545ad8 commit ef9303b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions RecoLocalCalo/EcalRecAlgos/src/PulseChiSqSNNLS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool PulseChiSqSNNLS::NNLS() {
aTbvec = invcovp.transpose()*_covdecomp.matrixL().solve(_sampvec);

int iter = 0;
Index idxwmax;
Index idxwmax = 0;
double wmax = 0.0;
//work = PulseVector::zeros();
while (true) {
Expand All @@ -311,10 +311,12 @@ bool PulseChiSqSNNLS::NNLS() {
const unsigned int nActive = npulse - _nP;

updatework = aTbvec - aTamat*_ampvec;
Index idxwmaxprev = idxwmax;
double wmaxprev = wmax;
wmax = updatework.tail(nActive).maxCoeff(&idxwmax);

//convergence
if (wmax<1e-11) break;
if (wmax<1e-11 || (idxwmax==idxwmaxprev && wmax==wmaxprev)) break;

//unconstrain parameter
Index idxp = _nP + idxwmax;
Expand Down

0 comments on commit ef9303b

Please sign in to comment.