Skip to content
Open
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
4 changes: 1 addition & 3 deletions roottest/root/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ ROOTTEST_ADD_TEST(typeguessing

ROOT_ADD_GTEST(misc test_misc.cxx LIBRARIES ROOT::ROOTDataFrame ROOT::GenVector)

ROOTTEST_ADD_TEST(ctors
MACRO test_ctors.C+
OUTREF test_ctors.ref)
ROOTTEST_ADD_TEST(ctors MACRO test_ctors.C+)

ROOTTEST_GENERATE_EXECUTABLE(branchoverwrite
test_branchoverwrite.cxx
Expand Down
21 changes: 11 additions & 10 deletions roottest/root/dataframe/Sentinel.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#ifndef SENTINEL
#define SENTINEL
#include <iostream>

class Sentinel {
static unsigned int fCtorCalls;
static unsigned int fDtorCalls;
static unsigned int fCopyCtorCalls;

public:
Sentinel() : x(0) {
std::cout << "ctor called" << std::endl;
}
Sentinel() : x(0) { fCtorCalls++; }

Sentinel(const Sentinel& o) : x(o.x) {
std::cout << "copy-ctor called" << std::endl;
}
Sentinel(const Sentinel &o) : x(o.x) {}

~Sentinel() {
std::cout << "dtor called" << std::endl;
}
~Sentinel() { fDtorCalls++; }

void set(int _x) { x = _x; }
int get() const { return x; }

static unsigned int GetCtorCalls() { return fCtorCalls; }
static unsigned int GetCopyCtorCalls() { return fCopyCtorCalls; }
static unsigned int GetDtorCalls() { return fDtorCalls; }

private:
int x;
};
Expand Down
20 changes: 9 additions & 11 deletions roottest/root/dataframe/testIMT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ void getTracks(unsigned int mu, FourVectors& tracks) {
// This makes the example stand-alone
void FillTree(const char* filename, const char* treeName) {
if (!gSystem->AccessPathName(filename)) return;
TFile f(filename,"RECREATE");
TTree t(treeName,treeName);
auto f = std::make_unique<TFile>(filename, "RECREATE");
auto t = std::make_unique<TTree>(treeName, treeName);
double b1;
int b2;
std::vector<FourVector> tracks;
std::vector<double> dv {-1,2,3,4};
std::list<int> sl {1,2,3,4};
t.Branch("b1", &b1);
t.Branch("b2", &b2);
t.Branch("tracks", &tracks);
t.Branch("dv", &dv);
t.Branch("sl", &sl);
t->Branch("b1", &b1);
t->Branch("b2", &b2);
t->Branch("tracks", &tracks);
t->Branch("dv", &dv);
t->Branch("sl", &sl);

int nevts = 16000;
for(int i = 0; i < nevts; ++i) {
Expand All @@ -77,11 +77,9 @@ void FillTree(const char* filename, const char* treeName) {

dv.emplace_back(i);
sl.emplace_back(i);
t.Fill();
t->Fill();
}
t.Write();
f.Close();
return;
f->Write();
}

auto fileName = "testIMT.root";
Expand Down
41 changes: 25 additions & 16 deletions roottest/root/dataframe/test_ctors.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
#include "TTree.h"
#include "ROOT/RDataFrame.hxx"
#include "Sentinel.h"

unsigned int Sentinel::fCtorCalls{};
unsigned int Sentinel::fDtorCalls{};
unsigned int Sentinel::fCopyCtorCalls{};

// test objects read from tree are constructed once per entry
void FillTree(const char* filename, const char* treeName) {
void FillTree(const char *filename, const char *treeName)
{
TFile f(filename, "RECREATE");
TTree t(treeName, treeName);
Sentinel o;
Expand All @@ -17,25 +23,28 @@ void FillTree(const char* filename, const char* treeName) {
f.Close();
}

void test_ctors() {
int test_ctors()
{
// Prepare an input tree to run on
auto fileName = "test_ctors.root";
auto treeName = "myTree";
std::cout << "filling tree...\n";
FillTree(fileName,treeName);
std::cout << "done\n";
FillTree(fileName, treeName);

// Filter, Define, Count and Foreach. We want one printout
std::cout << "building dataframe...\n";
ROOT::RDataFrame d(treeName, fileName, {"obj"});
std::cout << "done\nbuilding chain...\n";
auto dd = d.Filter([](const Sentinel& o) { std::cout << "filter\n"; return o.get() > 0; })
.Define("ox", [](const Sentinel& o) { std::cout << "addbranch\n"; return o.get(); });
ROOT::RDataFrame d(treeName, fileName);
auto dd = d.Filter([](const Sentinel &o) { return o.get() > 0; }, {"obj"})
.Define("ox", [](const Sentinel &o) { return o.get(); }, {"obj"});
auto r = dd.Count();
std::cout << "done\n";
std::cout << "running chain...\n";
dd.Foreach([](const Sentinel& o) { std::cout << "foreach: " << o.get() << std::endl; });
dd.Foreach([](const Sentinel &) {}, {"obj"});
auto c = *r;
std::cout << "done\n";
std::cout << "count: " << c << std::endl;

auto ctor_calls = Sentinel::GetCtorCalls();
auto copy_ctor_calls = Sentinel::GetCopyCtorCalls();
auto dtor_calls = Sentinel::GetDtorCalls();

// Exactly 3 Sentinel objects should have been constructed/destroyed: one in the FillTree function and one per each
// of the two entries read by RDataFrame.
if (c == 2 && ctor_calls == 3 && dtor_calls == 3 && copy_ctor_calls == 0)
return 0;

return 1;
}
18 changes: 0 additions & 18 deletions roottest/root/dataframe/test_ctors.ref

This file was deleted.

9 changes: 6 additions & 3 deletions roottest/root/dataframe/test_trainCache.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const auto lastEvt = 20;
const auto sumRef = 27.6706;
const auto epsilon = 0.001;
const auto refNBytes = 166;
const auto refNBytesRDF = 332;
// RDataFrame reads more than TTree in this particular case: the input branch is of a fundamental type (double), so
// RDataFrame will create an appropriate bulk column reader. For TTree leaves of fundamental types, the bulk API of
// TBranch will read the entire basket at every call, even if in this case we may actually use less.
const auto refNBytesRDF = 498;

class RBytesReadRAII
{
Expand Down Expand Up @@ -134,8 +137,8 @@ int WithRDF()
chain.GetTree()->PrintCacheStats();

if (refNBytesRDF != rbRAII.GetBytesRead()) {
std::cout << "With RDF: the bytes read (" << rbRAII.GetBytesRead()
<< ") are different from the reference (" << refNBytes << ")\n";
std::cout << "With RDF: the bytes read (" << rbRAII.GetBytesRead() << ") are different from the reference ("
<< refNBytesRDF << ")\n";
ret +=1;
}

Expand Down
12 changes: 6 additions & 6 deletions roottest/root/dataframe/test_trainCache.ref
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ Number of blocks in current cache..: 1, total size: 166
Sum is 27.6706
******TreeCache statistics for tree: TotemNtuple in file: bigFile.root ******
Number of branches in the cache ...: 1
Cache Efficiency ..................: 0.500000
Cache Efficiency ..................: 1.000000
Cache Efficiency Rel...............: 1.000000
Secondary Efficiency ..............: 0.000000
Secondary Efficiency Rel ..........: 0.000000
Learn entries......................: 100
Cached Reading.....................: 332 bytes in 1 transactions
Cached Reading.....................: 498 bytes in 1 transactions
Reading............................: 0 bytes in 0 uncached transactions
Readahead..........................: 256000 bytes with overhead = 3775 bytes
Average transaction................: 0.332000 Kbytes
Number of blocks in current cache..: 2, total size: 332
====> Bytes Read: 332
Readahead..........................: 256000 bytes with overhead = 10096 bytes
Average transaction................: 0.498000 Kbytes
Number of blocks in current cache..: 3, total size: 498
====> Bytes Read: 498
(int) 0
136 changes: 68 additions & 68 deletions tree/dataframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,73 +36,73 @@ if (runtime_cxxmodules AND WIN32)
endif()

set(RDATAFRAME_HEADERS
ROOT/RCsvDS.hxx
ROOT/RVecDS.hxx
ROOT/RDataFrame.hxx
ROOT/RDataSource.hxx
ROOT/RDFHelpers.hxx
ROOT/RLazyDS.hxx
ROOT/RNTupleDS.hxx
ROOT/RNTupleProcessorDS.hxx
ROOT/RResultHandle.hxx
ROOT/RResultPtr.hxx
ROOT/RRootDS.hxx
ROOT/RSnapshotOptions.hxx
ROOT/RTrivialDS.hxx
ROOT/RTTreeDS.hxx
ROOT/RDF/ActionHelpers.hxx
ROOT/RDF/ColumnReaderUtils.hxx
ROOT/RDF/GraphNode.hxx
ROOT/RDF/GraphUtils.hxx
ROOT/RDF/HistoModels.hxx
ROOT/RDF/InterfaceUtils.hxx
ROOT/RDF/RActionBase.hxx
ROOT/RDF/RAction.hxx
ROOT/RDF/RActionCustomLoader.hxx
ROOT/RDF/RActionSnapshot.hxx
ROOT/RDF/RActionImpl.hxx
ROOT/RDF/RColumnRegister.hxx
ROOT/RDF/RNewSampleNotifier.hxx
ROOT/RDF/RSampleInfo.hxx
ROOT/RDF/RDefineBase.hxx
ROOT/RDF/RDefaultValueFor.hxx
ROOT/RDF/RDefine.hxx
ROOT/RDF/RDefinePerSample.hxx
ROOT/RDF/RDefineReader.hxx
ROOT/RDF/RDSColumnReader.hxx
ROOT/RDF/RColumnReaderBase.hxx
ROOT/RDF/RCutFlowReport.hxx
ROOT/RDF/RDatasetSpec.hxx
ROOT/RDF/RDisplay.hxx
ROOT/RDF/RFilterBase.hxx
ROOT/RDF/RFilter.hxx
ROOT/RDF/RInterface.hxx
ROOT/RDF/RInterfaceBase.hxx
ROOT/RDF/RJittedAction.hxx
ROOT/RDF/RJittedDefine.hxx
ROOT/RDF/RJittedFilter.hxx
ROOT/RDF/RJittedVariation.hxx
ROOT/RDF/RLazyDSImpl.hxx
ROOT/RDF/RLoopManager.hxx
ROOT/RDF/RMergeableValue.hxx
ROOT/RDF/RMetaData.hxx
ROOT/RDF/RNodeBase.hxx
ROOT/RDF/RRangeBase.hxx
ROOT/RDF/RRange.hxx
ROOT/RDF/RResultMap.hxx
ROOT/RDF/RSample.hxx
ROOT/RDF/RFilterWithMissingValues.hxx
ROOT/RDF/RTreeColumnReader.hxx
ROOT/RDF/RVariation.hxx
ROOT/RDF/RVariationBase.hxx
ROOT/RDF/RVariationReader.hxx
ROOT/RDF/RVariationsDescription.hxx
ROOT/RDF/RVariedAction.hxx
ROOT/RDF/SnapshotHelpers.hxx
ROOT/RDF/CustomLoaderHelpers.hxx
ROOT/RDF/Utils.hxx
ROOT/RDF/PyROOTHelpers.hxx
ROOT/RDF/RDFDescription.hxx
ROOT/RCsvDS.hxx
ROOT/RVecDS.hxx
ROOT/RDataFrame.hxx
ROOT/RDataSource.hxx
ROOT/RDFHelpers.hxx
ROOT/RLazyDS.hxx
ROOT/RResultHandle.hxx
ROOT/RResultPtr.hxx
ROOT/RSnapshotOptions.hxx
ROOT/RTrivialDS.hxx
ROOT/RTTreeDS.hxx
ROOT/RDF/ActionHelpers.hxx
ROOT/RDF/ColumnReaderUtils.hxx
ROOT/RDF/GraphNode.hxx
ROOT/RDF/GraphUtils.hxx
ROOT/RDF/HistoModels.hxx
ROOT/RDF/InterfaceUtils.hxx
ROOT/RDF/RActionBase.hxx
ROOT/RDF/RAction.hxx
ROOT/RDF/RActionCustomLoader.hxx
ROOT/RDF/RActionSnapshot.hxx
ROOT/RDF/RActionImpl.hxx
ROOT/RDF/RColumnRegister.hxx
ROOT/RDF/RNewSampleNotifier.hxx
ROOT/RDF/RSampleInfo.hxx
ROOT/RDF/RDefineBase.hxx
ROOT/RDF/RDefaultValueFor.hxx
ROOT/RDF/RDefine.hxx
ROOT/RDF/RDefinePerSample.hxx
ROOT/RDF/RDefineReader.hxx
ROOT/RDF/RDSColumnReader.hxx
ROOT/RDF/RColumnReaderBase.hxx
ROOT/RDF/RCutFlowReport.hxx
ROOT/RDF/RDatasetSpec.hxx
ROOT/RDF/RDisplay.hxx
ROOT/RDF/RFilterBase.hxx
ROOT/RDF/RFilter.hxx
ROOT/RDF/RInterface.hxx
ROOT/RDF/RInterfaceBase.hxx
ROOT/RDF/RJittedAction.hxx
ROOT/RDF/RJittedDefine.hxx
ROOT/RDF/RJittedFilter.hxx
ROOT/RDF/RJittedVariation.hxx
ROOT/RDF/RLazyDSImpl.hxx
ROOT/RDF/RLoopManager.hxx
ROOT/RDF/RMaskedEntryRange.hxx
ROOT/RDF/RMergeableValue.hxx
ROOT/RDF/RMetaData.hxx
ROOT/RDF/RNodeBase.hxx
ROOT/RDF/RRangeBase.hxx
ROOT/RDF/RRange.hxx
ROOT/RDF/RResultMap.hxx
ROOT/RDF/RSample.hxx
ROOT/RDF/RFilterWithMissingValues.hxx
ROOT/RDF/RTreeColumnReader.hxx
ROOT/RDF/RVariation.hxx
ROOT/RDF/RVariationBase.hxx
ROOT/RDF/RVariationReader.hxx
ROOT/RDF/RVariationsDescription.hxx
ROOT/RDF/RVariedAction.hxx
ROOT/RDF/SnapshotHelpers.hxx
ROOT/RDF/CustomLoaderHelpers.hxx
ROOT/RDF/Utils.hxx
ROOT/RDF/PyROOTHelpers.hxx
ROOT/RDF/RDFDescription.hxx
ROOT/RNTupleDS.hxx
ROOT/RNTupleProcessorDS.hxx
)

ROOT_STANDARD_LIBRARY_PACKAGE(ROOTDataFrame
Expand Down Expand Up @@ -148,11 +148,11 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTDataFrame
src/RVariationBase.cxx
src/RVariationReader.cxx
src/RVariationsDescription.cxx
src/RRootDS.cxx
src/RTrivialDS.cxx
src/RDFDescription.cxx
src/RNTupleDS.cxx
src/RNTupleProcessorDS.cxx
src/RVecDS.cxx
DICTIONARY_OPTIONS
-writeEmptyRootPCM
${RDATAFRAME_EXTRA_INCLUDES}
Expand Down
1 change: 0 additions & 1 deletion tree/dataframe/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#pragma link C++ class ROOT::Internal::RDF::RIgnoreErrorLevelRAII-;
#pragma link C++ class ROOT::Internal::RDF::BufferedFillHelper-;
#pragma link C++ class ROOT::RDF::RTrivialDS-;
#pragma link C++ class ROOT::Internal::RDF::RRootDS-;
#pragma link C++ class ROOT::RDF::RCsvDS-;
#pragma link C++ class ROOT::Internal::RDF::MeanHelper-;
#pragma link C++ class ROOT::Internal::RDF::RColumnRegister-;
Expand Down
Loading