From eaf7287f97fdc5a10cc2f9f37de02b54f56e16a9 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 17 Nov 2026 17:53:40 +0100 Subject: [PATCH 1/2] [RF] Remove unused transient RooHistFunc::_unitNorm data member --- roofit/roofitcore/inc/RooHistFunc.h | 1 - roofit/roofitcore/src/RooHistFunc.cxx | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/roofit/roofitcore/inc/RooHistFunc.h b/roofit/roofitcore/inc/RooHistFunc.h index a234a8c959d0e..709c270fc5f0c 100644 --- a/roofit/roofitcore/inc/RooHistFunc.h +++ b/roofit/roofitcore/inc/RooHistFunc.h @@ -117,7 +117,6 @@ class RooHistFunc : public RooAbsReal { Int_t _intOrder = 0; ///< Interpolation order bool _cdfBoundaries = false; ///< Use boundary conditions for CDFs. mutable double _totVolume = 0.0; /// &&dataHist) diff --git a/roofit/roofitcore/src/RooHistFunc.cxx b/roofit/roofitcore/src/RooHistFunc.cxx index 22a7d78e2ec0b..43b42d8a5e285 100644 --- a/roofit/roofitcore/src/RooHistFunc.cxx +++ b/roofit/roofitcore/src/RooHistFunc.cxx @@ -137,8 +137,7 @@ RooHistFunc::RooHistFunc(const RooHistFunc& other, const char* name) : _dataHist(other._dataHist), _intOrder(other._intOrder), _cdfBoundaries(other._cdfBoundaries), - _totVolume(other._totVolume), - _unitNorm(other._unitNorm) + _totVolume(other._totVolume) { _histObsList.addClone(other._histObsList) ; From dc82bd116827bac2a117bc8425b6546e9d82320f Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 17 Nov 2026 18:06:17 +0100 Subject: [PATCH 2/2] [RF] Remove cloneAndOwnDataHist() methods of RooHistPdf and RooHistFunc The `RooHistFunc::cloneAndOwnDataHist()` and `RooHistPdf::cloneAndOwnDataHist()` were removed without deprecation period. They were only introduced in ROOT 6.28 by #12029 and are redundant with the `RooHistFunc` and `RooHistPdf` constructors that take a `std::unique_ptr`, introduced also in 6.28. This removal is keep the RooFit API surface under control. --- README/ReleaseNotes/v644/index.md | 1 + roofit/roofitcore/inc/RooHistFunc.h | 4 ---- roofit/roofitcore/inc/RooHistPdf.h | 4 ---- roofit/roofitcore/src/RooHistFunc.cxx | 7 ------ roofit/roofitcore/src/RooHistPdf.cxx | 23 +++++++++--------- roofit/xroofit/src/xRooNode.cxx | 34 ++++++++++++++------------- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/README/ReleaseNotes/v644/index.md b/README/ReleaseNotes/v644/index.md index dde65790e5f56..9fe0026c00d63 100644 --- a/README/ReleaseNotes/v644/index.md +++ b/README/ReleaseNotes/v644/index.md @@ -28,6 +28,7 @@ The following people have contributed to this new version: * The TMVA deep learning methods `MethodDL` (`TMVA::Types::kDL`) and `MethodDNN` (`TMVA::Types::kDNN`), together with all classes in the `TMVA::DNN` namespace and their helper classes `TMVA::Monitoring` and `Pattern`, are deprecated and will be removed in ROOT 6.46. Neural networks are nowadays trained with dedicated machine learning libraries, so maintaining a separate implementation with its own CPU, CUDA and cuDNN backends is no longer justified. Users are encouraged to train their models directly with these libraries, which integrate well with ROOT via the `ROOT.Experimental.ML.RDataLoader`, and to use SOFIE for inference in C++. The `TMVA_CNN_Classification` and `TMVA_RNN_Classification` tutorials are removed already, and the other TMVA tutorials do not use these methods anymore. We are aware that models trained with these methods may be stored in TMVA XML weight files and still be evaluated via `TMVA::Reader` in production workflows. If you need to keep running such models after ROOT 6.46, please reach out to the ROOT team by opening a [GitHub issue](https://github.com/root-project/root/issues) or posting on the [ROOT forum](https://root-forum.cern.ch/), so that a migration path to SOFIE can be provided. * The build options `tmva-cpu`, `tmva-gpu`, `tmva-cudnn` and `use_gsl_cblas` only affect the deprecated TMVA deep learning methods, so they are deprecated as well and will be removed in ROOT 6.46. The `tmva-cpu` option is now `OFF` by default, also with `-Dall=ON`, so `MethodDL` runs on a single thread without BLAS and `MethodDNN` cannot be trained, unless ROOT is configured with `-Dtmva-cpu=ON`. Evaluating existing weight files with `TMVA::Reader` works in both cases. +* The `RooHistFunc::cloneAndOwnDataHist()` and `RooHistPdf::cloneAndOwnDataHist()` were removed without deprecation period. They were only introduced in ROOT 6.28 and are redundant with the `RooHistFunc` and `RooHistPdf` constructors that take a `std::unique_ptr`, introduced also in 6.28. ## Build system diff --git a/roofit/roofitcore/inc/RooHistFunc.h b/roofit/roofitcore/inc/RooHistFunc.h index 709c270fc5f0c..9e5c2845a8824 100644 --- a/roofit/roofitcore/inc/RooHistFunc.h +++ b/roofit/roofitcore/inc/RooHistFunc.h @@ -49,10 +49,6 @@ class RooHistFunc : public RooAbsReal { return *_dataHist ; } - /// Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone. - /// If the underlying RooDataHist is already owned, then that is returned instead of being cloned. - RooDataHist* cloneAndOwnDataHist(const char* newname=""); - /// Get total bin volume spanned by this hist function. /// In 1-d, this is e.g. the range spanned on the x-axis. double totVolume() const; diff --git a/roofit/roofitcore/inc/RooHistPdf.h b/roofit/roofitcore/inc/RooHistPdf.h index fca7be4daa530..25cd57614c5c0 100644 --- a/roofit/roofitcore/inc/RooHistPdf.h +++ b/roofit/roofitcore/inc/RooHistPdf.h @@ -48,10 +48,6 @@ class RooHistPdf : public RooAbsPdf { return *_dataHist ; } - /// Replaces underlying RooDataHist with a clone, which is now owned, and returns the clone. - /// If the underlying RooDataHist is already owned, then that is returned instead of being cloned. - RooDataHist* cloneAndOwnDataHist(const char* newname=""); - void setInterpolationOrder(Int_t order) { // Set histogram interpolation order _intOrder = order ; diff --git a/roofit/roofitcore/src/RooHistFunc.cxx b/roofit/roofitcore/src/RooHistFunc.cxx index 43b42d8a5e285..0439c31d22d34 100644 --- a/roofit/roofitcore/src/RooHistFunc.cxx +++ b/roofit/roofitcore/src/RooHistFunc.cxx @@ -246,13 +246,6 @@ double RooHistFunc::maxVal(Int_t code) const return max*1.05 ; } -RooDataHist* RooHistFunc::cloneAndOwnDataHist(const char* newname) { - if (_ownedDataHist) return _ownedDataHist.get(); - _ownedDataHist.reset(static_cast(_dataHist->Clone(newname))); - _dataHist = _ownedDataHist.get(); - return _dataHist; -} - //////////////////////////////////////////////////////////////////////////////// /// Return the total volume spanned by the observables of the RooDataHist diff --git a/roofit/roofitcore/src/RooHistPdf.cxx b/roofit/roofitcore/src/RooHistPdf.cxx index 2f8438e4848eb..8bf637c6f8c68 100644 --- a/roofit/roofitcore/src/RooHistPdf.cxx +++ b/roofit/roofitcore/src/RooHistPdf.cxx @@ -177,13 +177,6 @@ RooHistPdf::RooHistPdf(const RooHistPdf& other, const char* name) : _histObsList.addClone(other._histObsList) ; } -RooDataHist* RooHistPdf::cloneAndOwnDataHist(const char* newname) { - if (_ownedDataHist) return _ownedDataHist.get(); - _ownedDataHist.reset(static_cast(_dataHist->Clone(newname))); - _dataHist = _ownedDataHist.get(); - return _dataHist; -} - void RooHistPdf::clampNegativeBins() { const std::size_t nBins = _dataHist->numEntries(); @@ -209,10 +202,16 @@ void RooHistPdf::clampNegativeBins() "before constructing the RooHistPdf." << std::endl; - RooDataHist *dh = cloneAndOwnDataHist(); - const bool hasSumW2 = dh->sumW2Array() != nullptr; + // We'll mutate the content of the RooDataHist, so we have to create an + // internal clone to avoid impacting other places that use the RooDataHist + if (!_ownedDataHist) { + _ownedDataHist.reset(static_cast(_dataHist->Clone())); + _dataHist = _ownedDataHist.get(); + } + + const bool hasSumW2 = _dataHist->sumW2Array() != nullptr; for (std::size_t i = 0; i < nBins; ++i) { - if (dh->weight(i) < 0.) { + if (_dataHist->weight(i) < 0.) { // Keep the original bin error: clamping the content is a // normalization-consistency measure, not a statement that the bin is // now known exactly. The error still quantifies the statistical @@ -223,8 +222,8 @@ void RooHistPdf::clampNegativeBins() // for anyone retrieving the histogram via dataHist(), including any // future per-bin MC-stat treatment, where a zero error would wrongly // fix the bin at exactly zero. - const double wgtErr = hasSumW2 ? std::sqrt(std::max(dh->weightSquared(i), 0.)) : 0.; - dh->set(i, 0., wgtErr); + const double wgtErr = hasSumW2 ? std::sqrt(std::max(_dataHist->weightSquared(i), 0.)) : 0.; + _dataHist->set(i, 0., wgtErr); } } } diff --git a/roofit/xroofit/src/xRooNode.cxx b/roofit/xroofit/src/xRooNode.cxx index db76eafc9c511..c58cd37ca5c8d 100644 --- a/roofit/xroofit/src/xRooNode.cxx +++ b/roofit/xroofit/src/xRooNode.cxx @@ -3847,22 +3847,24 @@ xRooNode xRooNode::Vary(const xRooNode &child) if (!v->hasError()) v->setError(1); - std::shared_ptr up( - static_cast(f->Clone(Form("%s_%s_up", f->GetName(), parName.Data())))); - std::shared_ptr down( - static_cast(f->Clone(Form("%s_%s_down", f->GetName(), parName.Data())))); - // RooHistFunc doesn't clone it's data hist ... do it ourself (will be cloned again if imported into a ws) -#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00) - std::unique_ptr h1( - static_cast(f->dataHist().Clone(Form("hist_%s", up->GetName())))); - std::unique_ptr h2( - static_cast(f->dataHist().Clone(Form("hist_%s", down->GetName())))); - up->_dataHist = dynamic_cast(f->dataHist().Clone(Form("hist_%s", up->GetName()))); - down->_dataHist = dynamic_cast(f->dataHist().Clone(Form("hist_%s", down->GetName()))); -#else - up->cloneAndOwnDataHist(TString::Format("hist_%s", up->GetName())); - down->cloneAndOwnDataHist(TString::Format("hist_%s", down->GetName())); -#endif + auto upName = TString::Format("%s_%s_up", f->GetName(), parName.Data()); + auto upHistName = TString::Format("hist_%s", upName.Data()); + auto downName = TString::Format("%s_%s_down", f->GetName(), parName.Data()); + auto downHistName = TString::Format("hist_%s", downName.Data()); + + // RooHistFunc doesn't clone it's data hist ... do it ourself + // (will be cloned again if imported into a ws) + auto up = std::make_shared(upName, f->GetTitle(), f->variables(), + std::make_unique(f->dataHist(), upHistName), + f->getInterpolationOrder()); + up->setCdfBoundaries(f->getCdfBoundaries()); + + auto down = std::make_shared(downName, f->GetTitle(), f->variables(), + + std::make_unique(f->dataHist(), downHistName), + f->getInterpolationOrder()); + down->setCdfBoundaries(f->getCdfBoundaries()); + auto ups = std::dynamic_pointer_cast(acquire(up, false, true)); auto downs = std::dynamic_pointer_cast(acquire(down, false, true)); #if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)