66#include < sstream>
77#include < cmath>
88#include < vector>
9+ #include < unordered_map>
910#include < string>
1011#include < memory>
1112#include < typeinfo>
@@ -414,9 +415,11 @@ void utils::copyAttributes(const RooAbsArg &from, RooAbsArg &to) {
414415 if (!attribs.empty ()) {
415416 for (std::set<std::string>::const_iterator it = attribs.begin (), ed = attribs.end (); it != ed; ++it) to.setAttribute (it->c_str ());
416417 }
417- const std::map<std::string, std::string> strattribs = from.stringAttributes ();
418+ const std::map
419+ <std::string, std::string> strattribs = from.stringAttributes ();
418420 if (!strattribs.empty ()) {
419- for (std::map<std::string,std::string>::const_iterator it = strattribs.begin (), ed = strattribs.end (); it != ed; ++it) to.setStringAttribute (it->first .c_str (), it->second .c_str ());
421+ for (std::map
422+ <std::string,std::string>::const_iterator it = strattribs.begin (), ed = strattribs.end (); it != ed; ++it) to.setStringAttribute (it->first .c_str (), it->second .c_str ());
420423 }
421424}
422425
@@ -695,7 +698,8 @@ std::vector<std::vector<int> > utils::generateCombinations(const std::vector<int
695698}
696699
697700
698- bool utils::checkParameterBoundary ( const RooRealVar ¶m ){
701+ bool utils::isParameterAtBoundary ( const RooRealVar ¶m ){
702+
699703 double vMin = param.getMin ();
700704 double vMax = param.getMax ();
701705 double val = param.getVal ();
@@ -708,25 +712,40 @@ bool utils::checkParameterBoundary( const RooRealVar ¶m ){
708712 float nSigma=1.0 ;
709713
710714 if (pullMin < nSigma || pullMax < nSigma){
711- CloseCoutSentry::breakFree ();
712- std::cout << " [WARNING] Found " <<param.GetName ()<< " at " << std::min (pullMin,pullMax) << " sigma of one of its boundaries:" << std::endl;
713- std::cout << " " ; param.Print ();
714- return false ;
715+ return true ;
715716 }
716-
717- return true ;
717+
718+ return false ;
718719}
719720
720- bool utils::checkParameterBoundaries ( const RooArgSet ¶ms ){
721-
722- bool isNoneBad = true ;
721+
722+ bool utils::anyParameterAtBoundaries ( const RooArgSet ¶ms, int verbosity ){
723+
724+ static std::unordered_map<std::string, unsigned char > timesFoundAtBoundary;
725+ bool isAnyBad = false ;
723726
724727 RooLinkedListIter iter = params.iterator (); int i = 0 ;
725728 for (RooRealVar *a = (RooRealVar *) iter.Next (); a != 0 ; a = (RooRealVar *) iter.Next (), ++i) {
726- bool isBad = checkParameterBoundary (*a);
727- isNoneBad &= isBad;
729+
730+ bool isBad = isParameterAtBoundary (*a);
731+
732+ if (isBad){
733+ std::string varName ((*a).GetName ());
734+
735+ if ( verbosity >= 9 || (timesFoundAtBoundary[varName] < 3 && verbosity > -1 ) ){
736+ fprintf (CloseCoutSentry::trueStdOutGlobal ()," [WARNING] Found [%s] at boundary. \n " , (*a).GetName ());
737+ std::cout << " " ; (*a).Print ();
738+ }
739+
740+ timesFoundAtBoundary[varName]++;
741+ }
742+
743+ isAnyBad |= isBad;
728744 }
729745
730- return isNoneBad;
746+ // for( std::unordered_map<std::string, unsigned char>::value_type e : timesFoundAtBoundary ){
747+ // printf("e %s -> %i\n", e.first.c_str(), e.second);
748+ // }
749+
750+ return isAnyBad;
731751}
732-
0 commit comments