Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions interface/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ namespace utils {
// Set range of physics model parameters
void setModelParameterRanges( const std::string & setPhysicsModelParameterRangeExpression, const RooArgSet & params);

/** @return true if the parameter's value is less than one sigma away from the lower end of the range */
bool isParameterAtLowerBoundary( const RooRealVar &);

/** @return true if the parameter's value is less than one sigma away from the upper end of the range */
bool isParameterAtUpperBoundary( const RooRealVar &);

bool isParameterAtBoundary( const RooRealVar &);
bool anyParameterAtBoundaries( const RooArgSet &, int verbosity);

Expand Down
52 changes: 45 additions & 7 deletions src/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,26 +712,43 @@ std::vector<std::vector<int> > utils::generateCombinations(const std::vector<int
}


bool utils::isParameterAtBoundary( const RooRealVar &param ){
bool utils::isParameterAtLowerBoundary( const RooRealVar &param ){

double vMin = param.getMin();
double vMax = param.getMax();
double val = param.getVal();
double errLo = -1.0 * param.getErrorLo();
double errHi = param.getErrorHi();

double pullMin = (val-vMin) / (errLo);

float nSigma=1.0;

if(pullMin < nSigma){
return true;
}

return false;
}

bool utils::isParameterAtUpperBoundary( const RooRealVar &param ){

double vMax = param.getMax();
double val = param.getVal();
double errHi = param.getErrorHi();

double pullMax = (vMax-val) / (errHi);

float nSigma=1.0;

if(pullMin < nSigma || pullMax < nSigma){
if(pullMax < nSigma){
return true;
}

return false;
}

bool utils::isParameterAtBoundary( const RooRealVar &param ){
return isParameterAtLowerBoundary(param) || isParameterAtUpperBoundary(param);
}

bool utils::anyParameterAtBoundaries( const RooArgSet &params, int verbosity ){

Expand All @@ -740,14 +757,35 @@ bool utils::anyParameterAtBoundaries( const RooArgSet &params, int verbosity ){

RooLinkedListIter iter = params.iterator(); int i = 0;
for (RooRealVar *a = (RooRealVar *) iter.Next(); a != 0; a = (RooRealVar *) iter.Next(), ++i) {

bool isBad = isParameterAtBoundary(*a);

bool atLowerBoundary = isParameterAtLowerBoundary(*a);
bool atUpperBoundary = isParameterAtUpperBoundary(*a);
bool isBad = atLowerBoundary || atUpperBoundary;

if(isBad){
std::string varName((*a).GetName());

if( verbosity >= 9 || (timesFoundAtBoundary[varName] < 3 && verbosity > -1) ){
fprintf(CloseCoutSentry::trueStdOutGlobal()," [WARNING] Found [%s] at boundary. \n", (*a).GetName());

fprintf(CloseCoutSentry::trueStdOutGlobal()," [WARNING] Found [%s] at ", (*a).GetName());

if (atLowerBoundary && atUpperBoundary)
fprintf(CloseCoutSentry::trueStdOutGlobal(),"both boundaries");
else if (atLowerBoundary && !atUpperBoundary)
fprintf(CloseCoutSentry::trueStdOutGlobal(),"lower boundary");
else if (!atLowerBoundary && atUpperBoundary)
fprintf(CloseCoutSentry::trueStdOutGlobal(),"upper boundary");
else
{
// we can't come here (as long as we are inside if(isBad) { .. } )
// because isBad = atLowerBoundary || atUpperBoundary
}

fprintf(CloseCoutSentry::trueStdOutGlobal()," (value: %f %+f%+f range: %f..%f)", a->getVal(), a->getErrorHi(), a->getErrorLo(),
a->getMin(), a->getMax());

fprintf(CloseCoutSentry::trueStdOutGlobal(),". \n");

std::cout << " "; (*a).Print();
}

Expand Down