28constexpr char const* kNTupleFileName =
"ntpl002_vector.root";
31constexpr int kUpdateGuiFreq = 1000;
34constexpr int kNEvents = 25000;
44 std::shared_ptr<std::vector<float>> fldVpx = model->MakeField<std::vector<float>>(
"vpx");
45 auto fldVpy = model->MakeField<std::vector<float>>(
"vpy");
46 auto fldVpz = model->MakeField<std::vector<float>>(
"vpz");
47 auto fldVrand = model->MakeField<std::vector<float>>(
"vrand");
53 TH1F hpx(
"hpx",
"This is the px distribution", 100, -4, 4);
56 auto c1 =
new TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500);
59 for (
int i = 0; i < kNEvents; i++) {
60 int npx =
static_cast<int>(
gRandom->Rndm(1) * 15);
68 for (
int j = 0; j < npx; ++j) {
76 fldVpx->emplace_back(px);
77 fldVpy->emplace_back(py);
78 fldVpz->emplace_back(pz);
79 fldVrand->emplace_back(random);
83 if (i && (i % kUpdateGuiFreq) == 0) {
84 if (i == kUpdateGuiFreq) hpx.Draw();
108 auto fldVpx = model->MakeField<std::vector<float>>(
"vpx");
117 std::cout <<
"Entry number 42 in JSON format:" << std::endl;
120 TCanvas *
c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 200, 10, 700, 500);
121 TH1F h(
"h",
"This is the px distribution", 100, -4, 4);
125 for (
auto entryId : *reader) {
126 reader->LoadEntry(entryId);
128 for (
auto px : *fldVpx) {
132 if (entryId && (entryId % kUpdateGuiFreq) == 0) {
133 if (entryId == kUpdateGuiFreq)
h.Draw();
static std::unique_ptr< RNTupleModel > Create()
static std::unique_ptr< RNTupleReader > Open(std::string_view ntupleName, std::string_view storage, const ROOT::RNTupleReadOptions &options=ROOT::RNTupleReadOptions())
Open an RNTuple for reading.
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)