Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eb8632c
[NFC] Fix white space.
hageboeck Sep 5, 2025
709d6da
[NFC] Remove stray whitespaces.
hageboeck Sep 9, 2025
a01aeee
[RF] Disable codegen backends in RooFit tests when clad=off.
hageboeck Nov 3, 2025
974638f
[Core] Initialise gEnv pointer.
hageboeck Mar 20, 2025
ac051c2
[hist] Make TEfficiency aware of TH1::AddDirectoryStatus.
hageboeck Sep 4, 2025
1eadddf
[roottest] Move hist ownership test from diffs to programmatic test.
hageboeck Sep 8, 2025
2a174e8
[hist] Mask SetDirectory(...) lines from SaveAs test.
hageboeck Sep 9, 2025
29bc512
[hist] Make the MapCppName test independent of gDirectory.
hageboeck Sep 9, 2025
84751f9
[hf] Explicitly write histograms in makeExample.C tutorial.
hageboeck Sep 9, 2025
ceb5d7b
[PyROOT] Make TFile context manager test/tutorial ready for ROOT 7.
hageboeck Sep 9, 2025
a2f1515
[PyROOT] Prepare for implicit object ownership = off.
hageboeck Sep 9, 2025
9bf6e97
[tutorials] Make hsimple ready for implicit object ownership=off.
hageboeck Sep 9, 2025
00c518e
[io] Prepare TFileMergerTest for implicit ownership = off.
hageboeck Sep 9, 2025
b75375b
[roottest] Prepare execFileMerger for implicit ownership = off.
hageboeck Sep 9, 2025
c4d7e32
[NFC] Fix stray white spaces.
hageboeck Sep 9, 2025
088b279
[hist] Ensure that items in THStack have the cleanup bit set.
hageboeck Sep 9, 2025
e09adf7
[hf] Prepare HistFactory for ROOT without implicit ownership.
hageboeck Sep 9, 2025
3189fd2
[RF] Prepare RooFit for ROOT without implicit ownership.
hageboeck Sep 9, 2025
917f546
[PyROOT] Remove a test that worked just by chance.
hageboeck Sep 9, 2025
b1ea3e2
[PyROOT] Prepare tests for ROOT with implicit ownership = off.
hageboeck Sep 9, 2025
b88100c
[hist] Actively add histograms to ROOT directory in FitSlices / Project.
hageboeck Sep 9, 2025
6784521
[SPLIT?] Prepare hist and directory for ROOT without implicit ownership.
hageboeck Sep 9, 2025
74c62f4
[core] Make TDirectory::Append tolerant to identical objects.
hageboeck Sep 16, 2025
e1768a2
Prepare test/stress for ROOT without implicit object ownership.
hageboeck Sep 16, 2025
72f19bc
[roottest] Fix output file path in nbdiff.py
hageboeck Sep 17, 2025
6287703
[Revise] Make TH1 AddDirectory callback independent of ROOT 7 mode.
hageboeck Sep 23, 2025
6d1738d
[roottest] Make notebook test independent of ownership model.
hageboeck Oct 23, 2025
35eb7ae
[Tutorials] Solve ownership problem in combinedFit.C
hageboeck Oct 24, 2025
ed91f24
[roottest] Make multicore/fork tutorial robust w.r.t. impl. ownership
hageboeck Oct 24, 2025
b291286
[RFile] Prepare RFile test for implicit object ownership off.
hageboeck Oct 27, 2025
415a648
Prepare a stressGraphics test for ROOT7 object ownership.
hageboeck Nov 3, 2025
1a0ecc2
[core] Add ROOT::Experimental::DisableImplicitObjectOwnership()
hageboeck Mar 20, 2025
272a3ea
[hist] Propagate implicit object registration settings to TH1 and der…
hageboeck Sep 5, 2025
385bd25
[core] Propagate implicit object ownership settings to TDirectory.
hageboeck Sep 5, 2025
13a2d70
[RF] Propagate implicit object registration settings to RooPlot.
hageboeck Sep 5, 2025
9764fc6
[REVERT] Test switching off the implicit ownership in the CI.
hageboeck Nov 4, 2025
60f8808
Make unfold tutorials ready for implicit object ownership=off.
hageboeck Nov 4, 2025
2e866e7
Add a missing header to make testUnfold7c.C compilable.
hageboeck Nov 4, 2025
0ca4f8a
Prepare mlp for implicit memory management off.
hageboeck Nov 5, 2025
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
4 changes: 3 additions & 1 deletion .github/workflows/root-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ jobs:
HOME: /Users/sftnight
INCREMENTAL: ${{ !contains(github.event.pull_request.labels.*.name, 'clean build') && !matrix.platform == 'mac15' && !matrix.platform == 'mac26'}}
GITHUB_PR_ORIGIN: ${{ github.event.pull_request.head.repo.clone_url }}
run: ".github/workflows/root-ci-config/build_root.py
ROOT_IMPLICIT_OWNERSHIP: silentOff
run: ".github/workflows/root-ci-config/build_root.py
--buildtype RelWithDebInfo
--incremental $INCREMENTAL
--base_ref ${{ github.base_ref }}
Expand Down Expand Up @@ -526,6 +527,7 @@ jobs:
INCREMENTAL: ${{ !contains(github.event.pull_request.labels.*.name, 'clean build') }}
GITHUB_PR_ORIGIN: ${{ github.event.pull_request.head.repo.clone_url }}
CMAKE_GENERATOR: ${{ matrix.cmake_generator }}
ROOT_IMPLICIT_OWNERSHIP: silentOff
run: ".github/workflows/root-ci-config/build_root.py
--buildtype RelWithDebInfo
--platform ${{ matrix.image }}
Expand Down
11 changes: 7 additions & 4 deletions bindings/pyroot/pythonizations/test/memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ROOT
import gc
import os
import unittest

