24constexpr int kNEvents = 10000;
26void Write(std::string_view ntupleName, std::string_view fileName)
30 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
31 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
32 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
33 auto fldN = model->MakeField<std::uint64_t>(
"vn");
37 for (
int i = 0; i < kNEvents; ++i) {
43 for (
int j = 0; j < *fldN; ++j) {
46 pz = px * px + py * py;
48 fldVpx->emplace_back(px);
49 fldVpy->emplace_back(py);
50 fldVpz->emplace_back(pz);
57void Read(
const std::vector<ROOT::RNTupleInputSpec> &ntuples)
59 auto c =
new TCanvas(
"c",
"RNTupleProcessor Example", 200, 10, 700, 500);
60 TH1F hPx(
"h",
"This is the px distribution", 100, -4, 4);
69 auto px = processor->RequestField<std::vector<float>>(
"vpx");
72 for (
const auto &idx : *processor) {
74 processor->LoadEntry(idx);
81 std::cout <<
"Processed a total of " << processor->GetNEntriesProcessed() <<
" entries" << std::endl;
86void ntpl012_processor_chain()
88 Write(
"ntuple1",
"ntuple1.root");
89 Write(
"ntuple2",
"ntuple2.root");
90 Write(
"ntuple3",
"ntuple3.root");
94 std::vector<ROOT::RNTupleInputSpec> ntuples = {
95 {
"ntuple1",
"ntuple1.root"}, {
"ntuple2",
"ntuple2.root"}, {
"ntuple3",
"ntuple3.root"}};
R__EXTERN TRandom * gRandom
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleProcessor > CreateChain(std::vector< RNTupleInputSpec > ntuples, const RNTupleProcessorOptions &opts=RNTupleProcessorOptions())
Create an RNTupleProcessor for a chain (i.e., a vertical combination) of RNTuples.
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)
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].