Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more robust protection against infinite loops in Ecal multifit (75x) #11374

Merged
merged 2 commits into from
Sep 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 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,13 @@ 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;
break;
}

//unconstrain parameter
Index idxp = _nP + idxwmax;
Expand Down Expand Up @@ -384,6 +391,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