1#ifndef TMVA_CHUNKLOADER
2#define TMVA_CHUNKLOADER
14namespace Experimental {
18template <
typename First,
typename... Rest>
33 template <
typename First_T>
42 template <
typename VecType>
53 template <
typename First_T,
typename... Rest_T>
66 template <
typename VecType,
typename... Rest_T>
80 template <
typename VecType>
84 std::size_t vec_size =
vec.size();
86 for (std::size_t i = 0; i < max_vec_size; i++) {
97 const std::vector<std::size_t> &maxVecSizes = std::vector<std::size_t>(),
98 const float vecPadding = 0.0)
113template <
typename... Args>
137 RChunkLoader(
const std::string &treeName,
const std::string &fileName,
const std::size_t chunkSize,
138 const std::vector<std::string> &cols,
const std::vector<std::string> &
filters = {},
139 const std::vector<std::size_t> &vecSizes = {},
const float vecPadding = 0.0)
155 std::pair<std::size_t, std::size_t>
162 long long start_l = currentRow;
166 .WithGlobalRange({start_l, std::numeric_limits<Long64_t>::max()});
187 auto x_filter = x_rdf.
Filter(
fFilters[0],
"RBatchGenerator_Filter_0");
188 for (
auto i = 1; i <
fFilters.size(); i++) {
189 auto name =
"RBatchGenerator_Filter_" + std::to_string(i);
195 auto myReport = x_ranged.Report();
198 x_ranged.Foreach(func,
fCols);
203 std::size_t processed_events = myReport.begin()->GetAll();
204 std::size_t passed_events = (myReport.end() - 1)->GetPass();
206 return std::make_pair(processed_events, passed_events);
219 auto myCount = x_ranged.Count();
222 x_ranged.Foreach(func,
fCols);
225 std::size_t processed_events = myCount.GetValue();
226 std::size_t passed_events = myCount.GetValue();
227 return std::make_pair(processed_events, passed_events);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
A dataset specification for RDataFrame.
RDatasetSpec & AddSample(RSample sample)
RInterface< RDFDetail::RFilter< F, Proxied >, DS_t > Filter(F f, const ColumnNames_t &columns={}, std::string_view name="")
Append a filter to the call graph.
RInterface< RDFDetail::RRange< Proxied >, DS_t > Range(unsigned int begin, unsigned int end, unsigned int stride=1)
Creates a node that filters entries based on range: [begin, end).
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
A "std::vector"-like collection of values implementing handy operation to analyse them.
void AssignVector(const ROOT::RVec< VecType > &vec)
Loop through the values of a given vector and load them into the RTensor Note: the given vec_size doe...
void AssignToTensor(const ROOT::RVec< VecType > &first, Rest_T... rest)
Recursively loop through the given values, and load them onto the fChunkTensor.
void AssignToTensor(First_T first)
Load the final given value into fChunkTensor.
void AssignToTensor(First_T first, Rest_T... rest)
Recursively loop through the given values, and load them onto the fChunkTensor.
RChunkLoaderFunctor(TMVA::Experimental::RTensor< float > &chunkTensor, const std::vector< std::size_t > &maxVecSizes=std::vector< std::size_t >(), const float vecPadding=0.0)
void operator()(First first, Rest... rest)
Loop through all columns of an event and put their values into an RTensor.
void AssignToTensor(const ROOT::RVec< VecType > &first)
Load the final given value into fChunkTensor.
TMVA::Experimental::RTensor< float > & fChunkTensor
std::vector< std::size_t > fMaxVecSizes
std::vector< std::string > fFilters
std::vector< std::string > fCols
RChunkLoader(const std::string &treeName, const std::string &fileName, const std::size_t chunkSize, const std::vector< std::string > &cols, const std::vector< std::string > &filters={}, const std::vector< std::size_t > &vecSizes={}, const float vecPadding=0.0)
Constructor for the RChunkLoader.
std::pair< std::size_t, std::size_t > loadNonFiltered(ROOT::RDataFrame &x_rdf, RChunkLoaderFunctor< Args... > &func)
Loop over the events in the dataframe untill either the end of the dataframe is reached,...
std::pair< std::size_t, std::size_t > loadFiltered(ROOT::RDataFrame &x_rdf, RChunkLoaderFunctor< Args... > &func)
Add filters to the RDataFrame and load a chunk of data.
std::pair< std::size_t, std::size_t > LoadChunk(TMVA::Experimental::RTensor< float > &chunkTensor, const std::size_t currentRow)
Load a chunk of data using the RChunkLoaderFunctor.
std::vector< std::size_t > fVecSizes
RTensor is a container with contiguous memory and shape information.
create variable transformations