31 using RNTupleModel = ROOT::Experimental::RNTupleModel;
32 using RNTupleReader = ROOT::Experimental::RNTupleReader;
33 using RNTupleWriter = ROOT::Experimental::RNTupleWriter;
36 constexpr
char const* kNTupleFileName =
"ntpl002_vector.root";
39 constexpr
int kUpdateGuiFreq = 1000;
42 constexpr
int kNEvents = 25000;
48 auto model = RNTupleModel::Create();
52 std::shared_ptr<std::vector<float>> fldVpx = model->MakeField<std::vector<float>>(
"vpx");
53 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
54 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
55 auto fldVrand = model->MakeField<std::vector<float>>(
"vrand");
59 auto ntuple = RNTupleWriter::Recreate(std::move(model),
"F", kNTupleFileName);
61 TH1F hpx(
"hpx",
"This is the px distribution", 100, -4, 4);
64 auto c1 =
new TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500);
67 for (
int i = 0; i < kNEvents; i++) {
68 int npx =
static_cast<int>(gRandom->Rndm(1) * 15);
76 for (
int j = 0; j < npx; ++j) {
78 gRandom->Rannor(px, py);
80 auto random = gRandom->Rndm(1);
84 fldVpx->emplace_back(px);
85 fldVpy->emplace_back(py);
86 fldVpz->emplace_back(pz);
87 fldVrand->emplace_back(random);
91 if (i && (i % kUpdateGuiFreq) == 0) {
92 if (i == kUpdateGuiFreq) hpx.Draw();
95 if (gSystem->ProcessEvents())
113 auto model = RNTupleModel::Create();
116 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
120 auto ntuple = RNTupleReader::Open(std::move(model),
"F", kNTupleFileName);
126 TCanvas *c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 200, 10, 700, 500);
127 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
131 for (
auto entryId : *ntuple) {
132 ntuple->LoadEntry(entryId);
134 for (
auto px : *fldVpx) {
138 if (entryId && (entryId % kUpdateGuiFreq) == 0) {
139 if (entryId == kUpdateGuiFreq) h.Draw();
142 if (gSystem->ProcessEvents())
152 void ntpl002_vector()