Skip to content
Merged
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
2 changes: 1 addition & 1 deletion roofit/hs3/src/RooJSONFactoryWSTool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ inline bool checkRegularBins(const TAxis &ax)
double w = ax.GetXmax() - ax.GetXmin();
double bw = w / ax.GetNbins();
for (int i = 0; i <= ax.GetNbins(); ++i) {
if (fabs(ax.GetBinUpEdge(i) - (ax.GetXmin() + (bw * i))) > w * 1e-6)
if (std::abs(ax.GetBinUpEdge(i) - (ax.GetXmin() + (bw * i))) > w * 1e-6)
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions roofit/multiprocess/test/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ generate_ND_gaussian_pdf_nll(RooWorkspace &w, unsigned int n, unsigned long N_ev
double mean[n], sigma[n];
for (unsigned ix = 0; ix < n; ++ix) {
mean[ix] = RooRandom::randomGenerator()->Gaus(0, 2);
sigma[ix] = 0.1 + abs(RooRandom::randomGenerator()->Gaus(0, 2));
sigma[ix] = 0.1 + std::abs(RooRandom::randomGenerator()->Gaus(0, 2));
}

// create gaussians and also the observables and parameters they depend on
Expand Down Expand Up @@ -126,7 +126,7 @@ generate_ND_gaussian_pdf_nll(RooWorkspace &w, unsigned int n, unsigned long N_ev
std::ostringstream os;
os << "s" << ix;
dynamic_cast<RooRealVar *>(w.arg(os.str().c_str()))
->setVal(0.1 + abs(RooRandom::randomGenerator()->Gaus(0, 2)));
->setVal(0.1 + std::abs(RooRandom::randomGenerator()->Gaus(0, 2)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion roofit/roofit/src/RooBCPEffDecay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void RooBCPEffDecay::generateEvent(Int_t code)
// Accept event if T is in generated range
double maxDil = 1.0 ;
double al2 = _absLambda*_absLambda ;
double maxAcceptProb = (1+al2) + fabs(maxDil*_CPeigenval*_absLambda*_argLambda) + fabs(maxDil*(1-al2)/2);
double maxAcceptProb = (1+al2) + std::abs(maxDil*_CPeigenval*_absLambda*_argLambda) + std::abs(maxDil*(1-al2)/2);
double acceptProb = (1+al2)/2*(1-_tag*_delMistag)
- (_tag*(1-2*_avgMistag))*(_CPeigenval*_absLambda*_argLambda)*sin(_dm*tval)
- (_tag*(1-2*_avgMistag))*(1-al2)/2*cos(_dm*tval);
Expand Down
2 changes: 1 addition & 1 deletion roofit/roofit/src/RooBCPGenDecay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void RooBCPGenDecay::generateEvent(Int_t code)
// Accept event if T is in generated range
double maxDil = 1.0 ;
// 2 in next line is conservative and inefficient - allows for delMistag=1!
double maxAcceptProb = 2 + fabs(maxDil*_avgS) + fabs(maxDil*_avgC);
double maxAcceptProb = 2 + std::abs(maxDil*_avgS) + std::abs(maxDil*_avgC);
double acceptProb = (1-_tag*_delMistag + _mu*_tag*(1. - 2.*_avgMistag))
+ (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgS*sin(_dm*tval)
- (_tag*(1-2*_avgMistag) + _mu*(1. - _tag*_delMistag))*_avgC*cos(_dm*tval);
Expand Down
2 changes: 1 addition & 1 deletion roofit/roofit/src/RooBDecay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void RooBDecay::generateEvent(Int_t code)

double dgt = _dgamma*t/2;
double dmt = _dm*t;
double ft = fabs(t);
double ft = std::abs(t);
double f = exp(-ft/_tau)*(_f0*cosh(dgt)+_f1*sinh(dgt)+_f2*cos(dmt)+_f3*sin(dmt));
if(f < 0) {
cout << "RooBDecay::generateEvent(" << GetName() << ") ERROR: PDF value less than zero" << endl;
Expand Down
6 changes: 3 additions & 3 deletions roofit/roofit/src/RooBukinPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ double RooBukinPdf::evaluate() const
r4=sqrt(xi*xi+1);
r1=xi/r4;

if(fabs(xi) > exp(-6.)){
if(std::abs(xi) > exp(-6.)){
r5=xi/log(r4+xi);
}
else
Expand All @@ -113,7 +113,7 @@ double RooBukinPdf::evaluate() const

//--- Center
else if(x < x2) {
if(fabs(xi) > exp(-6.)) {
if(std::abs(xi) > exp(-6.)) {
r2=log(1 + 4 * xi * r4 * (x-Xp)/hp)/log(1+2*xi*(xi-r4));
r2=-r3*r2*r2;
}
Expand All @@ -128,7 +128,7 @@ double RooBukinPdf::evaluate() const
r2=rho2*(x-x2)*(x-x2)/(Xp-x2)/(Xp-x2)-r3 - 4 * r3 * (x-x2)/hp * r5 * r4/(r4+xi)/(r4+xi);
}

if(fabs(r2) > 100){
if(std::abs(r2) > 100){
fit_result = 0;
}
else{
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofit/src/RooCBShape.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ double RooCBShape::evaluate() const {
double t = (m-m0)/sigma;
if (alpha < 0) t = -t;

double absAlpha = fabs((double)alpha);
double absAlpha = std::abs((double)alpha);

if (t >= -absAlpha) {
return exp(-0.5*t*t);
Expand Down Expand Up @@ -119,10 +119,10 @@ double RooCBShape::analyticalIntegral(Int_t code, const char* rangeName) const
double result = 0.0;
bool useLog = false;

if( fabs(n-1.0) < 1.0e-05 )
if( std::abs(n-1.0) < 1.0e-05 )
useLog = true;

double sig = fabs((double)sigma);
double sig = std::abs((double)sigma);

double tmin = (m.min(rangeName)-m0)/sig;
double tmax = (m.max(rangeName)-m0)/sig;
Expand All @@ -133,7 +133,7 @@ double RooCBShape::analyticalIntegral(Int_t code, const char* rangeName) const
tmax = -tmp;
}

double absAlpha = fabs((double)alpha);
double absAlpha = std::abs((double)alpha);

if( tmin >= -absAlpha ) {
result += sig*sqrtPiOver2*( ApproxErf(tmax/sqrt2)
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofit/src/RooGExpModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace {
double logErfC(double xx)
{
double t,z,ans;
z=fabs(xx);
z=std::abs(xx);
t=1.0/(1.0+0.5*z);

if(xx >= 0.0)
Expand Down Expand Up @@ -469,10 +469,10 @@ double RooGExpModel::calcDecayConv(double sign, double tau, double sig, double r
sign *= fsign ; // modified FMV,08/13/03

double cFly;
if ((sign<0)&&(fabs(tau-rtau)<tau/260)) {
if ((sign<0)&&(std::abs(tau-rtau)<tau/260)) {

double MeanTau=0.5*(tau+rtau);
if (fabs(xp/MeanTau)>300) {
if (std::abs(xp/MeanTau)>300) {
return 0 ;
}

Expand Down Expand Up @@ -848,7 +848,7 @@ double RooGExpModel::calcSinConvNorm(double sign, double tau, double sig, double
double term2 = evalCerfInt(-fsign, rtau, fsign*umin2, fsign*umax2, c2)*fsign*sign;

// WVE Handle 0/0 numeric divergence
if (fabs(tau-rtau)<1e-10 && fabs(term1+term2)<1e-10) {
if (std::abs(tau-rtau)<1e-10 && std::abs(term1+term2)<1e-10) {
cout << "epsilon method" << endl ;
static double epsilon = 1e-4 ;
return calcSinConvNorm(sign,tau+epsilon,sig,rtau-epsilon,fsign,rangeName) ;
Expand Down
8 changes: 4 additions & 4 deletions roofit/roofit/src/RooIntegralMorph.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void RooIntegralMorph::MorphCacheElem::calculate(TIterator* dIter)
// Calculate additional offset to apply if bin ixlo does not have X value calculated at bin center
double xBinC = xmin + (i+0.5)*binw ;
double xOffset = xBinC-_calcX[i] ;
if (fabs(xOffset/binw)>1e-3) {
if (std::abs(xOffset/binw)>1e-3) {
double slope = (_yatX[i+1]-_yatX[i-1])/(_calcX[i+1]-_calcX[i-1]) ;
double newY = _yatX[i] + slope*xOffset ;
//cout << "bin " << i << " needs to be re-centered " << xOffset/binw << " slope = " << slope << " origY = " << _yatX[i] << " newY = " << newY << endl ;
Expand Down Expand Up @@ -481,7 +481,7 @@ void RooIntegralMorph::MorphCacheElem::fillGap(Int_t ixlo, Int_t ixhi, double sp


// Policy: If centration quality is better than 1% OR better than 1/10 of a bin, fill interval with linear interpolation
if (fabs(cq)<0.01 || fabs(cq*(ixhi-ixlo))<0.1 || ymid<_ycutoff ) {
if (std::abs(cq)<0.01 || std::abs(cq*(ixhi-ixlo))<0.1 || ymid<_ycutoff ) {

// Fill remaining gaps on either side with linear interpolation
if (iX-ixlo>1) {
Expand Down Expand Up @@ -584,7 +584,7 @@ void RooIntegralMorph::MorphCacheElem::findRange()

// Terminate if value of X no longer moves by >0.1 bin size
double X = _alpha->getVal()*x1 + (1-_alpha->getVal())*x2 ;
if (fabs(X-Xlast)/(xmax-xmin)<0.0001) {
if (std::abs(X-Xlast)/(xmax-xmin)<0.0001) {
break ;
}
Xlast=X ;
Expand Down Expand Up @@ -621,7 +621,7 @@ void RooIntegralMorph::MorphCacheElem::findRange()

// Terminate if value of X no longer moves by >0.1 bin size
double X = _alpha->getVal()*x1 + (1-_alpha->getVal())*x2 ;
if (fabs(X-Xlast)/(xmax-xmin)<0.0001) {
if (std::abs(X-Xlast)/(xmax-xmin)<0.0001) {
break ;
}
Xlast=X ;
Expand Down
6 changes: 3 additions & 3 deletions roofit/roofit/src/RooLagrangianMorphFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ inline double invertMatrix(const Matrix &matrix, Matrix &inverse)
// sanitize numeric problems
for (size_t i = 0; i < n; ++i)
for (size_t j = 0; j < n; ++j)
if (fabs(inverse(i, j)) < 1e-9)
if (std::abs(inverse(i, j)) < 1e-9)
inverse(i, j) = 0;
return condition;
}
Expand Down Expand Up @@ -1060,8 +1060,8 @@ inline void inverseSanity(const Matrix &matrix, const Matrix &inverse, double &u
if (inverse(i, j) > largestWeight) {
largestWeight = (double)inverse(i, j);
}
if (fabs(unity(i, j) - static_cast<int>(i == j)) > unityDeviation) {
unityDeviation = fabs((double)unity(i, j)) - static_cast<int>(i == j);
if (std::abs(unity(i, j) - static_cast<int>(i == j)) > unityDeviation) {
unityDeviation = std::abs((double)unity(i, j)) - static_cast<int>(i == j);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions roofit/roofit/src/RooNDKeysPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,9 @@ double RooNDKeysPdf::analyticalIntegral(Int_t code, const char* rangeName) const
chi[j] = (bi->xVarHi[j]-x[j])/weight[j];

if (chi[j]>0) // inVarRange
prob *= (0.5 + TMath::Erf(fabs(chi[j])/sqrt(2.))/2.);
prob *= (0.5 + TMath::Erf(std::abs(chi[j])/sqrt(2.))/2.);
else // outside Var range
prob *= (0.5 - TMath::Erf(fabs(chi[j])/sqrt(2.))/2.);
prob *= (0.5 - TMath::Erf(std::abs(chi[j])/sqrt(2.))/2.);
}

norm += prob * _wMap.at(_idx[bi->sIdcs[i]]);
Expand Down
4 changes: 2 additions & 2 deletions roofit/roofit/test/testRooBernstein.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void IntegrationChecker(double a0, double a1, double a2, double a3)
auto numInt_full = bern.createIntegral(x, "FULL");

// closure
EXPECT_LT(fabs(int_full->getVal() - int_range1->getVal() - int_range2->getVal() - int_range3->getVal()), 1e-10);
EXPECT_LT(fabs(numInt_full->getVal() - numInt_range1->getVal() - numInt_range2->getVal() - numInt_range3->getVal()), 1e-10);
EXPECT_LT(std::abs(int_full->getVal() - int_range1->getVal() - int_range2->getVal() - int_range3->getVal()), 1e-10);
EXPECT_LT(std::abs(numInt_full->getVal() - numInt_range1->getVal() - numInt_range2->getVal() - numInt_range3->getVal()), 1e-10);

// comparision with polynomial
double accAnaVsNum = 1.;
Expand Down
6 changes: 3 additions & 3 deletions roofit/roofitcore/inc/RooAbsPdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ class RooAbsPdf : public RooAbsReal {
static void verboseEval(Int_t stat) ;
static int verboseEval() ;

double extendedTerm(double sumEntries, double expected, double sumEntriesW2=0.0) const;
double extendedTerm(double sumEntries, RooArgSet const* nset, double sumEntriesW2=0.0) const;
double extendedTerm(RooAbsData const& data, bool weightSquared) const;
double extendedTerm(double sumEntries, double expected, double sumEntriesW2=0.0, bool doOffset=false) const;
double extendedTerm(double sumEntries, RooArgSet const* nset, double sumEntriesW2=0.0, bool doOffset=false) const;
double extendedTerm(RooAbsData const& data, bool weightSquared, bool doOffset=false) const;

void setNormRange(const char* rangeName) ;
const char* normRange() const {
Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/inc/RooGlobalFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ enum class BatchModeOption { Off, Cpu, Cuda, Old };

/// For setting the offset mode with the Offset() command argument to
/// RooAbsPdf::fitTo()
enum class OffsetMode { Off, Initial, Bin };
enum class OffsetMode { None, Initial, Bin };

namespace Experimental {

Expand Down
8 changes: 4 additions & 4 deletions roofit/roofitcore/inc/RooNLLVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class RooNLLVar : public RooAbsOptTestStatistic {
_batchEvaluations = on;
}

void templateRatioOffset(bool on = true) {
_templateRatioOffset = on;
void enableBinOffsetting(bool on = true) {
_doBinOffset = on;
}

using ComputeResult = std::pair<ROOT::Math::KahanSum<double>, double>;
Expand All @@ -73,7 +73,7 @@ class RooNLLVar : public RooAbsOptTestStatistic {
std::size_t firstEvent, std::size_t lastEvent);
static RooNLLVar::ComputeResult computeScalarFunc(const RooAbsPdf *pdfClone, RooAbsData *dataClone, RooArgSet *normSet,
bool weightSq, std::size_t stepSize, std::size_t firstEvent,
std::size_t lastEvent, bool templateRatioOffset=false);
std::size_t lastEvent, bool doBinOffset=false);

protected:

Expand All @@ -88,7 +88,7 @@ class RooNLLVar : public RooAbsOptTestStatistic {

bool _extended{false};
bool _batchEvaluations{false};
bool _templateRatioOffset{false};
bool _doBinOffset{false};
bool _weightSq{false}; ///< Apply weights squared?
mutable bool _first{true}; ///<!
ROOT::Math::KahanSum<double> _offsetSaveW2{0.0}; ///<!
Expand Down
2 changes: 2 additions & 0 deletions roofit/roofitcore/inc/RooPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class RooPlot : public TNamed, public RooPrintable {

static void fillItemsFromTList(Items & items, TList const& tlist);

void createInternalPlotVarClone();

protected:

RooPlot(const RooPlot& other) = delete; // cannot be copied
Expand Down
20 changes: 19 additions & 1 deletion roofit/roofitcore/src/BatchModeDataHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "RooFit/BatchModeDataHelpers.h"
#include <RooAbsData.h>
#include <RooDataHist.h>
#include "RooNLLVarNew.h"

#include <ROOT/StringUtils.hxx>
Expand All @@ -23,7 +24,9 @@
/// Spans with the weights and squared weights will be also stored in the map,
/// keyed with the names `_weight` and the `_weight_sumW2`. If the dataset is
/// unweighted, these weight spans will only contain the single value `1.0`.
/// Entries with zero weight will be skipped.
/// Entries with zero weight will be skipped. If the input dataset is a
/// RooDataHist, the output map will also contain an item for the key
/// `_bin_volume` with the bin volumes.
///
/// \return A `std::map` with spans keyed to name pointers.
/// \param[in] data The input dataset.
Expand Down Expand Up @@ -110,6 +113,21 @@ RooFit::BatchModeDataHelpers::getDataSpans(RooAbsData const &data, std::string_v
insert(RooNLLVarNew::weightVarNameSumW2, weightSumW2);
}

// Add also bin volume information if we are dealing with a RooDataHist
if (auto dataHist = dynamic_cast<RooDataHist const *>(&data)) {
buffers.emplace();
auto &buffer = buffers.top();
buffer.reserve(nNonZeroWeight);

for (std::size_t i = 0; i < nEvents; ++i) {
if (!hasZeroWeight[i]) {
buffer.push_back(dataHist->binVolume(i));
}
}

insert("_bin_volume", {buffer.data(), buffer.size()});
}

// Get the real-valued batches and cast the also to double branches to put in
// the data map
for (auto const &item : data.getBatches(0, nEvents)) {
Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/RooAbsCategory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ bool RooAbsCategory::isSignType(bool mustHaveZero) const
if (mustHaveZero && theStateNames.size() != 3) return false;

for (const auto& type : theStateNames) {
if (abs(type.second)>1)
if (std::abs(type.second)>1)
return false;
}

Expand Down
Loading