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
1 change: 1 addition & 0 deletions tree/tree/inc/TChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class TChain : public TTree {
TFriendElement *AddFriend(TTree* chain, const char* alias = "", bool warn = false) override;
void Browse(TBrowser*) override;
virtual void CanDeleteRefs(bool flag = true);
virtual TTree *CopyTree(const char* selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override;
virtual void CreatePackets();
void DirectoryAutoAdd(TDirectory *) override;
Long64_t Draw(const char* varexp, const TCut& selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0) override;
Expand Down
18 changes: 18 additions & 0 deletions tree/tree/src/TChain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,24 @@ void TChain::CanDeleteRefs(bool flag /* = true */)
fCanDeleteRefs = flag;
}

////////////////////////////////////////////////////////////////////////////////
/// Copy a tree with selection.
///
/// See the documentation of TTree::CopyTree
///
/// ### Known limitations for TChain
/// - This method is not supported if used on an instance with friends

TTree* TChain::CopyTree(const char* selection, Option_t* option /* = 0 */, Long64_t nentries /* = TTree::kMaxEntries */, Long64_t firstentry /* = 0 */)
{
// A clear error for ROOT-10778
if (GetListOfFriends()) {
Error("CopyTree","TChain::CopyTree is not supported if the TChain instance has friends.");
return nullptr;
}
return this->TTree::CopyTree(selection, option, nentries, firstentry);
}

////////////////////////////////////////////////////////////////////////////////
/// Initialize the packet descriptor string.

Expand Down
13 changes: 13 additions & 0 deletions tree/tree/test/TChainRegressions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@
#include <TSystem.h>
#include <TTree.h>

#include "ROOT/TestSupport.hxx"
#include "gtest/gtest.h"

class TTreeCache;

// ROOT-10778
TEST(TChain, CopyTreeWithFriends)
{
TChain ch1("chain1");
TChain ch2("chain2");
ch1.AddFriend(&ch2);
ROOT::TestSupport::CheckDiagsRAII diags;
diags.requiredDiag(kError, "TChain::CopyTree",
"TChain::CopyTree is not supported if the TChain instance has friends.");
ch1.CopyTree("");
}

// https://its.cern.ch/jira/browse/ROOT-7973
TEST(TChain, WrongCacheReadTwoTrees)
{
Expand Down
Loading