Skip to content

Commit

Permalink
[RF] Only subtract NLL offset when not hidden in new BatchMode
Browse files Browse the repository at this point in the history
The old test statistics did not apply the offset subtraction if
`RooAbsReal::hideOffset()` was `true`, and the new BatchMode should do
the same.
  • Loading branch information
guitargeek committed Oct 26, 2022
1 parent be2dffe commit aa51f65
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
1 change: 1 addition & 0 deletions roofit/roofitcore/res/RooNLLVarNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class RooNLLVarNew : public RooAbsReal {
private:
double evaluate() const override { return _value; }
void resetWeightVarNames();
double getFinalValAfterOffsetting(ROOT::Math::KahanSum<double> &&result) const;

RooTemplateProxy<RooAbsPdf> _pdf;
RooArgSet _observables;
Expand Down
46 changes: 20 additions & 26 deletions roofit/roofitcore/src/RooNLLVarNew.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,7 @@ void RooNLLVarNew::computeBatch(cudaStream_t * /*stream*/, double *output, size_
result += sumWeightKahanSum.Sum() * std::log(static_cast<double>(_simCount));
}

// Check if value offset flag is set.
if (_doOffset) {

// If no offset is stored enable this feature now
if (_offset == 0 && result != 0) {
_offset = result;
}

// Subtract offset
result -= _offset;
}

output[0] = result.Sum();
output[0] = getFinalValAfterOffsetting(std::move(result));

return;
}
Expand Down Expand Up @@ -228,19 +216,7 @@ void RooNLLVarNew::computeBatch(cudaStream_t * /*stream*/, double *output, size_
kahanProb += _sumWeight * std::log(static_cast<double>(_simCount));
}

// Check if value offset flag is set.
if (_doOffset) {

// If no offset is stored enable this feature now
if (_offset == 0 && kahanProb != 0) {
_offset = kahanProb;
}

// Subtract offset
kahanProb -= _offset;
}

output[0] = kahanProb.Sum();
output[0] = getFinalValAfterOffsetting(std::move(kahanProb));
}

void RooNLLVarNew::getParametersHook(const RooArgSet * /*nset*/, RooArgSet *params, bool /*stripDisconnected*/) const
Expand Down Expand Up @@ -310,3 +286,21 @@ RooNLLVarNew::fillNormSetForServer(RooArgSet const & /*normSet*/, RooAbsArg cons
}
return nullptr;
}

double RooNLLVarNew::getFinalValAfterOffsetting(ROOT::Math::KahanSum<double> &&result) const
{
// Check if value offset flag is set.
if (_doOffset) {

// If no offset is stored enable this feature now
if (_offset == 0 && result != 0) {
_offset = result;
}

// Subtract offset
if (!RooAbsReal::hideOffset()) {
result -= _offset;
}
}
return result.Sum();
}

0 comments on commit aa51f65

Please sign in to comment.