Skip to content

Commit

Permalink
[tree] Propagate IMT settings of TChain to internal TTrees
Browse files Browse the repository at this point in the history
Fixes issue #8720
  • Loading branch information
dpiparo committed Apr 16, 2024
1 parent 2050ba9 commit 87d9b35
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tree/tree/src/TChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,7 @@ Long64_t TChain::LoadTree(Long64_t entry)
// (the friends of the chain will be updated in the
// next loop).
fTree->LoadTree(treeReadEntry);

if (fFriends) {
// The current tree has not changed but some of its friends might.
//
Expand Down Expand Up @@ -1528,6 +1529,10 @@ Long64_t TChain::LoadTree(Long64_t entry)
} else if (!fGlobalRegistration) {
fTree->ResetBit(kMustCleanup);
}
// Propagate the IMT settings
if (fTree) {
fTree->SetImplicitMT(fIMTEnabled);
}
}

fTreeNumber = treenum;
Expand Down
29 changes: 29 additions & 0 deletions tree/tree/test/ImplicitMT.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "TChain.h"
#include "TFile.h"
#include "TROOT.h"
#include "TSystem.h"
Expand Down Expand Up @@ -28,4 +29,32 @@ TEST(TTreeImplicitMT, flushBaskets)
gSystem->Unlink(ofileName);
}

//# 8720
TEST(TChainImplicitMT, propagateToTTree)
{
ROOT::DisableImplicitMT();

const auto fname0 = "propagateToTTree0.root";
const auto fname1 = "propagateToTTree1.root";
for (const auto fname : {fname0, fname1}) {
TFile f(fname, "RECREATE");
TTree t("e", "e");
t.Fill();
t.Write();
EXPECT_FALSE(t.GetImplicitMT());
}

TChain c("e");
c.SetImplicitMT(true);
c.Add(fname0);
c.Add(fname1);
c.LoadTree(0);
EXPECT_TRUE(c.GetTree()->GetImplicitMT());
c.LoadTree(1);
EXPECT_TRUE(c.GetTree()->GetImplicitMT());

gSystem->Unlink(fname0);
gSystem->Unlink(fname1);
}

#endif // R__USE_IMT

0 comments on commit 87d9b35

Please sign in to comment.