Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Revert "[TDF] Allow to SnapShot also when multiple files in input are…
… considered"

This reverts commit e884c50.
  • Loading branch information
eguiraud committed Jun 2, 2017
commit a657c25d26e6f8cbd087f1b0bb7cd745be1dbe8c
16 changes: 4 additions & 12 deletions tree/treeplayer/inc/ROOT/TDFInterface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public:
std::stringstream snapCall;
// build a string equivalent to
// "reinterpret_cast</nodetype/*>(this)->Snapshot<Ts...>(treename,filename,*reinterpret_cast<ColumnNames_t*>(&bnames))"
snapCall << "if (gROOTMutex) gROOTMutex->UnLock(); ((" << GetNodeTypeName() << "*)" << this << ")->Snapshot<";
snapCall << "((" << GetNodeTypeName() << "*)" << this << ")->Snapshot<";
bool first = true;
for (auto &b : bnames) {
if (!first) snapCall << ", ";
Expand Down Expand Up @@ -1084,23 +1084,16 @@ protected:
throw std::runtime_error(err_msg.c_str());
}

auto df = GetDataFrameChecked();
auto inputTree = df->GetTree();

if (!ROOT::IsImplicitMTEnabled()) {
std::unique_ptr<TFile> ofile(TFile::Open(filenameInt.c_str(), "RECREATE"));
TTree t(treenameInt.c_str(), treenameInt.c_str());

bool FirstEvent = true;
auto fillTree = [&t, &bnames, &FirstEvent, &inputTree](Args &... args) {
auto fillTree = [&t, &bnames, &FirstEvent](Args &... args) {
if (FirstEvent) {
// hack to call TTree::Branch on all variadic template arguments
std::initializer_list<int> expander = {(t.Branch(bnames[S].c_str(), &args), 0)..., 0};
(void)expander; // avoid unused variable warnings for older compilers such as gcc 4.9
// We need this in case we have multiple input file to rotate the pointers
// associated to the branches. This is in ROOT since forever to allow cloning of
// TChains and here, de facto, we are doing a clone.
inputTree->AddClone(&t);
FirstEvent = false;
}
t.Fill();
Expand All @@ -1109,17 +1102,16 @@ protected:
Foreach(fillTree, {bnames[S]...});
t.Write();
} else {
auto df = GetDataFrameChecked();
unsigned int nSlots = df->GetNSlots();
TBufferMerger merger (filenameInt.c_str(), "RECREATE");
TBufferMerger merger(filenameInt.c_str(), "RECREATE");
std::vector<std::shared_ptr<TBufferMergerFile>> files(nSlots);
std::vector<TTree *> trees(nSlots);

auto fillTree = [&](unsigned int slot, Args &... args) {
R__LOCKGUARD(gROOTMutex);
if (!trees[slot]) {
files[slot] = merger.GetFile();
trees[slot] = new TTree(treenameInt.c_str(), treenameInt.c_str());
// FIXME Here the tree needs to be added to the list of clones of the right chain
trees[slot]->ResetBit(kMustCleanup);
// hack to call TTree::Branch on all variadic template arguments
std::initializer_list<int> expander = {(trees[slot]->Branch(bnames[S].c_str(), &args), 0)..., 0};
Expand Down