Skip to content
Snippets Groups Projects
Commit 7afec2fa authored by Lorenzo Moneta's avatar Lorenzo Moneta
Browse files

fixes for Coverity (division by zero, 42512,3)

git-svn-id: http://root.cern.ch/svn/root/trunk@44095 27541ba8-7e3a-0410-8455-c3a389f83636
parent ea5421bd
Branches
Tags
No related merge requests found
......@@ -354,6 +354,7 @@ HypoTestInverter::HypoTestInverter( RooAbsData& data, ModelConfig &sbModel, Mode
HypoTestInverter::HypoTestInverter(const HypoTestInverter & rhs) :
IntervalCalculator(),
fTotalToysRun(0),
fCalculator0(0), fScannedVariable(0), // add these for Coverity
fResults(0)
{
......@@ -594,14 +595,16 @@ bool HypoTestInverter::RunFixedScan( int nBins, double xMin, double xMax, bool s
<< xMax << std::endl;
}
double thisX = 0;
double thisX = xMin;
for (int i=0; i<nBins; i++) {
if (scanLog)
thisX = exp( log(xMin)+i*(log(xMax)-log(xMin))/(nBins-1) ); // scan in log x
else
thisX = xMin+i*(xMax-xMin)/(nBins-1); // linear scan in x
if (i > 0) { // avoids case of nBins = 1
if (scanLog) {
thisX = exp( log(xMin) + i*(log(xMax)-log(xMin))/(nBins-1) ); // scan in log x
else
thisX = xMin + i*(xMax-xMin)/(nBins-1); // linear scan in x
}
bool status = RunOnePoint(thisX);
// check if failed status
......@@ -662,6 +665,12 @@ bool HypoTestInverter::RunOnePoint( double rVal, bool adaptive, double clTarget)
fScannedVariable->getVal() << endl;
return false;
}
// in case of a dummy result
if (TMath::IsNaN(result->NullPValue() ) && TMath::IsNaN(result->AlternatePValue() ) ) {
oocoutW((TObject*)0,Eval) << "HypoTestInverter - Skip invalid result for point " << fScannedVariable->GetName() << " = " <<
fScannedVariable->getVal() << endl;
return true; // need to return true to avoid breaking the scan loop
}
double lastXtested;
if ( fResults->ArraySize()!=0 ) lastXtested = fResults->GetXValue(fResults->ArraySize()-1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment