28constexpr int kNEvents = 10000;
30void Write(std::string_view ntupleName, std::string_view fileName)
34 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
35 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
36 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
37 auto fldN = model->MakeField<std::uint64_t>(
"vn");
41 for (
int i = 0; i < kNEvents; ++i) {
47 for (
int j = 0; j < *fldN; ++j) {
50 pz = px * px + py * py;
52 fldVpx->emplace_back(px);
53 fldVpy->emplace_back(py);
54 fldVpz->emplace_back(pz);
61void Read(
const std::vector<RNTupleOpenSpec> &ntuples)
63 auto c =
new TCanvas(
"c",
"RNTupleProcessor Example", 200, 10, 700, 500);
64 TH1F hPx(
"h",
"This is the px distribution", 100, -4, 4);
69 auto processor = RNTupleProcessor::CreateChain(ntuples);
70 int prevProcessorNumber{-1};
74 auto px = processor->RequestField<std::vector<float>>(
"vpx");
77 for (
auto idx : *processor) {
79 if (
static_cast<int>(processor->GetCurrentProcessorNumber()) > prevProcessorNumber) {
80 prevProcessorNumber = processor->GetCurrentProcessorNumber();
81 std::cout <<
"Processing `ntuple" << prevProcessorNumber + 1 <<
"` (" << idx + 1
82 <<
" total entries processed so far)" << std::endl;
91 std::cout <<
"Processed a total of " << processor->GetNEntriesProcessed() <<
" entries" << std::endl;
96void ntpl012_processor_chain()
98 Write(
"ntuple1",
"ntuple1.root");
99 Write(
"ntuple2",
"ntuple2.root");
100 Write(
"ntuple3",
"ntuple3.root");
104 std::vector<RNTupleOpenSpec> ntuples = {
105 {
"ntuple1",
"ntuple1.root"}, {
"ntuple2",
"ntuple2.root"}, {
"ntuple3",
"ntuple3.root"}};
Specification of the name and location of an RNTuple, used for creating a new RNTupleProcessor.
Interface for iterating over entries of vertically ("chained") and/or horizontally ("joined") combine...
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleWriter > Recreate(std::unique_ptr< ROOT::RNTupleModel > model, std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleWriteOptions &options=ROOT::RNTupleWriteOptions())
Creates an RNTupleWriter backed by storage, overwriting it if one with the same URI exists.
1-D histogram with a float per channel (see TH1 documentation)