Skip to content

Commit

Permalink
Merge pull request #11368 from bendavid/ecalloopfixv2_74x
Browse files Browse the repository at this point in the history
more robust protection against infinite loops in Ecal multifit (7_4_12_patchX)
  • Loading branch information
davidlange6 committed Sep 18, 2015
2 parents bc84795 + ecedf9c commit 38147a0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion RecoLocalCalo/EcalRecAlgos/src/PulseChiSqSNNLS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ bool PulseChiSqSNNLS::NNLS() {
int iter = 0;
Index idxwmax = 0;
double wmax = 0.0;
double threshold = 1e-11;
//work = PulseVector::zeros();
while (true) {
//can only perform this step if solution is guaranteed viable
Expand All @@ -316,7 +317,12 @@ bool PulseChiSqSNNLS::NNLS() {
wmax = updatework.tail(nActive).maxCoeff(&idxwmax);

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

//worst case protection
if (iter>=500) {
edm::LogWarning("PulseChiSqSNNLS::NNLS()") << "Max Iterations reached at iter " << iter << std::endl;
}

//unconstrain parameter
Index idxp = _nP + idxwmax;
Expand Down Expand Up @@ -384,6 +390,12 @@ bool PulseChiSqSNNLS::NNLS() {
--_nP;
}
++iter;

//adaptive convergence threshold to avoid infinite loops but still
//ensure best value is used
if (iter%50==0) {
threshold *= 10.;
}
}

return true;
Expand Down

0 comments on commit 38147a0

Please sign in to comment.