Check failure on line 4 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/test/memory.py:1:1: I001 Import block is un-sorted or un-formatted


def _leak(obj):
Expand All @@ -16,7 +16,7 @@
def test_tstyle_memory_management(self):
"""Regression test for https://github.com/root-project/root/issues/16918"""

h1 = ROOT.TH1F("h1", "", 100, 0, 10)

Check failure on line 19 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:19:9: F841 Local variable `h1` is assigned to but never used

style = ROOT.TStyle("NewSTYLE", "")
groot = ROOT.ROOT.GetROOT()
Expand All @@ -27,19 +27,19 @@
"""Regression test for https://github.com/root-project/root/issues/16942"""
# The test is just that the memory regulation works correctly and the
# application does not segfault
f2 = ROOT.TF2("f2", "sin(x)*sin(y)/x/y")

Check failure on line 30 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:30:9: F841 Local variable `f2` is assigned to but never used

def test_tf3_memory_regulation(self):
"""Make sure TF3 is properly managed by the memory regulation logic"""
# The test is just that the memory regulation works correctly and the
# application does not segfault
f3 = ROOT.TF3("f3","[0] * sin(x) + [1] * cos(y) + [2] * z",0,10,0,10,0,10)

Check failure on line 36 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:36:9: F841 Local variable `f3` is assigned to but never used

def test_tcolor_memory_regulation(self):
"""Make sure TColor is properly managed by the memory regulation logic"""
# The test is just that the memory regulation works correctly and the
# application does not segfault
c = ROOT.TColor(42, 42, 42)

Check failure on line 42 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:42:9: F841 Local variable `c` is assigned to but never used

