From 915e7552b24f653c40346a018813aba379afab17 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 12 Sep 2026 18:12:11 +0200 Subject: [PATCH] reduce the number of 'PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theorygit status -uno' messages. --- src/classes/PRunMuMinus.cpp | 8 ++++++-- src/classes/PRunSingleHisto.cpp | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/classes/PRunMuMinus.cpp b/src/classes/PRunMuMinus.cpp index e1fb4707..d3b12fd1 100644 --- a/src/classes/PRunMuMinus.cpp +++ b/src/classes/PRunMuMinus.cpp @@ -372,6 +372,7 @@ Double_t PRunMuMinus::CalcMaxLikelihood(const std::vector& par) Double_t theo; Double_t data; Double_t time(1.0); + Bool_t post_msg(true); Int_t i; // Calculate the theory function once to ensure one function evaluation for the current set of parameters. @@ -384,7 +385,7 @@ Double_t PRunMuMinus::CalcMaxLikelihood(const std::vector& par) Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs(); if (chunk < 10) chunk = 10; - #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh) + #pragma omp parallel for default(shared) private(i,time,theo,data,post_msg) schedule(dynamic,chunk) reduction(+:mllh) #endif for (i=fStartTimeBin; i < fEndTimeBin; ++i) { time = fData.GetDataTimeStart() + static_cast(i)*fData.GetDataTimeStep(); @@ -394,7 +395,10 @@ Double_t PRunMuMinus::CalcMaxLikelihood(const std::vector& par) data = fData.GetValue()->at(i); if (theo <= 0.0) { - std::cerr << ">> PRunMuMinus::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + if (post_msg) { + post_msg = false; + std::cerr << ">> PRunMuMinus::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + } continue; } diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 83deca84..3bdfe501 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -498,6 +498,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) Double_t theo; Double_t data; Double_t time(1.0); + Bool_t post_msg(true); Int_t i; // norm is needed since there is no simple scaling like in chisq case to get the correct Max.Log.Likelihood value when normlizing N(t) to 1/ns @@ -516,7 +517,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs(); if (chunk < 10) chunk = 10; - #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh) + #pragma omp parallel for default(shared) private(i,time,theo,data,post_msg) schedule(dynamic,chunk) reduction(+:mllh) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); @@ -526,7 +527,10 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) data = fData.GetValue()->at(i); if (theo <= 0.0) { - std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + if (post_msg) { + post_msg = false; + std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + } continue; } @@ -633,6 +637,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& Double_t theo; Double_t data; Double_t time(1.0); + Bool_t post_msg(true); Int_t i; // norm is needed since there is no simple scaling like in chisq case to get the correct Max.Log.Likelihood value when normlizing N(t) to 1/ns @@ -651,7 +656,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& Int_t chunk = (fEndTimeBin - fStartTimeBin)/omp_get_num_procs(); if (chunk < 10) chunk = 10; - #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(+:mllh) + #pragma omp parallel for default(shared) private(i,time,theo,data,post_msg) schedule(dynamic,chunk) reduction(+:mllh) #endif for (i=fStartTimeBin; i(i)*fData.GetDataTimeStep(); @@ -661,7 +666,10 @@ Double_t PRunSingleHisto::CalcMaxLikelihoodExpected(const std::vector& data = fData.GetValue()->at(i); if (theo <= 0.0) { - std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + if (post_msg) { + post_msg = false; + std::cerr << ">> PRunSingleHisto::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl; + } continue; }