def test_ttree_clone_in_file_context(self):
"""Test that CloneTree() doesn't give the ownership to Python when
Expand All @@ -49,8 +49,8 @@

ttree = ROOT.TTree("tree", "tree")

with ROOT.TFile(filename, "RECREATE") as infile:

Check failure on line 52 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:52:50: F841 Local variable `infile` is assigned to but never used
ttree_clone = ttree.CloneTree()

Check failure on line 53 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

bindings/pyroot/pythonizations/test/memory.py:53:13: F841 Local variable `ttree_clone` is assigned to but never used

os.remove(filename)

Expand Down Expand Up @@ -88,7 +88,7 @@
"TH1I": ("h", "h", 10, 0, 10),
"TH1L": ("h", "h", 10, 0, 10),
"TH1F": ("h", "h", 10, 0, 10),
"TH1D": ("h", "h", 10, 0, 10),

Check failure on line 91 in bindings/pyroot/pythonizations/test/memory.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F601)

bindings/pyroot/pythonizations/test/memory.py:91:13: F601 Dictionary key literal `"TH1D"` repeated
"TProfile": ("h", "h", 10, 0, 10),
"TH2C": ("h", "h", 10, 0, 10, 10, 0, 10),
"TH2S": ("h", "h", 10, 0, 10, 10, 0, 10),
Expand Down Expand Up @@ -127,11 +127,14 @@
"_check_object_setdirectory_in_memory_file_begin", "recreate")

x = klass(*args)
# TEfficiency does not automatically register with the directory
if not classname == "TEfficiency":
self.assertIs(x.GetDirectory(), f1)
x.SetDirectory(ROOT.nullptr)
# Actively register the object in case implicit ownership is off:
if not x.GetDirectory():
x.SetDirectory(f1)

self.assertIs(x.GetDirectory(), f1)
x.SetDirectory(ROOT.nullptr)
self.assertFalse(x.GetDirectory())

# Make sure that at this point the ownership of the object is with Python
ROOT.SetOwnership(x, True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def setUpClass(cls):
dir1.cd()
h1 = ROOT.TH1F("h1", "h1", cls.nbins, cls.xmin, cls.xmax)
ROOT.SetOwnership(h1, False)
h1.SetDirectory(dir1)

dir2 = dir1.mkdir("dir2")
dir2.cd()
h2 = ROOT.TH1F("h2", "h2", cls.nbins, cls.xmin, cls.xmax)
ROOT.SetOwnership(h2, False)
h2.SetDirectory(dir2)

def checkHisto(self, h):
xaxis = h.GetXaxis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def setUpClass(cls):
dir1.cd()
h1 = ROOT.TH1F("h1", "h1", cls.nbins, cls.xmin, cls.xmax)
ROOT.SetOwnership(h1, False)
h1.SetDirectory(dir1)

dir2 = dir1.mkdir("dir2")
dir2.cd()
h2 = ROOT.TH1F("h2", "h2", cls.nbins, cls.xmin, cls.xmax)
ROOT.SetOwnership(h2, False)
h2.SetDirectory(dir2)

def checkHisto(self, h):
xaxis = h.GetXaxis()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import unittest

import ROOT

from ROOT import TFile

Check failure on line 6 in bindings/pyroot/pythonizations/test/tfile_context_manager.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/test/tfile_context_manager.py:1:1: I001 Import block is un-sorted or un-formatted


class TFileContextManager(unittest.TestCase):
Expand Down Expand Up @@ -64,6 +64,7 @@
histoname = "myhisto_3"
with TFile(filename, "recreate") as outfile:
hout = ROOT.TH1F(histoname, histoname, self.NBINS, self.XMIN, self.XMAX)
hout.SetDirectory(outfile)
outfile.Write()

self.check_file_data(outfile, filename, histoname)
Expand Down
5 changes: 5 additions & 0 deletions core/base/inc/TROOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ namespace ROOT {
void DisableImplicitMT();
Bool_t IsImplicitMTEnabled();
UInt_t GetThreadPoolSize();
namespace Experimental {
void EnableImplicitObjectOwnership();
void DisableImplicitObjectOwnerhsip();
bool IsImplicitObjectOwnershipEnabled();
}
}

class TROOT : public TDirectory {
Expand Down
11 changes: 8 additions & 3 deletions core/base/src/TDirectory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,22 @@ TDirectory::TContext::~TContext()
/// ~~~ {.cpp}
/// TDirectory::AddDirectory
/// ~~~
/// \note When ROOT::Experimental::IsImplicitObjectOwnershipEnabled() is off, these settings
/// are without effect.

void TDirectory::AddDirectory(Bool_t add)
{
fgAddDirectory = add;
}

////////////////////////////////////////////////////////////////////////////////
/// Static function: see TDirectory::AddDirectory for more comments.

/// Check whether objects such as histograms or TGraphs2D should be owned by the current directory.
/// \copydetails AddDirectory(Bool_t)
/// \note ROOT::Experimental::IsImplicitObjectOwnershipEnabled() might lead to this
/// setting being always off, since it has higher precedence.
Bool_t TDirectory::AddDirectoryStatus()
{
return fgAddDirectory;
return ROOT::Experimental::IsImplicitObjectOwnershipEnabled() && fgAddDirectory;
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -205,6 +209,7 @@ void TDirectory::Append(TObject *obj, Bool_t replace /* = kFALSE */)
if (replace && obj->GetName() && obj->GetName()[0]) {
TObject *old;
while (nullptr != (old = GetList()->FindObject(obj->GetName()))) {
if (old == obj) return;
Warning("Append","Replacing existing %s: %s (Potential memory leak).",
obj->IsA()->GetName(),obj->GetName());
ROOT::DirAutoAdd_t func = old->IsA()->GetDirectoryAutoAdd();
Expand Down
4 changes: 1 addition & 3 deletions core/base/src/TEnv.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ into the local file by default.
#include "THashList.h"
#include "TError.h"


TEnv *gEnv; // main environment created in TROOT

TEnv *gEnv = nullptr; // main environment created in TROOT

static struct BoolNameTable_t {
const char *fName;
Expand Down
104 changes: 103 additions & 1 deletion core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ of a main program creating an interactive version is shown below:
#include <ROOT/RVersion.hxx>
#include "RConfigure.h"
#include "RConfigOptions.h"
#include <atomic>
#include <filesystem>
#include <string>
#include <map>
Expand Down Expand Up @@ -471,6 +472,49 @@ namespace Internal {
return isImplicitMTEnabled;
}

////////////////////////////////////////////////////////////////////////////////
/// \brief Test if objects such as TTree and TH1-derived classes should be implicitly owned
/// by gDirectory.
/// A default can be set in a .rootrc using "Root.ImplicitOwnership: 1" or setting
/// the environment variable "ROOT_IMPLICIT_OWNERSHIP=0".
static std::atomic_bool &IsImplicitOwnershipEnabled()
{
static std::atomic_bool initCompleted = false;
static std::atomic_bool implicitOwnership = true;

if (!initCompleted.load(std::memory_order_acquire)) {
R__LOCKGUARD(gROOTMutex);
// test again, because another thread might have raced us here
if (!initCompleted) {
int desiredValue = -1;
bool silent = false;
if (auto env = gSystem->Getenv("ROOT_IMPLICIT_OWNERSHIP"); env) {
if (strcmp(env, "silentOff") == 0) {
implicitOwnership = false;
silent = true;
} else {
try {
desiredValue = std::stoi(env);
} catch (std::invalid_argument& e) { }
if (desiredValue < 0) Error("TROOT", "ROOT_IMPLICIT_OWNERSHIP should be >= 0");
}
} else if (gEnv) {
desiredValue = gEnv->GetValue("Root.ImplicitOwnership", -1);
}

if (desiredValue == 0) {
if (!silent) Info("TROOT", "Implicit object ownership switched off by ROOT_IMPLICIT_OWNERSHIP or rootrc");
implicitOwnership = false;
} else if (desiredValue > 0) {
implicitOwnership = true;
}

initCompleted = true;
}
}

return implicitOwnership;
}
} // end of Internal sub namespace
// back to ROOT namespace

Expand Down Expand Up @@ -616,6 +660,64 @@ namespace Internal {
return 0;
#endif
}

namespace Experimental {
////////////////////////////////////////////////////////////////////////////////
/// \brief Switch ROOT's object ownership model to ROOT 6 mode.
///
/// In ROOT 6 mode, ROOT will implicitly assign ownership of histograms or TTrees
/// to the current \ref gDirectory, for example to the last TFile that was opened.
/// \code{.cpp}
/// TFile file(...);
/// TTree* tree = new TTree(...);
/// TH1D* histo = new TH1D(...);
/// file.Write(); // Both tree and histogram are in the file now
/// \endcode
///
/// In ROOT 7 mode, these objects won't register themselves to the current gDirectory,
/// so they are fully owned by the user. To write these to files, the user needs to do
/// one of the following:
/// - Explicitly transfer ownership:
/// \code{.cpp}
/// TFile file(...);
/// TTree* tree = new TTree(...);
/// tree->SetDirectory(&file);
/// \endcode
/// - Keep ownership of the object, but write explicitly:
/// \code{.cpp}
/// TFile file(...);
/// std::unique_ptr<TH1D> histo{new TH1D(...)};
/// file.WriteObject(histo.get(), "HistogramName");
/// file.Close();
/// // histo is still valid
/// \endcode
///
/// \note This setting has higher priority than TH1::AddDirectoryStatus() and TDirectory::AddDirectoryStatus().
/// These two will always evaluate to false if implicit ownership is off.
///
/// \copydetails ROOT::Internal::IsImplicitOwnershipEnabled()
void EnableImplicitObjectOwnerhsip()
{
Internal::IsImplicitOwnershipEnabled() = true;
}

////////////////////////////////////////////////////////////////////////////////
/// \brief Switch ROOT's object ownership model to ROOT 7 mode (no ownership).
/// \copydetails ROOT::Experimental::EnableImplicitObjectOwnership()
void DisableImplicitObjectOwnerhsip()
{
Internal::IsImplicitOwnershipEnabled() = false;
}

////////////////////////////////////////////////////////////////////////////////
/// Test whether the current directory should take ownership of objects such as
/// TH1-derived classes, TTree, TEntryList etc.
/// \copydetails ROOT::Experimental::EnableImplicitObjectOwnership()
bool IsImplicitObjectOwnershipEnabled()
{
return Internal::IsImplicitOwnershipEnabled();
}
}
} // end of ROOT namespace

TROOT *ROOT::Internal::gROOTLocal = ROOT::GetROOT();
Expand Down Expand Up @@ -2828,7 +2930,7 @@ void TROOT::SetBatch(Bool_t batch)
/// interactive mode.
/// - "server:port": turns the web display into server mode with specified port. Web widgets will not be displayed,
/// only text message with window URL will be printed on standard output
///
///
/// \note See more details related to webdisplay on RWebWindowsManager::ShowWindow

void TROOT::SetWebDisplay(const char *webdisplay)
Expand Down
5 changes: 3 additions & 2 deletions hist/hist/src/TEfficiency.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1503,15 +1503,16 @@ Double_t TEfficiency::BetaMode(Double_t a,Double_t b)
/// Notes:
/// - calls: SetName(name), SetTitle(title)
/// - set the statistic option to the default (kFCP)
/// - appends this object to the current directory SetDirectory(gDirectory)
/// - appends this object to the current directory SetDirectory(gDirectory) if
/// TH1::AddDirectoryStatus() is active.

void TEfficiency::Build(const char* name,const char* title)
{
SetName(name);
SetTitle(title);

SetStatisticOption(kDefStatOpt);
SetDirectory(gDirectory);
if (TH1::AddDirectoryStatus()) SetDirectory(gDirectory);

SetBit(kPosteriorMode,false);
SetBit(kShortestInterval,false);
Expand Down
28 changes: 15 additions & 13 deletions hist/hist/src/TH1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -736,11 +736,13 @@ TH1::TH1(const char *name,const char *title,Int_t nbins,const Double_t *xbins)
}

////////////////////////////////////////////////////////////////////////////////
/// Static function: cannot be inlined on Windows/NT.
/// Check whether TH1-derived classes are owned by the current gDirectory.
/// \note ROOT::Experimental::IsImplicitObjectOwnershipEnabled() might lead to this
/// setting being always off, since it has higher precedence.

Bool_t TH1::AddDirectoryStatus()
{
return fgAddDirectory;
return ROOT::Experimental::IsImplicitObjectOwnershipEnabled() && fgAddDirectory;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1249,16 +1251,19 @@ Bool_t TH1::Add(const TH1 *h1, const TH1 *h2, Double_t c1, Double_t c2)
}

////////////////////////////////////////////////////////////////////////////////
/// Sets the flag controlling the automatic add of histograms in memory
/// Sets the flag controlling the automatic add of histograms in memory.
///
/// By default (fAddDirectory = kTRUE), histograms are automatically added
/// to the list of objects in memory.
/// to the current directory (gDirectory).
/// Note that one histogram can be removed from its support directory
/// by calling h->SetDirectory(nullptr) or h->SetDirectory(dir) to add it
/// to the list of objects in the directory dir.
///
/// NOTE that this is a static function. To call it, use;
/// TH1::AddDirectory
/// This is a static function. To call it, use `TH1::AddDirectory`
///
/// \note When ROOT::Experimental::IsImplicitOwnershipEnabled() is off, AddDirectory is
/// without effect.
///

void TH1::AddDirectory(Bool_t add)
{
Expand Down Expand Up @@ -2720,7 +2725,7 @@ void TH1::Copy(TObject &obj) const
// will be added to gDirectory independently of the fDirectory stored.
// and if the AddDirectoryStatus() is false it will not be added to
// any directory (fDirectory = nullptr)
if (fgAddDirectory && gDirectory) {
if (AddDirectoryStatus() && gDirectory) {
gDirectory->Append(&obj);
((TH1&)obj).fFunctions->UseRWLock();
((TH1&)obj).fDirectory = gDirectory;
Expand Down Expand Up @@ -2776,16 +2781,13 @@ TObject* TH1::Clone(const char* newname) const
}

////////////////////////////////////////////////////////////////////////////////
/// Perform the automatic addition of the histogram to the given directory
/// Callback to perform the automatic addition of the histogram to the given directory.
///
/// Note this function is called in place when the semantic requires
/// this object to be added to a directory (I.e. when being read from
/// a TKey or being Cloned)
/// This callback is called when a TKey is read or an object is being Cloned.

void TH1::DirectoryAutoAdd(TDirectory *dir)
{
Bool_t addStatus = TH1::AddDirectoryStatus();
if (addStatus) {
if (fgAddDirectory) {
SetDirectory(dir);
if (dir) {
ResetBit(kCanDelete);
Expand Down
6 changes: 5 additions & 1 deletion hist/hist/src/TH2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ void TH2::DoFitSlices(bool onX,
} else {
hlist[ipar] = new TH1D(name,title, nOutBins, &bins->fArray[firstOutBin-1]);
}
hlist[ipar]->SetDirectory(gDirectory);
hlist[ipar]->GetXaxis()->SetTitle(outerAxis.GetTitle());
if (arr)
(*arr)[ipar] = hlist[ipar];
Expand All @@ -866,6 +867,7 @@ void TH2::DoFitSlices(bool onX,
} else {
hchi2 = new TH1D(name,"chisquare", nOutBins, &bins->fArray[firstOutBin-1]);
}
hchi2->SetDirectory(gDirectory);
hchi2->GetXaxis()->SetTitle(outerAxis.GetTitle());
if (arr)
(*arr)[npar] = hchi2;
Expand Down Expand Up @@ -2126,7 +2128,8 @@ TProfile *TH2::ProfileY(const char *name, Int_t firstxbin, Int_t lastxbin, Optio

////////////////////////////////////////////////////////////////////////////////
/// Internal (protected) method for performing projection on the X or Y axis
/// called by ProjectionX or ProjectionY
/// called by ProjectionX or ProjectionY.
/// The histograms created are added to gDirectory.

TH1D *TH2::DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
{
Expand Down Expand Up @@ -2239,6 +2242,7 @@ TH1D *TH2::DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbi
else
h1 = new TH1D(pname,GetTitle(),lastOutBin-firstOutBin+1,&bins->fArray[firstOutBin-1]);
}
h1->SetDirectory(gDirectory);
if (opt.Contains("e") || GetSumw2N() ) h1->Sumw2();
}
if (pname != name) delete [] pname;
Expand Down
1 change: 1 addition & 0 deletions hist/hist/src/THStack.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ void THStack::Add(TH1 *h1, Option_t *option)
}
if (!fHists) fHists = new TList();
fHists->Add(h1,option);
h1->SetBit(kMustCleanup); // The histogram is likely in multiple lists now
Modified(); //invalidate stack
}

Expand Down
Loading
Loading